public void performBasicCheck() throws RemoteException {
		try {
		    //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( (org.apache.catalina.tribes.membership.MemberImplRemoteInterface) 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( (org.apache.catalina.tribes.membership.MemberImplRemoteInterface) members[i]);
		            }
		        }
		    }

		    //check suspect members if they are still alive,
		    //if not, simply issue the memberDisappeared message
		    org.apache.catalina.tribes.membership.MemberImplRemoteInterface[] keys = removeSuspects.keySet().toArray(new org.apache.catalina.tribes.membership.MemberImplRemoteInterface[removeSuspects.size()]);
		    for (int i = 0; i < keys.length; i++) {
		        org.apache.catalina.tribes.membership.MemberImplRemoteInterface 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 org.apache.catalina.tribes.membership.MemberImplRemoteInterface[addSuspects.size()]);
		    for (int i = 0; i < keys.length; i++) {
		        org.apache.catalina.tribes.membership.MemberImplRemoteInterface 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+"]");
		        }
		    }
		} catch (Exception excp) {
			excp.printStackTrace();
		}
	}
Exemplo n.º 2
0
 @Override
 public void memberDisappeared(Member member) {
   // reset counters - lock free
   incounter.remove(member);
   outcounter.remove(member);
   // clear the remaining queue
   processLeftOvers(member, true);
   // notify upwards
   super.memberDisappeared(member);
 }
Exemplo n.º 3
0
  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]);
        } // end if
      } // end if
    } // for

    // 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)) / 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 + "]");
      } // end if
    }
  }
    @Override
    public void memberDisappeared(Member member) throws RemoteException {
		try {
		    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( (org.apache.catalina.tribes.membership.MemberImplRemoteInterface) member);
		            removeSuspects.remove(member);
		            if (member instanceof org.apache.catalina.tribes.membership.StaticMemberRemoteInterface) {
		                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+"]");

		    }
		} catch (Exception excp) {
			excp.printStackTrace();
		}
	}
 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]);
       }
     }
   }
 }
    public void performForcedCheck() throws RemoteException {
		try {
		    //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((org.apache.catalina.tribes.membership.MemberImplRemoteInterface)members[i])) super.memberAdded(members[i]);
		            addSuspects.remove(members[i]);
		        } else {
		            if (membership.getMember(members[i])!=null) {
		                membership.removeMember((org.apache.catalina.tribes.membership.MemberImplRemoteInterface)members[i]);
		                removeSuspects.remove(members[i]);
		                if (members[i] instanceof org.apache.catalina.tribes.membership.StaticMemberRemoteInterface) {
		                    addSuspects.put(members[i], Long.valueOf(System.currentTimeMillis()));
		                }
		                super.memberDisappeared(members[i]);
		            }
		        }
		    }

		} catch (Exception excp) {
			excp.printStackTrace();
		}
	}