@Config("store.ttl") public StoreConfig setTtl(Duration ttl) { Preconditions.checkNotNull( ttl, "ttl must not be null"); // TODO: remove once configuration supports bean validation Preconditions.checkArgument(ttl.toMillis() > 0, "ttl must be > 0"); this.ttl = ttl; return this; }
public void record( String method, int responseCode, long requestSizeInBytes, long responseSizeInBytes, Duration schedulingDelay, Duration requestProcessingTime) { request.update(1); requestTime.update((long) requestProcessingTime.toMillis()); readBytes.update(requestSizeInBytes); writtenBytes.update(responseSizeInBytes); }
private void scheduleNextAnnouncement(Duration delay) { // already stopped? avoids rejection exception if (executor.isShutdown()) { return; } executor.schedule( new Runnable() { @Override public void run() { announce(); } }, delay.toMillis(), MILLISECONDS); }
@Override public void close() { addValue(Duration.nanosSince(start)); }
public <T> T time(Callable<T> callable) throws Exception { long start = System.nanoTime(); T result = callable.call(); addValue(Duration.nanosSince(start)); return result; }
public void addValue(Duration duration) { sample.update(duration.toMillis()); sum.addAndGet(duration.toMillis()); count.incrementAndGet(); }
@EventField public double getDuration() { return duration.toMillis(); }