
Classes | |
| class | DelayedLogEntry |
| class | MyRemoteResponseCallback |
| class | ReceivedLogRecord |
Public Member Functions | |
| LogReceiver () | |
| boolean | isVerbose () |
| void | setVerbose (boolean verbose) |
| boolean | initialize () |
| boolean | initialize (ORB theORB, Manager manager, int timeoutSeconds) |
| boolean | isInitialized () |
| void | setDelayMillis (long newDelayMillis) |
| long | getDelayMillis () |
| BlockingQueue< DelayedLogEntry > | getLogQueue () |
| String[] | getStatusReports () |
| void | stop () |
| void | startCaptureLogs (final PrintWriter logWriter) throws IOException |
| void | startCaptureLogs (final PrintWriter logWriter, ThreadFactory threadFactory) throws IOException |
| void | stopCaptureLogs () |
Protected Attributes | |
| LCEngine | lct |
| MyRemoteResponseCallback | rrc |
Private Attributes | |
| boolean | verbose = false |
| DelayQueue< DelayedLogEntry > | logDelayQueue |
| ArrayList< String > | statusReports |
| volatile boolean | listenForLogs |
| volatile long | sortingDelayMillis = 20000 |
Receives log messages from the ACS Log service and sorts them by timestamp, even if the log messages arrive in different order within a certain time window.
For a client of this class to consume these log messages, method getLogQueue() provides a java.util.concurrent.BlockingQueue from which the client can extract the messages.
Before log messages can be received, initialize(ORB, Manager) must be called. To disconnect from the the log stream, call stop().
As an alternative to getLogQueue and stop, this class also offers the method pair startCaptureLogs(PrintWriter) and stopCaptureLogs(). These methods can be used to directly print the received log messages to some writer, sparing the effort of listening on the LogQueue. Method stopCaptureLogs() must be called in that case to stop capturing logs.
| alma::acs::logging::engine::LogReceiver::LogReceiver | ( | ) | [inline] |
| long alma::acs::logging::engine::LogReceiver::getDelayMillis | ( | ) | [inline] |
References sortingDelayMillis.
Referenced by stopCaptureLogs(), and alma::acs::component::client::ClientWithLogReceiverTest::testLogCapture().
| BlockingQueue<DelayedLogEntry> alma::acs::logging::engine::LogReceiver::getLogQueue | ( | ) | [inline] |
Gets access to the log record queue, from which the time-sorted log records should be fetched.
The queue elements are of type DelayedLogEntry, from which the log record can be extracted using the method DelayedLogEntry#getLogEntry().
References logDelayQueue.
Referenced by alma::contLogTest::TestLogLevelsCompImpl::LogSeriesExpectant::awaitLogRecords(), alma::contLogTest::TestLogLevelsCompImpl::LogSeriesExpectant::clearLogs(), startCaptureLogs(), and alma::acs::component::client::ClientWithLogReceiverTest::testLogQueueNoDelay().
| String [] alma::acs::logging::engine::LogReceiver::getStatusReports | ( | ) | [inline] |
Gets the status reports. Currently only a forceful disconnect would be shown, the rest is ignored. TODO: separate good and bad status reports
References statusReports.
| boolean alma::acs::logging::engine::LogReceiver::initialize | ( | ORB | theORB, | |
| Manager | manager, | |||
| int | timeoutSeconds | |||
| ) | [inline] |
Variant of initialize() which takes an existing ORB and manager reference.
This method attempts to wait for successful initialization for up to timeoutSeconds seconds. If initialization did not happen within this time, false is returned, otherwise true.
| theORB | the fully functional ORB object to reuse, or null if an ORB should be created | |
| manager | reference to the acs manager, or null if this reference should be created | |
| timeoutSeconds | timeout for awaiting the successful initialization. |
timeoutSeconds seconds. References com::cosylab::logging::engine::ACS::LCEngine::addLogConnectionListener(), com::cosylab::logging::engine::ACS::LCEngine::addLogListener(), com::cosylab::logging::engine::ACS::LCEngine::connect(), lct, logDelayQueue, rrc, com::cosylab::logging::engine::ACS::LCEngine::setAccessType(), sortingDelayMillis, statusReports, and verbose.
| boolean alma::acs::logging::engine::LogReceiver::initialize | ( | ) | [inline] |
Initializes the connection to the logging channel, which leads to log entries getting written to the sorting queue. To reuse an existing ORB and manager reference, use initialize(ORB, Manager) instead of this method.
This method attempts to wait for successful initialization for up to 10 seconds. If initialization did not happen within this time, false is returned, otherwise true.
If you call this method, make sure to subsequently call getLogQueue() and drain the queue at your own responsibility, or to call startCaptureLogs(PrintWriter) (or startCaptureLogs(PrintWriter, ThreadFactory)) which will drain the queue automatically.
Referenced by alma::acs::component::client::ComponentClientTestCase::getLogReceiver().
| boolean alma::acs::logging::engine::LogReceiver::isInitialized | ( | ) | [inline] |
References com::cosylab::logging::engine::ACS::LCEngine::isConnected(), and lct.
Referenced by alma::contLogTest::TestLogLevelsCompImpl::LogSeriesExpectant::LogSeriesExpectant(), startCaptureLogs(), alma::acs::component::client::ComponentClientTestCase::tearDown(), and alma::acs::component::client::ClientWithLogReceiverTest::testInitialized().
| boolean alma::acs::logging::engine::LogReceiver::isVerbose | ( | ) | [inline] |
References verbose.
| void alma::acs::logging::engine::LogReceiver::setDelayMillis | ( | long | newDelayMillis | ) | [inline] |
Sets the delay that a log record's timestamp must have with respect to the current system time in order to be allowed to leave the sorting queue.
| newDelayMillis | the delay time in milliseconds. |
References rrc, alma::acs::logging::engine::LogReceiver::MyRemoteResponseCallback::setDelayMillis(), and sortingDelayMillis.
Referenced by alma::contLogTest::TestLogLevelsCompImpl::LogSeriesExpectant::awaitLogRecords(), and alma::acs::component::client::ClientWithLogReceiverTest::testLogQueueNoDelay().
| void alma::acs::logging::engine::LogReceiver::setVerbose | ( | boolean | verbose | ) | [inline] |
| void alma::acs::logging::engine::LogReceiver::startCaptureLogs | ( | final PrintWriter | logWriter, | |
| ThreadFactory | threadFactory | |||
| ) | throws IOException [inline] |
Variant of startCaptureLogs(PrintWriter) which takes an optional ThreadFactory which will be used to create the thread that reads out the log queue. This method could be used if LogReceiver is run inside a container or as part of a ComponentClientTestCase.
References alma::acs::logging::engine::LogReceiver::DelayedLogEntry::getLogEntry(), getLogQueue(), isInitialized(), alma::acs::logging::engine::LogReceiver::DelayedLogEntry::isQueuePoison, listenForLogs, stop(), com::cosylab::logging::engine::log::ILogEntry::toXMLString(), and verbose.
| void alma::acs::logging::engine::LogReceiver::startCaptureLogs | ( | final PrintWriter | logWriter | ) | throws IOException [inline] |
Convenience method to capture logs directly into a PrintWriter. Method initialize(ORB, Manager) must be called as a precondition. Method stopCaptureLogs() must be called to stop writing logs to logWriter.
| logWriter |
| IOException |
Referenced by alma::acs::component::client::ClientWithLogReceiverTest::testLogCapture().
| void alma::acs::logging::engine::LogReceiver::stop | ( | ) | [inline] |
Disconnects from the logging channel. A special "queue poison" version of DelayedLogEntry will be added to the queue with zero delay, so that all clients who fetch log recored of the queue obtained from getLogQueue() know that the show is over.
References com::cosylab::logging::engine::ACS::LCEngine::close(), lct, listenForLogs, logDelayQueue, and verbose.
Referenced by startCaptureLogs(), alma::acs::component::client::ComponentClientTestCase::tearDown(), and alma::acs::component::client::ClientWithLogReceiverTest::testLogQueueNoDelay().
| void alma::acs::logging::engine::LogReceiver::stopCaptureLogs | ( | ) | [inline] |
Stops capturing logs into the PrintWriter that was provided to startCaptureLogs(PrintWriter) or any of the related methods. Even though the call to this method returns immediately, all log records that are currently residing inside the queue will still be written out, waiting the due time to allow sorting them.
References getDelayMillis(), and logDelayQueue.
Referenced by alma::acs::component::client::ClientWithLogReceiverTest::testLogCapture().
LCEngine alma::acs::logging::engine::LogReceiver::lct [protected] |
Referenced by initialize(), isInitialized(), and stop().
volatile boolean alma::acs::logging::engine::LogReceiver::listenForLogs [private] |
Referenced by startCaptureLogs(), and stop().
DelayQueue<DelayedLogEntry> alma::acs::logging::engine::LogReceiver::logDelayQueue [private] |
Referenced by getLogQueue(), initialize(), stop(), and stopCaptureLogs().
Referenced by initialize(), and setDelayMillis().
volatile long alma::acs::logging::engine::LogReceiver::sortingDelayMillis = 20000 [private] |
Referenced by getDelayMillis(), initialize(), and setDelayMillis().
ArrayList<String> alma::acs::logging::engine::LogReceiver::statusReports [private] |
Referenced by getStatusReports(), and initialize().
boolean alma::acs::logging::engine::LogReceiver::verbose = false [private] |
Referenced by initialize(), isVerbose(), startCaptureLogs(), and stop().
1.6.2