Search in sources :

Example 51 with MapService

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

the class LocalMapStatsUnderOnGoingClientUpdateTest method stats_generated_when_member_restarted_under_ongoing_client_update.

@Test
public void stats_generated_when_member_restarted_under_ongoing_client_update() throws Exception {
    IMap map = client.getMap(mapName);
    member.shutdown();
    member = factory.newHazelcastInstance();
    map.put(1, 1);
    map.put(2, 2);
    // get internal StatisticsAwareService.
    MapService mapService = getNodeEngineImpl(member).getService(SERVICE_NAME);
    Map<String, LocalMapStats> stats = ((StatisticsAwareService) mapService).getStats();
    LocalMapStats localMapStats = stats.get(mapName);
    // StatisticsAwareService should give right stats.
    assertNotNull("there should be 1 LocalMapStats object", localMapStats);
    assertEquals("Owned entry count should be 2", 2, localMapStats.getOwnedEntryCount());
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) IMap(com.hazelcast.core.IMap) StatisticsAwareService(com.hazelcast.spi.StatisticsAwareService) MapService(com.hazelcast.map.impl.MapService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 52 with MapService

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

the class TimedMemberStateFactory method createMemState.

private void createMemState(TimedMemberState timedMemberState, MemberStateImpl memberState, Collection<StatisticsAwareService> services) {
    int count = 0;
    Config config = instance.getConfig();
    Set<String> longInstanceNames = new HashSet<String>(maxVisibleInstanceCount);
    for (StatisticsAwareService service : services) {
        if (count < maxVisibleInstanceCount) {
            if (service instanceof MapService) {
                count = handleMap(memberState, count, config, ((MapService) service).getStats(), longInstanceNames);
            } else if (service instanceof MultiMapService) {
                count = handleMultimap(memberState, count, config, ((MultiMapService) service).getStats(), longInstanceNames);
            } else if (service instanceof QueueService) {
                count = handleQueue(memberState, count, config, ((QueueService) service).getStats(), longInstanceNames);
            } else if (service instanceof TopicService) {
                count = handleTopic(memberState, count, config, ((TopicService) service).getStats(), longInstanceNames);
            } else if (service instanceof DistributedExecutorService) {
                count = handleExecutorService(memberState, count, config, ((DistributedExecutorService) service).getStats(), longInstanceNames);
            } else if (service instanceof ReplicatedMapService) {
                count = handleReplicatedMap(memberState, count, config, ((ReplicatedMapService) service).getStats(), longInstanceNames);
            }
        }
    }
    WanReplicationService wanReplicationService = instance.node.nodeEngine.getWanReplicationService();
    Map<String, LocalWanStats> wanStats = wanReplicationService.getStats();
    if (wanStats != null) {
        count = handleWan(memberState, count, wanStats, longInstanceNames);
    }
    if (cacheServiceEnabled) {
        ICacheService cacheService = getCacheService();
        for (CacheConfig cacheConfig : cacheService.getCacheConfigs()) {
            if (cacheConfig.isStatisticsEnabled() && count < maxVisibleInstanceCount) {
                CacheStatistics statistics = cacheService.getStatistics(cacheConfig.getNameWithPrefix());
                //is filled.git
                if (statistics != null) {
                    count = handleCache(memberState, count, cacheConfig, statistics, longInstanceNames);
                }
            }
        }
    }
    timedMemberState.setInstanceNames(longInstanceNames);
}
Also used : StatisticsAwareService(com.hazelcast.spi.StatisticsAwareService) CacheConfig(com.hazelcast.config.CacheConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) MultiMapService(com.hazelcast.multimap.impl.MultiMapService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) QueueService(com.hazelcast.collection.impl.queue.QueueService) WanReplicationService(com.hazelcast.wan.WanReplicationService) CacheStatistics(com.hazelcast.cache.CacheStatistics) TopicService(com.hazelcast.topic.impl.TopicService) ICacheService(com.hazelcast.cache.impl.ICacheService) LocalWanStats(com.hazelcast.monitor.LocalWanStats) DistributedExecutorService(com.hazelcast.executor.impl.DistributedExecutorService) MultiMapService(com.hazelcast.multimap.impl.MultiMapService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) MapService(com.hazelcast.map.impl.MapService) CacheConfig(com.hazelcast.config.CacheConfig) HashSet(java.util.HashSet)

Example 53 with MapService

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

the class GetMapConfigOperation method run.

@Override
public void run() throws Exception {
    MapService service = getService();
    mapConfig = service.getMapServiceContext().getMapContainer(mapName).getMapConfig();
}
Also used : MapService(com.hazelcast.map.impl.MapService)

Example 54 with MapService

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

the class MadePublishableOperation method getContext.

private QueryCacheContext getContext() {
    MapService service = getService();
    MapServiceContext mapServiceContext = service.getMapServiceContext();
    return mapServiceContext.getQueryCacheContext();
}
Also used : MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 55 with MapService

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

the class PartitionWideEntryWithPredicateOperationFactory method getKeysFromIndex.

private Set<Data> getKeysFromIndex(NodeEngine nodeEngine) {
    // Do not use index in this case, because it requires full-table-scan.
    if (predicate == TruePredicate.INSTANCE) {
        return emptySet();
    }
    // get indexes
    MapService mapService = nodeEngine.getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    Indexes indexes = mapServiceContext.getMapContainer(name).getIndexes();
    // optimize predicate
    QueryOptimizer queryOptimizer = mapServiceContext.getQueryOptimizer();
    predicate = queryOptimizer.optimize(predicate, indexes);
    Set<QueryableEntry> querySet = indexes.query(predicate);
    if (querySet == null) {
        return emptySet();
    }
    List<Data> keys = null;
    for (QueryableEntry e : querySet) {
        if (keys == null) {
            keys = new ArrayList<Data>(querySet.size());
        }
        keys.add(e.getKeyData());
    }
    return keys == null ? Collections.<Data>emptySet() : newBuilder(keys).build();
}
Also used : Data(com.hazelcast.nio.serialization.Data) QueryOptimizer(com.hazelcast.query.impl.predicates.QueryOptimizer) MapService(com.hazelcast.map.impl.MapService) Indexes(com.hazelcast.query.impl.Indexes) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

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