Search in sources :

Example 1 with PromoteLiteMemberOp

use of com.hazelcast.internal.cluster.impl.operations.PromoteLiteMemberOp 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 2 with PromoteLiteMemberOp

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

the class PromoteLiteMemberTest method notExistingMember_promotion_shouldFail.

@Test
public void notExistingMember_promotion_shouldFail() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance hz1 = factory.newHazelcastInstance(new Config());
    HazelcastInstance hz2 = factory.newHazelcastInstance(new Config());
    PromoteLiteMemberOp op = new PromoteLiteMemberOp();
    op.setCallerUuid(UuidUtil.newUnsecureUUID());
    InternalCompletableFuture<MembersView> future = getOperationService(hz2).invokeOnTarget(ClusterServiceImpl.SERVICE_NAME, op, getAddress(hz1));
    exception.expect(CompletionException.class);
    exception.expect(new RootCauseMatcher(IllegalStateException.class));
    future.join();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) PromoteLiteMemberOp(com.hazelcast.internal.cluster.impl.operations.PromoteLiteMemberOp) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with PromoteLiteMemberOp

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

the class PromoteLiteMemberTest method normalMember_promotion_shouldFail_onNonMaster.

@Test
public void normalMember_promotion_shouldFail_onNonMaster() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    factory.newHazelcastInstance(new Config());
    HazelcastInstance hz2 = factory.newHazelcastInstance(new Config());
    HazelcastInstance hz3 = factory.newHazelcastInstance(new Config());
    PromoteLiteMemberOp op = new PromoteLiteMemberOp();
    op.setCallerUuid(getMember(hz2).getUuid());
    InternalCompletableFuture<MembersView> future = getOperationService(hz2).invokeOnTarget(ClusterServiceImpl.SERVICE_NAME, op, getAddress(hz3));
    exception.expect(CompletionException.class);
    exception.expect(new RootCauseMatcher(IllegalStateException.class));
    future.join();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) PromoteLiteMemberOp(com.hazelcast.internal.cluster.impl.operations.PromoteLiteMemberOp) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with PromoteLiteMemberOp

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

the class ClusterServiceImpl method promoteLocalLiteMember.

@Override
public void promoteLocalLiteMember() {
    MemberImpl member = getLocalMember();
    if (!member.isLiteMember()) {
        throw new IllegalStateException(member + " is not a lite member!");
    }
    MemberImpl master = getMasterMember();
    PromoteLiteMemberOp op = new PromoteLiteMemberOp();
    op.setCallerUuid(member.getUuid());
    InvocationFuture<MembersView> future = nodeEngine.getOperationService().invokeOnTarget(SERVICE_NAME, op, master.getAddress());
    MembersView view = future.joinInternal();
    lock.lock();
    try {
        if (!member.getAddress().equals(master.getAddress())) {
            updateMembers(view, master.getAddress(), master.getUuid(), getThisUuid());
        }
        MemberImpl localMemberInMemberList = membershipManager.getMember(member.getAddress());
        boolean result = localMemberInMemberList.isLiteMember();
        node.getNodeExtension().getAuditlogService().eventBuilder(AuditlogTypeIds.CLUSTER_PROMOTE_MEMBER).message("Promotion of the lite member").addParameter("success", result).addParameter("address", node.getThisAddress()).log();
        if (result) {
            throw new IllegalStateException("Cannot promote to data member! Previous master was: " + master.getAddress() + ", Current master is: " + getMasterAddress());
        }
    } finally {
        lock.unlock();
    }
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl) PromoteLiteMemberOp(com.hazelcast.internal.cluster.impl.operations.PromoteLiteMemberOp)

Example 5 with PromoteLiteMemberOp

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

the class PromoteLiteMemberTest method assertPromotionInvocationStarted.

private void assertPromotionInvocationStarted(HazelcastInstance instance) {
    OperationServiceImpl operationService = getNode(instance).getNodeEngine().getOperationService();
    InvocationRegistry invocationRegistry = operationService.getInvocationRegistry();
    assertTrueEventually(() -> {
        for (Map.Entry<Long, Invocation> entry : invocationRegistry.entrySet()) {
            if (entry.getValue().op instanceof PromoteLiteMemberOp) {
                return;
            }
        }
        fail("Cannot find PromoteLiteMemberOp invocation!");
    });
}
Also used : Invocation(com.hazelcast.spi.impl.operationservice.impl.Invocation) PromoteLiteMemberOp(com.hazelcast.internal.cluster.impl.operations.PromoteLiteMemberOp) Map(java.util.Map) IMap(com.hazelcast.map.IMap) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) InvocationRegistry(com.hazelcast.spi.impl.operationservice.impl.InvocationRegistry)

Aggregations

PromoteLiteMemberOp (com.hazelcast.internal.cluster.impl.operations.PromoteLiteMemberOp)6 Config (com.hazelcast.config.Config)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)2 RootCauseMatcher (com.hazelcast.internal.util.RootCauseMatcher)2 Address (com.hazelcast.cluster.Address)1 VectorClock (com.hazelcast.cluster.impl.VectorClock)1 EndpointQualifier (com.hazelcast.instance.EndpointQualifier)1 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)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 FetchMembersViewOp (com.hazelcast.internal.cluster.impl.operations.FetchMembersViewOp)1