You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2022/11/27 14:48:44 UTC
[iotdb] branch master updated: fix restart problem in confignode simple (#8207)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new d3534b7180 fix restart problem in confignode simple (#8207)
d3534b7180 is described below
commit d3534b71806e1fac3df5342a92fcd5e72d1afa7e
Author: Beyyes <cg...@foxmail.com>
AuthorDate: Sun Nov 27 22:48:39 2022 +0800
fix restart problem in confignode simple (#8207)
---
.../iotdb/confignode/manager/ConsensusManager.java | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java
index afa133575a..7e9c392e8b 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.commons.consensus.ConfigNodeRegionId;
import org.apache.iotdb.commons.consensus.ConsensusGroupId;
+import org.apache.iotdb.commons.exception.BadNodeUrlException;
import org.apache.iotdb.commons.utils.TestOnly;
import org.apache.iotdb.confignode.conf.ConfigNodeConfig;
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
@@ -51,6 +52,8 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import static org.apache.iotdb.consensus.ConsensusFactory.SIMPLE_CONSENSUS;
+
/** ConsensusManager maintains consensus class, request will redirect to consensus layer */
public class ConsensusManager {
@@ -78,10 +81,10 @@ public class ConsensusManager {
// There is only one ConfigNodeGroup
consensusGroupId = new ConfigNodeRegionId(CONF.getConfigNodeRegionId());
- if (ConsensusFactory.SIMPLE_CONSENSUS.equals(CONF.getConfigNodeConsensusProtocolClass())) {
+ if (SIMPLE_CONSENSUS.equals(CONF.getConfigNodeConsensusProtocolClass())) {
consensusImpl =
ConsensusFactory.getConsensusImpl(
- ConsensusFactory.SIMPLE_CONSENSUS,
+ SIMPLE_CONSENSUS,
ConsensusConfig.newBuilder()
.setThisNode(
new TEndPoint(CONF.getInternalAddress(), CONF.getConsensusPort()))
@@ -91,9 +94,7 @@ public class ConsensusManager {
.orElseThrow(
() ->
new IllegalArgumentException(
- String.format(
- ConsensusFactory.CONSTRUCT_FAILED_MSG,
- ConsensusFactory.SIMPLE_CONSENSUS)));
+ String.format(ConsensusFactory.CONSTRUCT_FAILED_MSG, SIMPLE_CONSENSUS)));
} else {
// Implement local ConsensusLayer by ConfigNodeConfig
consensusImpl =
@@ -179,6 +180,16 @@ public class ConsensusManager {
consensusImpl.start();
if (SystemPropertiesUtils.isRestarted()) {
// TODO: Check and notify if current ConfigNode's ip or port has changed
+
+ if (SIMPLE_CONSENSUS.equals(CONF.getConfigNodeConsensusProtocolClass())) {
+ // Only SIMPLE_CONSENSUS need invoking `createPeerForConsensusGroup` when restarted,
+ // but RATIS_CONSENSUS doesn't need it
+ try {
+ createPeerForConsensusGroup(SystemPropertiesUtils.loadConfigNodeList());
+ } catch (BadNodeUrlException e) {
+ throw new IOException(e);
+ }
+ }
LOGGER.info("Init ConsensusManager successfully when restarted");
} else if (ConfigNodeDescriptor.getInstance().isSeedConfigNode()) {
// Create ConsensusGroup that contains only itself