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

caogaofei pushed a commit to branch beyyes/remove_confignode_develop
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 1172ea99a56e8758566561d64c5a7ebb6b1c984a
Author: Beyyes <[email protected]>
AuthorDate: Thu Aug 25 20:32:17 2022 +0800

    fix the bug that option.get() throws exception
---
 .../sync/confignode/SyncConfigNodeClientPool.java  |  7 ++--
 .../sync/datanode/SyncDataNodeClientPool.java      |  2 +-
 .../confignode/conf/ConfigNodeRemoveCheck.java     |  6 ++--
 .../confignode/conf/ConfigNodeStartupCheck.java    | 38 +++++++++++-----------
 .../confignode/service/ConfigNodeCommandLine.java  |  5 ++-
 5 files changed, 29 insertions(+), 29 deletions(-)

diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/confignode/SyncConfigNodeClientPool.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/confignode/SyncConfigNodeClientPool.java
index a596b7e9f0..44366c1b57 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/confignode/SyncConfigNodeClientPool.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/confignode/SyncConfigNodeClientPool.java
@@ -101,11 +101,8 @@ public class SyncConfigNodeClientPool {
       }
     }
     LOGGER.error("{} failed on ConfigNode {}", requestType, endPoint, 
lastException);
-    switch (requestType) {
-      default:
-        return RpcUtils.getStatus(
-            TSStatusCode.ALL_RETRY_FAILED, "All retry failed due to" + 
lastException.getMessage());
-    }
+    return RpcUtils.getStatus(
+        TSStatusCode.ALL_RETRY_FAILED, "All retry failed due to " + 
lastException.getMessage());
   }
 
   /**
diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/datanode/SyncDataNodeClientPool.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/datanode/SyncDataNodeClientPool.java
index 690acb8e90..0c85ffda88 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/datanode/SyncDataNodeClientPool.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/datanode/SyncDataNodeClientPool.java
@@ -110,7 +110,7 @@ public class SyncDataNodeClientPool {
     }
     LOGGER.error("{} failed on DataNode {}", requestType, endPoint, 
lastException);
     return new TSStatus(TSStatusCode.ALL_RETRY_FAILED.getStatusCode())
-        .setMessage("All retry failed due to" + lastException.getMessage());
+        .setMessage("All retry failed due to: " + lastException.getMessage());
   }
 
   public void deleteRegions(Set<TRegionReplicaSet> deletedRegionSet) {
diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java
index 894e712374..79206ce654 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeRemoveCheck.java
@@ -39,14 +39,14 @@ import java.util.Properties;
 public class ConfigNodeRemoveCheck {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(ConfigNodeStartupCheck.class);
 
-  private static final ConfigNodeConfig conf = 
ConfigNodeDescriptor.getInstance().getConf();
+  private static final ConfigNodeConfig CONF = 
ConfigNodeDescriptor.getInstance().getConf();
 
   private final File systemPropertiesFile;
   private final Properties systemProperties;
 
   public ConfigNodeRemoveCheck() {
     systemPropertiesFile =
-        new File(conf.getSystemDir() + File.separator + 
ConfigNodeConstant.SYSTEM_FILE_NAME);
+        new File(CONF.getSystemDir() + File.separator + 
ConfigNodeConstant.SYSTEM_FILE_NAME);
     systemProperties = new Properties();
   }
 
@@ -62,7 +62,7 @@ public class ConfigNodeRemoveCheck {
           getConfigNodeList().stream()
               .filter(e -> e.getInternalEndPoint().equals(endPoint))
               .findFirst()
-              .get();
+              .orElse(null);
     } catch (IOException | BadNodeUrlException e) {
       LOGGER.error("Load system properties file failed.", e);
     }
diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeStartupCheck.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeStartupCheck.java
index 73c1f5ab20..4afab64920 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeStartupCheck.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeStartupCheck.java
@@ -38,7 +38,7 @@ public class ConfigNodeStartupCheck {
 
   private static final Logger LOGGER = 
LoggerFactory.getLogger(ConfigNodeStartupCheck.class);
 
-  private static final ConfigNodeConfig conf = 
ConfigNodeDescriptor.getInstance().getConf();
+  private static final ConfigNodeConfig CONF = 
ConfigNodeDescriptor.getInstance().getConf();
 
   public void startUpCheck() throws StartupException, IOException, 
ConfigurationException {
     checkGlobalConfig();
@@ -52,60 +52,60 @@ public class ConfigNodeStartupCheck {
   private void checkGlobalConfig() throws ConfigurationException {
     // When the ConfigNode consensus protocol is set to StandAlone,
     // the target_config_nodes needs to point to itself
-    if 
(conf.getConfigNodeConsensusProtocolClass().equals(ConsensusFactory.StandAloneConsensus)
-        && 
(!conf.getInternalAddress().equals(conf.getTargetConfigNode().getIp())
-            || conf.getInternalPort() != 
conf.getTargetConfigNode().getPort())) {
+    if 
(CONF.getConfigNodeConsensusProtocolClass().equals(ConsensusFactory.StandAloneConsensus)
+        && 
(!CONF.getInternalAddress().equals(CONF.getTargetConfigNode().getIp())
+            || CONF.getInternalPort() != 
CONF.getTargetConfigNode().getPort())) {
       throw new ConfigurationException(
           IoTDBConstant.TARGET_CONFIG_NODES,
-          conf.getTargetConfigNode().getIp() + ":" + 
conf.getTargetConfigNode().getPort(),
-          conf.getInternalAddress() + ":" + conf.getInternalPort());
+          CONF.getTargetConfigNode().getIp() + ":" + 
CONF.getTargetConfigNode().getPort(),
+          CONF.getInternalAddress() + ":" + CONF.getInternalPort());
     }
 
     // When the data region consensus protocol is set to StandAlone,
     // the data replication factor must be 1
-    if 
(conf.getDataRegionConsensusProtocolClass().equals(ConsensusFactory.StandAloneConsensus)
-        && conf.getDataReplicationFactor() != 1) {
+    if 
(CONF.getDataRegionConsensusProtocolClass().equals(ConsensusFactory.StandAloneConsensus)
+        && CONF.getDataReplicationFactor() != 1) {
       throw new ConfigurationException(
           "data_replication_factor",
-          String.valueOf(conf.getDataReplicationFactor()),
+          String.valueOf(CONF.getDataReplicationFactor()),
           String.valueOf(1));
     }
 
     // When the schema region consensus protocol is set to StandAlone,
     // the schema replication factor must be 1
-    if 
(conf.getSchemaRegionConsensusProtocolClass().equals(ConsensusFactory.StandAloneConsensus)
-        && conf.getSchemaReplicationFactor() != 1) {
+    if 
(CONF.getSchemaRegionConsensusProtocolClass().equals(ConsensusFactory.StandAloneConsensus)
+        && CONF.getSchemaReplicationFactor() != 1) {
       throw new ConfigurationException(
           "schema_replication_factor",
-          String.valueOf(conf.getSchemaReplicationFactor()),
+          String.valueOf(CONF.getSchemaReplicationFactor()),
           String.valueOf(1));
     }
 
     // When the schema region consensus protocol is set to 
MultiLeaderConsensus,
     // we should report an error
-    if (conf.getSchemaRegionConsensusProtocolClass()
+    if (CONF.getSchemaRegionConsensusProtocolClass()
         .equals(ConsensusFactory.MultiLeaderConsensus)) {
       throw new ConfigurationException(
           "schema_region_consensus_protocol_class",
-          String.valueOf(conf.getSchemaRegionConsensusProtocolClass()),
+          String.valueOf(CONF.getSchemaRegionConsensusProtocolClass()),
           String.format(
               "%s or %s", ConsensusFactory.StandAloneConsensus, 
ConsensusFactory.RatisConsensus));
     }
 
-    if (!conf.getRoutingPolicy().equals(RouteBalancer.LEADER_POLICY)
-        && !conf.getRoutingPolicy().equals(RouteBalancer.GREEDY_POLICY)) {
+    if (!CONF.getRoutingPolicy().equals(RouteBalancer.LEADER_POLICY)
+        && !CONF.getRoutingPolicy().equals(RouteBalancer.GREEDY_POLICY)) {
       throw new ConfigurationException(
-          "routing_policy", conf.getRoutingPolicy(), "leader or greedy");
+          "routing_policy", CONF.getRoutingPolicy(), "leader or greedy");
     }
   }
 
   private void createDirsIfNecessary() throws IOException {
     // If systemDir does not exist, create systemDir
-    File systemDir = new File(conf.getSystemDir());
+    File systemDir = new File(CONF.getSystemDir());
     createDirIfEmpty(systemDir);
 
     // If consensusDir does not exist, create consensusDir
-    File consensusDir = new File(conf.getConsensusDir());
+    File consensusDir = new File(CONF.getConsensusDir());
     createDirIfEmpty(consensusDir);
   }
 
diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java
index ae36f91a92..ef4dc7a951 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java
@@ -87,6 +87,9 @@ public class ConfigNodeCommandLine extends ServerCommandLine {
         LOGGER.error("Meet error when doing remove", e);
         return -1;
       }
+    } else {
+      LOGGER.error("Unsupported startup mode: {}", mode);
+      return -1;
     }
 
     return 0;
@@ -104,7 +107,7 @@ public class ConfigNodeCommandLine extends 
ServerCommandLine {
       TConfigNodeLocation removeConfigNodeLocation =
           ConfigNodeRemoveCheck.getInstance().removeCheck(endPoint);
       if (removeConfigNodeLocation == null) {
-        LOGGER.error("The ConfigNode not in the Cluster.");
+        LOGGER.error("The ConfigNode to be removed is not in the Cluster.");
         return;
       }
 

Reply via email to