

Classes | |
| class | GZipLogOutStream |
Public Member Functions | |
| synchronized long | loadLogs (String fileName, ACSRemoteLogListener logListener, ACSRemoteRawLogListener rawLogListener, ACSRemoteErrorListener errorListener, IOPorgressListener progressListener, boolean gzip) throws IOException, Exception |
| synchronized long | loadLogs (String fileName, ACSRemoteLogListener logListener, ACSRemoteRawLogListener rawLogListener, ACSRemoteErrorListener errorListener, IOPorgressListener progressListener) throws IOException, Exception |
| synchronized void | loadLogs (BufferedReader reader, ACSRemoteLogListener logListener, ACSRemoteRawLogListener rawLogListener, ACSRemoteErrorListener errorListener, IOPorgressListener progressListener) throws IOException, Exception |
| synchronized void | writeHeader (BufferedWriter wBuffer) throws IOException |
| synchronized void | terminateSave (BufferedWriter outBuffer, boolean close) throws IOException |
| synchronized int | saveLog (BufferedWriter outBuf, ILogEntry log) throws IOException |
| synchronized void | saveLogs (String fileName, Collection< ILogEntry > logs, IOPorgressListener progressListener, boolean append, boolean gzip) throws IOException |
| synchronized void | saveLogs (String fileName, Collection< ILogEntry > logs, IOPorgressListener progressListener, boolean append, boolean gzip, int compressionLevel) throws IOException |
| synchronized void | saveLogs (BufferedWriter outBuffer, Collection< ILogEntry > logs, IOPorgressListener progressListener) throws IOException |
| synchronized void | saveLogs (String fileName, Iterator< ILogEntry >iterator, IOPorgressListener progressListener, boolean append, boolean gzip) throws IOException |
| synchronized void | saveLogs (String fileName, Iterator< ILogEntry >iterator, IOPorgressListener progressListener, boolean append, boolean gzip, int compressionLevel) throws IOException |
| synchronized BufferedWriter | getBufferedWriter (String fileName, boolean append, boolean gzip, int compressionLevel) throws FileNotFoundException, IOException |
| synchronized BufferedWriter | getBufferedWriter (String fileName, boolean append, boolean gzip) throws FileNotFoundException, IOException |
| synchronized BufferedReader | getBufferedReader (String fileName) throws FileNotFoundException, IOException |
| synchronized void | saveLogs (BufferedWriter outBuf, Iterator< ILogEntry > iterator, IOPorgressListener progressListener) throws IOException |
| void | stopIO () |
Static Public Attributes | |
| static final int | DEFAULT_COMPRESSION_LEVEL = 5 |
Protected Attributes | |
| volatile boolean | stopped = false |
Private Member Functions | |
| void | injectLog (StringBuilder logStr, ACSRemoteLogListener logListener, ACSRemoteRawLogListener rawLogListener, ACSRemoteErrorListener errorListener) |
Private Attributes | |
| ACSLogParser | parser |
An helper class to perform synchronous I/O operations like load and save.
Load and save methods are executed in a synchronous way i.e. they do not return until the I/O is terminated (or an exception occurs).
Intermediate results useful to monitor the progress of the I/O are communicated to the listeners implementing the IOProgressListener interface.
The load and save methods of this class are synchronized but I would not say that this class is thread safe because it does not hold and lock the objects it receives as parameters like for example the BufferReader and the BufferWriter. So thread safety must be ensured by the owner of such objects.
Loading
The loading is performed through one of the overloaded loadLogs methods. The bytes read and the number of the logs successfully read are sent to the listeners implementing the IOProgressListener interface. If there are filters, an audience or a discard level defined, then each log is checked before being sent to the listener.
Saving
The saving of logs can be done by passing a Collection of logs or an Iteratorto one of the overloaded saveLogs methods. Such methods communicates the progress to the listener implementing the IOProgressListener interface.
Saving logs by passing the name of the file does not require any extra steps.
Saving logs by passing a BufferedWriter is always a three steps procedure:
prepareSaveFile to write XML header saveLogs or the saveLog Save to add the closing XML tags, flush and close the buffer Load and save can be very long operations. To stop an I/O, the stopIO() must be executed.
| synchronized BufferedReader alma::acs::logging::engine::io::IOHelper::getBufferedReader | ( | String | fileName | ) | throws FileNotFoundException, IOException [inline] |
Return the reader to get logs from
The reader can be compressed (GZIP) or not depending on the extension of the file name (i.e. ".gz" or ".xml").
| fileName | The name of the file to read |
| synchronized BufferedWriter alma::acs::logging::engine::io::IOHelper::getBufferedWriter | ( | String | fileName, | |
| boolean | append, | |||
| boolean | gzip | |||
| ) | throws FileNotFoundException, IOException [inline] |
Create a BufferedWriter to save logs into.
In case of compressed files, the default compression level is used
| fileName | The name of the file to write logs into | |
| append |
| |
| gzip | If true the file is compressed (GZIP) with the default level |
BufferedWriter to save logs into the file of the given name References DEFAULT_COMPRESSION_LEVEL, and getBufferedWriter().
| synchronized BufferedWriter alma::acs::logging::engine::io::IOHelper::getBufferedWriter | ( | String | fileName, | |
| boolean | append, | |||
| boolean | gzip, | |||
| int | compressionLevel | |||
| ) | throws FileNotFoundException, IOException [inline] |
Create a BufferedWriter to save logs into
| fileName | The name of the file to write logs into | |
| append |
| |
| gzip | If true the file is compressed (GZIP) | |
| compressionLevel | The compressionLevel for GZIP compression (0..9); ignored if gzip is false>/code> |
the BufferedWriter to save logs into the file of the given name Referenced by getBufferedWriter(), alma::acs::logging::io::IOLogsHelper::SaveLogs::run(), and saveLogs().
| void alma::acs::logging::engine::io::IOHelper::injectLog | ( | StringBuilder | logStr, | |
| ACSRemoteLogListener | logListener, | |||
| ACSRemoteRawLogListener | rawLogListener, | |||
| ACSRemoteErrorListener | errorListener | |||
| ) | [inline, private] |
Inject the log into the engine
| logStr | The string representation of the log | |
| logListener | The listener i.e. the callback for each new log to add |
References com::cosylab::logging::engine::ACS::ACSRemoteErrorListener::errorReceived(), com::cosylab::logging::engine::ACS::ACSRemoteLogListener::logEntryReceived(), com::cosylab::logging::engine::LogMatcher::match(), alma::acs::logging::engine::parser::ACSLogParser::parse(), parser, and com::cosylab::logging::engine::ACS::ACSRemoteRawLogListener::xmlEntryReceived().
Referenced by loadLogs().
| synchronized void alma::acs::logging::engine::io::IOHelper::loadLogs | ( | BufferedReader | reader, | |
| ACSRemoteLogListener | logListener, | |||
| ACSRemoteRawLogListener | rawLogListener, | |||
| ACSRemoteErrorListener | errorListener, | |||
| IOPorgressListener | progressListener | |||
| ) | throws IOException, Exception [inline] |
Load the logs from the given BufferedReader.
The logs are sent to the ACSRemoteLogListener and /or to the ACSRemoteRawLogListener.
| reader | The reader to read logs from | |
| logListener | The callback for each new log read from the IO | |
| rawLogListener | The callback for each new XML log read from the IO | |
| errorListener | The listener for errors | |
| progressListener | The listener to be notified about the bytes read |
| IOException | In case of an IO error while reading the file | |
| Exception | In case of error building the parser |
The size of the buffer
The buffer of data read from the file
The cursor to scan the buffer (circular)
When it is 0, then we have to read another block from the file
References alma::acs::logging::engine::io::LogStringBuffer::append(), alma::acs::util::StopWatch::getLapTimeMillis(), injectLog(), parser, and stopped.
| synchronized long alma::acs::logging::engine::io::IOHelper::loadLogs | ( | String | fileName, | |
| ACSRemoteLogListener | logListener, | |||
| ACSRemoteRawLogListener | rawLogListener, | |||
| ACSRemoteErrorListener | errorListener, | |||
| IOPorgressListener | progressListener | |||
| ) | throws IOException, Exception [inline] |
Load the logs from the file with the given name.
The logs are sent to the ACSRemoteLogListener and /or to the ACSRemoteRawLogListener.
The file can be compressed (GZIP) or plain. Compressed file names must terminate with .gz while plain XML file names must end with .xml.
| fileName | The name of the file to read logs from. fileName must terminate with .gz or .xml (case insensitive) | |
| logListener | The callback for each new log read from the IO | |
| rawLogListener | The callback for each new XML log read from the IO | |
| errorListener | The listener for errors | |
| progressListener | The listener to be notified about the bytes read |
| IOException | In case of an IO error while reading the file | |
| Exception | In case of error building the parser |
References loadLogs().
| synchronized long alma::acs::logging::engine::io::IOHelper::loadLogs | ( | String | fileName, | |
| ACSRemoteLogListener | logListener, | |||
| ACSRemoteRawLogListener | rawLogListener, | |||
| ACSRemoteErrorListener | errorListener, | |||
| IOPorgressListener | progressListener, | |||
| boolean | gzip | |||
| ) | throws IOException, Exception [inline] |
Load the logs from the file with the given name.
The logs are sent to the ACSRemoteLogListener and /or to the ACSRemoteRawLogListener.
| fileName | The name of the file to read logs from | |
| logListener | The callback for each new log read from the IO | |
| rawLogListener | The callback for each new XML log read from the IO | |
| errorListener | The listener for errors | |
| progressListener | The listener to be notified about the bytes read | |
| gzip | If true the file to read is compressed in GZIP format |
| IOException | In case of an IO error while reading the file | |
| Exception | In case of error building the parser |
Referenced by alma::acs::logging::tools::LogFileExtractor::extract(), loadLogs(), alma::acs::logging::archive::zoom::FileHelper::loadLogs(), alma::acs::logging::io::IOLogsHelper::LoadLogs::run(), alma::acs::logging::tools::LogFileSplitter::split(), alma::acs::jlog::test::LoadSaveTest::testAppend(), alma::acs::jlog::test::LoadSaveTest::testLoadingSpecialLogs(), alma::acs::jlog::test::LoadSaveTest::testSaveLoad(), alma::acs::jlog::test::LoadSaveTest::testSaveLoadCompressed(), alma::acs::jlog::test::LoadSaveTest::testSaveLoadFields(), and alma::acs::jlog::test::LoadSaveTest::testSaveLoadIterator().
| synchronized int alma::acs::logging::engine::io::IOHelper::saveLog | ( | BufferedWriter | outBuf, | |
| ILogEntry | log | |||
| ) | throws IOException [inline] |
Save a log in the passed file
| outbuf | The buffered writer where the logs have to be stored | |
| log | The log to save | |
| progressListener | The listener to be notified about the bytes written |
| IOException | In case of an IO error while writing logs into the file |
Referenced by saveLogs().
| synchronized void alma::acs::logging::engine::io::IOHelper::saveLogs | ( | BufferedWriter | outBuf, | |
| Iterator< ILogEntry > | iterator, | |||
| IOPorgressListener | progressListener | |||
| ) | throws IOException [inline] |
Save a collection of logs on a BufferedWriter.
The buffer must be initialized and terminated i.e. the prepareSaveFile and the terminateSave are not executed by this method.
| outBuf | The buffer to write logs into | |
| logs | The non empty collection of logs to save | |
| progressListener | The listener to be notified about the number of bytes written |
| IOException | In case of error writing |
| synchronized void alma::acs::logging::engine::io::IOHelper::saveLogs | ( | String | fileName, | |
| Iterator< ILogEntry > | iterator, | |||
| IOPorgressListener | progressListener, | |||
| boolean | append, | |||
| boolean | gzip, | |||
| int | compressionLevel | |||
| ) | throws IOException [inline] |
Save the logs available through an Iterator.
| filename | The name of the file to write logs into | |
| logs | The non empty collection of logs to save | |
| progressListener | The listener to be notified about the number of bytes written | |
| append |
| |
| gzip | If true the file is compressed (GZIP) | |
| compressionLevel | The compressionLevel for GZIP compression (0..9); ignored if gzip is false>/code> |
| IOException | In case of error writing |
References getBufferedWriter(), saveLogs(), terminateSave(), and writeHeader().
| synchronized void alma::acs::logging::engine::io::IOHelper::saveLogs | ( | String | fileName, | |
| Iterator< ILogEntry > | iterator, | |||
| IOPorgressListener | progressListener, | |||
| boolean | append, | |||
| boolean | gzip | |||
| ) | throws IOException [inline] |
Save the logs available through an Iterator.
| filename | The name of the file to write logs into | |
| logs | The non empty collection of logs to save | |
| progressListener | The listener to be notified about the number of bytes written | |
| append |
| |
| gzip | If true the file is compressed (GZIP) with the default compression level |
| IOException | In case of error writing |
References DEFAULT_COMPRESSION_LEVEL, and saveLogs().
| synchronized void alma::acs::logging::engine::io::IOHelper::saveLogs | ( | BufferedWriter | outBuffer, | |
| Collection< ILogEntry > | logs, | |||
| IOPorgressListener | progressListener | |||
| ) | throws IOException [inline] |
Save a collection of logs on a BufferedWriter.
The buffer must be initialized and terminated i.e. the prepareSaveFile and the terminateSave are not executed by this method.
| outBuffer | The writer to write logs into | |
| logs | The non empty collection of logs to save | |
| progressListener | The listener to be notified about the number of bytes written | |
| gzip | If true the file is compressed (GZIP) |
| IOException | In case of error writing |
References saveLogs().
| synchronized void alma::acs::logging::engine::io::IOHelper::saveLogs | ( | String | fileName, | |
| Collection< ILogEntry > | logs, | |||
| IOPorgressListener | progressListener, | |||
| boolean | append, | |||
| boolean | gzip, | |||
| int | compressionLevel | |||
| ) | throws IOException [inline] |
Save a collection of logs on disk
| fileName | The name of the file to store logs into | |
| logs | The non empty collection of logs to save | |
| progressListener | The listener to be notified about the number of bytes written | |
| append |
| |
| gzip | If true the file is compressed (GZIP) | |
| compressionLevel | The compressionLevel for GZIP compression (0..9); ignored if gzip is is false>/code> |
| IOException | In case of error writing |
References saveLogs().
| synchronized void alma::acs::logging::engine::io::IOHelper::saveLogs | ( | String | fileName, | |
| Collection< ILogEntry > | logs, | |||
| IOPorgressListener | progressListener, | |||
| boolean | append, | |||
| boolean | gzip | |||
| ) | throws IOException [inline] |
Save a collection of logs on disk
| fileName | The name of the file to store logs into | |
| logs | The non empty collection of logs to save | |
| progressListener | The listener to be notified about the number of bytes written | |
| append |
| |
| gzip | If true the file is compressed (GZIP) with the default compression level |
| IOException | In case of error writing |
References DEFAULT_COMPRESSION_LEVEL.
Referenced by alma::acs::logging::io::IOLogsHelper::SaveLogs::run(), saveLogs(), alma::acs::jlog::test::LoadSaveTest::testAppend(), alma::acs::jlog::test::LoadSaveTest::testSaveLoad(), alma::acs::jlog::test::LoadSaveTest::testSaveLoadCompressed(), alma::acs::jlog::test::LoadSaveTest::testSaveLoadFields(), and alma::acs::jlog::test::LoadSaveTest::testSaveLoadIterator().
| void alma::acs::logging::engine::io::IOHelper::stopIO | ( | ) | [inline] |
Call this method if you wish to interrupt a load or a save.
Load and save are executed synchronously so this method has to be called by a separate thread. A typical example is the "Abort" button of a dialog: when the user presses such a button, this method is invoked by the swing thread.
References stopped.
Referenced by alma::acs::logging::io::IOLogsHelper::logsRead(), alma::acs::logging::io::IOLogsHelper::logsWritten(), and alma::acs::logging::archive::zoom::FileHelper::stopLoading().
| synchronized void alma::acs::logging::engine::io::IOHelper::terminateSave | ( | BufferedWriter | outBuffer, | |
| boolean | close | |||
| ) | throws IOException [inline] |
Terminate the saving.
This method must executed when the save terminates. It does the following:
| outBuffer | The file to close | |
| close | If true the BufferedWriter is closed |
| IOException | In case of an IO error |
Referenced by alma::acs::logging::io::IOLogsHelper::SaveLogs::run(), and saveLogs().
| synchronized void alma::acs::logging::engine::io::IOHelper::writeHeader | ( | BufferedWriter | wBuffer | ) | throws IOException [inline] |
Write the XML header in the buffered writer
| bw |
| IOException |
Referenced by alma::acs::logging::io::IOLogsHelper::SaveLogs::run(), and saveLogs().
final int alma::acs::logging::engine::io::IOHelper::DEFAULT_COMPRESSION_LEVEL = 5 [static] |
The default compression level while saving files
Referenced by getBufferedWriter(), alma::acs::logging::engine::io::IOHelper::GZipLogOutStream::GZipLogOutStream(), and saveLogs().
The parser
Referenced by injectLog(), and loadLogs().
volatile boolean alma::acs::logging::engine::io::IOHelper::stopped = false [protected] |
Signal that a load or a save must be stopped
Referenced by loadLogs(), saveLogs(), and stopIO().
1.6.2