public class JobStateMonitor extends Object
The state refers to whether a job is unstarted, executed, completed etc.
It exists as a state-machine, where a job initially has an unstarted state.
Next, a call should occur to markAsExecuting()
to indicate that the job has started
executing.
Next, a call should occur to markAsCompleted(boolean)
to indicate that the job has
completed.
Constructor and Description |
---|
JobStateMonitor() |
Modifier and Type | Method and Description |
---|---|
int |
getExecutionDuration()
How long the job took to execute in milliseconds.
|
boolean |
isCompleted()
Is a job completed?
|
boolean |
isCompletedFailure()
Has a job completed with a failure?
|
boolean |
isCompletedSuccessfully()
Has a job completed with a successful outcome?
|
boolean |
isExecuting()
Is a job currently executing?
|
boolean |
isUnstarted()
Is a job unstarted?
|
void |
markAsCompleted(boolean successful)
Indicates that a job has stopped executing, and has completed.
|
void |
markAsExecuting()
Indicates that a job is currently executing.
|
public boolean isUnstarted()
public boolean isExecuting()
public boolean isCompleted()
public boolean isCompletedSuccessfully()
public boolean isCompletedFailure()
public void markAsExecuting()
This method records the start-time of execution, later used to help infers the total duration of excution.
OperationFailedRuntimeException
- if called without the job being in an unstarted
state.public void markAsCompleted(boolean successful)
This method records the end-time of execution, and infers the total duration of execution.
successful
- whether the job completed successfully or not.public int getExecutionDuration()
This method should only be called when the job is in a completed state.
OperationFailedRuntimeException
- if called without the job being in a completed state.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.