@Test public void generatesWithEvictionMaxEntry() { evictionAction = EvictionAction.OVERFLOW_TO_DISK.toString(); evictionEntryCount = 1; generate(); RegionAttributesType.EvictionAttributes evictionAttributes = config.getRegionAttributes().getEvictionAttributes(); assertThat(evictionAttributes).isNotNull(); assertThat(evictionAttributes.getLruEntryCount().getAction()) .isSameAs(EnumActionDestroyOverflow.OVERFLOW_TO_DISK); assertThat(evictionAttributes.getLruEntryCount().getMaximum()).isEqualTo("1"); }
@Test public void alterWithEvictionMaxWithExistingLruEntryCount() { 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.LruEntryCount existingEntryCount = new RegionAttributesType.EvictionAttributes.LruEntryCount(); existingEntryCount.setMaximum("100"); existingEntryCount.setAction(EnumActionDestroyOverflow.LOCAL_DESTROY); evictionAttributes.setLruEntryCount(existingEntryCount); command.updateConfigForGroup("cluster", cacheConfig, deltaConfig); assertThat(evictionAttributes.getLruEntryCount().getMaximum()).isEqualTo("20"); assertThat(evictionAttributes.getLruEntryCount().getAction()) .isEqualTo(EnumActionDestroyOverflow.LOCAL_DESTROY); }
} else if (configAttributes.getLruEntryCount() != null) { evictionAttributes .setAction(EvictionAction.parseAction(configAttributes.getLruEntryCount().getAction() .value())); } else if (configAttributes.getLruHeapPercentage() != null) {
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(); }