Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
104dc71
fix: Hopefully fixed the build of the cpp-example on windows systems
chrisdutz Aug 17, 2023
0db1a8f
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 17, 2023
1bdc2cf
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 18, 2023
0ea9e78
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 21, 2023
4b79d7a
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 31, 2023
5e54115
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 31, 2023
b16c9a0
Merge remote-tracking branch 'upstream/master'
chrisdutz Sep 5, 2023
d162a48
Merge branch 'apache:master' into master
chrisdutz Sep 6, 2023
13ef12e
Merge remote-tracking branch 'upstream/master'
chrisdutz Sep 7, 2023
4f22e11
Merge branch 'apache:master' into master
chrisdutz Sep 8, 2023
bbbf3e3
Merge remote-tracking branch 'upstream/master'
chrisdutz Sep 14, 2023
8a56b00
Merge remote-tracking branch 'upstream/master'
chrisdutz Sep 19, 2023
2ad77a6
Merge remote-tracking branch 'upstream/master'
chrisdutz Oct 17, 2023
383d101
Merge remote-tracking branch 'upstream/master'
chrisdutz Nov 1, 2023
f6f4ac6
Merge remote-tracking branch 'upstream/master'
chrisdutz Nov 7, 2023
e1c6f72
fix: Increase the timeout even more to finally make the build succeed.
chrisdutz Nov 7, 2023
8a18cf3
Merge remote-tracking branch 'upstream/master'
chrisdutz Nov 9, 2023
8b9075a
Merge remote-tracking branch 'upstream/master'
chrisdutz Nov 29, 2023
a6c11a0
Merge remote-tracking branch 'upstream/master'
chrisdutz Nov 29, 2023
18ccb78
Merge remote-tracking branch 'upstream/master'
chrisdutz Jan 3, 2024
1c5d175
Merge remote-tracking branch 'upstream/master'
chrisdutz Jan 8, 2024
d650a88
Merge remote-tracking branch 'upstream/master'
chrisdutz Jan 9, 2024
c84581a
Merge remote-tracking branch 'upstream/master'
chrisdutz Jan 23, 2024
f6e5f1c
Merge remote-tracking branch 'upstream/master'
chrisdutz Jan 30, 2024
bf64c2f
Merge remote-tracking branch 'upstream/master'
chrisdutz Feb 5, 2024
66680d1
Merge remote-tracking branch 'upstream/master'
chrisdutz Mar 13, 2024
9e62ab3
Merge remote-tracking branch 'upstream/master'
chrisdutz Mar 14, 2024
24f7842
fix: Fix the build.
chrisdutz Mar 14, 2024
9012fa9
Merge remote-tracking branch 'refs/remotes/origin/master'
chrisdutz Apr 15, 2024
9e5b39a
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Apr 15, 2024
055fc0d
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Apr 18, 2024
c08a231
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Apr 22, 2024
1134199
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz May 2, 2024
a835848
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz May 17, 2024
ac5791a
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz May 24, 2024
9d7e9bd
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz May 27, 2024
af5cbcc
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz May 28, 2024
4e32ab5
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 4, 2024
2bb282f
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 7, 2024
8e6f9b3
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 11, 2024
ff8f7d2
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 12, 2024
d4cc59d
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 13, 2024
9124725
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 25, 2024
2510143
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jul 10, 2024
7b678c7
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jul 11, 2024
8153f1e
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jul 31, 2024
77f7acf
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Aug 5, 2024
9ced664
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Aug 5, 2024
bede87a
chore: Started updating the config node cli to allow removing of conf…
chrisdutz Aug 5, 2024
2ab9553
Merge remote-tracking branch 'upstream/master' into issue/cleanup-con…
chrisdutz Aug 7, 2024
0aac6ad
chore: Added more tests
chrisdutz Aug 7, 2024
abc2e61
Merge remote-tracking branch 'upstream/master' into issue/cleanup-con…
chrisdutz Aug 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ IF "%~1"=="--help" (
echo Usage:
echo Remove the ConfigNode with confignode_id
echo ./sbin/remove-confignode.bat [confignode_id]
echo Remove the ConfigNode with address:port
echo ./sbin/remove-confignode.bat [cn_internal_address:cn_internal_port]
EXIT /B 0
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ if [ "$#" -eq 1 ] && [ "$1" == "--help" ]; then
echo "Usage:"
echo "Remove the ConfigNode with confignode_id"
echo "./sbin/remove-confignode.sh [confignode_id]"
echo "Remove the ConfigNode with address:port"
echo "./sbin/remove-confignode.sh [cn_internal_address:cn_internal_port]"
exit 0
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public class ConfigNodeConstant {
public static final String CONFIGNODE_PACKAGE = "org.apache.iotdb.confignode.service";
public static final String CONFIGNODE_JMX_PORT = "confignode.jmx.port";

public static final String REMOVE_CONFIGNODE_USAGE =
"Executed failed, check usage: <Node-id>/<internal_address>:<internal_port>";
public static final String REMOVE_CONFIGNODE_USAGE = "Executed failed, check usage: <Node-id>";

public static final String REMOVE_DATANODE_PROCESS = "[REMOVE_DATANODE_PROCESS]";
public static final String REGION_MIGRATE_PROCESS = "[REGION_MIGRATE_PROCESS]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
package org.apache.iotdb.confignode.conf;

import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.exception.BadNodeUrlException;
import org.apache.iotdb.commons.utils.NodeUrlUtils;
import org.apache.iotdb.confignode.client.CnToCnNodeRequestType;
import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool;
import org.apache.iotdb.rpc.TSStatusCode;
Expand All @@ -48,53 +46,43 @@ public class ConfigNodeRemoveCheck {

private static final Logger LOGGER = LoggerFactory.getLogger(ConfigNodeRemoveCheck.class);

private static final ConfigNodeConfig CONF = ConfigNodeDescriptor.getInstance().getConf();

private final SyncConfigNodeClientPool configNodeClientPool;
private final File systemPropertiesFile;
private final Properties systemProperties;

public ConfigNodeRemoveCheck() {
systemPropertiesFile =
new File(CONF.getSystemDir() + File.separator + ConfigNodeConstant.SYSTEM_FILE_NAME);
systemProperties = new Properties();
this(ConfigNodeDescriptor.getInstance().getConf(), SyncConfigNodeClientPool.getInstance());
}

public ConfigNodeRemoveCheck(
ConfigNodeConfig conf, SyncConfigNodeClientPool configNodeClientPool) {
this.configNodeClientPool = configNodeClientPool;
this.systemPropertiesFile =
new File(conf.getSystemDir() + File.separator + ConfigNodeConstant.SYSTEM_FILE_NAME);
this.systemProperties = new Properties();
}

public TConfigNodeLocation removeCheck(String args) {
TConfigNodeLocation nodeLocation = new TConfigNodeLocation();
if (!systemPropertiesFile.exists()) {
LOGGER.error("The system properties file is not exists. IoTDB-ConfigNode is shutdown.");
return nodeLocation;
return null;
}
try (FileInputStream inputStream = new FileInputStream(systemPropertiesFile)) {
systemProperties.load(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
if (isNumeric(args)) {
int id = Integer.parseInt(args);
nodeLocation =
getConfigNodeList().stream()
.filter(e -> e.getConfigNodeId() == id)
.findFirst()
.orElse(null);
return getConfigNodeList().stream()
.filter(e -> e.getConfigNodeId() == id)
.findFirst()
.orElse(null);
} else {
try {
TEndPoint endPoint = NodeUrlUtils.parseTEndPointUrl(args);
nodeLocation =
getConfigNodeList().stream()
.filter(e -> e.getInternalEndPoint().equals(endPoint))
.findFirst()
.orElse(null);
} catch (BadNodeUrlException e) {
LOGGER.info(
"Usage: remove-confignode.sh <confignode-id> "
+ "or remove-confignode.sh <internal_address>:<internal_port>",
e);
return nodeLocation;
}
LOGGER.error("Invalid format. Expected a numeric node id, but got: {}", args);
}
} catch (IOException | BadNodeUrlException e) {
LOGGER.error("Load system properties file failed.", e);
}

return nodeLocation;
return null;
}

public void removeConfigNode(TConfigNodeLocation removedNode)
Expand All @@ -108,11 +96,10 @@ public void removeConfigNode(TConfigNodeLocation removedNode)
for (TConfigNodeLocation configNodeLocation : configNodeList) {
status =
(TSStatus)
SyncConfigNodeClientPool.getInstance()
.sendSyncRequestToConfigNodeWithRetry(
configNodeLocation.getInternalEndPoint(),
removedNode,
CnToCnNodeRequestType.REMOVE_CONFIG_NODE);
configNodeClientPool.sendSyncRequestToConfigNodeWithRetry(
configNodeLocation.getInternalEndPoint(),
removedNode,
CnToCnNodeRequestType.REMOVE_CONFIG_NODE);
if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,66 @@ public class ConfigNodeCommandLine extends ServerCommandLine {
// Remove ConfigNode
private static final String MODE_REMOVE = "-r";

private final ConfigNode configNode;
private final ConfigNodeRemoveCheck configNodeRemoveCheck;

private static final String USAGE =
"Usage: <-s|-r> "
+ "[-D{} <configure folder>] \n"
+ "-s: Start the ConfigNode and join to the cluster\n"
+ "-r: Remove the ConfigNode out of the cluster\n";

/** Default constructor using the singletons for initializing the relationship. */
public ConfigNodeCommandLine() {
this(ConfigNode.getInstance(), ConfigNodeRemoveCheck.getInstance());
}

/**
* Additional constructor allowing injection of custom instances (mainly for testing)
*
* @param configNode reference to a config node
* @param configNodeRemoveCheck reference to the config node remove check
*/
public ConfigNodeCommandLine(ConfigNode configNode, ConfigNodeRemoveCheck configNodeRemoveCheck) {
this.configNode = configNode;
this.configNodeRemoveCheck = configNodeRemoveCheck;
}

@Override
protected String getUsage() {
return USAGE;
}

@Override
protected int run(String[] args) {
String mode;
if (args.length < 1) {
mode = MODE_START;
LOGGER.warn(
"ConfigNode does not specify a startup mode. The default startup mode {} will be used",
MODE_START);
} else {
mode = args[0];
if ((args == null) || (args.length < 1)) {
usage(null);
return -1;
}

String mode = args[0];
LOGGER.info("Running mode {}", mode);
if (MODE_START.equals(mode)) {
try {
// Do ConfigNode startup checks
LOGGER.info("Starting IoTDB {}", IoTDBConstant.VERSION_WITH_BUILD);
LOGGER.info("Starting ConfigNode {}", IoTDBConstant.VERSION_WITH_BUILD);
ConfigNodeStartupCheck checks = new ConfigNodeStartupCheck(IoTDBConstant.CN_ROLE);
checks.startUpCheck();
} catch (StartupException | ConfigurationException | IOException e) {
LOGGER.error("Meet error when doing start checking", e);
LOGGER.error("Received an error during startup of ConfigNode", e);
return -1;
}
activeConfigNodeInstance();
} else if (MODE_REMOVE.equals(mode)) {
if (args.length != 2) {
LOGGER.error("Expected 2 arguments, but got {}", args.length);
return -1;
}
// remove ConfigNode
try {
doRemoveConfigNode(args);
} catch (IOException e) {
LOGGER.error("Meet error when doing remove ConfigNode", e);
} catch (IOException | BadNodeUrlException e) {
LOGGER.error("Received an error during removal of ConfigNode", e);
return -1;
}
} else {
Expand All @@ -94,28 +113,25 @@ protected int run(String[] args) {
}

protected void activeConfigNodeInstance() {
ConfigNode.getInstance().active();
configNode.active();
}

protected void doRemoveConfigNode(String[] args) throws IOException {

protected void doRemoveConfigNode(String[] args) throws BadNodeUrlException, IOException {
if (args.length != 2) {
LOGGER.info(REMOVE_CONFIGNODE_USAGE);
return;
}

LOGGER.info("Starting to remove ConfigNode, parameter: {}, {}", args[0], args[1]);

try {
TConfigNodeLocation removeConfigNodeLocation =
ConfigNodeRemoveCheck.getInstance().removeCheck(args[1]);
if (removeConfigNodeLocation == null) {
LOGGER.error(
"The ConfigNode to be removed is not in the cluster, or the input format is incorrect.");
return;
}
TConfigNodeLocation removeConfigNodeLocation = configNodeRemoveCheck.removeCheck(args[1]);
// If for any reason no config node could be found, abort here.
if (removeConfigNodeLocation == null) {
throw new BadNodeUrlException("No ConfigNode to remove");
}

ConfigNodeRemoveCheck.getInstance().removeConfigNode(removeConfigNodeLocation);
try {
configNodeRemoveCheck.removeConfigNode(removeConfigNodeLocation);
} catch (BadNodeUrlException e) {
LOGGER.warn("No ConfigNodes need to be removed.", e);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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 junit.framework.TestCase;

public class ConfigNodeRemoveCheckTest extends TestCase {

public void testRemoveCheckNodeId() {}

public void testRemoveCheckRpcAndPort() {}

public void testRemoveConfigNode() {}
}
Loading