CacheAccessor Class Reference

CacheAccessor defines the subset of the Cache interface used for accessing cache pages. More...

#include <CacheAccessor.h>

Inheritance diagram for CacheAccessor:

Cache DelegatingCacheAccessor ScratchSegment CacheImpl< PageT, VictimPolicyT > TransactionalCacheAccessor QuotaCacheAccessor List of all members.

Public Member Functions

virtual ~CacheAccessor ()
virtual CachePagelockPage (BlockId blockId, LockMode lockMode, bool readIfUnmapped=true, MappedPageListener *pMappedPageListener=NULL, TxnId txnId=IMPLICIT_TXN_ID)=0
 Locks a page into memory with the specified concurrency mode.
virtual void unlockPage (CachePage &page, LockMode lockMode, TxnId txnId=IMPLICIT_TXN_ID)=0
 Releases lock held on page.
virtual void discardPage (BlockId blockId)=0
 Unmaps a page from the cache if already mapped, discarding its contents if dirty.
virtual bool prefetchPage (BlockId blockId, MappedPageListener *pMappedPageListener=NULL)=0
 Hints that a page should be prefetched in preparation for a future lock request.
virtual void prefetchBatch (BlockId blockId, uint nPages, MappedPageListener *pMappedPageListener=NULL)=0
 Hints that a contiguous run of pages should be prefetched.
virtual void flushPage (CachePage &page, bool async)=0
 Forces the contents of a dirty page to its mapped location.
virtual void nicePage (CachePage &page)=0
 Marks a page as nice, indicating that it is very unlikely the page's mapping will be needed again any time soon, so it is a good candidate for victimization.
virtual uint getMaxLockedPages ()=0
 
Returns:
the page lock quota on this accessor

virtual void setMaxLockedPages (uint nPages)=0
 Sets the page lock quota on this accessor.
virtual SharedCache getCache ()=0
 
Returns:
the underlying Cache accessed by this CacheAccessor

virtual void setTxnId (TxnId txnId)=0
 Sets a default TxnId to use for locking pages (to be used when IMPLICIT_TXN_ID is specified).
virtual TxnId getTxnId () const=0
 
Returns:
default TxnId associated with this accessor

virtual void getPrefetchParams (uint &prefetchPagesMax, uint &prefetchThrottleRate)=0
 Retrieves the current pre-fetch caching parameters that determine how many pages should be pre-fetched and how often the pre-fetches should occur.

Detailed Description

CacheAccessor defines the subset of the Cache interface used for accessing cache pages.

This allows page usage to be associated with particular consumers such as connections, algorithms, etc. The Cache interface is derived from CacheAccessor, so any Cache implementation can alway be used directly as a vanilla CacheAccessor.

Definition at line 41 of file CacheAccessor.h.


Constructor & Destructor Documentation

CacheAccessor::~CacheAccessor (  )  [virtual]

Definition at line 38 of file Cache.cpp.

00039 {
00040 }


Member Function Documentation

virtual CachePage* CacheAccessor::lockPage ( BlockId  blockId,
LockMode  lockMode,
bool  readIfUnmapped = true,
MappedPageListener pMappedPageListener = NULL,
TxnId  txnId = IMPLICIT_TXN_ID 
) [pure virtual]

Locks a page into memory with the specified concurrency mode.

When the page contents are no longer needed, the caller must invoke the unlockPage() method with the same concurrency mode to release it. If the desired page is already locked by another thread with an incompatible concurrency mode, blocks until the page becomes available (unless the lock mode is of the NoWait variety, in which case returns NULL immediately). Note that NoWait locking only applies to lock contention, not I/O, so if an unmapped page is locked in NoWait mode, blocks until the read completes.

The device referenced by the requested blockId must already be registered with the cache and must remain registered for the duration of the lock.

Notes on concurrency modes:

Parameters:
blockId the BlockId of the page to be locked
lockMode the desired concurrency mode
readIfUnmapped if true (the default) the page data is read as part of mapping; if false, the page data is left invalid until first write (used when allocating a new block with invalid contents)
pMappedPageListener optional listener to receive notifications when this page is written; if specified, it must match all prior and subsequent lock requests for the same page mapping
txnId optional TxnId to associate with lock; default is IMPLICIT_TXN_ID, which uses current thread ID as an implicit TxnId
Returns:
the locked CachePage, or NULL if a NoWait attempt failed

Implemented in CacheImpl< PageT, VictimPolicyT >, DelegatingCacheAccessor, QuotaCacheAccessor, TransactionalCacheAccessor, and ScratchSegment.

Referenced by CacheTest::lockPage().

virtual void CacheAccessor::unlockPage ( CachePage page,
LockMode  lockMode,
TxnId  txnId = IMPLICIT_TXN_ID 
) [pure virtual]

Releases lock held on page.

Parameters:
page the page to be unlocked
lockMode must correspond to value passed to Cache::lockPage; however, for pages locked with NOWAIT, the equivalent unlock type should be normal (e.g. LOCKMODE_S instead of LOCKMODE_S_NOWAIT)
txnId must correspond to value passed to Cache::lockPage

Implemented in CacheImpl< PageT, VictimPolicyT >, DelegatingCacheAccessor, QuotaCacheAccessor, TransactionalCacheAccessor, and ScratchSegment.

Referenced by PagingTestBase::testScratch(), SegmentTestBase::unlockPage(), and CacheTest::unlockPage().

virtual void CacheAccessor::discardPage ( BlockId  blockId  )  [pure virtual]

Unmaps a page from the cache if already mapped, discarding its contents if dirty.

The caller must ensure that no other thread has the page locked.

Parameters:
blockId the BlockId of the page to be discarded

Implemented in CacheImpl< PageT, VictimPolicyT >, DelegatingCacheAccessor, and ScratchSegment.

virtual bool CacheAccessor::prefetchPage ( BlockId  blockId,
MappedPageListener pMappedPageListener = NULL 
) [pure virtual]

Hints that a page should be prefetched in preparation for a future lock request.

Parameters:
blockId the BlockId of the page to be prefetched
pMappedPageListener optional listener to receive notifications when this page is written; if specified, it must match all prior and subsequent lock requests for the same page mapping
Returns:
true if the pre-fetch request was successful

Implemented in CacheImpl< PageT, VictimPolicyT >, DelegatingCacheAccessor, and ScratchSegment.

Referenced by SegmentTestBase::prefetchPage(), and CacheTest::prefetchPage().

virtual void CacheAccessor::prefetchBatch ( BlockId  blockId,
uint  nPages,
MappedPageListener pMappedPageListener = NULL 
) [pure virtual]

Hints that a contiguous run of pages should be prefetched.

Parameters:
blockId the BlockId of the first page to be prefetched; more will be prefetched depending on the configured batch size
nPages number of pages in batch
pMappedPageListener optional listener to receive notifications when this page is written; if specified, it must match all prior and subsequent lock requests for the same page mapping

Implemented in CacheImpl< PageT, VictimPolicyT >, DelegatingCacheAccessor, and ScratchSegment.

Referenced by CacheTest::prefetchBatch().

virtual void CacheAccessor::flushPage ( CachePage page,
bool  async 
) [pure virtual]

Forces the contents of a dirty page to its mapped location.

Page must already be locked in exclusive mode. For an asynchronous flush, the caller must ensure that the page contents remain unchanged until the flush completes.

Parameters:
page the page to be flushed
async true to schedle async write and return immediately; false to wait for write to complete

Implemented in CacheImpl< PageT, VictimPolicyT >, DelegatingCacheAccessor, and ScratchSegment.

virtual void CacheAccessor::nicePage ( CachePage page  )  [pure virtual]

Marks a page as nice, indicating that it is very unlikely the page's mapping will be needed again any time soon, so it is a good candidate for victimization.

Parameters:
page the page to be marked

Implemented in CacheImpl< PageT, VictimPolicyT >, DelegatingCacheAccessor, and ScratchSegment.

Referenced by PagingTestBase::testOp().

virtual uint CacheAccessor::getMaxLockedPages (  )  [pure virtual]

Returns:
the page lock quota on this accessor

Implemented in Cache, DelegatingCacheAccessor, QuotaCacheAccessor, and ScratchSegment.

virtual void CacheAccessor::setMaxLockedPages ( uint  nPages  )  [pure virtual]

Sets the page lock quota on this accessor.

Ignored for accessor implementations that don't support quotas.

Parameters:
nPages new quota

Implemented in Cache, DelegatingCacheAccessor, QuotaCacheAccessor, and ScratchSegment.

virtual SharedCache CacheAccessor::getCache (  )  [pure virtual]

Returns:
the underlying Cache accessed by this CacheAccessor

Implemented in Cache, DelegatingCacheAccessor, and ScratchSegment.

virtual void CacheAccessor::setTxnId ( TxnId  txnId  )  [pure virtual]

Sets a default TxnId to use for locking pages (to be used when IMPLICIT_TXN_ID is specified).

Not all CacheAccessor implementations support this behavior.

Parameters:
txnId new default txn ID

Implemented in Cache, DelegatingCacheAccessor, TransactionalCacheAccessor, and ScratchSegment.

virtual TxnId CacheAccessor::getTxnId (  )  const [pure virtual]

Returns:
default TxnId associated with this accessor

Implemented in Cache, DelegatingCacheAccessor, TransactionalCacheAccessor, and ScratchSegment.

virtual void CacheAccessor::getPrefetchParams ( uint prefetchPagesMax,
uint prefetchThrottleRate 
) [pure virtual]

Retrieves the current pre-fetch caching parameters that determine how many pages should be pre-fetched and how often the pre-fetches should occur.

Parameters:
[out] prefetchPagesMax max number of outstanding pre-fetch pages
[out] prefetchThrottleRate the number of successful pre-fetches that have to occur before the pre-fetch rate is throttled back up, in the event that it has been throttled down due to rejected requests

Implemented in CacheImpl< PageT, VictimPolicyT >, DelegatingCacheAccessor, and ScratchSegment.


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:27 2009 for Fennel by  doxygen 1.5.1