Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7f027a8
feat(registry): support the option, whether to check the connection …
fantiq Jul 28, 2025
2642ddb
Merge branch '3.3' into feat#15271
fantiq Jul 29, 2025
3b84280
Merge branch '3.3' into feat#15271
RainYuY Jul 30, 2025
815f205
use option directly
fantiq Aug 1, 2025
35b34fe
Merge remote-tracking branch 'origin/feat#15271' into feat#15271
fantiq Aug 1, 2025
94633f0
add connect check before retry task
fantiq Aug 4, 2025
8c4fa9d
Merge branch 'feat#15271' into feat_support_check_for_config_center_a…
fantiq Aug 7, 2025
e06c7d4
feat(config): support check option for config-center metadata-center …
fantiq Aug 19, 2025
9f47eea
Merge branch '3.3' into feat_support_check_for_config_center_and_meta…
fantiq Aug 19, 2025
89aedba
fix: ut and errCode check
fantiq Aug 19, 2025
add3b82
Merge remote-tracking branch 'origin/feat_support_check_for_config_ce…
fantiq Aug 19, 2025
8323884
fix(retry): 1: remote config_center retry. 2: fix service_discovery i…
fantiq Aug 25, 2025
9cedd32
fix for integration case
fantiq Aug 25, 2025
8d8dbb6
fix: format
fantiq Aug 25, 2025
ed5f167
fix(integration_case): metadata_report err msg.
fantiq Aug 25, 2025
ccfc70c
Merge branch '3.3' into feat_support_check_for_config_center_and_meta…
fantiq Aug 25, 2025
d19100d
fix: 1: copilot suggest. 2: service-discovery-registry destory() shou…
fantiq Aug 25, 2025
e0d360f
fix: copilot suggest, use single thread mode
fantiq Aug 26, 2025
4d44b1f
fix: improve the client create behavior
fantiq Aug 27, 2025
fbea966
fix(metadata-report): service-name-mapping report retry use dubbo sha…
fantiq Aug 28, 2025
a6b75ef
fix format
fantiq Aug 28, 2025
5b8198e
refactor(service-discovery): improve the method register() and update()
fantiq Sep 2, 2025
62300ad
fmt fix
fantiq Sep 2, 2025
eb72841
fix(service-discovery): support register subscribe retry
fantiq Sep 8, 2025
6ecb905
Merge branch '3.3' into feat_support_check_for_config_center_and_meta…
zrlw Sep 11, 2025
34d9ca0
Simplify error logging in DefaultApplicationDeployer to meet error co…
zrlw Sep 11, 2025
236240a
Refactor refresh instance error log info to meet code format requirement
zrlw Sep 11, 2025
ad7909f
fix: error-code check
fantiq Sep 11, 2025
f53ad95
fix copilot's suggestion
fantiq Sep 12, 2025
712763e
Merge branch '3.3' into feat_support_check_for_config_center_and_meta…
zrlw Sep 17, 2025
f5a0b31
merge 3.3
fantiq Sep 18, 2025
4042caf
Merge branch '3.3' into feat_support_check_for_config_center_and_meta…
RainYuY Oct 1, 2025
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 @@ -222,4 +222,12 @@ static String getRuleKey(URL url) {
default boolean removeConfig(String key, String group) {
return true;
}

/**
* check the config center client connection available
* @return the connection status
*/
default boolean isAvailable() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,9 @@ private Object iterateConfigOperation(Function<DynamicConfiguration, Object> fun
}
return value;
}

@Override
public boolean isAvailable() {
return !configurations.isEmpty() && configurations.stream().anyMatch(DynamicConfiguration::isAvailable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import static java.util.Collections.emptyMap;
import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE;
import static org.apache.dubbo.common.constants.CommonConstants.CHECK_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.CLASSIFIER_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
Expand Down Expand Up @@ -522,6 +523,10 @@ public static boolean isRegistry(URL url) {
|| (url.getProtocol() != null && url.getProtocol().endsWith("-registry-protocol"));
}

public static boolean isCheck(URL url) {
return url.getParameter(CHECK_KEY, true) && url.getPort() != 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why check url.getPort() != 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why check url.getPort() != 0?

It just kept the original logic, maybe it can be removed.

}

/**
* The specified {@link URL} is service discovery registry type or not
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ protected void mapServiceName(
}
logger.info("[INSTANCE_REGISTER] [METADATA_REGISTER] Try to register interface application mapping for service "
+ url.getServiceKey());
try {
serviceNameMapping.mapping(url);
return;
} catch (UnsupportedOperationException ignore) {
}
boolean succeeded = false;
try {
succeeded = serviceNameMapping.map(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ public DubboBootstrap metadataReport(Consumer<MetadataReportBuilder> consumerBui
public DubboBootstrap metadataReport(String id, Consumer<MetadataReportBuilder> consumerBuilder) {
MetadataReportBuilder metadataReportBuilder = createMetadataReportBuilder(id);
consumerBuilder.accept(metadataReportBuilder);
metadataReport(metadataReportBuilder.build());
return this;
}

Expand Down Expand Up @@ -673,6 +674,7 @@ public DubboBootstrap configCenter(Consumer<ConfigCenterBuilder> consumerBuilder
public DubboBootstrap configCenter(String id, Consumer<ConfigCenterBuilder> consumerBuilder) {
ConfigCenterBuilder configCenterBuilder = createConfigCenterBuilder(id);
consumerBuilder.accept(configCenterBuilder);
configCenter(configCenterBuilder.build());
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class MetadataReportBuilder extends AbstractBuilder<MetadataReportConfig,
*/
private Boolean check;

private Boolean reportDefinition;

public static MetadataReportBuilder newBuilder() {
return new MetadataReportBuilder();
}
Expand Down Expand Up @@ -141,6 +143,11 @@ public MetadataReportBuilder check(Boolean check) {
return getThis();
}

public MetadataReportBuilder reportDefinition(Boolean reportDefinition) {
this.reportDefinition = reportDefinition;
return getThis();
}

@Override
public MetadataReportConfig build() {
MetadataReportConfig metadataReport = new MetadataReportConfig();
Expand All @@ -157,6 +164,7 @@ public MetadataReportConfig build() {
metadataReport.setCycleReport(cycleReport);
metadataReport.setSyncReport(syncReport);
metadataReport.setCheck(check);
metadataReport.setReportDefinition(reportDefinition);

return metadataReport;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@

import static java.lang.String.format;
import static org.apache.dubbo.common.config.ConfigurationUtils.parseProperties;
import static org.apache.dubbo.common.constants.CommonConstants.CHECK_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_SPLIT_PATTERN;
import static org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METRICS_COLLECTOR_EXCEPTION;
Expand Down Expand Up @@ -488,6 +489,11 @@ private ConfigCenterConfig registryAsConfigCenter(RegistryConfig registryConfig)
cc.setTimeout(registryConfig.getTimeout().longValue());
}
cc.setHighestPriority(false);
// use registry check option
if (Boolean.FALSE == registryConfig.isCheck()
|| !Boolean.parseBoolean(cc.getParameters().getOrDefault(CHECK_KEY, "true"))) {
cc.setCheck(false);
}
return cc;
}

Expand Down Expand Up @@ -643,6 +649,11 @@ private MetadataReportConfig registryAsMetadataCenter(
if (metadataReportConfig.getTimeout() == null) {
metadataReportConfig.setTimeout(registryConfig.getTimeout());
}
// use registry check option
if (Boolean.FALSE == registryConfig.isCheck()
|| !Boolean.parseBoolean(metadataReportConfig.getParameters().getOrDefault(CHECK_KEY, "true"))) {
metadataReportConfig.setCheck(false);
}
return metadataReportConfig;
}

Expand Down Expand Up @@ -890,19 +901,17 @@ private DynamicConfiguration prepareEnvironment(ConfigCenterConfig configCenter)
DynamicConfiguration dynamicConfiguration;
try {
dynamicConfiguration = getDynamicConfiguration(configCenter.toUrl());
} catch (Exception e) {
if (!configCenter.isCheck()) {
if (!dynamicConfiguration.isAvailable()) {
logger.warn(
CONFIG_FAILED_INIT_CONFIG_CENTER,
"",
"",
"The configuration center failed to initialize",
e);
configCenter.setInitialized(false);
return null;
} else {
throw new IllegalStateException(e);
CONFIG_FAILED_INIT_CONFIG_CENTER, "", "", "The configuration center failed to initialize");
if (!configCenter.isCheck()) {
configCenter.setInitialized(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. initialized was already set to true at configCenter.checkOrUpdateInitialized(true).
  2. you might miss the process when dynamicConfiguration.isAvailable() return false and configCenter.isCheck() returns true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. yes, the configCenter.setInitialized(true) is unnecessary, i'll delete it later.
  2. if check = true, the create process will always throw IllegalStateException.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

            try {
                dynamicConfiguration = getDynamicConfiguration(configCenter.toUrl());
                if (!dynamicConfiguration.isAvailable()) {
                    logger.warn(
                            CONFIG_FAILED_INIT_CONFIG_CENTER, "", "", "The configuration center failed to initialize");
                    if (!configCenter.isCheck()) {
                        configCenter.setInitialized(true);
                        // TODO should it `updateExternalConfigMap` when the connection recovery
                        return dynamicConfiguration;
                    }
                }
            } catch (Exception e) {
                throw new IllegalStateException(e);
            }

it seemed you don't throw exception when check is true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When executing dynamicConfiguration = getDynamicConfiguration(configCenter.toUrl());, SPI DynamicConfigurationFactory will create DynamicConfiguration. Currently the impl nacos zookeeper and apollo will throw IllegalStateException if the check = true and the connection is unavailable.

Do you mean here need throw exception when check=true and connection is not available, to prevent situations where this logic is not implemented in other extensions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't know customer extensions whether throw exception or not, it might be better to prevent such situations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Right, it was fixed and also the metadata-report client.

// TODO should it `updateExternalConfigMap` when the connection recovery
return dynamicConfiguration;
}
}
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seemed werid that throw IllegalStateException in the try-catch block, maybe you should catch exception before checking dynamicConfiguration.

throw new IllegalStateException(e);
}
ApplicationModel applicationModel = getApplicationModel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
import org.apache.dubbo.common.utils.ConcurrentHashMapUtils;
import org.apache.dubbo.common.utils.MD5Utils;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.common.utils.UrlUtils;
import org.apache.dubbo.metrics.config.event.ConfigCenterEvent;
import org.apache.dubbo.metrics.event.MetricsEventBus;
import org.apache.dubbo.rpc.model.ApplicationModel;

import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -103,6 +105,9 @@ private NacosConfigServiceWrapper buildConfigService(URL url) {
int retryTimes = url.getPositiveParameter(NACOS_RETRY_KEY, 10);
int sleepMsBetweenRetries = url.getPositiveParameter(NACOS_RETRY_WAIT_KEY, 1000);
boolean check = url.getParameter(NACOS_CHECK_KEY, true);
if (check && !UrlUtils.isCheck(url)) {
check = false;
}
ConfigService tmpConfigServices = null;
try {
for (int i = 0; i < retryTimes + 1; i++) {
Expand Down Expand Up @@ -394,4 +399,12 @@ private ConfigChangeType getChangeType(String configInfo, String oldValue) {
protected String buildListenerKey(String key, String group) {
return key + HYPHEN_CHAR + group;
}

@Override
public boolean isAvailable() {
Optional<String> status = Optional.ofNullable(configService)
.map(NacosConfigServiceWrapper::getConfigService)
.map(ConfigService::getServerStatus);
return status.isPresent() && UP.equals(status.get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

import org.apache.zookeeper.data.Stat;

import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_CONNECT_REGISTRY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;

public class ZookeeperDynamicConfiguration extends TreePathDynamicConfiguration {
Expand Down Expand Up @@ -68,23 +67,6 @@ public class ZookeeperDynamicConfiguration extends TreePathDynamicConfiguration
new AbortPolicyWithReport(threadName, url));

zkClient = zookeeperClientManager.connect(url);
boolean isConnected = zkClient.isConnected();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this deletion possibly affect prepareEnvironment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the check = false and connection is unavailable, the client will add to cache, but will not assign the externalConfiguration and appExternalConfiguration.
Is it necessary to assign the externalConfiguration and appExternalConfiguration when connection recovery?

if (!isConnected) {

IllegalStateException illegalStateException = new IllegalStateException(
"Failed to connect with zookeeper, pls check if url " + url + " is correct.");

if (logger != null) {
logger.error(
CONFIG_FAILED_CONNECT_REGISTRY,
"configuration server offline",
"",
"Failed to connect with zookeeper",
illegalStateException);
}

throw illegalStateException;
}
}

/**
Expand Down Expand Up @@ -174,4 +156,9 @@ protected void doRemoveListener(String pathKey, ConfigurationListener listener)
zkClient.removeDataListener(pathKey, zookeeperDataListener);
}
}

@Override
public boolean isAvailable() {
return zkClient != null && zkClient.isConnected();
}
}
Loading
Loading