cmccabe commented on code in PR #13438:
URL: https://github.com/apache/kafka/pull/13438#discussion_r1146909450


##########
metadata/src/main/java/org/apache/kafka/controller/metrics/ControllerServerMetrics.java:
##########
@@ -0,0 +1,211 @@
+/*
+ * 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.kafka.controller.metrics;
+
+import com.yammer.metrics.core.Gauge;
+import com.yammer.metrics.core.MetricName;
+import com.yammer.metrics.core.MetricsRegistry;
+import org.apache.kafka.server.metrics.KafkaYammerMetrics;
+
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * These are the metrics which are managed by the ControllerServer class. They 
generally pertain to
+ * aspects of the metadata, like how many topics or partitions we have.
+ * All of these except MetadataErrorCount are managed by 
ControllerServerMetricsPublisher.
+ *
+ * IMPORTANT: Metrics which are managed by the QuorumController class itself 
should go in
+ * @link{org.apache.kafka.controller.metrics.QuorumControllerMetrics}, not 
here.
+ */
+public final class ControllerServerMetrics implements AutoCloseable {
+    private final static MetricName FENCED_BROKER_COUNT = getMetricName(
+        "KafkaController", "FencedBrokerCount");
+    private final static MetricName ACTIVE_BROKER_COUNT = getMetricName(
+        "KafkaController", "ActiveBrokerCount");
+    private final static MetricName GLOBAL_TOPIC_COUNT = getMetricName(
+        "KafkaController", "GlobalTopicCount");
+    private final static MetricName GLOBAL_PARTITION_COUNT = getMetricName(
+        "KafkaController", "GlobalPartitionCount");
+    private final static MetricName OFFLINE_PARTITION_COUNT = getMetricName(
+        "KafkaController", "OfflinePartitionsCount");
+    private final static MetricName PREFERRED_REPLICA_IMBALANCE_COUNT = 
getMetricName(
+        "KafkaController", "PreferredReplicaImbalanceCount");
+    private final static MetricName METADATA_ERROR_COUNT = getMetricName(
+        "KafkaController", "MetadataErrorCount");
+
+    private final Optional<MetricsRegistry> registry;
+    private final AtomicInteger fencedBrokerCount = new AtomicInteger(0);
+    private final AtomicInteger activeBrokerCount = new AtomicInteger(0);
+    private final AtomicInteger globalTopicCount = new AtomicInteger(0);
+    private final AtomicInteger globalPartitionCount = new AtomicInteger();

Review Comment:
   Good point. I changed them all to just use `new AtomicInteger(0)` to be 
explicit. The no-argument form defaults to 0 too but better to avoid that bit 
of cleverness



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to