All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.zhengframework.configuration.reload.MeteredReloadable Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
package com.github.zhengframework.configuration.reload;

import static java.util.Objects.requireNonNull;

import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;

public class MeteredReloadable implements Reloadable {

  private final Reloadable delegate;
  private final Timer reloadTimer;

  public MeteredReloadable(MetricRegistry metricRegistry, String metricPrefix,
      Reloadable delegate) {
    requireNonNull(metricRegistry);
    requireNonNull(metricPrefix);
    this.delegate = requireNonNull(delegate);

    reloadTimer = metricRegistry.timer(metricPrefix + "reloadable.reload");
  }

  @Override
  public void reload() {
    Timer.Context context = reloadTimer.time();
    try {
      delegate.reload();
    } finally {
      context.stop();
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy