@Override public final synchronized void resetRefCount(NewLRUClockHand lruList) { if (isInUseByTransaction()) { setInUseByTransaction(false); if (lruList != null) { lruList.appendEntry((LRUClockNode)this); } } } /**
protected boolean checkRecentlyUsed(LRUClockNode aNode) { if (aNode.testRecentlyUsed()) { // Throw it back, it's in the working set aNode.unsetRecentlyUsed(); // aNode.setInList(); if (debug) { logWriter.info(LocalizedStrings .NewLRUClockHand_SKIPPING_RECENTLY_USED_ENTRY, aNode); } appendEntry(aNode); return true; } else { return false; } }
@Override public final synchronized void decRefCount(NewLRUClockHand lruList, LocalRegion lr) { if (TXManagerImpl.decRefCount(this)) { if (isInUseByTransaction()) { setInUseByTransaction(false); if (lruList != null) { // No more transactions, place in lru list lruList.appendEntry((LRUClockNode)this); } if (lr != null && lr.isEntryExpiryPossible()) { lr.addExpiryTaskIfAbsent(this); } } } }
/** Called by DiskEntry.Helper.faultInValue */ @Override public final void lruEntryFaultIn(LRUEntry e) { if (logger.isDebugEnabled()) { logger.debug("lruEntryFaultIn for key={} size={}", e.getKey(), e.getEntrySize()); } NewLRUClockHand lruList = _getLruList(); if (_isOwnerALocalRegion()) { DiskRegion disk = _getOwner().getDiskRegion(); boolean possibleClear = disk != null && disk.didClearCountChange(); if (!possibleClear || this._getOwner().basicGetEntry(e.getKey()) == e) { lruEntryUpdate(e); e.unsetEvicted(); lruList.appendEntry(e); } } else { lruEntryUpdate(e); lruList.appendEntry(e); } }
clock.appendEntry( entry ); clock.appendEntry( entry ); Object obj = clock.getLRUEntry(); if ( obj instanceof LRUTestEntry ) {
/** Called by DiskEntry.Helper.faultInValue */ @Override public final void lruEntryFaultIn(LRUEntry e) { if (debug) debugLogging("lruEntryFaultIn for key=" + e.getKeyCopy() + " size=" + e.getEntrySize()); NewLRUClockHand lruList = _getLruList(); if (_isOwnerALocalRegion()) { LocalRegion owner = _getOwner(); DiskRegion disk = owner.getDiskRegion(); boolean possibleClear = disk != null && disk.didClearCountChange(); if (!possibleClear || owner.basicGetEntry(e.getKey()) == e) { lruEntryUpdate(e); e.unsetEvicted(); lruList.appendEntry(e); } } else { lruEntryUpdate(e); lruList.appendEntry(e); } lruList.stats().incFaultins(); }
if (e instanceof DiskEntry) { if (!e.testEvicted()) { lruList.appendEntry(e); lruList.appendEntry(e);
logger.trace(LogMarker.LRU_CLOCK, LocalizedMessage.create(LocalizedStrings.NewLRUClockHand_SKIPPING_RECENTLY_USED_ENTRY, aNode)); appendEntry(aNode); continue; // keep looking
@Override protected final void lruEntryUpdate(RegionEntry re ) { final LRUEntry e = (LRUEntry)re; setDelta(e.updateEntrySize(_getCCHelper())); if (debug) debugLogging("lruEntryUpdate for key=" + re.getKeyCopy() + " size=" + e.getEntrySize()); NewLRUClockHand lruList = _getLruList(); if (_isOwnerALocalRegion()) { LocalRegion owner = _getOwner(); DiskRegion disk = owner.getDiskRegion(); boolean possibleClear = disk != null && disk.didClearCountChange(); if (!possibleClear || owner.basicGetEntry(re.getKey()) == re) { if (e instanceof DiskEntry) { if (!e.testEvicted()) { lruList.appendEntry(e); } } //e.resetRefCount(lruList); } } else { // We are recovering the region so it is a DiskEntry. // Also clear is not yet possible and this entry will be in the region. // No need to call resetRefCount since tx are not yet possible. if (!e.testEvicted()) { lruList.appendEntry(e); } } } @Override
public void testEvicted() throws Exception { NewLRUClockHand clock = getAClockHand( getARegion(), new TestEnableLRU() ); // getLRUEntry( maxScan ) LRUTestEntry[] nodes = new LRUTestEntry[10]; int i = 0; for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); } for( i = 0; i < 10; i += 2 ) { clock.unlinkEntry( nodes[i] ); } // getLRUEntry until empty... verify order of results. for( i = 1; i < 10; i += 2 ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } assertTrue( "expected null", clock.getLRUEntry( ) == null ); }
public void testRemoveHead() throws Exception { NewLRUClockHand clock = getAClockHand( getARegion(), new TestEnableLRU() ); LRUTestEntry[] nodes = new LRUTestEntry[10]; int i = 0; for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); } clock.unlinkEntry(nodes[0]); for( i = 1; i < 10; i ++ ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } assertEquals(null, clock.getLRUEntry( )); }
public void testRemoveTail() throws Exception { NewLRUClockHand clock = getAClockHand( getARegion(), new TestEnableLRU() ); LRUTestEntry[] nodes = new LRUTestEntry[10]; int i = 0; for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); } clock.unlinkEntry(nodes[9]); for( i = 0; i < 9; i ++ ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } assertEquals(null, clock.getLRUEntry( )); }
/** * A unit test for JUnit * * @exception Exception Description of the Exception */ public void testAddToClockFace() throws Exception { NewLRUClockHand clock = getAClockHand( getARegion(), new TestEnableLRU() ); // getLRUEntry( maxScan ) LRUTestEntry[] nodes = new LRUTestEntry[10]; int i = 0; for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); } // getLRUEntry until empty... verify order of results. for( i = 0; i < 10; i++ ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } assertTrue( "expected null", clock.getLRUEntry( ) == null ); }
@Override protected final void lruEntryCreate(RegionEntry re) { LRUEntry e = (LRUEntry)re; // Assert.assertFalse(e._getValue() instanceof DiskEntry.RecoveredEntry) if (logger.isTraceEnabled(LogMarker.LRU)) { logger.trace(LogMarker.LRU, "lruEntryCreate for key={}; list size is: {}; actual size is: {}; map size is: {}; entry size: {}; in lru clock: {}", re.getKey(), getTotalEntrySize(), this._getLruList().getExpensiveListCount(), size(), e.getEntrySize(), !e.testEvicted()); } // this.lruCreatedKey = re.getKey(); // [ bruce ] for DEBUGGING only e.unsetEvicted(); NewLRUClockHand lruList = _getLruList(); DiskRegion disk = _getOwner().getDiskRegion(); boolean possibleClear = disk != null && disk.didClearCountChange(); if(!possibleClear || this._getOwner().basicGetEntry(re.getKey()) == re ) { lruList.appendEntry(e); lruEntryUpdate(e); } }
public void testRemoveMiddle() throws Exception { NewLRUClockHand clock = getAClockHand( getARegion(), new TestEnableLRU() ); LRUTestEntry[] nodes = new LRUTestEntry[10]; int i = 0; for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); } clock.unlinkEntry(nodes[5]); for( i = 0; i < 5; i ++ ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } for( i = 6; i < 10; i ++ ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } assertEquals(null, clock.getLRUEntry( )); }
for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); if ( i % 2 == 0 ) { nodes[i].setRecentlyUsed();
lruList.appendEntry(skipped.get(i));
.NewLRUClockHand_REMOVING_TRANSACTIONAL_ENTRY_FROM_CONSIDERATION); appendEntry(aNode); continue;
@Override protected final void lruEntryCreate(RegionEntry re) { LRUEntry e = (LRUEntry)re; // Assert.assertFalse(e._getValue() instanceof DiskEntry.RecoveredEntry) if ( debug ) { debugLogging( "lruEntryCreate for key=" + re.getKeyCopy() + "; list size is: " + getTotalEntrySize() + "; actual size is: " + this._getLruList().getExpensiveListCount() + "; map size is: " + sizeInVM() + "; entry size: " + e.getEntrySize() + "; in lru clock: " + !e.testEvicted()); } // this.lruCreatedKey = re.getKey(); // [ bruce ] for DEBUGGING only e.unsetEvicted(); NewLRUClockHand lruList = _getLruList(); DiskRegion disk = _getOwner().getDiskRegion(); boolean possibleClear = disk != null && disk.didClearCountChange(); if(!possibleClear || this._getOwner().basicGetEntry(re.getKey()) == re ) { lruList.appendEntry(e); lruEntryUpdate(e); } }
lruList.appendEntry(skipped.get(i)); lruList.appendEntry(skipped.get(i));