Oddjob

from rgordon.co.uk

Oddjob Quick Start Guide

Writing a Simple Oddjob File

Oddjob configuration files are written in XML. Each Oddjob file contains an Oddjob and may contain 0 or 1 jobs for Oddjob to run.

A file with no job for oddjob to run is a complete waste of time but perfectly legal.


<oddjob/>

A file with one job would be something like:


<oddjob>
  <echo text="Hello World!"/>
</oddjob>

Each job in an Oddjob file (except the top level oddjob) can have a name attribute. The name can be any text allowed as an XML attribute. The name is used in monitoring and warning messages - it doesn't need to be unique but it can be clearer if it is.

Each job in an Oddjob file (including the top level oddjob) can have an id attribute. A job can be referred to elsewhere in the file by it's id value. An id must be unique and must not contain the characters .()[].

Running More than One Job

Oddjob will only execute a single job but that single child could be a job like sequential or parallel.


<oddjob>
  <sequential>
    <echo text="This is followed..."/>
    <echo text="...By this"/>
  </sequential>
</oddjob>

By using sequential and parrallel jobs within each other, complicated dependencies can be built up.

Properties

By specifying a text attribute for the echo Job we were setting it's text property. This property is also available to be used to set other job's properties. If our echo job had the id "my-echo" we can access it's text property using the syntax "${my-echo.text}" as in this example:


<oddjob>
  <sequential>
    <echo id="my-echo" text="This will be displayed twice!"/>
    <echo text="${my-echo.text}"/>
  </sequential>
</oddjob>

Scheduling Jobs

Oddjob can schedule a job to run at certain times, on certain days, in certain months etc etc. To get oddjob to do this you need a Scheduler Job. You then add any number of Schedules to your Scheduler Job. The jobs you want scheduled are defined elsewhere - generally in a foler. Here's an example:


<oddjob>
  <parallel>
    <scheduler name="This is the scheduler">
      <schedules>
        <ojschedule name="This is one schedule" job="${morning-job}">
          <schedule>
            <time from="00:00" to="11:59">
              <interval interval="00:15"/>
            </time>
          </schedule>
        </ojschedule>
        <ojschedule name="This is another schedule" job="${afternoon-job}">
          <schedule>
            <time from="12:00" to="23:59">
              <interval interval="00:15"/>
            </time>
          </schedule>
        </ojschedule>
      </schedules>
    </scheduler>
    <folder name="My Jobs">
        <echo id="morning-job" name="Morning Job" text="Good Morning."/>
        <echo id="afternoon-job" name="Afternoon Job" text="Good Afternoon."/>
    </folder>  
  </parallel>
</oddjob>

State

A job can be in one of the following states:

ReadyThe job is ready to be executed. A job will only execute if it is 'Ready'
ExecutingThe job is executing.
CompleteThe job has completed successfully.
Not CompleteThe job ran but was not able to complete - e.g. A file was not available.
ExceptionSomething unexpected happened during the running of the job - e.g A network connection failed.

A job must be reset to the ready state before it can be executed again. The scheduler will do this automatically but when manually re-running a job it is useful to understand the difference between a hard reset and a soft reset.

A soft reset will reset a Not Complete state job or an Exception state job but will not reset a Complete state job. A hard reset will reset any job that has finished executing. These two reset levels are useful with sequences of jobs. A sequence can be reset without resetting jobs that completed successfully, or it can be reset so that all jobs are reset.

Using Oddjob Designer

Oddjob Designer is a GUI tool for creating Oddjob XML configuration files. Oddjob Designer can be started from OddjobExplorer.

Warning: When saving a file in Oddjob designer, it will reformat the xml and remove any comments!