alirezazamani commented on a change in pull request #410: Fix the execution 
delay for the jobs (409)
URL: https://github.com/apache/helix/pull/410#discussion_r315289200
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/task/WorkflowDispatcher.java
 ##########
 @@ -602,4 +590,33 @@ private void removeContextsAndPreviousAssignment(String 
workflow, Set<String> jo
     }
     cache.removeContext(workflow);
   }
+
+  private long computeStartTimeForJob(WorkflowContext workflowCtx, String job,
+      JobConfig jobConfig) {
+    // Since the start time is calculated base on the time of completion of 
parent jobs for this
+    // job, the calculated start time should only be calculated once. Persist 
the calculated time
+    // in WorkflowContext znode.
+    long calculatedStartTime = workflowCtx.getJobStartTime(job);
+    if (calculatedStartTime < 0) {
+      // Calculate the start time if it is not already calculated
+      calculatedStartTime = System.currentTimeMillis();
+      // If the start time is not calculated before, do the math.
+      if (jobConfig.getExecutionDelay() >= 0) {
+        calculatedStartTime += jobConfig.getExecutionDelay();
+      }
+      calculatedStartTime = Math.max(calculatedStartTime, 
jobConfig.getExecutionStart());
+      workflowCtx.setJobStartTime(job, calculatedStartTime);
+    }
+    return calculatedStartTime;
+  }
+
+  private boolean isJobReadyToExecute(WorkflowContext workflowCtx, String job) 
{
+    long calculatedStartTime = workflowCtx.getJobStartTime(job);
+    long timeNow = System.currentTimeMillis();
+    if (timeNow < calculatedStartTime) {
 
 Review comment:
   There is no other checks it needed. I agree. I moved it inline to the caller 
function.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org
For additional commands, e-mail: reviews-h...@helix.apache.org

Reply via email to