@Test public void generatesWithEvictionMaxMemory() { evictionAction = EvictionAction.LOCAL_DESTROY.toString(); evictionMaxMemory = 100; generate(); RegionAttributesType.EvictionAttributes evictionAttributes = config.getRegionAttributes().getEvictionAttributes(); assertThat(evictionAttributes).isNotNull(); assertThat(evictionAttributes.getLruMemorySize().getAction()) .isSameAs(EnumActionDestroyOverflow.LOCAL_DESTROY); assertThat(evictionAttributes.getLruMemorySize().getMaximum()).isEqualTo("100"); }
@Test public void alterWithEvictionMaxWithExistingLruMemory() { RegionConfig deltaConfig = getDeltaRegionConfig("alter region --name=regionA --eviction-max=20"); // we are saving the eviction-max as a lruEntryCount's maximum value RegionAttributesType.EvictionAttributes.LruEntryCount lruEntryCount = deltaConfig.getRegionAttributes().getEvictionAttributes().getLruEntryCount(); assertThat(lruEntryCount.getMaximum()).isEqualTo("20"); // when there is no eviction attributes at all RegionAttributesType existingAttributes = new RegionAttributesType(); existingRegionConfig.setRegionAttributes(existingAttributes); command.updateConfigForGroup("cluster", cacheConfig, deltaConfig); assertThat(existingAttributes.getEvictionAttributes()).isNull(); // when there is lruHeapPercentage eviction RegionAttributesType.EvictionAttributes evictionAttributes = new RegionAttributesType.EvictionAttributes(); existingAttributes.setEvictionAttributes(evictionAttributes); RegionAttributesType.EvictionAttributes.LruMemorySize existingMemorySize = new RegionAttributesType.EvictionAttributes.LruMemorySize(); existingMemorySize.setMaximum("100"); existingMemorySize.setAction(EnumActionDestroyOverflow.LOCAL_DESTROY); evictionAttributes.setLruMemorySize(existingMemorySize); command.updateConfigForGroup("cluster", cacheConfig, deltaConfig); assertThat(evictionAttributes.getLruMemorySize().getMaximum()).isEqualTo("20"); assertThat(evictionAttributes.getLruMemorySize().getAction()) .isEqualTo(EnumActionDestroyOverflow.LOCAL_DESTROY); }
.setMaximum(Integer.valueOf(configAttributes.getLruMemorySize().getMaximum())); } else if (configAttributes.getLruEntryCount() != null) { evictionAttributes
public String toStringRep() { return "lru-entry-count: " + this.lruEntryCount.getMaximum() + ", " + this.lruEntryCount.getAction().toString() + ", " + "\nlru-heap-percentage: " + this.lruHeapPercentage.getAction().toString() + "\nlru-memory-size: " + this.lruMemorySize.getMaximum() + this.lruMemorySize.getAction().toString(); }