コード例 #1
0
  public static final class ConfigBuilder {
    // Default values for Config
    private MetricsRegistry metricsRegistry = Metrics.defaultRegistry();
    private MetricPredicate predicate = MetricPredicate.ALL;
    private boolean printVMMetrics = true;
    private String host = "localhost";
    private int port = 5555;
    private long period = 60;
    private TimeUnit unit = TimeUnit.SECONDS;
    private String prefix = null;
    private String separator = " ";
    private final VirtualMachineMetrics vm = VirtualMachineMetrics.getInstance();
    private Clock clock = Clock.defaultClock();
    private String name = "riemann-reporter";
    private String localHost = null;

    private ConfigBuilder() {}

    public Config build() {
      return new Config(
          metricsRegistry,
          predicate,
          printVMMetrics,
          host,
          port,
          period,
          unit,
          prefix,
          separator,
          clock,
          name,
          localHost);
    }

    public ConfigBuilder metricsRegistry(MetricsRegistry r) {
      metricsRegistry = r;
      return this;
    }

    public ConfigBuilder predicate(MetricPredicate p) {
      predicate = p;
      return this;
    }

    public ConfigBuilder printVMMetrics(Boolean p) {
      printVMMetrics = p;
      return this;
    }

    public ConfigBuilder host(String h) {
      host = h;
      return this;
    }

    public ConfigBuilder port(int p) {
      port = p;
      return this;
    }

    public ConfigBuilder period(long p) {
      period = p;
      return this;
    }

    public ConfigBuilder unit(TimeUnit t) {
      unit = t;
      return this;
    }

    public ConfigBuilder prefix(String p) {
      prefix = p;
      return this;
    }

    public ConfigBuilder separator(String s) {
      separator = s;
      return this;
    }

    public ConfigBuilder clock(Clock c) {
      clock = c;
      return this;
    }

    public ConfigBuilder name(String n) {
      name = n;
      return this;
    }

    public ConfigBuilder localHost(String l) {
      localHost = l;
      return this;
    }
  }
コード例 #2
0
  public static class Config {
    public MetricsRegistry metricsRegistry = Metrics.defaultRegistry();
    public MetricPredicate predicate = MetricPredicate.ALL;
    public boolean printVMMetrics = false;
    public String host = "localhost";
    public int port = 5555;
    public long period = 60;
    public TimeUnit unit = TimeUnit.SECONDS;
    public String prefix = null;
    public String separator = " ";
    public final VirtualMachineMetrics vm = VirtualMachineMetrics.getInstance();
    public Clock clock = Clock.defaultClock();
    public String name = "riemann-reporter";
    public String localHost = null;

    public Config() {}

    public Config metricsRegistry(MetricsRegistry r) {
      metricsRegistry = r;
      return this;
    }

    public Config predicate(MetricPredicate p) {
      predicate = p;
      return this;
    }

    public Config printVMMetrics(Boolean p) {
      printVMMetrics = p;
      return this;
    }

    public Config host(String h) {
      host = h;
      return this;
    }

    public Config port(int p) {
      port = p;
      return this;
    }

    public Config period(long p) {
      period = p;
      return this;
    }

    public Config unit(TimeUnit t) {
      unit = t;
      return this;
    }

    public Config prefix(String p) {
      prefix = p;
      return this;
    }

    public Config separator(String s) {
      separator = s;
      return this;
    }

    public Config clock(Clock c) {
      clock = c;
      return this;
    }

    public Config name(String n) {
      name = n;
      return this;
    }

    public Config localHost(String l) {
      localHost = l;
      return this;
    }
  }