예제 #1
0
 /** Sets a timer to delay a message that came from the network. */
 private void setTimer(ListContainer container, long timeout, ViewID vid) {
   try {
     log.debug("TIME Container: " + container.header.getTime());
     SETOTimer timer =
         new SETOTimer(
             timeout / 1000,
             container.event.getChannel(),
             Direction.DOWN,
             this,
             EventQualifier.ON,
             container,
             vid);
     timer.go();
     if (log.isDebugEnabled())
       log.debug(
           "Setting new timer. NOW is "
               + timeProvider.currentTimeMillis()
               + " timer to "
               + timer.getTimeout());
   } catch (AppiaEventException e) {
     e.printStackTrace();
   } catch (AppiaException e) {
     e.printStackTrace();
   }
 }
예제 #2
0
  private void handleView(View ev) {
    vs = ev.vs;
    ls = ev.ls;

    try {
      ev.go();
    } catch (AppiaEventException ex) {
      ex.printStackTrace();
    }

    if (round == 0) {
      try {
        SuspectTimer periodic =
            new SuspectTimer("Suspect Timer", suspect_sweep, ev.getChannel(), this);
        periodic.go();
      } catch (AppiaException ex) {
        ex.printStackTrace();
        System.err.println(
            "appia:group:SuspectSession: impossible to set SuspectTimer, SuspectSession will be idle");
      }
    }

    if (vs.view.length != last_recv.length) {
      last_recv = new long[vs.view.length];
    }
    round = 1;
    Arrays.fill(last_recv, round);
  }
예제 #3
0
  private void deliverPendingView() {
    try {
      pendingView.go();
    } catch (AppiaEventException e) {
      e.printStackTrace();
    }

    if (!pendingMessages.isEmpty()) {
      log.debug("Delivering " + pendingMessages.size() + " pending messages");
      for (GroupSendableEvent event : pendingMessages) {
        reliableDATADeliver(event);
      }
      pendingMessages.clear();
    }

    if (!utSet) {
      try {
        UniformTimer ut =
            new UniformTimer(
                UNIFORM_INFO_PERIOD,
                pendingView.getChannel(),
                Direction.DOWN,
                this,
                EventQualifier.ON);
        ut.go();
        utSet = true;
      } catch (AppiaEventException e) {
        e.printStackTrace();
      } catch (AppiaException e) {
        e.printStackTrace();
      }
    }

    pendingView = null;
  }
예제 #4
0
  private void handleSuspectTimer(SuspectTimer ev) {
    if (ev.getPeriod() != suspect_sweep) {
      ev.setDir(Direction.invert(ev.getDir()));
      ev.setQualifierMode(EventQualifier.OFF);
      ev.setSource(this);
      try {
        ev.init();
        ev.go();
        SuspectTimer periodic =
            new SuspectTimer("Suspect Timer", suspect_sweep, ev.getChannel(), this);
        periodic.go();
      } catch (AppiaEventException e) {
        e.printStackTrace();
      } catch (AppiaException ex) {
        ex.printStackTrace();
        log.error(
            "appia:group:SuspectSession: impossible to set SuspectTimer, SuspectSession will be idle");
      }
      return;
    }

    try {
      ev.go();
    } catch (AppiaEventException ex) {
      ex.printStackTrace();
    }

    int i;
    boolean[] new_failed = null;

    for (i = 0; i < last_recv.length; i++) {
      if (i != ls.my_rank) {
        if ((round - last_recv[i] >= rounds_idle) && !ls.failed[i]) {
          ls.fail(i);
          if (new_failed == null) {
            new_failed = new boolean[ls.failed.length];
            Arrays.fill(new_failed, false);
          }
          new_failed[i] = true;

          log.debug(
              "Suspected "
                  + i
                  + " because it passed "
                  + (round - last_recv[i])
                  + " rounds of "
                  + suspect_sweep
                  + " milliseconds since last reception");
        }
      }
    }

    if (new_failed != null) {
      sendSuspect(new_failed, ev.getChannel());
      sendFail(new_failed, ev.getChannel());

      if (debugFull) {
        String s = "New failed members: ";
        for (int j = 0; j < new_failed.length; j++) if (new_failed[j]) s = s + j + ",";
        log.debug(s);
      }
    }

    if (round > last_recv[ls.my_rank]) {
      sendAlive(ev.getChannel());
      last_recv[ls.my_rank] = round;
      if (debugFull) log.debug("Sent Alive in round " + round);
    }

    if (debugFull)
      log.debug(
          "Ended round "
              + round
              + " at "
              + ev.getChannel().getTimeProvider().currentTimeMillis()
              + " milliseconds");

    round++;

    if (round < 0) {
      round = 1;
      for (i = 0; i < last_recv.length; i++) last_recv[i] = 0;
    }
  }