You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/03/15 11:56:34 UTC

[GitHub] [iotdb] wangchao316 commented on a change in pull request #5247: [To new_cluster] [IOTDB-2685] Create and start config node

wangchao316 commented on a change in pull request #5247:
URL: https://github.com/apache/iotdb/pull/5247#discussion_r826873830



##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfCheck.java
##########
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.confignode.conf;
+
+import org.apache.iotdb.confignode.exception.conf.RepeatConfigurationException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Objects;
+import java.util.Properties;
+
+/**
+ * ConfigNodeConfCheck checks parameters in iotdb-confignode.properties when started, and the
+ * consistency of some specific parameters on restart
+ */
+public class ConfigNodeConfCheck {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(ConfigNodeConfCheck.class);
+
+  private static final ConfigNodeConf conf = ConfigNodeDescriptor.getInstance().getConf();
+
+  private Properties specialProperties;
+
+  public void checkConfig() throws RepeatConfigurationException, IOException {
+
+    String propsDir = ConfigNodeDescriptor.getInstance().getPropsDir();
+    if (propsDir == null) {
+      // Skip configuration check when developer mode or test mode
+      return;

Review comment:
       Read the configuration and check whether the configuration can be shared with the standalone version.

##########
File path: confignode/pom.xml
##########
@@ -46,17 +46,24 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.tomcat.embed</groupId>
-            <artifactId>tomcat-embed-core</artifactId>
-            <version>8.5.46</version>
-            <scope>test</scope>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>iotdb-commons</artifactId>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.jetbrains</groupId>
             <artifactId>annotations</artifactId>
             <version>23.0.0</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>

Review comment:
                   <version>${junit.version}</version>
               <scope>test</scope>

##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfCheck.java
##########
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.confignode.conf;
+
+import org.apache.iotdb.confignode.exception.conf.RepeatConfigurationException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Objects;
+import java.util.Properties;
+
+/**
+ * ConfigNodeConfCheck checks parameters in iotdb-confignode.properties when started, and the
+ * consistency of some specific parameters on restart
+ */
+public class ConfigNodeConfCheck {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(ConfigNodeConfCheck.class);
+
+  private static final ConfigNodeConf conf = ConfigNodeDescriptor.getInstance().getConf();
+
+  private Properties specialProperties;
+
+  public void checkConfig() throws RepeatConfigurationException, IOException {
+
+    String propsDir = ConfigNodeDescriptor.getInstance().getPropsDir();
+    if (propsDir == null) {
+      // Skip configuration check when developer mode or test mode
+      return;
+    }
+    specialProperties = new Properties();
+
+    File specialPropertiesFile =
+        new File(propsDir + File.separator + ConfigNodeConstant.SPECIAL_CONF_NAME);
+    if (!specialPropertiesFile.exists()) {
+      if (specialPropertiesFile.createNewFile()) {
+        LOGGER.info(
+            "Special configuration file {} for ConfigNode is created.",
+            specialPropertiesFile.getAbsolutePath());
+        writeSpecialProperties(specialPropertiesFile);
+        return;
+      } else {
+        LOGGER.error(
+            "Can't create special configuration file {} for ConfigNode. IoTDB-ConfigNode is shutdown.",
+            specialPropertiesFile.getAbsolutePath());
+        System.exit(-1);
+      }
+    }
+
+    FileInputStream inputStream = new FileInputStream(specialPropertiesFile);

Review comment:
       closed after stream use, you could use "try() {}"

##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConstant.java
##########
@@ -20,11 +20,31 @@
 
 public class ConfigNodeConstant {
 
+  // when running the program in IDE, we can not get the version info using
+  // getImplementationVersion()
+  public static final String VERSION =
+      ConfigNodeConstant.class.getPackage().getImplementationVersion() != null
+          ? ConfigNodeConstant.class.getPackage().getImplementationVersion()
+          : "UNKNOWN";
+
+  public static final String GLOBAL_NAME = "IoTDB ConfigNode";
+  public static final String CONFIGNODE_CONF = "CONFIGNODE_CONF";
+  public static final String CONFIGNODE_HOME = "CONFIGNODE_HOME";
+
+  public static final String ENV_FILE_NAME = "confignode-env";
+  public static final String CONF_NAME = "iotdb-confignode.properties";
+  public static final String SPECIAL_CONF_NAME = "iotdb-confignode-special.properties";
+
+  public static final String CONFIGNODE_PACKAGE = "org.apache.iotdb.confignode.service";
+  public static final String JMX_TYPE = "type";
+  public static final String CONFIGNODE_JMX_PORT = "confignode.jmx.port";
+
+  public static final String DATA_DIR = "data";

Review comment:
       Add the config_data_dir parameter to the configuration item to support mounting of multiple disks.
    see :"DirectoryManager" in server 

##########
File path: confignode/src/test/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptorTest.java
##########
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.confignode.conf;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.net.URL;
-
-public class ConfigNodeDescriptorTest {
-
-  private final String confPath = System.getProperty(ConfigNodeConf.CONF_NAME, null);
-
-  @Before
-  public void init() {
-    org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.getInstance();
-  }
-
-  @After
-  public void clear() {
-    if (confPath != null) {

Review comment:
       why does delete test?




-- 
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: reviews-unsubscribe@iotdb.apache.org

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