Examples of GridTaskResultImpl


Examples of org.nebulaframework.core.task.GridTaskResultImpl

    // Update Stats
    taskCount++;

    // Create Result Wrapper
    GridTaskResultImpl taskResult = new GridTaskResultImpl(jobId, taskId,
        node.getId());

    // Execution Start Time
    long start = System.currentTimeMillis();
   
    try {
     
      // Execute Task
      Serializable result = task.execute();

      // Put result into Result Wrapper
      taskResult.setResult(result);
     
      // Reset Consecutive Failure Count
      consecFails = 0;
     
    } catch (Exception e) {

      log.warn("[TaskExecutor] Exception while executing GridTask", e);

      // Exception, send exception details instead of result
      taskResult.setException(e);

      // Update consecutive failures, and check for limit
      consecFails++;
     
      // Fire Local Event
      ServiceMessage message = new ServiceMessage(jobId, ServiceMessageType.LOCAL_TASKFAILED);
      ServiceEventsSupport.fireServiceEvent(message);
     
      if (consecFails > CONSECUTIVE_FAILURES_THRESHOLD) {
        try {
         
          // If we are above consecutive failure threshold,
          // slow down result production
          Thread.sleep(500 * (consecFails - CONSECUTIVE_FAILURES_THRESHOLD));
         
        } catch (InterruptedException ie) {
          log.warn("Interrupted", ie);
        }
      }
     
    } finally {
     
      // Set Execution Time
      long duration = System.currentTimeMillis() - start;
      taskResult.setExecutionTime(duration);
     
      // If result is execution time aware, set the execution time
      if (taskResult.getResult() instanceof ExecutionTimeAware) {
        ((ExecutionTimeAware) taskResult.getResult()).setExecutionTime(duration);
      }
     
      log.debug("[TaskExecutor] Sending Result for Task " + taskId + " | Duration : " + duration);
     
      // Send the result to ResultQueue
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.