Пример #1
0
  public void up(MessageBatch batch) {
    if (batch.dest() == null) { // not a unicast batch
      up_prot.up(batch);
      return;
    }

    int size = batch.size();
    Map<Short, List<Message>> msgs =
        new TreeMap<Short, List<Message>>(); // map of messages, keyed by conn-id
    for (Message msg : batch) {
      if (msg == null || msg.isFlagSet(Message.Flag.NO_RELIABILITY)) continue;
      UnicastHeader hdr = (UnicastHeader) msg.getHeader(id);
      if (hdr == null) continue;
      batch.remove(msg); // remove the message from the batch, so it won't be passed up the stack

      if (hdr.type != UnicastHeader.DATA) {
        try {
          handleUpEvent(msg.getSrc(), hdr);
        } catch (Throwable t) { // we cannot let an exception terminate the processing of this batch
          log.error(local_addr + ": failed handling event", t);
        }
        continue;
      }

      List<Message> list = msgs.get(hdr.conn_id);
      if (list == null) msgs.put(hdr.conn_id, list = new ArrayList<Message>(size));
      list.add(msg);
    }

    if (!msgs.isEmpty()) handleBatchReceived(batch.sender(), msgs); // process msgs:
    if (!batch.isEmpty()) up_prot.up(batch);
  }
Пример #2
0
 public void up(MessageBatch batch) {
   for (Message msg : batch) {
     FragHeader hdr = (FragHeader) msg.getHeader(this.id);
     if (hdr != null) { // needs to be defragmented
       Message assembled_msg = unfragment(msg, hdr);
       if (assembled_msg != null)
         // the reassembled msg has to be add in the right place
         // (https://issues.jboss.org/browse/JGRP-1648),
         // and canot be added to the tail of the batch !
         batch.replace(msg, assembled_msg);
       else batch.remove(msg);
     }
   }
   if (!batch.isEmpty()) up_prot.up(batch);
 }