Java Reference
In-Depth Information
Listing 9-5
Asynchronous execution of the task and monitoring of task execution
1. public boolean run() throws JDMException {
2. BuildTask btk = btkFactory.create( "attritionBuildData",
3. "attritionBuildSettings", "attrition_model" );
4. dmeConn.saveObject("attrition_build_task", btk, true);
5. ExecutionHandle btkExecHandle = dmeConn.execute("attrition_build_task");
6. //Get the status of the execution
7. ExecutionStatus btkExecStatus = btkExecHandle.getLatestStatus();
8. System.out.println(btkExecStatus.getState());
9. int waitUntilCompletion=0;
10. ExecutionStatus status = btkExecHandle.waitForCompletion(waitUntilCompletion);
11. if( ExecutionState.success.equals( status.getState() ) )
12. return true;
13. else
14. return false;
15. }
method. Both methods return an ExecutionStatus object that is used to
get the execution state using the getState method. Figure 9-1 shows the
possible state transitions for task execution. When a task is executed,
it starts in the submitted state to indicate that the task is successfully
submitted to the DME for execution. Based on the DME implementa-
tion, the task execution can be queued or executed immediately.
When the task begins execution, it enters the executing state and
remains there until completion. When execution successfully com-
pletes, the execution status enters the success state, otherwise it enters
the error state. Using the ExecutionHandle.terminate method, a task can
be terminated when it is in either the submitted or executing states.
When the terminate method is invoked, the task enters the terminating
state, and after successful termination, it enters the terminated state.
The ExecutionStatus object encapsulates execution state entry time,
and any description or warnings associated with the state. A JDM
implementation can add implementation-specific states, for example,
a queued state between the submitted and executing states, etc.
Figure 9-1
Task execution state transition.
Search WWH ::

Custom Search