From commits-return-7902-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Mon Aug 5 13:30:09 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id D9A4E180181 for ; Mon, 5 Aug 2019 15:30:08 +0200 (CEST) Received: (qmail 89416 invoked by uid 500); 5 Aug 2019 13:30:08 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 89400 invoked by uid 99); 5 Aug 2019 13:30:08 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Aug 2019 13:30:08 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 03F3885EE5; Mon, 5 Aug 2019 13:30:03 +0000 (UTC) Date: Mon, 05 Aug 2019 13:30:02 +0000 To: "commits@zookeeper.apache.org" Subject: [zookeeper] branch master updated: ZOOKEEPER-3474: Enable BookKeeper checkstyle configuration on zookeeper-prometheus-metrics MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <156501180276.27646.12311148938497898053@gitbox.apache.org> From: eolivelli@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: zookeeper X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: d84b7a682eb4601005db9fac886079b1a9a4d4b0 X-Git-Newrev: 49354f581f3b88316177492ef28823b50a5b33f7 X-Git-Rev: 49354f581f3b88316177492ef28823b50a5b33f7 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. eolivelli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/zookeeper.git The following commit(s) were added to refs/heads/master by this push: new 49354f5 ZOOKEEPER-3474: Enable BookKeeper checkstyle configuration on zookeeper-prometheus-metrics 49354f5 is described below commit 49354f581f3b88316177492ef28823b50a5b33f7 Author: tison AuthorDate: Mon Aug 5 15:29:50 2019 +0200 ZOOKEEPER-3474: Enable BookKeeper checkstyle configuration on zookeeper-prometheus-metrics Subtasks of ZOOKEEPER-3431. Enable BookKeeper checkstyle configuration on zookeeper-promethus-metrics. Author: tison Reviewers: Enrico Olivelli , Norbert Kalmar Closes #1028 from TisonKun/ZOOKEEPER-3474 --- pom.xml | 2 +- zookeeper-jute/pom.xml | 2 +- zookeeper-metrics-providers/pom.xml | 37 ++++++++++++++++++++++ .../prometheus/PrometheusMetricsProvider.java | 23 ++++++-------- .../metrics/prometheus/ExportJvmInfoTest.java | 5 +-- .../prometheus/PrometheusMetricsProviderTest.java | 19 +++++------ .../src/test/resources/log4j.properties | 4 +-- 7 files changed, 64 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index 6176f6b..718a7d5 100755 --- a/pom.xml +++ b/pom.xml @@ -574,7 +574,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.0.0 + 3.1.0 com.puppycrawl.tools diff --git a/zookeeper-jute/pom.xml b/zookeeper-jute/pom.xml index 91b215f..e5d192b 100755 --- a/zookeeper-jute/pom.xml +++ b/zookeeper-jute/pom.xml @@ -157,7 +157,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.0.0 + 3.1.0 com.puppycrawl.tools diff --git a/zookeeper-metrics-providers/pom.xml b/zookeeper-metrics-providers/pom.xml index 5c83792..b6ae141 100755 --- a/zookeeper-metrics-providers/pom.xml +++ b/zookeeper-metrics-providers/pom.xml @@ -37,4 +37,41 @@ zookeeper-prometheus-metrics + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.1.0 + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + + checkstyle-strict.xml + checkstyleSuppressions.xml + UTF-8 + true + true + false + true + + + + checkstyle + validate + + check + + + + + + + + diff --git a/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/main/java/org/apache/zookeeper/metrics/prometheus/PrometheusMetricsProvider.java b/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/main/java/org/apache/zookeeper/metrics/prometheus/PrometheusMetricsProvider.java index ffa9e5b..569c049 100644 --- a/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/main/java/org/apache/zookeeper/metrics/prometheus/PrometheusMetricsProvider.java +++ b/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/main/java/org/apache/zookeeper/metrics/prometheus/PrometheusMetricsProvider.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.zookeeper.metrics.prometheus; import io.prometheus.client.Collector; @@ -29,7 +30,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.function.BiConsumer; import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.zookeeper.metrics.Counter; @@ -60,7 +60,7 @@ public class PrometheusMetricsProvider implements MetricsProvider { *

* When you are running ZooKeeper (server or client) together with other * libraries every metrics will be expected as a single view. - * + *

*/ private final CollectorRegistry collectorRegistry = CollectorRegistry.defaultRegistry; private int port = 7000; @@ -133,6 +133,7 @@ public class PrometheusMetricsProvider implements MetricsProvider { * This method is not expected to be used to serve metrics to Prometheus. We * are using the MetricsServlet provided by Prometheus for that, leaving the * real representation to the Prometheus Java client. + *

* * @param sink the receiver of data (4lw interface, Admin server or tests) */ @@ -199,25 +200,21 @@ public class PrometheusMetricsProvider implements MetricsProvider { @Override public Counter getCounter(String name) { - return counters.computeIfAbsent(name, (n) -> { - return new PrometheusCounter(n); - }); + return counters.computeIfAbsent(name, PrometheusCounter::new); } /** * Gauges may go up and down, in ZooKeeper they are a way to export * internal values with a callback. * - * @param name the name of the gauge + * @param name the name of the gauge * @param gauge the callback */ @Override public void registerGauge(String name, Gauge gauge) { Objects.requireNonNull(name); - gauges.compute(name, (id, prev) -> { - return new PrometheusGaugeWrapper(id, gauge, - prev != null ? prev.inner : null); - }); + gauges.compute(name, (id, prev) -> + new PrometheusGaugeWrapper(id, gauge, prev != null ? prev.inner : null)); } @Override @@ -311,8 +308,8 @@ public class PrometheusMetricsProvider implements MetricsProvider { this.gauge = gauge; this.inner = prev != null ? prev : io.prometheus.client.Gauge - .build(name, name) - .register(collectorRegistry); + .build(name, name) + .register(collectorRegistry); } /** diff --git a/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/java/org/apache/zookeeper/metrics/prometheus/ExportJvmInfoTest.java b/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/java/org/apache/zookeeper/metrics/prometheus/ExportJvmInfoTest.java index 899a271..fb5353d 100644 --- a/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/java/org/apache/zookeeper/metrics/prometheus/ExportJvmInfoTest.java +++ b/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/java/org/apache/zookeeper/metrics/prometheus/ExportJvmInfoTest.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -15,11 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.zookeeper.metrics.prometheus; +import static org.junit.Assert.assertEquals; import io.prometheus.client.CollectorRegistry; import java.util.Properties; -import static org.junit.Assert.assertEquals; import org.junit.Test; /** diff --git a/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/java/org/apache/zookeeper/metrics/prometheus/PrometheusMetricsProviderTest.java b/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/java/org/apache/zookeeper/metrics/prometheus/PrometheusMetricsProviderTest.java index b52bd7b..2d691db 100644 --- a/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/java/org/apache/zookeeper/metrics/prometheus/PrometheusMetricsProviderTest.java +++ b/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/java/org/apache/zookeeper/metrics/prometheus/PrometheusMetricsProviderTest.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -15,8 +15,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.zookeeper.metrics.prometheus; +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import io.prometheus.client.CollectorRegistry; import java.io.IOException; import java.io.PrintWriter; @@ -30,17 +39,9 @@ import org.apache.zookeeper.metrics.Gauge; import org.apache.zookeeper.metrics.MetricsContext; import org.apache.zookeeper.metrics.Summary; import org.hamcrest.CoreMatchers; -import static org.hamcrest.CoreMatchers.containsString; import org.junit.After; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import org.junit.Before; import org.junit.Test; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /** * Tests about Prometheus Metrics Provider. Please note that we are not testing diff --git a/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/resources/log4j.properties b/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/resources/log4j.properties index 4a2ede9..d7f930d 100644 --- a/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/resources/log4j.properties +++ b/zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/test/resources/log4j.properties @@ -1,5 +1,5 @@ # Copyright 2012 The Apache Software Foundation -# +# # 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 @@ -34,7 +34,7 @@ log4j.rootLogger=${zookeeper.root.logger} # # console -# Add "console" to rootlogger above if you want to use this +# Add "console" to rootlogger above if you want to use this # log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold}