Пример #1
0
  @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;
  }
Пример #2
0
 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);
 }
Пример #3
0
 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);
 }
Пример #4
0
 @Override
 public void close() {
   addValue(Duration.nanosSince(start));
 }
Пример #5
0
 public <T> T time(Callable<T> callable) throws Exception {
   long start = System.nanoTime();
   T result = callable.call();
   addValue(Duration.nanosSince(start));
   return result;
 }
Пример #6
0
 public void addValue(Duration duration) {
   sample.update(duration.toMillis());
   sum.addAndGet(duration.toMillis());
   count.incrementAndGet();
 }
Пример #7
0
 @EventField
 public double getDuration() {
   return duration.toMillis();
 }