Search in sources :

Example 11 with CPMember

use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.

the class CPMemberAddRemoveTest method testCPMemberIdentityChanges_whenLocalMemberIsRecovered_duringRestart.

@Test
public void testCPMemberIdentityChanges_whenLocalMemberIsRecovered_duringRestart() throws ExecutionException, InterruptedException {
    HazelcastInstance[] instances = newInstances(3);
    waitAllForLeaderElection(instances, getMetadataGroupId(instances[0]));
    Member localMember = instances[0].getCluster().getLocalMember();
    CPMember localCpMember = instances[0].getCPSubsystem().getLocalCPMember();
    instances[0].getLifecycleService().terminate();
    assertClusterSizeEventually(2, instances[1]);
    instances[1].getCPSubsystem().getCPSubsystemManagementService().removeCPMember(localCpMember.getUuid()).toCompletableFuture().get();
    instances[0] = newHazelcastInstance(initOrCreateConfig(createConfig(3, 3)), randomString(), new StaticMemberNodeContext(factory, localMember));
    assertEquals(localMember, instances[0].getCluster().getLocalMember());
    assertTrueAllTheTime(() -> assertNull(instances[0].getCPSubsystem().getLocalCPMember()), 5);
    instances[0].getCPSubsystem().getCPSubsystemManagementService().promoteToCPMember().toCompletableFuture().get();
    assertNotNull(instances[0].getCPSubsystem().getLocalCPMember());
    assertNotEquals(localCpMember, instances[0].getCPSubsystem().getLocalCPMember());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) StaticMemberNodeContext(com.hazelcast.instance.StaticMemberNodeContext) Member(com.hazelcast.cluster.Member) CPMember(com.hazelcast.cp.CPMember) CPMember(com.hazelcast.cp.CPMember) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 12 with CPMember

use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.

the class CPMemberAddRemoveTest method testRaftMemberNotPresentInAnyRaftGroupIsRemovedDirectlyAfterCrash.

@Test
public void testRaftMemberNotPresentInAnyRaftGroupIsRemovedDirectlyAfterCrash() throws ExecutionException, InterruptedException {
    HazelcastInstance[] instances = newInstances(3, 3, 1);
    HazelcastInstance master = instances[0];
    HazelcastInstance promoted = instances[instances.length - 1];
    promoted.getCPSubsystem().getCPSubsystemManagementService().promoteToCPMember().toCompletableFuture().get();
    CPMember promotedMember = promoted.getCPSubsystem().getLocalCPMember();
    promoted.getLifecycleService().terminate();
    master.getCPSubsystem().getCPSubsystemManagementService().removeCPMember(promotedMember.getUuid()).toCompletableFuture().get();
    MembershipChangeSchedule schedule = getRaftInvocationManager(master).<MembershipChangeSchedule>query(getMetadataGroupId(master), new GetMembershipChangeScheduleOp(), LINEARIZABLE).get();
    assertNull(schedule);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) GetMembershipChangeScheduleOp(com.hazelcast.cp.internal.raftop.metadata.GetMembershipChangeScheduleOp) CPMember(com.hazelcast.cp.CPMember) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 13 with CPMember

use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.

the class CPMemberAddRemoveTest method testRemoveMemberFromForceDestroyedRaftGroup.

@Test
public void testRemoveMemberFromForceDestroyedRaftGroup() throws ExecutionException, InterruptedException {
    HazelcastInstance[] instances = newInstances(3, 3, 0);
    waitAllForLeaderElection(instances, getMetadataGroupId(instances[0]));
    CPGroupId groupId = getRaftInvocationManager(instances[0]).createRaftGroup("test", 2).get();
    CPGroup group = instances[0].getCPSubsystem().getCPSubsystemManagementService().getCPGroup(groupId.getName()).toCompletableFuture().get();
    CPMember crashedMember = group.members().iterator().next();
    HazelcastInstance runningInstance = (getAddress(instances[0])).equals(crashedMember.getAddress()) ? instances[1] : instances[0];
    factory.getInstance(crashedMember.getAddress()).getLifecycleService().terminate();
    CPSubsystemManagementService cpSubsystemManagementService = runningInstance.getCPSubsystem().getCPSubsystemManagementService();
    cpSubsystemManagementService.forceDestroyCPGroup(groupId.getName()).toCompletableFuture().get();
    cpSubsystemManagementService.removeCPMember(crashedMember.getUuid()).toCompletableFuture().get();
    Collection<CPMember> activeMembers = cpSubsystemManagementService.getCPMembers().toCompletableFuture().get();
    assertFalse(activeMembers.contains(crashedMember));
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) CPGroup(com.hazelcast.cp.CPGroup) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) CPSubsystemManagementService(com.hazelcast.cp.CPSubsystemManagementService) CPMember(com.hazelcast.cp.CPMember) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 14 with CPMember

use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.

the class CPMemberAddRemoveTest method when_crashedMemberIsRemovedAndThenNewCPMemberIsPromoted_then_membershipChangeSucceeds.

@Test
public void when_crashedMemberIsRemovedAndThenNewCPMemberIsPromoted_then_membershipChangeSucceeds() throws ExecutionException, InterruptedException {
    int cpMemberCount = 3;
    HazelcastInstance[] instances = newInstances(cpMemberCount);
    waitUntilCPDiscoveryCompleted(instances);
    CPMember cpMember3 = instances[2].getCPSubsystem().getLocalCPMember();
    instances[2].getLifecycleService().terminate();
    instances[0].getCPSubsystem().getCPSubsystemManagementService().removeCPMember(cpMember3.getUuid());
    assertTrueEventually(() -> {
        CPGroup metadataGroup = instances[0].getCPSubsystem().getCPSubsystemManagementService().getCPGroup(CPGroup.METADATA_CP_GROUP_NAME).toCompletableFuture().get();
        assertEquals(cpMemberCount - 1, metadataGroup.members().size());
        assertFalse(metadataGroup.members().contains(cpMember3));
    });
    HazelcastInstance instance4 = factory.newHazelcastInstance(createConfig(cpMemberCount, cpMemberCount));
    instance4.getCPSubsystem().getCPSubsystemManagementService().promoteToCPMember().toCompletableFuture().get();
    assertTrueEventually(() -> {
        CPGroup metadataGroup = instances[0].getCPSubsystem().getCPSubsystemManagementService().getCPGroup(CPGroup.METADATA_CP_GROUP_NAME).toCompletableFuture().get();
        assertTrue(metadataGroup.members().contains(instance4.getCPSubsystem().getLocalCPMember()));
        assertEquals(cpMemberCount, metadataGroup.members().size());
    });
}
Also used : CPGroup(com.hazelcast.cp.CPGroup) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) CPMember(com.hazelcast.cp.CPMember) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 15 with CPMember

use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.

the class CPMemberAddRemoveTest method when_crashedMemberIsReplacedByAnotherAvailableCPMember_then_membershipChangeSucceeds.

@Test
public void when_crashedMemberIsReplacedByAnotherAvailableCPMember_then_membershipChangeSucceeds() throws InterruptedException, ExecutionException {
    int cpMemberCount = 3;
    HazelcastInstance[] instances = newInstances(cpMemberCount);
    waitUntilCPDiscoveryCompleted(instances);
    HazelcastInstance instance4 = factory.newHazelcastInstance(createConfig(cpMemberCount, cpMemberCount));
    instance4.getCPSubsystem().getCPSubsystemManagementService().promoteToCPMember().toCompletableFuture().get();
    CPMember cpMember3 = instances[2].getCPSubsystem().getLocalCPMember();
    instances[2].getLifecycleService().terminate();
    instances[0].getCPSubsystem().getCPSubsystemManagementService().removeCPMember(cpMember3.getUuid());
    assertTrueEventually(() -> {
        CPGroup metadataGroup = instances[0].getCPSubsystem().getCPSubsystemManagementService().getCPGroup(CPGroup.METADATA_CP_GROUP_NAME).toCompletableFuture().get();
        assertTrue(metadataGroup.members().contains(instance4.getCPSubsystem().getLocalCPMember()));
        assertEquals(cpMemberCount, metadataGroup.members().size());
    });
}
Also used : CPGroup(com.hazelcast.cp.CPGroup) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) CPMember(com.hazelcast.cp.CPMember) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

CPMember (com.hazelcast.cp.CPMember)57 HazelcastInstance (com.hazelcast.core.HazelcastInstance)40 Test (org.junit.Test)38 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)27 SlowTest (com.hazelcast.test.annotation.SlowTest)27 CPGroup (com.hazelcast.cp.CPGroup)17 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)16 CPGroupId (com.hazelcast.cp.CPGroupId)14 ConnectionResponse (com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse)11 QuickTest (com.hazelcast.test.annotation.QuickTest)11 ArrayList (java.util.ArrayList)11 Config (com.hazelcast.config.Config)10 RaftNodeImpl (com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)10 RaftEndpoint (com.hazelcast.cp.internal.raft.impl.RaftEndpoint)7 GetActiveCPMembersOp (com.hazelcast.cp.internal.raftop.metadata.GetActiveCPMembersOp)6 JsonArray (com.hazelcast.internal.json.JsonArray)6 JsonObject (com.hazelcast.internal.json.JsonObject)6 TestHazelcastInstanceFactory.initOrCreateConfig (com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig)6 CPSubsystemManagementService (com.hazelcast.cp.CPSubsystemManagementService)4 JsonValue (com.hazelcast.internal.json.JsonValue)4