use of com.hazelcast.config.MaxSizeConfig in project hazelcast by hazelcast.
the class MapMaxSizeConfigTest method setMaxSize_withConstructor_toPositive.
@Test
public void setMaxSize_withConstructor_toPositive() throws Exception {
final int expectedMaxSize = 123456;
MaxSizeConfig maxSizeConfig = new MaxSizeConfig(expectedMaxSize, MaxSizeConfig.MaxSizePolicy.PER_NODE);
assertEquals(expectedMaxSize, maxSizeConfig.getSize());
}
use of com.hazelcast.config.MaxSizeConfig in project hazelcast by hazelcast.
the class EvictionTest method testEvictionLFUInternal.
/**
* This test is only testing occurrence of LFU eviction.
*/
protected void testEvictionLFUInternal(boolean disableStats) {
int mapMaxSize = 10000;
String mapName = randomMapName();
MaxSizeConfig msc = new MaxSizeConfig();
msc.setMaxSizePolicy(PER_NODE);
msc.setSize(mapMaxSize);
Config config = getConfig();
MapConfig mapConfig = config.getMapConfig(mapName);
mapConfig.setStatisticsEnabled(disableStats);
mapConfig.setEvictionPolicy(LFU);
mapConfig.setMinEvictionCheckMillis(0);
mapConfig.setMaxSizeConfig(msc);
HazelcastInstance node = createHazelcastInstance(config);
IMap<Object, Object> map = node.getMap(mapName);
for (int i = 0; i < 2 * mapMaxSize; i++) {
map.put(i, i);
}
int mapSize = map.size();
assertTrue("Eviction did not work, map size " + mapSize + " should be smaller than allowed max size = " + mapMaxSize, mapSize < mapMaxSize);
}
use of com.hazelcast.config.MaxSizeConfig in project hazelcast by hazelcast.
the class MapStoreEvictionTest method newConfig.
private Config newConfig(String mapName, boolean sizeLimited, MapStoreConfig.InitialLoadMode loadMode) {
Config cfg = new Config();
cfg.setGroupConfig(new GroupConfig(getClass().getSimpleName()));
cfg.setProperty("hazelcast.partition.count", "5");
MapStoreConfig mapStoreConfig = new MapStoreConfig().setImplementation(loader).setInitialLoadMode(loadMode);
MapConfig mapConfig = cfg.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
if (sizeLimited) {
MaxSizeConfig maxSizeConfig = new MaxSizeConfig(MAX_SIZE_PER_NODE, MaxSizeConfig.MaxSizePolicy.PER_NODE);
mapConfig.setMaxSizeConfig(maxSizeConfig);
mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
mapConfig.setMinEvictionCheckMillis(0);
}
return cfg;
}
use of com.hazelcast.config.MaxSizeConfig in project hazelcast by hazelcast.
the class PluggableMemoryInfoAccessorTest method testPluggedMemoryInfoAccessorUsed.
/**
* Used {@link ZeroMemoryInfoAccessor} to evict every put, map should not contain any entry after this test run.
*/
@Test
public void testPluggedMemoryInfoAccessorUsed() throws Exception {
MaxSizeConfig maxSizeConfig = new MaxSizeConfig();
maxSizeConfig.setMaxSizePolicy(FREE_HEAP_PERCENTAGE);
maxSizeConfig.setSize(50);
Config config = getConfig();
config.getMapConfig("test").setEvictionPolicy(LFU).setMaxSizeConfig(maxSizeConfig);
HazelcastInstance node = createHazelcastInstance(config);
IMap map = node.getMap("test");
for (int i = 0; i < 1000; i++) {
map.put(i, i);
}
assertEquals(0, map.size());
}
use of com.hazelcast.config.MaxSizeConfig in project cas by apereo.
the class HazelcastTicketRegistryConfiguration method createMapConfig.
private MapConfig createMapConfig(final TicketDefinition definition) {
final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
final HazelcastProperties.Cluster cluster = hz.getCluster();
final EvictionPolicy evictionPolicy = EvictionPolicy.valueOf(cluster.getEvictionPolicy());
LOGGER.debug("Creating Hazelcast map configuration for [{}] with idle timeout [{}] second(s)", definition.getProperties().getStorageName(), definition.getProperties().getStorageTimeout());
return new MapConfig().setName(definition.getProperties().getStorageName()).setMaxIdleSeconds((int) definition.getProperties().getStorageTimeout()).setBackupCount(cluster.getBackupCount()).setAsyncBackupCount(cluster.getAsyncBackupCount()).setEvictionPolicy(evictionPolicy).setMaxSizeConfig(new MaxSizeConfig().setMaxSizePolicy(MaxSizeConfig.MaxSizePolicy.valueOf(cluster.getMaxSizePolicy())).setSize(cluster.getMaxHeapSizePercentage()));
}
Aggregations