Search in sources :

Example 46 with MapService

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

the class MapClearMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    int clearedTotal = 0;
    for (Object affectedEntries : map.values()) {
        clearedTotal += (Integer) affectedEntries;
    }
    MapService service = getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = service.getMapServiceContext();
    if (clearedTotal > 0) {
        Address thisAddress = nodeEngine.getThisAddress();
        MapEventPublisher mapEventPublisher = mapServiceContext.getMapEventPublisher();
        mapEventPublisher.publishMapEvent(thisAddress, parameters.name, CLEAR_ALL, clearedTotal);
    }
    return null;
}
Also used : Address(com.hazelcast.nio.Address) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapEventPublisher(com.hazelcast.map.impl.event.MapEventPublisher)

Example 47 with MapService

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

the class MapExecuteOnAllKeysMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    List<Map.Entry<Data, Data>> dataMap = new ArrayList<Map.Entry<Data, Data>>();
    MapService mapService = getService(MapService.SERVICE_NAME);
    for (Object o : map.values()) {
        if (o != null) {
            MapEntries entries = (MapEntries) mapService.getMapServiceContext().toObject(o);
            entries.putAllToList(dataMap);
        }
    }
    return dataMap;
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data) MapService(com.hazelcast.map.impl.MapService) Map(java.util.Map)

Example 48 with MapService

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

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

Example 50 with MapService

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

the class InvalidationMetadataDistortionTest method distortRandomPartitionUuid.

private void distortRandomPartitionUuid(HazelcastInstance member) {
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(member);
    int partitionCount = nodeEngineImpl.getPartitionService().getPartitionCount();
    int partitionId = getInt(partitionCount);
    MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
    Invalidator invalidator = mapNearCacheManager.getInvalidator();
    MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
    metaDataGenerator.setUuid(partitionId, UuidUtil.newSecureUUID());
}
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

MapService (com.hazelcast.map.impl.MapService)80 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)44 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)20 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)13 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)12 Invalidator (com.hazelcast.internal.nearcache.impl.invalidation.Invalidator)11 MapContainer (com.hazelcast.map.impl.MapContainer)10 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)10 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 Test (org.junit.Test)9 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)8 Config (com.hazelcast.config.Config)7 Before (org.junit.Before)7 Data (com.hazelcast.nio.serialization.Data)6 Map (java.util.Map)6 Address (com.hazelcast.nio.Address)5 IPartitionLostEvent (com.hazelcast.spi.partition.IPartitionLostEvent)5 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)4