Exemplo n.º 1
0
 /**
  * This method stores the given task with the specified name in the DMS and submits the task for
  * asynchronous execution in the DMS. After completing the task successfully it returns true. If
  * there is a task failure, then it prints the error description and returns false.
  *
  * @param taskObj task object
  * @param taskName name of the task
  * @return boolean returns true when the task is successful
  * @exception JDMException if task execution failed
  */
 public static boolean executeTask(Task taskObj, String taskName) throws JDMException {
   boolean isTaskSuccess = false;
   m_dmeConn.saveObject(taskName, taskObj, true);
   ExecutionHandle execHandle = m_dmeConn.execute(taskName);
   System.out.print("\n" + taskName + " is started, please wait. ");
   // Wait for completion of the task
   ExecutionStatus status = execHandle.waitForCompletion(Integer.MAX_VALUE);
   // Check the status of the task after completion
   isTaskSuccess = status.getState().equals(ExecutionState.success);
   if (isTaskSuccess) {
     // Task completed successfully
     System.out.println(taskName + " is successful.\n");
   } else { // Task failed
     System.out.println(
         taskName + " is failed.\nFailure Description: " + status.getDescription() + "\n");
   }
   return isTaskSuccess;
 }