Search in sources :

Example 76 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class DistributedExecutorServiceTest method setup.

@Before
public void setup() {
    Config config = new Config();
    config.addExecutorConfig(new ExecutorConfig().setName(EXECUTOR_NAME).setStatisticsEnabled(false));
    hz = createHazelcastInstance(config);
    NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
    distributedExecutorService = nodeEngine.getService(DistributedExecutorService.SERVICE_NAME);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Config(com.hazelcast.config.Config) ExecutorConfig(com.hazelcast.config.ExecutorConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) Before(org.junit.Before)

Example 77 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class ClientListenersTest method testEntryMergeListener_withPortableNotRegisteredInNode.

@Test
public void testEntryMergeListener_withPortableNotRegisteredInNode() throws Exception {
    final IMap<Object, Object> map = client.getMap(randomMapName());
    final CountDownLatch latch = new CountDownLatch(1);
    map.addEntryListener(new EntryMergedListener<Object, Object>() {

        @Override
        public void entryMerged(EntryEvent<Object, Object> event) {
            latch.countDown();
        }
    }, true);
    Node node = getNode(server);
    NodeEngineImpl nodeEngine = node.nodeEngine;
    OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();
    SerializationService serializationService = getSerializationService(server);
    Data key = serializationService.toData(1);
    Data value = serializationService.toData(new ClientRegressionWithMockNetworkTest.SamplePortable(1));
    EntryView entryView = EntryViews.createSimpleEntryView(key, value, Mockito.mock(Record.class));
    MergeOperation op = new MergeOperation(map.getName(), key, entryView, new PassThroughMergePolicy());
    int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
    operationService.invokeOnPartition(MapService.SERVICE_NAME, op, partitionId);
    assertOpenEventually(latch);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MergeOperation(com.hazelcast.map.impl.operation.MergeOperation) PassThroughMergePolicy(com.hazelcast.map.merge.PassThroughMergePolicy) Node(com.hazelcast.instance.Node) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) CountDownLatch(java.util.concurrent.CountDownLatch) EntryView(com.hazelcast.core.EntryView) Record(com.hazelcast.map.impl.record.Record) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 78 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class LockAdvancedTest method testLockCleanup_whenInvokingMemberDies.

@Test
public void testLockCleanup_whenInvokingMemberDies() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance hz = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();
    NodeEngineImpl nodeEngine = getNodeEngineImpl(hz2);
    InternalOperationService operationService = getOperationService(hz2);
    warmUpPartitions(hz2);
    String name = randomNameOwnedBy(hz);
    Data key = nodeEngine.toData(name);
    int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
    operationService.invokeOnPartition(LockService.SERVICE_NAME, new SlowLockOperation(name, key, 2000), partitionId);
    sleepMillis(500);
    terminateInstance(hz2);
    final ILock lock = hz.getLock(name);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertFalse("Lock owned by dead member should have been released!", lock.isLocked());
        }
    }, 30);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) HeapData(com.hazelcast.internal.serialization.impl.HeapData) Data(com.hazelcast.nio.serialization.Data) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) ILock(com.hazelcast.core.ILock) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) IOException(java.io.IOException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 79 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class BaseMigrationOperation method executeBeforeMigrations.

void executeBeforeMigrations() throws Exception {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    PartitionMigrationEvent event = getMigrationEvent();
    Throwable t = null;
    for (MigrationAwareService service : nodeEngine.getServices(MigrationAwareService.class)) {
        // we need to make sure all beforeMigration() methods are executed
        try {
            service.beforeMigration(event);
        } catch (Throwable e) {
            getLogger().warning("Error while executing beforeMigration()", e);
            t = e;
        }
    }
    if (t != null) {
        throw ExceptionUtil.rethrow(t);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) PartitionMigrationEvent(com.hazelcast.spi.PartitionMigrationEvent) MigrationAwareService(com.hazelcast.spi.MigrationAwareService)

Example 80 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class ReplicaSyncRequest method logNoReplicaDataFound.

private void logNoReplicaDataFound(int partitionId, int replicaIndex) {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    ILogger logger = nodeEngine.getLogger(getClass());
    if (logger.isFinestEnabled()) {
        logger.finest("No replica data is found for partitionId=" + partitionId + ", replicaIndex=" + replicaIndex);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ILogger(com.hazelcast.logging.ILogger)

Aggregations

NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)112 HazelcastInstance (com.hazelcast.core.HazelcastInstance)39 Test (org.junit.Test)32 ParallelTest (com.hazelcast.test.annotation.ParallelTest)31 QuickTest (com.hazelcast.test.annotation.QuickTest)31 Node (com.hazelcast.instance.Node)21 MapService (com.hazelcast.map.impl.MapService)20 Config (com.hazelcast.config.Config)19 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)19 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)16 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)14 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)14 ILogger (com.hazelcast.logging.ILogger)11 AssertTask (com.hazelcast.test.AssertTask)11 Invalidator (com.hazelcast.internal.nearcache.impl.invalidation.Invalidator)10 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)10 Address (com.hazelcast.nio.Address)10 Data (com.hazelcast.nio.serialization.Data)10 Before (org.junit.Before)10 Operation (com.hazelcast.spi.Operation)9