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

[Dubbo-6034] Fix the RegistyUrl mismatching to ZoneAwareClusterInvoker.PREFER_REGISTRY_KEY #7788

Merged
merged 3 commits into from
May 22, 2021
Merged

[Dubbo-6034] Fix the RegistyUrl mismatching to ZoneAwareClusterInvoker.PREFER_REGISTRY_KEY #7788

merged 3 commits into from
May 22, 2021

Conversation

plusmancn
Copy link
Contributor

@plusmancn plusmancn commented May 18, 2021

What is the purpose of the change

Fixes #6034

When I have follow setting, the final registry URL is: nacos://127.0.0.1:8849/....?preferred=true.

<dubbo:registry address="nacos://127.0.0.1:8849" preferred="true"/>

Because of ZoneAwareClusterInvoker.PREFER_REGISTRY_KEY is mismatching to RegistryConfig.preferred key, the following code can't works as expect.

// method => org.apache.dubbo.rpc.cluster.support.registry.ZoneAwareClusterInvoker#doInvoke
if (clusterInvoker.isAvailable() && clusterInvoker.getRegistryUrl()
        .getParameter(PREFER_REGISTRY_KEY, false)) {
    return clusterInvoker.invoke(invocation);
}

Brief changelog

  • Aliasing preferred equal to ZoneAwareClusterInvoker.PREFER_REGISTRY_KEY when invoking AbstractConfig#appendParameters method.

Verifying this change

  • The final registry URL should be: nacos://127.0.0.1:8849/....?registry.preferred=true.

  • Make sure there is a GitHub_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Run mvn clean install -DskipTests=false & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

@codecov-commenter
Copy link

codecov-commenter commented May 18, 2021

Codecov Report

Merging #7788 (c05c14e) into master (1a7ca1e) will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #7788      +/-   ##
============================================
- Coverage     59.47%   59.42%   -0.05%     
  Complexity      556      556              
============================================
  Files          1083     1086       +3     
  Lines         43755    43800      +45     
  Branches       6380     6391      +11     
============================================
+ Hits          26022    26029       +7     
- Misses        14876    14899      +23     
- Partials       2857     2872      +15     
Impacted Files Coverage Δ Complexity Δ
...ster/support/registry/ZoneAwareClusterInvoker.java 0.00% <ø> (ø) 0.00 <0.00> (ø)
...n/java/org/apache/dubbo/config/RegistryConfig.java 86.17% <ø> (ø) 0.00 <0.00> (ø)
...in/java/org/apache/dubbo/common/utils/JVMUtil.java 81.13% <0.00%> (-11.33%) 0.00% <0.00%> (ø%)
...va/org/apache/dubbo/rpc/support/ProtocolUtils.java 61.53% <0.00%> (-8.03%) 0.00% <0.00%> (ø%)
...ng/transport/dispatcher/all/AllChannelHandler.java 82.75% <0.00%> (-6.90%) 0.00% <0.00%> (ø%)
.../rpc/protocol/dubbo/LazyConnectExchangeClient.java 49.45% <0.00%> (-4.40%) 0.00% <0.00%> (ø%)
...ava/org/apache/dubbo/rpc/filter/GenericFilter.java 37.70% <0.00%> (-3.37%) 0.00% <0.00%> (ø%)
...c/main/java/org/apache/dubbo/rpc/RpcException.java 80.00% <0.00%> (-3.34%) 0.00% <0.00%> (ø%)
.../dubbo/remoting/transport/netty4/NettyChannel.java 61.38% <0.00%> (-1.99%) 0.00% <0.00%> (ø%)
...he/dubbo/registry/multicast/MulticastRegistry.java 68.37% <0.00%> (-0.94%) 0.00% <0.00%> (ø%)
... and 16 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 1a7ca1e...c05c14e. Read the comment docs.

@AlbumenJ
Copy link
Member

Would you please add some unit test cases for this PR?

@plusmancn plusmancn requested a review from AlbumenJ May 19, 2021 15:47
@plusmancn
Copy link
Contributor Author

Would you please add some unit test cases for this PR?

I have finished the unit test for this PR, please have a look at it.

@AlbumenJ AlbumenJ merged commit 7209ac3 into apache:master May 22, 2021
AlbumenJ added a commit to AlbumenJ/dubbo that referenced this pull request May 28, 2021
@plusmancn plusmancn deleted the fix_registry_prefer branch August 20, 2021 15:31
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.

dubbo2.7.6使用xml配置多注册中心后,preferred="true"无效
3 participants