com::cosylab::logging::engine::cache::CacheEntriesQueue Class Reference
List of all members.
Detailed Description
The queue of entries.
This class has been introduced to avoid keeping in memory a never ending queue of CacheEntry and reduce the chance to face an out of memory at run-time.
CacheEntriesQueue
extends LinkedBlockingQueue by keeping in memory only a defined subset of items. All exceeding items are flushed on disk.
Implementation note
CacheEntry
items are read only with the poll
or an equivalent method and pushed with put
.
Adding entries:
If there is enough room in the queue (i.e. size()<MAX_QUEUE_LENGTH
) then a new entry is stored directly in the queue otherwise it is added to a vector (cachedEntries
) ready to be written on file. If the size of the vector is greater of the size of a page (PAGE_LEN
), the page is flushed on disk. Note that what is in the vector is added at the end of the file.
Getting entries:
The entry to get is always in the queue. After getting the entry, it checks if the the size of the queue allows to get new entries from the file (i.e. read a new page) or from the vector. Note that the right order is first the file and then the vector. In fact the vector, cachedEntries
, contains the last received entries, packed to be transferred on a new page on disk while the first entries to push in the queue are on a page disk (if any).
- Author:
- acaproni
Constructor & Destructor Documentation
com::cosylab::logging::engine::cache::CacheEntriesQueue::CacheEntriesQueue |
( |
|
) |
[inline] |
|
Member Function Documentation
Override void com::cosylab::logging::engine::cache::CacheEntriesQueue::clear |
( |
|
) |
[inline] |
|
|
Clear the queue and the file (if any) |
synchronized void com::cosylab::logging::engine::cache::CacheEntriesQueue::flushEntriesInQueue |
( |
|
) |
[inline, private] |
|
|
Move the entries from the file or the vector into the queue
The vector contains the last added entries so if there are pages in the file they are flushed before the vector |
File com::cosylab::logging::engine::cache::CacheEntriesQueue::getNewFile |
( |
|
) |
[inline, private] |
|
|
Attempts to create the file for the strings in several places before giving up.
- Returns:
- A new temporary file
null if it was not possible to create a new file
|
Override CacheEntry com::cosylab::logging::engine::cache::CacheEntriesQueue::poll |
( |
long |
timeout, |
|
|
TimeUnit |
unit |
|
) |
throws InterruptedException [inline] |
|
|
Get the next value from the queue. |
Override void com::cosylab::logging::engine::cache::CacheEntriesQueue::put |
( |
CacheEntry |
entry |
) |
throws InterruptedException [inline] |
|
|
Put an entry in Cache.
If the cache is full the entry is added to the buffer. |
synchronized void com::cosylab::logging::engine::cache::CacheEntriesQueue::readNextPageFromFile |
( |
|
) |
[inline, private] |
|
|
Read page from the file putting all the CacheEntry it contains in the queue. |
Override int com::cosylab::logging::engine::cache::CacheEntriesQueue::size |
( |
|
) |
[inline] |
|
|
Return the number of cache entries waiting in queue |
synchronized void com::cosylab::logging::engine::cache::CacheEntriesQueue::writePageOnFile |
( |
|
) |
[inline, private] |
|
Member Data Documentation
|
This Vector contains the entries that will be written on the file. |
|
The buffer containing the hexadecimal string of a CacheEntry |
|
The file to buffer entries on disk. |
|
The max number of entries kept in memory. |
|
The number of the next page to read from file.
Note: a new page is always added at the end of the file while the reading happens in a different order. |
|
The number of CacheEntry to read/write from/to disk on each I/O |
|
The size (in bytes) of a page |
|
The number of pages written on file and not yet read |
|
The RandomAccessFile to read/write entries created from bufferFile .
The I/O is paginated i.e. each read or write is done for a block of PAGE_LEN entries. |
|
The object to wait events from |
|
When in the LinkedBlockingQueue there are less entries then the THRESHOLD then the entries in the buffer are flushed in the queue |
The documentation for this class was generated from the following file:
Generated on Thu Apr 30 03:13:10 2009 for ACS Java API by
1.3.8