protected void performForcedCheck() { // update all alive times Member[] members = super.getMembers(); for (int i = 0; members != null && i < members.length; i++) { if (memberAlive(members[i])) { if (membership.memberAlive((MemberImpl) members[i])) super.memberAdded(members[i]); addSuspects.remove(members[i]); } else { if (membership.getMember(members[i]) != null) { membership.removeMember((MemberImpl) members[i]); removeSuspects.remove(members[i]); if (members[i] instanceof StaticMember) { addSuspects.put(members[i], Long.valueOf(System.currentTimeMillis())); } super.memberDisappeared(members[i]); } } } }
@Override public void memberAdded(Member member) { if (membership == null) setupMembership(); boolean notify = false; synchronized (membership) { if (removeSuspects.containsKey(member)) { // previously marked suspect, system below picked up the member again removeSuspects.remove(member); } else if (membership.getMember(member) == null) { // if we add it here, then add it upwards too // check to see if it is alive if (memberAlive(member)) { membership.memberAlive((MemberImpl) member); notify = true; } else { addSuspects.put(member, Long.valueOf(System.currentTimeMillis())); } } } if (notify) super.memberAdded(member); }
protected void performBasicCheck() { // update all alive times Member[] members = super.getMembers(); for (int i = 0; members != null && i < members.length; i++) { if (addSuspects.containsKey(members[i]) && membership.getMember(members[i]) == null) { // avoid temporary adding member. continue; } if (membership.memberAlive((MemberImpl) members[i])) { // we don't have this one in our membership, check to see if he/she is alive if (memberAlive(members[i])) { log.warn("Member added, even though we werent notified:" + members[i]); super.memberAdded(members[i]); } else { membership.removeMember((MemberImpl) members[i]); } } } // check suspect members if they are still alive, // if not, simply issue the memberDisappeared message MemberImpl[] keys = removeSuspects.keySet().toArray(new MemberImpl[removeSuspects.size()]); for (int i = 0; i < keys.length; i++) { MemberImpl m = keys[i]; if (membership.getMember(m) != null && (!memberAlive(m))) { membership.removeMember(m); super.memberDisappeared(m); removeSuspects.remove(m); if (log.isInfoEnabled()) log.info("Suspect member, confirmed dead.[" + m + "]"); } else { if (removeSuspectsTimeout > 0) { long timeNow = System.currentTimeMillis(); int timeIdle = (int) ((timeNow - removeSuspects.get(m).longValue()) / 1000L); if (timeIdle > removeSuspectsTimeout) { removeSuspects.remove(m); // remove suspect member } } } } // check add suspects members if they are alive now, // if they are, simply issue the memberAdded message keys = addSuspects.keySet().toArray(new MemberImpl[addSuspects.size()]); for (int i = 0; i < keys.length; i++) { MemberImpl m = keys[i]; if (membership.getMember(m) == null && (memberAlive(m))) { membership.memberAlive(m); super.memberAdded(m); addSuspects.remove(m); if (log.isInfoEnabled()) log.info("Suspect member, confirmed alive.[" + m + "]"); } } }
@Override public void memberDisappeared(Member member) { if (membership == null) setupMembership(); boolean notify = false; boolean shutdown = Arrays.equals(member.getCommand(), Member.SHUTDOWN_PAYLOAD); if (!shutdown) if (log.isInfoEnabled()) log.info("Received memberDisappeared[" + member + "] message. Will verify."); synchronized (membership) { if (!membership.contains(member)) { if (log.isInfoEnabled()) log.info("Verification complete. Member already disappeared[" + member + "]"); return; } // check to see if the member really is gone // if the payload is not a shutdown message if (shutdown || !memberAlive(member)) { // not correct, we need to maintain the map membership.removeMember((MemberImpl) member); removeSuspects.remove(member); if (member instanceof StaticMember) { addSuspects.put(member, Long.valueOf(System.currentTimeMillis())); } notify = true; } else { // add the member as suspect removeSuspects.put(member, Long.valueOf(System.currentTimeMillis())); } } if (notify) { if (log.isInfoEnabled()) log.info("Verification complete. Member disappeared[" + member + "]"); super.memberDisappeared(member); } else { if (log.isInfoEnabled()) log.info("Verification complete. Member still alive[" + member + "]"); } }
@Override public Member getMember(Member mbr) { if (membership == null) setupMembership(); return membership.getMember(mbr); }
@Override public Member[] getMembers() { if (membership == null) setupMembership(); return membership.getMembers(); }
@Override public boolean hasMembers() { if (membership == null) setupMembership(); return membership.hasMembers(); }