chia7712 commented on code in PR #16010:
URL: https://github.com/apache/kafka/pull/16010#discussion_r1608610743
##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -452,19 +452,20 @@ object StorageTool extends Logging {
stream.println("All of the log directories are already formatted.")
} else {
metaPropertiesEnsemble.emptyLogDirs().forEach(logDir => {
- copier.setLogDirProps(logDir, new
MetaProperties.Builder(metaProperties).
- setDirectoryId(copier.generateValidDirectoryId()).
+ val loggingCopier = new
MetaPropertiesEnsemble.Copier(metaPropertiesEnsemble)
+ loggingCopier.setLogDirProps(logDir, new
MetaProperties.Builder(metaProperties).
+ setDirectoryId(loggingCopier.generateValidDirectoryId()).
build())
- copier.setPreWriteHandler((logDir, _, _) => {
+ loggingCopier.setPreWriteHandler((logDir, _, _) => {
stream.println(s"Formatting $logDir with metadata.version
$metadataVersion.")
Files.createDirectories(Paths.get(logDir))
val bootstrapDirectory = new BootstrapDirectory(logDir,
Optional.empty())
bootstrapDirectory.writeBinaryFile(bootstrapMetadata)
})
- copier.setWriteErrorHandler((logDir, e) => {
+ loggingCopier.setWriteErrorHandler((logDir, e) => {
throw new TerseFailure(s"Error while writing meta.properties file
$logDir: ${e.getMessage}")
})
- copier.writeLogDirChanges()
Review Comment:
Maybe the simpler solution is move `copier.writeLogDirChanges()` out of
loop.
--
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]