mumrah commented on code in PR #13337:
URL: https://github.com/apache/kafka/pull/13337#discussion_r1131462269


##########
metadata/src/main/java/org/apache/kafka/image/loader/MetadataLoader.java:
##########
@@ -449,6 +450,15 @@ SnapshotManifest loadSnapshot(
     public void handleLeaderChange(LeaderAndEpoch leaderAndEpoch) {
         eventQueue.append(() -> {
             currentLeaderAndEpoch = leaderAndEpoch;
+            for (MetadataPublisher publisher : publishers.values()) {
+                try {
+                    publisher.onControllerChange(currentLeaderAndEpoch);
+                } catch (Throwable e) {
+                    faultHandler.handleFault("Unhandled error publishing the 
new leader " +
+                            "change to " + currentLeaderAndEpoch + " with 
publisher " +
+                            publisher.name(), e);

Review Comment:
   nit; tabs



##########
metadata/src/main/java/org/apache/kafka/metadata/migration/KRaftMigrationDriver.java:
##########
@@ -223,16 +223,21 @@ public String name() {
     }
 
     @Override
-    public void publishSnapshot(MetadataDelta delta, MetadataImage newImage, 
SnapshotManifest manifest) {
-        enqueueMetadataChangeEvent(delta, newImage, manifest.provenance(), 
true, NO_OP_HANDLER);
+    public void onControllerChange(LeaderAndEpoch newLeaderAndEpoch) {
+        eventQueue.append(new KRaftLeaderEvent(newLeaderAndEpoch));
     }
 
     @Override
-    public void publishLogDelta(MetadataDelta delta, MetadataImage newImage, 
LogDeltaManifest manifest) {
-        if (!leaderAndEpoch.equals(manifest.leaderAndEpoch())) {
-            eventQueue.append(new KRaftLeaderEvent(manifest.leaderAndEpoch()));
-        }
-        enqueueMetadataChangeEvent(delta, newImage, manifest.provenance(), 
false, NO_OP_HANDLER);
+    public void onMetadataUpdate(
+        MetadataDelta delta,
+        MetadataImage newImage,
+        LoaderManifest manifest
+    ) {
+        enqueueMetadataChangeEvent(delta,
+                newImage,

Review Comment:
   nit: tabs



##########
metadata/src/main/java/org/apache/kafka/image/publisher/SnapshotGenerator.java:
##########
@@ -200,7 +201,24 @@ void resetSnapshotCounters() {
     }
 
     @Override
-    public void publishSnapshot(
+    public void onMetadataUpdate(
+        MetadataDelta delta,
+        MetadataImage newImage,
+        LoaderManifest manifest
+    ) {
+        switch (manifest.type()) {
+            case LOG_DELTA:
+                publishLogDelta(delta, newImage, (LogDeltaManifest) manifest);
+                break;
+            case SNAPSHOT:
+                publishSnapshot(delta, newImage, (SnapshotManifest) manifest);
+                break;
+            default:
+                break;

Review Comment:
   wdyt about throwing an IllegalStateException in the `default`. I do that 
sometimes to future-proof against unhandled enums down the road. 



##########
metadata/src/main/java/org/apache/kafka/image/loader/LoaderManifest.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.image.loader;
+
+import org.apache.kafka.image.MetadataProvenance;
+
+
+/**
+ * Contains information about what was loaded.
+ */
+public interface LoaderManifest {

Review Comment:
   Ok, fair enough. Works for me 👍 



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