示例#1
0
  public void messageReceived(ClusterMessage message) {

    if (log.isDebugEnabled() && message != null)
      log.debug(
          "Assuming clocks are synched: Replication for "
              + message.getUniqueId()
              + " took="
              + (System.currentTimeMillis() - (message).getTimestamp())
              + " ms.");

    // invoke all the listeners
    boolean accepted = false;
    if (message != null) {
      for (Iterator<ClusterListener> iter = clusterListeners.iterator(); iter.hasNext(); ) {
        ClusterListener listener = iter.next();
        if (listener.accept(message)) {
          accepted = true;
          listener.messageReceived(message);
        }
      }
      if (!accepted && notifyLifecycleListenerOnFailure) {
        Member dest = message.getAddress();
        // Notify our interested LifecycleListeners
        fireLifecycleEvent(RECEIVE_MESSAGE_FAILURE_EVENT, new SendMessageData(message, dest, null));
        if (log.isDebugEnabled()) {
          log.debug(
              "Message "
                  + message.toString()
                  + " from type "
                  + message.getClass().getName()
                  + " transfered but no listener registered");
        }
      }
    }
    return;
  }
示例#2
0
 /**
  * send a cluster message to one member
  *
  * @param msg message to transfer
  * @param dest Receiver member
  * @see org.apache.catalina.ha.CatalinaCluster#send(org.apache.catalina.ha.ClusterMessage,
  *     org.apache.catalina.tribes.Member)
  */
 @Override
 public void send(ClusterMessage msg, Member dest) {
   try {
     msg.setAddress(getLocalMember());
     int sendOptions = channelSendOptions;
     if (msg instanceof SessionMessage
         && ((SessionMessage) msg).getEventType() == SessionMessage.EVT_ALL_SESSION_DATA) {
       sendOptions = Channel.SEND_OPTIONS_SYNCHRONIZED_ACK | Channel.SEND_OPTIONS_USE_ACK;
     }
     if (dest != null) {
       if (!getLocalMember().equals(dest)) {
         channel.send(new Member[] {dest}, msg, sendOptions);
       } else log.error(sm.getString("simpleTcpCluster.unableSend.localMember", msg));
     } else {
       Member[] destmembers = channel.getMembers();
       if (destmembers.length > 0) channel.send(destmembers, msg, sendOptions);
       else if (log.isDebugEnabled()) log.debug("No members in cluster, ignoring message:" + msg);
     }
   } catch (Exception x) {
     log.error(sm.getString("simpleTcpCluster.sendFailed"), x);
   }
 }
示例#3
0
 @Override
 public void messageReceived(Serializable message, Member sender) {
   ClusterMessage fwd = (ClusterMessage) message;
   fwd.setAddress(sender);
   messageReceived(fwd);
 }