abstract class Job extends Object
Job
manages the division of work for a problem
whose solution is obtained by assembling partial results to
original problem.Modifier and Type | Field and Description |
---|---|
(package private) java.util.concurrent.atomic.AtomicIntegerArray |
attempts |
(package private) static Logger |
logger |
private java.util.concurrent.atomic.AtomicInteger |
pend |
private java.util.concurrent.ExecutorService |
pool |
(package private) java.util.concurrent.ConcurrentMap<Integer,Object> |
results |
private java.util.concurrent.ConcurrentMap<Runnable,Integer> |
tasks |
private WakeupManager |
wm |
Constructor and Description |
---|
Job(java.util.concurrent.ExecutorService pool,
WakeupManager wm)
Create the
Job object giving it the
ExecutorService responsible for the pool of
threads which perform the necessary work. |
Modifier and Type | Method and Description |
---|---|
(package private) int |
attempt(Runnable who)
Given a
Runnable , this method
returns the current number of attempts it has made. |
private void |
awaitPending(long waitFor) |
(package private) abstract Object |
computeResult()
Generate the solution to the original problem.
|
(package private) abstract Runnable[] |
createTasks()
Create the tasks required to compute all of the
PartialResult objects necessary for the
solution to the original problem. |
private void |
decrementPending() |
(package private) abstract Object |
doWork(Runnable who,
Object param)
The work performed is implemented here.
|
protected WakeupManager |
getMgr()
Returns a reference to the
WakeupManager which
provides the scheduling of tasks created by
this Job |
protected java.util.concurrent.ExecutorService |
getPool()
Returns a reference to the
ExecutorService which
supplies the threads used to executed tasks created by
this Job |
boolean |
isCompleted(long waitFor)
Check to see if the
Job execution has
completed. |
(package private) boolean |
performWork(Runnable who,
Object param)
Used by a task to do a piece of work and record the
number of attempts.
|
private void |
reportDone(Runnable who,
Object param) |
void |
scheduleTasks()
Schedules tasks for execution
|
private void |
setPending(int num) |
void |
stop()
Halt all of the work being performed by
the
Job |
private final java.util.concurrent.ExecutorService pool
private final WakeupManager wm
private final java.util.concurrent.atomic.AtomicInteger pend
final java.util.concurrent.ConcurrentMap<Integer,Object> results
volatile java.util.concurrent.atomic.AtomicIntegerArray attempts
private final java.util.concurrent.ConcurrentMap<Runnable,Integer> tasks
static final Logger logger
Job(java.util.concurrent.ExecutorService pool, WakeupManager wm)
Job
object giving it the
ExecutorService
responsible for the pool of
threads which perform the necessary work.pool
- the ExecutorService
which provides the threadsboolean performWork(Runnable who, Object param) throws JobException
who
- The task which is performing the workparam
- A parameter used in performing the workJobException
int attempt(Runnable who) throws JobException
Runnable
, this method
returns the current number of attempts it has made.who
- The task for which the number of attempts
is inquiredJobException
abstract Object doWork(Runnable who, Object param) throws JobException
who
- The task performing the workparam
- A parameter used to do the workJobException
abstract Runnable[] createTasks()
PartialResult
objects necessary for the
solution to the original problem.public final void scheduleTasks()
private void awaitPending(long waitFor)
private void setPending(int num)
private void decrementPending()
protected java.util.concurrent.ExecutorService getPool()
ExecutorService
which
supplies the threads used to executed tasks created by
this Job
protected WakeupManager getMgr()
WakeupManager
which
provides the scheduling of tasks created by
this Job
private void reportDone(Runnable who, Object param) throws JobException
JobException
public boolean isCompleted(long waitFor) throws JobException
Job
execution has
completed.waitFor
- The amount of time the caller is willing
to wait for the completion status to arrive.JobException
abstract Object computeResult() throws JobException
JobException
public final void stop()
Job
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.