use of com.hazelcast.cp.internal.raftop.metadata.GetMembershipChangeScheduleOp 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.internal.raftop.metadata.GetMembershipChangeScheduleOp in project hazelcast by hazelcast.
the class CPMemberAddRemoveTest method testRaftMemberNotPresentInAnyRaftGroupIsRemovedDirectlyForGracefulShutdown.
@Test
public void testRaftMemberNotPresentInAnyRaftGroupIsRemovedDirectlyForGracefulShutdown() 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();
promoted.getLifecycleService().shutdown();
MembershipChangeSchedule schedule = getRaftInvocationManager(master).<MembershipChangeSchedule>query(getMetadataGroupId(master), new GetMembershipChangeScheduleOp(), LINEARIZABLE).get();
assertNull(schedule);
}
use of com.hazelcast.cp.internal.raftop.metadata.GetMembershipChangeScheduleOp in project hazelcast by hazelcast.
the class CPMemberAddRemoveTest method testRemoveMemberFromMajorityLostRaftGroup.
@Test
public void testRemoveMemberFromMajorityLostRaftGroup() throws ExecutionException, InterruptedException {
HazelcastInstance[] instances = newInstances(3, 3, 0);
waitAllForLeaderElection(instances, getMetadataGroupId(instances[0]));
CPGroupId groupId = getRaftInvocationManager(instances[0]).createRaftGroup("test", 2).get();
getRaftInvocationManager(instances[0]).invoke(groupId, new DummyOp()).get();
RaftNodeImpl groupLeaderRaftNode = getLeaderNode(instances, groupId);
CPGroup group = instances[0].getCPSubsystem().getCPSubsystemManagementService().getCPGroup(groupId.getName()).toCompletableFuture().get();
CPMember[] groupMembers = group.members().toArray(new CPMember[0]);
CPMember crashedMember = groupMembers[0].getUuid().equals(groupLeaderRaftNode.getLocalMember().getUuid()) ? groupMembers[1] : groupMembers[0];
HazelcastInstance runningInstance = (getAddress(instances[0])).equals(crashedMember.getAddress()) ? instances[1] : instances[0];
RaftInvocationManager invocationManager = getRaftInvocationManager(runningInstance);
factory.getInstance(crashedMember.getAddress()).getLifecycleService().terminate();
// from now on, "test" group lost the majority
// we triggered removal of the crashed member but we won't be able to commit to the "test" group
CompletableFuture<Void> f = runningInstance.getCPSubsystem().getCPSubsystemManagementService().removeCPMember(crashedMember.getUuid()).toCompletableFuture();
// wait until RaftCleanupHandler kicks in and appends ApplyRaftGroupMembersCmd to the leader of the "test" group
assertTrueEventually(() -> assertTrue(getLastLogOrSnapshotEntry(groupLeaderRaftNode).operation() instanceof UpdateRaftGroupMembersCmd));
// force-destroy the raft group.
// Now, the pending membership change in the "test" group will fail and we will fix it in the metadata group.
runningInstance.getCPSubsystem().getCPSubsystemManagementService().forceDestroyCPGroup(groupId.getName()).toCompletableFuture().get();
f.get();
MembershipChangeSchedule schedule = invocationManager.<MembershipChangeSchedule>query(getMetadataGroupId(runningInstance), new GetMembershipChangeScheduleOp(), LINEARIZABLE).get();
assertNull(schedule);
}
use of com.hazelcast.cp.internal.raftop.metadata.GetMembershipChangeScheduleOp in project hazelcast by hazelcast.
the class CPMemberAddRemoveTest method testRaftMemberIsRemovedForGracefulShutdown.
@Test
public void testRaftMemberIsRemovedForGracefulShutdown() throws ExecutionException, InterruptedException {
HazelcastInstance[] instances = newInstances(3, 3, 0);
CPMember shutdownCPMember = instances[0].getCPSubsystem().getLocalCPMember();
instances[0].getLifecycleService().shutdown();
RaftInvocationManager invocationManager = getRaftInvocationManager(instances[1]);
CPGroupId metadataGroupId = getMetadataGroupId(instances[1]);
MembershipChangeSchedule schedule = invocationManager.<MembershipChangeSchedule>query(metadataGroupId, new GetMembershipChangeScheduleOp(), LINEARIZABLE).get();
assertNull(schedule);
CPGroup group = invocationManager.<CPGroup>invoke(metadataGroupId, new GetRaftGroupOp(metadataGroupId)).join();
assertEquals(2, group.members().size());
for (CPMember member : group.members()) {
assertNotEquals(shutdownCPMember, member);
}
}
Aggregations