You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2021/11/20 13:41:02 UTC
[incubator-doris] branch master updated: [refactor] extract duplicate code to writePropertiesToFile (#7119)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new a88541d [refactor] extract duplicate code to writePropertiesToFile (#7119)
a88541d is described below
commit a88541d2d4412af4243e63039d5afcc591053d09
Author: Universe <23...@qq.com>
AuthorDate: Sat Nov 20 21:40:50 2021 +0800
[refactor] extract duplicate code to writePropertiesToFile (#7119)
Extract duplicate code to writePropertiesToFile in org/apache/doris/persist/Storage.java
---
.../main/java/org/apache/doris/persist/Storage.java | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/Storage.java b/fe/fe-core/src/main/java/org/apache/doris/persist/Storage.java
index 5f79d54..999687c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/Storage.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/Storage.java
@@ -217,20 +217,7 @@ public class Storage {
Properties properties = new Properties();
setFields(properties);
- RandomAccessFile file = new RandomAccessFile(new File(metaDir, VERSION_FILE), "rws");
- FileOutputStream out = null;
-
- try {
- file.seek(0);
- out = new FileOutputStream(file.getFD());
- properties.store(out, null);
- file.setLength(out.getChannel().position());
- } finally {
- if (out != null) {
- out.close();
- }
- file.close();
- }
+ writePropertiesToFile(properties, VERSION_FILE);
}
public void writeFrontendRoleAndNodeName(FrontendNodeType role, String nameNode) throws IOException {
@@ -239,7 +226,11 @@ public class Storage {
properties.setProperty(FRONTEND_ROLE, role.name());
properties.setProperty(NODE_NAME, nameNode);
- RandomAccessFile file = new RandomAccessFile(new File(metaDir, ROLE_FILE), "rws");
+ writePropertiesToFile(properties, ROLE_FILE);
+ }
+
+ private void writePropertiesToFile(Properties properties, String fileName) throws IOException {
+ RandomAccessFile file = new RandomAccessFile(new File(metaDir, fileName), "rws");
FileOutputStream out = null;
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org