You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by el...@apache.org on 2016/03/08 23:10:38 UTC
[3/3] calcite git commit: [CALCITE-1133] Remove dropwizard-metrics2
module
[CALCITE-1133] Remove dropwizard-metrics2 module
Calcite doesn't need to own this code, it can live outside
of Calcite and we don't have to incur the debt it will bring.
Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/83a8e883
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/83a8e883
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/83a8e883
Branch: refs/heads/master
Commit: 83a8e883a9a50b618d5892aa708f55a5dd1bd169
Parents: 6b91297
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 8 16:39:53 2016 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 8 17:00:17 2016 -0500
----------------------------------------------------------------------
dropwizard-metrics2/pom.xml | 145 ------
.../metrics/hadoop/HadoopMetrics2Reporter.java | 451 -------------------
.../metrics/hadoop/PackageMarker.java | 37 --
.../dropwizard/metrics/hadoop/package-info.java | 24 -
.../hadoop/HadoopMetrics2ReporterTest.java | 334 --------------
pom.xml | 2 -
6 files changed, 993 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite/blob/83a8e883/dropwizard-metrics2/pom.xml
----------------------------------------------------------------------
diff --git a/dropwizard-metrics2/pom.xml b/dropwizard-metrics2/pom.xml
deleted file mode 100644
index bcb7033..0000000
--- a/dropwizard-metrics2/pom.xml
+++ /dev/null
@@ -1,145 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to you under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.calcite</groupId>
- <artifactId>calcite</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>calcite-dropwizard-hadoop-metrics2</artifactId>
- <packaging>jar</packaging>
- <name>Calcite Dropwizard Reporter for Hadoop Metrics2</name>
- <description>A Dropwizard Metrics reporter which also acts as a Hadoop Metrics2 MetricsSource.</description>
-
- <properties>
- <top.dir>${project.basedir}/..</top.dir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>io.dropwizard.metrics</groupId>
- <artifactId>metrics-core</artifactId>
- <version>${dropwizard-metrics3.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <versionRange>[2.12.1,)</versionRange>
- <goals>
- <goal>check</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>analyze</id>
- <goals>
- <goal>analyze-only</goal>
- </goals>
- <configuration>
- <failOnWarning>true</failOnWarning>
- <!-- ignore "unused but declared" warnings -->
- <ignoredUnusedDeclaredDependencies>
- <ignoredUnusedDeclaredDependency>org.slf4j:slf4j-log4j12</ignoredUnusedDeclaredDependency>
- </ignoredUnusedDeclaredDependencies>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!-- Parent module has the same plugin and does the work of
- generating -sources.jar for each project. But without the
- plugin declared here, IDEs don't know the sources are
- available. -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>verify</phase>
- <goals>
- <goal>jar-no-fork</goal>
- <goal>test-jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-remote-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>non-root-resources</id>
- <goals>
- <goal>process</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/calcite/blob/83a8e883/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/HadoopMetrics2Reporter.java
----------------------------------------------------------------------
diff --git a/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/HadoopMetrics2Reporter.java b/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/HadoopMetrics2Reporter.java
deleted file mode 100644
index 89a49eb..0000000
--- a/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/HadoopMetrics2Reporter.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.dropwizard.metrics.hadoop;
-
-import org.apache.hadoop.metrics2.MetricsCollector;
-import org.apache.hadoop.metrics2.MetricsInfo;
-import org.apache.hadoop.metrics2.MetricsRecordBuilder;
-import org.apache.hadoop.metrics2.MetricsSource;
-import org.apache.hadoop.metrics2.MetricsSystem;
-import org.apache.hadoop.metrics2.lib.Interns;
-import org.apache.hadoop.metrics2.lib.MetricsRegistry;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Gauge;
-import com.codahale.metrics.Histogram;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.MetricFilter;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.ScheduledReporter;
-import com.codahale.metrics.Snapshot;
-import com.codahale.metrics.Timer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.SortedMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Dropwizard-Metrics {@link com.codahale.metrics.Reporter} which also acts as a Hadoop Metrics2
- * {@link MetricsSource}. Configure it like other Reporters.
- *
- * <pre>
- * final HadoopMetrics2Reporter metrics2Reporter = HadoopMetrics2Reporter.forRegistry(metrics)
- * .build(DefaultMetricsSystem.initialize("Phoenix"), // The application-level name
- * "QueryServer", // Component name
- * "Phoenix Query Server", // Component description
- * "General"); // Name for each metric record
- * metrics2Reporter.start(30, TimeUnit.SECONDS);
- * </pre>
- */
-public class HadoopMetrics2Reporter extends ScheduledReporter implements MetricsSource {
- private static final Logger LOG = LoggerFactory.getLogger(HadoopMetrics2Reporter.class);
- private static final String EMPTY_STRING = "";
-
- public static final MetricsInfo RATE_UNIT_LABEL =
- Interns.info("rate_unit", "The unit of measure for rate metrics");
- public static final MetricsInfo DURATION_UNIT_LABEL =
- Interns.info("duration_unit", "The unit of measure of duration metrics");
-
- /**
- * Returns a new {@link Builder} for {@link HadoopMetrics2Reporter}.
- *
- * @param registry the registry to report
- * @return a {@link Builder} instance for a {@link HadoopMetrics2Reporter}
- */
- public static Builder forRegistry(MetricRegistry registry) {
- return new Builder(registry);
- }
-
- /**
- * A builder to create {@link HadoopMetrics2Reporter} instances.
- */
- public static class Builder {
- private final MetricRegistry registry;
- private MetricFilter filter;
- private TimeUnit rateUnit;
- private TimeUnit durationUnit;
- private String recordContext;
-
- private Builder(MetricRegistry registry) {
- this.registry = registry;
- this.filter = MetricFilter.ALL;
- this.rateUnit = TimeUnit.SECONDS;
- this.durationUnit = TimeUnit.MILLISECONDS;
- }
-
- /**
- * Convert rates to the given time unit. Defaults to {@link TimeUnit#SECONDS}.
- *
- * @param rateUnit a unit of time
- * @return {@code this}
- */
- public Builder convertRatesTo(TimeUnit rateUnit) {
- this.rateUnit = Objects.requireNonNull(rateUnit);
- return this;
- }
-
- /**
- * Convert durations to the given time unit. Defaults to {@link TimeUnit#MILLISECONDS}.
- *
- * @param durationUnit a unit of time
- * @return {@code this}
- */
- public Builder convertDurationsTo(TimeUnit durationUnit) {
- this.durationUnit = Objects.requireNonNull(durationUnit);
- return this;
- }
-
- /**
- * Only report metrics which match the given filter. Defaults to {@link MetricFilter#ALL}.
- *
- * @param filter a {@link MetricFilter}
- * @return {@code this}
- */
- public Builder filter(MetricFilter filter) {
- this.filter = Objects.requireNonNull(filter);
- return this;
- }
-
- /**
- * A "context" name that will be added as a tag on each emitted metric record. Defaults to
- * no "context" attribute on each record.
- *
- * @param recordContext The "context" tag
- * @return {@code this}
- */
- public Builder recordContext(String recordContext) {
- this.recordContext = Objects.requireNonNull(recordContext);
- return this;
- }
-
- /**
- * Builds a {@link HadoopMetrics2Reporter} with the given properties, making metrics available
- * to the Hadoop Metrics2 framework (any configured {@link MetricsSource}s.
- *
- * @param metrics2System The Hadoop Metrics2 system instance.
- * @param jmxContext The JMX "path", e.g. {@code "MyServer,sub=Requests"}.
- * @param description A description these metrics.
- * @param recordName A suffix included on each record to identify it.
- *
- * @return a {@link HadoopMetrics2Reporter}
- */
- public HadoopMetrics2Reporter build(MetricsSystem metrics2System, String jmxContext,
- String description, String recordName) {
- return new HadoopMetrics2Reporter(registry,
- rateUnit,
- durationUnit,
- filter,
- metrics2System,
- Objects.requireNonNull(jmxContext),
- description,
- recordName,
- recordContext);
- }
- }
-
- private final MetricsRegistry metrics2Registry;
- private final MetricsSystem metrics2System;
- private final String recordName;
- private final String context;
-
- @SuppressWarnings("rawtypes")
- private final ConcurrentLinkedQueue<Entry<String, Gauge>> dropwizardGauges;
- private final ConcurrentLinkedQueue<Entry<String, Counter>> dropwizardCounters;
- private final ConcurrentLinkedQueue<Entry<String, Histogram>> dropwizardHistograms;
- private final ConcurrentLinkedQueue<Entry<String, Meter>> dropwizardMeters;
- private final ConcurrentLinkedQueue<Entry<String, Timer>> dropwizardTimers;
-
- private HadoopMetrics2Reporter(MetricRegistry registry, TimeUnit rateUnit, TimeUnit durationUnit,
- MetricFilter filter, MetricsSystem metrics2System, String jmxContext, String description,
- String recordName, String context) {
- super(registry, "hadoop-metrics2-reporter", filter, rateUnit, durationUnit);
- this.metrics2Registry = new MetricsRegistry(Interns.info(jmxContext, description));
- this.metrics2System = metrics2System;
- this.recordName = recordName;
- this.context = context;
-
- this.dropwizardGauges = new ConcurrentLinkedQueue<>();
- this.dropwizardCounters = new ConcurrentLinkedQueue<>();
- this.dropwizardHistograms = new ConcurrentLinkedQueue<>();
- this.dropwizardMeters = new ConcurrentLinkedQueue<>();
- this.dropwizardTimers = new ConcurrentLinkedQueue<>();
-
- // Register this source with the Metrics2 system.
- // Make sure this is the last thing done as getMetrics() can be called at any time after.
- this.metrics2System.register(Objects.requireNonNull(jmxContext),
- Objects.requireNonNull(description), this);
- }
-
- @Override public void getMetrics(MetricsCollector collector, boolean all) {
- MetricsRecordBuilder builder = collector.addRecord(recordName);
- if (null != context) {
- builder.setContext(context);
- }
-
- snapshotAllMetrics(builder);
-
- metrics2Registry.snapshot(builder, all);
- }
-
- /**
- * Consumes the current metrics collected by dropwizard and adds them to the {@code builder}.
- *
- * @param builder A record builder
- */
- void snapshotAllMetrics(MetricsRecordBuilder builder) {
- // Pass through the gauges
- @SuppressWarnings("rawtypes")
- Iterator<Entry<String, Gauge>> gaugeIterator = dropwizardGauges.iterator();
- while (gaugeIterator.hasNext()) {
- @SuppressWarnings("rawtypes")
- Entry<String, Gauge> gauge = gaugeIterator.next();
- final MetricsInfo info = Interns.info(gauge.getKey(), EMPTY_STRING);
- final Object o = gauge.getValue().getValue();
-
- // Figure out which gauge types metrics2 supports and call the right method
- if (o instanceof Integer) {
- builder.addGauge(info, (int) o);
- } else if (o instanceof Long) {
- builder.addGauge(info, (long) o);
- } else if (o instanceof Float) {
- builder.addGauge(info, (float) o);
- } else if (o instanceof Double) {
- builder.addGauge(info, (double) o);
- } else {
- LOG.info("Ignoring Gauge ({}) with unhandled type: {}", gauge.getKey(), o.getClass());
- }
-
- gaugeIterator.remove();
- }
-
- // Pass through the counters
- Iterator<Entry<String, Counter>> counterIterator = dropwizardCounters.iterator();
- while (counterIterator.hasNext()) {
- Entry<String, Counter> counter = counterIterator.next();
- MetricsInfo info = Interns.info(counter.getKey(), EMPTY_STRING);
- LOG.info("Adding counter {} {}", info, counter.getValue().getCount());
- builder.addCounter(info, counter.getValue().getCount());
- counterIterator.remove();
- }
-
- // Pass through the histograms
- Iterator<Entry<String, Histogram>> histogramIterator = dropwizardHistograms.iterator();
- while (histogramIterator.hasNext()) {
- final Entry<String, Histogram> entry = histogramIterator.next();
- final String name = entry.getKey();
- final Histogram histogram = entry.getValue();
-
- addSnapshot(builder, name, EMPTY_STRING, histogram.getSnapshot(), histogram.getCount());
-
- histogramIterator.remove();
- }
-
- // Pass through the meter values
- Iterator<Entry<String, Meter>> meterIterator = dropwizardMeters.iterator();
- while (meterIterator.hasNext()) {
- final Entry<String, Meter> meterEntry = meterIterator.next();
- final String name = meterEntry.getKey();
- final Meter meter = meterEntry.getValue();
-
- addMeter(builder, name, EMPTY_STRING, meter.getCount(), meter.getMeanRate(),
- meter.getOneMinuteRate(), meter.getFiveMinuteRate(), meter.getFifteenMinuteRate());
-
- meterIterator.remove();
- }
-
- // Pass through the timers (meter + histogram)
- Iterator<Entry<String, Timer>> timerIterator = dropwizardTimers.iterator();
- while (timerIterator.hasNext()) {
- final Entry<String, Timer> timerEntry = timerIterator.next();
- final String name = timerEntry.getKey();
- final Timer timer = timerEntry.getValue();
- final Snapshot snapshot = timer.getSnapshot();
-
- // Add the meter info (mean rate and rate over time windows)
- addMeter(builder, name, EMPTY_STRING, timer.getCount(), timer.getMeanRate(),
- timer.getOneMinuteRate(), timer.getFiveMinuteRate(), timer.getFifteenMinuteRate());
-
- // Count was already added via the meter
- addSnapshot(builder, name, EMPTY_STRING, snapshot);
-
- timerIterator.remove();
- }
-
- // Add in metadata about what the units the reported metrics are displayed using.
- builder.tag(RATE_UNIT_LABEL, getRateUnit());
- builder.tag(DURATION_UNIT_LABEL, getDurationUnit());
- }
-
- /**
- * Add Dropwizard-Metrics rate information to a Hadoop-Metrics2 record builder, converting the
- * rates to the appropriate unit.
- *
- * @param builder A Hadoop-Metrics2 record builder.
- * @param name A base name for this record.
- * @param desc A description for the record.
- * @param count The number of measured events.
- * @param meanRate The average measured rate.
- * @param oneMinuteRate The measured rate over the past minute.
- * @param fiveMinuteRate The measured rate over the past five minutes
- * @param fifteenMinuteRate The measured rate over the past fifteen minutes.
- */
- private void addMeter(MetricsRecordBuilder builder, String name, String desc, long count,
- double meanRate, double oneMinuteRate, double fiveMinuteRate, double fifteenMinuteRate) {
- builder.addGauge(Interns.info(name + "_count", EMPTY_STRING), count);
- builder.addGauge(Interns.info(name + "_mean_rate", EMPTY_STRING), convertRate(meanRate));
- builder.addGauge(Interns.info(name + "_1min_rate", EMPTY_STRING), convertRate(oneMinuteRate));
- builder.addGauge(Interns.info(name + "_5min_rate", EMPTY_STRING), convertRate(fiveMinuteRate));
- builder.addGauge(Interns.info(name + "_15min_rate", EMPTY_STRING),
- convertRate(fifteenMinuteRate));
- }
-
- /**
- * Add Dropwizard-Metrics value-distribution data to a Hadoop-Metrics2 record building, converting
- * the durations to the appropriate unit.
- *
- * @param builder A Hadoop-Metrics2 record builder.
- * @param name A base name for this record.
- * @param desc A description for this record.
- * @param snapshot The distribution of measured values.
- * @param count The number of values which were measured.
- */
- private void addSnapshot(MetricsRecordBuilder builder, String name, String desc,
- Snapshot snapshot, long count) {
- builder.addGauge(Interns.info(name + "_count", desc), count);
- addSnapshot(builder, name, desc, snapshot);
- }
-
- /**
- * Add Dropwizard-Metrics value-distribution data to a Hadoop-Metrics2 record building, converting
- * the durations to the appropriate unit.
- *
- * @param builder A Hadoop-Metrics2 record builder.
- * @param name A base name for this record.
- * @param desc A description for this record.
- * @param snapshot The distribution of measured values.
- */
- private void addSnapshot(MetricsRecordBuilder builder, String name, String desc,
- Snapshot snapshot) {
- builder.addGauge(Interns.info(name + "_mean", desc), convertDuration(snapshot.getMean()));
- builder.addGauge(Interns.info(name + "_min", desc), convertDuration(snapshot.getMin()));
- builder.addGauge(Interns.info(name + "_max", desc), convertDuration(snapshot.getMax()));
- builder.addGauge(Interns.info(name + "_median", desc), convertDuration(snapshot.getMedian()));
- builder.addGauge(Interns.info(name + "_stddev", desc), convertDuration(snapshot.getStdDev()));
-
- builder.addGauge(Interns.info(name + "_75thpercentile", desc),
- convertDuration(snapshot.get75thPercentile()));
- builder.addGauge(Interns.info(name + "_95thpercentile", desc),
- convertDuration(snapshot.get95thPercentile()));
- builder.addGauge(Interns.info(name + "_98thpercentile", desc),
- convertDuration(snapshot.get98thPercentile()));
- builder.addGauge(Interns.info(name + "_99thpercentile", desc),
- convertDuration(snapshot.get99thPercentile()));
- builder.addGauge(Interns.info(name + "_999thpercentile", desc),
- convertDuration(snapshot.get999thPercentile()));
- }
-
- @SuppressWarnings("rawtypes")
- @Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
- SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters,
- SortedMap<String, Timer> timers) {
- for (Entry<String, Gauge> gauge : gauges.entrySet()) {
- dropwizardGauges.add(gauge);
- }
-
- for (Entry<String, Counter> counter : counters.entrySet()) {
- dropwizardCounters.add(counter);
- }
-
- for (Entry<String, Histogram> histogram : histograms.entrySet()) {
- dropwizardHistograms.add(histogram);
- }
-
- for (Entry<String, Meter> meter : meters.entrySet()) {
- dropwizardMeters.add(meter);
- }
-
- for (Entry<String, Timer> timer : timers.entrySet()) {
- dropwizardTimers.add(timer);
- }
- }
-
- @Override protected String getRateUnit() {
- // Make it "events per rate_unit" to be accurate.
- return "events/" + super.getRateUnit();
- }
-
- @Override protected String getDurationUnit() {
- // Make it visible to the tests
- return super.getDurationUnit();
- }
-
- @Override protected double convertDuration(double duration) {
- // Make it visible to the tests
- return super.convertDuration(duration);
- }
-
- @Override protected double convertRate(double rate) {
- // Make it visible to the tests
- return super.convertRate(rate);
- }
-
- // Getters visible for testing
-
- MetricsRegistry getMetrics2Registry() {
- return metrics2Registry;
- }
-
- MetricsSystem getMetrics2System() {
- return metrics2System;
- }
-
- String getRecordName() {
- return recordName;
- }
-
- String getContext() {
- return context;
- }
-
- @SuppressWarnings("rawtypes") ConcurrentLinkedQueue<Entry<String, Gauge>> getDropwizardGauges() {
- return dropwizardGauges;
- }
-
- ConcurrentLinkedQueue<Entry<String, Counter>> getDropwizardCounters() {
- return dropwizardCounters;
- }
-
- ConcurrentLinkedQueue<Entry<String, Histogram>> getDropwizardHistograms() {
- return dropwizardHistograms;
- }
-
- ConcurrentLinkedQueue<Entry<String, Meter>> getDropwizardMeters() {
- return dropwizardMeters;
- }
-
- ConcurrentLinkedQueue<Entry<String, Timer>> getDropwizardTimers() {
- return dropwizardTimers;
- }
-}
-
-// End HadoopMetrics2Reporter.java
http://git-wip-us.apache.org/repos/asf/calcite/blob/83a8e883/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/PackageMarker.java
----------------------------------------------------------------------
diff --git a/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/PackageMarker.java b/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/PackageMarker.java
deleted file mode 100644
index 40a9b4f..0000000
--- a/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/PackageMarker.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.dropwizard.metrics.hadoop;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * This is a dummy annotation that forces javac to produce output for
- * otherwise empty package-info.java.
- *
- * <p>The result is maven-compiler-plugin can properly identify the scope of
- * changed files
- *
- * <p>See more details in
- * <a href="https://jira.codehaus.org/browse/MCOMPILER-205">
- * maven-compiler-plugin: incremental compilation broken</a>
- */
-@Retention(RetentionPolicy.SOURCE)
-public @interface PackageMarker {
-}
-
-// End PackageMarker.java
http://git-wip-us.apache.org/repos/asf/calcite/blob/83a8e883/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/package-info.java
----------------------------------------------------------------------
diff --git a/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/package-info.java b/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/package-info.java
deleted file mode 100644
index a842ff9..0000000
--- a/dropwizard-metrics2/src/main/java/org/apache/calcite/dropwizard/metrics/hadoop/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Hadoop Metrics2 MetricsSource for Dropwizard-Metrics.
- */
-@PackageMarker
-package org.apache.calcite.dropwizard.metrics.hadoop;
-
-// End package-info.java
http://git-wip-us.apache.org/repos/asf/calcite/blob/83a8e883/dropwizard-metrics2/src/test/java/org/apache/calcite/dropwizard/metrics/hadoop/HadoopMetrics2ReporterTest.java
----------------------------------------------------------------------
diff --git a/dropwizard-metrics2/src/test/java/org/apache/calcite/dropwizard/metrics/hadoop/HadoopMetrics2ReporterTest.java b/dropwizard-metrics2/src/test/java/org/apache/calcite/dropwizard/metrics/hadoop/HadoopMetrics2ReporterTest.java
deleted file mode 100644
index 4eee7a2..0000000
--- a/dropwizard-metrics2/src/test/java/org/apache/calcite/dropwizard/metrics/hadoop/HadoopMetrics2ReporterTest.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.dropwizard.metrics.hadoop;
-
-import org.apache.calcite.dropwizard.metrics.hadoop.HadoopMetrics2Reporter.Builder;
-
-import org.apache.hadoop.metrics2.MetricsCollector;
-import org.apache.hadoop.metrics2.MetricsRecordBuilder;
-import org.apache.hadoop.metrics2.MetricsSystem;
-import org.apache.hadoop.metrics2.lib.Interns;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Gauge;
-import com.codahale.metrics.Histogram;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.Snapshot;
-import com.codahale.metrics.Timer;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.mockito.Mockito;
-
-import java.util.AbstractMap.SimpleEntry;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-/**
- * Tests for {@link HadoopMetrics2Reporter}.
- */
-public class HadoopMetrics2ReporterTest {
-
- private MetricRegistry mockRegistry;
- private MetricsSystem mockMetricsSystem;
- private String recordName = "myserver";
- private HadoopMetrics2Reporter metrics2Reporter;
-
- @Before public void setup() {
- mockRegistry = mock(MetricRegistry.class);
- mockMetricsSystem = mock(MetricsSystem.class);
-
- recordName = "myserver";
- metrics2Reporter = HadoopMetrics2Reporter.forRegistry(mockRegistry)
- .convertDurationsTo(TimeUnit.MILLISECONDS)
- .convertRatesTo(TimeUnit.SECONDS)
- .build(mockMetricsSystem, "MyServer", "My Cool Server", recordName);
- }
-
- private void verifyRecordBuilderUnits(MetricsRecordBuilder recordBuilder) {
- verify(recordBuilder).tag(HadoopMetrics2Reporter.RATE_UNIT_LABEL,
- metrics2Reporter.getRateUnit());
- verify(recordBuilder).tag(HadoopMetrics2Reporter.DURATION_UNIT_LABEL,
- metrics2Reporter.getDurationUnit());
- }
-
- @Test public void testBuilderDefaults() {
- Builder builder = HadoopMetrics2Reporter.forRegistry(mockRegistry);
-
- final String jmxContext = "MyJmxContext;sub=Foo";
- final String desc = "Description";
- final String recordName = "Metrics";
-
- HadoopMetrics2Reporter reporter =
- builder.build(mockMetricsSystem, jmxContext, desc, recordName);
-
- assertEquals(mockMetricsSystem, reporter.getMetrics2System());
- // The Context "tag", not the jmx context
- assertEquals(null, reporter.getContext());
- assertEquals(recordName, reporter.getRecordName());
- }
-
- @Test public void testGaugeReporting() {
- final AtomicLong gaugeValue = new AtomicLong(0L);
- @SuppressWarnings("rawtypes")
- final Gauge gauge = new Gauge<Long>() {
- @Override public Long getValue() {
- return gaugeValue.get();
- }
- };
-
- // Add the metrics objects to the internal "queues" by hand
- metrics2Reporter.getDropwizardGauges().add(new SimpleEntry<>("my_gauge", gauge));
-
- // Set some values
- gaugeValue.set(5L);
-
- MetricsCollector collector = mock(MetricsCollector.class);
- MetricsRecordBuilder recordBuilder = mock(MetricsRecordBuilder.class);
-
- Mockito.when(collector.addRecord(recordName)).thenReturn(recordBuilder);
-
- // Make sure a value of 5 gets reported
- metrics2Reporter.getMetrics(collector, true);
-
- verify(recordBuilder).addGauge(Interns.info("my_gauge", ""), gaugeValue.get());
- verifyRecordBuilderUnits(recordBuilder);
- }
-
- @Test public void testCounterReporting() {
- final Counter counter = new Counter();
-
- // Add the metrics objects to the internal "queues" by hand
- metrics2Reporter.getDropwizardCounters().add(new SimpleEntry<>("my_counter", counter));
-
- // Set some values
- counter.inc(5L);
-
- MetricsCollector collector = mock(MetricsCollector.class);
- MetricsRecordBuilder recordBuilder = mock(MetricsRecordBuilder.class);
-
- Mockito.when(collector.addRecord(recordName)).thenReturn(recordBuilder);
-
- metrics2Reporter.getMetrics(collector, true);
-
- verify(recordBuilder).addCounter(Interns.info("my_counter", ""), 5L);
- verifyRecordBuilderUnits(recordBuilder);
- }
-
- @Test public void testHistogramReporting() {
- final String metricName = "my_histogram";
- final Histogram histogram = mock(Histogram.class);
- final Snapshot snapshot = mock(Snapshot.class);
-
- long count = 10L;
- double percentile75 = 75;
- double percentile95 = 95;
- double percentile98 = 98;
- double percentile99 = 99;
- double percentile999 = 999;
- double median = 50;
- double mean = 60;
- long min = 1L;
- long max = 100L;
- double stddev = 10;
-
- when(snapshot.get75thPercentile()).thenReturn(percentile75);
- when(snapshot.get95thPercentile()).thenReturn(percentile95);
- when(snapshot.get98thPercentile()).thenReturn(percentile98);
- when(snapshot.get99thPercentile()).thenReturn(percentile99);
- when(snapshot.get999thPercentile()).thenReturn(percentile999);
- when(snapshot.getMedian()).thenReturn(median);
- when(snapshot.getMean()).thenReturn(mean);
- when(snapshot.getMin()).thenReturn(min);
- when(snapshot.getMax()).thenReturn(max);
- when(snapshot.getStdDev()).thenReturn(stddev);
-
- when(histogram.getCount()).thenReturn(count);
- when(histogram.getSnapshot()).thenReturn(snapshot);
-
- MetricsCollector collector = mock(MetricsCollector.class);
- MetricsRecordBuilder recordBuilder = mock(MetricsRecordBuilder.class);
-
- Mockito.when(collector.addRecord(recordName)).thenReturn(recordBuilder);
-
- // Add the metrics objects to the internal "queues" by hand
- metrics2Reporter.getDropwizardHistograms().add(new SimpleEntry<>(metricName, histogram));
-
- metrics2Reporter.getMetrics(collector, true);
-
- verify(recordBuilder).addGauge(Interns.info(metricName + "_max", ""),
- metrics2Reporter.convertDuration(max));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_min", ""),
- metrics2Reporter.convertDuration(min));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_median", ""),
- metrics2Reporter.convertDuration(median));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_count", ""), count);
- verify(recordBuilder).addGauge(Interns.info(metricName + "_stddev", ""),
- metrics2Reporter.convertDuration(stddev));
-
- verify(recordBuilder).addGauge(Interns.info(metricName + "_75thpercentile", ""),
- metrics2Reporter.convertDuration(percentile75));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_95thpercentile", ""),
- metrics2Reporter.convertDuration(percentile95));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_98thpercentile", ""),
- metrics2Reporter.convertDuration(percentile98));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_99thpercentile", ""),
- metrics2Reporter.convertDuration(percentile99));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_999thpercentile", ""),
- metrics2Reporter.convertDuration(percentile999));
-
- verifyRecordBuilderUnits(recordBuilder);
- }
-
- @Test public void testTimerReporting() {
- final String metricName = "my_timer";
- final Timer timer = mock(Timer.class);
- final Snapshot snapshot = mock(Snapshot.class);
-
- // Add the metrics objects to the internal "queues" by hand
- metrics2Reporter.getDropwizardTimers().add(new SimpleEntry<>(metricName, timer));
-
- long count = 10L;
- double meanRate = 1.0;
- double oneMinRate = 2.0;
- double fiveMinRate = 5.0;
- double fifteenMinRate = 10.0;
-
- when(timer.getCount()).thenReturn(count);
- when(timer.getMeanRate()).thenReturn(meanRate);
- when(timer.getOneMinuteRate()).thenReturn(oneMinRate);
- when(timer.getFiveMinuteRate()).thenReturn(fiveMinRate);
- when(timer.getFifteenMinuteRate()).thenReturn(fifteenMinRate);
- when(timer.getSnapshot()).thenReturn(snapshot);
-
- double percentile75 = 75;
- double percentile95 = 95;
- double percentile98 = 98;
- double percentile99 = 99;
- double percentile999 = 999;
- double median = 50;
- double mean = 60;
- long min = 1L;
- long max = 100L;
- double stddev = 10;
-
- when(snapshot.get75thPercentile()).thenReturn(percentile75);
- when(snapshot.get95thPercentile()).thenReturn(percentile95);
- when(snapshot.get98thPercentile()).thenReturn(percentile98);
- when(snapshot.get99thPercentile()).thenReturn(percentile99);
- when(snapshot.get999thPercentile()).thenReturn(percentile999);
- when(snapshot.getMedian()).thenReturn(median);
- when(snapshot.getMean()).thenReturn(mean);
- when(snapshot.getMin()).thenReturn(min);
- when(snapshot.getMax()).thenReturn(max);
- when(snapshot.getStdDev()).thenReturn(stddev);
-
- MetricsCollector collector = mock(MetricsCollector.class);
- MetricsRecordBuilder recordBuilder = mock(MetricsRecordBuilder.class);
-
- Mockito.when(collector.addRecord(recordName)).thenReturn(recordBuilder);
-
- metrics2Reporter.getMetrics(collector, true);
-
- // We get the count from the meter and histogram
- verify(recordBuilder).addGauge(Interns.info(metricName + "_count", ""), count);
-
- // Verify the rates
- verify(recordBuilder).addGauge(Interns.info(metricName + "_mean_rate", ""),
- metrics2Reporter.convertRate(meanRate));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_1min_rate", ""),
- metrics2Reporter.convertRate(oneMinRate));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_5min_rate", ""),
- metrics2Reporter.convertRate(fiveMinRate));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_15min_rate", ""),
- metrics2Reporter.convertRate(fifteenMinRate));
-
- // Verify the histogram
- verify(recordBuilder).addGauge(Interns.info(metricName + "_max", ""),
- metrics2Reporter.convertDuration(max));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_min", ""),
- metrics2Reporter.convertDuration(min));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_median", ""),
- metrics2Reporter.convertDuration(median));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_stddev", ""),
- metrics2Reporter.convertDuration(stddev));
-
- verify(recordBuilder).addGauge(Interns.info(metricName + "_75thpercentile", ""),
- metrics2Reporter.convertDuration(percentile75));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_95thpercentile", ""),
- metrics2Reporter.convertDuration(percentile95));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_98thpercentile", ""),
- metrics2Reporter.convertDuration(percentile98));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_99thpercentile", ""),
- metrics2Reporter.convertDuration(percentile99));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_999thpercentile", ""),
- metrics2Reporter.convertDuration(percentile999));
-
- verifyRecordBuilderUnits(recordBuilder);
- }
-
- @Test public void testMeterReporting() {
- final String metricName = "my_meter";
- final Meter meter = mock(Meter.class);
-
- // Add the metrics objects to the internal "queues" by hand
- metrics2Reporter.getDropwizardMeters().add(new SimpleEntry<>(metricName, meter));
-
- // Set some values
- long count = 10L;
- double meanRate = 1.0;
- double oneMinRate = 2.0;
- double fiveMinRate = 5.0;
- double fifteenMinRate = 10.0;
-
- when(meter.getCount()).thenReturn(count);
- when(meter.getMeanRate()).thenReturn(meanRate);
- when(meter.getOneMinuteRate()).thenReturn(oneMinRate);
- when(meter.getFiveMinuteRate()).thenReturn(fiveMinRate);
- when(meter.getFifteenMinuteRate()).thenReturn(fifteenMinRate);
-
- MetricsCollector collector = mock(MetricsCollector.class);
- MetricsRecordBuilder recordBuilder = mock(MetricsRecordBuilder.class);
-
- Mockito.when(collector.addRecord(recordName)).thenReturn(recordBuilder);
-
- metrics2Reporter.getMetrics(collector, true);
-
- // Verify the rates
- verify(recordBuilder).addGauge(Interns.info(metricName + "_count", ""), count);
- verify(recordBuilder).addGauge(Interns.info(metricName + "_mean_rate", ""),
- metrics2Reporter.convertRate(meanRate));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_1min_rate", ""),
- metrics2Reporter.convertRate(oneMinRate));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_5min_rate", ""),
- metrics2Reporter.convertRate(fiveMinRate));
- verify(recordBuilder).addGauge(Interns.info(metricName + "_15min_rate", ""),
- metrics2Reporter.convertRate(fifteenMinRate));
-
- // Verify the units
- verifyRecordBuilderUnits(recordBuilder);
- }
-}
-
-// End HadoopMetrics2ReporterTest.java
http://git-wip-us.apache.org/repos/asf/calcite/blob/83a8e883/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d8e9364..72e7124 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,7 +60,6 @@ limitations under the License.
<commons-dbcp.version>1.4</commons-dbcp.version>
<commons-lang3.version>3.2</commons-lang3.version>
<commons-logging.version>1.1.3</commons-logging.version>
- <dropwizard-metrics3.version>3.1.2</dropwizard-metrics3.version>
<eigenbase-properties.version>1.1.5</eigenbase-properties.version>
<findbugs.version>1.3.9</findbugs.version>
<fmpp-maven-plugin.version>1.0</fmpp-maven-plugin.version>
@@ -131,7 +130,6 @@ limitations under the License.
<modules>
<module>cassandra</module>
<module>core</module>
- <module>dropwizard-metrics2</module>
<module>example</module>
<module>linq4j</module>
<module>mongodb</module>