public <T> T invoke(final Callable<T> c) throws Exception { final LatencyTracker latencyTracker = new LatencyTracker(); try { T result = requestCounter.invoke(new Callable<T>() { public T call() throws Exception { return latencyTracker.invoke(c); } }); recordSuccess(latencyTracker); return result; } catch (Exception e) { recordFailure(latencyTracker); if (WRAP_MSG.equals(e.getMessage())) { throw (Exception)e.getCause(); } else { throw e; } } }
public void invoke(final Runnable r) throws Exception { final LatencyTracker latencyTracker = new LatencyTracker(); try { requestCounter.invoke(new Runnable() { public void run() { try { latencyTracker.invoke(r); } catch (Exception e) { throw new RuntimeException(WRAP_MSG, e); } } }); recordSuccess(latencyTracker); } catch (RuntimeException re) { recordFailure(latencyTracker); if (WRAP_MSG.equals(re.getMessage())) { throw (Exception)re.getCause(); } else { throw re; } } }