use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class Invocation_BlockingTest method async_whenOperationTimeout.
@Test
public void async_whenOperationTimeout() {
int callTimeout = 5000;
Config config = new Config().setProperty(OPERATION_CALL_TIMEOUT_MILLIS.getName(), "" + callTimeout);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance(config);
HazelcastInstance remote = factory.newHazelcastInstance(config);
warmUpPartitions(factory.getAllHazelcastInstances());
NodeEngineImpl nodeEngine = getNodeEngineImpl(local);
String key = generateKeyOwnedBy(remote);
int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
// first we lock the lock by another thread
InternalOperationService opService = nodeEngine.getOperationService();
int otherThreadId = 2;
opService.invokeOnPartition(new LockOperation(new InternalLockNamespace(key), nodeEngine.toData(key), otherThreadId, -1, -1).setPartitionId(partitionId)).join();
// then we execute a lock operation that won't be executed because lock is already acquired
// we are going to do some waiting (3x call timeout)
int threadId = 1;
Operation op = new LockOperation(new InternalLockNamespace(key), nodeEngine.toData(key), threadId, -1, 3 * callTimeout).setPartitionId(partitionId);
final InternalCompletableFuture<Object> future = opService.invokeOnPartition(op);
final ExecutionCallback<Object> callback = getExecutionCallbackMock();
future.andThen(callback);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
verify(callback).onResponse(Boolean.FALSE);
}
});
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class OperationFailureTest method onFailure_shouldBeCalled_whenOperationExecutionFails.
@Test
public void onFailure_shouldBeCalled_whenOperationExecutionFails() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hz = factory.newHazelcastInstance();
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
FailingOperation op = new FailingOperation(new CountDownLatch(1));
nodeEngine.getOperationService().execute(op);
assertOpenEventually(op.latch);
assertInstanceOf(ExpectedRuntimeException.class, op.failure);
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class OperationFailureTest method onFailure_shouldBeCalled_whenBackupExecutionFails.
@Test
public void onFailure_shouldBeCalled_whenBackupExecutionFails() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hz = factory.newHazelcastInstance();
HazelcastInstance hz2 = factory.newHazelcastInstance();
warmUpPartitions(hz, hz2);
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
nodeEngine.getOperationService().invokeOnPartition(null, new EmptyBackupAwareOperation(), 0);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertNotNull(backupOperationFailure.get());
}
});
Throwable failure = backupOperationFailure.getAndSet(null);
assertInstanceOf(ExpectedRuntimeException.class, failure);
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class MapStoreWriteBehindTest method writeBehindQueueSize.
private int writeBehindQueueSize(HazelcastInstance node, String mapName) {
int size = 0;
final NodeEngineImpl nodeEngine = getNode(node).getNodeEngine();
MapService mapService = nodeEngine.getService(MapService.SERVICE_NAME);
final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
final int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
for (int i = 0; i < partitionCount; i++) {
final RecordStore recordStore = mapServiceContext.getExistingRecordStore(i, mapName);
if (recordStore == null) {
continue;
}
final MapDataStore mapDataStore = recordStore.getMapDataStore();
size += ((WriteBehindStore) mapDataStore).getWriteBehindQueue().size();
}
return size;
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class MapKeyValueSource method open.
@Override
public boolean open(NodeEngine nodeEngine) {
NodeEngineImpl nei = (NodeEngineImpl) nodeEngine;
IPartitionService ps = nei.getPartitionService();
MapService mapService = nei.getService(MapService.SERVICE_NAME);
ss = nei.getSerializationService();
Address partitionOwner = ps.getPartitionOwner(partitionId);
if (partitionOwner == null) {
return false;
}
RecordStore recordStore = mapService.getMapServiceContext().getRecordStore(partitionId, mapName);
iterator = recordStore.iterator();
return true;
}
Aggregations