/** * All entries for the LRUCapacityController are * considered to be of size 1. */ public int entrySize( Object key, Object value ) throws IllegalArgumentException { if (Token.isRemoved(value) /*&& (value != Token.TOMBSTONE)*/) { // un-comment to make tombstones visible // bug #42228 - lruEntryDestroy removes an entry from the LRU, but if // it is subsequently resurrected we want the new entry to generate a delta return 0; } if ((value == null /* overflow to disk */ || value == Token.INVALID || value == Token.LOCAL_INVALID) && getEvictionAction().isOverflowToDisk()) { // Don't count this guys toward LRU return 0; } else { return 1; } }
/** * Broken-out so that it can be overridden */ protected int handleLocalDestroy(LRUEntry entry) { assert _getCCHelper().getEvictionAction().isLocalDestroy(); int size = entry.getEntrySize(); if (_getOwner().evictDestroy(entry)) { return size; } else { return 0; } }
expirationAttrs.toString()); if (evictAttrs != null && !evictAttrs.getAction().isNone()) { evictionStr = evictAttrs.toString(); if (evictAttrs.getAction().isOverflowToDisk()) { isOverflow = true;
EvictionAction action = _getCCHelper().getEvictionAction(); LocalRegion region = _getOwner(); if (action.isLocalDestroy()) { int size = entry.getEntrySize(); if (region.evictDestroy(entry)) { return 0; } else if (action.isOverflowToDisk()) { Assert.assertTrue(entry instanceof DiskEntry); int change = 0;
@Override public Properties getProperties() { Properties props = new Properties(); if (this.evictionAction != EvictionAction.DEFAULT_EVICTION_ACTION) { props.setProperty(EVICTION_ACTION, this.evictionAction.toString()); } if (this.maximumEntries != DEFAULT_MAXIMUM_ENTRIES) { props.setProperty(MAXIMUM_ENTRIES, String.valueOf(this.maximumEntries)); } return props; }
/** * The 3rd step of EvictionAttributes validation, where mutation is acceptible * This should be done before buckets are created. Validate EvictionAttributes * with respect to localMaxMemory potentially changing the eviction * attributes. * * @see AttributesFactory#validateAttributes(RegionAttributes) * @see #validateDistributedEvictionAttributes(EvictionAttributes) */ void validateEvictionAttributesAgainstLocalMaxMemory() { final EvictionAttributes ea = pr.getEvictionAttributes(); if (pr.getLocalMaxMemory()==0 && !ea.getAction().isNone()) { // This is an accessor which won't ever do eviction, say so logger.info(LocalizedMessage.create( LocalizedStrings.PartitionedRegion_EVICTIONATTRIBUTES_0_WILL_HAVE_NO_EFFECT_1_2, new Object[] { ea, pr.getFullPath(), Integer.valueOf(pr.localMaxMemory)})); } }
/** * Create an <code>lru-heap-percentage</code> eviction controller, assigning * it to the enclosed <code>region-attributes</code> * @param atts */ private void startLRUHeapPercentage(Attributes atts) { final String lruAction = atts.getValue(ACTION); EvictionAction action = EvictionAction.DEFAULT_EVICTION_ACTION; if (lruAction != null) { action = EvictionAction.parseAction(lruAction); } // Store for later addition of ObjectSizer, if any stack.push(EvictionAttributes.createLRUHeapAttributes(null, action)); }
lruAction = (byte)EvictionAction.NONE.getValue(); lruLimit = 0; } else if (ea.isLRUHeap()) { EvictionAction ea = EvictionAction.parseAction(lruActionOption); if (ea != null) { lruAction = (byte)ea.getValue(); } else { throw new IllegalArgumentException("Expected lruAction to be one of the following: \"none\", \"overflow-to-disk\", or \"local-destroy\"");
@Override public int hashCode() { return this.evictionAction.hashCode(); }
public EvictionAction getActualLruAction() { return EvictionAction.parseValue(getLruAction()); } public int getLruLimit() {
byte raLruAction = (byte)(ra.getEvictionAttributes().getAction().getValue()); int raLruLimit = 0; if (!ra.getEvictionAttributes().getAlgorithm().isLRUHeap()) {
"IllegalStateException</ExpectedException>"); assertTrue(firstEa.getAlgorithm().isLRUEntry()); assertTrue(!firstEa.getAction().isOverflowToDisk()); factory.setEvictionAttributes(EvictionAttributes .createLRUEntryAttributes(maxEntries, "IllegalStateException</ExpectedException>"); assertTrue(firstEa.getAlgorithm().isLRUEntry()); assertTrue(!firstEa.getAction().isNone()); factory.setEvictionAttributes(EvictionAttributes .createLRUEntryAttributes(maxEntries, EvictionAction.NONE));
EvictionAction action = _getCCHelper().getEvictionAction(); LocalRegion region = _getOwner(); if (action.isLocalDestroy()) { return handleLocalDestroy(entry); } else if (action.isOverflowToDisk()) { Assert.assertTrue(entry instanceof DiskEntry); int change = 0;
@Override public Properties getProperties() { Properties props = new Properties(); if (this.evictionAction != EvictionAction.DEFAULT_EVICTION_ACTION) { props.setProperty(EVICTION_ACTION, this.evictionAction.toString()); } if (this.maximumEntries != DEFAULT_MAXIMUM_ENTRIES) { props.setProperty(MAXIMUM_ENTRIES, String.valueOf(this.maximumEntries)); } return props; }
/** * The 3rd step of EvictionAttributes validation, where mutation is acceptible * This should be done before buckets are created. Validate EvictionAttributes * with respect to localMaxMemory potentially changing the eviction * attributes. * * @see AttributesFactory#validateAttributes(RegionAttributes) * @see #validateDistributedEvictionAttributes(EvictionAttributes) */ void validateEvictionAttributesAgainstLocalMaxMemory() { final EvictionAttributes ea = pr.getEvictionAttributes(); if (pr.getLocalMaxMemory()==0 && !ea.getAction().isNone()) { // This is an accessor which won't ever do eviction, say so pr.logger.info( LocalizedStrings. PartitionedRegion_EVICTIONATTRIBUTES_0_WILL_HAVE_NO_EFFECT_1_2, new Object[] { ea, pr.getFullPath(), Integer.valueOf(pr.localMaxMemory)}); } }
/** * Create an <code>lru-heap-percentage</code> eviction controller, assigning * it to the enclosed <code>region-attributes</code> * @param atts */ private void startLRUHeapPercentage(Attributes atts) { final String lruAction = atts.getValue(ACTION); EvictionAction action = EvictionAction.DEFAULT_EVICTION_ACTION; if (lruAction != null) { action = EvictionAction.parseAction(lruAction); } // Store for later addition of ObjectSizer, if any stack.push(EvictionAttributes.createLRUHeapAttributes(null, action)); }
lruAction = (byte)EvictionAction.NONE.getValue(); lruLimit = 0; } else if (ea.isLRUHeap()) { EvictionAction ea = EvictionAction.parseAction(lruActionOption); if (ea != null) { lruAction = (byte)ea.getValue(); } else { throw new IllegalArgumentException("Expected lruAction to be one of the following: \"none\", \"overflow-to-disk\", or \"local-destroy\"");
@Override public int hashCode() { return this.evictionAction.hashCode(); }
public EvictionAction getActualLruAction() { return EvictionAction.parseValue(getLruAction()); } public int getLruLimit() {