[Index]

throttle


Throttle parallel execution. This will limit the number of jobs running in parallel.


Property Summary

limit The maximum number of simultaneous jobs this throttle will allow.
original The ExecuutorService to throttle.

Example Summary

Example 1 Throttling parallel execution.
Example 2 Sharing a throttle.

Property Detail

limit

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredYes.

The maximum number of simultaneous jobs this throttle will allow.

original

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

The ExecuutorService to throttle. This will be automatically set by Oddjob.


Examples

Example 1

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>

Example 2

Sharing a throttle. The same throttle is shared between to parallel 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 convert that creates a single instance.


(c) Rob Gordon 2005 - 2017