if (algorithm.isNone()) { return null; // rely on the product to reset else if (algorithm.isLRUEntry()) { return EvictionAttributes.createLRUEntryAttributes( else if (algorithm.isLRUHeap()) { return EvictionAttributes.createLRUHeapAttributes( else if (algorithm.isLRUMemory()) { return EvictionAttributes.createLRUMemoryAttributes(
Object expectedValue = info.evictionAttr.getAlgorithm().toString(); verifyValue(expectedValue, methodName, attr, null); expectedInToString.add("algorithm=" + expectedValue); if (!info.evictionAttr.getAlgorithm().isNone()) { // if the algorithm is set then we want to see action in the result of toString expectedInToString.add("action=" + expectedValue); EvictionAlgorithm algorithm = info.evictionAttr.getAlgorithm(); expectedValue = null; if (algorithm.isLRUEntry() || algorithm.isLRUMemory()) { expectedValue = info.evictionAttr.getMaximum(); expectedInToString.add("maximum=" + expectedValue);
/** returns true if this object uses a least-recently-used algorithm */ public boolean isLRU() { return this.isLRUEntry() || this.isLRUMemory() || this.isLRUHeap(); }
@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(); }
private final int getKeySize(Object key, EnableLRU capacityController) { final GemFireCacheImpl.StaticSystemCallbacks sysCb = GemFireCacheImpl.getInternalProductCallbacks(); if (sysCb == null || capacityController.getEvictionAlgorithm().isLRUEntry()) { return capacityController.entrySize(key, null); } else { int tries = 1; do { final int size = sysCb.entryKeySizeInBytes(key, this); if (size >= 0) { return size - ReflectionSingleObjectSizer.REFERENCE_SIZE; } if ((tries % MAX_READ_TRIES_YIELD) == 0) { Thread.yield(); } } while (tries++ <= MAX_READ_TRIES); throw sysCb.checkCacheForNullKeyValue("DiskLRU RegionEntry#getKeySize"); } } private void diskInitialize(RegionEntryContext context, Object value) {
.setRedundantCopies(totalNoOfBuckets == 4 ? 0 : 1).setTotalNumBuckets( totalNoOfBuckets); if (evictionAlgorithm.isLRUMemory()) partitionAttributesFactory.setLocalMaxMemory(maxEnteries); if (evictionAlgorithm.isLRUHeap()) { factory.setEvictionAttributes(EvictionAttributes .createLRUHeapAttributes(null, : EvictionAction.OVERFLOW_TO_DISK)); else if (evictionAlgorithm.isLRUMemory()) {
public Object call() throws Exception { try { final PartitionedRegion pr = (PartitionedRegion)getRootRegion(name); assertNotNull(pr); long entriesEvicted = 0; for (final Iterator i = pr.getDataStore().getAllLocalBuckets() .iterator(); i.hasNext();) { final Map.Entry entry = (Map.Entry)i.next(); final BucketRegion bucketRegion = (BucketRegion)entry.getValue(); if (bucketRegion == null) { continue; } assertTrue(bucketRegion.getAttributes().getEvictionAttributes() .getAlgorithm().isLRUMemory()); assertTrue(bucketRegion.getAttributes().getEvictionAttributes() .getAction().isLocalDestroy()); } entriesEvicted = ((AbstractLRURegionMap)pr.entries)._getLruList().stats() .getEvictions(); return new Long(entriesEvicted); } finally { } } };
EvictionAlgorithm ea = EvictionAlgorithm.parseAction(lruOption); if (ea != null) { lruAlgorithm = (byte)ea.getValue(); } else { throw new IllegalArgumentException("Expected lru to be one of the following: \"none\", \"lru-entry-count\", \"lru-heap-percentage\", or \"lru-memory-size\""); if (ea.isNone()) { lruAction = (byte)EvictionAction.NONE.getValue(); lruLimit = 0; } else if (ea.isLRUHeap()) { lruLimit = 0;
if (attrs.getPartitionAttributes() != null && this.evictionAttributes != null && this.evictionAttributes.getAlgorithm().isLRUMemory() && attrs.getPartitionAttributes().getLocalMaxMemory() != 0 && this.evictionAttributes.getMaximum() != attrs && !this.evictionAttributes.getAlgorithm().isNone()) { this.setEvictionController(this.evictionAttributes .createEvictionController(this, attrs.getOffHeap()));
if (drv.isBucket() && !drv.getActualLruAlgorithm().isNone()) { drv.prlruStats = getDiskStore().getOrCreatePRLRUStats(drv);
@Override public int getMaximum() { if (this.algorithm.isLRUHeap()) { throw new UnsupportedOperationException("LRUHeap does not support a maximum"); } return this.maximum; }
@Override public String toString() { final StringBuilder buffer = new StringBuilder(128); buffer.append("EvictionAttributesData ["); buffer.append("algorithm=").append(this.getAlgorithm()); if (!this.getAlgorithm().equals(EvictionAlgorithm.NONE.toString())) { buffer.append(", action=").append(this.getAction()); if (!this.getAlgorithm().equals(EvictionAlgorithm.LRU_HEAP.toString())) { buffer.append(", maximum=").append(this.getMaximum()); } } buffer.append("]"); return buffer.toString(); }
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; }
/** * Returns true if this object uses a LIFO algorithm * * @since 5.7 */ public boolean isLIFO() { return this.algorithm.isLIFO(); }
if (ev != null && ev.getAlgorithm().isLRU()) { EvictionAttributes rev = new EvictionAttributesImpl( (EvictionAttributesImpl)ev ); af.setEvictionAttributes( rev );
@Override public final int hashCode() { return this.getAlgorithm().hashCode() ^ this.getMaximum(); }
@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(); }
private final int getKeySize(Object key, EnableLRU capacityController) { final GemFireCacheImpl.StaticSystemCallbacks sysCb = GemFireCacheImpl.getInternalProductCallbacks(); if (sysCb == null || capacityController.getEvictionAlgorithm().isLRUEntry()) { return capacityController.entrySize(key, null); } else { int tries = 1; do { final int size = sysCb.entryKeySizeInBytes(key, this); if (size >= 0) { return size - ReflectionSingleObjectSizer.REFERENCE_SIZE; } if ((tries % MAX_READ_TRIES_YIELD) == 0) { Thread.yield(); } } while (tries++ <= MAX_READ_TRIES); throw sysCb.checkCacheForNullKeyValue("DiskLRU RegionEntry#getKeySize"); } } private void diskInitialize(RegionEntryContext context, Object value) {