org.oddjob.jobs.structural
Class ParallelJob
java.lang.Object
org.oddjob.framework.BaseComponent
org.oddjob.framework.BasePrimary
org.oddjob.framework.StructuralJob<Object>
org.oddjob.framework.SimultaneousStructural
org.oddjob.jobs.structural.ParallelJob
- All Implemented Interfaces:
- Serializable, Runnable, ArooaContextAware, ArooaSessionAware, Forceable, OptionallyTransient, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful, Stoppable, Structural
public class ParallelJob
- extends SimultaneousStructural
- implements OptionallyTransient
Description
A job which executes it's child jobs in parallel.
Once the child jobs are submitted, Oddjob's thread of execution continues
on out of this job. The state is set to ACTIVE and will continue to
change depending on the state of the child Jobs. The join
property can be used to hold the thread of execution until the
submitted jobs have finished executing - but it's use is discouraged.
See the property documentation below for more information.
The state of job, including its modification by the
stateOperator
property is identical to SequentialJob
and is well documented there. Likewise with the transient property.
Example
Two jobs running in parallel. Note that the order of execution of the
two child jobs is not predictable.
<oddjob>
<job>
<parallel>
<jobs>
<echo>This runs in parallel</echo>
<echo>With this which could be displayed first!</echo>
</jobs>
</parallel>
</job>
</oddjob>
Example
Two services started in parallel. This might be quite useful if the
services took a long time to start - maybe because they loaded a lot
of data into a cache for instance.
<oddjob>
<job>
<state:cascade xmlns:state="http://rgordon.co.uk/oddjob/state">
<jobs>
<parallel>
<jobs>
<bean class="org.oddjob.jobs.structural.ServiceManagerTest$Lights" id="lights"/>
<bean class="org.oddjob.jobs.structural.ServiceManagerTest$MachineThatGoes" goes="ping" id="machine"/>
</jobs>
</parallel>
<echo>The lights are ${lights.are} and the machine goes ${machine.goes}.</echo>
</jobs>
</state:cascade>
</job>
</oddjob>
The CascadeJob
will execute the final job only once both services
have started, and it will continue be in a STARTED after execution has
completed.
Adding a SERVICES stateOperator property will mean that parallel is
COMPLETE once the services have started and so the whole cascade shows
as complete.
<oddjob>
<job>
<state:cascade xmlns:state="http://rgordon.co.uk/oddjob/state">
<jobs>
<parallel stateOperator="SERVICES">
<jobs>
<bean class="org.oddjob.jobs.structural.ServiceManagerTest$Lights" id="lights"/>
<bean class="org.oddjob.jobs.structural.ServiceManagerTest$MachineThatGoes" goes="ping" id="machine"/>
</jobs>
</parallel>
<echo>The lights are ${lights.are} and the machine goes ${machine.goes}.</echo>
</jobs>
</state:cascade>
</job>
</oddjob>
Example
Examples elsewhere.
- See Also:
- Serialized Form
- Author:
- Rob Gordon
Methods inherited from class org.oddjob.framework.StructuralJob |
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, isStop, onDestroy, onReset, removeStructuralListener, run, softReset, stateHandler, stop |
Methods inherited from class org.oddjob.framework.BaseComponent |
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession |
ParallelJob
public ParallelJob()
setStateOperator
public void setStateOperator(StateOperator stateOperator)
Property: stateOperator
Description: Set the way the children's state is
evaluated and reflected by the parent. Values can be WORST,
ACTIVE, or SERVICES.
Required: No, default is ACTIVE.
- Parameters:
stateOperator
- The state operator to be applied to children's
states to derive our state.
getStateOperator
public StateOperator getStateOperator()
- Getter for State Operator.
- Returns:
getInitialStateOp
protected StateOperator getInitialStateOp()
- Description copied from class:
StructuralJob
- Subclasses must provide the
StateOperator
that will decide
how to evaluate the children's state.
- Specified by:
getInitialStateOp
in class StructuralJob<Object>
- Returns:
- A State Operator. Must not be null.
isJoin
public boolean isJoin()
- Overrides:
isJoin
in class SimultaneousStructural
setJoin
public void setJoin(boolean join)
isTransient
public boolean isTransient()
- Description copied from interface:
OptionallyTransient
- Is the component transient.
- Specified by:
isTransient
in interface OptionallyTransient
- Returns:
- true if transient, false otherwise.
setTransient
public void setTransient(boolean _transient)