public class LogMultiFileCache extends java.lang.Object implements ILogMap
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_FILEMAXSIZE
The default max size of each file of the cache
|
static java.lang.String |
FILEMAXSIZE_PROPERTY_NAME
The name of the property defining the max size of each fileof the cache
|
| Constructor and Description |
|---|
LogMultiFileCache()
Constructor
The maximum size of the files is read from the system properties.
|
LogMultiFileCache(long fileSize)
Builds a LogMultiFileCache objects setting the maximum size of the
cache files
|
| Modifier and Type | Method and Description |
|---|---|
int |
add(ILogEntry log)
Add a log to the cache
|
void |
clear()
Clear the Map i.e.
|
void |
deleteLog(java.lang.Integer logKey)
Delete a log with the given key.
|
void |
deleteLogs(java.util.Collection<java.lang.Integer> keys)
Delete a set of logs
|
long |
getFilesSize()
Return the disk space used by all the files of the cache.
|
java.lang.Integer |
getFirstLog()
Return the key of the first valid log (FIFO).
|
int |
getFirstLogs(int n,
java.util.Collection<java.lang.Integer> keys)
Append at most n keys from the first valid logs to the collection.
|
java.lang.Integer |
getLastLog()
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 change if such log has been deleted
|
ILogEntry |
getLog(java.lang.Integer logKey)
Retrieves a log by means of its keyword.
|
long |
getLogFileSize()
Return the size of the last log file used by the cache
(it is here for testing purposes)
|
long |
getMaxFileSize()
Return the current maximum size of the log file
|
int |
getNumberOfCacheFiles() |
int |
getSize() |
java.util.Iterator<ILogEntry> |
iterator()
Return an Iterator to browse the logs in the map.
|
java.util.Set<java.lang.Integer> |
keySet()
The keys in the map
|
void |
printFileTableInfo()
Return the current maximum size of the log file
|
void |
replaceLog(java.lang.Integer key,
ILogEntry log)
Replace the log in the given position with the new one
|
void |
setDebugTrace(boolean flag)
Return the current maximum size of the log file
|
public static final java.lang.String FILEMAXSIZE_PROPERTY_NAME
public static final long DEFAULT_FILEMAXSIZE
public LogMultiFileCache(long fileSize)
throws LogCacheException
fileSize - The maximum size of cache filesLogCacheExceptionpublic LogMultiFileCache()
throws LogCacheException
LogCacheExceptionpublic ILogEntry getLog(java.lang.Integer logKey) throws LogCacheException
getLog in interface ILogMappos - The key of the log to retrieveLogCacheExceptionpublic int add(ILogEntry log) throws LogCacheException
add in interface ILogMaplog - The log to add to the cacheLogCacheExceptionpublic void deleteLog(java.lang.Integer logKey)
throws LogCacheException
deleteLog in interface ILogMappos - The key of the log to deleteLogCacheExceptionpublic int getSize()
public java.lang.Integer getLastLog()
getLastLog in interface ILogMapILogMappublic java.lang.Integer getFirstLog()
getFirstLog in interface ILogMapIn - case of error getting the first logILogMappublic void deleteLogs(java.util.Collection<java.lang.Integer> keys)
throws LogCacheException
deleteLogs in interface ILogMapkeys - The keys of logs to deleteLogCacheExceptionILogMappublic void clear()
throws LogCacheException
clear in interface ILogMapLogCacheExceptionILogMappublic void replaceLog(java.lang.Integer key,
ILogEntry log)
throws LogCacheException
replaceLog in interface ILogMapposition - The position of the log to replacelog - The key (identifier) of the logLogCacheExceptionILogMappublic java.util.Iterator<ILogEntry> iterator()
public java.util.Set<java.lang.Integer> keySet()
public int getFirstLogs(int n,
java.util.Collection<java.lang.Integer> keys)
getFirstLogs in interface ILogMapn - The desired number of keys of first logskeys - The collection to add they keys toILogMappublic long getLogFileSize()
throws LogCacheException
LogCacheExceptionpublic long getFilesSize()
throws java.io.IOException
java.io.IOException - In case of error getting the size of one of
the filespublic long getMaxFileSize()
throws LogCacheException
LogCacheExceptionpublic void setDebugTrace(boolean flag)
throws LogCacheException
LogCacheExceptionpublic void printFileTableInfo()
throws LogCacheException
LogCacheExceptionpublic int getNumberOfCacheFiles()