MonitoringClientCallListener(Listener<RespT> delegate, ClientStats stats) { this.delegate = delegate; this.stats = stats; this.startNanos = MathUtils.nowInNano(); }
TimedRunnable(Runnable runnable) { this.runnable = runnable; this.initNanos = MathUtils.nowInNano(); }
TimedCallable(Callable<T> callable) { this.callable = callable; this.initNanos = MathUtils.nowInNano(); }
MonitoringServerCall(ServerCall<ReqT, RespT> delegate, ServerStats stats) { super(delegate); this.stats = stats; this.startNanos = MathUtils.nowInNano(); stats.recordCallStarted(); }
@Override public void run() { taskPendingStats.registerSuccessfulEvent(MathUtils.elapsedNanos(initNanos), TimeUnit.NANOSECONDS); long startNanos = MathUtils.nowInNano(); try { this.runnable.run(); } finally { long elapsedMicroSec = MathUtils.elapsedMicroSec(startNanos); taskExecutionStats.registerSuccessfulEvent(elapsedMicroSec, TimeUnit.MICROSECONDS); if (elapsedMicroSec >= warnTimeMicroSec) { log.warn("Runnable {}:{} took too long {} micros to execute.", runnable, runnable.getClass(), elapsedMicroSec); } } } }
@Override public T call() throws Exception { taskPendingStats.registerSuccessfulEvent(MathUtils.elapsedNanos(initNanos), TimeUnit.NANOSECONDS); long startNanos = MathUtils.nowInNano(); try { return this.callable.call(); } finally { long elapsedMicroSec = MathUtils.elapsedMicroSec(startNanos); taskExecutionStats.registerSuccessfulEvent(elapsedMicroSec, TimeUnit.MICROSECONDS); if (elapsedMicroSec >= warnTimeMicroSec) { log.warn("Callable {}:{} took too long {} micros to execute.", callable, callable.getClass(), elapsedMicroSec); } } } }
int ackQuorumSize, Map<String, byte[]> customMetadata) throws BKNotEnoughBookiesException { long startTime = MathUtils.nowInNano(); EnsemblePlacementPolicy.PlacementResult<List<BookieSocketAddress>> newEnsembleResponse; List<BookieSocketAddress> socketAddresses; newEnsembleTimer.registerSuccessfulEvent(MathUtils.nowInNano() - startTime, TimeUnit.NANOSECONDS); } catch (BKNotEnoughBookiesException e) { if (log.isDebugEnabled()) { log.warn("New ensemble: {} is not adhering to Placement Policy", socketAddresses); newEnsembleTimer.registerFailedEvent(MathUtils.nowInNano() - startTime, TimeUnit.NANOSECONDS);
Set<BookieSocketAddress> excludeBookies) throws BKNotEnoughBookiesException { long startTime = MathUtils.nowInNano(); BookieSocketAddress addr = existingBookies.get(bookieIdx); EnsemblePlacementPolicy.PlacementResult<BookieSocketAddress> replaceBookieResponse; addr, existingBookies, socketAddress, excludeBookies, quarantinedBookiesSet); replaceBookieTimer.registerSuccessfulEvent(MathUtils.nowInNano() - startTime, TimeUnit.NANOSECONDS); } catch (BKNotEnoughBookiesException e) { if (log.isDebugEnabled()) { addr, existingBookies, socketAddress, excludeBookies); replaceBookieTimer.registerFailedEvent(MathUtils.nowInNano() - startTime, TimeUnit.NANOSECONDS);
protected void onReadRequestStart(Channel channel) { if (readsSemaphore != null) { if (!readsSemaphore.tryAcquire()) { final long throttlingStartTimeNanos = MathUtils.nowInNano(); channel.config().setAutoRead(false); LOG.info("Too many read requests in progress, disabling autoread on channel {}", channel); requestStats.blockReadRequest(); readsSemaphore.acquireUninterruptibly(); channel.config().setAutoRead(true); final long delayNanos = MathUtils.elapsedNanos(throttlingStartTimeNanos); LOG.info("Re-enabled autoread on channel {} after ReadRequest delay of {} nanos", channel, delayNanos); requestStats.unblockReadRequest(delayNanos); } } requestStats.trackReadRequest(); }
protected void onAddRequestStart(Channel channel) { if (addsSemaphore != null) { if (!addsSemaphore.tryAcquire()) { final long throttlingStartTimeNanos = MathUtils.nowInNano(); channel.config().setAutoRead(false); LOG.info("Too many add requests in progress, disabling autoread on channel {}", channel); requestStats.blockAddRequest(); addsSemaphore.acquireUninterruptibly(); channel.config().setAutoRead(true); final long delayNanos = MathUtils.elapsedNanos(throttlingStartTimeNanos); LOG.info("Re-enabled autoread on channel {} after AddRequest delay of {} nanos", channel, delayNanos); requestStats.unblockAddRequest(delayNanos); } } requestStats.trackAddRequest(); }