Skip to content

add a switch to control whether to prefer to register public address or site local address - #3834

Closed
lexburner wants to merge 1 commit into
apache:masterfrom
lexburner:improve/#3802
Closed

lexburner wants to merge 1 commit into
apache:masterfrom
lexburner:improve/#3802

Conversation

@lexburner

Copy link
Copy Markdown
Contributor

What is the purpose of the change

fix the issue: #3802
improve the existing changes: #3520

Brief changelog

  • add a switch dubbo.prefer.public.address.
  • change the strategy to achieve IP address.

steps to achieve IP:

  1. judge the switch dubbo.prefer.public.address
  2. search from hosts mapping using InetAddress.getLocalHost()
  3. search from the network cards using NetworkInterface.getNetworkInterfaces()
  4. if the address achieved in 2 & 3 not match the dubbo.prefer.public.address, downgrade to the reverse property of dubbo.prefer.public.address. In words, if no public address found, downgrade to site-local address; if no site-local address found, downgrade to public address;
  5. if no address found, using loopback address 127.0.0.1.

@lexburner
lexburner requested a review from beiwei30 April 9, 2019 09:22
@ralf0131

Copy link
Copy Markdown
Contributor

Hi, sorry but could you resolve the conflicts first?

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #3834 into master will decrease coverage by 0.11%.
The diff coverage is 35.89%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3834      +/-   ##
============================================
- Coverage     63.66%   63.55%   -0.12%     
  Complexity       71       71              
============================================
  Files           712      708       -4     
  Lines         31450    31227     -223     
  Branches       5073     5060      -13     
============================================
- Hits          20023    19846     -177     
+ Misses         9134     9089      -45     
+ Partials       2293     2292       -1
Impacted Files Coverage Δ Complexity Δ
...c/main/java/org/apache/dubbo/common/Constants.java 93.33% <ø> (ø) 0 <0> (ø) ⬇️
...ava/org/apache/dubbo/config/ApplicationConfig.java 94.25% <33.33%> (-1.1%) 0 <0> (ø)
...n/java/org/apache/dubbo/common/utils/NetUtils.java 68.26% <36.11%> (-1.54%) 0 <0> (ø)
.../apache/dubbo/remoting/transport/AbstractPeer.java 58.69% <0%> (-13.05%) 0% <0%> (ø)
...e/dubbo/remoting/transport/netty/NettyChannel.java 54.11% <0%> (-8.24%) 0% <0%> (ø)
...in/java/org/apache/dubbo/rpc/support/RpcUtils.java 53.6% <0%> (-3.1%) 0% <0%> (ø)
...he/dubbo/registry/multicast/MulticastRegistry.java 67.87% <0%> (-1.81%) 0% <0%> (ø)
...dubbo/remoting/exchange/support/DefaultFuture.java 71.42% <0%> (-1.37%) 0% <0%> (ø)
...ubbo/config/builders/AbstractReferenceBuilder.java 94.11% <0%> (-1.24%) 0% <0%> (ø)
...e/dubbo/config/builders/AbstractMethodBuilder.java 95.55% <0%> (-0.94%) 0% <0%> (ø)
... and 42 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 4c96814...0f450ca. Read the comment docs.

@lexburner

Copy link
Copy Markdown
Contributor Author

@beiwei30 Conflicts are resolved, the logic rollbacks to reversion and adds the switch to control the public IP prefer.

@lexburner

Copy link
Copy Markdown
Contributor Author

I notice that the file style of NetUtils changes from CRLF to LF. This causes a miss-comparison between new and reversions. Which one of CRLF and LF prefers in Dubbo? or maybe it does not take any difference.

@beiwei30

Copy link
Copy Markdown
Member

I notice that the file style of NetUtils changes from CRLF to LF. This causes a miss-comparison between new and reversions. Which one of CRLF and LF prefers in Dubbo? or maybe it does not take any difference.

make sure you set autocrlf = false in your gitconfig to avoid it.

@beiwei30 beiwei30 closed this Apr 26, 2019
@lexburner
lexburner deleted the improve/#3802 branch April 29, 2019 09:39
@initpassion

Copy link
Copy Markdown

最新的代码中并没有找到对应的开关和源码信息, 请问下高版本有保留该代码吗, 我使用的是2.7.15

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.

5 participants