You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by jk...@apache.org on 2023/05/03 16:03:32 UTC
[unomi] branch unomi-1.x updated: UNOMI-761: Correctly calculate initial delay of the Segment/Scoring r… (#613)
This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch unomi-1.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/unomi-1.x by this push:
new 7a7ec63e9 UNOMI-761: Correctly calculate initial delay of the Segment/Scoring r… (#613)
7a7ec63e9 is described below
commit 7a7ec63e97fd705a901073858536c4991ea46072
Author: kevan Jahanshahi <jk...@apache.org>
AuthorDate: Wed May 3 18:02:52 2023 +0200
UNOMI-761: Correctly calculate initial delay of the Segment/Scoring r… (#613)
* UNOMI-761: Correctly calculate initial delay of the Segment/Scoring recalculation scheduled task
* UNOMI-761: Correctly calculate initial delay of the Segment/Scoring recalculation scheduled task
---
.../apache/unomi/services/impl/scheduler/SchedulerServiceImpl.java | 7 +++----
.../apache/unomi/services/impl/segments/SegmentServiceImpl.java | 6 ++++--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/services/src/main/java/org/apache/unomi/services/impl/scheduler/SchedulerServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/scheduler/SchedulerServiceImpl.java
index ea21c38f6..89f5d3062 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/scheduler/SchedulerServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/scheduler/SchedulerServiceImpl.java
@@ -64,11 +64,10 @@ public class SchedulerServiceImpl implements SchedulerService {
public static long getTimeDiffInSeconds(int hourInUtc, ZonedDateTime now) {
ZonedDateTime nextRun = now.withHour(hourInUtc).withMinute(0).withSecond(0);
- if(now.compareTo(nextRun) > 0)
+ if(now.compareTo(nextRun) > 0) {
nextRun = nextRun.plusDays(1);
+ }
- Duration duration = Duration.between(now, nextRun);
- long initialDelay = duration.getSeconds();
- return initialDelay;
+ return Duration.between(now, nextRun).getSeconds();
}
}
diff --git a/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
index cdeb96137..377631c1f 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
@@ -1232,8 +1232,10 @@ public class SegmentServiceImpl extends AbstractServiceImpl implements SegmentSe
}
};
long initialDelay = SchedulerServiceImpl.getTimeDiffInSeconds(dailyDateExprEvaluationHourUtc, ZonedDateTime.now(ZoneOffset.UTC));
- logger.info("daily recalculation job for segments and scoring that contains date relative conditions will run at fixed rate, initialDelay={}, taskExecutionPeriod={}", initialDelay, TimeUnit.DAYS.toSeconds(1));
- schedulerService.getScheduleExecutorService().scheduleAtFixedRate(task, initialDelay, taskExecutionPeriod, TimeUnit.DAYS);
+ long period = TimeUnit.DAYS.toSeconds(taskExecutionPeriod);
+ logger.info("daily recalculation job for segments and scoring that contains date relative conditions will run at fixed rate, " +
+ "initialDelay={}, taskExecutionPeriod={} in seconds", initialDelay, period);
+ schedulerService.getScheduleExecutorService().scheduleAtFixedRate(task, initialDelay, period, TimeUnit.SECONDS);
task = new TimerTask() {
@Override