Skip to content

Commit

Permalink
[IOTDB-6295] Adjust the timeout period in ConfigNode registration pro…
Browse files Browse the repository at this point in the history
…cedure (apache#11962)
  • Loading branch information
CRZbulabula authored Jan 24, 2024
1 parent 2072603 commit c52da2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -1220,10 +1221,13 @@ public TSStatus checkConfigNodeGlobalConfig(TConfigNodeRegisterReq req) {

@Override
public TSStatus createPeerForConsensusGroup(List<TConfigNodeLocation> configNodeLocations) {
for (int i = 0; i < 30; i++) {
final long rpcTimeoutInMS = COMMON_CONF.getConnectionTimeoutInMS();
final long retryIntervalInMS = 1000;

for (int i = 0; i < rpcTimeoutInMS / retryIntervalInMS; i++) {
try {
if (consensusManager.get() == null) {
Thread.sleep(1000);
TimeUnit.MILLISECONDS.sleep(retryIntervalInMS);
} else {
// When add non Seed-ConfigNode to the ConfigNodeGroup, the parameter should be emptyList
consensusManager.get().createPeerForConsensusGroup(Collections.emptyList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.apache.iotdb.commons.concurrent.ThreadModule;
import org.apache.iotdb.commons.concurrent.ThreadName;
import org.apache.iotdb.commons.concurrent.ThreadPoolMetrics;
import org.apache.iotdb.commons.conf.CommonConfig;
import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.exception.StartupException;
import org.apache.iotdb.commons.service.JMXService;
Expand Down Expand Up @@ -74,11 +76,12 @@ public class ConfigNode implements ConfigNodeMBean {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigNode.class);

private static final ConfigNodeConfig CONF = ConfigNodeDescriptor.getInstance().getConf();
private static final CommonConfig COMMON_CONFIG = CommonDescriptor.getInstance().getConfig();

private static final int STARTUP_RETRY_NUM = 10;
private static final int SCHEDULE_WAITING_RETRY_NUM = 20;
private static final long STARTUP_RETRY_INTERVAL_IN_MS = TimeUnit.SECONDS.toMillis(3);

private static final int SCHEDULE_WAITING_RETRY_NUM =
(int) (COMMON_CONFIG.getConnectionTimeoutInMS() / STARTUP_RETRY_INTERVAL_IN_MS);
private static final int SEED_CONFIG_NODE_ID = 0;

private static final int INIT_NON_SEED_CONFIG_NODE_ID = -1;
Expand Down Expand Up @@ -425,11 +428,6 @@ public ConfigManager getConfigManager() {
return configManager;
}

public void addMetrics() {
// Add some Metrics for configManager
configManager.addMetrics();
}

protected void addShutDownHook() {
Runtime.getRuntime().addShutdownHook(new ConfigNodeShutdownHook());
}
Expand Down

0 comments on commit c52da2b

Please sign in to comment.