Re: [PR] Implement Cluster ID [iotdb]

2023-12-15 Thread via GitHub


OneSizeFitsQuorum merged PR #11702:
URL: https://github.com/apache/iotdb/pull/11702


-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-15 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1427709536


##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,94 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.confignode.rpc.thrift.TGetClusterIdResp;
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterStartIT {
+  private static final Logger logger = 
LoggerFactory.getLogger(IoTDBClusterStartIT.class);
+
+  private static final String ratisConsensusProtocolClass =
+  "org.apache.iotdb.consensus.ratis.RatisConsensus";
+
+  private static final int testConfigNodeNum = 3, testDataNodeNum = 0;
+
+  @Before
+  public void setUp() {
+EnvFactory.getEnv()
+.getConfig()
+.getCommonConfig()
+.setConfigNodeConsensusProtocolClass(ratisConsensusProtocolClass)
+.setSchemaRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setDataRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setConfigNodeConsensusProtocolClass(ConsensusFactory.RATIS_CONSENSUS);
+
+EnvFactory.getEnv().initClusterEnvironment(testConfigNodeNum, 
testDataNodeNum);
+  }
+
+  @After
+  public void tearDown() {
+EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void clusterIdTest() throws ClientManagerException, IOException, 
InterruptedException {
+final long maxTestTime = TimeUnit.SECONDS.toMillis(30);
+final long testInterval = TimeUnit.SECONDS.toMillis(1);
+try (SyncConfigNodeIServiceClient client =
+(SyncConfigNodeIServiceClient) 
EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+  long startTime = System.currentTimeMillis();
+  while (System.currentTimeMillis() - startTime < maxTestTime) {
+try {
+  TGetClusterIdResp resp = client.getClusterId();

Review Comment:
   very rigourous



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-15 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1427703730


##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,94 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.confignode.rpc.thrift.TGetClusterIdResp;
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterStartIT {
+  private static final Logger logger = 
LoggerFactory.getLogger(IoTDBClusterStartIT.class);
+
+  private static final String ratisConsensusProtocolClass =
+  "org.apache.iotdb.consensus.ratis.RatisConsensus";
+
+  private static final int testConfigNodeNum = 3, testDataNodeNum = 0;
+
+  @Before
+  public void setUp() {
+EnvFactory.getEnv()
+.getConfig()
+.getCommonConfig()
+.setConfigNodeConsensusProtocolClass(ratisConsensusProtocolClass)
+.setSchemaRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setDataRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setConfigNodeConsensusProtocolClass(ConsensusFactory.RATIS_CONSENSUS);

Review Comment:
   removed



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-15 Thread via GitHub


OneSizeFitsQuorum commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1427670442


##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,94 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.confignode.rpc.thrift.TGetClusterIdResp;
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterStartIT {
+  private static final Logger logger = 
LoggerFactory.getLogger(IoTDBClusterStartIT.class);
+
+  private static final String ratisConsensusProtocolClass =
+  "org.apache.iotdb.consensus.ratis.RatisConsensus";
+
+  private static final int testConfigNodeNum = 3, testDataNodeNum = 0;
+
+  @Before
+  public void setUp() {
+EnvFactory.getEnv()
+.getConfig()
+.getCommonConfig()
+.setConfigNodeConsensusProtocolClass(ratisConsensusProtocolClass)
+.setSchemaRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setDataRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setConfigNodeConsensusProtocolClass(ConsensusFactory.RATIS_CONSENSUS);

Review Comment:
   remove duplicated



##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,94 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.confignode.rpc.thrift.TGetClusterIdResp;
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterStartIT {
+  private static final Logger logger = 
LoggerFactory.getLogger(IoTDBClusterStartIT.class);
+
+  private static final String ratisConsensusProtocolClass =
+  "org.apache.iotdb.consensus.ratis.RatisConsensus";
+
+  private static final int testConfig

Re: [PR] Implement Cluster ID [iotdb]

2023-12-14 Thread via GitHub


CRZbulabula commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1427566999


##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,96 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.confignode.rpc.thrift.TGetClusterIdResp;
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestLogger;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterStartIT {
+  private static final Logger logger = IoTDBTestLogger.logger;

Review Comment:
   But normally we use LoggerFactory.getLogger



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-14 Thread via GitHub


liyuheng5 commented on PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#issuecomment-1857273666

   > PTAL. By the way, it's better to test version updation for this PR
   
   Checked, it's work.


-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-14 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1427535358


##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,96 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.confignode.rpc.thrift.TGetClusterIdResp;
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestLogger;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterStartIT {
+  private static final Logger logger = IoTDBTestLogger.logger;
+
+  private static final String ratisConsensusProtocolClass =
+  "org.apache.iotdb.consensus.ratis.RatisConsensus";
+
+  private static final int testConfigNodeNum = 3, testDataNodeNum = 0;
+
+  private static final long maxTestTime = TimeUnit.SECONDS.toMillis(30);
+  private static final long testInterval = TimeUnit.SECONDS.toMillis(1);
+
+  @Before
+  public void setUp() {
+EnvFactory.getEnv()
+.getConfig()
+.getCommonConfig()
+.setConfigNodeConsensusProtocolClass(ratisConsensusProtocolClass)
+.setSchemaRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setDataRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setConfigNodeConsensusProtocolClass(ConsensusFactory.RATIS_CONSENSUS);
+
+EnvFactory.getEnv().initClusterEnvironment(testConfigNodeNum, 
testDataNodeNum);
+  }
+
+  @After
+  public void tearDown() {
+EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void clusterIdTest() {
+try (SyncConfigNodeIServiceClient client =
+(SyncConfigNodeIServiceClient) 
EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+  long startTime = System.currentTimeMillis();
+  while (System.currentTimeMillis() - startTime < maxTestTime) {
+try {
+  TGetClusterIdResp resp = client.getClusterId();
+  if (TSStatusCode.SUCCESS_STATUS.getStatusCode() == 
resp.getStatus().getCode()) {
+return;
+  }
+} catch (TException ignore) {
+
+}

Review Comment:
   indeed



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-14 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1427534940


##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/confignode/UpdateClusterIdPlan.java:
##
@@ -0,0 +1,76 @@
+/*
+ * 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.consensus.request.write.confignode;
+
+import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan;
+import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Objects;
+
+public class UpdateClusterIdPlan extends ConfigPhysicalPlan {

Review Comment:
   sure



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-14 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1427532888


##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/ClusterInfo.java:
##
@@ -0,0 +1,97 @@
+/*
+ * 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.persistence;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.snapshot.SnapshotProcessor;
+import 
org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateClusterIdPlan;
+import org.apache.iotdb.rpc.RpcUtils;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+import org.apache.thrift.TException;
+import org.apache.thrift.transport.TIOStreamTransport;
+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.UUID;
+
+public class ClusterInfo implements SnapshotProcessor {

Review Comment:
   good point !



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-14 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1427519409


##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,96 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.confignode.rpc.thrift.TGetClusterIdResp;
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestLogger;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterStartIT {
+  private static final Logger logger = IoTDBTestLogger.logger;

Review Comment:
   To follow IoTDBClusterRestartIT :P



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-14 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1427518489


##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,96 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.confignode.rpc.thrift.TGetClusterIdResp;
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestLogger;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterStartIT {
+  private static final Logger logger = IoTDBTestLogger.logger;
+
+  private static final String ratisConsensusProtocolClass =
+  "org.apache.iotdb.consensus.ratis.RatisConsensus";
+
+  private static final int testConfigNodeNum = 3, testDataNodeNum = 0;
+
+  private static final long maxTestTime = TimeUnit.SECONDS.toMillis(30);
+  private static final long testInterval = TimeUnit.SECONDS.toMillis(1);
+
+  @Before
+  public void setUp() {
+EnvFactory.getEnv()
+.getConfig()
+.getCommonConfig()
+.setConfigNodeConsensusProtocolClass(ratisConsensusProtocolClass)
+.setSchemaRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setDataRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setConfigNodeConsensusProtocolClass(ConsensusFactory.RATIS_CONSENSUS);
+
+EnvFactory.getEnv().initClusterEnvironment(testConfigNodeNum, 
testDataNodeNum);
+  }
+
+  @After
+  public void tearDown() {
+EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void clusterIdTest() {
+try (SyncConfigNodeIServiceClient client =
+(SyncConfigNodeIServiceClient) 
EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+  long startTime = System.currentTimeMillis();
+  while (System.currentTimeMillis() - startTime < maxTestTime) {
+try {
+  TGetClusterIdResp resp = client.getClusterId();
+  if (TSStatusCode.SUCCESS_STATUS.getStatusCode() == 
resp.getStatus().getCode()) {
+return;
+  }
+} catch (TException ignore) {
+
+}
+  }
+  String errorMessage = String.format("Cluster ID failed to generate in %d 
ms.", maxTestTime);
+  Assert.fail(errorMessage);
+} catch (ClientManagerException | IOException | InterruptedException e) {
+  throw new RuntimeException(e);

Review Comment:
   Sure, now throw them to upper level



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-14 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1427517532


##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,96 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.confignode.rpc.thrift.TGetClusterIdResp;
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestLogger;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterStartIT {
+  private static final Logger logger = IoTDBTestLogger.logger;
+
+  private static final String ratisConsensusProtocolClass =
+  "org.apache.iotdb.consensus.ratis.RatisConsensus";
+
+  private static final int testConfigNodeNum = 3, testDataNodeNum = 0;
+
+  private static final long maxTestTime = TimeUnit.SECONDS.toMillis(30);
+  private static final long testInterval = TimeUnit.SECONDS.toMillis(1);
+
+  @Before
+  public void setUp() {
+EnvFactory.getEnv()
+.getConfig()
+.getCommonConfig()
+.setConfigNodeConsensusProtocolClass(ratisConsensusProtocolClass)
+.setSchemaRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setDataRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setConfigNodeConsensusProtocolClass(ConsensusFactory.RATIS_CONSENSUS);
+
+EnvFactory.getEnv().initClusterEnvironment(testConfigNodeNum, 
testDataNodeNum);
+  }
+
+  @After
+  public void tearDown() {
+EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void clusterIdTest() {
+try (SyncConfigNodeIServiceClient client =
+(SyncConfigNodeIServiceClient) 
EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+  long startTime = System.currentTimeMillis();
+  while (System.currentTimeMillis() - startTime < maxTestTime) {
+try {
+  TGetClusterIdResp resp = client.getClusterId();
+  if (TSStatusCode.SUCCESS_STATUS.getStatusCode() == 
resp.getStatus().getCode()) {
+return;
+  }

Review Comment:
   omg sorry I forgot



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-13 Thread via GitHub


CRZbulabula commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1425191504


##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,96 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.confignode.rpc.thrift.TGetClusterIdResp;
+import org.apache.iotdb.consensus.ConsensusFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestLogger;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import org.apache.thrift.TException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({ClusterIT.class})
+public class IoTDBClusterStartIT {
+  private static final Logger logger = IoTDBTestLogger.logger;
+
+  private static final String ratisConsensusProtocolClass =
+  "org.apache.iotdb.consensus.ratis.RatisConsensus";
+
+  private static final int testConfigNodeNum = 3, testDataNodeNum = 0;
+
+  private static final long maxTestTime = TimeUnit.SECONDS.toMillis(30);
+  private static final long testInterval = TimeUnit.SECONDS.toMillis(1);
+
+  @Before
+  public void setUp() {
+EnvFactory.getEnv()
+.getConfig()
+.getCommonConfig()
+.setConfigNodeConsensusProtocolClass(ratisConsensusProtocolClass)
+.setSchemaRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setDataRegionConsensusProtocolClass(ratisConsensusProtocolClass)
+.setConfigNodeConsensusProtocolClass(ConsensusFactory.RATIS_CONSENSUS);
+
+EnvFactory.getEnv().initClusterEnvironment(testConfigNodeNum, 
testDataNodeNum);
+  }
+
+  @After
+  public void tearDown() {
+EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void clusterIdTest() {
+try (SyncConfigNodeIServiceClient client =
+(SyncConfigNodeIServiceClient) 
EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+  long startTime = System.currentTimeMillis();
+  while (System.currentTimeMillis() - startTime < maxTestTime) {
+try {
+  TGetClusterIdResp resp = client.getClusterId();
+  if (TSStatusCode.SUCCESS_STATUS.getStatusCode() == 
resp.getStatus().getCode()) {
+return;
+  }
+} catch (TException ignore) {
+
+}

Review Comment:
   The error exception should be logged
   ```suggestion
   } catch (TException e) {
 logger.error(e);
   }
   ```



##
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterStartIT.java:
##
@@ -0,0 +1,96 @@
+/*
+ * 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.it.cluster;
+
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.

Re: [PR] Implement Cluster ID [iotdb]

2023-12-13 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1425144337


##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java:
##
@@ -272,6 +277,7 @@ public ConfigManager() throws IOException {
 quotaInfo);
 this.stateMachine = new ConfigRegionStateMachine(this, executor);
 
+this.clusterManager = new ClusterManager(this, clusterInfo);

Review Comment:
   done



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-13 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1425140652


##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java:
##
@@ -203,6 +204,8 @@ public class ConfigManager implements IManager {
   private static final ConfigNodeConfig CONF = 
ConfigNodeDescriptor.getInstance().getConf();
   private static final CommonConfig COMMON_CONF = 
CommonDescriptor.getInstance().getConfig();
 
+  private final ClusterManager clusterManager;

Review Comment:
   done



-- 
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-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-13 Thread via GitHub


liyuheng5 commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1425138378


##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/statemachine/ConfigRegionStateMachine.java:
##
@@ -236,6 +236,7 @@ public void notifyLeaderReady() {
 configManager.checkUserPathPrivilege();
 // Add Metric after leader ready
 configManager.addMetrics();
+configManager.getClusterManager().checkClusterId();

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.

To unsubscribe, e-mail: reviews-unsubscr...@iotdb.apache.org

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



Re: [PR] Implement Cluster ID [iotdb]

2023-12-13 Thread via GitHub


OneSizeFitsQuorum commented on code in PR #11702:
URL: https://github.com/apache/iotdb/pull/11702#discussion_r1425105832


##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/statemachine/ConfigRegionStateMachine.java:
##
@@ -236,6 +236,7 @@ public void notifyLeaderReady() {
 configManager.checkUserPathPrivilege();
 // Add Metric after leader ready
 configManager.addMetrics();
+configManager.getClusterManager().checkClusterId();

Review Comment:
   async and add comment



##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java:
##
@@ -203,6 +204,8 @@ public class ConfigManager implements IManager {
   private static final ConfigNodeConfig CONF = 
ConfigNodeDescriptor.getInstance().getConf();
   private static final CommonConfig COMMON_CONF = 
CommonDescriptor.getInstance().getConfig();
 
+  private final ClusterManager clusterManager;

Review Comment:
   move to line 212



##
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/IoTDBShutdownHook.java:
##
@@ -55,6 +55,7 @@ public IoTDBShutdownHook() {
 
   @Override
   public void run() {
+logger.info("IoTDB exiting...");

Review Comment:
   DataNode exiting



##
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java:
##
@@ -272,6 +277,7 @@ public ConfigManager() throws IOException {
 quotaInfo);
 this.stateMachine = new ConfigRegionStateMachine(this, executor);
 
+this.clusterManager = new ClusterManager(this, clusterInfo);

Review Comment:
   move to line 283



-- 
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-unsubscr...@iotdb.apache.org

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



[PR] Implement Cluster ID [iotdb]

2023-12-12 Thread via GitHub


liyuheng5 opened a new pull request, #11702:
URL: https://github.com/apache/iotdb/pull/11702

   doc: https://apache-iotdb.feishu.cn/docx/E5hjdaWIwo2JT7xCi6bcvtyinfh


-- 
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-unsubscr...@iotdb.apache.org

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