Class ConcurrentJobMonitor
Object
ConcurrentJobMonitor
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionConcurrentJobMonitor
(long totalNumberJobs) Creates a newConcurrentJobMonitor
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(SubmittedJob job) Adds a job to be considered in the aggregate view.A human-understandable string describing the aggregate state.Derive statistics on the aggregate state of jobs.describeUncompletedJobs
(int fewerThanThreshold) A string that describes all jobs that are not tey completed, but only if there are fewer than a certain number.long
The total number of submitted jobs to be executed.iterator()
long
The number of jobs that have completed in a state of failure.long
The number of jobs that have completed, regardless of failure state.long
The number of jobs that have completed in a state of success.long
The number of jobs that are currently executing.long
The number of jobs that remain uncompleted.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ConcurrentJobMonitor
public ConcurrentJobMonitor(long totalNumberJobs) Creates a newConcurrentJobMonitor
instance.- Parameters:
totalNumberJobs
- The total number of submitted jobs to be executed.
-
-
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
TaskStatistics
capturing the state at the point it was executed.
-
iterator
- Specified by:
iterator
in interfaceIterable<SubmittedJob>
-
getTotalNumberJobs
public long getTotalNumberJobs()The total number of submitted jobs to be executed.
-