Skip to content
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

[ISSUE-#7722] Fix serviceNameMapping didn't work problem. #7723

Merged
merged 1 commit into from
May 13, 2021

Conversation

horizonzy
Copy link
Member

What is the purpose of the change

For-#7722

@codecov-commenter
Copy link

codecov-commenter commented May 10, 2021

Codecov Report

Merging #7723 (18c5b4c) into master (f29663b) will increase coverage by 0.00%.
The diff coverage is 40.00%.

❗ Current head 18c5b4c differs from pull request most recent head 259eaaa. Consider uploading reports for the commit 259eaaa to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##             master    #7723   +/-   ##
=========================================
  Coverage     59.18%   59.19%           
+ Complexity      529      528    -1     
=========================================
  Files          1076     1076           
  Lines         43540    43529   -11     
  Branches       6363     6364    +1     
=========================================
- Hits          25771    25765    -6     
  Misses        14903    14903           
+ Partials       2866     2861    -5     
Impacted Files Coverage Δ Complexity Δ
...egistry/client/migration/MigrationRuleHandler.java 45.45% <ø> (ø) 0.00 <0.00> (ø)
.../dubbo/registry/integration/RegistryDirectory.java 76.19% <ø> (+0.35%) 0.00 <0.00> (ø)
.../registry/zookeeper/ZookeeperServiceDiscovery.java 30.95% <0.00%> (-2.82%) 0.00 <0.00> (ø)
...keeper/ZookeeperServiceDiscoveryChangeWatcher.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...gistry/client/EventPublishingServiceDiscovery.java 73.75% <20.00%> (ø) 0.00 <0.00> (ø)
...e/dubbo/registry/integration/DynamicDirectory.java 74.25% <50.00%> (+10.89%) 0.00 <0.00> (ø)
...ache/dubbo/cache/support/AbstractCacheFactory.java 87.50% <75.00%> (-12.50%) 0.00 <0.00> (ø)
...dubbo/rpc/cluster/directory/AbstractDirectory.java 89.47% <100.00%> (ø) 0.00 <0.00> (ø)
...che/dubbo/remoting/transport/mina/MinaChannel.java 35.52% <0.00%> (-10.53%) 14.00% <0.00%> (-1.00%)
.../dubbo/remoting/transport/netty4/NettyChannel.java 59.40% <0.00%> (-1.99%) 0.00% <0.00%> (ø%)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f29663b...259eaaa. Read the comment docs.

Copy link
Contributor

@xiaoheng1 xiaoheng1 left a comment

Choose a reason for hiding this comment

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

There is a problem with SERVICE_REGISTRY_PROTOCOL.equals(url.getProtocol()), you are right.

@@ -216,7 +219,7 @@ public void exported() {
exportedURLs.forEach(url -> {
// dubbo2.7.x does not register serviceNameMapping information with the registry by default.
// Only when the user manually turns on the service introspection, can he register with the registration center.
boolean isServiceDiscovery = SERVICE_REGISTRY_PROTOCOL.equals(url.getProtocol());
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a problem with SERVICE_REGISTRY_PROTOCOL.equals(url.getProtocol()), you are right.

Copy link
Contributor

@xiaoheng1 xiaoheng1 left a comment

Choose a reason for hiding this comment

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

if (SERVICE_REGISTRY_PROTOCOL.equals(registryURL.getProtocol())) {
url = url.addParameterIfAbsent(REGISTRY_TYPE_KEY, SERVICE_REGISTRY_TYPE);
}

Why do we need this paragraph of judgment? In the org.apache.dubbo.config.utils.ConfigValidationUtils#loadRegistries method, it has been converted to registryProtcol based on the registry-type parameter.

@horizonzy
Copy link
Member Author

The url is different.
In method exported.

        List<URL> exportedURLs = this.getExportedUrls();
        exportedURLs.forEach(url -> {
            // dubbo2.7.x does not register serviceNameMapping information with the registry by default.
            // Only when the user manually turns on the service introspection, can he register with the registration center.
            boolean isServiceDiscovery = SERVICE_REGISTRY_PROTOCOL.equals(url.getProtocol());
            if (isServiceDiscovery) {
                Map<String, String> parameters = getApplication().getParameters();
                ServiceNameMapping.getExtension(parameters != null ? parameters.get(MAPPING_KEY) : null).map(url);
            }
        });

getExportedUrls return the url which didn't hold registry param.

see:

Map<String, String> map = new HashMap<String, String>();

@xiaoheng1
Copy link
Contributor

The url is different.
In method exported.

        List<URL> exportedURLs = this.getExportedUrls();
        exportedURLs.forEach(url -> {
            // dubbo2.7.x does not register serviceNameMapping information with the registry by default.
            // Only when the user manually turns on the service introspection, can he register with the registration center.
            boolean isServiceDiscovery = SERVICE_REGISTRY_PROTOCOL.equals(url.getProtocol());
            if (isServiceDiscovery) {
                Map<String, String> parameters = getApplication().getParameters();
                ServiceNameMapping.getExtension(parameters != null ? parameters.get(MAPPING_KEY) : null).map(url);
            }
        });

getExportedUrls return the url which didn't hold registry param.

see:

Map<String, String> map = new HashMap<String, String>();

i get it. you are right.

Copy link
Contributor

@xiaoheng1 xiaoheng1 left a comment

Choose a reason for hiding this comment

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

LGTM

@AlbumenJ AlbumenJ merged commit 9633f6b into apache:master May 13, 2021
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