Search in sources :

Example 11 with MemberInfo

use of com.hazelcast.internal.cluster.MemberInfo in project hazelcast by hazelcast.

the class ClusterJoinManager method startJoin.

private void startJoin() {
    logger.fine("Starting join...");
    clusterServiceLock.lock();
    try {
        InternalPartitionService partitionService = node.getPartitionService();
        try {
            joinInProgress = true;
            // pause migrations until join, member-update and post-join operations are completed
            partitionService.pauseMigration();
            Collection<MemberImpl> members = clusterService.getMemberImpls();
            Collection<MemberInfo> memberInfos = createMemberInfoList(members);
            for (MemberInfo memberJoining : joiningMembers.values()) {
                memberInfos.add(memberJoining);
            }
            long time = clusterClock.getClusterTime();
            // post join operations must be lock free, that means no locks at all:
            // no partition locks, no key-based locks, no service level locks!
            Operation[] postJoinOps = nodeEngine.getPostJoinOperations();
            boolean createPostJoinOperation = (postJoinOps != null && postJoinOps.length > 0);
            PostJoinOperation postJoinOp = (createPostJoinOperation ? new PostJoinOperation(postJoinOps) : null);
            clusterService.updateMembers(memberInfos, node.getThisAddress());
            int count = members.size() - 1 + joiningMembers.size();
            List<Future> calls = new ArrayList<Future>(count);
            PartitionRuntimeState partitionRuntimeState = partitionService.createPartitionState();
            for (MemberInfo member : joiningMembers.values()) {
                long startTime = clusterClock.getClusterStartTime();
                Operation finalizeJoinOperation = new FinalizeJoinOperation(member.getUuid(), memberInfos, postJoinOp, time, clusterService.getClusterId(), startTime, clusterStateManager.getState(), clusterService.getClusterVersion(), partitionRuntimeState);
                calls.add(invokeClusterOperation(finalizeJoinOperation, member.getAddress()));
            }
            for (MemberImpl member : members) {
                if (member.localMember() || joiningMembers.containsKey(member.getAddress())) {
                    continue;
                }
                Operation memberInfoUpdateOperation = new MemberInfoUpdateOperation(member.getUuid(), memberInfos, time, partitionRuntimeState, true);
                calls.add(invokeClusterOperation(memberInfoUpdateOperation, member.getAddress()));
            }
            int timeout = Math.min(calls.size() * FINALIZE_JOIN_TIMEOUT_FACTOR, FINALIZE_JOIN_MAX_TIMEOUT);
            waitWithDeadline(calls, timeout, TimeUnit.SECONDS, whileFinalizeJoinsExceptionHandler);
        } finally {
            reset();
            partitionService.resumeMigration();
        }
    } finally {
        clusterServiceLock.unlock();
    }
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) MemberImpl(com.hazelcast.instance.MemberImpl) ArrayList(java.util.ArrayList) PostJoinOperation(com.hazelcast.internal.cluster.impl.operations.PostJoinOperation) FinalizeJoinOperation(com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOperation) MemberInfoUpdateOperation(com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation) ConfigMismatchOperation(com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOperation) Operation(com.hazelcast.spi.Operation) BeforeJoinCheckFailureOperation(com.hazelcast.internal.cluster.impl.operations.BeforeJoinCheckFailureOperation) SetMasterOperation(com.hazelcast.internal.cluster.impl.operations.SetMasterOperation) GroupMismatchOperation(com.hazelcast.internal.cluster.impl.operations.GroupMismatchOperation) PostJoinOperation(com.hazelcast.internal.cluster.impl.operations.PostJoinOperation) MasterDiscoveryOperation(com.hazelcast.internal.cluster.impl.operations.MasterDiscoveryOperation) JoinRequestOperation(com.hazelcast.internal.cluster.impl.operations.JoinRequestOperation) AuthenticationFailureOperation(com.hazelcast.internal.cluster.impl.operations.AuthenticationFailureOperation) MemberInfoUpdateOperation(com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation) FinalizeJoinOperation(com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOperation) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) Future(java.util.concurrent.Future)

Example 12 with MemberInfo

use of com.hazelcast.internal.cluster.MemberInfo in project hazelcast by hazelcast.

the class ClusterHeartbeatManager method sendMemberListToOthers.

/** Invoked on the master to send the member list (see {@link MemberInfoUpdateOperation}) to non-master nodes. */
private void sendMemberListToOthers() {
    if (!node.isMaster()) {
        return;
    }
    Collection<MemberImpl> members = clusterService.getMemberImpls();
    List<MemberInfo> memberInfos = createMemberInfoList(members);
    for (MemberImpl member : members) {
        if (member.localMember()) {
            continue;
        }
        MemberInfoUpdateOperation op = new MemberInfoUpdateOperation(member.getUuid(), memberInfos, clusterClock.getClusterTime(), null, false);
        nodeEngine.getOperationService().send(op, member.getAddress());
    }
}
Also used : MemberInfo(com.hazelcast.internal.cluster.MemberInfo) MemberImpl(com.hazelcast.instance.MemberImpl) MemberInfoUpdateOperation(com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation)

Example 13 with MemberInfo

use of com.hazelcast.internal.cluster.MemberInfo in project hazelcast by hazelcast.

the class ClusterServiceImpl method doUpdateMembers.

private void doUpdateMembers(Collection<MemberInfo> members) {
    MemberMap currentMemberMap = memberMapRef.get();
    String scopeId = thisAddress.getScopeId();
    Collection<MemberImpl> newMembers = new LinkedList<MemberImpl>();
    MemberImpl[] updatedMembers = new MemberImpl[members.size()];
    int memberIndex = 0;
    for (MemberInfo memberInfo : members) {
        Address address = memberInfo.getAddress();
        MemberImpl member = currentMemberMap.getMember(address);
        if (member == null) {
            member = createMember(memberInfo, scopeId);
            newMembers.add(member);
            long now = clusterClock.getClusterTime();
            clusterHeartbeatManager.onHeartbeat(member, now);
            clusterHeartbeatManager.acceptMasterConfirmation(member, now);
            repairPartitionTableIfReturningMember(member);
        }
        updatedMembers[memberIndex++] = member;
    }
    setMembers(updatedMembers);
    sendMembershipEvents(currentMemberMap.getMembers(), newMembers);
    MemberMap membersRemovedInNotActiveState = membersRemovedInNotActiveStateRef.get();
    membersRemovedInNotActiveStateRef.set(MemberMap.cloneExcluding(membersRemovedInNotActiveState, updatedMembers));
    clusterHeartbeatManager.heartbeat();
    logger.info(membersString());
}
Also used : MemberInfo(com.hazelcast.internal.cluster.MemberInfo) Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) LinkedList(java.util.LinkedList)

Aggregations

MemberInfo (com.hazelcast.internal.cluster.MemberInfo)13 MemberImpl (com.hazelcast.instance.MemberImpl)7 MemberInfoUpdateOperation (com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation)4 Address (com.hazelcast.nio.Address)4 AuthenticationFailureOperation (com.hazelcast.internal.cluster.impl.operations.AuthenticationFailureOperation)3 BeforeJoinCheckFailureOperation (com.hazelcast.internal.cluster.impl.operations.BeforeJoinCheckFailureOperation)3 ConfigMismatchOperation (com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOperation)3 FinalizeJoinOperation (com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOperation)3 GroupMismatchOperation (com.hazelcast.internal.cluster.impl.operations.GroupMismatchOperation)3 JoinRequestOperation (com.hazelcast.internal.cluster.impl.operations.JoinRequestOperation)3 MasterDiscoveryOperation (com.hazelcast.internal.cluster.impl.operations.MasterDiscoveryOperation)3 PostJoinOperation (com.hazelcast.internal.cluster.impl.operations.PostJoinOperation)3 SetMasterOperation (com.hazelcast.internal.cluster.impl.operations.SetMasterOperation)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 Node (com.hazelcast.instance.Node)2 TriggerMemberListPublishOperation (com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOperation)2 PartitionRuntimeState (com.hazelcast.internal.partition.PartitionRuntimeState)2 Operation (com.hazelcast.spi.Operation)2