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