Skip to content
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 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
4cc8185
conflict resolved
fantiq Nov 11, 2025
f758db1
Merge branch '3.3' into feat_support_check_for_config_center_and_meta…
zrlw Nov 14, 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 @@ -26,7 +26,6 @@
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.threadpool.manager.ExecutorRepository;
import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository;
import org.apache.dubbo.common.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.common.utils.CollectionUtils;
Expand Down Expand Up @@ -71,7 +70,6 @@
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

Expand Down Expand Up @@ -400,11 +398,7 @@ protected void exported() {
exportedURLs.forEach(url -> {
if (url.getParameter(SERVICE_NAME_MAPPING_KEY, false)) {
ServiceNameMapping serviceNameMapping = ServiceNameMapping.getDefaultExtension(getScopeModel());
ScheduledExecutorService scheduledExecutor = getScopeModel()
.getBeanFactory()
.getBean(FrameworkExecutorRepository.class)
.getSharedScheduledExecutor();
mapServiceName(url, serviceNameMapping, scheduledExecutor);
mapServiceName(url, serviceNameMapping);
Copy link
Contributor

Choose a reason for hiding this comment

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

why remove scheduledExecutor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

}
});

Expand All @@ -423,49 +417,24 @@ public boolean hasRegistrySpecified() {
.getRegistries());
}

protected void mapServiceName(
URL url, ServiceNameMapping serviceNameMapping, ScheduledExecutorService scheduledExecutor) {
protected void mapServiceName(URL url, ServiceNameMapping serviceNameMapping) {
if (!exported) {
return;
}
logger.info("[INSTANCE_REGISTER] [METADATA_REGISTER] Try to register interface application mapping for service "
+ url.getServiceKey());
boolean succeeded = false;
try {
succeeded = serviceNameMapping.map(url);
if (succeeded) {
logger.info(
"[INSTANCE_REGISTER][METADATA_REGISTER] Successfully registered interface application mapping for service "
+ url.getServiceKey());
} else {
logger.error(
CONFIG_SERVER_DISCONNECTED,
"configuration server disconnected",
"",
"[INSTANCE_REGISTER] [METADATA_REGISTER] Failed register interface application mapping for service "
+ url.getServiceKey());
}
} catch (Exception e) {
if (serviceNameMapping.map(url)) {
logger.info(
"[INSTANCE_REGISTER][METADATA_REGISTER] Successfully registered interface application mapping for service "
+ url.getServiceKey());
} else {
logger.error(
CONFIG_SERVER_DISCONNECTED,
"configuration server disconnected",
"",
"[INSTANCE_REGISTER] [METADATA_REGISTER] Failed register interface application mapping for service "
+ url.getServiceKey(),
e);
+ url.getServiceKey());
}
if (!succeeded && serviceNameMapping.hasValidMetadataCenter()) {
scheduleToMapping(scheduledExecutor, serviceNameMapping, url);
}
}

private void scheduleToMapping(
ScheduledExecutorService scheduledExecutor, ServiceNameMapping serviceNameMapping, URL url) {
Integer mappingRetryInterval = getApplication().getMappingRetryInterval();
scheduledExecutor.schedule(
() -> mapServiceName(url, serviceNameMapping, scheduledExecutor),
mappingRetryInterval == null ? 5000 : mappingRetryInterval,
TimeUnit.MILLISECONDS);
}

private void checkAndUpdateSubConfigs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public DubboBootstrap metadataReport(Consumer<MetadataReportBuilder> consumerBui
public DubboBootstrap metadataReport(String id, Consumer<MetadataReportBuilder> consumerBuilder) {
MetadataReportBuilder metadataReportBuilder = createMetadataReportBuilder(id);
consumerBuilder.accept(metadataReportBuilder);
return this;
return metadataReport(metadataReportBuilder.build());
}

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

public DubboBootstrap configCenter(ConfigCenterConfig configCenterConfig) {
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 All @@ -118,6 +119,8 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(DefaultApplicationDeployer.class);

private static final String REFRESH_ERR = "Refresh instance and metadata error.";

private final ApplicationModel applicationModel;

private final ConfigManager configManager;
Expand Down Expand Up @@ -488,6 +491,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 +651,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 @@ -886,7 +899,6 @@ private DynamicConfiguration prepareEnvironment(ConfigCenterConfig configCenter)
if (!configCenter.checkOrUpdateInitialized(true)) {
return null;
}

DynamicConfiguration dynamicConfiguration;
try {
dynamicConfiguration = getDynamicConfiguration(configCenter.toUrl());
Expand All @@ -904,6 +916,24 @@ private DynamicConfiguration prepareEnvironment(ConfigCenterConfig configCenter)
throw new IllegalStateException(e);
}
}
if (dynamicConfiguration == null || !dynamicConfiguration.isAvailable()) {
if (configCenter.isCheck()) {
throw new IllegalStateException("The configuration center is not available");
} else if (dynamicConfiguration == null) {
logger.warn(
CONFIG_FAILED_INIT_CONFIG_CENTER,
"",
"",
"The configuration center failed to initialize, dynamicConfiguration is null.");
} else {
logger.warn(
CONFIG_FAILED_INIT_CONFIG_CENTER,
"",
"",
"The configuration center initialize successfully, but connection is not available.");
}
return dynamicConfiguration;
}
ApplicationModel applicationModel = getApplicationModel();

if (StringUtils.isNotEmpty(configCenter.getConfigFile())) {
Expand Down Expand Up @@ -1034,12 +1064,7 @@ public synchronized void registerServiceInstance() {
}
} catch (Exception e) {
if (!applicationModel.isDestroyed()) {
logger.error(
CONFIG_REFRESH_INSTANCE_ERROR,
"",
"",
"Refresh instance and metadata error.",
e);
logger.error(CONFIG_REFRESH_INSTANCE_ERROR, "", "", REFRESH_ERR, e);
}
}
},
Expand All @@ -1056,7 +1081,7 @@ public void refreshServiceInstance() {
try {
ServiceInstanceMetadataUtils.refreshMetadataAndInstance(applicationModel);
} catch (Exception e) {
logger.error(CONFIG_REFRESH_INSTANCE_ERROR, "", "", "Refresh instance and metadata error.", e);
logger.error(CONFIG_REFRESH_INSTANCE_ERROR, "", "", REFRESH_ERR, e);
}
}
}
Expand Down Expand Up @@ -1345,7 +1370,7 @@ private void onStarted() {
ServiceInstanceMetadataUtils.refreshMetadataAndInstance(applicationModel);
}
} catch (Exception e) {
logger.error(CONFIG_REFRESH_INSTANCE_ERROR, "", "", "Refresh instance and metadata error.", e);
logger.error(CONFIG_REFRESH_INSTANCE_ERROR, "", "", REFRESH_ERR, e);
}
}

Expand Down
Loading
Loading