gavinchou commented on code in PR #32292:
URL: https://github.com/apache/doris/pull/32292#discussion_r1525938267
##########
fe/fe-core/src/main/java/org/apache/doris/DorisFE.java:
##########
@@ -396,23 +409,43 @@ private static void
checkCommandLineOptions(CommandLineOptions cmdLineOpts) {
System.exit(-1);
}
} else if (cmdLineOpts.runImageTool()) {
- File imageFile = new File(cmdLineOpts.getImagePath());
+ CommandLineOptions.ImageToolOptions imageTool =
cmdLineOpts.getImageToolOpts();
+ File imageFile = new File(imageTool.getImagePath());
if (!imageFile.exists()) {
System.out.println("image does not exist: " +
imageFile.getAbsolutePath()
+ " . Please put an absolute path instead");
System.exit(-1);
- } else {
- System.out.println("Start to load image: ");
+ }
+
+ System.out.println("Start to load image: ");
+ try {
+ MetaReader.read(imageFile, Env.getCurrentEnv());
+ System.out.println("Load image success. Image file " +
imageTool.getImagePath() + " is valid");
+ } catch (Exception e) {
+ System.out.println("Load image failed. Image file " +
imageTool.getImagePath() + " is invalid");
+ LOG.warn("", e);
+ }
+ if (imageTool.dumpImage()) {
+ System.out.println("Start to dump image to " +
imageTool.getDumpPath());
+ imageFile = new File(imageTool.getDumpPath());
try {
- MetaReader.read(imageFile, Env.getCurrentEnv());
- System.out.println("Load image success. Image file " +
cmdLineOpts.getImagePath() + " is valid");
+ if (imageFile.exists() && !imageFile.delete()) {
+ System.out.println(imageTool.getDumpPath() + " can not
be deleted.");
+ System.exit(-1);
+ }
+ imageFile.getParentFile().mkdirs();
+ if (!imageFile.createNewFile()) {
+ System.out.println(imageTool.getDumpPath() + " can not
be created.");
+ System.exit(-1);
+ }
+ MetaWriter.write(imageFile, Env.getCurrentEnv());
Review Comment:
It's better we write an image that has already replayed the existing
editlogs.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]