private void undelivered(InetSocketAddress addr, Channel channel) { int rank, i; if ((rank = vs.getRankByAddress(addr)) >= 0) { if (!ls.failed[rank]) { ls.fail(rank); boolean[] new_failed = new boolean[vs.view.length]; for (i = 0; i < new_failed.length; i++) new_failed[i] = (i == rank); sendSuspect(ls.failed, channel); sendFail(new_failed, channel); log.debug("Suspected member " + rank + " due to Undelivered"); } } else log.debug("Undelivered didn't contain a current view member"); }
private void handleSuspect(Suspect ev) { if (ev.getDir() == Direction.UP) { if (ls.failed[ev.orig]) { log.debug("Invalid (failed) message source"); return; } ev.failed = ArrayOptimized.popArrayBoolean(ev.getMessage()); } if (ev.failed[ls.my_rank]) { log.debug("i am not failed !!"); return; } int i; boolean[] new_failed = null; for (i = 0; i < ev.failed.length; i++) { if (ev.failed[i] && !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; } } if (new_failed != null) { if (ev.getDir() == Direction.DOWN) { ArrayOptimized.pushArrayBoolean(ls.failed, ev.getMessage()); // ev.getObjectsMessage().push(ls.failed); try { ev.go(); } catch (AppiaEventException ex) { ex.printStackTrace(); } } sendFail(new_failed, ev.getChannel()); } }
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; } }