use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class Invocation_NestedRemoteTest method invokeOnPartition_outerGeneric_innerGeneric_forbidden.
@Test
public void invokeOnPartition_outerGeneric_innerGeneric_forbidden() {
HazelcastInstance[] cluster = createHazelcastInstanceFactory(1).newInstances();
HazelcastInstance local = cluster[0];
OperationService operationService = getOperationService(local);
InnerOperation innerOperation = new InnerOperation(RESPONSE, GENERIC_OPERATION);
OuterOperation outerOperation = new OuterOperation(innerOperation, GENERIC_OPERATION);
expected.expect(Exception.class);
operationService.invokeOnPartition(null, outerOperation, outerOperation.getPartitionId());
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class Invocation_NestedRemoteTest method invokeOnPartition_outerRemote_innerGeneric.
@Test
public void invokeOnPartition_outerRemote_innerGeneric() {
HazelcastInstance[] cluster = createHazelcastInstanceFactory(2).newInstances();
HazelcastInstance local = cluster[0];
HazelcastInstance remote = cluster[1];
OperationService operationService = getOperationService(local);
int partitionId = getPartitionId(remote);
InnerOperation innerOperation = new InnerOperation(RESPONSE, GENERIC_OPERATION);
OuterOperation outerOperation = new OuterOperation(innerOperation, partitionId);
InternalCompletableFuture future = operationService.invokeOnPartition(null, outerOperation, partitionId);
assertEquals(RESPONSE, future.join());
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class Invocation_NetworkSplitTest method testWaitingInvocations_whenNodeSplitFromCluster.
private void testWaitingInvocations_whenNodeSplitFromCluster(SplitAction splitAction) throws Exception {
Config config = createConfig();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
HazelcastInstance hz1 = factory.newHazelcastInstance(config);
HazelcastInstance hz2 = factory.newHazelcastInstance(config);
HazelcastInstance hz3 = factory.newHazelcastInstance(config);
Node node1 = TestUtil.getNode(hz1);
Node node2 = TestUtil.getNode(hz2);
Node node3 = TestUtil.getNode(hz3);
warmUpPartitions(hz1, hz2, hz3);
int partitionId = getPartitionId(hz2);
NodeEngineImpl nodeEngine3 = node3.getNodeEngine();
OperationService operationService3 = nodeEngine3.getOperationService();
Operation op = new AlwaysBlockingOperation();
Future<Object> future = operationService3.invokeOnPartition("", op, partitionId);
// just wait a little to make sure
// operation is landed on wait-queue
sleepSeconds(1);
// execute the given split action
splitAction.run(node1, node2, node3);
// Let node3 detect the split and merge it back to other two.
ClusterServiceImpl clusterService3 = node3.getClusterService();
clusterService3.merge(node1.address);
assertClusterSizeEventually(3, hz1);
assertClusterSizeEventually(3, hz2);
assertClusterSizeEventually(3, hz3);
try {
future.get(1, TimeUnit.MINUTES);
fail("Future.get() should fail with a MemberLeftException!");
} catch (MemberLeftException e) {
// expected
EmptyStatement.ignore(e);
} catch (Exception e) {
fail(e.getClass().getName() + ": " + e.getMessage());
}
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class Invocation_RetryTest method whenTargetMemberDiesThenOperationAbortedWithMembersLeftException.
@Test(expected = MemberLeftException.class)
public void whenTargetMemberDiesThenOperationAbortedWithMembersLeftException() throws Exception {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance();
HazelcastInstance remote = factory.newHazelcastInstance();
warmUpPartitions(local, remote);
OperationService service = getOperationService(local);
Operation op = new TargetOperation();
Address address = new Address(remote.getCluster().getLocalMember().getSocketAddress());
Future future = service.createInvocationBuilder(null, op, address).invoke();
sleepSeconds(1);
remote.getLifecycleService().terminate();
future.get();
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class Invocation_DetectHeartbeatTimeoutTest method whenExpiresEventually.
/**
* This test checks if the invocation expires eventually after the operation did manage to execute and did manage to send
* some heartbeats but for whatever reason the response was not received.
*
* We do this by sending in a void operation that runs for an long period (so there are heartbeats) but on completion it
* doesn't send a response.
*/
@Test
public void whenExpiresEventually() {
Config config = new Config();
config.setProperty(OPERATION_CALL_TIMEOUT_MILLIS.getName(), "5000");
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance(config);
HazelcastInstance remote = factory.newHazelcastInstance(config);
OperationService opService = getOperationService(local);
Operation operation = new VoidOperation(SECONDS.toMillis(20));
InvocationFuture future = (InvocationFuture) opService.invokeOnPartition(null, operation, getPartitionId(remote));
Invocation invocation = future.invocation;
assertDetectHeartbeatTimeoutEventually(invocation, NO_TIMEOUT__CALL_TIMEOUT_NOT_EXPIRED);
assertDetectHeartbeatTimeoutEventually(invocation, NO_TIMEOUT__HEARTBEAT_TIMEOUT_NOT_EXPIRED);
assertDetectHeartbeatTimeoutEventually(invocation, TIMEOUT);
}
Aggregations