public class BalanceProcedureScheduler
extends java.lang.Object
The state machine framework consist of:
Job: The state machine. It implements the basic logic of the
state machine.
Procedure: The components of the job. It implements the custom
logic.
ProcedureScheduler: The multi-thread model responsible for running,
recovering, handling errors and job persistence.
Journal: It handles the job persistence and recover.
Example:
Job.Builder builder = new Job.Builder<>();
builder.nextProcedure(new WaitProcedure("wait", 1000, 30 * 1000));
Job job = builder.build();
ProcedureScheduler scheduler = new ProcedureScheduler(CONF);
scheduler.init();
scheduler.submit(job);
scheduler.waitUntilDone(job);
| Modifier and Type | Field | Description |
|---|---|---|
static org.slf4j.Logger |
LOG |
| Constructor | Description |
|---|---|
BalanceProcedureScheduler(org.apache.hadoop.conf.Configuration conf) |
| Modifier and Type | Method | Description |
|---|---|---|
BalanceJob |
findJob(BalanceJob job) |
Find job in scheduler.
|
java.util.Collection<BalanceJob> |
getAllJobs() |
Return all jobs in the scheduler.
|
void |
init(boolean recoverJobs) |
Init the scheduler.
|
boolean |
isRunning() |
The running state of the scheduler.
|
BalanceJob |
remove(BalanceJob job) |
Remove the job from scheduler if it finishes.
|
void |
setJournal(BalanceJournal journal) |
|
void |
shutDown() |
Shutdown the scheduler.
|
void |
shutDownAndWait(int timeout) |
Shutdown scheduler and wait at most timeout seconds for procedures to
finish.
|
void |
submit(BalanceJob job) |
Submit the job.
|
void |
waitUntilDone(BalanceJob job) |
Wait permanently until the job is done.
|
public BalanceProcedureScheduler(org.apache.hadoop.conf.Configuration conf)
public void init(boolean recoverJobs)
throws java.io.IOException
recoverJobs - whether to recover all the jobs from journal or not.java.io.IOExceptionpublic void submit(BalanceJob job) throws java.io.IOException
java.io.IOExceptionpublic BalanceJob remove(BalanceJob job)
public BalanceJob findJob(BalanceJob job)
public java.util.Collection<BalanceJob> getAllJobs()
public void waitUntilDone(BalanceJob job)
public boolean isRunning()
public void shutDown()
public void shutDownAndWait(int timeout)
timeout - Wait at most timeout seconds for procedures to finish.@VisibleForTesting public void setJournal(BalanceJournal journal)
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.