com.twitter.common.thrift.callers
Class ThriftCaller<T>

java.lang.Object
  extended by com.twitter.common.thrift.callers.ThriftCaller<T>
All Implemented Interfaces:
Caller

public class ThriftCaller<T>
extends Object
implements Caller

A caller that issues calls to a target that is assumed to be a client to a thrift service.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.twitter.common.thrift.callers.Caller
Caller.ResultCapture, Caller.WrappedMethodCallback
 
Constructor Summary
ThriftCaller(ObjectPool<Connection<org.apache.thrift.transport.TTransport,InetSocketAddress>> connectionPool, RequestTracker<InetSocketAddress> requestTracker, Function<org.apache.thrift.transport.TTransport,T> clientFactory, Amount<Long,Time> timeout, boolean debug)
          Creates a new thrift caller.
 
Method Summary
 Object call(Method method, Object[] args, org.apache.thrift.async.AsyncMethodCallback callback, Amount<Long,Time> connectTimeoutOverride)
          Invokes a method on an object, using the given arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThriftCaller

public ThriftCaller(ObjectPool<Connection<org.apache.thrift.transport.TTransport,InetSocketAddress>> connectionPool,
                    RequestTracker<InetSocketAddress> requestTracker,
                    Function<org.apache.thrift.transport.TTransport,T> clientFactory,
                    Amount<Long,Time> timeout,
                    boolean debug)
Creates a new thrift caller.

Parameters:
connectionPool - The connection pool to use.
requestTracker - The request tracker to nofify of request results.
clientFactory - Factory to use for building client object instances.
timeout - The timeout to use when requesting objects from the connection pool.
debug - Whether to use the caller in debug mode.
Method Detail

call

public Object call(Method method,
                   Object[] args,
                   @Nullable
                   org.apache.thrift.async.AsyncMethodCallback callback,
                   @Nullable
                   Amount<Long,Time> connectTimeoutOverride)
            throws Throwable
Description copied from interface: Caller
Invokes a method on an object, using the given arguments. The method call may be asynchronous, in which case callback will be non-null.

Specified by:
call in interface Caller
Parameters:
method - The method being invoked.
args - The arguments to call method with.
callback - The callback to use if the method is asynchronous.
connectTimeoutOverride - Optional override for the default connection timeout.
Returns:
The return value from invoking the method.
Throws:
Throwable - Exception, as prescribed by the method's contract.