TimedCallable(Callable<T> callable) { this.callable = callable; this.initNanos = MathUtils.nowInNano(); }
/** * skip hashcode generation in this special case. * * @param orderingKey long ordering key * @return the thread for executing this order key */ public ExecutorService chooseThread(long orderingKey) { if (threads.length == 1) { return threads[0]; } return threads[MathUtils.signSafeMod(orderingKey, threads.length)]; }
@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); } } } }
long startTime = MathUtils.nowInNano(); log.debug("iteration took {} ms", MathUtils.elapsedNanos(startTime) / 1e6); startTime = MathUtils.nowInNano(); log.debug("sorting {} ms", (MathUtils.elapsedNanos(startTime) / 1e6)); startTime = MathUtils.nowInNano(); log.debug("entry log adding {} ms", MathUtils.elapsedNanos(startTime) / 1e6);
final long startTime = MathUtils.nowInNano(); boolean success = isWritesetWritable(writeSet, key, allowedNonWritableCount); if (MathUtils.nowInNano() < deadline) { long maxSleep = MathUtils.elapsedMSec(startTime); if (maxSleep < 0) { maxSleep = 1; MathUtils.elapsedMSec(startTime), writeSet.size() - allowedNonWritableCount); MathUtils.elapsedNanos(startTime), TimeUnit.NANOSECONDS); } else { clientChannelWriteWaitStats.registerFailedEvent( MathUtils.elapsedNanos(startTime), TimeUnit.NANOSECONDS);
@Override public void close(Status status, Metadata trailers) { stats.recordServerHandled(status.getCode()); if (stats.shouldRecordLatency()) { long latencyMicros = MathUtils.elapsedMicroSec(startNanos); stats.recordLatency(Status.OK == status, latencyMicros); } super.close(status, trailers); } }
@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); } } } }
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(); }
@Override public void onClose(Status status, Metadata trailers) { stats.recordClientHandled(status.getCode()); if (stats.shouldRecordLatency()) { long latencyMicros = MathUtils.elapsedMicroSec(startNanos); stats.recordLatency(Status.OK == status, latencyMicros); } super.onClose(status, trailers); }
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(); }
MonitoringClientCallListener(Listener<RespT> delegate, ClientStats stats) { this.delegate = delegate; this.stats = stats; this.startNanos = MathUtils.nowInNano(); }
public long getThreadID(long orderingKey) { // skip hashcode generation in this special case if (threadIds.length == 1) { return threadIds[0]; } return threadIds[MathUtils.signSafeMod(orderingKey, threadIds.length)]; }
TimedRunnable(Runnable runnable) { this.runnable = runnable; this.initNanos = MathUtils.nowInNano(); }
private SingleDirectoryDbLedgerStorage getLedgerSorage(long ledgerId) { return ledgerStorageList.get(MathUtils.signSafeMod(ledgerId, numberOfDirs)); }
MonitoringServerCall(ServerCall<ReqT, RespT> delegate, ServerStats stats) { super(delegate); this.stats = stats; this.startNanos = MathUtils.nowInNano(); stats.recordCallStarted(); }
public ExecutorService chooseThread(Object orderingKey) { // skip hashcode generation in this special case if (threads.length == 1) { return threads[0]; } if (null == orderingKey) { return threads[rand.nextInt(threads.length)]; } else { return threads[MathUtils.signSafeMod(orderingKey.hashCode(), threads.length)]; } }
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);
/** * Find next broker {@link LoadManagerReport} in round-robin fashion. * * @return * @throws PulsarServerException */ LoadManagerReport nextBroker() throws PulsarServerException { List<LoadManagerReport> availableBrokers = localZkCache.getAvailableBrokers(); if (availableBrokers.isEmpty()) { throw new PulsarServerException("No active broker is available"); } else { int brokersCount = availableBrokers.size(); int nextIdx = signSafeMod(counter.getAndIncrement(), brokersCount); return availableBrokers.get(nextIdx); } }
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);
List<File> ledgerDirs = ledgerDirsManager.getAllLedgerDirs(); int dirIndex = MathUtils.signSafeMod(ledgerId, ledgerDirs.size()); String ledgerBasePath = ledgerDirs.get(dirIndex).toString();