Search in sources :

Example 76 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class MapReplicationStateHolder method prepare.

void prepare(PartitionContainer container, int replicaIndex) {
    data = new HashMap<String, Set<RecordReplicationInfo>>(container.getMaps().size());
    loaded = new HashMap<String, Boolean>(container.getMaps().size());
    for (Map.Entry<String, RecordStore> entry : container.getMaps().entrySet()) {
        RecordStore recordStore = entry.getValue();
        MapContainer mapContainer = recordStore.getMapContainer();
        MapConfig mapConfig = mapContainer.getMapConfig();
        if (mapConfig.getTotalBackupCount() < replicaIndex) {
            continue;
        }
        MapServiceContext mapServiceContext = mapContainer.getMapServiceContext();
        String mapName = entry.getKey();
        loaded.put(mapName, recordStore.isLoaded());
        // now prepare data to migrate records
        Set<RecordReplicationInfo> recordSet = new HashSet<RecordReplicationInfo>(recordStore.size());
        final Iterator<Record> iterator = recordStore.iterator();
        while (iterator.hasNext()) {
            Record record = iterator.next();
            Data key = record.getKey();
            RecordReplicationInfo recordReplicationInfo = mapReplicationOperation.createRecordReplicationInfo(key, record, mapServiceContext);
            recordSet.add(recordReplicationInfo);
        }
        data.put(mapName, recordSet);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Data(com.hazelcast.nio.serialization.Data) MapContainer(com.hazelcast.map.impl.MapContainer) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) RecordReplicationInfo(com.hazelcast.map.impl.record.RecordReplicationInfo) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) Record(com.hazelcast.map.impl.record.Record) MapConfig(com.hazelcast.config.MapConfig) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 77 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class ClearExpiredOperation method run.

@Override
public void run() throws Exception {
    final MapService mapService = getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    final PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(getPartitionId());
    final ConcurrentMap<String, RecordStore> recordStores = partitionContainer.getMaps();
    final boolean backup = !isOwner();
    for (final RecordStore recordStore : recordStores.values()) {
        if (recordStore.size() > 0 && recordStore.isExpirable()) {
            recordStore.evictExpiredEntries(expirationPercentage, backup);
            recordStore.disposeDeferredBlocks();
        }
    }
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 78 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext 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 79 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext in project hazelcast by hazelcast.

the class MemberMapMetaDataFetcherTest method getRepairingTask.

private RepairingTask getRepairingTask(String mapName, int partition, long givenSequence, UUID givenUuid) {
    Config config = new Config();
    config.getMapConfig(mapName).setNearCacheConfig(new NearCacheConfig());
    HazelcastInstance member = factory.newHazelcastInstance(config);
    MapService mapService = getNodeEngineImpl(member).getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    distortRandomPartitionSequence(mapName, partition, givenSequence, member);
    distortRandomPartitionUuid(partition, givenUuid, member);
    member.getMap(mapName);
    return mapServiceContext.getMapNearCacheManager().getRepairingTask();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 80 with MapServiceContext

use of com.hazelcast.map.impl.MapServiceContext 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

MapServiceContext (com.hazelcast.map.impl.MapServiceContext)137 MapService (com.hazelcast.map.impl.MapService)111 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)34 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)29 Invalidator (com.hazelcast.internal.nearcache.impl.invalidation.Invalidator)25 MapContainer (com.hazelcast.map.impl.MapContainer)22 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)22 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)20 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)16 HazelcastInstance (com.hazelcast.core.HazelcastInstance)15 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)15 NodeEngine (com.hazelcast.spi.impl.NodeEngine)14 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)13 Node (com.hazelcast.instance.impl.Node)12 Data (com.hazelcast.internal.serialization.Data)11 Accessors.getNode (com.hazelcast.test.Accessors.getNode)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)9 Config (com.hazelcast.config.Config)8 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)8