RegionAttributesType.EvictionAttributes.LruHeapPercentage heapPercentage = new RegionAttributesType.EvictionAttributes.LruHeapPercentage(); heapPercentage.setAction(action); objectSizerClass.ifPresent(o -> heapPercentage.setClassName(o)); configAttributes.setLruHeapPercentage(heapPercentage);
private RegionAttributesType.EvictionAttributes generateEvictionAttributes(String evictionAction, Integer maxMemory, Integer maxEntryCount, String objectSizer) { RegionAttributesType.EvictionAttributes configAttributes = new RegionAttributesType.EvictionAttributes(); EnumActionDestroyOverflow action = EnumActionDestroyOverflow.fromValue(evictionAction); if (maxMemory == null && maxEntryCount == null) { RegionAttributesType.EvictionAttributes.LruHeapPercentage heapPercentage = new RegionAttributesType.EvictionAttributes.LruHeapPercentage(); heapPercentage.setAction(action); heapPercentage.setClassName(objectSizer); configAttributes.setLruHeapPercentage(heapPercentage); } else if (maxMemory != null) { RegionAttributesType.EvictionAttributes.LruMemorySize memorySize = new RegionAttributesType.EvictionAttributes.LruMemorySize(); memorySize.setAction(action); memorySize.setClassName(objectSizer); memorySize.setMaximum(maxMemory.toString()); configAttributes.setLruMemorySize(memorySize); } else { RegionAttributesType.EvictionAttributes.LruEntryCount entryCount = new RegionAttributesType.EvictionAttributes.LruEntryCount(); entryCount.setAction(action); entryCount.setMaximum(maxEntryCount.toString()); configAttributes.setLruEntryCount(entryCount); } return configAttributes; }
public void setLruHeapPercentage(EnumActionDestroyOverflow action) { if (evictionAttributes == null) { evictionAttributes = new EvictionAttributes(); } EvictionAttributes.LruHeapPercentage lruHeapPercentage = new EvictionAttributes.LruHeapPercentage(); lruHeapPercentage.setAction(action); evictionAttributes.setLruHeapPercentage(lruHeapPercentage); }