Search in sources :

Example 16 with MetaDataGenerator

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

the class MapNearCacheStateHolder method prepare.

void prepare(PartitionContainer container, int replicaIndex) {
    MapService mapService = container.getMapService();
    MetaDataGenerator metaData = getPartitionMetaDataGenerator(mapService);
    int partitionId = container.getPartitionId();
    partitionUuid = metaData.getUuidOrNull(partitionId);
    ConcurrentMap<String, RecordStore> maps = container.getMaps();
    for (Map.Entry<String, RecordStore> entry : maps.entrySet()) {
        if (mapNameSequencePairs == emptyList()) {
            mapNameSequencePairs = new ArrayList(container.getMaps().size());
        }
        String mapName = entry.getKey();
        mapNameSequencePairs.add(mapName);
        mapNameSequencePairs.add(metaData.currentSequence(mapName, partitionId));
    }
}
Also used : RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) ArrayList(java.util.ArrayList) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map)

Example 17 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 18 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 19 with MetaDataGenerator

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

the class MemberMapMetaDataFetcherTest 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 20 with MetaDataGenerator

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

the class MemberMapMetaDataFetcherTest method distortRandomPartitionSequence.

private void distortRandomPartitionSequence(String mapName, int partition, long sequence, 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.setCurrentSequence(mapName, partition, sequence);
}
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)

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