|
@@ -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){
|