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-4793]make RegistryDirectory can refresh the invokers when providers number become 0 when using nacos registry #4802

Merged
merged 3 commits into from
Sep 9, 2019

Conversation

tswstarplanet
Copy link
Contributor

@tswstarplanet tswstarplanet commented Aug 12, 2019

What is the purpose of the change

fix #4793

Brief changelog

NacosRegistry.java

fix issue 4793, add toUrlWithEmpty emthod like ZookeeperRegistry.java, when the provider number become 0, generate an url with empty protocol.

Verifying this change

has been test

Follow this checklist to help us incorporate your contribution quickly and easily:

  • 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-io
Copy link

codecov-io commented Aug 12, 2019

Codecov Report

Merging #4802 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #4802      +/-   ##
===========================================
- Coverage     63.92%   63.9%   -0.02%     
  Complexity      451     451              
===========================================
  Files           769     769              
  Lines         33171   33179       +8     
  Branches       5229    5232       +3     
===========================================
  Hits          21204   21204              
- Misses         9547    9549       +2     
- Partials       2420    2426       +6
Impacted Files Coverage Δ Complexity Δ
...org/apache/dubbo/registry/nacos/NacosRegistry.java 0% <0%> (ø) 0 <0> (ø) ⬇️
.../remoting/transport/netty4/NettyClientHandler.java 61.4% <0%> (-7.02%) 0% <0%> (ø)
.../apache/dubbo/remoting/transport/AbstractPeer.java 58.69% <0%> (-6.53%) 0% <0%> (ø)
...bbo/registry/support/ProviderConsumerRegTable.java 80.48% <0%> (-4.88%) 0% <0%> (ø)
...he/dubbo/remoting/transport/netty/NettyServer.java 69.64% <0%> (-3.58%) 8% <0%> (-1%)
...he/dubbo/registry/multicast/MulticastRegistry.java 67.87% <0%> (-1.81%) 0% <0%> (ø)
.../dubbo/remoting/transport/netty4/NettyChannel.java 64.7% <0%> (-1.18%) 0% <0%> (ø)
...pache/dubbo/remoting/transport/AbstractServer.java 47.91% <0%> (-1.05%) 0% <0%> (ø)
.../rpc/protocol/dubbo/LazyConnectExchangeClient.java 58.82% <0%> (+2.35%) 0% <0%> (ø) ⬇️
...ache/dubbo/rpc/protocol/ProtocolFilterWrapper.java 88.33% <0%> (+3.33%) 0% <0%> (ø) ⬇️
... and 3 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 897709b...e78ec79. Read the comment docs.

Copy link

@Moriadry-zz Moriadry-zz left a comment

Choose a reason for hiding this comment

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

Some nitpicks, we can discuss about it.

URL url = buildURL(instance);
if (UrlUtils.isMatch(consumerURL, url)) {
urls.add(url);
if (instances != null && !instances.isEmpty()) {

Choose a reason for hiding this comment

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

Maybe we don't need to check whether instances is empty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For String or Collection, I think not only null, but also size check are needed because the for each will create useless iterator object.

// Healthy Instances
filterHealthyInstances(healthyInstances);
List<URL> urls = buildURLs(url, healthyInstances);
if (healthyInstances.size() > 0) {

Choose a reason for hiding this comment

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

If healthyInstances is empty, this still works? Not sure, could u pls check it.
I believe we should make our code as clean as possible :)

Copy link
Contributor Author

@tswstarplanet tswstarplanet Aug 19, 2019

Choose a reason for hiding this comment

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

Same as above. I think it's a fail-fast term.

private List<URL> buildURLs(URL consumerURL, Collection<Instance> instances) {
if (instances.isEmpty()) {
return Collections.emptyList();
private List<URL> toUrlWithEmpty(URL consumerURL, Collection<Instance> instances) {
Copy link

@Moriadry-zz Moriadry-zz Aug 17, 2019

Choose a reason for hiding this comment

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

Last nitpick, what about changing toUrlWithEmpty to toUrlsWhenEmpty? (just
one suggestion, there should be another better method name to make it clear)

I know we use toUrlWithEmpty in zookeeperRegistry.class, but I found the name may bring us a little confusion :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The name tells that the protocol will be set "empty"

@cvictory cvictory requested review from mercyblitz and removed request for chickenlj September 4, 2019 06:34
@cvictory cvictory added this to the 2.7.4 milestone Sep 4, 2019
@CLAassistant
Copy link

CLAassistant commented Sep 6, 2019

CLA assistant check
All committers have signed the CLA.

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.

dubbo+nacos服务发现bug(2.7.4.1依然存在)
6 participants