muralibasani commented on code in PR #16094: URL: https://github.com/apache/kafka/pull/16094#discussion_r1619109614
########## core/src/main/scala/kafka/tools/StorageTool.scala: ########## @@ -452,21 +460,68 @@ object StorageTool extends Logging { stream.println("All of the log directories are already formatted.") } else { metaPropertiesEnsemble.emptyLogDirs().forEach(logDir => { + System.out.println("logDir : "+ logDir) copier.setLogDirProps(logDir, new MetaProperties.Builder(metaProperties). setDirectoryId(copier.generateValidDirectoryId()). build()) copier.setPreWriteHandler((logDir, _, _) => { stream.println(s"Formatting $logDir with metadata.version $metadataVersion.") Files.createDirectories(Paths.get(logDir)) val bootstrapDirectory = new BootstrapDirectory(logDir, Optional.empty()) + System.out.println("bootstrapDirectory : "+ bootstrapDirectory) bootstrapDirectory.writeBinaryFile(bootstrapMetadata) }) copier.setWriteErrorHandler((logDir, e) => { throw new TerseFailure(s"Error while writing meta.properties file $logDir: ${e.getMessage}") }) copier.writeLogDirChanges() + // Write new file checkpoint file if standalone mode + if(standaloneMode){ + writeCheckpointFile(logDir) + } }) } 0 } + + def writeCheckpointFile(logDir: String): Unit = { + val snapshotCheckpointDir = logDir + "/__cluster_metadata-0" + + // Ensure the directory exists + val snapshotDir = Paths.get(snapshotCheckpointDir) + if (!Files.exists(snapshotDir)) { + Files.createDirectories(snapshotDir) + } + + // Create the full path for the checkpoint file + val checkpointFilePath = snapshotDir.resolve(snapshotDir) + + // Create the raw snapshot writer + val rawSnapshotWriter = FileRawSnapshotWriter.create(checkpointFilePath, new OffsetAndEpoch(0, 0)) + + val builder = new RecordsSnapshotWriter.Builder() + .setKraftVersion(1) + .setVoterSet(Optional.empty()) Review Comment: trying this way ``` val voterMap: java.util.Map[Integer, VoterSet.VoterNode] = new util.HashMap() voterMap.put(1, new VoterSet.VoterNode( ReplicaKey.of(nodeId, Optional.of(directoryId)), Collections.singletonMap(controllerListenerNames, new InetSocketAddress(host, port)), new SupportedVersionRange(0.toShort, 1.toShort) )) ``` -- 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