Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support delaying jobs schedule with configurable delay time and start time #64

Merged
merged 1 commit into from Jan 31, 2017
Merged

Support delaying jobs schedule with configurable delay time and start time #64

merged 1 commit into from Jan 31, 2017

Conversation

junkaixue
Copy link
Contributor

Overview
Currently, Workflows and Jobs running by Helix requires more flexibility. For example, some of the jobs need to be started after some jobs finished for a certain mount of time. Same as Workflow, it may run at specific time, when some operations have been done. To better support Workflow and Job scheduling, Helix should provide a new feature to let user setup the delay time or starting for specific Workflows and Jobs. Workflows and Jobs should have an option that allow user set starting time of this Workflow or Job or set the delaying time for this Workflow and Job, when they are ready to start. Then Workflows and Jobs can be scheduled at correct time.
Purposed Design
The whole design has been split into two parts, generic rebalancer scheduling and delay time calculation. Since Job scheduling can be done via rerun WorkflowRebalancer, Workflow and Job delay scheduling can rely on the same generic scheduling mechanism. Generic task scheduling tasks the responsibiliy to set the running time for specific Workflow object. Then each object has its own starting time calculation algorithm.

Generic Task Scheduling
For generic task scheduling, it is better to have a centralized scheduler, RebalanceScheduler. It provides four public APIs:
public class RebalanceScheduler {
public void scheduleRebalance(HelixManager manager, String resource, long startTime);

public long getRebalanceTime(String resource);

public long removeScheduledRebalance(String resource);

public static void invokeRebalance(HelixDataAccessor accessor, String resource);

}

Obviously, it offers schedule a rebalancer, get schedule time of a rebalancer and remove a rebalancer schedule. It also have an API that can invoke rebalancer immediately. With this RebalancerScheduler, each resource can be scheduled at certain start time.
Delay Time Calculation
Workflows have a property expiryTime, which is the delay time that for the Workflow. User can set it by call setExpiry method in WorkflowConfig. For Job, two methods, in JobConfig, will be provided: setExecutionStart and setExecutionDelay. Through these API, user can set the delay time and start time for Workflows and Jobs. Internally, Helix will take the delay time and start time, which is later.
For the logic implemented in computing Workflows and Jobs, Helix choose to do real time computation. User can set delay time or start time at JobConfig. When the job is ready to run, Helix will calculate the "start time" for delay via current time plus the delay time. Then compare it with start time if user set it up in JobConfig.
Inline image 1
Impact
From user perspective, user have to understand the difference between delay time and start time.
The WorkflowRebalancer will be called multiple times, which might be considered for performance.

@lei-xia
Copy link
Member

lei-xia commented Jan 27, 2017

Can you rebase to the head of the branch?

@junkaixue
Copy link
Contributor Author

Updated.

@junkaixue junkaixue changed the title Delay the job scheduling when check job ready to schedule Support delaying jobs schedule with configurable delay time and start time Jan 27, 2017
@asfgit asfgit merged commit 594d94a into apache:helix-0.6.x Jan 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants