Authored by chaogeng

Merge branch 'test6.8.9' of http://git.yoho.cn/datasync/yoho-datasync-fullsync into test6.8.9

@@ -89,6 +89,7 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService { @@ -89,6 +89,7 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService {
89 int indexPage = index; 89 int indexPage = index;
90 es.execute(() -> { 90 es.execute(() -> {
91 syncArticle(startTime, endTime, indexPage, pageSize); 91 syncArticle(startTime, endTime, indexPage, pageSize);
  92 +
92 }); 93 });
93 } 94 }
94 }finally { 95 }finally {
@@ -107,6 +108,13 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService { @@ -107,6 +108,13 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService {
107 syncArticleProduct(publicArticleList); 108 syncArticleProduct(publicArticleList);
108 //同步label 和 article_label表 109 //同步label 和 article_label表
109 syncArticleLabel(publicArticleList); 110 syncArticleLabel(publicArticleList);
  111 +
  112 + try {
  113 + Thread.sleep(200);
  114 + } catch (InterruptedException e) {
  115 + logger.warn("syncArticle syncArticle error !error{}", e);
  116 + }
  117 +
110 } 118 }
111 119
112 120
@@ -217,9 +225,8 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService { @@ -217,9 +225,8 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService {
217 for (GrassArticleBlock grassArticleBlock:grassArticleBlocks) { 225 for (GrassArticleBlock grassArticleBlock:grassArticleBlocks) {
218 //第一个image为默认封面图 226 //第一个image为默认封面图
219 if("image".equals(grassArticleBlock.getTemplateKey())){ 227 if("image".equals(grassArticleBlock.getTemplateKey())){
220 - String dataString = JSONObject.parseObject(grassArticleBlock.getContentData()).getString("data");  
221 - JSONObject block = JSONObject.parseObject(dataString);  
222 - return block.getString("src"); 228 + String dataString = getBlock(grassArticleBlock.getTemplateKey(),grassArticleBlock.getContentData(),true);
  229 + return dataString;
223 } 230 }
224 231
225 } 232 }
@@ -157,7 +157,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -157,7 +157,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
157 */ 157 */
158 private void syncPraiseByArticle(Integer startTime, Integer endTime){ 158 private void syncPraiseByArticle(Integer startTime, Integer endTime){
159 logger.info("syncPraiseByArticle begin, startTime is {}, endTime is {}", startTime, endTime); 159 logger.info("syncPraiseByArticle begin, startTime is {}, endTime is {}", startTime, endTime);
160 - ExecutorService es = Executors.newSingleThreadExecutor(); 160 + ExecutorService es = Executors.newFixedThreadPool(2);
161 int pageSize = 100; 161 int pageSize = 100;
162 Long startTimeLong = (long)startTime * 1000; 162 Long startTimeLong = (long)startTime * 1000;
163 Long endTimeLong = (long)endTime * 1000; 163 Long endTimeLong = (long)endTime * 1000;
@@ -170,6 +170,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -170,6 +170,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
170 int indexPage = index; 170 int indexPage = index;
171 es.execute(() -> { 171 es.execute(() -> {
172 syncPraiseByArticlePage(startTimeLong, endTimeLong, indexPage, pageSize); 172 syncPraiseByArticlePage(startTimeLong, endTimeLong, indexPage, pageSize);
  173 +
173 }); 174 });
174 } 175 }
175 }finally { 176 }finally {
@@ -191,6 +192,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -191,6 +192,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
191 logger.info("syncPraiseByArticlePage find grassArticlePraise num is {}", grassArticlePraiseList.size()); 192 logger.info("syncPraiseByArticlePage find grassArticlePraise num is {}", grassArticlePraiseList.size());
192 List<PublicUserPraise> needSyncData = buildPublicUserPraise(publicArticleIdAndGrassIdMap, nowArticleIdAndpublicArticleIdMap,grassArticlePraiseList); 193 List<PublicUserPraise> needSyncData = buildPublicUserPraise(publicArticleIdAndGrassIdMap, nowArticleIdAndpublicArticleIdMap,grassArticlePraiseList);
193 publicUserPraiseRepository.saveAll(needSyncData); 194 publicUserPraiseRepository.saveAll(needSyncData);
  195 + try {
  196 + Thread.sleep(200);
  197 + } catch (InterruptedException e) {
  198 + logger.warn(" sync error{}", e);
  199 + }
194 } 200 }
195 201
196 private List<PublicUserPraise> buildPublicUserPraise(Map<Integer, Integer> publicArticleIdAndGrassIdMap,Map<Integer, Integer> nowArticleIdAndpublicArticleIdMap, List<GrassArticlePraise> grassArticlePraiseList){ 202 private List<PublicUserPraise> buildPublicUserPraise(Map<Integer, Integer> publicArticleIdAndGrassIdMap,Map<Integer, Integer> nowArticleIdAndpublicArticleIdMap, List<GrassArticlePraise> grassArticlePraiseList){
@@ -238,7 +244,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -238,7 +244,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
238 */ 244 */
239 private void syncPraiseBySelf(Integer startTime, Integer endTime){ 245 private void syncPraiseBySelf(Integer startTime, Integer endTime){
240 logger.info("syncPraiseBySelf begin, startTime is {}, endTime is {}", startTime, endTime); 246 logger.info("syncPraiseBySelf begin, startTime is {}, endTime is {}", startTime, endTime);
241 - ExecutorService es = Executors.newSingleThreadExecutor(); 247 + ExecutorService es = Executors.newFixedThreadPool(2);
242 int pageSize = 100; 248 int pageSize = 100;
243 int total = grassArticlePraiseRepository.countByCreateTimeBetween(startTime, endTime); 249 int total = grassArticlePraiseRepository.countByCreateTimeBetween(startTime, endTime);
244 logger.info("syncPraiseBySelf get grassArticlePraise count is {}", total); 250 logger.info("syncPraiseBySelf get grassArticlePraise count is {}", total);
@@ -249,6 +255,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -249,6 +255,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
249 int indexPage = index; 255 int indexPage = index;
250 es.execute(() -> { 256 es.execute(() -> {
251 syncPraiseBySelfPage(startTime, endTime, indexPage, pageSize); 257 syncPraiseBySelfPage(startTime, endTime, indexPage, pageSize);
  258 +
252 }); 259 });
253 } 260 }
254 }finally { 261 }finally {
@@ -270,6 +277,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -270,6 +277,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
270 277
271 List<PublicUserPraise> needSyncData = buildPublicUserPraise(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, grassArticlePraiseList); 278 List<PublicUserPraise> needSyncData = buildPublicUserPraise(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, grassArticlePraiseList);
272 publicUserPraiseRepository.saveAll(needSyncData); 279 publicUserPraiseRepository.saveAll(needSyncData);
  280 + try {
  281 + Thread.sleep(200);
  282 + } catch (InterruptedException e) {
  283 + logger.warn("sync error{}", e);
  284 + }
273 } 285 }
274 286
275 287
@@ -280,7 +292,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -280,7 +292,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
280 */ 292 */
281 private void syncFavoriteByArticle(Integer startTime, Integer endTime){ 293 private void syncFavoriteByArticle(Integer startTime, Integer endTime){
282 logger.info("syncFavoriteByArticle begin, startTime is {}, endTime is {}", startTime, endTime); 294 logger.info("syncFavoriteByArticle begin, startTime is {}, endTime is {}", startTime, endTime);
283 - ExecutorService es = Executors.newSingleThreadExecutor(); 295 + ExecutorService es = Executors.newFixedThreadPool(2);
284 Long startTimeLong = (long)startTime * 1000; 296 Long startTimeLong = (long)startTime * 1000;
285 Long endTimeLong = (long)endTime * 1000; 297 Long endTimeLong = (long)endTime * 1000;
286 int pageSize = 100; 298 int pageSize = 100;
@@ -293,6 +305,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -293,6 +305,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
293 int indexPage = index; 305 int indexPage = index;
294 es.execute(() -> { 306 es.execute(() -> {
295 syncFavoriteByArticlePage(startTimeLong, endTimeLong, indexPage, pageSize); 307 syncFavoriteByArticlePage(startTimeLong, endTimeLong, indexPage, pageSize);
  308 +
296 }); 309 });
297 } 310 }
298 }finally { 311 }finally {
@@ -315,6 +328,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -315,6 +328,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
315 logger.info("syncFavoriteByArticlePage find userFavoriteArticle num is {}", userFavoriteArticleList.size()); 328 logger.info("syncFavoriteByArticlePage find userFavoriteArticle num is {}", userFavoriteArticleList.size());
316 List<PublicUserFavorite> needSyncData = buildPublicUserFavorite(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, userFavoriteArticleList); 329 List<PublicUserFavorite> needSyncData = buildPublicUserFavorite(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, userFavoriteArticleList);
317 publicUserFavoriteRepository.saveAll(needSyncData); 330 publicUserFavoriteRepository.saveAll(needSyncData);
  331 + try {
  332 + Thread.sleep(200);
  333 + } catch (InterruptedException e) {
  334 + logger.warn("sync error{}", e);
  335 + }
318 } 336 }
319 337
320 338
@@ -353,7 +371,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -353,7 +371,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
353 */ 371 */
354 private void syncFavoriteBySelf(Integer startTime, Integer endTime){ 372 private void syncFavoriteBySelf(Integer startTime, Integer endTime){
355 logger.info("syncFavoriteBySelf begin, startTime is {}, endTime is {}", startTime, endTime); 373 logger.info("syncFavoriteBySelf begin, startTime is {}, endTime is {}", startTime, endTime);
356 - ExecutorService es = Executors.newSingleThreadExecutor(); 374 + ExecutorService es = Executors.newFixedThreadPool(2);
357 int pageSize = 100; 375 int pageSize = 100;
358 int total = userFavoriteArticleRepository.countByCreateTimeBetween(startTime, endTime); 376 int total = userFavoriteArticleRepository.countByCreateTimeBetween(startTime, endTime);
359 logger.info("syncFavoriteBySelf get grassArticlePraise count is {}", total); 377 logger.info("syncFavoriteBySelf get grassArticlePraise count is {}", total);
@@ -364,6 +382,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -364,6 +382,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
364 int indexPage = index; 382 int indexPage = index;
365 es.execute(() -> { 383 es.execute(() -> {
366 syncFavoriteBySelfPage(startTime, endTime, indexPage, pageSize); 384 syncFavoriteBySelfPage(startTime, endTime, indexPage, pageSize);
  385 +
367 }); 386 });
368 } 387 }
369 }finally { 388 }finally {
@@ -385,6 +404,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -385,6 +404,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
385 404
386 List<PublicUserFavorite> needSyncData = buildPublicUserFavorite(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, userFavoriteArticleList); 405 List<PublicUserFavorite> needSyncData = buildPublicUserFavorite(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, userFavoriteArticleList);
387 publicUserFavoriteRepository.saveAll(needSyncData); 406 publicUserFavoriteRepository.saveAll(needSyncData);
  407 + try {
  408 + Thread.sleep(200);
  409 + } catch (InterruptedException e) {
  410 + logger.warn("sync error{}", e);
  411 + }
388 } 412 }
389 413
390 414
@@ -395,7 +419,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -395,7 +419,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
395 */ 419 */
396 private void syncUserAttention(Integer startTime, Integer endTime){ 420 private void syncUserAttention(Integer startTime, Integer endTime){
397 logger.info("syncUserAttention begin, startTime is {}, endTime is {}", startTime, endTime); 421 logger.info("syncUserAttention begin, startTime is {}, endTime is {}", startTime, endTime);
398 - ExecutorService es = Executors.newSingleThreadExecutor(); 422 + ExecutorService es = Executors.newFixedThreadPool(2);
399 int pageSize = 100; 423 int pageSize = 100;
400 int total = grassUserAttentionRepository.countByCreateTimeBetween(startTime, endTime); 424 int total = grassUserAttentionRepository.countByCreateTimeBetween(startTime, endTime);
401 logger.info("syncUserAttention get attention count is {}", total); 425 logger.info("syncUserAttention get attention count is {}", total);
@@ -406,6 +430,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -406,6 +430,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
406 int indexPage = index; 430 int indexPage = index;
407 es.execute(() -> { 431 es.execute(() -> {
408 syncUserAttentionPage(startTime, endTime, indexPage, pageSize); 432 syncUserAttentionPage(startTime, endTime, indexPage, pageSize);
  433 +
409 }); 434 });
410 } 435 }
411 }finally { 436 }finally {
@@ -420,6 +445,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -420,6 +445,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
420 445
421 List<PublicUserAttention> needSyncData = buildPublicUserAttention(grassUserAttentionList); 446 List<PublicUserAttention> needSyncData = buildPublicUserAttention(grassUserAttentionList);
422 publicUserAttentionRepository.saveAll(needSyncData); 447 publicUserAttentionRepository.saveAll(needSyncData);
  448 + try {
  449 + Thread.sleep(200);
  450 + } catch (InterruptedException e) {
  451 + logger.warn("sync error{}", e);
  452 + }
423 } 453 }
424 454
425 private List<PublicUserAttention> buildPublicUserAttention( List<GrassUserAttention> grassUserAttentionList){ 455 private List<PublicUserAttention> buildPublicUserAttention( List<GrassUserAttention> grassUserAttentionList){
@@ -465,7 +495,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -465,7 +495,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
465 */ 495 */
466 private void syncCommentsByArticle(Integer startTime, Integer endTime){ 496 private void syncCommentsByArticle(Integer startTime, Integer endTime){
467 logger.info("syncCommentsByArticle begin, startTime is {}, endTime is {}", startTime, endTime); 497 logger.info("syncCommentsByArticle begin, startTime is {}, endTime is {}", startTime, endTime);
468 - ExecutorService es = Executors.newSingleThreadExecutor(); 498 + ExecutorService es = Executors.newFixedThreadPool(2);
469 int pageSize = 100; 499 int pageSize = 100;
470 Long startTimeLong = (long)startTime * 1000; 500 Long startTimeLong = (long)startTime * 1000;
471 Long endTimeLong = (long)endTime * 1000; 501 Long endTimeLong = (long)endTime * 1000;
@@ -495,7 +525,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -495,7 +525,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
495 */ 525 */
496 private void syncCommentsBySelf(Integer startTime, Integer endTime){ 526 private void syncCommentsBySelf(Integer startTime, Integer endTime){
497 logger.info("syncCommentsBySelf begin, startTime is {}, endTime is {}", startTime, endTime); 527 logger.info("syncCommentsBySelf begin, startTime is {}, endTime is {}", startTime, endTime);
498 - ExecutorService es = Executors.newSingleThreadExecutor(); 528 + ExecutorService es = Executors.newFixedThreadPool(2);
499 int pageSize = 100; 529 int pageSize = 100;
500 int total = grassArticleCommentRepository.countByCreateTimeBetween(startTime, endTime); 530 int total = grassArticleCommentRepository.countByCreateTimeBetween(startTime, endTime);
501 logger.info("syncCommentsBySelf get grassArticlePraise count is {}", total); 531 logger.info("syncCommentsBySelf get grassArticlePraise count is {}", total);
@@ -554,6 +584,12 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -554,6 +584,12 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
554 584
555 buildAndSaveChildrenCommentBySelf(publicArticleIdAndGrassIdMap, grassChildrenArticleComments, relateIdMap); 585 buildAndSaveChildrenCommentBySelf(publicArticleIdAndGrassIdMap, grassChildrenArticleComments, relateIdMap);
556 586
  587 + try {
  588 + Thread.sleep(200);
  589 + } catch (InterruptedException e) {
  590 + logger.warn("sync error{}", e);
  591 + }
  592 +
557 } 593 }
558 594
559 /** 595 /**
@@ -587,6 +623,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -587,6 +623,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
587 623
588 //同步所有层级的子评论 624 //同步所有层级的子评论
589 buildAndSaveChildrenComment(publicArticleIdAndGrassIdMap,rootPublicComments, childrenComments, rootIdMap); 625 buildAndSaveChildrenComment(publicArticleIdAndGrassIdMap,rootPublicComments, childrenComments, rootIdMap);
  626 + try {
  627 + Thread.sleep(200);
  628 + } catch (InterruptedException e) {
  629 + logger.warn("sync error{}", e);
  630 + }
590 631
591 } 632 }
592 633
@@ -784,7 +825,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -784,7 +825,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
784 */ 825 */
785 private void syncCommentPraise(Integer startTime, Integer endTime){ 826 private void syncCommentPraise(Integer startTime, Integer endTime){
786 logger.info("syncCommentPraise begin, startTime is {}, endTime is {}", startTime, endTime); 827 logger.info("syncCommentPraise begin, startTime is {}, endTime is {}", startTime, endTime);
787 - ExecutorService es = Executors.newSingleThreadExecutor(); 828 + ExecutorService es = Executors.newFixedThreadPool(2);
788 int pageSize = 100; 829 int pageSize = 100;
789 int total = grassCommentPraiseRepository.countByCreateTimeBetween(startTime, endTime); 830 int total = grassCommentPraiseRepository.countByCreateTimeBetween(startTime, endTime);
790 logger.info("syncCommentPraise get commentPraise count is {}", total); 831 logger.info("syncCommentPraise get commentPraise count is {}", total);
@@ -820,6 +861,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -820,6 +861,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
820 861
821 List<PublicUserPraise> needSyncData = buildPublicUserPraise(relateIdMap, grassCommentPraiseList); 862 List<PublicUserPraise> needSyncData = buildPublicUserPraise(relateIdMap, grassCommentPraiseList);
822 publicUserPraiseRepository.saveAll(needSyncData); 863 publicUserPraiseRepository.saveAll(needSyncData);
  864 + try {
  865 + Thread.sleep(200);
  866 + } catch (InterruptedException e) {
  867 + logger.warn("sync error{}", e);
  868 + }
823 } 869 }
824 870
825 private List<PublicUserPraise> buildPublicUserPraise(Map<Integer, Integer> relateIdMap, List<GrassCommentPraise> grassCommentPraiseList){ 871 private List<PublicUserPraise> buildPublicUserPraise(Map<Integer, Integer> relateIdMap, List<GrassCommentPraise> grassCommentPraiseList){
@@ -60,7 +60,7 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService { @@ -60,7 +60,7 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService {
60 60
61 private void syncUserAchieveData(Integer startTime, Integer endTime){ 61 private void syncUserAchieveData(Integer startTime, Integer endTime){
62 logger.info("syncUserAchieveData begin, startTime is {}, endTime is {}", startTime, endTime); 62 logger.info("syncUserAchieveData begin, startTime is {}, endTime is {}", startTime, endTime);
63 - ExecutorService es = Executors.newSingleThreadExecutor(); 63 + ExecutorService es = Executors.newFixedThreadPool(2);
64 int total = grassUserAchieveRepository.countByCreateTimeBetween(startTime, endTime); 64 int total = grassUserAchieveRepository.countByCreateTimeBetween(startTime, endTime);
65 logger.info("syncUserAchieveData get grassArticlePraise count is {}", total); 65 logger.info("syncUserAchieveData get grassArticlePraise count is {}", total);
66 int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1; 66 int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1;
@@ -83,6 +83,11 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService { @@ -83,6 +83,11 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService {
83 List<PublicUserHomePage> needSyncData = buildPublicUserHomePage(grassUserAchieveList); 83 List<PublicUserHomePage> needSyncData = buildPublicUserHomePage(grassUserAchieveList);
84 logger.info("syncUserAchieveDataPage need sync data count is {}", needSyncData.size()); 84 logger.info("syncUserAchieveDataPage need sync data count is {}", needSyncData.size());
85 publicUserHomePageRepository.saveAll(needSyncData); 85 publicUserHomePageRepository.saveAll(needSyncData);
  86 + try {
  87 + Thread.sleep(200);
  88 + } catch (InterruptedException e) {
  89 + logger.warn("sync error{}", e);
  90 + }
86 } 91 }
87 92
88 private List<PublicUserHomePage> buildPublicUserHomePage( List<GrassUserAchieve> grassUserAchieveList ){ 93 private List<PublicUserHomePage> buildPublicUserHomePage( List<GrassUserAchieve> grassUserAchieveList ){
@@ -107,7 +112,7 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService { @@ -107,7 +112,7 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService {
107 112
108 private void syncVirtualUserData(Integer startTime, Integer endTime){ 113 private void syncVirtualUserData(Integer startTime, Integer endTime){
109 logger.info("syncVirtualUserData begin, startTime is {}, endTime is {}", startTime, endTime); 114 logger.info("syncVirtualUserData begin, startTime is {}, endTime is {}", startTime, endTime);
110 - ExecutorService es = Executors.newSingleThreadExecutor(); 115 + ExecutorService es = Executors.newFixedThreadPool(2);
111 int total = grassVirtualUserRepository.countByCreateTimeBetween(startTime, endTime); 116 int total = grassVirtualUserRepository.countByCreateTimeBetween(startTime, endTime);
112 logger.info("syncVirtualUserData get grassArticlePraise count is {}", total); 117 logger.info("syncVirtualUserData get grassArticlePraise count is {}", total);
113 int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1; 118 int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1;
@@ -130,6 +135,11 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService { @@ -130,6 +135,11 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService {
130 List<PublicVirtualUser> needSyncData = buildPublicVirtualUserPage(grassUserAchieveList); 135 List<PublicVirtualUser> needSyncData = buildPublicVirtualUserPage(grassUserAchieveList);
131 logger.info("syncUserAchieveDataPage need sync data count is {}", needSyncData.size()); 136 logger.info("syncUserAchieveDataPage need sync data count is {}", needSyncData.size());
132 publicVirtualUserRepository.saveAll(needSyncData); 137 publicVirtualUserRepository.saveAll(needSyncData);
  138 + try {
  139 + Thread.sleep(200);
  140 + } catch (InterruptedException e) {
  141 + logger.warn("sync error{}", e);
  142 + }
133 } 143 }
134 144
135 145
1 spring: 1 spring:
2 datasource: 2 datasource:
3 - url: jdbc:mysql://192.168.102.219:3306/yh_pcms?useUnicode=true&amp;characterEncoding=UTF-8  
4 - username: yh_test  
5 - password: 9nm0icOwt6bMHjMusIfMLw==  
6 - driver-class-name: com.mysql.jdbc.Driver 3 + primary:
  4 + url: jdbc:mysql://write.cms.yohoops.org:3306/yh_grass?useUnicode=true&amp;characterEncoding=UTF-8
  5 + username: yh_vpc_bak
  6 + password: +BfhVxZQ4LuPKt+QxSy9naMwEu/zaKV31I9S8xDJIUA=
  7 + driver-class-name: com.mysql.jdbc.Driver
  8 +
  9 + secondary:
  10 + url: jdbc:mysql://write.cms.yohoops.org:3306/yh_pcms?useUnicode=true&amp;characterEncoding=UTF-8
  11 + username: yh_vpc_bak
  12 + password: +BfhVxZQ4LuPKt+QxSy9naMwEu/zaKV31I9S8xDJIUA=
  13 + driver-class-name: com.mysql.jdbc.Driver
  14 +
  15 +logging:
  16 + config: classpath:logback-boot.xml
@@ -11,3 +11,6 @@ spring: @@ -11,3 +11,6 @@ spring:
11 username: yh_test 11 username: yh_test
12 password: 9nm0icOwt6bMHjMusIfMLw== 12 password: 9nm0icOwt6bMHjMusIfMLw==
13 driver-class-name: com.mysql.jdbc.Driver 13 driver-class-name: com.mysql.jdbc.Driver
  14 +
  15 +logging:
  16 + config: classpath:logback-boot.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +
  3 +<!-- 从高到地低 OFF 、 FATAL 、 ERROR 、 WARN 、 INFO 、 DEBUG 、 TRACE 、 ALL -->
  4 +<!-- 日志输出规则 根据当前ROOT 级别,日志输出时,级别高于root默认的级别时 会输出 -->
  5 +<!-- 以下 每个配置的 filter 是过滤掉输出文件里面,会出现高级别文件,依然出现低级别的日志信息,通过filter 过滤只记录本级别的日志-->
  6 +
  7 +
  8 +<!-- 属性描述 scan:性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。
  9 + debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
  10 +<configuration scan="true" scanPeriod="60 seconds" debug="false">
  11 + <!-- 日志最大的历史 7天 -->
  12 + <property name="maxHistory" value="7"/>
  13 + <!-- 日志最大的文件大小 10MB-->
  14 + <property name="maxFileSize" value="10MB"/>
  15 + <!-- 彩色日志 -->
  16 + <!-- 彩色日志依赖的渲染类 -->
  17 + <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
  18 + <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
  19 + <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
  20 + <!-- 彩色日志格式 -->
  21 + <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
  22 +
  23 + <!-- ConsoleAppender 控制台输出日志 -->
  24 + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  25 + <!-- 对日志进行格式化 -->
  26 + <encoder>
  27 + <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
  28 + <!-- 设置字符集 -->
  29 + <charset>UTF-8</charset>
  30 + </encoder>
  31 + </appender>
  32 +
  33 + <!-- DEBUG、INFO、WARN、ERROR级别日志 appender -->
  34 + <appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
  35 + <file>/Data/logs/yoho-datasync-fullsync/debug.log</file>
  36 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  37 + <!-- daily rollover -->
  38 + <fileNamePattern>/Data/logs/yoho-datasync-fullsync/archived/debug.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  39 + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  40 + <!-- or whenever the file size reaches 100MB -->
  41 + <maxFileSize>${maxFileSize}</maxFileSize>
  42 + </timeBasedFileNamingAndTriggeringPolicy>
  43 + <!-- keep 30 days' worth of history -->
  44 + <maxHistory>${maxHistory}</maxHistory>
  45 + </rollingPolicy>
  46 + <encoder>
  47 + <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
  48 + <!-- 设置字符集 -->
  49 + <charset>UTF-8</charset>
  50 + </encoder>
  51 + </appender>
  52 +
  53 + <!-- INFO级别日志 appender -->
  54 + <appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
  55 + <file>/Data/logs/yoho-datasync-fullsync/info.log</file>
  56 + <!-- 过滤器,过滤掉 TRACE 和 DEBUG 级别的日志 -->
  57 + <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  58 + <level>INFO</level>
  59 + </filter>
  60 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  61 + <!-- daily rollover -->
  62 + <fileNamePattern>/Data/logs/yoho-datasync-fullsync/archived/info.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  63 + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  64 + <!-- or whenever the file size reaches 100MB -->
  65 + <maxFileSize>${maxFileSize}</maxFileSize>
  66 + </timeBasedFileNamingAndTriggeringPolicy>
  67 + <!-- keep 30 days' worth of history -->
  68 + <maxHistory>${maxHistory}</maxHistory>
  69 + </rollingPolicy>
  70 + <encoder>
  71 + <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
  72 + <!-- 设置字符集 -->
  73 + <charset>UTF-8</charset>
  74 + </encoder>
  75 + </appender>
  76 +
  77 + <!-- WARN级别日志 appender -->
  78 + <appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
  79 + <file>/Data/logs/yoho-datasync-fullsync/warn.log</file>
  80 + <!-- 过滤器,过滤掉 TRACE 和 DEBUG 和 INFO 级别的日志 -->
  81 + <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  82 + <level>WARN</level>
  83 + </filter>
  84 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  85 + <!-- daily rollover -->
  86 + <fileNamePattern>/Data/logs/yoho-datasync-fullsync/archived/warn.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  87 + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  88 + <!-- or whenever the file size reaches 100MB -->
  89 + <maxFileSize>${maxFileSize}</maxFileSize>
  90 + </timeBasedFileNamingAndTriggeringPolicy>
  91 + <!-- keep 30 days' worth of history -->
  92 + <maxHistory>${maxHistory}</maxHistory>
  93 + </rollingPolicy>
  94 + <encoder>
  95 + <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
  96 + <!-- 设置字符集 -->
  97 + <charset>UTF-8</charset>
  98 + </encoder>
  99 + </appender>
  100 +
  101 + <!-- 数据检测相关日志 -->
  102 + <appender name="DATA_CHECKERROR_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
  103 + <file>/Data/logs/yoho-datasync-fullsync/datacheck-error.log</file>
  104 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  105 + <!-- daily rollover -->
  106 + <fileNamePattern>/Data/logs/yoho-datasync-fullsync/archived/datacheck-error.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  107 + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  108 + <!-- or whenever the file size reaches 100MB -->
  109 + <maxFileSize>${maxFileSize}</maxFileSize>
  110 + </timeBasedFileNamingAndTriggeringPolicy>
  111 + <!-- keep 30 days' worth of history -->
  112 + <maxHistory>${maxHistory}</maxHistory>
  113 + </rollingPolicy>
  114 + <encoder>
  115 + <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
  116 + <!-- 设置字符集 -->
  117 + <charset>UTF-8</charset>
  118 + </encoder>
  119 + </appender>
  120 +
  121 + <!-- 数据检测相关日志 -->
  122 + <logger name="DATA_CHECKERROR" additivity="false">
  123 + <level value="INFO"/>
  124 + <appender-ref ref="DATA_CHECKERROR_LOG"/>
  125 + </logger>
  126 +
  127 + <!-- root级别 DEBUG -->
  128 + <root level="INFO">
  129 + <!-- 控制台输出 -->
  130 + <appender-ref ref="STDOUT" />
  131 + <!-- 文件输出 -->
  132 + <appender-ref ref="DEBUG" />
  133 + <appender-ref ref="WARN" />
  134 + </root>
  135 +
  136 +</configuration>