use of com.hazelcast.map.impl.proxy.MapProxyImpl 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.proxy.MapProxyImpl in project hazelcast by hazelcast.
the class ContainsValueOperationTest method executeOperation.
protected InternalCompletableFuture<Object> executeOperation(Map map, String key, int value) {
int partitionId = getNode(member1).getPartitionService().getPartitionId(key);
MapProxyImpl mapProxy = (MapProxyImpl) map;
MapServiceContext mapServiceContext = ((MapService) mapProxy.getService()).getMapServiceContext();
MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapProxy.getName());
OperationFactory operationFactory = operationProvider.createContainsValueOperationFactory(mapProxy.getName(), mapServiceContext.toData(value));
Operation operation = operationFactory.createOperation();
InternalOperationService operationService = getOperationService(member1);
return operationService.createInvocationBuilder(MapService.SERVICE_NAME, operation, partitionId).invoke();
}
use of com.hazelcast.map.impl.proxy.MapProxyImpl 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.proxy.MapProxyImpl in project hazelcast by hazelcast.
the class MapPartitionIteratorTest method test_next_Throws_Exception_On_EmptyPartition.
@Test(expected = NoSuchElementException.class)
public void test_next_Throws_Exception_On_EmptyPartition() throws Exception {
HazelcastInstance instance = createHazelcastInstance();
MapProxyImpl<Object, Object> proxy = (MapProxyImpl<Object, Object>) instance.getMap(randomMapName());
Iterator<Map.Entry<Object, Object>> iterator = proxy.iterator(10, 1, prefetchValues);
iterator.next();
}
use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.
the class MapPartitionIteratorTest method test_HasNext_Returns_True_On_NonEmptyPartition.
@Test
public void test_HasNext_Returns_True_On_NonEmptyPartition() throws Exception {
HazelcastInstance instance = createHazelcastInstance();
MapProxyImpl<Object, Object> proxy = (MapProxyImpl<Object, Object>) instance.getMap(randomMapName());
String key = generateKeyForPartition(instance, 1);
String value = randomString();
proxy.put(key, value);
Iterator<Map.Entry<Object, Object>> iterator = proxy.iterator(10, 1, prefetchValues);
assertTrue(iterator.hasNext());
}
Aggregations