org.opends.server.loggers
Class AsyncronousTextWriter

java.lang.Object
  extended by org.opends.server.loggers.AsyncronousTextWriter
All Implemented Interfaces:
ServerShutdownListener, TextWriter

public class AsyncronousTextWriter
extends java.lang.Object
implements ServerShutdownListener, TextWriter

A Text Writer which writes log records asynchronously to character-based stream.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.opends.server.loggers.TextWriter
TextWriter.STDERR, TextWriter.STDOUT, TextWriter.STREAM
 
Constructor Summary
AsyncronousTextWriter(java.lang.String name, int capacity, boolean autoFlush, TextWriter writer)
          Construct a new AsyncronousTextWriter wrapper.
 
Method Summary
 void flush()
          Flushes any buffered contents of the output stream.
 long getBytesWritten()
          Retrieves the number of bytes written by this writer.
 java.lang.String getShutdownListenerName()
          Retrieves the human-readable name for this shutdown listener.
 TextWriter getWrappedWriter()
          Retrieves the wrapped writer.
 void processServerShutdown(Message reason)
          Indicates that the Directory Server has received a request to stop running and that this shutdown listener should take any action necessary to prepare for it.
 void setAutoFlush(boolean autoFlush)
          Set the auto flush setting for this writer.
 void shutdown()
          Releases any resources held by the writer.
 void shutdown(boolean shutdownWrapped)
          Releases any resources held by the writer.
 void writeRecord(java.lang.String record)
          Write the log record asyncronously.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncronousTextWriter

public AsyncronousTextWriter(java.lang.String name,
                             int capacity,
                             boolean autoFlush,
                             TextWriter writer)
Construct a new AsyncronousTextWriter wrapper.

Parameters:
name - the name of the thread.
capacity - the size of the queue before it gets flushed.
autoFlush - indicates if the underlying writer should be flushed after the queue is flushed.
writer - a character stream used for output.
Method Detail

writeRecord

public void writeRecord(java.lang.String record)
Write the log record asyncronously.

Specified by:
writeRecord in interface TextWriter
Parameters:
record - the log record to write.

flush

public void flush()
Flushes any buffered contents of the output stream.

Specified by:
flush in interface TextWriter

getBytesWritten

public long getBytesWritten()
Retrieves the number of bytes written by this writer.

Specified by:
getBytesWritten in interface TextWriter
Returns:
the number of bytes written by this writer.

getWrappedWriter

public TextWriter getWrappedWriter()
Retrieves the wrapped writer.

Returns:
The wrapped writer used by this asyncronous writer.

getShutdownListenerName

public java.lang.String getShutdownListenerName()
Retrieves the human-readable name for this shutdown listener.

Specified by:
getShutdownListenerName in interface ServerShutdownListener
Returns:
The human-readable name for this shutdown listener.

processServerShutdown

public void processServerShutdown(Message reason)
Indicates that the Directory Server has received a request to stop running and that this shutdown listener should take any action necessary to prepare for it.

Specified by:
processServerShutdown in interface ServerShutdownListener
Parameters:
reason - The human-readable reason for the shutdown.

shutdown

public void shutdown()
Releases any resources held by the writer.

Specified by:
shutdown in interface TextWriter

shutdown

public void shutdown(boolean shutdownWrapped)
Releases any resources held by the writer.

Parameters:
shutdownWrapped - If the wrapped writer should be closed as well.

setAutoFlush

public void setAutoFlush(boolean autoFlush)
Set the auto flush setting for this writer.

Parameters:
autoFlush - If the writer should flush the buffer after every line.