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());
}
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);
}
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));
}
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());
});
}
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());
});
}
Aggregations