Search in sources :

Example 11 with MapServiceContext

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

the class BasicMapStoreContext method create.

static MapStoreContext create(MapContainer mapContainer) {
    final BasicMapStoreContext context = new BasicMapStoreContext();
    final String mapName = mapContainer.getName();
    final MapServiceContext mapServiceContext = mapContainer.getMapServiceContext();
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final PartitioningStrategy partitioningStrategy = mapContainer.getPartitioningStrategy();
    final MapConfig mapConfig = mapContainer.getMapConfig();
    final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
    final ClassLoader configClassLoader = nodeEngine.getConfigClassLoader();
    // create store.
    final Object store = createStore(mapName, mapStoreConfig, configClassLoader);
    final MapStoreWrapper storeWrapper = new MapStoreWrapper(mapName, store);
    storeWrapper.instrument(nodeEngine);
    setStoreImplToWritableMapStoreConfig(nodeEngine, mapName, store);
    context.setMapName(mapName);
    context.setMapStoreConfig(mapStoreConfig);
    context.setPartitioningStrategy(partitioningStrategy);
    context.setMapServiceContext(mapServiceContext);
    context.setStoreWrapper(storeWrapper);
    final MapStoreManager mapStoreManager = createMapStoreManager(context);
    context.setMapStoreManager(mapStoreManager);
    // todo this is user code. it may also block map store creation.
    callLifecycleSupportInit(context);
    return context;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MapStoreWrapper(com.hazelcast.map.impl.MapStoreWrapper) PartitioningStrategy(com.hazelcast.core.PartitioningStrategy) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 12 with MapServiceContext

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

the class MapDataStores method createWriteBehindStore.

/**
     * Creates a write behind data store.
     *
     * @param mapStoreContext      context for map store operations.
     * @param partitionId          partition id of partition.
     * @param writeBehindProcessor the {@link WriteBehindProcessor}
     * @param <K>                  type of key to store.
     * @param <V>                  type of value to store.
     * @return new write behind store manager.
     */
public static <K, V> MapDataStore<K, V> createWriteBehindStore(MapStoreContext mapStoreContext, int partitionId, WriteBehindProcessor writeBehindProcessor) {
    MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext();
    MapStoreConfig mapStoreConfig = mapStoreContext.getMapStoreConfig();
    WriteBehindStore mapDataStore = new WriteBehindStore(mapStoreContext, partitionId);
    mapDataStore.setWriteBehindQueue(newWriteBehindQueue(mapServiceContext, mapStoreConfig.isWriteCoalescing()));
    mapDataStore.setWriteBehindProcessor(writeBehindProcessor);
    return (MapDataStore<K, V>) mapDataStore;
}
Also used : MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)

Example 13 with MapServiceContext

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

the class MapDataStores method createWriteThroughStore.

/**
     * Creates a write through data store.
     *
     * @param mapStoreContext context for map store operations.
     * @param <K>             type of key to store.
     * @param <V>             type of value to store.
     * @return new write through store manager.
     */
public static <K, V> MapDataStore<K, V> createWriteThroughStore(MapStoreContext mapStoreContext) {
    final MapStoreWrapper store = mapStoreContext.getMapStoreWrapper();
    final MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext();
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final SerializationService serializationService = nodeEngine.getSerializationService();
    return (MapDataStore<K, V>) new WriteThroughStore(store, serializationService);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MapStoreWrapper(com.hazelcast.map.impl.MapStoreWrapper) WriteThroughStore(com.hazelcast.map.impl.mapstore.writethrough.WriteThroughStore) SerializationService(com.hazelcast.spi.serialization.SerializationService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 14 with MapServiceContext

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

the class MapNearCacheStateHolder method getPartitionMetaDataGenerator.

private MetaDataGenerator getPartitionMetaDataGenerator(MapService mapService) {
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
    Invalidator invalidator = mapNearCacheManager.getInvalidator();
    return invalidator.getMetaDataGenerator();
}
Also used : MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) Invalidator(com.hazelcast.internal.nearcache.impl.invalidation.Invalidator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 15 with MapServiceContext

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

Aggregations

MapServiceContext (com.hazelcast.map.impl.MapServiceContext)63 MapService (com.hazelcast.map.impl.MapService)44 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)15 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)14 Invalidator (com.hazelcast.internal.nearcache.impl.invalidation.Invalidator)12 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)12 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)10 NodeEngine (com.hazelcast.spi.NodeEngine)10 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 MapContainer (com.hazelcast.map.impl.MapContainer)6 Data (com.hazelcast.nio.serialization.Data)6 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)5 MapStoreConfig (com.hazelcast.config.MapStoreConfig)4 SimpleEntryView (com.hazelcast.map.impl.SimpleEntryView)4 HashMap (java.util.HashMap)4 Config (com.hazelcast.config.Config)3 MapConfig (com.hazelcast.config.MapConfig)3 NearCacheConfig (com.hazelcast.config.NearCacheConfig)3 Node (com.hazelcast.instance.Node)3