From fb8e66a0cd146a239c1ca2332416dbe70149b927 Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Sun, 8 Sep 2024 09:27:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD=E5=99=A8?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=EF=BC=88=E6=9C=AA=E7=99=BB=E5=BD=95=EF=BC=89=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../module/impl/rule/ActiveMonitoringModule.java | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index fceb8d5a3f..2d5d253ae4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ghostchu.peerbanhelper peerbanhelper - 6.1.0 + 6.1.1 takari-jar PeerBanHelper diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ActiveMonitoringModule.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ActiveMonitoringModule.java index ef273770dd..e6a7ff874f 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ActiveMonitoringModule.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ActiveMonitoringModule.java @@ -34,9 +34,6 @@ public class ActiveMonitoringModule extends AbstractFeatureModule implements Rel private final PeerRecordDao peerRecordDao; private final Deque dataBuffer = new ConcurrentLinkedDeque<>(); private final TrafficJournalDao trafficJournalDao; - private ExecutorService taskWriteService; - private long dataRetentionTime; - private ScheduledExecutorService scheduleService; private final BlockingDeque taskWriteQueue = new LinkedBlockingDeque<>(); private final Cache diskWriteCache = CacheBuilder .newBuilder() @@ -44,6 +41,9 @@ public class ActiveMonitoringModule extends AbstractFeatureModule implements Rel .maximumSize(3500) .removalListener(notification -> dataBuffer.offer((PeerRecordDao.BatchHandleTasks) notification.getKey())) .build(); + private ExecutorService taskWriteService; + private long dataRetentionTime; + private ScheduledExecutorService scheduleService; public ActiveMonitoringModule(PeerRecordDao peerRecordDao, TrafficJournalDao trafficJournalDao) { super(); @@ -123,10 +123,12 @@ private void writeJournal() { for (Downloader downloader : getServer().getDownloaders()) { try { var entity = trafficJournalDao.getTodayJournal(downloader.getName()); - var stats = downloader.getStatistics(); - entity.setDataOverallUploaded(stats.totalUploaded()); - entity.setDataOverallDownloaded(stats.totalDownloaded()); - trafficJournalDao.update(entity); + if (downloader.login().success()) { + var stats = downloader.getStatistics(); + entity.setDataOverallUploaded(stats.totalUploaded()); + entity.setDataOverallDownloaded(stats.totalDownloaded()); + trafficJournalDao.update(entity); + } } catch (Throwable e) { log.error("Unable to write hourly traffic journal to database", e); }