Package org.oddjob.scheduling
Class ExecutorThrottleType
java.lang.Object
org.oddjob.scheduling.ExecutorThrottleType
- All Implemented Interfaces:
ArooaValue,ValueFactory<ExecutorService>
- Author:
- rob
Description
Throttle parallel execution. This will limit the number of jobs running in parallel.Example
Throttling parallel execution.
<oddjob>
<job>
<parallel id="parallel">
<executorService>
<throttle limit="2"/>
</executorService>
<jobs>
<wait name="Wait 1"/>
<wait name="Wait 2"/>
<wait name="Wait 3"/>
<wait name="Wait 4"/>
</jobs>
</parallel>
</job>
</oddjob>
Sharing a throttle. The same throttle is shared between
to ParallelJob jobs. The total number of jobs executing between
both parallels is 2.
<oddjob>
<job>
<sequential>
<jobs>
<variables id="vars">
<throttle>
<convert>
<value>
<throttle limit="2"/>
</value>
</convert>
</throttle>
</variables>
<parallel id="parallel-1">
<executorService>
<value value="${vars.throttle.is}"/>
</executorService>
<jobs>
<wait name="Wait 1"/>
<wait name="Wait 2"/>
</jobs>
</parallel>
<parallel id="parallel-2">
<executorService>
<value value="${vars.throttle.is}"/>
</executorService>
<jobs>
<wait name="Wait 3"/>
<wait name="Wait 4"/>
</jobs>
</parallel>
</jobs>
</sequential>
</job>
</oddjob>
The throttle type is a factory type and so would provide a new instance
each time it's used. To overcome this the throttle is
wrapped in a convert ConvertType that creates a single instance.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.oddjob.arooa.types.ValueFactory
ValueFactory.Conversions -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetLimit()voidsetLimit(int max) voidsetOriginal(ExecutorService original) toString()toValue()Provide an instance of the type this is a factory for.
-
Constructor Details
-
ExecutorThrottleType
public ExecutorThrottleType()
-
-
Method Details
-
toValue
Description copied from interface:ValueFactoryProvide an instance of the type this is a factory for.- Specified by:
toValuein interfaceValueFactory<ExecutorService>- Returns:
- An instance of the type. May be null.
- Throws:
ArooaConversionException- If unable to provide a value.
-
getLimit
public int getLimit() -
setLimit
public void setLimit(int max) -
getOriginal
-
setOriginal
-
toString
-