muralibasani commented on code in PR #16094: URL: https://github.com/apache/kafka/pull/16094#discussion_r1619077543
########## 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: @jsancio Thanks. when trying to create a voterset, VoterNode constructor is not accessible in core\tools, as VoterNode is part of raft package. Any suggestions ? We need this public constructor https://github.com/apache/kafka/blob/8068a086a3f41b9f7e4d4a1dab3338f029089f23/raft/src/main/java/org/apache/kafka/raft/internals/VoterSet.java#L49 -- 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