Search in sources :

Example 16 with MapContainer

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

the class MapStoreTest method testReadingConfiguration.

@Test(timeout = 120000)
public void testReadingConfiguration() throws Exception {
    String mapName = "mapstore-test";
    InputStream is = getClass().getResourceAsStream("/com/hazelcast/config/hazelcast-mapstore-config.xml");
    XmlConfigBuilder builder = new XmlConfigBuilder(is);
    Config config = builder.build();
    HazelcastInstance hz = createHazelcastInstance(config);
    MapProxyImpl map = (MapProxyImpl) hz.getMap(mapName);
    MapService mapService = (MapService) map.getService();
    MapContainer mapContainer = mapService.getMapServiceContext().getMapContainer(mapName);
    MapStoreWrapper mapStoreWrapper = mapContainer.getMapStoreContext().getMapStoreWrapper();
    Iterator keys = mapStoreWrapper.loadAllKeys().iterator();
    final Set<String> loadedKeySet = loadedKeySet(keys);
    final Set<String> expectedKeySet = expectedKeySet();
    assertEquals(expectedKeySet, loadedKeySet);
    assertEquals("true", mapStoreWrapper.load("my-prop-1"));
    assertEquals("foo", mapStoreWrapper.load("my-prop-2"));
}
Also used : MapStoreWrapper(com.hazelcast.map.impl.MapStoreWrapper) XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) HazelcastInstance(com.hazelcast.core.HazelcastInstance) InputStream(java.io.InputStream) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) Iterator(java.util.Iterator) MapService(com.hazelcast.map.impl.MapService) MapContainer(com.hazelcast.map.impl.MapContainer) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 17 with MapContainer

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

the class MapNearCacheManager method getFromNearCache.

public Object getFromNearCache(String mapName, Data key) {
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    if (!mapContainer.hasInvalidationListener()) {
        return null;
    }
    NearCacheConfig nearCacheConfig = mapContainer.getMapConfig().getNearCacheConfig();
    NearCache<Data, Object> nearCache = getOrCreateNearCache(mapName, nearCacheConfig);
    return nearCache.get(key);
}
Also used : NearCacheConfig(com.hazelcast.config.NearCacheConfig) Data(com.hazelcast.nio.serialization.Data) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 18 with MapContainer

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

the class AddInterceptorOperation method run.

@Override
public void run() {
    mapService = getService();
    MapContainer mapContainer = mapService.getMapServiceContext().getMapContainer(mapName);
    mapContainer.getInterceptorRegistry().register(id, mapInterceptor);
}
Also used : MapContainer(com.hazelcast.map.impl.MapContainer)

Example 19 with MapContainer

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

the class EvictionChecker method getUsedHeapInBytes.

protected long getUsedHeapInBytes(String mapName) {
    long heapCost = 0L;
    final List<Integer> partitionIds = findPartitionIds();
    for (int partitionId : partitionIds) {
        final PartitionContainer container = mapServiceContext.getPartitionContainer(partitionId);
        if (container == null) {
            continue;
        }
        heapCost += getRecordStoreHeapCost(mapName, container);
    }
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    if (!mapContainer.getMapConfig().isNearCacheEnabled()) {
        return heapCost;
    }
    MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
    NearCache nearCache = mapNearCacheManager.getNearCache(mapName);
    NearCacheStats nearCacheStats = nearCache.getNearCacheStats();
    heapCost += nearCacheStats.getOwnedEntryMemoryCost();
    return heapCost;
}
Also used : MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) NearCacheStats(com.hazelcast.monitor.NearCacheStats) NearCache(com.hazelcast.internal.nearcache.NearCache) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 20 with MapContainer

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

the class MapReplicationStateHolder method prepare.

void prepare(PartitionContainer container, int replicaIndex) {
    data = new HashMap<String, Set<RecordReplicationInfo>>(container.getMaps().size());
    loaded = new HashMap<String, Boolean>(container.getMaps().size());
    for (Map.Entry<String, RecordStore> entry : container.getMaps().entrySet()) {
        RecordStore recordStore = entry.getValue();
        MapContainer mapContainer = recordStore.getMapContainer();
        MapConfig mapConfig = mapContainer.getMapConfig();
        if (mapConfig.getTotalBackupCount() < replicaIndex) {
            continue;
        }
        MapServiceContext mapServiceContext = mapContainer.getMapServiceContext();
        String mapName = entry.getKey();
        loaded.put(mapName, recordStore.isLoaded());
        // now prepare data to migrate records
        Set<RecordReplicationInfo> recordSet = new HashSet<RecordReplicationInfo>(recordStore.size());
        final Iterator<Record> iterator = recordStore.iterator();
        while (iterator.hasNext()) {
            Record record = iterator.next();
            Data key = record.getKey();
            RecordReplicationInfo recordReplicationInfo = mapReplicationOperation.createRecordReplicationInfo(key, record, mapServiceContext);
            recordSet.add(recordReplicationInfo);
        }
        data.put(mapName, recordSet);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Data(com.hazelcast.nio.serialization.Data) MapContainer(com.hazelcast.map.impl.MapContainer) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) RecordReplicationInfo(com.hazelcast.map.impl.record.RecordReplicationInfo) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) Record(com.hazelcast.map.impl.record.Record) MapConfig(com.hazelcast.config.MapConfig) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

MapContainer (com.hazelcast.map.impl.MapContainer)25 MapService (com.hazelcast.map.impl.MapService)10 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)6 Data (com.hazelcast.nio.serialization.Data)5 MapConfig (com.hazelcast.config.MapConfig)4 Record (com.hazelcast.map.impl.record.Record)4 Map (java.util.Map)4 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)3 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)3 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)3 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)3 HashMap (java.util.HashMap)3 EntryView (com.hazelcast.core.EntryView)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)2 Predicate (com.hazelcast.query.Predicate)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 Config (com.hazelcast.config.Config)1