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"); } }
/** * All entries for the LRUCapacityController are considered to be of size 1. */ @Override public int entrySize(Object key, Object value) { if (Token.isRemoved(value)) { // 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 entry toward LRU return 0; } else { return 1; } }
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(); }
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(
EvictionAction action = getEvictionController().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;
/** * Create an <code>lru-heap-percentage</code> eviction controller, assigning it to the enclosed * <code>region-attributes</code> * */ 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)); }
public EvictionAction getActualLruAction() { return EvictionAction.parseValue(getLruAction()); }
/** * 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( "EvictionAttributes {} will have no effect for Partitioned Region {} on this VM because localMaxMemory is {}.", new Object[] {ea, pr.getFullPath(), Integer.valueOf(pr.localMaxMemory)}); } }
byte raLruAction = (byte) (ra.getEvictionAttributes().getAction().getValue()); int raLruLimit = ra.getEvictionAttributes().getMaximum(); if (isRecreated()) {
/** * Start the configuration of a <code>lru-memory-size</code> eviction controller. Allow for any of * the attributes to be missing. Store the attributes on the stack anticipating the declaration of * an {@link ObjectSizer}. * */ private void startLRUMemorySize(Attributes atts) { String lruAction = atts.getValue(ACTION); EvictionAction action = EvictionAction.DEFAULT_EVICTION_ACTION; if (lruAction != null) { action = EvictionAction.parseAction(lruAction); } String maximum = atts.getValue(MAXIMUM); int max = EvictionAttributes.DEFAULT_MEMORY_MAXIMUM; if (maximum != null) { max = parseInt(maximum); } // Store for later addition of ObjectSizer, if any (the cast is for clarity sake) stack.push(EvictionAttributes.createLRUMemoryAttributes(max, null, action)); }
private boolean isOverflowEnabled() { EvictionAttributes ea = getAttributes().getEvictionAttributes(); return ea != null && ea.getAction().isOverflowToDisk(); }
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(); }
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; }
/** * Create an <code>lru-entry-count</code> eviction controller, assigning it to the enclosed * <code>region-attributes</code>. Allow any combination of attributes to be provided. Use the * default values for any attribute that is not provided. * */ private void startLRUEntryCount(Attributes atts) { final String maximum = atts.getValue(MAXIMUM); int max = EvictionAttributes.DEFAULT_ENTRIES_MAXIMUM; if (maximum != null) { max = parseInt(maximum); } final String lruAction = atts.getValue(ACTION); EvictionAction action = EvictionAction.DEFAULT_EVICTION_ACTION; if (lruAction != null) { action = EvictionAction.parseAction(lruAction); } RegionAttributesCreation regAttrs = peekRegionAttributesContext(LRU_ENTRY_COUNT); regAttrs.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(max, action)); }
@Override public void run2() throws CacheException { RegionAttributes<Object, Object> ra = getRegionAttributes(); AttributesFactory<Object, Object> factory = new AttributesFactory<>(ra); if (ra.getEvictionAttributes() == null || !ra.getEvictionAttributes().getAction().isOverflowToDisk()) { factory.setDiskStoreName(null); } factory.setDataPolicy(DataPolicy.REPLICATE); factory.addCacheListener(new MirroredDataFromNonMirroredListener()); createRegion(name, factory.create()); } });
new RegionAttributesType.EvictionAttributes(); EnumActionDestroyOverflow action = EnumActionDestroyOverflow.fromValue(this.getAction() .toString()); EvictionAlgorithm algorithm = getAlgorithm(); Optional<String> objectSizerClass = Optional.ofNullable(getObjectSizer())
if (ea.getAction().isLocalDestroy()) {
public EvictionAttributes convertToEvictionAttributes() { EvictionAction action = EvictionAction.parseAction(evictionAction); ObjectSizer sizer; if (objectSizer != null) { try { Class<ObjectSizer> sizerClass = (Class<ObjectSizer>) ClassPathLoader.getLatest().forName(objectSizer); sizer = sizerClass.newInstance(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException( "Unable to instantiate class " + objectSizer + " - " + e.toString()); } } else { sizer = ObjectSizer.DEFAULT; } if (maxMemory == null && maxEntryCount == null) { return EvictionAttributes.createLRUHeapAttributes(sizer, action); } else if (maxMemory != null) { return EvictionAttributes.createLRUMemoryAttributes(maxMemory, sizer, action); } else { return EvictionAttributes.createLRUEntryAttributes(maxEntryCount, action); } } }
@Override public void run2() throws CacheException { RegionAttributes<Object, Object> ra = getRegionAttributes(); AttributesFactory<Object, Object> factory = new AttributesFactory<>(ra); if (ra.getEvictionAttributes() == null || !ra.getEvictionAttributes().getAction().isOverflowToDisk()) { factory.setDiskStoreName(null); } factory.setDataPolicy(DataPolicy.REPLICATE); createRegion(name, factory.create()); } });