@Override
    public void memberAdded(Member member) throws RemoteException {
		try {
		    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( (org.apache.catalina.tribes.membership.MemberImplRemoteInterface) member);
		                notify = true;
		            } else {
		                addSuspects.put(member, Long.valueOf(System.currentTimeMillis()));
		            }
		        }
		    }
		    if ( notify ) super.memberAdded(member);
		} catch (Exception excp) {
			excp.printStackTrace();
		}
	}
 @Override
 public Object clone() {
   try {
     synchronized (membersLock) {
       org.apache.catalina.tribes.membership.MembershipRemoteInterface clone =
           gerenciadornuvem0.getMembership(local, memberComparator);
       @SuppressWarnings("unchecked") // map is correct type already
       final HashMap<
               org.apache.catalina.tribes.membership.MemberImplRemoteInterface,
               org.apache.catalina.tribes.membership.MembershipMbrEntryRemoteInterface>
           tmpclone =
               (HashMap<
                       org.apache.catalina.tribes.membership.MemberImplRemoteInterface,
                       org.apache.catalina.tribes.membership.MembershipMbrEntryRemoteInterface>)
                   getMapData().clone();
       clone.setMapData(tmpclone);
       clone.setMembersData(
           new org.apache.catalina.tribes.membership.MemberImplRemoteInterface
               [getMembersData().length]);
       System.arraycopy(getMembersData(), 0, clone.getMembersData(), 0, getMembersData().length);
       return clone;
     }
   } catch (Exception excp) {
     excp.printStackTrace();
   }
   return null;
 }
    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();
		}
	}
    @Override
    public Member getMember(Member mbr) throws RemoteException {
		try {
		    if ( membership == null ) setupMembership();
		    return membership.getMember(mbr);
		} catch (Exception excp) {
			excp.printStackTrace();
		}
		return null;
	}
    @Override
    public boolean hasMembers() throws RemoteException {
		try {
		    if ( membership == null ) setupMembership();
		    return membership.hasMembers();
		} catch (Exception excp) {
			excp.printStackTrace();
		}
		return true;
	}
    @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();
		}
	}
    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();
		}
	}