Class ConcurrentJobMonitor
Object
org.anchoranalysis.experiment.task.processor.ConcurrentJobMonitor
- All Implemented Interfaces:
Iterable<SubmittedJob>
public class ConcurrentJobMonitor extends Object implements Iterable<SubmittedJob>
Monitors all submitted jobs and their current state of execution.
It provides statistics and a textual description of the aggregate state of execution across all jobs.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description ConcurrentJobMonitor(long totalNumberJobs) -
Method Summary
Modifier and Type Method Description voidadd(SubmittedJob job)Adds a job to be considered in the aggregate view.StringcurrentStateDescription()A human-understandable string describing the aggregate state.TaskStatisticsderiveStatistics()Derive statistics on the aggregate state of jobs.Optional<String>describeUncompletedJobs(int fewerThanThreshold)A string that describes all jobs that are not tey completed, but only if there are fewer than a certain number.longgetTotalNumberJobs()The total number of submitted jobs to be executed.Iterator<SubmittedJob>iterator()longnumberCompletedFailureJobs()The number of jobs that have completed in a state of failure.longnumberCompletedJobs()The number of jobs that have completed, regardless of failure state.longnumberCompletedSuccessfullyJobs()The number of jobs that have completed in a state of success.longnumberExecutingJobs()The number of jobs that are currently executing.longnumberUncompletedJobs()The number of jobs that remain uncompleted.
-
Constructor Details
-
ConcurrentJobMonitor
public ConcurrentJobMonitor(long totalNumberJobs)
-
-
Method Details
-
add
Adds a job to be considered in the aggregate view.- Parameters:
job- the job.
-
currentStateDescription
A human-understandable string describing the aggregate state.It features:
- The number of completed jobs.
- The number of executing jobs.
- The number of jobs, that have not yet started executing (remaining to be executed).
The string is shortened using abbreviations to help fit in a line of console outut.
- Returns:
- the string, as per above.
-
describeUncompletedJobs
A string that describes all jobs that are not tey completed, but only if there are fewer than a certain number.The string shows the number and a short-name for each job, and the number of seconds for which it is has been executing.
The string shows the jobs on one long line, without using newlines.
- Parameters:
fewerThanThreshold- a description is only shown if the total number of executing tasks is less than this threshold.- Returns:
- a string in the form above if the condition is fulfilled, or otherwise
Optional.empty().
-
numberUncompletedJobs
public long numberUncompletedJobs()The number of jobs that remain uncompleted.- Returns:
- the number of jobs.
-
numberCompletedJobs
public long numberCompletedJobs()The number of jobs that have completed, regardless of failure state.This includes both jobs that have completed successfully and with failure.
- Returns:
- the number of jobs.
-
numberCompletedSuccessfullyJobs
public long numberCompletedSuccessfullyJobs()The number of jobs that have completed in a state of success.- Returns:
- the number of jobs.
-
numberCompletedFailureJobs
public long numberCompletedFailureJobs()The number of jobs that have completed in a state of failure.- Returns:
- the number of jobs.
-
numberExecutingJobs
public long numberExecutingJobs()The number of jobs that are currently executing.- Returns:
- the number of jobs.
-
deriveStatistics
Derive statistics on the aggregate state of jobs.- Returns:
- a newly created
TaskStatisticscapturing the state at the point it was executed.
-
iterator
- Specified by:
iteratorin interfaceIterable<SubmittedJob>
-
getTotalNumberJobs
public long getTotalNumberJobs()The total number of submitted jobs to be executed.
-