Пример #1
0
 @Test(dataProvider = "createTimer")
 public void test9(TimeScheduler timer) throws Exception {
   try {
     NakReceiverWindow win = new NakReceiverWindow(sender, cmd, 0, timer);
     win.add(1, new Message());
     win.add(2, new Message());
     win.add(3, new Message());
     win.add(4, new Message());
     win.add(6, new Message());
     System.out.println("win: " + win);
     while ((win.remove()) != null) ;
     win.stable(6); // 6 is ignore as it is >= highest delivered message
     System.out.println("win: " + win);
     assert win.get(2) != null;
     check(win, 0, 6, 4);
     win.add(5, new Message());
     check(win, 0, 6, 4);
     while ((win.remove()) != null) ;
     check(win, 0, 6, 6);
     win.stable(6);
     check(win, 6, 6, 6);
   } finally {
     timer.stop();
   }
 }
Пример #2
0
 @Test(dataProvider = "createTimer")
 public void testHighestDelivered(TimeScheduler timer) throws Exception {
   try {
     NakReceiverWindow win = new NakReceiverWindow(sender, cmd, 0, timer);
     win.add(1, new Message());
     win.add(2, new Message());
     win.add(3, new Message());
     win.add(4, new Message());
     check(win, 0, 4, 0);
     win.add(10, new Message());
     check(win, 0, 10, 0);
     System.out.println("win: " + win);
     win.add(9, new Message());
     win.add(7, new Message());
     win.add(8, new Message());
     win.add(6, new Message());
     win.add(5, new Message());
     System.out.println("win: " + win);
     check(win, 0, 10, 0);
     while ((win.remove()) != null) ;
     check(win, 0, 10, 10);
     win.stable(5);
     System.out.println("win: " + win);
     check(win, 5, 10, 10);
     win.stable(10);
     System.out.println("win: " + win);
     check(win, 10, 10, 10);
   } finally {
     timer.stop();
   }
 }
Пример #3
0
 @Test(dataProvider = "createTimer")
 public void testAdd(TimeScheduler timer) throws Exception {
   try {
     NakReceiverWindow win = new NakReceiverWindow(sender, cmd, 0, timer);
     check(win, 0, 0, 0);
     win.add(0, new Message()); // discarded, next expected is 1
     check(win, 0, 0, 0);
     win.add(1, new Message());
     check(win, 0, 1, 0);
     win.add(2, new Message());
     win.add(3, new Message());
     win.add(4, new Message());
     check(win, 0, 4, 0);
     win.add(6, new Message());
     check(win, 0, 6, 0);
     win.add(5, new Message());
     check(win, 0, 6, 0);
     while (win.remove() != null) ;
     check(win, 0, 6, 6);
     win.stable(4);
     check(win, 4, 6, 6);
     win.stable(6);
     check(win, 6, 6, 6);
   } finally {
     timer.stop();
   }
 }
Пример #4
0
 @Test(dataProvider = "createTimer")
 public void test8(TimeScheduler timer) throws Exception {
   try {
     NakReceiverWindow win = new NakReceiverWindow(sender, cmd, 0, timer);
     win.add(1, new Message());
     win.add(2, new Message());
     win.add(3, new Message());
     win.add(4, new Message());
     win.add(6, new Message());
     check(win, 0, 6, 0); // haven't delivered a message yet
     while (win.remove() != null) ;
     check(win, 0, 6, 4);
     win.add(5, new Message());
     check(win, 0, 6, 4);
     win.remove();
     check(win, 0, 6, 5);
     win.remove();
     check(win, 0, 6, 6);
     win.stable(4);
     check(win, 4, 6, 6);
     win.stable(6);
     check(win, 6, 6, 6);
   } finally {
     timer.stop();
   }
 }
Пример #5
0
  protected void sendStableMessage(Address dest, short conn_id, long low, long high) {
    Message stable_msg = new Message(dest, null, null);
    Unicast2Header hdr = Unicast2Header.createStableHeader(conn_id, low, high);
    stable_msg.putHeader(this.id, hdr);
    stable_msg.setFlag(Message.OOB);
    if (log.isTraceEnabled()) {
      StringBuilder sb = new StringBuilder();
      sb.append(local_addr)
          .append(" --> STABLE(")
          .append(dest)
          .append(": ")
          .append(low)
          .append("-")
          .append(high)
          .append(", conn_id=")
          .append(conn_id)
          .append(")");
      log.trace(sb.toString());
    }
    down_prot.down(new Event(Event.MSG, stable_msg));

    ReceiverEntry entry = recv_table.get(dest);
    NakReceiverWindow win = entry != null ? entry.received_msgs : null;
    if (win != null) win.stable(win.getHighestDelivered());
  }
Пример #6
0
 @ManagedOperation(
     description = "Purges highes delivered messages and compacts the retransmission tables")
 public void purgeAndCompact() {
   for (Map.Entry<Address, ReceiverEntry> entry : recv_table.entrySet()) {
     NakReceiverWindow win = entry.getValue().received_msgs;
     win.stable(win.getHighestDelivered());
     win.compact();
   }
 }
Пример #7
0
 @Test(dataProvider = "createTimer")
 public void test7(TimeScheduler timer) throws Exception {
   try {
     NakReceiverWindow win = new NakReceiverWindow(sender, cmd, 0, timer);
     win.add(1, new Message());
     win.add(2, new Message());
     win.add(3, new Message());
     win.add(4, new Message());
     check(win, 0, 4, 0);
     System.out.println("Note that the subsequent warning is expected:");
     win.stable(4); // no-op because we haven't even removed 4 messages
     check(win, 0, 4, 0);
     while (win.remove() != null) ;
     check(win, 0, 4, 4);
     win.stable(4);
     check(win, 4, 4, 4);
   } finally {
     timer.stop();
   }
 }
Пример #8
0
 @Test(dataProvider = "createTimer")
 public void test10a(TimeScheduler timer) throws Exception {
   try {
     NakReceiverWindow win = new NakReceiverWindow(sender, cmd, 0, timer);
     win.add(1, new Message());
     win.add(2, new Message());
     win.add(3, new Message());
     win.add(4, new Message());
     while ((win.remove()) != null) ;
     win.stable(4);
     check(win, 4, 4, 4);
   } finally {
     timer.stop();
   }
 }