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

优化网卡地址优先级 #1986

Merged
merged 5 commits into from
Feb 23, 2019
Merged

优化网卡地址优先级 #1986

merged 5 commits into from
Feb 23, 2019

Conversation

Accelerator96
Copy link
Contributor

index低的网卡地址优先级高

index低的网卡地址优先级高
@JaredTan95
Copy link
Member

fix #1874.

@codecov-io
Copy link

codecov-io commented Feb 20, 2019

Codecov Report

Merging #1986 into master will decrease coverage by 7.35%.
The diff coverage is 75%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1986      +/-   ##
============================================
- Coverage     57.54%   50.18%   -7.36%     
- Complexity     1120     1978     +858     
============================================
  Files           193      400     +207     
  Lines          5940    12349    +6409     
  Branches        636     1275     +639     
============================================
+ Hits           3418     6197    +2779     
- Misses         2259     5693    +3434     
- Partials        263      459     +196
Impacted Files Coverage Δ Complexity Δ
.../foundation/internals/NetworkInterfaceManager.java 60.65% <75%> (+2.03%) 11 <0> (ø) ⬇️
.../apollo/internals/RemoteConfigLongPollService.java 79.75% <0%> (-0.62%) 27% <0%> (-1%)
...ework/apollo/portal/controller/ItemController.java 6.32% <0%> (ø) 1% <0%> (?)
...o/configservice/wrapper/DeferredResultWrapper.java 100% <0%> (ø) 12% <0%> (?)
...omponent/emailbuilder/GrayPublishEmailBuilder.java 11.53% <0%> (ø) 1% <0%> (?)
...k/apollo/portal/controller/FavoriteController.java 33.33% <0%> (ø) 1% <0%> (?)
...apollo/portal/entity/vo/AppRolesAssignedUsers.java 0% <0%> (ø) 0% <0%> (?)
...ponent/emailbuilder/NormalPublishEmailBuilder.java 20% <0%> (ø) 1% <0%> (?)
.../framework/apollo/portal/entity/vo/SystemInfo.java 0% <0%> (ø) 0% <0%> (?)
...rk/apollo/portal/service/NamespaceLockService.java 36.36% <0%> (ø) 1% <0%> (?)
... and 199 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 f7ed4f7...79baacd. Read the comment docs.

List<NetworkInterface> nis = interfaces == null ? Collections.<NetworkInterface>emptyList()
: Collections.list(interfaces);
//sort the network interfaces according to the index asc
Collections.sort(nis, new Comparator<NetworkInterface>() {
Copy link
Member

Choose a reason for hiding this comment

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

can be replaced with list.sort?

Copy link
Member

Choose a reason for hiding this comment

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

can be replaced with lambda?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

of course! but apollo-core is <java.version>1.7</java.version> in pom.xml.
Consider compatibility,i don't use lambda.

Copy link
Member

Choose a reason for hiding this comment

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

Got it

if (nis1.getIndex() > nis2.getIndex()) {
return 1;
} else {
return -1;
Copy link
Member

Choose a reason for hiding this comment

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

do we need a case to return 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Return 0 is invalid。

this is results on my computer。
return 0:
name:utun0 (utun0)------index = 18
name:awdl0 (awdl0)------index = 12
name:en5 (en5)------index = 8
name:en0 (en0)------index = 10
name:lo0 (lo0)------index = 1

return -1:
name:lo0 (lo0)------index = 1
name:en5 (en5)------index = 8
name:en0 (en0)------index = 10
name:awdl0 (awdl0)------index = 12
name:utun0 (utun0)------index = 18

I don't know why return 0 sorting does not take effect.....

Copy link
Member

Choose a reason for hiding this comment

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

normally we would return 3 values for a comparison between variable a and b

  1. 1 means a > b
  2. 0 means a = b
  3. -1 means a < b

I'm not saying we should change the statement return -1 to return 0, what I mean by do we need a case to return 0? is I'm not sure if there is a case that nis1.getIndex() == nis2.getIndex()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know.Maybe this can be replaced by "Integer.compare(nis1.getIndex(), nis2.getIndex())"

@coveralls
Copy link

coveralls commented Feb 23, 2019

Coverage Status

Coverage increased (+0.01%) to 53.956% when pulling 380deec on Accelerater:master into d762823 on ctripcorp:master.

Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

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

LGTM

@nobodyiam nobodyiam merged commit c5eb325 into apolloconfig:master Feb 23, 2019
CrackerCat pushed a commit to CrackerCat/apollo-1 that referenced this pull request Jul 31, 2024
优化网卡地址优先级,index低的网卡地址优先级高
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.

6 participants