Search in sources :

Example 1 with OperationParkerImpl

use of com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl in project hazelcast by hazelcast.

the class ClientDisconnectTest method assertEmptyPendingInvocationAndWaitSet.

private void assertEmptyPendingInvocationAndWaitSet(HazelcastInstance server) {
    NodeEngineImpl nodeEngine = getNodeEngineImpl(server);
    OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();
    final InvocationRegistry invocationRegistry = operationService.getInvocationRegistry();
    final OperationParkerImpl operationParker = (OperationParkerImpl) nodeEngine.getOperationParker();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertTrue(invocationRegistry.entrySet().isEmpty());
        }
    });
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertEquals(0, operationParker.getTotalParkedOperationCount());
        }
    });
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) AssertTask(com.hazelcast.test.AssertTask) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) InvocationRegistry(com.hazelcast.spi.impl.operationservice.impl.InvocationRegistry) OperationParkerImpl(com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl)

Example 2 with OperationParkerImpl

use of com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl in project hazelcast by hazelcast.

the class Invocation_NetworkSplitTest method testWaitNotifyService_whenNodeSplitFromCluster.

private void testWaitNotifyService_whenNodeSplitFromCluster(SplitAction action) {
    Config config = createConfig();
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(4);
    final HazelcastInstance hz1 = factory.newHazelcastInstance(config);
    final HazelcastInstance hz2 = factory.newHazelcastInstance(config);
    final HazelcastInstance hz3 = factory.newHazelcastInstance(config);
    warmUpPartitions(hz1, hz2, hz3);
    int partitionId = getPartitionId(hz3);
    getNodeEngineImpl(hz1).getOperationService().invokeOnPartition("", new AlwaysBlockingOperation(), partitionId);
    final OperationParkerImpl waitNotifyService3 = (OperationParkerImpl) getNodeEngineImpl(hz3).getOperationParker();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertEquals(1, waitNotifyService3.getTotalParkedOperationCount());
        }
    });
    action.run(hz1, hz2, hz3);
    // create a new node to prevent same partition assignments
    // after node3 rejoins
    factory.newHazelcastInstance(config);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertEquals(0, getPartitionService(hz1).getMigrationQueueSize());
        }
    });
    unblock(hz1, hz2, hz3);
    // Let node3 detect the split and merge it back to other two.
    ClusterServiceImpl clusterService3 = (ClusterServiceImpl) getClusterService(hz3);
    clusterService3.merge(getAddress(hz1));
    assertClusterSizeEventually(4, hz1, hz2, hz3);
    assertEquals(0, waitNotifyService3.getTotalParkedOperationCount());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) OperationParkerImpl(com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl)

Example 3 with OperationParkerImpl

use of com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl in project hazelcast by hazelcast.

the class HazelcastTestSupport method assertWaitingOperationCountEventually.

public static void assertWaitingOperationCountEventually(final int expectedOpsCount, HazelcastInstance instance) {
    final OperationParkerImpl waitNotifyService = getOperationParkingService(instance);
    assertTrueEventually(() -> assertEquals(expectedOpsCount, waitNotifyService.getTotalParkedOperationCount()));
}
Also used : OperationParkerImpl(com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl)

Example 4 with OperationParkerImpl

use of com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl in project hazelcast by hazelcast.

the class ClientDisconnectTest method assertNonEmptyPendingInvocationAndWaitSet.

private void assertNonEmptyPendingInvocationAndWaitSet(HazelcastInstance server) {
    NodeEngineImpl nodeEngine = getNodeEngineImpl(server);
    OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();
    final InvocationRegistry invocationRegistry = operationService.getInvocationRegistry();
    final OperationParkerImpl operationParker = (OperationParkerImpl) nodeEngine.getOperationParker();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertFalse(invocationRegistry.entrySet().isEmpty());
        }
    });
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertTrue(operationParker.getTotalParkedOperationCount() > 0);
        }
    });
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) AssertTask(com.hazelcast.test.AssertTask) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) InvocationRegistry(com.hazelcast.spi.impl.operationservice.impl.InvocationRegistry) OperationParkerImpl(com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl)

Example 5 with OperationParkerImpl

use of com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl in project hazelcast by hazelcast.

the class Invocation_NetworkSplitTest method testWaitingInvocations_whenNodeSplitFromCluster.

private void testWaitingInvocations_whenNodeSplitFromCluster(SplitAction action) {
    Config config = createConfig();
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    final HazelcastInstance hz1 = factory.newHazelcastInstance(config);
    final HazelcastInstance hz2 = factory.newHazelcastInstance(config);
    final HazelcastInstance hz3 = factory.newHazelcastInstance(config);
    warmUpPartitions(hz1, hz2, hz3);
    int partitionId = getPartitionId(hz2);
    Operation op = new AlwaysBlockingOperation();
    Future<Object> future = getNodeEngineImpl(hz3).getOperationService().invokeOnPartition("", op, partitionId);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            final OperationParkerImpl waitNotifyService3 = (OperationParkerImpl) getNodeEngineImpl(hz2).getOperationParker();
            assertEquals(1, waitNotifyService3.getTotalParkedOperationCount());
        }
    });
    // execute the given split action
    action.run(hz1, hz2, hz3);
    unblock(hz1, hz2, hz3);
    // Let node3 detect the split and merge it back to other two.
    ClusterServiceImpl clusterService3 = (ClusterServiceImpl) getClusterService(hz3);
    clusterService3.merge(getAddress(hz1));
    assertClusterSizeEventually(3, hz1, hz2, hz3);
    try {
        future.get(1, TimeUnit.MINUTES);
        fail("Future.get() should fail with a MemberLeftException!");
    } catch (MemberLeftException expected) {
        ignore(expected);
    } catch (Exception e) {
        fail(e.getClass().getName() + ": " + e.getMessage());
    }
}
Also used : Config(com.hazelcast.config.Config) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) Operation(com.hazelcast.spi.impl.operationservice.Operation) BlockingOperation(com.hazelcast.spi.impl.operationservice.BlockingOperation) TimeoutException(java.util.concurrent.TimeoutException) MemberLeftException(com.hazelcast.core.MemberLeftException) OperationParkerImpl(com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) MemberLeftException(com.hazelcast.core.MemberLeftException)

Aggregations

OperationParkerImpl (com.hazelcast.spi.impl.operationparker.impl.OperationParkerImpl)5 AssertTask (com.hazelcast.test.AssertTask)4 Config (com.hazelcast.config.Config)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 InvocationRegistry (com.hazelcast.spi.impl.operationservice.impl.InvocationRegistry)2 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)2 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 MemberLeftException (com.hazelcast.core.MemberLeftException)1 BlockingOperation (com.hazelcast.spi.impl.operationservice.BlockingOperation)1 Operation (com.hazelcast.spi.impl.operationservice.Operation)1 TimeoutException (java.util.concurrent.TimeoutException)1