com.twitter.common.thrift.callers
Class StatTrackingCaller

java.lang.Object
  extended by com.twitter.common.thrift.callers.StatTrackingCaller
All Implemented Interfaces:
Caller

public class StatTrackingCaller
extends Object

A caller that exports statistics about calls made to the wrapped caller.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.twitter.common.thrift.callers.Caller
Caller.ResultCapture, Caller.WrappedMethodCallback
 
Constructor Summary
StatTrackingCaller(Caller decoratedCaller, boolean async, StatsProvider statsProvider, String serviceName)
          Creates a new stat tracking caller, which will export stats to the given StatsProvider.
 
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.
protected  Object invoke(Method method, Object[] args, org.apache.thrift.async.AsyncMethodCallback callback, Caller.ResultCapture capture, Amount<Long,Time> connectTimeoutOverride)
          Convenience method for invoking the method and shunting the capture into the callback if the call is asynchronous.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatTrackingCaller

public StatTrackingCaller(Caller decoratedCaller,
                          boolean async,
                          StatsProvider statsProvider,
                          String serviceName)
Creates a new stat tracking caller, which will export stats to the given StatsProvider.

Parameters:
decoratedCaller - The caller to decorate with a deadline.
async - Whether the caller is asynchronous.
statsProvider - The stat provider to export statistics to.
serviceName - The name of the service that methods are being called on.
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.

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.

invoke

protected final Object invoke(Method method,
                              Object[] args,
                              @Nullable
                              org.apache.thrift.async.AsyncMethodCallback callback,
                              @Nullable
                              Caller.ResultCapture capture,
                              @Nullable
                              Amount<Long,Time> connectTimeoutOverride)
                       throws Throwable
Convenience method for invoking the method and shunting the capture into the callback if the call is asynchronous.

Parameters:
method - The method being invoked.
args - The arguments to call method with.
callback - The callback to use if the method is asynchronous.
capture - The result capture to notify of the call result.
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.