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/02 09:47:06 UTC

[unomi] branch fixSegmentJobScheduling created (now 3369bbc91)

This is an automated email from the ASF dual-hosted git repository.

jkevan pushed a change to branch fixSegmentJobScheduling
in repository https://gitbox.apache.org/repos/asf/unomi.git


      at 3369bbc91 UNOMI-761: Correctly calculate initial delay of the Segment/Scoring recalculation scheduled task

This branch includes the following new commits:

     new 3369bbc91 UNOMI-761: Correctly calculate initial delay of the Segment/Scoring recalculation scheduled task

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[unomi] 01/01: UNOMI-761: Correctly calculate initial delay of the Segment/Scoring recalculation scheduled task

Posted by jk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jkevan pushed a commit to branch fixSegmentJobScheduling
in repository https://gitbox.apache.org/repos/asf/unomi.git

commit 3369bbc917422074412e8af6e0a4e51ab02c7e4b
Author: Kevan <ke...@jahia.com>
AuthorDate: Tue May 2 11:46:47 2023 +0200

    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    | 2 +-
 2 files changed, 4 insertions(+), 5 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 1cc852f24..7e8147544 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
@@ -1217,7 +1217,7 @@ 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);
+        schedulerService.getScheduleExecutorService().scheduleAtFixedRate(task, initialDelay, taskExecutionPeriod * 24 * 60 * 60, TimeUnit.SECONDS);
 
         task = new TimerTask() {
             @Override