示例#1
0
 private MemberImpl createMember(MemberInfo memberInfo, String ipV6ScopeId) {
   Address address = memberInfo.getAddress();
   address.setScopeId(ipV6ScopeId);
   return new MemberImpl(
       address,
       thisAddress.equals(address),
       memberInfo.getUuid(),
       (HazelcastInstanceImpl) nodeEngine.getHazelcastInstance(),
       memberInfo.getAttributes(),
       memberInfo.isLiteMember());
 }
示例#2
0
  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();
    }
  }