ostore.cache
Interface DataCache

All Known Implementing Classes:
BufferCache

public interface DataCache

This is the original functional interface to the OceanStore buffer cache. The old (partial) implementation is now in DataCacheImpl. The separation is so that new cache implementations can do things in their own way, without being tied to any of the old implementation's assumptions.

Version:
$ID: DataCache.java, v 1.0
Author:
Larry H. Tung

Method Summary
 void assign(CacheablePinned handle, Cacheable block)
          Assign a block to reserved space
 void assign(CacheablePinned handle, CacheableIdentity id)
          Give a reserved block an identity; if an id already exists, the new identifiers will be appended to the existing id.
 CacheablePinned getPinWithException(CacheableIdentity id)
          Request a page and pin it (regardless if it's already pinned).
 CacheableHandle getWithException(CacheableIdentity id)
          Request a handle to a block in the cache.
 CacheablePinned reserveWithException(int n)
          Reserve n bytes in the cache if there is room; otherwise throw a CacheFullException.
 LinkedList reserveWithException(int b, int sz)
          Reserve b blocks of sz bytes each in the cache if there is room; otherwise throw a CacheFullException.
 int totalPins()
          return the total number of pins being held
 CacheableHandle unpin(CacheablePinned pinned)
          Unpin the pinned block; it is an error to call this function if the CacheablePinned has already been used for another unpin call.
 

Method Detail

getWithException

public CacheableHandle getWithException(CacheableIdentity id)
                                 throws CacheMissException
Request a handle to a block in the cache.

Returns:
CacheableHandle for particular id
Throws:
CacheMissException - if block is not in the cache

getPinWithException

public CacheablePinned getPinWithException(CacheableIdentity id)
                                    throws CacheMissException
Request a page and pin it (regardless if it's already pinned).

Returns:
CacheablePinned for particular id
Throws:
CacheMissException - if block is not in the cache

assign

public void assign(CacheablePinned handle,
                   CacheableIdentity id)
Give a reserved block an identity; if an id already exists, the new identifiers will be appended to the existing id.


assign

public void assign(CacheablePinned handle,
                   Cacheable block)
Assign a block to reserved space


reserveWithException

public CacheablePinned reserveWithException(int n)
                                     throws CacheFullException
Reserve n bytes in the cache if there is room; otherwise throw a CacheFullException.

Parameters:
n - the number of bytes to reserve
Throws:
CacheFullException - if not enough space is available

reserveWithException

public LinkedList reserveWithException(int b,
                                       int sz)
                                throws CacheFullException
Reserve b blocks of sz bytes each in the cache if there is room; otherwise throw a CacheFullException.

Parameters:
b - the number of block to reserve
sz - the size of each block
Throws:
CacheFullException - if not enough space is available

unpin

public CacheableHandle unpin(CacheablePinned pinned)
Unpin the pinned block; it is an error to call this function if the CacheablePinned has already been used for another unpin call.


totalPins

public int totalPins()
return the total number of pins being held