kevin-wu24 commented on code in PR #20707:
URL: https://github.com/apache/kafka/pull/20707#discussion_r2445041788
##########
metadata/src/main/java/org/apache/kafka/metadata/storage/Formatter.java:
##########
@@ -511,8 +510,9 @@ static void writeDynamicQuorumSnapshot(
Snapshots.BOOTSTRAP_SNAPSHOT_ID)).
setKraftVersion(KRaftVersion.fromFeatureLevel(kraftVersion)).
setVoterSet(Optional.of(voterSet));
- try (RecordsSnapshotWriter<ApiMessageAndVersion> writer =
builder.build(new MetadataRecordSerde())) {
+ try (RecordsSnapshotWriter<ApiMessageAndVersion> writer =
builder.build(new MetadataRecordSerde(),
Optional.of(bootstrapMetadata.records()))) {
writer.freeze();
Review Comment:
```suggestion
try (RecordsSnapshotWriter<ApiMessageAndVersion> writer =
builder.build(new MetadataRecordSerde()))) {
writer.append(bootstrapMetadata.records());
writer.freeze();
```
##########
core/src/test/scala/unit/kafka/tools/DumpLogSegmentsTest.scala:
##########
@@ -601,7 +602,7 @@ class DumpLogSegmentsTest {
.setRawSnapshotWriter(metadataLog.createNewSnapshot(new
OffsetAndEpoch(0, 0)).get)
.setKraftVersion(KRaftVersion.KRAFT_VERSION_1)
.setVoterSet(Optional.of(VoterSetTest.voterSet(VoterSetTest.voterMap(IntStream.of(1,
2, 3), true))))
- .build(MetadataRecordSerde.INSTANCE)
+ .build(MetadataRecordSerde.INSTANCE, emptyOptional)
Review Comment:
We should be able to remove this.
##########
metadata/src/main/java/org/apache/kafka/metadata/storage/Formatter.java:
##########
Review Comment:
We should only construct the `VoterSet` object if
`initialControllers.isPresent()`.
##########
metadata/src/main/java/org/apache/kafka/metadata/storage/Formatter.java:
##########
@@ -437,14 +437,11 @@ void doFormat(BootstrapMetadata bootstrapMetadata) throws
Exception {
directoryTypes.get(writeLogDir).description(), writeLogDir,
MetadataVersion.FEATURE_NAME, releaseVersion);
Files.createDirectories(Paths.get(writeLogDir));
- BootstrapDirectory bootstrapDirectory = new
BootstrapDirectory(writeLogDir);
- bootstrapDirectory.writeBinaryFile(bootstrapMetadata);
- if
(directoryTypes.get(writeLogDir).isDynamicMetadataDirectory()) {
- writeDynamicQuorumSnapshot(writeLogDir,
- initialControllers.get(),
- featureLevels.get(KRaftVersion.FEATURE_NAME),
- controllerListenerName);
- }
+ writeBoostrapSnapshot(writeLogDir,
+ bootstrapMetadata,
+ initialControllers.get(),
Review Comment:
We need to pass the optional for `initialControllers` here. We can only do a
`.get()` if `initialControllers.isPresent()`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]