Search in sources :

Example 1 with DefaultRaftReplicateOp

use of com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp in project hazelcast by hazelcast.

the class RaftInvocationManager method invoke.

public <T> InternalCompletableFuture<T> invoke(CPGroupId groupId, RaftOp raftOp, boolean deserializeResponse) {
    if (cpSubsystemEnabled) {
        Operation operation = new DefaultRaftReplicateOp(groupId, raftOp);
        Invocation invocation = new RaftInvocation(operationService.getInvocationContext(), raftInvocationContext, groupId, operation, invocationMaxRetryCount, invocationRetryPauseMillis, operationCallTimeout, deserializeResponse);
        return invocation.invoke();
    }
    return invokeOnPartition(new UnsafeRaftReplicateOp(groupId, raftOp), deserializeResponse);
}
Also used : RaftInvocation(com.hazelcast.spi.impl.operationservice.impl.RaftInvocation) Invocation(com.hazelcast.spi.impl.operationservice.impl.Invocation) RaftInvocation(com.hazelcast.spi.impl.operationservice.impl.RaftInvocation) Operation(com.hazelcast.spi.impl.operationservice.Operation) DefaultRaftReplicateOp(com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp) UnsafeRaftReplicateOp(com.hazelcast.cp.internal.operation.unsafe.UnsafeRaftReplicateOp)

Example 2 with DefaultRaftReplicateOp

use of com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp in project hazelcast by hazelcast.

the class RaftInvocationFailureTest method test_invocationFailsWithMemberLeftException_when_thereAreRetryableExceptionsAfterwards.

@Test
public void test_invocationFailsWithMemberLeftException_when_thereAreRetryableExceptionsAfterwards() throws ExecutionException, InterruptedException {
    CPGroupId groupId = getRaftInvocationManager(instances[0]).createRaftGroup(groupName).get();
    waitAllForLeaderElection(instances, groupId);
    HazelcastInstance leader = getLeaderInstance(instances, groupId);
    Future f = new RaftInvocation(getOperationService(leader).invocationContext, getRaftInvocationManager(leader).getRaftInvocationContext(), groupId, new DefaultRaftReplicateOp(groupId, new CustomResponseOp2()), 10, 50, 60000).invoke();
    try {
        f.get(60, TimeUnit.SECONDS);
        fail();
    } catch (Exception e) {
        assertInstanceOf(IndeterminateOperationStateException.class, e.getCause());
    }
    assertTrue(COMMIT_COUNT.get() > groupSize);
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) DefaultRaftReplicateOp(com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp) StaleAppendRequestException(com.hazelcast.cp.exception.StaleAppendRequestException) CallerNotMemberException(com.hazelcast.spi.exception.CallerNotMemberException) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with DefaultRaftReplicateOp

use of com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp in project hazelcast by hazelcast.

the class RaftInvocationFailureTest method test_invocationFailsWitNonRetryableException_when_thereAreRetryableExceptionsAfterIndeterminateOperationState.

@Test
public void test_invocationFailsWitNonRetryableException_when_thereAreRetryableExceptionsAfterIndeterminateOperationState() throws ExecutionException, InterruptedException {
    CPGroupId groupId = getRaftInvocationManager(instances[0]).createRaftGroup(groupName).get();
    waitAllForLeaderElection(instances, groupId);
    HazelcastInstance leader = getLeaderInstance(instances, groupId);
    Future f = new RaftInvocation(getOperationService(leader).invocationContext, getRaftInvocationManager(leader).getRaftInvocationContext(), groupId, new DefaultRaftReplicateOp(groupId, new CustomResponseOp5()), 10, 50, 60000).invoke();
    try {
        f.get(60, TimeUnit.SECONDS);
        fail();
    } catch (Exception e) {
        assertInstanceOf(IllegalStateException.class, e.getCause());
    }
    assertTrue(COMMIT_COUNT.get() > groupSize);
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) DefaultRaftReplicateOp(com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp) StaleAppendRequestException(com.hazelcast.cp.exception.StaleAppendRequestException) CallerNotMemberException(com.hazelcast.spi.exception.CallerNotMemberException) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with DefaultRaftReplicateOp

use of com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp in project hazelcast by hazelcast.

the class RaftInvocationFailureTest method test_invocationFailsWithStaleAppendRequestException_when_thereAreRetryableExceptionsAfterwards.

@Test
public void test_invocationFailsWithStaleAppendRequestException_when_thereAreRetryableExceptionsAfterwards() throws ExecutionException, InterruptedException {
    CPGroupId groupId = getRaftInvocationManager(instances[0]).createRaftGroup(groupName).get();
    waitAllForLeaderElection(instances, groupId);
    HazelcastInstance leader = getLeaderInstance(instances, groupId);
    Future f = new RaftInvocation(getOperationService(leader).invocationContext, getRaftInvocationManager(leader).getRaftInvocationContext(), groupId, new DefaultRaftReplicateOp(groupId, new CustomResponseOp3()), 100, 500, 60000).invoke();
    try {
        f.get(60, TimeUnit.SECONDS);
        fail();
    } catch (Exception e) {
        assertInstanceOf(IndeterminateOperationStateException.class, e.getCause());
    }
    assertTrue(COMMIT_COUNT.get() > groupSize);
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) DefaultRaftReplicateOp(com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp) StaleAppendRequestException(com.hazelcast.cp.exception.StaleAppendRequestException) CallerNotMemberException(com.hazelcast.spi.exception.CallerNotMemberException) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with DefaultRaftReplicateOp

use of com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp in project hazelcast by hazelcast.

the class RaftInvocationFailureTest method test_invocationFailsOnMemberLeftException.

@Test
public void test_invocationFailsOnMemberLeftException() throws ExecutionException, InterruptedException {
    CPGroupId groupId = getRaftInvocationManager(instances[0]).createRaftGroup(groupName).get();
    waitAllForLeaderElection(instances, groupId);
    HazelcastInstance leader = getLeaderInstance(instances, groupId);
    Future f = new RaftInvocation(getOperationService(leader).invocationContext, getRaftInvocationManager(leader).getRaftInvocationContext(), groupId, new DefaultRaftReplicateOp(groupId, new CustomResponseOp()), 10, 50, 60000).invoke();
    try {
        f.get(60, TimeUnit.SECONDS);
        fail();
    } catch (Exception e) {
        assertInstanceOf(IndeterminateOperationStateException.class, e.getCause());
    }
    assertTrue(COMMIT_COUNT.get() <= groupSize);
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) DefaultRaftReplicateOp(com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp) StaleAppendRequestException(com.hazelcast.cp.exception.StaleAppendRequestException) CallerNotMemberException(com.hazelcast.spi.exception.CallerNotMemberException) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

DefaultRaftReplicateOp (com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 IndeterminateOperationStateException (com.hazelcast.core.IndeterminateOperationStateException)5 MemberLeftException (com.hazelcast.core.MemberLeftException)5 CPGroupId (com.hazelcast.cp.CPGroupId)5 StaleAppendRequestException (com.hazelcast.cp.exception.StaleAppendRequestException)5 CallerNotMemberException (com.hazelcast.spi.exception.CallerNotMemberException)5 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 ExecutionException (java.util.concurrent.ExecutionException)5 Future (java.util.concurrent.Future)5 Test (org.junit.Test)5 UnsafeRaftReplicateOp (com.hazelcast.cp.internal.operation.unsafe.UnsafeRaftReplicateOp)1 Operation (com.hazelcast.spi.impl.operationservice.Operation)1 Invocation (com.hazelcast.spi.impl.operationservice.impl.Invocation)1 RaftInvocation (com.hazelcast.spi.impl.operationservice.impl.RaftInvocation)1