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


##########
metadata/src/main/java/org/apache/kafka/controller/metrics/ControllerServerMetricsPublisher.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * 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 org.apache.kafka.common.Uuid;
+import org.apache.kafka.image.MetadataDelta;
+import org.apache.kafka.image.MetadataImage;
+import org.apache.kafka.image.TopicDelta;
+import org.apache.kafka.image.TopicImage;
+import org.apache.kafka.image.loader.LoaderManifest;
+import org.apache.kafka.image.publisher.MetadataPublisher;
+import org.apache.kafka.metadata.BrokerRegistration;
+import org.apache.kafka.metadata.PartitionRegistration;
+import org.apache.kafka.server.fault.FaultHandler;
+
+import java.util.Map.Entry;
+import java.util.Optional;
+
+
+/**
+ * This publisher translates metadata updates sent by MetadataLoader into 
changes to controller
+ * metrics. Like all MetadataPublisher objects, it only receives notifications 
about events that
+ * have been persisted to the metadata log. So on the active controller, it 
will run slightly
+ * behind the latest in-memory state which has not yet been fully persisted to 
the log. This is
+ * reasonable for metrics, which don't need up-to-the-millisecond update 
latency.
+ *
+ * NOTE: the ZK controller has some special rules for calculating 
preferredReplicaImbalanceCount
+ * which we haven't implemented here. Specifically, the ZK controller 
considers reassigning
+ * partitions to always have their preferred leader, even if they don't.
+ * All other metrics should be the same, as far as is possible.
+ */
+public class ControllerServerMetricsPublisher implements MetadataPublisher {

Review Comment:
   Good idea. I renamed:
   
   ControllerServerMetrics -> ControllerMetadataMetrics
   ControllerServerMetricsPublisher -> ControllerMetadataMetricsPublisher
   
   and associated tests



-- 
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