@Override public MemoryConfiguration get() { return new ConfigurationBuilder().memory() .size(this.size) .storageType(this.storageType) .evictionStrategy(this.size > 0 ? EvictionStrategy.REMOVE : EvictionStrategy.MANUAL) .evictionType(this.evictionType) .addressCount(this.capacity) .create(); } }
@Override public MemoryConfiguration get() { return new ConfigurationBuilder().memory() .size(this.size) .storageType(this.storageType) .evictionStrategy(this.size > 0 ? EvictionStrategy.REMOVE : EvictionStrategy.MANUAL) .evictionType(this.evictionType) .addressCount(this.capacity) .create(); } }
@Test(expectedExceptions = CacheConfigurationException.class) public void testAddressCountTooLargeAfterRounding() { int addressCount = 3; // 30 is more than 3 * 8, but addressCount has to be rounded up so this will not be enough long bytes = 30; ConfigurationBuilder builder = new ConfigurationBuilder(); builder.memory() .size(bytes) .evictionType(EvictionType.MEMORY) .storageType(StorageType.OFF_HEAP) .addressCount(addressCount); EmbeddedCacheManager manager = TestCacheManagerFactory.createCacheManager(builder); } }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder dcc = getDefaultClusteredCacheConfig(CacheMode.LOCAL, false); dcc.memory().storageType(StorageType.OFF_HEAP).evictionType(EvictionType.COUNT) .size(500) // Set the address count to minimum to cause as many issues as possible! .addressCount(1); // Only start up the 1 cache addClusterEnabledCacheManager(dcc); }
builder.memory().evictionType(type); final int addressCount = MemoryOffHeapConfigurationResource.ADDRESS_COUNT.resolveModelAttribute(context, node).asInt(); builder.memory().addressCount(addressCount);
break; case OFF_HEAP: memoryConfigurationBuilder.addressCount(1 << 7); UnpooledOffHeapMemoryAllocator.estimateSizeOverhead(memoryConfigurationBuilder.addressCount() << 3)); break;
protected void configure(ConfigurationBuilder cfg) { long size = EVICTION_MAX_ENTRIES; if (evictionType == EvictionType.MEMORY) { if (storageType == StorageType.BINARY) { // Binary key/value size is 128 bytes size *= 128; } else { // Off heap key/value size is 64 bytes size = UnpooledOffHeapMemoryAllocator.estimateSizeOverhead(size * 64); // Have to also include address count overhead size += UnpooledOffHeapMemoryAllocator.estimateSizeOverhead(cfg.memory().addressCount() << 3); } } cfg .jmxStatistics() .enable() .memory() .storageType(storageType) .evictionType(evictionType) .size(size) .persistence() .passivation(true) .addStore(DummyInMemoryStoreConfigurationBuilder.class) .purgeOnStartup(true); }