Exemple #1
0
 /**
  * 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 DATAHeader pop(Message message) {
   DATAHeader header = new DATAHeader(-1, -1);
   header.delay = message.popLong();
   header.sn = message.popLong();
   header.id = message.popInt();
   return header;
 }
Exemple #2
0
 /**
  * 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;
 }
Exemple #3
0
  /**
   * Deliver a DATA event received from the network.
   *
   * @param event the event received from the network.
   */
  private void reliableDATADeliver(GroupSendableEvent 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);
    DATAHeader header = DATAHeader.pop(event.getMessage());
    log.debug(
        "Received DATA message: "
            + header.id
            + ":"
            + header.sn
            + " timestpamp is "
            + timeProvider.currentTimeMillis());
    header.setTime(delay[header.id] + timeProvider.currentTimeMillis());
    ListContainer container = new ListContainer(event, header);
    // add the event to the RECEIVED list...
    R.addLast(container);
    // ... and set a timer to be delivered later, according to the delay that came with the message
    setTimer(container, delay[header.id], vs.id);

    // Deliver event to the upper layer (spontaneous order)
    try {
      event.go();
    } catch (AppiaEventException e) {
      e.printStackTrace();
    }
  }
Exemple #4
0
 private void handleUniformInfo(UniformInfoEvent event) {
   log.debug(
       "Received UniformInfo from " + event.orig + ". Uniformity information table now is: ");
   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);
   if (log.isDebugEnabled())
     for (int i = 0; i < lastOrderList.length; i++)
       log.debug("RANK :" + i + " | LAST_ORDER: " + lastOrderList[i]);
   deliverUniform();
 }
Exemple #5
0
 /** 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();
 }
 /**
  * Clears the values of the VC in the header of a message.
  *
  * @param omsg the message whose header will be cleared.
  */
 private void clearVC(Message omsg) {
   for (int i = 0; i < VC.length; i++) omsg.popLong();
 }
 /**
  * Extracts the VC from the header of a message.
  *
  * @param omsg the message from where the VC will be extracted.
  * @param VCm array where the values of the VC for the given message will be stored.
  */
 private void extractVCm(Message omsg, long[] VCm) {
   for (int i = VCm.length - 1; i >= 0; i--) VCm[i] = omsg.popLong();
 }