@Override public String toString() { final StringBuilder buffer = new StringBuilder(128); buffer.append(" algorithm=").append(this.getAlgorithm()); if (!this.getAlgorithm().isNone()) { buffer.append("; action=").append(this.getAction()); if (!getAlgorithm().isLRUHeap()) { buffer.append("; maximum=").append(this.getMaximum()); } if (this.getObjectSizer() != null) { buffer.append("; sizer=").append(this.getObjectSizer()); } } return buffer.toString(); }
@Override public int hashCode() { return this.getAlgorithm().hashCode() ^ this.getMaximum(); }
@Override public boolean equals(final Object obj) { if (obj == this) { return true; } if (!(obj instanceof EvictionAttributes)) { return false; } final EvictionAttributes other = (EvictionAttributes) obj; if (!getAlgorithm().equals(other.getAlgorithm())) { return false; } if (!getAction().equals(other.getAction())) { return false; } if (getMaximum() != other.getMaximum()) { return false; } return true; }
/** * Dump the attributes which are common across the PR to the string builder. */ public void dumpCommonAttributes(StringBuilder msg) { msg.append("\n\tlru=").append(getEvictionAttributes().getAlgorithm()); if (!getEvictionAttributes().getAlgorithm().isNone()) { msg.append("\n\tlruAction=").append(getEvictionAttributes().getAction()); if (!getEvictionAttributes().getAlgorithm().isLRUHeap()) { msg.append("\n\tlruLimit=").append(getEvictionAttributes().getMaximum()); } } msg.append("\n\tconcurrencyLevel=").append(getConcurrencyLevel()); msg.append("\n\tinitialCapacity=").append(getInitialCapacity()); msg.append("\n\tloadFactor=").append(getLoadFactor()); msg.append("\n\toffHeap=").append(getOffHeap()); msg.append("\n\tstatisticsEnabled=").append(getStatisticsEnabled()); msg.append("\n\tdrId=").append(getId()); msg.append("\n\tisBucket=").append(isBucket()); msg.append("\n\tclearEntryId=").append(getClearOplogEntryId()); msg.append("\n\tflags=").append(getFlags()); }
/** * copy constructor */ public EvictionAttributesImpl(EvictionAttributes other) { this.algorithm = other.getAlgorithm(); this.sizer = other.getObjectSizer(); this.maximum = other.getMaximum(); this.action = other.getAction(); }
private boolean isMemoryEvictionConfigured() { boolean result = false; EvictionAttributes ea = region.getAttributes().getEvictionAttributes(); if (ea != null && ea.getAlgorithm().isLRUMemory()) { result = true; } return result; }
private static EvictionController createEvictionController() { EvictionController result = mock(EvictionController.class); when(result.getEvictionAlgorithm()).thenReturn(evictionAttributes.getAlgorithm()); EvictionCounters evictionCounters = mock(EvictionCounters.class); when(result.getCounters()).thenReturn(evictionCounters); return result; }
static void validateRegionAttributes(RegionAttributes attrs) { if (!attrs.getDataPolicy().withPartitioning()) { // replicated region throw new UnsupportedOperationException( "Lucene indexes on replicated regions are not supported"); } // For now we cannot support eviction with local destroy. // Eviction with overflow to disk still needs to be supported EvictionAttributes evictionAttributes = attrs.getEvictionAttributes(); EvictionAlgorithm evictionAlgorithm = evictionAttributes.getAlgorithm(); if (evictionAlgorithm != EvictionAlgorithm.NONE && evictionAttributes.getAction().isLocalDestroy()) { throw new UnsupportedOperationException( "Lucene indexes on regions with eviction and action local destroy are not supported"); } }
public EvictionAttributesInfo(EvictionAttributes ea) { EvictionAction evictAction = ea.getAction(); if (evictAction != null) { evictionAction = evictAction.toString(); } EvictionAlgorithm evictionAlgo = ea.getAlgorithm(); if (evictionAlgo != null) { evictionAlgorithm = evictionAlgo.toString(); } evictionMaxValue = ea.getMaximum(); }
@Override protected boolean includeLocalRegion(LocalRegion region) { return region.getEvictionAttributes().getAlgorithm().isLRUHeap() && region.getAttributes().getOffHeap(); }
public EvictionAttributesInfo(EvictionAttributes ea) { EvictionAction evictAction = ea.getAction(); if (evictAction != null) { evictionAction = evictAction.toString(); } EvictionAlgorithm evictionAlgo = ea.getAlgorithm(); if (evictionAlgo != null) { evictionAlgorithm = evictionAlgo.toString(); } evictionMaxValue = ea.getMaximum(); }
protected boolean includeLocalRegion(LocalRegion region) { return region.getEvictionAttributes().getAlgorithm().isLRUHeap() && !region.getAttributes().getOffHeap(); }
@Override protected boolean includePartitionedRegion(PartitionedRegion region) { return region.getEvictionAttributes().getAlgorithm().isLRUHeap() && region.getDataStore() != null && region.getAttributes().getOffHeap(); }
protected boolean includePartitionedRegion(PartitionedRegion region) { return region.getEvictionAttributes().getAlgorithm().isLRUHeap() && region.getDataStore() != null && !region.getAttributes().getOffHeap(); }
public static EvictionAttributesData getEvictionAttributesData(RegionAttributes regAttrs) { String algorithm = ""; Integer maximum = null; if (regAttrs.getEvictionAttributes().getAlgorithm() != null) { algorithm = regAttrs.getEvictionAttributes().getAlgorithm().toString(); if (algorithm.equals(EvictionAlgorithm.NONE.toString())) { EvictionAttributesData evictionAttributesData = new EvictionAttributesData(algorithm, null, EvictionAlgorithm.NONE.toString()); return evictionAttributesData; } if (!regAttrs.getEvictionAttributes().getAlgorithm().isLRUHeap()) { maximum = regAttrs.getEvictionAttributes().getMaximum(); } } String action = regAttrs.getEvictionAttributes().getAction().toString(); EvictionAttributesData evictionAttributesData = new EvictionAttributesData(algorithm, maximum, action); return evictionAttributesData; }
private boolean isLruValueRecoveryDisabled(DiskRecoveryStore store) { return !store.getDiskStore().isOffline() && !getParent().RECOVER_LRU_VALUES && !store.getEvictionAttributes().getAlgorithm().isNone(); }
@Test public void evictionAttributes() throws Exception { args.setEvictionAttributes(null, 0, 0, null); assertThat(args.getEvictionAttributes()).isNull(); args.setEvictionAttributes("local-destroy", null, null, null); EvictionAttributes attributes = args.getEvictionAttributes() .convertToEvictionAttributes(); assertThat(attributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_HEAP); assertThat(attributes.getAction()).isEqualTo(EvictionAction.LOCAL_DESTROY); assertThat(attributes.getMaximum()).isEqualTo(0); args.setEvictionAttributes("overflow-to-disk", 1000, null, null); EvictionAttributes attributes1 = args.getEvictionAttributes() .convertToEvictionAttributes(); assertThat(attributes1.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_MEMORY); assertThat(attributes1.getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK); assertThat(attributes1.getMaximum()).isEqualTo(1000); args.setEvictionAttributes("local-destroy", null, 1000, null); EvictionAttributes attributes2 = args.getEvictionAttributes() .convertToEvictionAttributes(); assertThat(attributes2.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_ENTRY); assertThat(attributes2.getAction()).isEqualTo(EvictionAction.LOCAL_DESTROY); assertThat(attributes2.getMaximum()).isEqualTo(1000); }
private void initialize(Region region) { setNumberOfEntries(region.size()); EvictionAttributes ea = region.getAttributes().getEvictionAttributes(); if (ea != null && ea.getAlgorithm().isLRUMemory()) { setHeapSize(((InternalRegion) region).getEvictionCounter()); } else { setHeapSize(-1); } }
public int getSizeForEviction() { EvictionAttributes ea = this.getAttributes().getEvictionAttributes(); if (ea == null) return 0; EvictionAlgorithm algo = ea.getAlgorithm(); if (!algo.isLRUHeap()) return 0; EvictionAction action = ea.getAction(); int size = action.isLocalDestroy() ? this.getRegionMap().sizeInVM() : (int) this.getNumEntriesInVM(); return size; }
private static void lruUpdateCallback(DiskRecoveryStore recoveryStore) { /* * Used conditional check to see if if its a LIFO Enabled, yes then disable * lruUpdateCallback() and called updateStats() its keep track of actual entries present in * memory - useful when checking capacity constraint */ try { if (recoveryStore.getEvictionAttributes() != null && recoveryStore.getEvictionAttributes().getAlgorithm().isLIFO()) { recoveryStore.getRegionMap().updateEvictionCounter(); return; } // this must be done after releasing synchronization recoveryStore.getRegionMap().lruUpdateCallback(); } catch (DiskAccessException dae) { recoveryStore.handleDiskAccessException(dae); throw dae; } }