Search in sources :

Example 1 with MembersUpdateOp

use of com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp in project hazelcast by hazelcast.

the class MembershipUpdateTest method memberReceives_memberUpdateFromInvalidMaster.

@Test
public void memberReceives_memberUpdateFromInvalidMaster() throws Exception {
    Config config = new Config();
    config.setProperty(MEMBER_LIST_PUBLISH_INTERVAL_SECONDS.getName(), String.valueOf(Integer.MAX_VALUE));
    HazelcastInstance hz1 = factory.newHazelcastInstance(config);
    HazelcastInstance hz2 = factory.newHazelcastInstance(config);
    HazelcastInstance hz3 = factory.newHazelcastInstance(config);
    assertClusterSizeEventually(3, hz2);
    Node node = getNode(hz1);
    ClusterServiceImpl clusterService = node.getClusterService();
    MembershipManager membershipManager = clusterService.getMembershipManager();
    MemberInfo newMemberInfo = new MemberInfo(new Address("127.0.0.1", 6000), newUnsecureUUID(), Collections.emptyMap(), false, node.getVersion());
    MembersView membersView = MembersView.cloneAdding(membershipManager.getMembersView(), singleton(newMemberInfo));
    Operation memberUpdate = new MembersUpdateOp(membershipManager.getMember(getAddress(hz3)).getUuid(), membersView, clusterService.getClusterTime(), null, true);
    NodeEngineImpl nonMasterNodeEngine = getNodeEngineImpl(hz2);
    memberUpdate.setCallerUuid(nonMasterNodeEngine.getNode().getThisUuid());
    Future<Object> future = nonMasterNodeEngine.getOperationService().invokeOnTarget(null, memberUpdate, getAddress(hz3));
    future.get();
    // member update should not be applied
    assertClusterSize(3, hz1, hz2, hz3);
    assertMemberViewsAreSame(getMemberMap(hz1), getMemberMap(hz2));
    assertMemberViewsAreSame(getMemberMap(hz1), getMemberMap(hz3));
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) Address(com.hazelcast.cluster.Address) Accessors.getAddress(com.hazelcast.test.Accessors.getAddress) MembersUpdateOp(com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp) TestHazelcastInstanceFactory.initOrCreateConfig(com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) Node(com.hazelcast.instance.impl.Node) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Operation(com.hazelcast.spi.impl.operationservice.Operation) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with MembersUpdateOp

use of com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp in project hazelcast by hazelcast.

the class MembershipManager method sendMemberListToOthers.

/**
 * Invoked on the master to send the member list (see {@link MembersUpdateOp}) to non-master nodes.
 */
private void sendMemberListToOthers() {
    if (!clusterService.isMaster() || !clusterService.isJoined() || clusterService.getClusterJoinManager().isMastershipClaimInProgress()) {
        if (logger.isFineEnabled()) {
            logger.fine("Cannot publish member list to cluster. Is-master: " + clusterService.isMaster() + ", joined: " + clusterService.isJoined() + " , mastership claim in progress: " + clusterService.getClusterJoinManager().isMastershipClaimInProgress());
        }
        return;
    }
    MemberMap memberMap = getMemberMap();
    MembersView membersView = memberMap.toMembersView();
    if (logger.isFineEnabled()) {
        logger.fine("Sending member list to the non-master nodes: " + memberListString());
    }
    for (MemberImpl member : memberMap.getMembers()) {
        if (member.localMember()) {
            continue;
        }
        MembersUpdateOp op = new MembersUpdateOp(member.getUuid(), membersView, clusterService.getClusterTime(), null, false);
        op.setCallerUuid(clusterService.getThisUuid());
        nodeEngine.getOperationService().send(op, member.getAddress());
    }
}
Also used : MembersUpdateOp(com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp) MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Example 3 with MembersUpdateOp

use of com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp in project hazelcast by hazelcast.

the class ClusterDataSerializerHook method createFactory.

@Override
public DataSerializableFactory createFactory() {
    ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
    constructors[AUTH_FAILURE] = arg -> new AuthenticationFailureOp();
    constructors[ADDRESS] = arg -> new Address();
    constructors[MEMBER] = arg -> new MemberImpl();
    constructors[HEARTBEAT] = arg -> new HeartbeatOp();
    constructors[CONFIG_CHECK] = arg -> new ConfigCheck();
    constructors[MEMBER_HANDSHAKE] = arg -> new MemberHandshake();
    constructors[MEMBER_INFO_UPDATE] = arg -> new MembersUpdateOp();
    constructors[FINALIZE_JOIN] = arg -> new FinalizeJoinOp();
    constructors[BEFORE_JOIN_CHECK_FAILURE] = arg -> new BeforeJoinCheckFailureOp();
    constructors[CHANGE_CLUSTER_STATE] = arg -> new CommitClusterStateOp();
    constructors[CONFIG_MISMATCH] = arg -> new ConfigMismatchOp();
    constructors[CLUSTER_MISMATCH] = arg -> new ClusterMismatchOp();
    constructors[SPLIT_BRAIN_MERGE_VALIDATION] = arg -> new SplitBrainMergeValidationOp();
    constructors[JOIN_REQUEST_OP] = arg -> new JoinRequestOp();
    constructors[LOCK_CLUSTER_STATE] = arg -> new LockClusterStateOp();
    constructors[MASTER_CLAIM] = arg -> new JoinMastershipClaimOp();
    constructors[WHOIS_MASTER] = arg -> new WhoisMasterOp();
    constructors[MERGE_CLUSTERS] = arg -> new MergeClustersOp();
    constructors[POST_JOIN] = arg -> new OnJoinOp();
    constructors[ROLLBACK_CLUSTER_STATE] = arg -> new RollbackClusterStateOp();
    constructors[MASTER_RESPONSE] = arg -> new MasterResponseOp();
    constructors[SHUTDOWN_NODE] = arg -> new ShutdownNodeOp();
    constructors[TRIGGER_MEMBER_LIST_PUBLISH] = arg -> new TriggerMemberListPublishOp();
    constructors[CLUSTER_STATE_TRANSACTION_LOG_RECORD] = arg -> new ClusterStateTransactionLogRecord();
    constructors[MEMBER_INFO] = arg -> new MemberInfo();
    constructors[JOIN_MESSAGE] = arg -> new JoinMessage();
    constructors[JOIN_REQUEST] = arg -> new JoinRequest();
    constructors[MIGRATION_INFO] = arg -> new MigrationInfo();
    constructors[MEMBER_VERSION] = arg -> new MemberVersion();
    constructors[CLUSTER_STATE_CHANGE] = arg -> new ClusterStateChange();
    constructors[SPLIT_BRAIN_JOIN_MESSAGE] = arg -> new SplitBrainJoinMessage();
    constructors[VERSION] = arg -> new Version();
    constructors[FETCH_MEMBER_LIST_STATE] = arg -> new FetchMembersViewOp();
    constructors[EXPLICIT_SUSPICION] = arg -> new ExplicitSuspicionOp();
    constructors[MEMBERS_VIEW] = arg -> new MembersView();
    constructors[TRIGGER_EXPLICIT_SUSPICION] = arg -> new TriggerExplicitSuspicionOp();
    constructors[MEMBERS_VIEW_METADATA] = arg -> new MembersViewMetadata();
    constructors[HEARTBEAT_COMPLAINT] = arg -> new HeartbeatComplaintOp();
    constructors[PROMOTE_LITE_MEMBER] = arg -> new PromoteLiteMemberOp();
    constructors[VECTOR_CLOCK] = arg -> new VectorClock();
    constructors[ENDPOINT_QUALIFIER] = arg -> new EndpointQualifier();
    return new ArrayDataSerializableFactory(constructors);
}
Also used : MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) MergeClustersOp(com.hazelcast.internal.cluster.impl.operations.MergeClustersOp) Address(com.hazelcast.cluster.Address) MembersUpdateOp(com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp) SplitBrainMergeValidationOp(com.hazelcast.internal.cluster.impl.operations.SplitBrainMergeValidationOp) RollbackClusterStateOp(com.hazelcast.internal.cluster.impl.operations.RollbackClusterStateOp) EndpointQualifier(com.hazelcast.instance.EndpointQualifier) TriggerMemberListPublishOp(com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp) MemberVersion(com.hazelcast.version.MemberVersion) HeartbeatComplaintOp(com.hazelcast.internal.cluster.impl.operations.HeartbeatComplaintOp) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) Version(com.hazelcast.version.Version) MemberVersion(com.hazelcast.version.MemberVersion) ShutdownNodeOp(com.hazelcast.internal.cluster.impl.operations.ShutdownNodeOp) HeartbeatOp(com.hazelcast.internal.cluster.impl.operations.HeartbeatOp) TriggerExplicitSuspicionOp(com.hazelcast.internal.cluster.impl.operations.TriggerExplicitSuspicionOp) BeforeJoinCheckFailureOp(com.hazelcast.internal.cluster.impl.operations.BeforeJoinCheckFailureOp) MasterResponseOp(com.hazelcast.internal.cluster.impl.operations.MasterResponseOp) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) LockClusterStateOp(com.hazelcast.internal.cluster.impl.operations.LockClusterStateOp) ExplicitSuspicionOp(com.hazelcast.internal.cluster.impl.operations.ExplicitSuspicionOp) TriggerExplicitSuspicionOp(com.hazelcast.internal.cluster.impl.operations.TriggerExplicitSuspicionOp) VectorClock(com.hazelcast.cluster.impl.VectorClock) AuthenticationFailureOp(com.hazelcast.internal.cluster.impl.operations.AuthenticationFailureOp) ClusterMismatchOp(com.hazelcast.internal.cluster.impl.operations.ClusterMismatchOp) PromoteLiteMemberOp(com.hazelcast.internal.cluster.impl.operations.PromoteLiteMemberOp) FinalizeJoinOp(com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOp) ConstructorFunction(com.hazelcast.internal.util.ConstructorFunction) ConfigMismatchOp(com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOp) CommitClusterStateOp(com.hazelcast.internal.cluster.impl.operations.CommitClusterStateOp) WhoisMasterOp(com.hazelcast.internal.cluster.impl.operations.WhoisMasterOp) OnJoinOp(com.hazelcast.internal.cluster.impl.operations.OnJoinOp) JoinRequestOp(com.hazelcast.internal.cluster.impl.operations.JoinRequestOp) FetchMembersViewOp(com.hazelcast.internal.cluster.impl.operations.FetchMembersViewOp) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory) JoinMastershipClaimOp(com.hazelcast.internal.cluster.impl.operations.JoinMastershipClaimOp)

Example 4 with MembersUpdateOp

use of com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp in project hazelcast by hazelcast.

the class ClusterJoinManager method startJoin.

/**
 * Starts join process on master member.
 */
private void startJoin() {
    logger.fine("Starting join...");
    clusterServiceLock.lock();
    try {
        InternalPartitionService partitionService = node.getPartitionService();
        boolean shouldTriggerRepartition = true;
        try {
            joinInProgress = true;
            // pause migrations until join, member-update and post-join operations are completed
            partitionService.pauseMigration();
            MemberMap memberMap = clusterService.getMembershipManager().getMemberMap();
            MembersView newMembersView = MembersView.cloneAdding(memberMap.toMembersView(), joiningMembers.values());
            long time = clusterClock.getClusterTime();
            // member list must be updated on master before preparation of pre-/post-join ops so other operations which have
            // to be executed on stable cluster can detect the member list version change and retry in case of topology change
            UUID thisUuid = clusterService.getThisUuid();
            if (!clusterService.updateMembers(newMembersView, node.getThisAddress(), thisUuid, thisUuid)) {
                return;
            }
            // post join operations must be lock free, that means no locks at all:
            // no partition locks, no key-based locks, no service level locks!
            OnJoinOp preJoinOp = preparePreJoinOps();
            OnJoinOp postJoinOp = preparePostJoinOp();
            // this is the current partition assignment state, not taking into account the
            // currently joining members
            PartitionRuntimeState partitionRuntimeState = partitionService.createPartitionState();
            for (MemberInfo member : joiningMembers.values()) {
                if (isMemberRestartingWithPersistence(member.getAttributes()) && isMemberRejoining(memberMap, member.getAddress(), member.getUuid())) {
                    logger.info(member + " is rejoining the cluster");
                    // do not trigger repartition immediately, wait for joining member to load hot-restart data
                    shouldTriggerRepartition = false;
                }
                long startTime = clusterClock.getClusterStartTime();
                Operation op = new FinalizeJoinOp(member.getUuid(), newMembersView, preJoinOp, postJoinOp, time, clusterService.getClusterId(), startTime, clusterStateManager.getState(), clusterService.getClusterVersion(), partitionRuntimeState, !shouldTriggerRepartition);
                op.setCallerUuid(thisUuid);
                invokeClusterOp(op, member.getAddress());
            }
            for (MemberImpl member : memberMap.getMembers()) {
                if (member.localMember() || joiningMembers.containsKey(member.getAddress())) {
                    continue;
                }
                Operation op = new MembersUpdateOp(member.getUuid(), newMembersView, time, partitionRuntimeState, true);
                op.setCallerUuid(thisUuid);
                invokeClusterOp(op, member.getAddress());
            }
        } finally {
            reset();
            if (shouldTriggerRepartition) {
                partitionService.resumeMigration();
            }
        }
    } finally {
        clusterServiceLock.unlock();
    }
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) MembersUpdateOp(com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Operation(com.hazelcast.spi.impl.operationservice.Operation) FinalizeJoinOp(com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOp) OnJoinOp(com.hazelcast.internal.cluster.impl.operations.OnJoinOp) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) UUID(java.util.UUID)

Example 5 with MembersUpdateOp

use of com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp in project hazelcast by hazelcast.

the class MembershipManager method sendMemberListToMember.

/**
 * Sends the current member list to the {@code target}. Called on the master node.
 *
 * @param target the destination for the member update operation
 */
public void sendMemberListToMember(Address target) {
    clusterServiceLock.lock();
    try {
        if (!clusterService.isMaster() || !clusterService.isJoined()) {
            if (logger.isFineEnabled()) {
                logger.fine("Cannot publish member list to " + target + ". Is-master: " + clusterService.isMaster() + ", joined: " + clusterService.isJoined());
            }
            return;
        }
        if (clusterService.getThisAddress().equals(target)) {
            return;
        }
        MemberMap memberMap = memberMapRef.get();
        MemberImpl member = memberMap.getMember(target);
        if (member == null) {
            if (logger.isFineEnabled()) {
                logger.fine("Not member: " + target + ", cannot send member list.");
            }
            return;
        }
        if (logger.isFineEnabled()) {
            logger.fine("Sending member list to member: " + target + " " + memberListString());
        }
        MembersUpdateOp op = new MembersUpdateOp(member.getUuid(), memberMap.toMembersView(), clusterService.getClusterTime(), null, false);
        op.setCallerUuid(clusterService.getThisUuid());
        nodeEngine.getOperationService().send(op, target);
    } finally {
        clusterServiceLock.unlock();
    }
}
Also used : MembersUpdateOp(com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp) MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Aggregations

MembersUpdateOp (com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp)6 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)4 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)3 Operation (com.hazelcast.spi.impl.operationservice.Operation)3 Address (com.hazelcast.cluster.Address)2 Config (com.hazelcast.config.Config)2 ServiceConfig (com.hazelcast.config.ServiceConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)2 Node (com.hazelcast.instance.impl.Node)2 FinalizeJoinOp (com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOp)2 OnJoinOp (com.hazelcast.internal.cluster.impl.operations.OnJoinOp)2 VectorClock (com.hazelcast.cluster.impl.VectorClock)1 EndpointQualifier (com.hazelcast.instance.EndpointQualifier)1 AuthenticationFailureOp (com.hazelcast.internal.cluster.impl.operations.AuthenticationFailureOp)1 BeforeJoinCheckFailureOp (com.hazelcast.internal.cluster.impl.operations.BeforeJoinCheckFailureOp)1 ClusterMismatchOp (com.hazelcast.internal.cluster.impl.operations.ClusterMismatchOp)1 CommitClusterStateOp (com.hazelcast.internal.cluster.impl.operations.CommitClusterStateOp)1 ConfigMismatchOp (com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOp)1 ExplicitSuspicionOp (com.hazelcast.internal.cluster.impl.operations.ExplicitSuspicionOp)1