Search in sources :

Example 81 with NodeEngine

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

the class CompletableFutureTest method setUp.

@Before
public void setUp() {
    NodeEngine nodeEngine = getNode(createHazelcastInstance()).getNodeEngine();
    executionService = nodeEngine.getExecutionService();
    startLogicLatch = new CountDownLatch(1);
    executedLogic = new CountDownLatch(1);
    inExecutionLatch = new CountDownLatch(1);
    reference1 = new AtomicReference<Object>();
    reference2 = new AtomicReference<Object>();
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) CountDownLatch(java.util.concurrent.CountDownLatch) Before(org.junit.Before)

Example 82 with NodeEngine

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

the class PartitionCorrectnessTestSupport method fillData.

void fillData(HazelcastInstance hz) {
    NodeEngine nodeEngine = getNode(hz).nodeEngine;
    OperationService operationService = nodeEngine.getOperationService();
    for (int i = 0; i < partitionCount; i++) {
        operationService.invokeOnPartition(null, new TestIncrementOperation(), i);
        for (String name : NAMESPACES) {
            operationService.invokeOnPartition(null, new TestFragmentIncrementOperation(name), i);
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) TestIncrementOperation(com.hazelcast.internal.partition.service.TestIncrementOperation) TestFragmentIncrementOperation(com.hazelcast.internal.partition.service.fragment.TestFragmentIncrementOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 83 with NodeEngine

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

the class AbstractGracefulShutdownCorrectnessTest method testPartitionData_whenNodesStartedShutdown_whileOperationsOngoing.

@Test(timeout = 6000 * 10 * 10)
public void testPartitionData_whenNodesStartedShutdown_whileOperationsOngoing() throws InterruptedException {
    final Config config = getConfig(true, false);
    Future future = spawn(() -> {
        LinkedList<HazelcastInstance> instances = new LinkedList<>(Arrays.asList(factory.newInstances(config, nodeCount)));
        try {
            for (int i = 0; i < 3; i++) {
                shutdownNodes(instances, shutdownNodeCount);
                Collection<HazelcastInstance> startedInstances = startNodes(config, shutdownNodeCount);
                instances.addAll(startedInstances);
            }
            shutdownNodes(instances, shutdownNodeCount);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    });
    HazelcastInstance hz = factory.newHazelcastInstance(config);
    NodeEngine nodeEngine = getNodeEngineImpl(hz);
    while (!nodeEngine.getClusterService().isJoined()) {
        TimeUnit.MILLISECONDS.sleep(100);
    }
    OperationService operationService = nodeEngine.getOperationService();
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    int value = 0;
    do {
        value++;
        for (int p = 0; p < partitionCount; p++) {
            operationService.invokeOnPartition(null, new TestPutOperation(value), p).join();
        }
    } while (!future.isDone());
    for (int p = 0; p < partitionCount; p++) {
        Integer actual = (Integer) operationService.invokeOnPartition(null, new TestGetOperation(), p).join();
        assertNotNull(actual);
        assertEquals(value, actual.intValue());
    }
}
Also used : TestPutOperation(com.hazelcast.internal.partition.service.TestPutOperation) TestGetOperation(com.hazelcast.internal.partition.service.TestGetOperation) Config(com.hazelcast.config.Config) LinkedList(java.util.LinkedList) NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Test(org.junit.Test)

Example 84 with NodeEngine

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

the class CacheClearExpiredOperation method isOwner.

private boolean isOwner() {
    final NodeEngine nodeEngine = getNodeEngine();
    final Address owner = nodeEngine.getPartitionService().getPartitionOwner(getPartitionId());
    return nodeEngine.getThisAddress().equals(owner);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Address(com.hazelcast.cluster.Address)

Example 85 with NodeEngine

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

the class CacheOperation method publishWanUpdate.

protected final void publishWanUpdate(Data dataKey, Data dataValue, CacheRecord record) {
    if (!recordStore.isWanReplicationEnabled() || record == null) {
        return;
    }
    NodeEngine nodeEngine = getNodeEngine();
    SerializationService serializationService = nodeEngine.getSerializationService();
    Data dataExpiryPolicy = toHeapData(serializationService.toData(record.getExpiryPolicy()));
    publishWanUpdate(dataKey, dataValue, dataExpiryPolicy, record);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) SerializationService(com.hazelcast.internal.serialization.SerializationService) ToHeapDataConverter.toHeapData(com.hazelcast.internal.util.ToHeapDataConverter.toHeapData) Data(com.hazelcast.internal.serialization.Data)

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