Search in sources :

Example 66 with NodeEngine

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);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) CallIdSequenceWithoutBackpressure(com.hazelcast.spi.impl.sequence.CallIdSequenceWithoutBackpressure) ILogger(com.hazelcast.logging.ILogger) Properties(java.util.Properties) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Before(org.junit.Before)

Example 67 with NodeEngine

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;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) ClusterService(com.hazelcast.internal.cluster.ClusterService) MapConfig(com.hazelcast.config.MapConfig) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 68 with NodeEngine

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);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) OperationTimeoutException(com.hazelcast.core.OperationTimeoutException) Config(com.hazelcast.config.Config) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) CountDownLatch(java.util.concurrent.CountDownLatch) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory)

Example 69 with NodeEngine

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);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) TransactionOptions(com.hazelcast.transaction.TransactionOptions) ILogger(com.hazelcast.logging.ILogger) Before(org.junit.Before)

Example 70 with NodeEngine

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());
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

NodeEngine (com.hazelcast.spi.impl.NodeEngine)165 Data (com.hazelcast.internal.serialization.Data)48 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)30 Address (com.hazelcast.cluster.Address)22 Test (org.junit.Test)21 ILogger (com.hazelcast.logging.ILogger)20 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)18 QuickTest (com.hazelcast.test.annotation.QuickTest)18 Config (com.hazelcast.config.Config)17 Operation (com.hazelcast.spi.impl.operationservice.Operation)16 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)15 IPartitionService (com.hazelcast.internal.partition.IPartitionService)12 Nonnull (javax.annotation.Nonnull)12 ArrayList (java.util.ArrayList)11 Future (java.util.concurrent.Future)11 Member (com.hazelcast.cluster.Member)10 UUID (java.util.UUID)10 InitializingObject (com.hazelcast.spi.impl.InitializingObject)9 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9