Search in sources :

Example 16 with MapService

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

the class ClearExpiredOperation method afterRun.

@Override
public void afterRun() throws Exception {
    final MapService mapService = getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    final PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(getPartitionId());
    partitionContainer.setHasRunningCleanup(false);
    partitionContainer.setLastCleanupTime(Clock.currentTimeMillis());
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 17 with MapService

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

the class PostJoinMapOperation method run.

@Override
public void run() throws Exception {
    MapService mapService = getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    for (MapIndexInfo mapIndex : indexInfoList) {
        final MapContainer mapContainer = mapServiceContext.getMapContainer(mapIndex.mapName);
        final Indexes indexes = mapContainer.getIndexes();
        for (MapIndexInfo.IndexInfo indexInfo : mapIndex.lsIndexes) {
            indexes.addOrGetIndex(indexInfo.attributeName, indexInfo.ordered);
        }
    }
    for (InterceptorInfo interceptorInfo : interceptorInfoList) {
        final MapContainer mapContainer = mapServiceContext.getMapContainer(interceptorInfo.mapName);
        InterceptorRegistry interceptorRegistry = mapContainer.getInterceptorRegistry();
        Map<String, MapInterceptor> interceptorMap = interceptorRegistry.getId2InterceptorMap();
        List<Map.Entry<String, MapInterceptor>> entryList = interceptorInfo.interceptors;
        for (Map.Entry<String, MapInterceptor> entry : entryList) {
            if (!interceptorMap.containsKey(entry.getKey())) {
                interceptorRegistry.register(entry.getKey(), entry.getValue());
            }
        }
    }
    createQueryCaches();
}
Also used : MapInterceptor(com.hazelcast.map.MapInterceptor) Indexes(com.hazelcast.query.impl.Indexes) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer) InterceptorRegistry(com.hazelcast.map.impl.InterceptorRegistry) MapService(com.hazelcast.map.impl.MapService) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap)

Example 18 with MapService

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

the class MapKeyValueSource method open.

@Override
public boolean open(NodeEngine nodeEngine) {
    NodeEngineImpl nei = (NodeEngineImpl) nodeEngine;
    IPartitionService ps = nei.getPartitionService();
    MapService mapService = nei.getService(MapService.SERVICE_NAME);
    ss = nei.getSerializationService();
    Address partitionOwner = ps.getPartitionOwner(partitionId);
    if (partitionOwner == null) {
        return false;
    }
    RecordStore recordStore = mapService.getMapServiceContext().getRecordStore(partitionId, mapName);
    iterator = recordStore.iterator();
    return true;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Address(com.hazelcast.nio.Address) IPartitionService(com.hazelcast.spi.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapService(com.hazelcast.map.impl.MapService)

Example 19 with MapService

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

the class AbstractMapPartitionMessageTask method getMapOperationProvider.

protected final MapOperationProvider getMapOperationProvider(String mapName) {
    MapService mapService = getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    return mapServiceContext.getMapOperationProvider(mapName);
}
Also used : MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 20 with MapService

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

the class MapAddPartitionLostListenerMessageTask method call.

@Override
protected Object call() {
    final ClientEndpoint endpoint = getEndpoint();
    final MapService mapService = getService(MapService.SERVICE_NAME);
    final MapPartitionLostListener listener = new MapPartitionLostListener() {

        @Override
        public void partitionLost(MapPartitionLostEvent event) {
            if (endpoint.isAlive()) {
                ClientMessage eventMessage = MapAddPartitionLostListenerCodec.encodeMapPartitionLostEvent(event.getPartitionId(), event.getMember().getUuid());
                sendClientMessage(null, eventMessage);
            }
        }
    };
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    String registrationId;
    if (parameters.localOnly) {
        registrationId = mapServiceContext.addLocalPartitionLostListener(listener, parameters.name);
    } else {
        registrationId = mapServiceContext.addPartitionLostListener(listener, parameters.name);
    }
    endpoint.addListenerDestroyAction(MapService.SERVICE_NAME, parameters.name, registrationId);
    return registrationId;
}
Also used : MapPartitionLostListener(com.hazelcast.map.listener.MapPartitionLostListener) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientEndpoint(com.hazelcast.client.ClientEndpoint) MapService(com.hazelcast.map.impl.MapService) MapPartitionLostEvent(com.hazelcast.map.MapPartitionLostEvent) 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