use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class Invocation_DetectHeartbeatTimeoutTest method whenCallTimeoutDisabled.
@Test
public void whenCallTimeoutDisabled() {
Config config = new Config();
config.setProperty(OPERATION_CALL_TIMEOUT_MILLIS.getName(), "1000");
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance();
HazelcastInstance remote = factory.newHazelcastInstance();
OperationService opService = getOperationService(local);
Operation operation = new VoidOperation();
InvocationFuture future = (InvocationFuture) opService.createInvocationBuilder(null, operation, getPartitionId(remote)).setCallTimeout(Long.MAX_VALUE).invoke();
Invocation invocation = future.invocation;
assertEquals(Long.MAX_VALUE, invocation.op.getCallTimeout());
assertEquals(Long.MAX_VALUE, invocation.callTimeoutMillis);
assertEquals(NO_TIMEOUT__CALL_TIMEOUT_DISABLED, invocation.detectTimeout(SECONDS.toMillis(1)));
assertFalse(future.isDone());
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class OperationRunnerImplTest method runOperation_whenGeneric.
@Test
public void runOperation_whenGeneric() {
final AtomicLong counter = new AtomicLong();
final Object response = "someresponse";
Operation op = new Operation() {
@Override
public void run() throws Exception {
counter.incrementAndGet();
}
@Override
public Object getResponse() {
return response;
}
};
op.setPartitionId(-1);
op.setOperationResponseHandler(responseHandler);
operationRunner.run(op);
assertEquals(1, counter.get());
verify(responseHandler).sendResponse(op, response);
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class Invocation_DetectHeartbeatTimeoutTest method whenCallTimeoutNotExpired.
@Test
public void whenCallTimeoutNotExpired() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance();
HazelcastInstance remote = factory.newHazelcastInstance();
OperationService opService = getOperationService(local);
Operation operation = new SlowOperation(SECONDS.toMillis(60));
InvocationFuture future = (InvocationFuture) opService.invokeOnPartition(null, operation, getPartitionId(remote));
Invocation invocation = future.invocation;
assertEquals(NO_TIMEOUT__CALL_TIMEOUT_NOT_EXPIRED, invocation.detectTimeout(SECONDS.toMillis(1)));
assertFalse(future.isDone());
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class Invocation_DetectHeartbeatTimeoutTest method whenResponseAvailable.
@Test
public void whenResponseAvailable() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance();
HazelcastInstance remote = factory.newHazelcastInstance();
OperationService opService = getOperationService(local);
Operation operation = new SlowOperation(SECONDS.toMillis(60));
InvocationFuture future = (InvocationFuture) opService.invokeOnPartition(null, operation, getPartitionId(remote));
Invocation invocation = future.invocation;
invocation.pendingResponse = "foo";
invocation.backupsAcksExpected = 1;
assertEquals(NO_TIMEOUT__RESPONSE_AVAILABLE, invocation.detectTimeout(SECONDS.toMillis(1)));
assertFalse(future.isDone());
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class MapProxySupport method loadInternal.
/**
* Maps keys to corresponding partitions and sends operations to them.
*/
protected void loadInternal(Iterable<Data> dataKeys, boolean replaceExistingValues) {
Map<Integer, List<Data>> partitionIdToKeys = getPartitionIdToKeysMap(dataKeys);
Iterable<Entry<Integer, List<Data>>> entries = partitionIdToKeys.entrySet();
for (Entry<Integer, List<Data>> entry : entries) {
Integer partitionId = entry.getKey();
List<Data> correspondingKeys = entry.getValue();
Operation operation = createLoadAllOperation(correspondingKeys, replaceExistingValues);
operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
}
waitUntilLoaded();
}
Aggregations