use of com.hazelcast.config.MaxSizePolicy in project hazelcast by hazelcast.
the class CachePartitionIteratorBouncingTest method getConfig.
@Override
protected Config getConfig() {
Config config = smallInstanceConfig();
MaxSizePolicy maxSizePolicy = getInMemoryFormat() == InMemoryFormat.NATIVE ? USED_NATIVE_MEMORY_SIZE : DEFAULT_MAX_SIZE_POLICY;
config.getCacheConfig(TEST_CACHE_NAME).setInMemoryFormat(getInMemoryFormat()).getEvictionConfig().setMaxSizePolicy(maxSizePolicy).setSize(Integer.MAX_VALUE);
return config;
}
use of com.hazelcast.config.MaxSizePolicy in project hazelcast by hazelcast.
the class CacheEventJournalBasicTest method getConfig.
@Override
protected Config getConfig() {
Config config = super.getConfig();
CacheSimpleConfig nonEvictingCache = config.getCacheConfig(NON_EVICTING_CACHE).setInMemoryFormat(getInMemoryFormat());
MaxSizePolicy maxSizePolicy = getInMemoryFormat() == InMemoryFormat.NATIVE ? USED_NATIVE_MEMORY_SIZE : DEFAULT_MAX_SIZE_POLICY;
nonEvictingCache.getEvictionConfig().setMaxSizePolicy(maxSizePolicy).setSize(Integer.MAX_VALUE);
final CacheSimpleConfig evictingCache = config.getCacheConfig(EVICTING_CACHE).setInMemoryFormat(getInMemoryFormat());
evictingCache.getEvictionConfig().setMaxSizePolicy(maxSizePolicy);
return config;
}
use of com.hazelcast.config.MaxSizePolicy in project hazelcast by hazelcast.
the class EvictionChecker method checkEvictable.
public boolean checkEvictable(RecordStore recordStore) {
if (recordStore.size() == 0) {
return false;
}
String mapName = recordStore.getName();
MapContainer mapContainer = recordStore.getMapContainer();
EvictionConfig evictionConfig = mapContainer.getMapConfig().getEvictionConfig();
MaxSizePolicy maximumSizePolicy = evictionConfig.getMaxSizePolicy();
int maxConfiguredSize = evictionConfig.getSize();
switch(maximumSizePolicy) {
case PER_NODE:
return recordStore.size() > toPerPartitionMaxSize(maxConfiguredSize, mapName);
case PER_PARTITION:
return recordStore.size() > maxConfiguredSize;
case USED_HEAP_SIZE:
return usedHeapInBytes(mapName) > MEGABYTES.toBytes(maxConfiguredSize);
case FREE_HEAP_SIZE:
return availableMemoryInBytes() < MEGABYTES.toBytes(maxConfiguredSize);
case USED_HEAP_PERCENTAGE:
return (usedHeapInBytes(mapName) * ONE_HUNDRED / Math.max(maxMemoryInBytes(), 1)) > maxConfiguredSize;
case FREE_HEAP_PERCENTAGE:
return (availableMemoryInBytes() * ONE_HUNDRED / Math.max(maxMemoryInBytes(), 1)) < maxConfiguredSize;
default:
throw new IllegalArgumentException("Not an appropriate max size policy [" + maximumSizePolicy + ']');
}
}
use of com.hazelcast.config.MaxSizePolicy in project hazelcast by hazelcast.
the class AbstractInternalQueryCache method reachedMaxCapacity.
@Override
public boolean reachedMaxCapacity() {
EvictionConfig evictionConfig = queryCacheConfig.getEvictionConfig();
MaxSizePolicy maximumSizePolicy = evictionConfig.getMaxSizePolicy();
return maximumSizePolicy == MaxSizePolicy.ENTRY_COUNT && size() == evictionConfig.getSize();
}
use of com.hazelcast.config.MaxSizePolicy in project hazelcast by hazelcast.
the class ConfigValidator method checkOnHeapNearCacheMaxSizePolicy.
private static void checkOnHeapNearCacheMaxSizePolicy(NearCacheConfig nearCacheConfig) {
InMemoryFormat inMemoryFormat = nearCacheConfig.getInMemoryFormat();
if (inMemoryFormat == NATIVE) {
return;
}
MaxSizePolicy maxSizePolicy = nearCacheConfig.getEvictionConfig().getMaxSizePolicy();
if (!NEAR_CACHE_SUPPORTED_ON_HEAP_MAX_SIZE_POLICIES.contains(maxSizePolicy)) {
throw new InvalidConfigurationException(format("Near Cache maximum size policy %s cannot be used with %s storage." + " Supported maximum size policies are: %s", maxSizePolicy, inMemoryFormat, NEAR_CACHE_SUPPORTED_ON_HEAP_MAX_SIZE_POLICIES));
}
}
Aggregations