Commit 7a73ab9beda0f166fc4a560305862cedb42e77d0
1 parent
fa315aa0
2023年11月29日15:24:04 解决并发上报数据导致的问题
Showing
1 changed file
with
8 additions
and
4 deletions
src/main/java/cn/fw/freya/service/CrawlBizService.java
... | ... | @@ -306,11 +306,15 @@ public class CrawlBizService { |
306 | 306 | CrawlStrategy crawlStrategy = crawlStrategyMap.get(typeEnum); |
307 | 307 | List<LivePool> yesterdayLiveMsg; |
308 | 308 | int tryGetDataCnt = 0; |
309 | - do { | |
310 | - LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(5));// 线程挂起5秒, 防止并发上报, 旧数据覆盖新数据 | |
311 | - yesterdayLiveMsg = crawlStrategy.getLiveMsg(accountNo);// 获取昨日直播信息 | |
309 | + while (autoExpireLocalCache.containsKey(account.getCrawlIngLockKey())) {// 务必等待capture主线程完成数据抓取上报逻辑 | |
310 | + LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(1)); | |
311 | + } | |
312 | + yesterdayLiveMsg = crawlStrategy.getLiveMsg(accountNo);// 获取昨日直播信息 | |
313 | + while (tryGetDataCnt < 12 && !this.checkHasPlayback(yesterdayLiveMsg)) { | |
314 | + LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(5));// 线程挂起5秒 | |
315 | + yesterdayLiveMsg = crawlStrategy.getLiveMsg(accountNo);// 再次获取昨日直播信息 | |
312 | 316 | tryGetDataCnt++; |
313 | - } while (tryGetDataCnt < 12 && !this.checkHasPlayback(yesterdayLiveMsg)); | |
317 | + } | |
314 | 318 | if (!this.checkHasPlayback(yesterdayLiveMsg)) { |
315 | 319 | log.info("{} 直播无回放记录, 放弃重新上报直播数据", accountNo); |
316 | 320 | return; | ... | ... |