use of org.apache.geode.internal.cache.lru.LRUAlgorithm in project geode by apache.
the class AbstractLRURegionMap method initialize.
protected void initialize(Object owner, Attributes attr, InternalRegionArguments internalRegionArgs) {
super.initialize(owner, attr, internalRegionArgs, true);
EvictionAlgorithm ea;
LRUAlgorithm ec;
if (owner instanceof LocalRegion) {
ea = ((LocalRegion) owner).getEvictionAttributes().getAlgorithm();
ec = ((LocalRegion) owner).getEvictionController();
} else if (owner instanceof PlaceHolderDiskRegion) {
PlaceHolderDiskRegion phdr = (PlaceHolderDiskRegion) owner;
ea = phdr.getActualLruAlgorithm();
ec = phdr.getEvictionAttributes().createEvictionController(null, phdr.getOffHeap());
} else {
throw new IllegalStateException("expected LocalRegion or PlaceHolderDiskRegion");
}
this.evictionController = ec;
if (ea.isLRUMemory()) {
((MemLRUCapacityController) ec).setEntryOverHead(getEntryOverHead());
}
if (ea.isLRUHeap()) {
((HeapLRUCapacityController) ec).setEntryOverHead(getEntryOverHead());
}
_setCCHelper(getHelper(ec));
/*
* modification for LIFO Logic incubation
*
*/
if (ea == EvictionAlgorithm.LIFO_ENTRY || ea == EvictionAlgorithm.LIFO_MEMORY) {
_setLruList(new NewLIFOClockHand(owner, _getCCHelper(), internalRegionArgs));
} else {
_setLruList(new NewLRUClockHand(owner, _getCCHelper(), internalRegionArgs));
}
}
use of org.apache.geode.internal.cache.lru.LRUAlgorithm in project geode by apache.
the class ParallelQueueRemovalMessageJUnitTest method createQueueRegion.
private void createQueueRegion() {
// Mock queue region
this.queueRegion = mock(PartitionedRegion.class);
when(this.queueRegion.getFullPath()).thenReturn(getRegionQueueName());
when(this.queueRegion.getPrStats()).thenReturn(mock(PartitionedRegionStats.class));
when(this.queueRegion.getDataStore()).thenReturn(mock(PartitionedRegionDataStore.class));
when(this.queueRegion.getCache()).thenReturn(this.cache);
EvictionAttributesImpl ea = (EvictionAttributesImpl) EvictionAttributes.createLRUMemoryAttributes(100, null, EvictionAction.OVERFLOW_TO_DISK);
LRUAlgorithm algorithm = ea.createEvictionController(this.queueRegion, false);
algorithm.getLRUHelper().initStats(this.queueRegion, this.cache.getDistributedSystem());
when(this.queueRegion.getEvictionController()).thenReturn(algorithm);
}
use of org.apache.geode.internal.cache.lru.LRUAlgorithm in project geode by apache.
the class DiskStoreImpl method getOrCreatePRLRUStats.
LRUStatistics getOrCreatePRLRUStats(PlaceHolderDiskRegion dr) {
String prName = dr.getPrName();
LRUStatistics result = null;
synchronized (this.prlruStatMap) {
result = this.prlruStatMap.get(prName);
if (result == null) {
EvictionAttributesImpl ea = dr.getEvictionAttributes();
LRUAlgorithm ec = ea.createEvictionController(null, dr.getOffHeap());
StatisticsFactory sf = cache.getDistributedSystem();
result = ec.getLRUHelper().initStats(dr, sf);
this.prlruStatMap.put(prName, result);
}
}
return result;
}
Aggregations