[Index]

state:equals


Runs it's child job and then compares the state of the child job to the given state. It's own state is complete if the states match, incomplete otherwise.

This job is probably most useful in it's 'not equals' form - i.e. to check when something hasn't completed.


Property Summary

job The job to run who's state will be compared.
name A name, can be any text.
state The state to match.
stop Read only view of the internal stop flag.

Example Summary

Example 1 COMPLETE when the child job isn't complete.

Property Detail

job

Configured ByELEMENT
AccessWRITE_ONLY
RequiredYes.

The job to run who's state will be compared.

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

A name, can be any text.

state

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, defaults to COMPLETE.

The state to match.

stop

AccessREAD_ONLY
RequiredRead only.

Read only view of the internal stop flag. This flag is cleared with a reset.


Examples

Example 1

COMPLETE when the child job isn't complete. This example demonstrates how the state:equals job can be used to reverse the meaning of the exists job. A request to shutdown a database may complete asynchronously, and the only way to tell if shutdown is complete is to check that the Database's lock file has be removed. This example demonstrates how Oddjob can check for this situation before attempting to back up the database.

<oddjob id="this">
    <job>
        <scheduling:retry name="Database Backup" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">
            <schedule>
                <schedules:interval interval="00:00:02" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>
            </schedule>
            <job>
                <sequential id="db-backup">
                    <jobs>
                        <state:equals state="!COMPLETE" xmlns:state="http://rgordon.co.uk/oddjob/state">
                            <job>
                                <state:resets harden="true">
                                    <job>
                                        <exists file="${db.lock.file}"/>
                                    </job>
                                </state:resets>
                            </job>
                        </state:equals>
                        <echo>Backing up the Database...</echo>
                    </jobs>
                </sequential>
            </job>
        </scheduling:retry>
    </job>
</oddjob>


(c) Rob Gordon 2005 - 2017