Exemple #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;
  }
Exemple #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);
 }
Exemple #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);
 }
Exemple #4
0
 @Override
 public void close() {
   addValue(Duration.nanosSince(start));
 }
Exemple #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;
 }
Exemple #6
0
 public void addValue(Duration duration) {
   sample.update(duration.toMillis());
   sum.addAndGet(duration.toMillis());
   count.incrementAndGet();
 }
 @EventField
 public double getDuration() {
   return duration.toMillis();
 }