Search in sources :

Example 11 with MetaDataGenerator

use of com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator 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 12 with MetaDataGenerator

use of com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator 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 13 with MetaDataGenerator

use of com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator in project hazelcast by hazelcast.

the class CacheGetInvalidationMetaDataOperation method getNamePartitionSequenceList.

private Map<String, List<Map.Entry<Integer, Long>>> getNamePartitionSequenceList(List<Integer> ownedPartitionIds) {
    MetaDataGenerator metaDataGenerator = getPartitionMetaDataGenerator();
    Map<String, List<Map.Entry<Integer, Long>>> sequences = new HashMap<String, List<Map.Entry<Integer, Long>>>(ownedPartitionIds.size());
    for (String name : names) {
        List<Map.Entry<Integer, Long>> mapSequences = new ArrayList<Map.Entry<Integer, Long>>();
        for (Integer partitionId : ownedPartitionIds) {
            long partitionSequence = metaDataGenerator.currentSequence(name, partitionId);
            if (partitionSequence != 0) {
                mapSequences.add(new AbstractMap.SimpleEntry<Integer, Long>(partitionId, partitionSequence));
            }
        }
        sequences.put(name, mapSequences);
    }
    return sequences;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AbstractMap(java.util.AbstractMap) ArrayList(java.util.ArrayList) List(java.util.List) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) HashMap(java.util.HashMap) AbstractMap(java.util.AbstractMap) Map(java.util.Map)

Example 14 with MetaDataGenerator

use of com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator in project hazelcast by hazelcast.

the class CacheGetInvalidationMetaDataOperation method getPartitionUuidList.

private Map<Integer, UUID> getPartitionUuidList(List<Integer> ownedPartitionIds) {
    MetaDataGenerator metaDataGenerator = getPartitionMetaDataGenerator();
    Map<Integer, UUID> partitionUuids = new HashMap<Integer, UUID>(ownedPartitionIds.size());
    for (Integer partitionId : ownedPartitionIds) {
        UUID uuid = metaDataGenerator.getUuidOrNull(partitionId);
        if (uuid != null) {
            partitionUuids.put(partitionId, uuid);
        }
    }
    return partitionUuids;
}
Also used : HashMap(java.util.HashMap) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) UUID(java.util.UUID)

Example 15 with MetaDataGenerator

use of com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator in project hazelcast by hazelcast.

the class MapGetInvalidationMetaDataOperation method getPartitionUuidList.

private Map<Integer, UUID> getPartitionUuidList(List<Integer> ownedPartitionIds) {
    MetaDataGenerator metaDataGenerator = getPartitionMetaDataGenerator();
    Map<Integer, UUID> partitionUuids = new HashMap<Integer, UUID>(ownedPartitionIds.size());
    for (Integer partitionId : ownedPartitionIds) {
        UUID uuid = metaDataGenerator.getUuidOrNull(partitionId);
        if (uuid != null) {
            partitionUuids.put(partitionId, uuid);
        }
    }
    return partitionUuids;
}
Also used : HashMap(java.util.HashMap) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) UUID(java.util.UUID)

Aggregations

MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)23 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)14 MapService (com.hazelcast.map.impl.MapService)12 Invalidator (com.hazelcast.internal.nearcache.impl.invalidation.Invalidator)10 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)10 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)10 HashMap (java.util.HashMap)6 CacheEventHandler (com.hazelcast.cache.impl.CacheEventHandler)5 CacheService (com.hazelcast.cache.impl.CacheService)5 ArrayList (java.util.ArrayList)5 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)4 UUID (java.util.UUID)4 Map (java.util.Map)3 ICacheService (com.hazelcast.cache.impl.ICacheService)2 AbstractMap (java.util.AbstractMap)2 List (java.util.List)2 AbstractCacheService (com.hazelcast.cache.impl.AbstractCacheService)1 CacheProxy (com.hazelcast.cache.impl.CacheProxy)1 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)1 ICacheRecordStore (com.hazelcast.cache.impl.ICacheRecordStore)1