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());
}
});
}
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());
}
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()));
}
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);
}
});
}
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());
}
}
Aggregations