narendly 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_r315042991
########## 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: This method could be simplified to: `return System.currentTimeMillis() >= workflowCtx.getJobStartTime(job);` Also, are we sure that there's no other checks required in this function? If it's just going to be a one-liner (in other words, there are no other checks to perform than checking the calculatedStartTime against current time to determine if a job is ready to be processed/updated), and if the usage is only in this place, perhaps it may not be worth it to make it a separate function. If that's the case, let's just keep what we had inline. ---------------------------------------------------------------- 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