public void updateMembers(Collection<MemberInfo> members) { lock.lock(); try { Map<Address, MemberImpl> currentMemberMap = membersMapRef.get(); if (!shouldProcessMemberUpdate(currentMemberMap, members)) { return; } String scopeId = thisAddress.getScopeId(); Collection<MemberImpl> newMembers = new LinkedList<MemberImpl>(); MemberImpl[] updatedMembers = new MemberImpl[members.size()]; int memberIndex = 0; for (MemberInfo memberInfo : members) { MemberImpl member = currentMemberMap.get(memberInfo.getAddress()); if (member == null) { member = createMember(memberInfo, scopeId); newMembers.add(member); long now = Clock.currentTimeMillis(); clusterHeartbeatManager.onHeartbeat(member, now); clusterHeartbeatManager.acceptMasterConfirmation(member, now); Map<Address, MemberImpl> membersRemovedInNotActiveState = new LinkedHashMap<Address, MemberImpl>(membersRemovedInNotActiveStateRef.get()); membersRemovedInNotActiveState.remove(member.getAddress()); membersRemovedInNotActiveStateRef.set( Collections.unmodifiableMap(membersRemovedInNotActiveState)); } updatedMembers[memberIndex++] = member; } setMembers(updatedMembers); sendMembershipEvents(currentMemberMap.values(), newMembers); clusterJoinManager.reset(); clusterHeartbeatManager.heartBeat(); node.setJoined(); logger.info(membersString()); } finally { lock.unlock(); } }
private void registerThisMember() { setMembers(thisMember); sendMembershipEvents(Collections.<MemberImpl>emptySet(), Collections.singleton(thisMember)); }