Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::acs::logging::engine::LogReceiver Class Reference

Collaboration diagram for alma::acs::logging::engine::LogReceiver:

Collaboration graph
[legend]
List of all members.

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< DelayedLogEntrygetLogQueue ()
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< DelayedLogEntrylogDelayQueue
ArrayList< String > statusReports
volatile boolean listenForLogs
volatile long sortingDelayMillis = 20000

Detailed Description

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.

Author:
hsommer


Constructor & Destructor Documentation

alma::acs::logging::engine::LogReceiver::LogReceiver  )  [inline]
 


Member Function Documentation

long alma::acs::logging::engine::LogReceiver::getDelayMillis  )  [inline]
 

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().

Returns:

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

Returns:

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.

Parameters:
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.
Returns:
true if initialization was successful within at most timeoutSeconds seconds.

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.

Returns:
true if initialization was successful within at most 10 seconds

boolean alma::acs::logging::engine::LogReceiver::isInitialized  )  [inline]
 

boolean alma::acs::logging::engine::LogReceiver::isVerbose  )  [inline]
 

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.

Parameters:
newDelayMillis the delay time in milliseconds.

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.

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.

Parameters:
logWriter 
Exceptions:
IOException 

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.

See also:
DelayedLogEntry::isQueuePoison()

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.


Member Data Documentation

LCEngine alma::acs::logging::engine::LogReceiver::lct [protected]
 

volatile boolean alma::acs::logging::engine::LogReceiver::listenForLogs [private]
 

DelayQueue<DelayedLogEntry> alma::acs::logging::engine::LogReceiver::logDelayQueue [private]
 

MyRemoteResponseCallback alma::acs::logging::engine::LogReceiver::rrc [protected]
 

volatile long alma::acs::logging::engine::LogReceiver::sortingDelayMillis = 20000 [private]
 

ArrayList<String> alma::acs::logging::engine::LogReceiver::statusReports [private]
 

boolean alma::acs::logging::engine::LogReceiver::verbose = false [private]
 


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:53:50 2009 for ACS Java API by doxygen 1.3.8