Public Member Functions | |
LogBufferedFileCache (int writeBufferSize) throws LogCacheException | |
LogBufferedFileCache () throws LogCacheException | |
synchronized void | clear () throws LogCacheException |
synchronized ILogEntry | getLog (Integer key) throws LogCacheException |
synchronized void | deleteLog (Integer key) throws LogCacheException |
synchronized void | deleteLogs (Collection< Integer > keys) throws LogCacheException |
synchronized int | add (ILogEntry log) throws LogCacheException |
void | flushBuffer () throws LogCacheException |
synchronized int | getSize () |
long | getFileSize () throws IOException |
synchronized final int | getBufferSize () |
Integer | getFirstLog () |
int | getFirstLogs (int n, Collection< Integer > keys) |
Integer | getLastLog () |
Set< Integer > | keySet () |
Iterator< ILogEntry > | iterator () |
Override synchronized void | replaceLog (Integer key, ILogEntry log) throws LogCacheException |
Static Public Attributes | |
final String | WRITEBUFFERSIZE_PROPERTY_NAME = "jlog.cache.writebuffersize" |
final int | DEFAULT_WRITEBUFFERSIZE = 8192 |
Static Private Member Functions | |
int | getDefaultWriteCacheSize () |
Private Attributes | |
TreeMap< Integer, BufferedCacheItem > | buffer = new TreeMap<IntegerBufferedCacheItem>() |
int | size |
volatile long | bufferFileSize = 0 |
It uses a WriteBuffer to store the logs to write on disk. The purpose of this class is to write several logs at once reducing the write operations on disk.
The buffer stores the logs when they are added. It flushes the buffer on disk when the number of logs in memory exceeds the maximum size. This means that the number of chars written on the file cache at once is not fixed but depends on the lengths of the logs stored in this buffer. To enhance performance and to have the size of the file always available, the buffer stores the log together with other info in Map of BufferedCacheItem
|
Build a LogBufferedFileCache with the given size for the cache and the write buffer. If there isn't enough memory for the cache, tries with a smmaller size.
|
|
Build a LogBufferedFileCache with the default sizes for the write buffer
|
|
Append a log to the cache
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Empty the cache
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Delete a log with the given key
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Delete a collection of logs
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Flush all the logs on file |
|
|
|
Gets the default size ot the write buffer, which comes either from the system property
|
|
Return the length of the file on disk taking into account the length of the string to write on the disk for the logs in the buffer.
Reimplemented from com::cosylab::logging::client::cache::LogFileCache.
|
|
Return the key of the first valid log (FIFO). The key of the first log is 0 but it can change if the log 0 has been deleted.
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Append at most n keys from the first valid logs to the collection. First here means first in the FIFO policy. The number of added keys can be less then n if the cache doesn't contain enough logs.
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Return the key of the last valid log (FIFO) The key of the last log is the key of the last inserted log but it can cheang if such log has been deleted
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Return the log with the given key
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Return the number of logs in cache
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Return an iterator over the logs in cache Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Return a set with all the keys of the logs in cache
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
Replace the log in the given position with the new one
If the log to replace is not in the buffer,
Implements com::cosylab::logging::client::cache::ILogMap.
|
|
|
|
|
|
|
|
|
|
|