Esempio n. 1
0
 protected void deliver(Message msg, Event evt, SequencerHeader hdr) {
   Address sender = msg.getSrc();
   if (sender == null) {
     if (log.isErrorEnabled())
       log.error(local_addr + ": sender is null, cannot deliver " + "::" + hdr.getSeqno());
     return;
   }
   long msg_seqno = hdr.getSeqno();
   if (sender.equals(local_addr)) {
     forward_table.remove(msg_seqno);
     if (hdr.flush_ack) {
       ack_promise.setResult(msg_seqno);
       if (ack_mode && !flushing && threshold > 0 && ++num_acks >= threshold) {
         ack_mode = false;
         num_acks = 0;
       }
     }
   }
   if (!canDeliver(sender, msg_seqno)) {
     if (log.isWarnEnabled())
       log.warn(local_addr + ": dropped duplicate message " + sender + "::" + msg_seqno);
     return;
   }
   if (log.isTraceEnabled()) log.trace(local_addr + ": delivering " + sender + "::" + msg_seqno);
   up_prot.up(evt);
   delivered_bcasts++;
 }
Esempio n. 2
0
 /**
  * Unmarshal the original message (in the payload) and then pass it up (unless already delivered)
  *
  * @param msg
  */
 protected void unwrapAndDeliver(final Message msg, boolean flush_ack) {
   try {
     Message msg_to_deliver =
         Util.streamableFromBuffer(
             Message.class, msg.getRawBuffer(), msg.getOffset(), msg.getLength());
     SequencerHeader hdr = (SequencerHeader) msg_to_deliver.getHeader(this.id);
     if (flush_ack) hdr.flush_ack = true;
     deliver(msg_to_deliver, new Event(Event.MSG, msg_to_deliver), hdr);
   } catch (Exception ex) {
     log.error(Util.getMessage("FailureUnmarshallingBuffer"), ex);
   }
 }
Esempio n. 3
0
  protected void broadcast(
      final Message msg, boolean copy, Address original_sender, long seqno, boolean resend) {
    Message bcast_msg = null;

    if (!copy) {
      bcast_msg = msg; // no need to add a header, message already has one
    } else {
      SequencerHeader new_hdr = new SequencerHeader(SequencerHeader.WRAPPED_BCAST, seqno);
      bcast_msg =
          new Message(null, msg.getRawBuffer(), msg.getOffset(), msg.getLength())
              .putHeader(this.id, new_hdr);
      if (resend) {
        new_hdr.flush_ack = true;
        bcast_msg.setFlag(Message.Flag.DONT_BUNDLE);
      }
    }

    if (log.isTraceEnabled())
      log.trace(local_addr + ": broadcasting " + original_sender + "::" + seqno);

    down_prot.down(new Event(Event.MSG, bcast_msg));
    bcast_msgs++;
  }