TWSz Java API restart and restartAndCleanUp job in plan

91 Views Asked by At

I'm looking for an example how to restart and restart and clean up job in Plan using TWSz Java API. For simple restart I'm changing status of a job

plan.setJobInstanceStatus(jobInPlanList.get(0).getId(), FlowNodeInternalStatusType.FLOW_NODE_ZOSSTATUS_READY, "", null);

I don't know that this is correct way to do that? And I can;t find the way to restart and clean up, I tried to use combination:

plan.beginJobRestartCleanup
plan.executeJobRestartCleanup
plan.commitJobRestartAndCleanup

But nothing works properly.

1

There are 1 best solutions below

0
On BEST ANSWER

for simple restart is ok to set job status to ready. Concerning restart and clean up, you should use the following flow: -set RestartCleanupOptions parameter that you need to pass to beginJobRestartCleanup api -modify job to be restarted, if needed -commit -handle possible exception using a try-catch block and rollbackJobRestartCleanup

Here is an example:

    try
    {
        /*
         * start the cleanup session, modify parameters if needed
         */
        RestartCleanupOptions rco = new RestartCleanupOptions();
        rco.setAction(RestartCleanupType.ACTION_JOBRERUN);
        rco.setCleanup(CleanUpOption.MANUAL);
        rco.setUseExpandedJCL(false);
        plan.beginJobRestartCleanup(restartID, rco, null);


        /*
         * Now get datasets lists for the specified restart step
         */
        List datasetList = plan.getJobDataSets(restartID, null);

        /* Here you can modify datasetList if needed*/

        /*
         * Now set the datasets
         */
        plan.setJobDataSets(restartID, datasetList, null);
        /*
         * Now get the JCL
         */
        JobControlLanguage jcl = plan.getJobJCL(restartID, true, null);

        /* Here you can modify jcl if needed*/

        /*
         * Now set the JCL
         */
        plan.setJobJCL(restartID, jcl, true, null);
        /*
         * Execute the step-restart operation
         */
        plan.executeJobRestartCleanup(restartID, "JCL", null, null, null);
        /*
         * commit the step restart phase
         */
        plan.commitJobRestartAndCleanup(JobInPlan.class, restartID, null);

    }
    catch (ConnException e)
    {
        plan.rollbackJobRestartAndCleanup(JobInPlan.class, restartID, null);
    }

I hope this will be helpful.