/** * Pops a header from a message. Creates a new Header from the values contained by the message. * * @param message message that contains the info to build the header * @return a header builted from the values of contained by the message */ public static SEQHeader pop(Message message) { SEQHeader header = new SEQHeader(); header.order = message.popLong(); header.sn = message.popLong(); header.id = message.popInt(); return header; }
/** * Multicast a SEQUENCER message to the group. * * @param container the container of the message to be sequenced. */ private void reliableSEQMulticast(ListContainer container) { SEQHeader header = new SEQHeader(container.header.sender(), container.header.sn(), globalSN); SeqOrderEvent event; try { event = new SeqOrderEvent(container.event.getChannel(), Direction.DOWN, this, vs.group, vs.id); SEQHeader.push(header, event.getMessage()); Message msg = event.getMessage(); for (int i = 0; i < lastOrderList.length; i++) msg.pushLong(lastOrderList[i]); log.debug("Sending SEQ message. Rank=" + ls.my_rank + " Header: " + header); event.go(); } catch (AppiaEventException e2) { e2.printStackTrace(); } }
/** Deliver a SEQUENCER message received from the network. */ private void reliableSEQDeliver(SeqOrderEvent event) { Message msg = event.getMessage(); long[] uniformInfo = new long[vs.view.length]; for (int i = uniformInfo.length; i > 0; i--) uniformInfo[i - 1] = msg.popLong(); mergeUniformInfo(uniformInfo); SEQHeader header = SEQHeader.pop(event.getMessage()); log.debug( "[" + ls.my_rank + "] Received SEQ message " + header.id + ":" + header.sn + " timestamp is " + timeProvider.currentTimeMillis()); lastOrderList[ls.my_rank] = header.order; newUniformInfo = true; // add it to the sequencer list S.add(new ListSEQContainer(header, timeProvider.currentTimeMillis())); log.debug("Received SEQ from " + event.orig + " at time " + timeProvider.currentTimeMillis()); // and tries to deliver messages that already have the order deliverRegular(); deliverUniform(); }