Package org.nebulaframework.grid.service.message

Examples of org.nebulaframework.grid.service.message.ServiceMessage


    }

    log.info("Node registered [ID:" + nodeId + "]");

    // Notify Service Event
    ServiceMessage message = new ServiceMessage(nodeId.toString(),ServiceMessageType.NODE_REGISTERED);
    ServiceEventsSupport.getInstance().onServiceMessage(message);

    // Create HeartBeat Failure Hook
    ServiceEventsSupport.addServiceHook(new ServiceHookCallback() {
      public void onServiceEvent(ServiceMessage msg) {
        synchronized (this) {
          clusterNodes.remove(nodeId);
         
          // Notify Service Event
          ServiceMessage message = new ServiceMessage(nodeId.toString(),ServiceMessageType.NODE_UNREGISTERED);
          ServiceEventsSupport.getInstance().onServiceMessage(message);
        }   
      }
    }, nodeId.toString(), ServiceMessageType.HEARTBEAT_FAILED);
   
View Full Code Here


   */
  public void unregisterNode(UUID id) {
    synchronized (this) {
      this.clusterNodes.remove(id);
    }
    ServiceMessage message = new ServiceMessage(id.toString(), ServiceMessageType.NODE_UNREGISTERED);
    cluster.getServiceMessageSender().sendServiceMessage(message);
    log.info("Node unregistered [ID:" + id + "]");
  }
View Full Code Here

        return;
      }
    }
   
    // Send Default Peer Disconnection Messages
    ServiceMessage message = null;
    message = new ServiceMessage(this.clusterInfo.getServiceUrl(), ServiceMessageType.PEER_DISCONNECTION);
    serviceMessageSender.sendServiceMessage(message);
   
    // Send Alternative Transport Peer Disconnection Messages (if applicable)
    for (String transport : clusterInfo.getTransportUrls()) {
      message = new ServiceMessage(transport, ServiceMessageType.PEER_DISCONNECTION);
      serviceMessageSender.sendServiceMessage(message);
    }
   
    // Send Shutdown Message
    message = new ServiceMessage(this.clusterId.toString(),
                                                ServiceMessageType.CLUSTER_SHUTDOWN);
   
    serviceMessageSender.sendServiceMessage(message);
   
    try {
View Full Code Here

       
        missed++;

        // If  missed more than MAX_MISS, notify
        if (missed > ClusterHeartBeatService.MAX_MISS) {
          ServiceMessage message = new ServiceMessage(nodeId
              .toString(), ServiceMessageType.HEARTBEAT_FAILED);
          ClusterManager.getInstance().getServiceMessageSender()
              .sendServiceMessage(message);
          log.warn("[Heartbeat] Heartbeat Failed on " + nodeId.toString());
          stop();
View Full Code Here

       
        // Start Executor
        executor.start(loader);
       
        // Fire Local Event
        ServiceMessage message = new ServiceMessage(jobId, ServiceMessageType.LOCAL_JOBSTARTED);
        ServiceEventsSupport.fireServiceEvent(message);
       
        // Add a hook to stop job if Cluster fails
        ServiceEventsSupport.addServiceHook(new ServiceHookCallback() {

          @Override
          public void onServiceEvent(ServiceMessage message) {
            ServiceMessage msg = new ServiceMessage(jobId, ServiceMessageType.JOB_END);
            try {
              GridNode.getInstance().getJobExecutionService().onServiceMessage(msg);
            } catch (IllegalStateException e) {
              log.debug("GridNode Instance Destroyed");
            }
View Full Code Here

      synchronized (TaskExecutor.class) {
        // Invoke stop() instance method on proper TaskExecutor
        TaskExecutor.executors.get(jobId).stop();
       
        // Fire Local Event
        ServiceMessage message = new ServiceMessage(jobId, ServiceMessageType.LOCAL_JOBFINISHED);
        ServiceEventsSupport.fireServiceEvent(message);
       
      }
    } catch (NullPointerException e) {
      // No TaskExecutor for given Job
View Full Code Here

      // 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
      sendResult(taskResult);
     
      // Fire Local Event
      ServiceMessage doneMessage = new ServiceMessage(jobId, ServiceMessageType.LOCAL_TASKDONE);
      ServiceEventsSupport.fireServiceEvent(doneMessage);
     
     
      // Fire Local Event
      ServiceMessage timeMessage = new ServiceMessage(String.valueOf(duration),
                                                      ServiceMessageType.LOCAL_TASKEXEC);
      ServiceEventsSupport.fireServiceEvent(timeMessage);
    }
  }
View Full Code Here

      peers.put(url, con);
      log.info("[PeerService] Connected with Peer Cluster on " + url);
     
      // Notify Event Hooks
      ServiceMessage message = new ServiceMessage(url, ServiceMessageType.PEER_CONNECTION);
      ServiceEventsSupport.getInstance().onServiceMessage(message);
     
    } catch (Exception e) {
      log.warn("[PeerService] Unable to connect with Cluster " + url, e);
      if (con!=null) {  // If Connection was created
View Full Code Here

  protected void notifyJobStart(String jobId) {

    log.info("[JobService] Starting GridJob " + jobId);

    // Create ServiceMessage for Job Start Notification
    ServiceMessage message = new ServiceMessage(jobId,
        ServiceMessageType.JOB_START);

    // Send ServiceMessage to GridNodes
    cluster.getServiceMessageSender().sendServiceMessage(message);
    log.debug("[ClusterJobService] Notified Job Start {" + jobId + "}");
View Full Code Here

    // Remove GridJob from Active GridJobs map
    removeJob(jobId);

    // Create ServiceMessage for Job End Notification
    ServiceMessage message = new ServiceMessage(jobId,
        ServiceMessageType.JOB_END);

    // Send ServiceMessage to GridNodes
    cluster.getServiceMessageSender().sendServiceMessage(message);
    log.debug("[ClusterJobService] Notified Job End {" + jobId + "}");
View Full Code Here

TOP

Related Classes of org.nebulaframework.grid.service.message.ServiceMessage

Copyright © 2018 www.massapicom. 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.