private void removeMember(MemberImpl deadMember) { logger.info("Removing " + deadMember); lock.lock(); try { Map<Address, MemberImpl> members = membersMapRef.get(); final Address deadAddress = deadMember.getAddress(); if (members.containsKey(deadAddress)) { // !!! ORDERED !!! Map<Address, MemberImpl> newMembers = new LinkedHashMap<Address, MemberImpl>(members); newMembers.remove(deadAddress); clusterHeartbeatManager.removeMember(deadMember); setMembersRef(newMembers); if (node.isMaster()) { if (logger.isFinestEnabled()) { logger.finest(deadMember + " is dead, sending remove to all other members..."); } invokeMemberRemoveOperation(deadAddress); } final ClusterState clusterState = clusterStateManager.getState(); if (clusterState == ClusterState.FROZEN || clusterState == ClusterState.PASSIVE) { if (logger.isFinestEnabled()) { logger.finest( deadMember + " is dead, added to members left while cluster is " + clusterState + " state"); } Map<Address, MemberImpl> membersRemovedInNotActiveState = new LinkedHashMap<Address, MemberImpl>(membersRemovedInNotActiveStateRef.get()); membersRemovedInNotActiveState.put(deadAddress, deadMember); membersRemovedInNotActiveStateRef.set( Collections.unmodifiableMap(membersRemovedInNotActiveState)); final InternalPartitionServiceImpl partitionService = node.partitionService; partitionService.cancelReplicaSyncRequestsTo(deadAddress); } else { onMemberRemove(deadMember, newMembers); } // async events sendMembershipEventNotifications( deadMember, unmodifiableSet(new LinkedHashSet<Member>(newMembers.values())), false); } } finally { lock.unlock(); } }
void removeMembersDeadWhileClusterIsNotActive() { lock.lock(); try { Map<Address, MemberImpl> memberMap = membersMapRef.get(); Map<Address, MemberImpl> membersRemovedInNotActiveState = membersRemovedInNotActiveStateRef.get(); Collection<MemberImpl> members = membersRemovedInNotActiveState.values(); membersRemovedInNotActiveStateRef.set(Collections.<Address, MemberImpl>emptyMap()); for (MemberImpl member : members) { onMemberRemove(member, memberMap); } } finally { lock.unlock(); } }