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"));
}
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);
}
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);
}
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;
}
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);
}
}
Aggregations