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

java.lang.Object
  extended by com.twitter.common.logging.BufferedLog.Builder<T,R>
Type Parameters:
T - Log message type.
R - Log result type.
Enclosing class:
BufferedLog<T,R>

public static class BufferedLog.Builder<T,R>
extends Object

Configures a BufferedLog object.


Constructor Summary
BufferedLog.Builder()
           
 
Method Summary
 BufferedLog.Builder<T,R> buffer(Log<T,R> bufferedLog)
          Specifies the log that should be buffered.
 BufferedLog<T,R> build()
          Creates the buffered log.
 BufferedLog.Builder<T,R> withChunkLength(int chunkLength)
          Specifies the desired number of log records to submit in each request.
 BufferedLog.Builder<T,R> withExecutorService(ExecutorService logSubmitService)
          Specifies the executor service to use for (synchronously or asynchronously) sending log entries.
 BufferedLog.Builder<T,R> withFlushInterval(Amount<Integer,Time> flushInterval)
          Specifies the maximum amount of time that a log entry may wait in the buffer before an attempt is made to flush the buffer.
 BufferedLog.Builder<T,R> withMaxBuffer(int maxBufferSize)
          Specifies the maximum allowable buffer size, after which log records will be dropped to conserve memory.
 BufferedLog.Builder<T,R> withRetryFilter(Predicate<R> retryFilter)
          Adds a custom retry filter that will be used to determine whether a log result R should be used to indicate that a log request should be retried.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferedLog.Builder

public BufferedLog.Builder()
Method Detail

buffer

public BufferedLog.Builder<T,R> buffer(Log<T,R> bufferedLog)
Specifies the log that should be buffered.

Parameters:
bufferedLog - Log to buffer requests to.
Returns:
A reference to the builder.

withRetryFilter

public BufferedLog.Builder<T,R> withRetryFilter(Predicate<R> retryFilter)
Adds a custom retry filter that will be used to determine whether a log result R should be used to indicate that a log request should be retried. Log submit retry behavior is not defined when the filter throws uncaught exceptions.

Parameters:
retryFilter - Filter to determine whether to retry.
Returns:
A reference to the builder.

withMaxBuffer

public BufferedLog.Builder<T,R> withMaxBuffer(int maxBufferSize)
Specifies the maximum allowable buffer size, after which log records will be dropped to conserve memory.

Parameters:
maxBufferSize - Maximum buffer size.
Returns:
A reference to the builder.

withChunkLength

public BufferedLog.Builder<T,R> withChunkLength(int chunkLength)
Specifies the desired number of log records to submit in each request.

Parameters:
chunkLength - Maximum number of records to accumulate before trying to submit.
Returns:
A reference to the builder.

withFlushInterval

public BufferedLog.Builder<T,R> withFlushInterval(Amount<Integer,Time> flushInterval)
Specifies the maximum amount of time that a log entry may wait in the buffer before an attempt is made to flush the buffer.

Parameters:
flushInterval - Log flush interval.
Returns:
A reference to the builder.

withExecutorService

public BufferedLog.Builder<T,R> withExecutorService(ExecutorService logSubmitService)
Specifies the executor service to use for (synchronously or asynchronously) sending log entries.

Parameters:
logSubmitService - Log submit executor service.
Returns:
A reference to the builder.

build

public BufferedLog<T,R> build()
Creates the buffered log.

Returns:
The prepared buffered log.