Search in sources :

Example 1 with LRUAlgorithm

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));
    }
}
Also used : HeapLRUCapacityController(org.apache.geode.internal.cache.lru.HeapLRUCapacityController) LRUAlgorithm(org.apache.geode.internal.cache.lru.LRUAlgorithm) MemLRUCapacityController(org.apache.geode.internal.cache.lru.MemLRUCapacityController) NewLIFOClockHand(org.apache.geode.internal.cache.lru.NewLIFOClockHand) NewLRUClockHand(org.apache.geode.internal.cache.lru.NewLRUClockHand) EvictionAlgorithm(org.apache.geode.cache.EvictionAlgorithm)

Example 2 with LRUAlgorithm

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);
}
Also used : LRUAlgorithm(org.apache.geode.internal.cache.lru.LRUAlgorithm) EvictionAttributesImpl(org.apache.geode.internal.cache.EvictionAttributesImpl) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) PartitionedRegionDataStore(org.apache.geode.internal.cache.PartitionedRegionDataStore) PartitionedRegionStats(org.apache.geode.internal.cache.PartitionedRegionStats)

Example 3 with LRUAlgorithm

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;
}
Also used : LRUAlgorithm(org.apache.geode.internal.cache.lru.LRUAlgorithm) LRUStatistics(org.apache.geode.internal.cache.lru.LRUStatistics) StatisticsFactory(org.apache.geode.StatisticsFactory)

Aggregations

LRUAlgorithm (org.apache.geode.internal.cache.lru.LRUAlgorithm)3 StatisticsFactory (org.apache.geode.StatisticsFactory)1 EvictionAlgorithm (org.apache.geode.cache.EvictionAlgorithm)1 EvictionAttributesImpl (org.apache.geode.internal.cache.EvictionAttributesImpl)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 PartitionedRegionDataStore (org.apache.geode.internal.cache.PartitionedRegionDataStore)1 PartitionedRegionStats (org.apache.geode.internal.cache.PartitionedRegionStats)1 HeapLRUCapacityController (org.apache.geode.internal.cache.lru.HeapLRUCapacityController)1 LRUStatistics (org.apache.geode.internal.cache.lru.LRUStatistics)1 MemLRUCapacityController (org.apache.geode.internal.cache.lru.MemLRUCapacityController)1 NewLIFOClockHand (org.apache.geode.internal.cache.lru.NewLIFOClockHand)1 NewLRUClockHand (org.apache.geode.internal.cache.lru.NewLRUClockHand)1