public 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) int[] |
attempts |
(package private) static Logger |
logger |
private int |
pending |
private TaskManager |
pool |
(package private) Object[] |
results |
private Map |
tasks |
private WakeupManager |
wm |
Constructor and Description |
---|
Job(TaskManager pool,
WakeupManager wm)
Create the
Job object giving it the
TaskManager responsible for the pool of
threads which perform the necessary work. |
Modifier and Type | Method and Description |
---|---|
(package private) int |
attempt(TaskManager.Task who)
Given a
TaskManager.Task , 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 TaskManager.Task[] |
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(TaskManager.Task 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 TaskManager |
getPool()
Returns a reference to the
TaskManager 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(TaskManager.Task who,
Object param)
Used by a task to do a piece of work and record the
number of attempts.
|
private void |
reportDone(TaskManager.Task 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 TaskManager pool
private WakeupManager wm
private int pending
Object[] results
int[] attempts
private Map tasks
static final Logger logger
public Job(TaskManager pool, WakeupManager wm)
Job
object giving it the
TaskManager
responsible for the pool of
threads which perform the necessary work.pool
- the TaskManager
which provides the threadsboolean performWork(TaskManager.Task who, Object param) throws JobException
who
- The task which is performing the workparam
- A parameter used in performing the workJobException
int attempt(TaskManager.Task who) throws JobException
TaskManager.Task
, 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(TaskManager.Task who, Object param) throws JobException
who
- The task performing the workparam
- A parameter used to do the workJobException
abstract TaskManager.Task[] createTasks()
PartialResult
objects necessary for the
solution to the original problem.public void scheduleTasks()
private void awaitPending(long waitFor)
private void setPending(int num)
private void decrementPending()
protected TaskManager getPool()
TaskManager
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(TaskManager.Task 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 void stop()
Job
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.