Search in sources :

Example 1 with TTimeoutException

use of com.twitter.common.thrift.TTimeoutException in project commons by twitter.

the class StatTrackingCaller method call.

@Override
public Object call(Method method, Object[] args, @Nullable AsyncMethodCallback callback, @Nullable Amount<Long, Time> connectTimeoutOverride) throws Throwable {
    final RequestTimer requestStats = stats.get(method);
    final long startTime = System.nanoTime();
    ResultCapture capture = new ResultCapture() {

        @Override
        public void success() {
            requestStats.requestComplete(TimeUnit.NANOSECONDS.toMicros(System.nanoTime() - startTime));
        }

        @Override
        public boolean fail(Throwable t) {
            // backoff mechanism - consider how to plumb something similar.
            if (t instanceof TTimeoutException || t instanceof TimeoutException) {
                requestStats.incTimeouts();
                return true;
            }
            // it stands.
            if (!(t instanceof TResourceExhaustedException)) {
                requestStats.incReconnects();
            }
            // TODO(John Sirois): provide more detailed stats: track counts for distinct exceptions types,
            // track retries-per-method, etc...
            requestStats.incErrors();
            return true;
        }
    };
    return invoke(method, args, callback, capture, connectTimeoutOverride);
}
Also used : TResourceExhaustedException(com.twitter.common.thrift.TResourceExhaustedException) TTimeoutException(com.twitter.common.thrift.TTimeoutException) RequestTimer(com.twitter.common.stats.StatsProvider.RequestTimer) TTimeoutException(com.twitter.common.thrift.TTimeoutException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

RequestTimer (com.twitter.common.stats.StatsProvider.RequestTimer)1 TResourceExhaustedException (com.twitter.common.thrift.TResourceExhaustedException)1 TTimeoutException (com.twitter.common.thrift.TTimeoutException)1 TimeoutException (java.util.concurrent.TimeoutException)1