From 284cd94a98bf08acb93f264b18b9191fdbda18a9 Mon Sep 17 00:00:00 2001 From: Sotatek-HuyLe3a Date: Thu, 7 Dec 2023 14:41:44 +0700 Subject: [PATCH] feat: #101 add initial delay for pool offline data job --- .../ledgersync/scheduler/PoolOfflineDataProperties.java | 1 + .../ledgersync/scheduler/SchedulerConfiguration.java | 2 +- .../ledgersync/scheduler/SchedulerProperties.java | 1 + .../ledgersync/scheduler/jobs/PoolOfflineDataScheduler.java | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/PoolOfflineDataProperties.java b/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/PoolOfflineDataProperties.java index d3728215..ba1be737 100644 --- a/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/PoolOfflineDataProperties.java +++ b/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/PoolOfflineDataProperties.java @@ -7,4 +7,5 @@ @Setter public class PoolOfflineDataProperties { private long fixedDelay; + private long initialDelay; } diff --git a/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/SchedulerConfiguration.java b/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/SchedulerConfiguration.java index 46ba529f..3ba50229 100644 --- a/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/SchedulerConfiguration.java +++ b/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/SchedulerConfiguration.java @@ -49,7 +49,7 @@ public PoolOfflineDataScheduler poolOfflineDataScheduler(PoolOfflineDataStoringS PoolOfflineDataProperties poolOfflineDataProperties() { PoolOfflineDataProperties poolOfflineDataProperties = new PoolOfflineDataProperties(); poolOfflineDataProperties.setFixedDelay(properties.getPoolOfflineData().getFixedDelay()); - + poolOfflineDataProperties.setInitialDelay(properties.getPoolOfflineData().getInitialDelay()); return poolOfflineDataProperties; } diff --git a/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/SchedulerProperties.java b/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/SchedulerProperties.java index 0b98f6af..9044bcb4 100644 --- a/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/SchedulerProperties.java +++ b/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/SchedulerProperties.java @@ -16,6 +16,7 @@ public class SchedulerProperties { @Setter public static final class PoolOfflineData { private long fixedDelay = 172800L; + private long initialDelay = 20000L; } @Getter diff --git a/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/jobs/PoolOfflineDataScheduler.java b/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/jobs/PoolOfflineDataScheduler.java index 188be431..23f19385 100644 --- a/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/jobs/PoolOfflineDataScheduler.java +++ b/components/scheduler/src/main/java/org/cardanofoundation/ledgersync/scheduler/jobs/PoolOfflineDataScheduler.java @@ -23,7 +23,8 @@ public class PoolOfflineDataScheduler { final PoolOfflineDataProperties poolOfflineDataProperties; @Transactional - @Scheduled(fixedDelayString = "#{poolOfflineDataProperties.getFixedDelay() * 1000}") + @Scheduled(initialDelayString = "#{poolOfflineDataProperties.getInitialDelay()}", + fixedDelayString = "#{poolOfflineDataProperties.getFixedDelay() * 1000}") public void fetchPoolOffline() { log.info("-----------Start job fetch pool offline data-----------"); final var startTime = System.currentTimeMillis();