scheduling:retry sheduling more than one job

General
henyo
2011-12-09
2013-05-28
  • henyo

    henyo - 2011-12-09

    here is my oddjob tree:

    the xml:
    <oddjob>
        <job>
            <scheduling:timer id="timer" name="Timer" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">
                <schedule>
                    <schedules:now xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>
                </schedule>
                <job>
                    <sequential>
                        <jobs>
                            <variables id="localhostConnection">
                                <dbConnection>
                                    <connection driver="com.mysql.jdbc.Driver" password="root" url="jdbc:mysql://10.21.160.12:3306/test" username="root">
                                        <classLoader>
                                            <url-class-loader>
                                                <files>
                                                    <file file="E:\source\oddjob\myTest\mysql-connector-java-5.0.8-bin.jar"/>
                                                </files>
                                            </url-class-loader>
                                        </classLoader>
                                    </connection>
                                </dbConnection>
                            </variables>
                            <scheduling:retry id="ifNotDone">
                                <schedule>
                                    <schedules:interval interval="00:00:5" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>
                                </schedule>
                                <job>
                                    <state:cascade xmlns:state="http://rgordon.co.uk/oddjob/state">
                                        <jobs>
                                            <sql id="test">
                                                <connection>
                                                    <value value="${localhostConnection.dbConnection}"/>
                                                </connection>
                                                <input>
                                                    <buffer><![CDATA]></buffer>
                                                </input>
                                                <results>
                                                    <sql-results-bean/>
                                                </results>
                                            </sql>
                                            <echo><![CDATA]></echo>
                                            <check eq="DONE" id="checkDone" value="${test.results.row.DONE}"/>
                                        </jobs>
                                    </state:cascade>
                                </job>
                            </scheduling:retry>
                        </jobs>
                    </sequential>
                </job>
            </scheduling:timer>
        </job>
    </oddjob>

    the execute resulte is

    ===================================================================================

    what I want to do is when then CheckJob is failed, the Retry resheduling it`s all child job,such as:Sql Echo CheckJob .what should I do?

     
  • Rob Gordon

    Rob Gordon - 2011-12-09

    Hi - http://rgordon.co.uk/oddjob/reference/org/oddjob/state/Resets.html is what you want.

    Here's the XML:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <oddjob>
        <job>
            <scheduling:timer id="timer" name="Timer" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">
                <schedule>
                    <schedules:now xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>
                </schedule>
                <job>
                    <sequential>
                        <jobs>
                            <variables id="localhostConnection">
                                <dbConnection>
                                    <connection driver="com.mysql.jdbc.Driver" password="root" url="jdbc:mysql://10.21.160.12:3306/test" username="root">
                                        <classLoader>
                                            <url-class-loader>
                                                <files>
                                                    <file file="E:\source\oddjob\myTest\mysql-connector-java-5.0.8-bin.jar"/>
                                                </files>
                                            </url-class-loader>
                                        </classLoader>
                                    </connection>
                                </dbConnection>
                            </variables>
                            <scheduling:retry id="ifNotDone">
                                <schedule>
                                    <schedules:interval interval="00:00:5" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>
                                </schedule>
                                <job>
                                    <state:resets harden="true" name="Hard Reset Whole Child Sequence" xmlns:state="http://rgordon.co.uk/oddjob/state">
                                        <job>
                                            <sequential>
                                                <jobs>
                                                    <sql id="test">
                                                        <connection>
                                                            <value value="${localhostConnection.dbConnection}"/>
                                                        </connection>
                                                        <input>
                                                            <buffer><![CDATA[select DONE
    from test where name='1']]></buffer>
                                                        </input>
                                                        <results>
                                                            <sql-results-bean/>
                                                        </results>
                                                    </sql>
                                                    <echo><![CDATA[the state is
    ${test.results.row.DONE}]]></echo>
                                                    <check eq="DONE" id="checkDone" value="${test.results.row.DONE}"/>
                                                </jobs>
                                            </sequential>
                                        </job>
                                    </state:resets>
                                </job>
                            </scheduling:retry>
                        </jobs>
                    </sequential>
                </job>
            </scheduling:timer>
        </job>
    </oddjob>

    Also the Cascade job isn't the best choice here - it's designed for asynchronous triggering of the next job, but as none of the child jobs (sql, echo, check) complete asynchronously sequential is a better choice.

    Rob.

     
  • henyo

    henyo - 2011-12-09

    thanks !
    According to your suggestion,I set my oddjob like this :

     
  • Rob Gordon

    Rob Gordon - 2011-12-09

    Glad it works - as an aside, where you have the JoinJob is a good example of where it is better to use a CascadeJob. Join hogs a thread, where as Cascade is event driven. I would have:

    -oddjob
    -timer
      -sequential
        variables
        variables
       -cascade
          retry etc…
          echo

    But unless you have many join jobs hogging a thread won't be a problem.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks