Search in sources :

Example 1 with AddAndGetOperation

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);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AddAndGetOperation(com.hazelcast.internal.longregister.operations.AddAndGetOperation) Config(com.hazelcast.config.Config) AddAndGetOperation(com.hazelcast.internal.longregister.operations.AddAndGetOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) ExecutionException(java.util.concurrent.ExecutionException) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Example 2 with AddAndGetOperation

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AddAndGetOperation(com.hazelcast.internal.longregister.operations.AddAndGetOperation) Address(com.hazelcast.cluster.Address) Accessors.getAddress(com.hazelcast.test.Accessors.getAddress) Config(com.hazelcast.config.Config) AddAndGetOperation(com.hazelcast.internal.longregister.operations.AddAndGetOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

Config (com.hazelcast.config.Config)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 AddAndGetOperation (com.hazelcast.internal.longregister.operations.AddAndGetOperation)2 Operation (com.hazelcast.spi.impl.operationservice.Operation)2 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 Address (com.hazelcast.cluster.Address)1 Accessors.getAddress (com.hazelcast.test.Accessors.getAddress)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.Test)1