morningman commented on a change in pull request #4704:
URL: https://github.com/apache/incubator-doris/pull/4704#discussion_r502742507



##########
File path: fe/fe-core/src/main/java/org/apache/doris/common/ConfigBase.java
##########
@@ -284,4 +308,31 @@ public synchronized static boolean 
checkIsMasterOnly(String key) {
 
         return anno.masterOnly();
     }
+
+    // overwrite configs to customConfFile.
+    // use synchronized to make sure only one thread modify this file
+    public synchronized static void persistConfig(Map<String, String> 
customConf) throws IOException {
+        File file = new File(customConfFile);
+        if (!file.exists()) {
+            file.createNewFile();
+        } else {
+            // clear the file content
+            try (PrintWriter writer = new PrintWriter(file)) {
+                writer.print("");
+            }
+        }
+
+        Properties props = new Properties();
+        props.load(new FileReader(customConfFile));
+
+        for (Map.Entry<String, String> entry : customConf.entrySet()) {
+            props.setProperty(entry.getKey(), entry.getValue());
+        }
+
+        try (FileOutputStream fos = new FileOutputStream(file)) {
+            props.store(fos, "THIS IS AN AUTO GENERATED CONFIG FILE. DO NOT 
EDIT IT!\n\n" +

Review comment:
       OK




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to