-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Feat support check for config-center and metadata-center #15639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.3
Are you sure you want to change the base?
Changes from 16 commits
7f027a8
2642ddb
3b84280
815f205
35b34fe
94633f0
8c4fa9d
e06c7d4
9f47eea
89aedba
add3b82
8323884
9cedd32
8d8dbb6
ed5f167
ccfc70c
d19100d
e0d360f
4d44b1f
fbea966
a6b75ef
5b8198e
62300ad
eb72841
6ecb905
34d9ca0
236240a
ad7909f
f53ad95
712763e
f5a0b31
4042caf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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; | ||
| } | ||
|
|
||
|
|
@@ -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; | ||
| } | ||
|
|
||
|
|
@@ -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); | ||
|
||
| // TODO should it `updateExternalConfigMap` when the connection recovery | ||
| return dynamicConfiguration; | ||
| } | ||
| } | ||
| } catch (Exception e) { | ||
|
||
| throw new IllegalStateException(e); | ||
| } | ||
| ApplicationModel applicationModel = getApplicationModel(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
|
@@ -68,23 +67,6 @@ public class ZookeeperDynamicConfiguration extends TreePathDynamicConfiguration | |
| new AbortPolicyWithReport(threadName, url)); | ||
|
|
||
| zkClient = zookeeperClientManager.connect(url); | ||
| boolean isConnected = zkClient.isConnected(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this deletion possibly affect prepareEnvironment? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -174,4 +156,9 @@ protected void doRemoveListener(String pathKey, ConfigurationListener listener) | |
| zkClient.removeDataListener(pathKey, zookeeperDataListener); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isAvailable() { | ||
| return zkClient != null && zkClient.isConnected(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just kept the original logic, maybe it can be removed.