Search in sources :

Example 1 with TriggerDestroyRaftGroupOp

use of com.hazelcast.cp.internal.raftop.metadata.TriggerDestroyRaftGroupOp 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();
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) CPGroup(com.hazelcast.cp.CPGroup) RaftInvocationManager(com.hazelcast.cp.internal.RaftInvocationManager) GetRaftGroupOp(com.hazelcast.cp.internal.raftop.metadata.GetRaftGroupOp) CPGroupDestroyedException(com.hazelcast.cp.exception.CPGroupDestroyedException) TriggerDestroyRaftGroupOp(com.hazelcast.cp.internal.raftop.metadata.TriggerDestroyRaftGroupOp) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with TriggerDestroyRaftGroupOp

use of com.hazelcast.cp.internal.raftop.metadata.TriggerDestroyRaftGroupOp in project hazelcast by hazelcast.

the class RaftInvocationManagerTest method when_raftGroupIsDestroyed_then_operationsEventuallyFail.

@Test
public void when_raftGroupIsDestroyed_then_operationsEventuallyFail() throws ExecutionException, InterruptedException {
    int nodeCount = 3;
    instances = newInstances(nodeCount);
    RaftInvocationManager invocationManager = getRaftInvocationManager(instances[0]);
    CPGroupId groupId = invocationManager.createRaftGroup("test", nodeCount).get();
    invocationManager.invoke(groupId, new RaftTestApplyOp("val")).get();
    invocationManager.invoke(getRaftService(instances[0]).getMetadataGroupId(), new TriggerDestroyRaftGroupOp(groupId)).get();
    assertTrueEventually(() -> {
        try {
            invocationManager.invoke(groupId, new RaftTestApplyOp("val")).get();
            fail();
        } catch (ExecutionException e) {
            assertInstanceOf(CPGroupDestroyedException.class, e.getCause());
        }
    });
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) CPGroupDestroyedException(com.hazelcast.cp.exception.CPGroupDestroyedException) ExecutionException(java.util.concurrent.ExecutionException) TriggerDestroyRaftGroupOp(com.hazelcast.cp.internal.raftop.metadata.TriggerDestroyRaftGroupOp) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with TriggerDestroyRaftGroupOp

use of com.hazelcast.cp.internal.raftop.metadata.TriggerDestroyRaftGroupOp 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");
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) CPGroup(com.hazelcast.cp.CPGroup) RaftInvocationManager(com.hazelcast.cp.internal.RaftInvocationManager) GetRaftGroupOp(com.hazelcast.cp.internal.raftop.metadata.GetRaftGroupOp) CPGroupDestroyedException(com.hazelcast.cp.exception.CPGroupDestroyedException) TriggerDestroyRaftGroupOp(com.hazelcast.cp.internal.raftop.metadata.TriggerDestroyRaftGroupOp) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

CPGroupId (com.hazelcast.cp.CPGroupId)3 CPGroupDestroyedException (com.hazelcast.cp.exception.CPGroupDestroyedException)3 TriggerDestroyRaftGroupOp (com.hazelcast.cp.internal.raftop.metadata.TriggerDestroyRaftGroupOp)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 CPGroup (com.hazelcast.cp.CPGroup)2 RaftInvocationManager (com.hazelcast.cp.internal.RaftInvocationManager)2 GetRaftGroupOp (com.hazelcast.cp.internal.raftop.metadata.GetRaftGroupOp)2 ExecutionException (java.util.concurrent.ExecutionException)1