Java Reference
In-Depth Information
53. ExecutionStatus status = dmeConn.execute( btk, timeOut );
54. if( ExecutionState.success.equals( status.getState() ) )
55. return true;
56. else
57. return false;
58. }
59. //Retrieve built model
60. public void output() throws JDMException {
61. ClassificationModel clsModel = (ClassificationModel)dmeConn.retrieveObject(
62. "attrition_model", NamedObject.model );
63. }
64. //Remove the model to be able to reexecute this example
65. public void reset() throws JDMException {
66. dmeConn.removeObject("attrition_model", NamedObject.model );
67. )
9.1.3
Executing Mining Operations
The Connection interface has two execute methods, one used for
synchronous task execution and another used for asynchronous task
execution. Listing 9-4 uses the synchronous execution in the run
method: Connection.execute(Task, timeOut) (line 53). This method
returns the status of task execution only after the task finishes execu-
tion in the DME. In line 52, the timeOut argument value is specified
as null to indicate that the code will block until the task finishes
execution, ending in either success or failure. However, one can
specify a maximum task duration in seconds. If task execution is not
completed by the specified timeOut period, it will be terminated and
the execute method returns, putting the task in a terminated state.
Often, synchronous execution will be used for short running tasks,
such as a record apply task where the apply results can be obtained
in real-time.
Listing 9-5 shows the asynchronous version of this example using
the attritionBuildTask and the method Connection.execute(taskName)
(line 5). This method takes the name of a task saved in the DME (line
4) before invoking the execute method. This method returns an Execu-
tionHandle object that is used to monitor the task execution in the
DME. To get task execution status, the application uses the getLatest-
Status method (line 7). Table 9-5 and Table 9-6 list the methods of the
ExecutionHandle and ExecutionStatus interfaces, respectively. Appli-
cations either can wait for the completion of an asynchronous task
using the ExecutionHandle.waitForCompletion method (line 10) or can
check the status as needed using the ExecutionHandle.getLatestStatus
 
Search WWH ::




Custom Search