示例#1
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);
  }
示例#2
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;
    }
  }