public class ParallelJob extends SimultaneousStructural implements OptionallyTransient
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.
<oddjob> <job> <parallel> <jobs> <echo>This runs in parallel</echo> <echo>With this which could be displayed first!</echo> </jobs> </parallel> </job> </oddjob>
<oddjob> <job> <cascade cascadeOn="COMPLETE"> <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> </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> <cascade> <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> </cascade> </job> </oddjob>
ExecutorThrottleType
has an example of limiting the number
of concurrently executing jobs.childHelper, destroy, stop, structuralState
Constructor and Description |
---|
ParallelJob() |
Modifier and Type | Method and Description |
---|---|
protected StateOperator |
getInitialStateOp()
Subclasses must provide the
StateOperator that will decide
how to evaluate the children's state. |
StateOperator |
getStateOperator()
Getter for State Operator.
|
boolean |
isJoin()
Should execution wait for all jobs to be executed before returning
to calling code.
|
boolean |
isTransient()
Is the component transient.
|
void |
setJoin(boolean join) |
void |
setStateOperator(StateOperator stateOperator) |
void |
setTransient(boolean _transient) |
execute, getExecutorService, onStop, setExecutorService, setJobs, startChildStateReflector
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, onHardReset, onReset, onSoftReset, postStop, removeStructuralListener, run, softReset, stateHandler, stop, stopChildStateReflector
configure, getName, logger, logger, loggerName, save, setName, toString
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addStateListener, lastStateEvent, removeStateListener
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.
stateOperator
- The state operator to be applied to children's
states to derive our state.public StateOperator getStateOperator()
protected StateOperator getInitialStateOp()
StructuralJob
StateOperator
that will decide
how to evaluate the children's state.getInitialStateOp
in class StructuralJob<java.lang.Object>
public boolean isJoin()
SimultaneousStructural
This property is intended to be overridden by sub classes that wish to give that choice to users.
isJoin
in class SimultaneousStructural
public void setJoin(boolean join)
public boolean isTransient()
OptionallyTransient
isTransient
in interface OptionallyTransient
public void setTransient(boolean _transient)