use of com.hazelcast.map.impl.MapContainer in project hazelcast by hazelcast.
the class MapContainerCreationUponDestroyStressTest method assertRecordStoresSharesSameMapContainerInstance.
private void assertRecordStoresSharesSameMapContainerInstance(IMap<Long, Long> map) {
String mapName = map.getName();
MapContainer expectedMapContainer = getMapContainer(map);
for (int i = 0; i < PARTITION_COUNT; i++) {
PartitionContainer partitionContainer = getMapServiceContext(map).getPartitionContainer(i);
RecordStore recordStore = partitionContainer.getMaps().get(mapName);
if (recordStore == null) {
continue;
}
assertEquals(expectedMapContainer, recordStore.getMapContainer());
}
}
use of com.hazelcast.map.impl.MapContainer in project hazelcast by hazelcast.
the class EvictionMaxSizePolicyTest method setMockRuntimeMemoryInfoAccessor.
public static void setMockRuntimeMemoryInfoAccessor(IMap map, final long totalMemoryMB, final long freeMemoryMB, final long maxMemoryMB) {
final MapProxyImpl mapProxy = (MapProxyImpl) map;
final MapService mapService = (MapService) mapProxy.getService();
final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MemoryInfoAccessor memoryInfoAccessor = new MemoryInfoAccessor() {
@Override
public long getTotalMemory() {
return MEGABYTES.toBytes(totalMemoryMB);
}
@Override
public long getFreeMemory() {
return MEGABYTES.toBytes(freeMemoryMB);
}
@Override
public long getMaxMemory() {
return MEGABYTES.toBytes(maxMemoryMB);
}
};
MapContainer mapContainer = mapServiceContext.getMapContainer(map.getName());
MapEvictionPolicy mapEvictionPolicy = mapContainer.getMapConfig().getMapEvictionPolicy();
EvictionChecker evictionChecker = new EvictionChecker(memoryInfoAccessor, mapServiceContext);
IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
Evictor evictor = new TestEvictor(mapEvictionPolicy, evictionChecker, partitionService);
mapContainer.setEvictor(evictor);
}
use of com.hazelcast.map.impl.MapContainer in project hazelcast by hazelcast.
the class IndexIntegrationTest method getIndexOfAttributeForMap.
private static Index getIndexOfAttributeForMap(HazelcastInstance instance, String mapName, String attribute) {
Node node = getNode(instance);
MapService service = node.nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext mapServiceContext = service.getMapServiceContext();
MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
Indexes indexes = mapContainer.getIndexes();
return indexes.getIndex(attribute);
}
use of com.hazelcast.map.impl.MapContainer in project hazelcast by hazelcast.
the class DynamicMapConfigTest method isEvictionEnabled.
private boolean isEvictionEnabled(IMap map) {
MapProxyImpl mapProxy = (MapProxyImpl) map;
MapService mapService = (MapService) mapProxy.getService();
MapServiceContext mapServiceContext = (MapServiceContext) mapService.getMapServiceContext();
MapContainer mapContainer = mapServiceContext.getMapContainer(map.getName());
EvictionPolicy evictionPolicy = mapContainer.getMapConfig().getEvictionPolicy();
return evictionPolicy != NONE;
}
use of com.hazelcast.map.impl.MapContainer in project hazelcast by hazelcast.
the class PostJoinMapOperationTest method testPostJoinMapOperation_whenMapHasNoData.
@Test
public void testPostJoinMapOperation_whenMapHasNoData() {
TestHazelcastInstanceFactory hzFactory = createHazelcastInstanceFactory(2);
// given: a single node HazelcastInstance with a map configured with index and interceptor
HazelcastInstance hz1 = hzFactory.newHazelcastInstance();
IMap<String, Person> map = hz1.getMap("map");
map.addIndex("age", true);
map.addInterceptor(new FixedReturnInterceptor());
assertEquals(RETURNED_FROM_INTERCEPTOR, map.get("foo"));
// when: another member joins the cluster
HazelcastInstance hz2 = hzFactory.newHazelcastInstance();
waitAllForSafeState(hz1, hz2);
// then: index & interceptor exist on internal MapContainer on node that joined the cluster
MapService mapService = getNodeEngineImpl(hz2).getService(MapService.SERVICE_NAME);
MapContainer mapContainerOnNode2 = mapService.getMapServiceContext().getMapContainer("map");
assertEquals(1, mapContainerOnNode2.getIndexes().getIndexes().length);
assertEquals(1, mapContainerOnNode2.getInterceptorRegistry().getInterceptors().size());
assertEquals(Person.class, mapContainerOnNode2.getInterceptorRegistry().getInterceptors().get(0).interceptGet("anything").getClass());
assertEquals(RETURNED_FROM_INTERCEPTOR.getAge(), ((Person) mapContainerOnNode2.getInterceptorRegistry().getInterceptors().get(0).interceptGet("anything")).getAge());
// also verify via user API
IMap<String, Person> mapOnNode2 = hz2.getMap("map");
assertEquals(RETURNED_FROM_INTERCEPTOR, mapOnNode2.get("whatever"));
hzFactory.terminateAll();
}
Aggregations