示例#1
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();
    }
  }
示例#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 DATAHeader pop(Message message) {
   DATAHeader header = new DATAHeader(-1, -1);
   header.delay = message.popLong();
   header.sn = message.popLong();
   header.id = message.popInt();
   return header;
 }
示例#3
0
 /**
  * Multicast a DATA event to the group.
  *
  * @param event the event to be multicast.
  * @param msgDelay the message delay associated with the event.
  */
 private void reliableDATAMulticast(GroupSendableEvent event, long msgDelay) {
   DATAHeader header = new DATAHeader(ls.my_rank, sendingLocalSN++, msgDelay);
   DATAHeader.push(header, event.getMessage());
   Message msg = event.getMessage();
   for (int i = 0; i < lastOrderList.length; i++) msg.pushLong(lastOrderList[i]);
   log.debug(
       "Sending DATA message from appl. Rank="
           + ls.my_rank
           + " SN="
           + sendingLocalSN
           + " Delay="
           + msgDelay);
   try {
     event.go();
   } catch (AppiaEventException e) {
     e.printStackTrace();
   }
   timeLastMsgSent = timeProvider.currentTimeMillis();
 }
示例#4
0
 public DATAHeader(DATAHeader obj) {
   this.id = obj.sender();
   this.sn = obj.sn();
   delay = obj.get_delay();
 }