|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ostore.cache.BufferCache
Manages file blocks and (someday soon) archival fragments in memory, keeping the total core size to a given limit--an intended replacement for DataCacheImpl, LRUCacheImpl, MemoryCache, and CacheDb.
Field Summary | |
---|---|
protected int |
_pinned_bytes
|
protected SinkIF |
_sink
|
protected Object |
_size_lock
|
protected int |
_space_wait_queue_bytes_reserved
|
protected int |
_total_pin_count
|
protected Object |
_total_pin_count_lock
|
protected NodeId |
self_node_id
|
protected static int |
STATE_DISK_ONLY
|
protected static int |
STATE_FLUSHING_TO_DISK
|
protected static int |
STATE_LOADING_FROM_DISK
|
protected static int |
STATE_MEM_AND_DISK
|
protected static int |
STATE_MEM_ONLY
|
protected static int |
STATE_MODIFIED_DURING_FLUSH
|
protected static int |
STATE_REMOVED
|
protected static String[] |
state_to_string
|
Constructor Summary | |
---|---|
BufferCache()
|
Method Summary | |
---|---|
protected boolean |
acquire_space(int bytes)
|
void |
assign(CacheablePinned pin,
Cacheable cacheable)
Assign a block to reserved space |
void |
assign(CacheablePinned pin,
CacheableIdentity identifier)
Give a reserved block an identity; if an id already exists, the new identifiers will be appended to the existing id. |
protected boolean |
block_being_flushed(ostore.cache.BufferCache.CacheItem item)
|
boolean |
cache_contains(CacheableIdentity id)
cache_contains returns true if the
cache contains the item labeled by the
CacheableIdentity ; false,
otherwise. |
protected boolean |
cheap_need_space(int total_needed)
Returns true if space has been acquired. |
protected boolean |
check_cache_type(CacheableIdentity id,
boolean die,
QueueElementIF event)
|
protected boolean |
check_cache_type(CacheableIdentity id,
int cacheType,
boolean die,
QueueElementIF event)
|
protected boolean |
check_cache_type(int cacheType,
boolean die,
QueueElementIF event)
|
protected static SecureHash |
ci_to_diss(CacheableIdentity id)
|
protected static SecureHash |
ci_to_guid(CacheableIdentity id)
|
protected static SecureHash |
ci_to_vhash(CacheableIdentity id)
|
protected static VID |
ci_to_vid(CacheableIdentity id)
idToVid converts a CacheableIdentity
to a VID . |
void |
destroy()
|
protected ostore.cache.BufferCache.CacheItem |
find_cache_item(CacheableIdentity identifier)
|
protected void |
flush_block(ostore.cache.BufferCache.CacheItem item)
|
protected void |
get_block(CacheableIdentity id,
int req_id,
boolean want_pin)
|
protected CacheableHandle |
get(CacheableIdentity id)
|
CacheablePinned |
getPin(CacheableIdentity 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. |
protected void |
handle_assign(CacheAssignRequest req)
|
protected void |
handle_block_req_have_space(ostore.cache.BufferCache.CacheItem item)
|
protected void |
handle_block_req(CacheBlockRequestMessage req)
|
protected void |
handle_get_comp(StorageManager.GetBlockCompleted gc)
|
protected void |
handle_pin_req(CachePinnedRequest.Local req)
|
protected void |
handle_put_comp(StorageManager.PutBlockCompleted pc)
|
protected void |
handle_reserve_have_space(CacheReserveSpaceMessage req)
|
protected void |
handle_reserve(CacheReserveSpaceMessage req)
|
protected void |
handle_unpin(CacheUnpinRequest req)
|
void |
handleEvent(QueueElementIF item)
FIXME remove the storage_manager declaration protected StorageManager _storage_manager; |
void |
handleEvents(QueueElementIF[] items)
|
void |
init(ConfigDataIF config)
|
protected void |
item_pinned(int sz)
|
protected void |
item_unpinned(int sz)
|
boolean |
local_node_contains(CacheableIdentity id)
local_node_contains returns true if the
local node contains the item labeled by the
CacheableIdentity anywhere in the
cache, on disk, or anywhere inbetween; false,
otherwise.
|
protected CacheableIdentity |
make_ci(ostore.cache.BufferCache.CacheItem item)
|
protected void |
need_space(Object req,
int total_needed)
Called to indicate that whatever function is trying to satisfy the given request needs more space in order to do so; requests are satisfied in FIFO order; will result in a call to space_available when it is. |
protected CacheablePinned |
reserve(int n)
|
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 . |
protected void |
space_available(Object obj)
|
String |
toString()
|
int |
totalPins()
return the total number of pins being held |
CacheableHandle |
unpin(CacheablePinned p)
Unpin the pinned block; it is an error to call this function if the CacheablePinned has already been used for another unpin call. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected SinkIF _sink
protected NodeId self_node_id
protected int _total_pin_count
protected int _pinned_bytes
protected Object _total_pin_count_lock
protected static final int STATE_MEM_ONLY
protected static final int STATE_MEM_AND_DISK
protected static final int STATE_DISK_ONLY
protected static final int STATE_LOADING_FROM_DISK
protected static final int STATE_FLUSHING_TO_DISK
protected static final int STATE_MODIFIED_DURING_FLUSH
protected static final int STATE_REMOVED
protected static final String[] state_to_string
protected Object _size_lock
protected int _space_wait_queue_bytes_reserved
Constructor Detail |
public BufferCache()
Method Detail |
public boolean cache_contains(CacheableIdentity id)
cache_contains
returns true if the
cache contains the item labeled by the
CacheableIdentity
; false,
otherwise. That is, cache_contains
will return false if the cache item is contained
only on disk.
NOTE: if the item is currently loading from disk.
cache_contains
returns true.
WARNING: this is just a hint. The status of the
item can change between calls.
id
- CacheableIdentity
.
CacheableIdentity
;
false, otherwise.public boolean local_node_contains(CacheableIdentity id)
local_node_contains
returns true if the
local node contains the item labeled by the
CacheableIdentity
anywhere in the
cache, on disk, or anywhere inbetween; false,
otherwise.
WARNING: this is just a hint. The status of the
item can change between calls.
id
- CacheableIdentity
.
CacheableIdentity
; false, otherwise.public void init(ConfigDataIF config) throws Exception
init
in interface EventHandlerIF
Exception
public void handleEvent(QueueElementIF item) throws EventHandlerException
handleEvent
in interface EventHandlerIF
EventHandlerException
public void handleEvents(QueueElementIF[] items) throws EventHandlerException
handleEvents
in interface EventHandlerIF
EventHandlerException
public void destroy() throws Exception
destroy
in interface EventHandlerIF
Exception
protected void handle_put_comp(StorageManager.PutBlockCompleted pc)
protected void handle_block_req(CacheBlockRequestMessage req)
protected void get_block(CacheableIdentity id, int req_id, boolean want_pin)
protected void handle_block_req_have_space(ostore.cache.BufferCache.CacheItem item)
protected void handle_get_comp(StorageManager.GetBlockCompleted gc)
protected void handle_pin_req(CachePinnedRequest.Local req)
protected void handle_reserve(CacheReserveSpaceMessage req)
protected void handle_reserve_have_space(CacheReserveSpaceMessage req)
protected void handle_unpin(CacheUnpinRequest req)
protected void handle_assign(CacheAssignRequest req)
protected CacheableHandle get(CacheableIdentity id)
public CacheableHandle getWithException(CacheableIdentity id) throws CacheMissException
DataCache
getWithException
in interface DataCache
CacheMissException
- if block is not in the cachepublic CacheablePinned getPin(CacheableIdentity id)
public CacheablePinned getPinWithException(CacheableIdentity id) throws CacheMissException
DataCache
getPinWithException
in interface DataCache
CacheMissException
- if block is not in the cachepublic void assign(CacheablePinned pin, CacheableIdentity identifier)
DataCache
assign
in interface DataCache
public void assign(CacheablePinned pin, Cacheable cacheable)
DataCache
assign
in interface DataCache
protected CacheablePinned reserve(int n)
public CacheablePinned reserveWithException(int n) throws CacheFullException
DataCache
n
bytes in the cache if there is room;
otherwise throw a CacheFullException
.
reserveWithException
in interface DataCache
n
- the number of bytes to reserve
CacheFullException
- if not enough space is availablepublic LinkedList reserveWithException(int b, int sz) throws CacheFullException
DataCache
b
blocks of sz
bytes each in the
cache if there is room; otherwise throw a
CacheFullException
.
reserveWithException
in interface DataCache
b
- the number of block to reservesz
- the size of each block
CacheFullException
- if not enough space is availablepublic CacheableHandle unpin(CacheablePinned p)
DataCache
unpin
in interface DataCache
protected CacheableIdentity make_ci(ostore.cache.BufferCache.CacheItem item)
public int totalPins()
DataCache
totalPins
in interface DataCache
protected final void item_pinned(int sz)
protected final void item_unpinned(int sz)
protected boolean block_being_flushed(ostore.cache.BufferCache.CacheItem item)
protected void flush_block(ostore.cache.BufferCache.CacheItem item)
protected boolean check_cache_type(CacheableIdentity id, boolean die, QueueElementIF event)
protected boolean check_cache_type(int cacheType, boolean die, QueueElementIF event)
protected boolean check_cache_type(CacheableIdentity id, int cacheType, boolean die, QueueElementIF event)
protected final boolean acquire_space(int bytes)
protected boolean cheap_need_space(int total_needed)
protected void need_space(Object req, int total_needed)
protected void space_available(Object obj)
protected static final SecureHash ci_to_vhash(CacheableIdentity id)
protected static final SecureHash ci_to_guid(CacheableIdentity id)
protected static final SecureHash ci_to_diss(CacheableIdentity id)
protected static final VID ci_to_vid(CacheableIdentity id)
idToVid
converts a CacheableIdentity
to a VID
. The presedence is to first assign
the VID
a guid if the
CacheableIdentity
.GUID is not null. Otherwise,
assigns the VID
a VHASH.
protected ostore.cache.BufferCache.CacheItem find_cache_item(CacheableIdentity identifier)
public String toString()
toString
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |