Search in sources :

Example 96 with NodeEngineImpl

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

the class MapInvalidationMetaDataMigrationTest method getPartitionToSequenceMap.

private Map<Integer, Long> getPartitionToSequenceMap(String mapName, HazelcastInstance instance) {
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(instance);
    int partitionCount = nodeEngineImpl.getPartitionService().getPartitionCount();
    HashMap<Integer, Long> partitionToSequenceMap = new HashMap<Integer, Long>(partitionCount);
    MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
    Invalidator invalidator = mapNearCacheManager.getInvalidator();
    MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
    for (int i = 0; i < partitionCount; i++) {
        partitionToSequenceMap.put(i, metaDataGenerator.currentSequence(mapName, i));
    }
    return partitionToSequenceMap;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) Invalidator(com.hazelcast.internal.nearcache.impl.invalidation.Invalidator) HashMap(java.util.HashMap) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 97 with NodeEngineImpl

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

the class MapInvalidationMetaDataMigrationTest method getPartitionToUuidMap.

private Map<Integer, UUID> getPartitionToUuidMap(HazelcastInstance instance) {
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(instance);
    int partitionCount = nodeEngineImpl.getPartitionService().getPartitionCount();
    HashMap<Integer, UUID> partitionToSequenceMap = new HashMap<Integer, UUID>(partitionCount);
    MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
    Invalidator invalidator = mapNearCacheManager.getInvalidator();
    MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
    for (int i = 0; i < partitionCount; i++) {
        partitionToSequenceMap.put(i, metaDataGenerator.getUuidOrNull(i));
    }
    return partitionToSequenceMap;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) Invalidator(com.hazelcast.internal.nearcache.impl.invalidation.Invalidator) HashMap(java.util.HashMap) UUID(java.util.UUID) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 98 with NodeEngineImpl

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

the class ReplicatedMapReorderedReplicationTest method testNonConvergingReplicatedMaps.

@Test
public void testNonConvergingReplicatedMaps() throws Exception {
    final int nodeCount = 4;
    final int keyCount = 10000;
    final int threadCount = 2;
    updateFactory();
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    final Config config = new Config();
    final HazelcastInstance[] instances = factory.newInstances(config, nodeCount);
    warmUpPartitions(instances);
    final int partitionId = randomPartitionOwnedBy(instances[0]).getPartitionId();
    final String mapName = randomMapName();
    final NodeEngineImpl nodeEngine = getNodeEngineImpl(instances[0]);
    final Thread[] threads = new Thread[threadCount];
    for (int i = 0; i < threadCount; i++) {
        final int startIndex = i;
        threads[i] = new Thread(new Runnable() {

            @Override
            public void run() {
                for (int j = startIndex; j < keyCount; j += threadCount) {
                    put(nodeEngine, mapName, partitionId, j, j);
                }
            }
        });
    }
    for (Thread thread : threads) {
        thread.start();
    }
    for (Thread thread : threads) {
        thread.join();
    }
    final ReplicatedRecordStore[] stores = new ReplicatedRecordStore[nodeCount];
    for (int i = 0; i < nodeCount; i++) {
        ReplicatedMapService service = getNodeEngineImpl(instances[i]).getService(ReplicatedMapService.SERVICE_NAME);
        service.triggerAntiEntropy();
        stores[i] = service.getReplicatedRecordStore(mapName, false, partitionId);
    }
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            long version = stores[0].getVersion();
            for (ReplicatedRecordStore store : stores) {
                assertEquals(version, store.getVersion());
                assertFalse(store.isStale(version));
            }
        }
    });
    for (int i = 0; i < keyCount; i++) {
        for (ReplicatedRecordStore store : stores) {
            assertTrue(store.containsKey(i));
        }
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Config(com.hazelcast.config.Config) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 99 with NodeEngineImpl

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

the class AbstractBaseReplicatedRecordStoreTest method setUp.

@Before
public void setUp() {
    HazelcastInstance instance = createHazelcastInstance();
    NodeEngineImpl nodeEngine = getNodeEngineImpl(instance);
    ReplicatedMapService service = new ReplicatedMapService(nodeEngine);
    recordStore = new TestReplicatedRecordStore("recordStore", service, 0);
    recordStoreSameAttributes = new TestReplicatedRecordStore("recordStore", service, 0);
    recordStoreSameAttributes.storageRef.set(recordStore.storageRef.get());
    recordStoreOtherStorage = new TestReplicatedRecordStore("recordStore", service, 0);
    recordStoreOtherName = new TestReplicatedRecordStore("otherRecordStore", service, 0);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) Before(org.junit.Before)

Example 100 with NodeEngineImpl

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

the class MockConnection method close.

public void close(String msg, Throwable cause) {
    if (!alive.compareAndSet(true, false)) {
        return;
    }
    if (localConnection != null) {
        //this is a member-to-member connection
        NodeEngineImpl localNodeEngine = localConnection.nodeEngine;
        Node localNode = localNodeEngine.getNode();
        MockConnectionManager connectionManager = (MockConnectionManager) localNode.connectionManager;
        connectionManager.onClose(this);
    } else {
        //this is a client-member connection. we need to notify NodeEngine about a client connection being closed.
        MockConnectionManager connectionManager = (MockConnectionManager) nodeEngine.getNode().connectionManager;
        connectionManager.onClose(this);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Node(com.hazelcast.instance.Node)

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