com.twitter.common.thrift
Class Config

java.lang.Object
  extended by com.twitter.common.thrift.Config

public class Config
extends Object

Represents the configuration for a thrift call. Use builder() to create a new one or or builder(Config) to create a new config based on another config.

If a deadline is specified, it acts as a global timeout for each thrift call made. Obtaining connections, performing the remote call and executing retries are all expected to complete within this deadline. When the specified deadline is not met, an TTimeoutException will be thrown.

If max retries is specified as zero (never retry), then the list of retryable exceptions are ignored. It is only when max retries is greater than zero that list of retryable exceptions is used to determine if a particular failed call should be retried.


Nested Class Summary
static class Config.AbstractBuilder<T extends Config.AbstractBuilder>
           
static class Config.Builder
           
 
Method Summary
static Config.Builder builder()
          Created a builder for a new Config.
static Config.Builder builder(Config config)
           
 boolean enableStats()
          Returns true if the client should track request statistics.
 Amount<Long,Time> getConnectTimeout()
          Returns the maximum time to wait for a connection to be established.
 int getMaxRetries()
          Returns the maximum number of retries to perform for each thrift call.
 Amount<Long,Time> getRequestTimeout()
          Returns the maximum time to wait for any thrift call to complete.
 ImmutableSet<Class<? extends Exception>> getRetryableExceptions()
          Returns the set of exceptions to retry calls for.
 StatsProvider getStatsProvider()
          Returns the stats provider to use to record Thrift client stats.
 boolean isDebug()
          Returns true if the client should log extra debugging information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

builder

public static Config.Builder builder()
Created a builder for a new Config. Default values are as follows:


builder

public static Config.Builder builder(Config config)
Parameters:
config -
Returns:

getRequestTimeout

public Amount<Long,Time> getRequestTimeout()
Returns the maximum time to wait for any thrift call to complete. A deadline of 0 means to wait forever


getConnectTimeout

public Amount<Long,Time> getConnectTimeout()
Returns the maximum time to wait for a connection to be established. A deadline of 0 means to wait forever


getMaxRetries

public int getMaxRetries()
Returns the maximum number of retries to perform for each thrift call. A value of 0 means to never retry and in this case getRetryableExceptions() will be an empty set.


getRetryableExceptions

public ImmutableSet<Class<? extends Exception>> getRetryableExceptions()
Returns the set of exceptions to retry calls for. The returned set will only be empty if getMaxRetries() is 0.


isDebug

public boolean isDebug()
Returns true if the client should log extra debugging information. Currently this includes method call arguments when RPCs fail with exceptions.


enableStats

public boolean enableStats()
Returns true if the client should track request statistics.


getStatsProvider

public StatsProvider getStatsProvider()
Returns the stats provider to use to record Thrift client stats.