/** * Create an <code>lru-heap-percentage</code> eviction controller, assigning it to the enclosed * <code>region-attributes</code> * */ private void startLRUHeapPercentage(Attributes atts) { final String lruAction = atts.getValue(ACTION); EvictionAction action = EvictionAction.DEFAULT_EVICTION_ACTION; if (lruAction != null) { action = EvictionAction.parseAction(lruAction); } // Store for later addition of ObjectSizer, if any stack.push(EvictionAttributes.createLRUHeapAttributes(null, action)); }
public EvictionAttributes convertToEvictionAttributes() { EvictionAction action = EvictionAction.parseAction(evictionAction); ObjectSizer sizer; if (objectSizer != null) { try { Class<ObjectSizer> sizerClass = (Class<ObjectSizer>) ClassPathLoader.getLatest().forName(objectSizer); sizer = sizerClass.newInstance(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException( "Unable to instantiate class " + objectSizer + " - " + e.toString()); } } else { sizer = ObjectSizer.DEFAULT; } if (maxMemory == null && maxEntryCount == null) { return EvictionAttributes.createLRUHeapAttributes(sizer, action); } else if (maxMemory != null) { return EvictionAttributes.createLRUMemoryAttributes(maxMemory, sizer, action); } else { return EvictionAttributes.createLRUEntryAttributes(maxEntryCount, action); } } }
EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); factory.setDiskSynchronous(true); factory.setDiskStoreName(cache.createDiskStoreFactory()
AttributesFactory<?, ?> af = new AttributesFactory(); af.setDataPolicy(DataPolicy.NORMAL); af.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes()); cache.setRegionAttributes(shortcut.toString(), af.create()); break; af.setDataPolicy(DataPolicy.NORMAL); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); break; af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); break; AttributesFactory<?, ?> af = new AttributesFactory(); af.setDataPolicy(DataPolicy.NORMAL); af.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes()); UserSpecifiedRegionAttributes<?, ?> attributes = (UserSpecifiedRegionAttributes) af.create(); af.setDataPolicy(DataPolicy.NORMAL); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); UserSpecifiedRegionAttributes<?, ?> attributes = (UserSpecifiedRegionAttributes) af.create();
factory.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes(ObjectSizer.DEFAULT, EvictionAction.OVERFLOW_TO_DISK));
af.setPartitionAttributes(paf.create()); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); break; af.setPartitionAttributes(paf.create()); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); break; af.setPartitionAttributes(paf.create()); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); break; af.setPartitionAttributes(paf.create()); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); break; PartitionAttributesFactory paf = new PartitionAttributesFactory(); af.setPartitionAttributes(paf.create()); af.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes()); cache.setRegionAttributes(shortcut.toString(), af.create()); break;
EvictionAttributes createAttributes() { switch (type) { case HEAP_PERCENTAGE: if (threshold != null) { throw new IllegalArgumentException("HEAP_PERCENTAGE (LRU_HEAP algorithm) does not support threshold (a.k.a. maximum)!"); } return EvictionAttributes.createLRUHeapAttributes(getObjectSizer(), getAction()); case MEMORY_SIZE: return (threshold != null ? EvictionAttributes.createLRUMemoryAttributes(getThreshold(), getObjectSizer(), getAction()) : EvictionAttributes.createLRUMemoryAttributes(getObjectSizer(), getAction())); case ENTRY_COUNT: default: return (threshold != null ? EvictionAttributes.createLRUEntryAttributes(getThreshold(), getAction()) : EvictionAttributes.createLRUEntryAttributes(DEFAULT_LRU_MAXIMUM_ENTRIES, getAction())); } }
EvictionAttributes createAttributes() { switch (type) { case HEAP_PERCENTAGE: if (threshold != null) { throw new IllegalArgumentException("HEAP_PERCENTAGE (LRU_HEAP algorithm) does not support threshold (a.k.a. maximum)!"); } return EvictionAttributes.createLRUHeapAttributes(getObjectSizer(), getAction()); case MEMORY_SIZE: return (threshold != null ? EvictionAttributes.createLRUMemoryAttributes(getThreshold(), getObjectSizer(), getAction()) : EvictionAttributes.createLRUMemoryAttributes(getObjectSizer(), getAction())); case ENTRY_COUNT: default: return (threshold != null ? EvictionAttributes.createLRUEntryAttributes(getThreshold(), getAction()) : EvictionAttributes.createLRUEntryAttributes(DEFAULT_LRU_MAXIMUM_ENTRIES, getAction())); } }