com.twitter.common.logging
Class BufferedLog<T,R>

java.lang.Object
  extended by com.twitter.common.logging.BufferedLog<T,R>
All Implemented Interfaces:
Log<T,Void>

public class BufferedLog<T,R>
extends Object
implements Log<T,Void>

Log that buffers requests before sending them to a wrapped log.


Nested Class Summary
static class BufferedLog.Builder<T,R>
          Configures a BufferedLog object.
 
Method Summary
static
<T,R> BufferedLog.Builder<T,R>
builder()
           
 void flush()
          Flushes the log, attempting to purge any state that is only stored locally.
protected  int getBacklog()
          Gets the current number of messages in the local buffer.
 Void log(List<T> entries)
          Batch version of log.
 Void log(T entry)
          Stores a log entry, flushing immediately if the buffer length limit is exceeded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

builder

public static <T,R> BufferedLog.Builder<T,R> builder()

getBacklog

protected int getBacklog()
Gets the current number of messages in the local buffer.

Returns:
The number of backlogged messages.

log

public Void log(T entry)
Stores a log entry, flushing immediately if the buffer length limit is exceeded.

Specified by:
log in interface Log<T,Void>
Parameters:
entry - Entry to log.
Returns:
The result of the log request.

log

public Void log(List<T> entries)
Description copied from interface: Log
Batch version of log.

Specified by:
log in interface Log<T,Void>
Parameters:
entries - Entries to log.
Returns:
The result of the log request.

flush

public void flush()
Description copied from interface: Log
Flushes the log, attempting to purge any state that is only stored locally.

Specified by:
flush in interface Log<T,Void>