@Test public void testResetAllMetrics() { String counterName = "Worker.Counter"; MetricsSystem.counter(counterName).inc(); assertEquals(1, MetricsSystem.counter(counterName).getCount()); String meterName = "Worker.Meter"; MetricsSystem.meter(meterName).mark(1000); assertEquals(1000, MetricsSystem.meter(meterName).getCount()); String timerName = "Worker.Timer"; MetricsSystem.timer(timerName).time().close(); assertEquals(1, MetricsSystem.timer(timerName).getCount()); MetricsSystem.resetAllMetrics(); assertEquals(0, MetricsSystem.counter(counterName).getCount()); assertEquals(0, MetricsSystem.meter(meterName).getCount()); assertEquals(0, MetricsSystem.reportWorkerMetrics().size()); assertEquals(0, MetricsSystem.timer(timerName).getCount()); }
public static synchronized void resetAllMetrics() { long startTime = System.currentTimeMillis(); for (Counter counter : METRIC_REGISTRY.getCounters().values()) { counter.dec(counter.getCount()); } for (String meterName : METRIC_REGISTRY.getMeters().keySet()) { METRIC_REGISTRY.remove(meterName); METRIC_REGISTRY.meter(meterName); } for (String timerName : METRIC_REGISTRY.getTimers().keySet()) { METRIC_REGISTRY.remove(timerName); METRIC_REGISTRY.timer(timerName); } LAST_REPORTED_METRICS.clear(); LOG.info("Reset all metrics in the metrics system in {}ms", System.currentTimeMillis() - startTime); }
MetricsSystem { public static synchronized void resetAllMetrics() { long startTime = System.currentTimeMillis(); for (Counter counter : METRIC_REGISTRY.getCounters().values()) { counter.dec(counter.getCount()); } for (String meterName : METRIC_REGISTRY.getMeters().keySet()) { METRIC_REGISTRY.remove(meterName); METRIC_REGISTRY.meter(meterName); } for (String timerName : METRIC_REGISTRY.getTimers().keySet()) { METRIC_REGISTRY.remove(timerName); METRIC_REGISTRY.timer(timerName); } LAST_REPORTED_METRICS.clear(); LOG.info("Reset all metrics in the metrics system in {}ms", System.currentTimeMillis() - startTime); } }
MetricsSystem { public static synchronized void resetAllMetrics() { long startTime = System.currentTimeMillis(); for (Counter counter : METRIC_REGISTRY.getCounters().values()) { counter.dec(counter.getCount()); } for (String meterName : METRIC_REGISTRY.getMeters().keySet()) { METRIC_REGISTRY.remove(meterName); METRIC_REGISTRY.meter(meterName); } for (String timerName : METRIC_REGISTRY.getTimers().keySet()) { METRIC_REGISTRY.remove(timerName); METRIC_REGISTRY.timer(timerName); } LAST_REPORTED_METRICS.clear(); LOG.info("Reset all metrics in the metrics system in {}ms", System.currentTimeMillis() - startTime); } private  MetricsSystem(); }
MetricsSystem { public static synchronized void resetAllMetrics() { long startTime = System.currentTimeMillis(); for (Counter counter : METRIC_REGISTRY.getCounters().values()) { counter.dec(counter.getCount()); } for (String meterName : METRIC_REGISTRY.getMeters().keySet()) { METRIC_REGISTRY.remove(meterName); METRIC_REGISTRY.meter(meterName); } for (String timerName : METRIC_REGISTRY.getTimers().keySet()) { METRIC_REGISTRY.remove(timerName); METRIC_REGISTRY.timer(timerName); } LAST_REPORTED_METRICS.clear(); LOG.info("Reset all metrics in the metrics system in {}ms", System.currentTimeMillis() - startTime); } private  MetricsSystem(); static void startSinks(String metricsConfFile); static synchronized void startSinksFromConfig(MetricsConfig config); static synchronized void stopSinks(); static synchronized int getNumSinks(); static String getMetricName(String name); static String getMasterMetricName(String name); static String getJobWorkerMetricName(String name); static void checkMinimalPollingPeriod(TimeUnit pollUnit, int pollPeriod); static String stripInstanceAndHost(String metricsName); static String escape(AlluxioURI uri); static String unescape(String uri); static Counter counter(String name); static Counter counterWithTags(String name, boolean shouldReport, String... tags); static Meter meter(String name); static Meter meterWithTags(String name, boolean shouldReport, String... tags); static Timer timer(String name); static synchronized void registerGaugeIfAbsent(String name, Gauge<T> metric); static List<alluxio.grpc.Metric> reportWorkerMetrics(); static List<alluxio.grpc.Metric> reportClientMetrics(); static Map<String, Set<Metric>> getMasterMetrics(Set<String> metricNames); @Nullable static Metric getMetricValue(String fullName); static Map<String, MetricValue> allMetrics(); @VisibleForTesting static void initShouldReportMetrics(InstanceType instanceType); static synchronized void resetAllMetrics(); @VisibleForTesting static void clearAllMetrics(); @VisibleForTesting static void resetCountersAndGauges(); }
MetricsSystem { public static synchronized void resetAllMetrics() { long startTime = System.currentTimeMillis(); for (Counter counter : METRIC_REGISTRY.getCounters().values()) { counter.dec(counter.getCount()); } for (String meterName : METRIC_REGISTRY.getMeters().keySet()) { METRIC_REGISTRY.remove(meterName); METRIC_REGISTRY.meter(meterName); } for (String timerName : METRIC_REGISTRY.getTimers().keySet()) { METRIC_REGISTRY.remove(timerName); METRIC_REGISTRY.timer(timerName); } LAST_REPORTED_METRICS.clear(); LOG.info("Reset all metrics in the metrics system in {}ms", System.currentTimeMillis() - startTime); } private  MetricsSystem(); static void startSinks(String metricsConfFile); static synchronized void startSinksFromConfig(MetricsConfig config); static synchronized void stopSinks(); static synchronized int getNumSinks(); static String getMetricName(String name); static String getMasterMetricName(String name); static String getJobWorkerMetricName(String name); static void checkMinimalPollingPeriod(TimeUnit pollUnit, int pollPeriod); static String stripInstanceAndHost(String metricsName); static String escape(AlluxioURI uri); static String unescape(String uri); static Counter counter(String name); static Counter counterWithTags(String name, boolean shouldReport, String... tags); static Meter meter(String name); static Meter meterWithTags(String name, boolean shouldReport, String... tags); static Timer timer(String name); static synchronized void registerGaugeIfAbsent(String name, Gauge<T> metric); static List<alluxio.grpc.Metric> reportWorkerMetrics(); static List<alluxio.grpc.Metric> reportClientMetrics(); static Map<String, Set<Metric>> getMasterMetrics(Set<String> metricNames); @Nullable static Metric getMetricValue(String fullName); static Map<String, MetricValue> allMetrics(); @VisibleForTesting static void initShouldReportMetrics(InstanceType instanceType); static synchronized void resetAllMetrics(); @VisibleForTesting static void clearAllMetrics(); @VisibleForTesting static void resetCountersAndGauges(); static final String CLUSTER; static final MetricRegistry METRIC_REGISTRY; static final String SINK_REGEX; }