use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class RaftInvocationManagerQueryTest method when_queryLocalFromLeader_withLeaderLocalPolicy_thenReadLatestValue.
@Test
public void when_queryLocalFromLeader_withLeaderLocalPolicy_thenReadLatestValue() throws Exception {
int nodeCount = 3;
instances = newInstances(nodeCount);
RaftInvocationManager invocationService = getRaftInvocationManager(instances[0]);
CPGroupId groupId = invocationService.createRaftGroup("test", nodeCount).get();
String value = "value";
invocationService.invoke(groupId, new RaftTestApplyOp(value)).get();
HazelcastInstance leader = getLeaderInstance(instances, groupId);
Future<Object> future = getRaftInvocationManager(leader).queryLocally(groupId, new RaftTestQueryOp(), LEADER_LOCAL);
assertEquals(value, future.get());
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class RaftInvocationManagerQueryTest method when_queryLocalFromFollower_withoutAnyCommit_thenReturnDefaultValue.
@Test
public void when_queryLocalFromFollower_withoutAnyCommit_thenReturnDefaultValue() throws Exception {
int nodeCount = 3;
instances = newInstances(nodeCount);
RaftInvocationManager invocationService = getRaftInvocationManager(instances[0]);
CPGroupId groupId = invocationService.createRaftGroup("test", nodeCount).get();
HazelcastInstance follower = getRandomFollowerInstance(instances, groupId);
Future<Object> future = getRaftInvocationManager(follower).query(groupId, new RaftTestQueryOp(), ANY_LOCAL);
assertNull(future.get());
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class RaftInvocationManagerQueryTest method when_queryLocalFromLeader_withoutAnyCommit_thenReturnDefaultValue.
@Test
public void when_queryLocalFromLeader_withoutAnyCommit_thenReturnDefaultValue() throws Exception {
int nodeCount = 3;
instances = newInstances(nodeCount);
RaftInvocationManager invocationService = getRaftInvocationManager(instances[0]);
CPGroupId groupId = invocationService.createRaftGroup("test", nodeCount).get();
Future<Object> future = invocationService.query(groupId, new RaftTestQueryOp(), LEADER_LOCAL);
assertNull(future.get());
}
use of com.hazelcast.cp.CPGroupId 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);
}
use of com.hazelcast.cp.CPGroupId 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);
}
Aggregations