From 46c0e763ae40b88b02f4c5628a21ab6c7a415326 Mon Sep 17 00:00:00 2001 From: Shichao Nie Date: Tue, 3 Dec 2024 10:38:17 +0800 Subject: [PATCH] fix(core): write next node id into image (#2206) Signed-off-by: Shichao Nie --- .../src/main/java/org/apache/kafka/image/ClusterImage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metadata/src/main/java/org/apache/kafka/image/ClusterImage.java b/metadata/src/main/java/org/apache/kafka/image/ClusterImage.java index 35160c74fd..aa8bdfe6e9 100644 --- a/metadata/src/main/java/org/apache/kafka/image/ClusterImage.java +++ b/metadata/src/main/java/org/apache/kafka/image/ClusterImage.java @@ -17,17 +17,18 @@ package org.apache.kafka.image; +import org.apache.kafka.common.metadata.UpdateNextNodeIdRecord; import org.apache.kafka.image.node.ClusterImageNode; import org.apache.kafka.image.writer.ImageWriter; import org.apache.kafka.image.writer.ImageWriterOptions; import org.apache.kafka.metadata.BrokerRegistration; import org.apache.kafka.metadata.ControllerRegistration; +import org.apache.kafka.server.common.ApiMessageAndVersion; import java.util.Collections; import java.util.Map; import java.util.Objects; - /** * Represents the cluster in the metadata image. * @@ -100,6 +101,7 @@ public void write(ImageWriter writer, ImageWriterOptions options) { } } } + writer.write(new ApiMessageAndVersion(new UpdateNextNodeIdRecord().setNodeId(nextNodeId), (short) 0)); } @Override