Ejemplo n.º 1
0
  private void publishFailureDetected(String broker) {
    try {
      String pubStr =
          "[class,"
              + HeartbeatSubscriber.MESSAGE_CLASS
              + "],"
              + "[detectorID,'"
              + m_BrokerCore.getBrokerID()
              + "'],"
              + "[detectedID,'"
              + broker
              + "'],"
              + "[type,'FAILURE_DETECTED']";
      Publication pub = MessageFactory.createPublicationFromString(pubStr);
      PublicationMessage pubMsg =
          new PublicationMessage(
              pub, m_BrokerCore.getNewMessageID(), MessageDestination.HEARTBEAT_MANAGER);

      Map<MessageDestination, LinkInfo> statisticTable =
          m_BrokerCore.getOverlayManager().getORT().getStatisticTable();
      MessageDestination failureBroker = new MessageDestination(broker, DestinationType.BROKER);
      if (statisticTable.containsKey(failureBroker)) {
        LinkInfo link = statisticTable.get(failureBroker);
        link.setStatus();
      }

      heartbeatLogger.info("Sending failure of " + broker + " detected messsage.");
      m_BrokerCore.routeMessage(pubMsg, MessageDestination.INPUTQUEUE);
    } catch (ParseException e) {
      heartbeatLogger.error(e.getMessage());
      exceptionLogger.error(e.getMessage());
    }
  }
Ejemplo n.º 2
0
 public PublicationMessage publish(String pubStr, String brokerID) throws ClientException {
   try {
     Publication newPub = MessageFactory.createPublicationFromString(pubStr);
     if (newPub.getClassVal() == null) {
       throw new ClientException("Publication syntax error");
     }
     return publish(newPub, brokerID);
   } catch (ParseException e) {
     throw new ClientException(e);
   }
 }
Ejemplo n.º 3
0
  private void publishHeartbeats() {
    try {
      Map<MessageDestination, OutputQueue> neighbors =
          m_BrokerCore.getOverlayManager().getORT().getBrokerQueues();
      synchronized (neighbors) {
        for (MessageDestination md : neighbors.keySet()) {
          String brokerID = md.getDestinationID();

          // create and set a timer event for the heartbeat request
          TimerEvent event = new TimerEvent(this, m_HeartbeatTimeout, HEARTBEAT_TIMEOUT_TIMER);
          event.setAttachment(brokerID);
          int handle = m_TimerThread.setTimer(event);

          // publish the heartbeat request
          String pubStr =
              "[class,"
                  + HeartbeatSubscriber.MESSAGE_CLASS
                  + "],"
                  + "[brokerID,'"
                  + brokerID
                  + "'],"
                  + "[fromID,'"
                  + m_BrokerCore.getBrokerID()
                  + "'],"
                  + "[type,'HEARTBEAT_REQ'],"
                  + "[handle,'"
                  + handle
                  + "']";
          Publication pub = MessageFactory.createPublicationFromString(pubStr);
          PublicationMessage pubMsg =
              new PublicationMessage(
                  pub, m_BrokerCore.getNewMessageID(), MessageDestination.HEARTBEAT_MANAGER);
          heartbeatLogger.info(
              "Broker "
                  + m_BrokerCore.getBrokerID()
                  + " is sending heartbeat REQ to broker "
                  + brokerID
                  + " with handle "
                  + handle);
          m_BrokerCore.routeMessage(pubMsg, MessageDestination.INPUTQUEUE);
          // add by shuang for testing
          currentHandle = handle;
        }
      }
    } catch (ParseException e) {
      heartbeatLogger.error(e.getMessage());
      exceptionLogger.error(e.getMessage());
    }
  }