-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Feature improvement, only register one url for port unification. #12528
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
Feature improvement, only register one url for port unification. #12528
Conversation
# Conflicts: # dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
|
For those who want multiple protocol support with multiple address URLs should config like below: dubbo:
protocols:
- id: dubbo
name: dubbo
- id: rest
name: rest |
# Conflicts: # dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
|
With this change, the usage of Dubbo can be as simple as this: private static void main(String[] args) {
ServiceConfig<DemoService> service = new ServiceConfig<>();
service.setInterface(DemoService.class);
service.setRef(new DemoServiceImpl());
DubboBootstrap.getInstance().service(service).start().await();
} |
|
Kudos, SonarCloud Quality Gate passed! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 3.3.0-beta.1-release #12528 +/- ##
==========================================================
+ Coverage 66.19% 68.07% +1.88%
+ Complexity 20 6 -14
==========================================================
Files 3485 1710 -1775
Lines 141232 70397 -70835
Branches 20338 10220 -10118
==========================================================
- Hits 93485 47922 -45563
+ Misses 38460 17805 -20655
+ Partials 9287 4670 -4617 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| @Override | ||
| public void prepareApplicationInstance() { | ||
| public void prepareApplicationInstance(ModuleModel moduleModel) { |
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.
ApplicationDeployer depends on ModuleModel might not a good design.
BTW, if there are more than one ModuleModels, will this work not expected?
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.
DefaultApplicationDeployer.java
public void notifyModuleChanged(ModuleModel moduleModel, DeployState state) {
checkState(moduleModel, state);
}
public void checkState(ModuleModel moduleModel, DeployState moduleState) {
synchronized (stateLock) {
if (!moduleModel.isInternal() && moduleState == DeployState.STARTED) {
prepareApplicationInstance(moduleModel);
}
}It's currently designed to work this way:
- when the state of a ModuleModel changes, it will call
notifyModuleChangedand passes ModuleModel instance in. checkStatewill then check if this ModelModel isInternal, if true,prepareApplicationInstance(moduleModel);will be called.
ApplicationDeployer depends on ModuleModel mainly querying for statuses such as 'STARTED', 'isInternal', and 'hasRegistryInteraction'. All these statuses can be wrapped into an Event or something, but I think this can be further optimized with this issue #12750
| onExported(); | ||
|
|
||
| if (hasRegistrySpecified()) { | ||
| getScopeModel().getDeployer().getApplicationDeployer().exportMetadataService(); |
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.
Depends on MetadataService here might not a good design
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.
Consider provide a solution for this issue with #12750
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 seems that the full service export process can move from ServiceConfig to a new ModuleLifecycle implement? This might solve this problem
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.
Yes, I think so, this might need some extra efforts to merge this change with Lifecycle mechanism.
# Conflicts: # dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
# Conflicts: # dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java # dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryDirectory.java # dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ServiceInstanceMetadataUtils.java # dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java # dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
…' into 3.3-multiple-protocol-support # Conflicts: # dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java # dubbo-spring-boot/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java # dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency/FileTest.java








Currently, multiple protocol port-unification feature works the following way:
With the following configuration:
It will create two provider urls in the registry:
But with this pull request, there will only have one url in the registry
tri://demo-service?ext.protocol=restConsumers can automatically tell the main protocol
trifrom theextprotocol, those consumers without protocol set consumetri(the main protocol) while others with protocol set consume the protocol specified (for examplerest). One consumer instance will always stick to one specific protocol for each specific service based on the protocol setting on its side, so this pull request also addresses the issue that consumers will randomly use all protocols (tri, rest in this case) for different invocations.For application-based service discovery, the extra protocol url will still be registered to metadata, so the provide side process is not affected, what I do to this model in this patch is only to decide which protocol to use on the consumer side.