Skip to content

Conversation

@chickenlj
Copy link
Contributor

@chickenlj chickenlj commented Jun 14, 2023

Currently, multiple protocol port-unification feature works the following way:

With the following configuration:

dubbo
  protocol
     name: tri
     port: -1
     ext-protocol: rest

It will create two provider urls in the registry:

  • rest://demo-service
  • tri://demo-service

But with this pull request, there will only have one url in the registry

tri://demo-service?ext.protocol=rest

Consumers can automatically tell the main protocol tri from the ext protocol, those consumers without protocol set consume tri (the main protocol) while others with protocol set consume the protocol specified (for example rest). 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.

@chickenlj chickenlj added the status/don’t-merge No plan to merge label Jun 14, 2023
@chickenlj
Copy link
Contributor Author

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

@chickenlj chickenlj removed the status/don’t-merge No plan to merge label Jul 11, 2023
@chickenlj
Copy link
Contributor Author

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();
    }

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 9 Code Smells

48.9% 48.9% Coverage
0.0% 0.0% Duplication

@codecov-commenter
Copy link

codecov-commenter commented Aug 10, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.07%. Comparing base (33a8063) to head (ebe72f6).

Current head ebe72f6 differs from pull request most recent head 8a9c1ed

Please upload reports for the commit 8a9c1ed to get more accurate results.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AlbumenJ AlbumenJ requested review from AlbumenJ and CrazyHZM and removed request for AlbumenJ August 11, 2023 02:50

@Override
public void prepareApplicationInstance() {
public void prepareApplicationInstance(ModuleModel moduleModel) {
Copy link
Member

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?

Copy link
Contributor Author

@chickenlj chickenlj Aug 14, 2023

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:

  1. when the state of a ModuleModel changes, it will call notifyModuleChanged and passes ModuleModel instance in.
  2. checkState will 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();
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

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.

@chickenlj chickenlj changed the base branch from 3.3 to 3.3.0-beta.1-release August 30, 2023 09:40
# 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
@chickenlj chickenlj merged commit 8e55dae into apache:3.3.0-beta.1-release Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants