This is an automated email from the ASF dual-hosted git repository.

zyk pushed a commit to branch rel/0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.13 by this push:
     new 93e885bb32 [To rel/0.13][IOTDB-5133] Add log and directory checker for 
export schema tool (#8697)
93e885bb32 is described below

commit 93e885bb32118187c47a636e7bf34f57887e73a5
Author: Chen YZ <[email protected]>
AuthorDate: Wed Jan 4 13:36:41 2023 +0800

    [To rel/0.13][IOTDB-5133] Add log and directory checker for export schema 
tool (#8697)
    
    [To rel/0.13][IOTDB-5133] Add log and directory checker for export schema 
tool (#8697)
---
 docs/UserGuide/Maintenance-Tools/Export-Schema-Tool.md        |  6 +++---
 docs/zh/UserGuide/Maintenance-Tools/Export-Schema-Tool.md     |  6 +++---
 .../java/org/apache/iotdb/db/tools/mlog/ExportSchema.java     | 11 ++++++++++-
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/docs/UserGuide/Maintenance-Tools/Export-Schema-Tool.md 
b/docs/UserGuide/Maintenance-Tools/Export-Schema-Tool.md
index 2716fc6805..e08e6e509b 100644
--- a/docs/UserGuide/Maintenance-Tools/Export-Schema-Tool.md
+++ b/docs/UserGuide/Maintenance-Tools/Export-Schema-Tool.md
@@ -42,11 +42,11 @@ Windows
 > ./exportSchema.bat-d /yourpath/data/system/schema -o /yourpath/targetDir
 
 
-Export destination directory on server need to be specified when exporting 
metadata using scripting.
+Export destination directory on server need to be specified when exporting 
metadata using scripting. Note that the target directory path must be absolute 
path.
 ```
 usage: ExportSchema -o <target directory path> [-h <host address>] [-p <port>] 
[-u <user>] [-pw <password>] [-help]
- -o <target directory path>   Need to specify a target directory path on
-                              server(required)
+ -o <target directory path>   Need to specify a absolute target directory
+                              path on server(required)
  -h <host address>            Could specify a specify the IoTDB host
                               address, default is 127.0.0.1 (optional)
  -p <port>                    Could specify a specify the IoTDB port,
diff --git a/docs/zh/UserGuide/Maintenance-Tools/Export-Schema-Tool.md 
b/docs/zh/UserGuide/Maintenance-Tools/Export-Schema-Tool.md
index 749da80c5d..fbd6a72528 100644
--- a/docs/zh/UserGuide/Maintenance-Tools/Export-Schema-Tool.md
+++ b/docs/zh/UserGuide/Maintenance-Tools/Export-Schema-Tool.md
@@ -42,11 +42,11 @@ Windows
 
 > ./exportSchema.bat -o /yourpath/targetDir -h 127.0.0.1 -p 6667 -u root -pw 
 > root
 
-使用脚本方式导出元数据时候,需要指定 IoTDB 元数据文件的导出目标目录(位于 IoTDB 服务器上):
+使用脚本方式导出元数据时候,需要指定 IoTDB 元数据文件的导出目标目录(位于 IoTDB 服务器),注意导出目标目录必须为绝对路径。
 ```
 usage: ExportSchema -o <target directory path> [-h <host address>] [-p <port>] 
[-u <user>] [-pw <password>] [-help]
- -o <target directory path>   Need to specify a target directory path on
-                              server(required)
+ -o <target directory path>   Need to specify a absolute target directory
+                              path on server(required)
  -h <host address>            Could specify a specify the IoTDB host
                               address, default is 127.0.0.1 (optional)
  -p <port>                    Could specify a specify the IoTDB port,
diff --git 
a/server/src/main/java/org/apache/iotdb/db/tools/mlog/ExportSchema.java 
b/server/src/main/java/org/apache/iotdb/db/tools/mlog/ExportSchema.java
index 2a972092d5..89137a60f1 100644
--- a/server/src/main/java/org/apache/iotdb/db/tools/mlog/ExportSchema.java
+++ b/server/src/main/java/org/apache/iotdb/db/tools/mlog/ExportSchema.java
@@ -33,6 +33,9 @@ import org.apache.commons.cli.ParseException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
 public class ExportSchema {
   private static final Logger logger = 
LoggerFactory.getLogger(ExportSchema.class);
 
@@ -68,7 +71,7 @@ public class ExportSchema {
             .required()
             .argName(TARGET_DIR_NAME)
             .hasArg()
-            .desc("Need to specify a target directory path on 
server(required)")
+            .desc("Need to specify a absolute target directory path on 
server(required)")
             .build();
     options.addOption(targetDir);
 
@@ -159,6 +162,11 @@ public class ExportSchema {
       password = "root";
     }
     String targetDir = commandLine.getOptionValue(TARGET_DIR_ARGS);
+    Path p = Paths.get(targetDir);
+    if (!p.isAbsolute()) {
+      logger.error("Target directory path should be absolute path.");
+      return;
+    }
 
     Session session =
         new Session.Builder()
@@ -171,6 +179,7 @@ public class ExportSchema {
     try {
       session.open(false);
       session.executeNonQueryStatement(String.format("EXPORT SCHEMA '%s'", 
targetDir));
+      logger.info("Export schema successfully.");
     } catch (IoTDBConnectionException | StatementExecutionException e) {
       logger.error(e.getMessage(), e);
     } finally {

Reply via email to