public class IOLogsHelper extends java.lang.Object implements IOPorgressListener
LogTableDataModel class shorter
and more readable.
This class instantiate a new thread for each load/save operation.
To cleanly close, the done() must be called.
This class allows only one load/save at a time. If an I/O is requested while another one is in progress, an exception is thrown.
This class is not thread safe!
| Modifier and Type | Class and Description |
|---|---|
class |
IOLogsHelper.LoadUrl
A class to download logs from a remote URL.
|
| Constructor and Description |
|---|
IOLogsHelper(LoggingClient client)
Build an IOCacheHelper object
|
| Modifier and Type | Method and Description |
|---|---|
void |
bytesRead(long bytes)
Moves the progress bar of the progress monitor
|
void |
bytesWritten(long bytes)
This method notifies about the total number of bytes written during a save.
|
void |
done(boolean sync)
Release the resource acquired by this object
It terminates the thread so the object can be deleted by the JVM
NOTE: when the thread is terminated it is not possible to
request asynchronous services
|
IOHelper |
getIoHelper() |
boolean |
isPerformingIO()
Check if a load/save is in progress
|
void |
loadLogs(java.io.BufferedReader br,
ACSRemoteLogListener logListener,
ACSRemoteErrorListener errorListener,
int progressRange)
Load the logs from the given file in the Cache appending their
starting positions in the index vector.
|
void |
loadLogsFromUrl(java.net.URL url,
ACSRemoteLogListener logListener,
ACSRemoteErrorListener errorListener)
Load logs from the passed url.
|
void |
logsRead(int numOfLogs)
Change the label of the progress monitor
|
void |
logsWritten(int numOfLogs)
This method notifies about the total number of logs written during a save.
|
void |
saveLogs(java.lang.String fileName,
boolean compress,
int level,
LogCache cache)
Save the logs in a file.
|
public IOLogsHelper(LoggingClient client) throws java.lang.Exception
java.lang.Exception - IN case of error building the IOHelperpublic void loadLogs(java.io.BufferedReader br,
ACSRemoteLogListener logListener,
ACSRemoteErrorListener errorListener,
int progressRange)
The logs are appended at the end of the cache as well as the new positions are appended at the end of the index vector. The load is performed in a thread as it might be very slow
The filter, discard level and audience of the engine are applied while loading.
This is done by applying to ioHelper the same constraints
defined in the LCEngine.
br - The the file to readlogListener - The callback for each new log read from the IOerrorListener - The listener of errorsprogressRange - The range of the progress bar (if <=0 the progress bar is undetermined)public void loadLogsFromUrl(java.net.URL url,
ACSRemoteLogListener logListener,
ACSRemoteErrorListener errorListener)
logListener - The callback for each new log read from the IOerrorListener - The listener of errorsurl - The url to readpublic void saveLogs(java.lang.String fileName,
boolean compress,
int level,
LogCache cache)
throws java.io.IOException
fileName - The name of the file to savecompress - true if the file must be compressed (GZIP)level - The level of compression (ignored if compress is false)cache - The cache that contains the logsjava.io.IOExceptionsaveLogsFromThreadpublic void done(boolean sync)
sync - If it is true wait the termination of the threads before returningpublic void bytesRead(long bytes)
bytesRead in interface IOPorgressListenerbytes - The number of bytes read while loadingIOPorgressListener.bytesRead(long)public void bytesWritten(long bytes)
IOPorgressListenerThe value passed as parameter includes the number of the bytes read since the beginning of the save.
bytesWritten in interface IOPorgressListenerbytes - The number of bytes read while loadingIOPorgressListener.bytesWritten(long)public void logsRead(int numOfLogs)
logsRead in interface IOPorgressListenerIOPorgressListener.logsRead(int)public void logsWritten(int numOfLogs)
IOPorgressListenerThe value passed as parameter is the number of logs written since the beginning of the save.
logsWritten in interface IOPorgressListenerIOPorgressListener.logsWritten(int)public boolean isPerformingIO()
true if a load/save is in progresspublic IOHelper getIoHelper()