Search in sources :

Example 66 with NodeEngineImpl

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

the class InternalCacheRecordStoreTest method ownerStateShouldBeUpdatedAfterMigration.

/**
     * Test for issue: https://github.com/hazelcast/hazelcast/issues/6983
     */
@Test
public void ownerStateShouldBeUpdatedAfterMigration() throws Exception {
    HazelcastCacheManager hzCacheManager = (HazelcastCacheManager) cacheManager;
    HazelcastInstance instance1 = hzCacheManager.getHazelcastInstance();
    Node node1 = TestUtil.getNode(instance1);
    NodeEngineImpl nodeEngine1 = node1.getNodeEngine();
    InternalPartitionService partitionService1 = nodeEngine1.getPartitionService();
    int partitionCount = partitionService1.getPartitionCount();
    String cacheName = randomName();
    CacheConfig cacheConfig = new CacheConfig().setName(cacheName);
    Cache<String, String> cache = cacheManager.createCache(cacheName, cacheConfig);
    String fullCacheName = hzCacheManager.getCacheNameWithPrefix(cacheName);
    for (int i = 0; i < partitionCount; i++) {
        String key = generateKeyForPartition(instance1, i);
        cache.put(key, "Value");
    }
    for (int i = 0; i < partitionCount; i++) {
        verifyPrimaryState(node1, fullCacheName, i, true);
    }
    HazelcastInstance instance2 = getHazelcastInstance();
    Node node2 = TestUtil.getNode(instance2);
    warmUpPartitions(instance1, instance2);
    waitAllForSafeState(instance1, instance2);
    for (int i = 0; i < partitionCount; i++) {
        boolean ownedByNode1 = partitionService1.isPartitionOwner(i);
        if (ownedByNode1) {
            verifyPrimaryState(node1, fullCacheName, i, true);
            verifyPrimaryState(node2, fullCacheName, i, false);
        } else {
            verifyPrimaryState(node1, fullCacheName, i, false);
            verifyPrimaryState(node2, fullCacheName, i, true);
        }
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) HazelcastCacheManager(com.hazelcast.cache.HazelcastCacheManager) HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Node(com.hazelcast.instance.Node) CacheConfig(com.hazelcast.config.CacheConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest) CacheFromDifferentNodesTest(com.hazelcast.cache.CacheFromDifferentNodesTest)

Example 67 with NodeEngineImpl

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

the class AdvancedClusterStateTest method spyTransactionManagerService.

private static TransactionManagerServiceImpl spyTransactionManagerService(HazelcastInstance hz) throws Exception {
    NodeEngineImpl nodeEngine = getNode(hz).nodeEngine;
    TransactionManagerServiceImpl transactionManagerService = (TransactionManagerServiceImpl) nodeEngine.getTransactionManagerService();
    TransactionManagerServiceImpl spiedTransactionManagerService = spy(transactionManagerService);
    Field transactionManagerServiceField = NodeEngineImpl.class.getDeclaredField("transactionManagerService");
    transactionManagerServiceField.setAccessible(true);
    transactionManagerServiceField.set(nodeEngine, spiedTransactionManagerService);
    return spiedTransactionManagerService;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Field(java.lang.reflect.Field) TransactionManagerServiceImpl(com.hazelcast.transaction.impl.TransactionManagerServiceImpl)

Example 68 with NodeEngineImpl

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

the class DiagnosticsLogTest method getDiagnostics.

public Diagnostics getDiagnostics(HazelcastInstance hazelcastInstance) {
    Node node = getNode(hazelcastInstance);
    NodeEngineImpl nodeEngine = node.nodeEngine;
    try {
        Field field = NodeEngineImpl.class.getDeclaredField("diagnostics");
        field.setAccessible(true);
        return (Diagnostics) field.get(nodeEngine);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Field(java.lang.reflect.Field) Node(com.hazelcast.instance.Node) IOException(java.io.IOException)

Example 69 with NodeEngineImpl

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

the class ClientMapMetaDataFetcherTest method distortRandomPartitionUuid.

private void distortRandomPartitionUuid(int partition, UUID uuid, HazelcastInstance member) {
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(member);
    MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
    Invalidator invalidator = mapNearCacheManager.getInvalidator();
    MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
    metaDataGenerator.setUuid(partition, uuid);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) Invalidator(com.hazelcast.internal.nearcache.impl.invalidation.Invalidator) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 70 with NodeEngineImpl

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

the class InvalidationMetadataDistortionTest method distortRandomPartitionSequence.

private void distortRandomPartitionSequence(String mapName, HazelcastInstance member) {
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(member);
    MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
    Invalidator invalidator = mapNearCacheManager.getInvalidator();
    MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
    InternalPartitionService partitionService = nodeEngineImpl.getPartitionService();
    int partitionCount = partitionService.getPartitionCount();
    metaDataGenerator.setCurrentSequence(mapName, getInt(partitionCount), getInt(MAX_VALUE));
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) Invalidator(com.hazelcast.internal.nearcache.impl.invalidation.Invalidator) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

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