use of com.hazelcast.internal.longregister.operations.AddAndGetOperation in project hazelcast by hazelcast.
the class AdvancedClusterStateTest method partitionInvocation_shouldFail_whenPartitionsNotAssigned_whenMigrationNotAllowed.
private void partitionInvocation_shouldFail_whenPartitionsNotAssigned_whenMigrationNotAllowed(ClusterState state) throws InterruptedException {
Config config = new Config();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
HazelcastInstance[] instances = factory.newInstances(config);
HazelcastInstance hz2 = instances[1];
HazelcastInstance hz3 = instances[2];
changeClusterStateEventually(hz2, state);
OperationServiceImpl operationService = getNode(hz3).getNodeEngine().getOperationService();
Operation op = new AddAndGetOperation(randomName(), 1);
Future<Long> future = operationService.invokeOnPartition(LongRegisterService.SERVICE_NAME, op, 1);
exception.expect(IllegalStateException.class);
try {
future.get();
} catch (ExecutionException e) {
// IllegalStateException should be cause of ExecutionException.
throw ExceptionUtil.rethrow(e);
}
}
use of com.hazelcast.internal.longregister.operations.AddAndGetOperation in project hazelcast by hazelcast.
the class AdvancedClusterStateTest method invocationShouldComplete_whenMemberReJoins_inFrozenState.
@Test
public void invocationShouldComplete_whenMemberReJoins_inFrozenState() throws Exception {
Config config = new Config();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
HazelcastInstance[] instances = factory.newInstances(config);
HazelcastInstance hz1 = instances[0];
HazelcastInstance hz2 = instances[1];
HazelcastInstance hz3 = instances[2];
warmUpPartitions(instances);
waitAllForSafeState(instances);
Address owner = getNode(hz1).getThisAddress();
String key = generateKeyOwnedBy(hz1);
int partitionId = hz1.getPartitionService().getPartition(key).getPartitionId();
changeClusterStateEventually(hz2, ClusterState.FROZEN);
terminateInstance(hz1);
OperationServiceImpl operationService = getNode(hz3).getNodeEngine().getOperationService();
Operation op = new AddAndGetOperation(key, 1);
Future<Long> future = operationService.invokeOnPartition(LongRegisterService.SERVICE_NAME, op, partitionId);
assertFalse(future.isDone());
factory.newHazelcastInstance(owner);
assertClusterSizeEventually(3, hz2);
assertTrueEventually(() -> assertTrue(future.isDone()));
// should not fail
future.get();
}
Aggregations