/** * Returns a brief description of this capacity controller. * * @since 4.0 */ @Override public String toString() { return LocalizedStrings.LRUCapacityController_LRUCAPACITYCONTROLLER_WITH_A_CAPACITY_OF_0_ENTRIES_AND_EVICTION_ACTION_1.toLocalizedString( new Object[] { Long.valueOf(this.getLimit()), this.getEvictionAction()}); } }
@Override public void setLimit(int max) { setMaximumEntries(max); }
/** * Because an <code>LRUCapacityController</code> is {@link * Declarable}, it can be initialized with properties. The {@link * #MAXIMUM_ENTRIES "maximum-entries"} (case-sensitive) property can * be used to specify the capacity allowed by this controller. * Other properties in props are ignored. The {@link * #EVICTION_ACTION "eviction-action"} property specifies the action * to be taken when the region has reached its capacity. * * @throws NumberFormatException * The <code>maximum-entries</code> property cannot be * parsed as an integer * @throws IllegalArgumentException * The value of the <code>eviction-action</code> property is * not recoginzed. */ public void init(Properties props) throws NumberFormatException { String prop = null; if ( ( prop = props.getProperty( MAXIMUM_ENTRIES ) ) != null ) { this.maximumEntries = Integer.parseInt( prop ); } if ( ( prop = props.getProperty( EVICTION_ACTION ) ) != null ) { setEvictionAction(EvictionAction.parseAction(prop)); } }
/** * Build the appropriate eviction controller using the attributes provided. * * @return the super of the eviction controller or null if no {@link EvictionAction} * is set. * * @see EvictionAttributes */ public LRUAlgorithm createEvictionController(Region region, boolean isOffHeap) { if (this.algorithm == EvictionAlgorithm.LRU_ENTRY) { this.evictionController = new LRUCapacityController(this.maximum, this.action,region); } else if (this.algorithm == EvictionAlgorithm.LRU_HEAP) { this.evictionController = new HeapLRUCapacityController(this.sizer,this.action,region); } else if (this.algorithm == EvictionAlgorithm.LRU_MEMORY) { this.evictionController = new MemLRUCapacityController(this.maximum, this.sizer, this.action,region, isOffHeap); } else if(this.algorithm == EvictionAlgorithm.LIFO_ENTRY){ this.evictionController = new LRUCapacityController(this.maximum, this.action,region); } else if(this.algorithm == EvictionAlgorithm.LIFO_MEMORY){ this.evictionController = new MemLRUCapacityController(this.maximum, this.sizer, this.action,region, isOffHeap); } else { // for all other algorithms, return null this.evictionController = null; } return this.evictionController; }
/** * Because an <code>LRUCapacityController</code> is {@link * Declarable}, it can be initialized with properties. The {@link * #MAXIMUM_ENTRIES "maximum-entries"} (case-sensitive) property can * be used to specify the capacity allowed by this controller. * Other properties in props are ignored. The {@link * #EVICTION_ACTION "eviction-action"} property specifies the action * to be taken when the region has reached its capacity. * * @throws NumberFormatException * The <code>maximum-entries</code> property cannot be * parsed as an integer * @throws IllegalArgumentException * The value of the <code>eviction-action</code> property is * not recoginzed. */ public void init(Properties props) throws NumberFormatException { String prop = null; if ( ( prop = props.getProperty( MAXIMUM_ENTRIES ) ) != null ) { this.maximumEntries = Integer.parseInt( prop ); } if ( ( prop = props.getProperty( EVICTION_ACTION ) ) != null ) { setEvictionAction(EvictionAction.parseAction(prop)); } }
/** * Build the appropriate eviction controller using the attributes provided. * * @return the super of the eviction controller or null if no {@link EvictionAction} * is set. * * @see EvictionAttributes */ public LRUAlgorithm createEvictionController(Region region, boolean isOffHeap) { if (this.algorithm == EvictionAlgorithm.LRU_ENTRY) { this.evictionController = new LRUCapacityController(this.maximum, this.action,region); } else if (this.algorithm == EvictionAlgorithm.LRU_HEAP) { this.evictionController = new HeapLRUCapacityController(this.sizer,this.action,region); } else if (this.algorithm == EvictionAlgorithm.LRU_MEMORY) { this.evictionController = new MemLRUCapacityController(this.maximum, this.sizer, this.action,region, isOffHeap); } else if(this.algorithm == EvictionAlgorithm.LIFO_ENTRY){ this.evictionController = new LRUCapacityController(this.maximum, this.action,region); } else if(this.algorithm == EvictionAlgorithm.LIFO_MEMORY){ this.evictionController = new MemLRUCapacityController(this.maximum, this.sizer, this.action,region, isOffHeap); } else { // for all other algorithms, return null this.evictionController = null; } return this.evictionController; }
/** * Returns a brief description of this capacity controller. * * @since 4.0 */ @Override public String toString() { return LocalizedStrings.LRUCapacityController_LRUCAPACITYCONTROLLER_WITH_A_CAPACITY_OF_0_ENTRIES_AND_EVICTION_ACTION_1.toLocalizedString( new Object[] { Long.valueOf(this.getLimit()), this.getEvictionAction()}); } }
@Override public void setLimit(int max) { setMaximumEntries(max); }
/** * Creates an LRU capacity controller that allows the given number of maximum * entries. * * @param maximumEntries * The maximum number of entries allowed in the region whose * capacity this controller controls. Once there are * <code>capacity</code> entries in a region, this controller * will remove the least recently used entry.<br> * <p> * For a region with {@link DataPolicy#PARTITION}, the maximum * number of entries allowed in the region, collectively for * its primary buckets and redundant copies for this VM. After * there are <code>capacity</code> entries in the region's * primary buckets and redundant copies for this VM, this * controller will remove the least recently used entry from * the bucket in which the subsequent <code>put</code> takes * place. * @param evictionAction * The action to perform upon the least recently used entry. * See {@link #EVICTION_ACTION}. */ public LRUCapacityController(int maximumEntries, EvictionAction evictionAction,Region region) { super(evictionAction,region); setMaximumEntries(maximumEntries); }
/** * Creates an LRU capacity controller that allows the given number of maximum * entries. * * @param maximumEntries * The maximum number of entries allowed in the region whose * capacity this controller controls. Once there are * <code>capacity</code> entries in a region, this controller * will remove the least recently used entry.<br> * <p> * For a region with {@link DataPolicy#PARTITION}, the maximum * number of entries allowed in the region, collectively for * its primary buckets and redundant copies for this VM. After * there are <code>capacity</code> entries in the region's * primary buckets and redundant copies for this VM, this * controller will remove the least recently used entry from * the bucket in which the subsequent <code>put</code> takes * place. * @param evictionAction * The action to perform upon the least recently used entry. * See {@link #EVICTION_ACTION}. */ public LRUCapacityController(int maximumEntries, EvictionAction evictionAction,Region region) { super(evictionAction,region); setMaximumEntries(maximumEntries); }