use of com.hazelcast.cp.internal.raftop.metadata.GetRaftGroupOp in project hazelcast by hazelcast.
the class MetadataRaftGroupTest method when_memberIsShutdown_then_itIsRemovedFromRaftGroups.
@Test
public void when_memberIsShutdown_then_itIsRemovedFromRaftGroups() throws ExecutionException, InterruptedException {
int cpNodeCount = 7;
int metadataGroupSize = 5;
int atomicLong1GroupSize = 3;
instances = newInstances(cpNodeCount, metadataGroupSize, 0);
CPGroupId groupId1 = createNewRaftGroup(instances[0], "id1", atomicLong1GroupSize);
CPGroupId groupId2 = createNewRaftGroup(instances[0], "id2", cpNodeCount);
CPMember endpoint = findCommonEndpoint(instances[0], getMetadataGroupId(instances[0]), groupId1);
assertNotNull(endpoint);
RaftInvocationManager invocationService = null;
HazelcastInstance aliveInstance = null;
for (HazelcastInstance instance : instances) {
if (!getAddress(instance).equals(endpoint.getAddress())) {
aliveInstance = instance;
invocationService = getRaftInvocationManager(instance);
break;
}
}
assertNotNull(invocationService);
factory.getInstance(endpoint.getAddress()).shutdown();
CPGroupId metadataGroupId = getMetadataGroupId(aliveInstance);
InternalCompletableFuture<List<CPMember>> f1 = invocationService.query(metadataGroupId, new GetActiveCPMembersOp(), LINEARIZABLE);
List<CPMember> activeEndpoints = f1.get();
assertThat(activeEndpoints, not(hasItem(endpoint)));
InternalCompletableFuture<CPGroup> f2 = invocationService.query(metadataGroupId, new GetRaftGroupOp(metadataGroupId), LINEARIZABLE);
InternalCompletableFuture<CPGroup> f3 = invocationService.query(metadataGroupId, new GetRaftGroupOp(groupId1), LINEARIZABLE);
InternalCompletableFuture<CPGroup> f4 = invocationService.query(metadataGroupId, new GetRaftGroupOp(groupId2), LINEARIZABLE);
CPGroup metadataGroup = f2.get();
assertFalse(metadataGroup.members().contains(endpoint));
assertEquals(metadataGroupSize, metadataGroup.members().size());
CPGroup atomicLongGroup1 = f3.get();
assertFalse(atomicLongGroup1.members().contains(endpoint));
assertEquals(atomicLong1GroupSize, atomicLongGroup1.members().size());
CPGroup atomicLongGroup2 = f4.get();
assertFalse(atomicLongGroup2.members().contains(endpoint));
assertEquals(cpNodeCount - 1, atomicLongGroup2.members().size());
}
use of com.hazelcast.cp.internal.raftop.metadata.GetRaftGroupOp in project hazelcast by hazelcast.
the class AtomicLongBasicTest method testRecreate_afterGroupDestroy.
@Test
public void testRecreate_afterGroupDestroy() throws Exception {
atomicLong.destroy();
CPGroupId groupId = getGroupId(atomicLong);
RaftInvocationManager invocationManager = getRaftInvocationManager(instances[0]);
invocationManager.invoke(getRaftService(instances[0]).getMetadataGroupId(), new TriggerDestroyRaftGroupOp(groupId)).get();
assertTrueEventually(() -> {
CPGroup group = invocationManager.<CPGroup>query(getMetadataGroupId(instances[0]), new GetRaftGroupOp(groupId), LINEARIZABLE).join();
assertEquals(CPGroupStatus.DESTROYED, group.status());
});
try {
atomicLong.incrementAndGet();
fail();
} catch (CPGroupDestroyedException ignored) {
}
atomicLong = createAtomicLong(name);
CPGroupId newGroupId = getGroupId(atomicLong);
assertNotEquals(groupId, newGroupId);
atomicLong.incrementAndGet();
}
use of com.hazelcast.cp.internal.raftop.metadata.GetRaftGroupOp 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);
}
}
use of com.hazelcast.cp.internal.raftop.metadata.GetRaftGroupOp in project hazelcast by hazelcast.
the class AtomicRefBasicTest method testRecreate_afterGroupDestroy.
@Test
public void testRecreate_afterGroupDestroy() throws Exception {
atomicRef.destroy();
CPGroupId groupId = getGroupId(atomicRef);
RaftInvocationManager invocationManager = getRaftInvocationManager(instances[0]);
invocationManager.invoke(getRaftService(instances[0]).getMetadataGroupId(), new TriggerDestroyRaftGroupOp(groupId)).get();
assertTrueEventually(() -> {
CPGroup group = invocationManager.<CPGroup>invoke(getMetadataGroupId(instances[0]), new GetRaftGroupOp(groupId)).join();
assertEquals(CPGroupStatus.DESTROYED, group.status());
});
try {
atomicRef.get();
fail();
} catch (CPGroupDestroyedException ignored) {
}
atomicRef = createAtomicRef(name);
assertNotEquals(groupId, getGroupId(atomicRef));
atomicRef.set("str1");
}
Aggregations