Search in sources :

Example 46 with MapServiceContext

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

the class QueryCacheRecoveryUponEventLossTest method getBrokenSequences.

private Map getBrokenSequences(HazelcastInstance instance, String mapName, QueryCache queryCache) {
    Node node = getNode(instance);
    MapService service = node.getNodeEngine().getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = service.getMapServiceContext();
    QueryCacheContext context = mapServiceContext.getQueryCacheContext();
    SubscriberContext subscriberContext = context.getSubscriberContext();
    MapSubscriberRegistry mapSubscriberRegistry = subscriberContext.getMapSubscriberRegistry();
    SubscriberRegistry subscriberRegistry = mapSubscriberRegistry.getOrNull(mapName);
    if (subscriberRegistry == null) {
        return Collections.emptyMap();
    }
    String cacheId = ((InternalQueryCache) queryCache).getCacheId();
    Accumulator accumulator = subscriberRegistry.getOrNull(cacheId);
    if (accumulator == null) {
        return Collections.emptyMap();
    }
    SubscriberAccumulator subscriberAccumulator = (SubscriberAccumulator) accumulator;
    return subscriberAccumulator.getBrokenSequences();
}
Also used : Accumulator(com.hazelcast.map.impl.querycache.accumulator.Accumulator) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 47 with MapServiceContext

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

the class AbstractRecordFactoryTest method createMapContainer.

protected MapContainer createMapContainer(boolean perEntryStatsEnabled, EvictionPolicy evictionPolicy, CacheDeserializedValues cacheDeserializedValues) {
    MapConfig mapConfig = newMapConfig(perEntryStatsEnabled, evictionPolicy, cacheDeserializedValues);
    NodeEngine nodeEngine = mock(NodeEngine.class);
    ClusterService clusterService = mock(ClusterService.class);
    MapServiceContext mapServiceContext = mock(MapServiceContext.class);
    when(mapServiceContext.getNodeEngine()).thenReturn(nodeEngine);
    when(nodeEngine.getClusterService()).thenReturn(clusterService);
    when(clusterService.getClusterVersion()).thenReturn(Versions.CURRENT_CLUSTER_VERSION);
    MapContainer mapContainer = mock(MapContainer.class);
    when(mapContainer.getMapConfig()).thenReturn(mapConfig);
    when(mapContainer.getEvictor()).thenReturn(evictionPolicy == EvictionPolicy.NONE ? Evictor.NULL_EVICTOR : mock(Evictor.class));
    when(mapContainer.getMapServiceContext()).thenReturn(mapServiceContext);
    return mapContainer;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) ClusterService(com.hazelcast.internal.cluster.ClusterService) MapConfig(com.hazelcast.config.MapConfig) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 48 with MapServiceContext

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

the class NodeQueryCacheEventServiceTest method getSubscriberContext.

private static SubscriberContext getSubscriberContext(HazelcastInstance node) {
    MapService mapService = getNodeEngineImpl(node).getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
    return queryCacheContext.getSubscriberContext();
}
Also used : QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 49 with MapServiceContext

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

the class QueryCacheEventLostListenerTest method setTestSequencer.

private void setTestSequencer(HazelcastInstance instance, int eventCount) {
    Node node = getNode(instance);
    MapService service = node.getNodeEngine().getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = service.getMapServiceContext();
    QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
    queryCacheContext.setSubscriberContext(new TestSubscriberContext(queryCacheContext, eventCount, true));
}
Also used : TestSubscriberContext(com.hazelcast.map.impl.querycache.subscriber.TestSubscriberContext) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 50 with MapServiceContext

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

the class TransactionsWithWriteBehind_whenNoCoalescingQueueIsFullTest method getTotalNumOfTxnReservedCapacity.

private static long getTotalNumOfTxnReservedCapacity(String mapName, HazelcastInstance node) {
    long reservedCapacity = 0;
    MapServiceContext mapServiceContext = ((MapService) ((MapProxyImpl) node.getMap(mapName)).getService()).getMapServiceContext();
    PartitionContainer[] partitionContainers = mapServiceContext.getPartitionContainers();
    for (PartitionContainer partitionContainer : partitionContainers) {
        RecordStore recordStore = partitionContainer.getExistingRecordStore(mapName);
        if (recordStore != null) {
            reservedCapacity += recordStore.getMapDataStore().getTxnReservedCapacityCounter().getReservedCapacityCountPerTxnId().size();
        }
    }
    return reservedCapacity;
}
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)

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