use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class InboundResponseHandlerSupplierTest method setup.
@Before
public void setup() {
ILogger logger = Logger.getLogger(getClass());
HazelcastProperties properties = new HazelcastProperties(new Properties());
invocationRegistry = new InvocationRegistry(logger, new CallIdSequenceWithoutBackpressure(), properties);
serializationService = new DefaultSerializationServiceBuilder().build();
nodeEngine = mock(NodeEngine.class);
when(nodeEngine.getLogger(any(Class.class))).thenReturn(logger);
when(nodeEngine.getSerializationService()).thenReturn(serializationService);
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class AbstractRecordFactoryTest method createMapContainer.
protected MapContainer createMapContainer(boolean perEntryStatsEnabled, EvictionPolicy evictionPolicy, CacheDeserializedValues cacheDeserializedValues) {
MapConfig mapConfig = newMapConfig(perEntryStatsEnabled, evictionPolicy, cacheDeserializedValues);
NodeEngine nodeEngine = mock(NodeEngine.class);
ClusterService clusterService = mock(ClusterService.class);
MapServiceContext mapServiceContext = mock(MapServiceContext.class);
when(mapServiceContext.getNodeEngine()).thenReturn(nodeEngine);
when(nodeEngine.getClusterService()).thenReturn(clusterService);
when(clusterService.getClusterVersion()).thenReturn(Versions.CURRENT_CLUSTER_VERSION);
MapContainer mapContainer = mock(MapContainer.class);
when(mapContainer.getMapConfig()).thenReturn(mapConfig);
when(mapContainer.getEvictor()).thenReturn(evictionPolicy == EvictionPolicy.NONE ? Evictor.NULL_EVICTOR : mock(Evictor.class));
when(mapContainer.getMapServiceContext()).thenReturn(mapServiceContext);
return mapContainer;
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class OperationServiceImpl_timeoutTest method testOperationTimeout.
private void testOperationTimeout(int memberCount, boolean async) {
assertTrue(memberCount > 0);
Config config = new Config();
config.setProperty(OPERATION_CALL_TIMEOUT_MILLIS.getName(), "3000");
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(memberCount);
HazelcastInstance[] instances = factory.newInstances(config);
warmUpPartitions(instances);
final HazelcastInstance hz = instances[memberCount - 1];
NodeEngine nodeEngine = getNodeEngineImpl(hz);
OperationService operationService = nodeEngine.getOperationService();
int partitionId = (int) (Math.random() * nodeEngine.getPartitionService().getPartitionCount());
InternalCompletableFuture<Object> future = operationService.invokeOnPartition(null, new TimedOutBackupAwareOperation(), partitionId);
final CountDownLatch latch = new CountDownLatch(1);
if (async) {
future.exceptionally((throwable) -> {
if (throwable instanceof OperationTimeoutException) {
latch.countDown();
}
return null;
});
} else {
try {
future.joinInternal();
fail("Should throw OperationTimeoutException!");
} catch (OperationTimeoutException ignored) {
latch.countDown();
}
}
assertOpenEventually("Should throw OperationTimeoutException", latch);
for (HazelcastInstance instance : instances) {
OperationServiceImpl_BasicTest.assertNoLitterInOpService(instance);
}
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class TransactionImplTest method setup.
@Before
public void setup() {
HazelcastInstance hz = createHazelcastInstance();
operationService = getOperationService(hz);
logger = mock(ILogger.class);
txManagerService = mock(TransactionManagerServiceImpl.class);
nodeEngine = mock(NodeEngine.class);
when(nodeEngine.getOperationService()).thenReturn(operationService);
when(nodeEngine.getLocalMember()).thenReturn(new MemberImpl());
when(nodeEngine.getLogger(TransactionImpl.class)).thenReturn(logger);
options = new TransactionOptions().setTransactionType(ONE_PHASE);
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class TransactionLogTest method rollback_partitionSpecificRecord.
@Test
public void rollback_partitionSpecificRecord() throws Exception {
OperationService operationService = mock(OperationService.class);
NodeEngine nodeEngine = mock(NodeEngine.class);
when(nodeEngine.getOperationService()).thenReturn(operationService);
TransactionLog log = new TransactionLog();
TransactionLogRecord partitionRecord = mock(TransactionLogRecord.class);
Operation partitionOperation = new DummyPartitionOperation();
when(partitionRecord.newRollbackOperation()).thenReturn(partitionOperation);
log.add(partitionRecord);
log.rollback(nodeEngine);
verify(operationService, times(1)).invokeOnPartition(partitionOperation.getServiceName(), partitionOperation, partitionOperation.getPartitionId());
}
Aggregations