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

alma::acs::logging::AcsLoggingHandlerTest::TestLogQueue Class Reference

Inheritance diagram for alma::acs::logging::AcsLoggingHandlerTest::TestLogQueue:

Inheritance graph
[legend]
Collaboration diagram for alma::acs::logging::AcsLoggingHandlerTest::TestLogQueue:

Collaboration graph
[legend]
List of all members.

Public Attributes

int nFlush
List< LogRecord > logRecords

Package Functions

 TestLogQueue ()
void reset ()
Future< Boolean > flush ()
synchronized boolean log (LogRecord logRecord)

Detailed Description

Test log queue that allows verification of calls to log and flush.

Actually this class does not support any of the special features of DispatchingLogQueue. It will not even forward the log record to it. It only extends DispatchingLogQueue because AcsLoggingHandler requires a DispatchingLogQueue in the ctor and I see no big advantage in refactoring this.


Constructor & Destructor Documentation

alma::acs::logging::AcsLoggingHandlerTest::TestLogQueue::TestLogQueue  )  [inline, package]
 


Member Function Documentation

Future<Boolean> alma::acs::logging::AcsLoggingHandlerTest::TestLogQueue::flush  )  [inline, package]
 

Tries to send log records to the remote log service, but at most RemoteLogDispatcher#getBufferSize(). If sending fails, the log records remain in the queue (actually they may be first taken out and then get re-submitted).

This method returns immediately, since flushing is done in a separate thread. The returned future object can be used to wait for termination of the log flush and get the result, or to cancel the flush. The result is a Boolean which is true if all or at least 1 log record could be taken off the log queue.

Reimplemented from alma::acs::logging::DispatchingLogQueue.

synchronized boolean alma::acs::logging::AcsLoggingHandlerTest::TestLogQueue::log LogRecord  logRecord  )  [inline, package]
 

Adds a LogRecord to the internal queue, so that it gets scheduled for logging. If a high-level log record should be sent out immediately, the caller of this method should subsequently call flush(), as the log method itself does not trigger a flush based on levels.

Threading note: it seems ok to make this method "synchronized". This avoids problems with stale queue size, even though the damage would be small since the treatment of queue size is somewhat arbitrary anyway. Synchronization should not block callers long at all because flushing is done in a separate thread and only gets triggered here.

TODO: there is currently a minor problem with queue overflow: log records get drained from the queue, and when they can't be sent off to the log service, they are resubmitted to the queue. It could happen that in the meantime, some other record with INFO or higher level has been added to the queue, and that resubmitting some of the even more important records may fail. The solution would be to replace the 70%-filter rule with a running priority filter: any incoming record can kick out a less important record if the queue is full.

Parameters:
logRecord to be logged
Returns:
true if logRecord was added to the queue for logging. False if queue was too full for this record.

Reimplemented from alma::acs::logging::DispatchingLogQueue.

void alma::acs::logging::AcsLoggingHandlerTest::TestLogQueue::reset  )  [inline, package]
 


Member Data Documentation

List<LogRecord> alma::acs::logging::AcsLoggingHandlerTest::TestLogQueue::logRecords
 

int alma::acs::logging::AcsLoggingHandlerTest::TestLogQueue::nFlush
 


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