use of com.hazelcast.cp.exception.CPGroupDestroyedException 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.exception.CPGroupDestroyedException in project hazelcast by hazelcast.
the class RaftReplicateOp method run.
@Override
public final void run() {
RaftService service = getService();
RaftNode raftNode = service.getOrInitRaftNode(groupId);
if (raftNode == null) {
if (service.isRaftGroupDestroyed(groupId)) {
sendResponse(new CPGroupDestroyedException(groupId));
} else {
sendResponse(new NotLeaderException(groupId, service.getLocalCPEndpoint(), null));
}
return;
} else if (raftNode.getStatus() == RaftNodeStatus.STEPPED_DOWN) {
sendResponse(new NotLeaderException(groupId, service.getLocalCPEndpoint(), null));
getNodeEngine().getExecutionService().execute(CP_SUBSYSTEM_EXECUTOR, () -> service.stepDownRaftNode(groupId));
return;
}
replicate(raftNode).whenCompleteAsync(this, CALLER_RUNS);
}
use of com.hazelcast.cp.exception.CPGroupDestroyedException in project hazelcast by hazelcast.
the class RaftQueryOp method run.
@Override
public final void run() {
RaftService service = getService();
RaftNode raftNode = service.getRaftNode(groupId);
if (raftNode == null) {
if (service.isRaftGroupDestroyed(groupId)) {
sendResponse(new CPGroupDestroyedException(groupId));
} else {
sendResponse(new NotLeaderException(groupId, service.getLocalCPEndpoint(), null));
}
return;
} else if (raftNode.getStatus() == RaftNodeStatus.STEPPED_DOWN) {
sendResponse(new NotLeaderException(groupId, service.getLocalCPEndpoint(), null));
getNodeEngine().getExecutionService().execute(CP_SUBSYSTEM_EXECUTOR, () -> service.stepDownRaftNode(groupId));
return;
}
if (op instanceof RaftNodeAware) {
((RaftNodeAware) op).setRaftNode(raftNode);
}
raftNode.query(op, queryPolicy).whenCompleteAsync(this, CALLER_RUNS);
}
use of com.hazelcast.cp.exception.CPGroupDestroyedException in project hazelcast by hazelcast.
the class CPMemberAddRemoveTest method testMetadataGroupReinitializationAfterLostMajority.
@Test
public void testMetadataGroupReinitializationAfterLostMajority() throws ExecutionException, InterruptedException {
HazelcastInstance[] instances = newInstances(3, 3, 1);
long groupIdSeed = getRaftService(instances[0]).getMetadataGroupManager().getGroupIdSeed();
RaftGroupId groupId = getRaftInvocationManager(instances[0]).createRaftGroup(CPGroup.DEFAULT_GROUP_NAME).get();
IAtomicLong long1 = instances[0].getCPSubsystem().getAtomicLong("proxy");
sleepAtLeastMillis(10);
instances[1].getLifecycleService().terminate();
instances[2].getLifecycleService().terminate();
assertClusterSizeEventually(2, instances[3]);
HazelcastInstance[] newInstances = new HazelcastInstance[3];
newInstances[0] = instances[0];
newInstances[1] = instances[3];
Config config = createConfig(3, 3);
newInstances[2] = factory.newHazelcastInstance(config);
assertClusterSizeEventually(3, newInstances);
newInstances[0].getCPSubsystem().getCPSubsystemManagementService().reset().toCompletableFuture().get();
waitUntilCPDiscoveryCompleted(newInstances);
long newGroupIdSeed = getRaftService(newInstances[0]).getMetadataGroupManager().getGroupIdSeed();
RaftGroupId newGroupId = getRaftInvocationManager(instances[0]).createRaftGroup(CPGroup.DEFAULT_GROUP_NAME).get();
assertThat(newGroupIdSeed, greaterThan(groupIdSeed));
assertThat(newGroupId.getSeed(), greaterThan(groupId.getSeed()));
try {
long1.incrementAndGet();
fail();
} catch (CPGroupDestroyedException ignored) {
}
IAtomicLong long2 = newInstances[2].getCPSubsystem().getAtomicLong("proxy");
long2.incrementAndGet();
assertTrueEventually(() -> {
CPGroupSummary group = queryRaftGroupLocally(newInstances[2], getMetadataGroupId(newInstances[2]));
assertNotNull(group);
Collection<CPMember> endpoints = group.members();
for (HazelcastInstance instance : newInstances) {
Member localMember = instance.getCluster().getLocalMember();
assertThat(new CPMemberInfo(localMember), isIn(endpoints));
}
});
}
use of com.hazelcast.cp.exception.CPGroupDestroyedException 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