-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Update Eureka Server's service-urls upon EnvironmentChangeEvent. #2455
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2455 +/- ##
=========================================
+ Coverage 65.65% 68.3% +2.64%
=========================================
Files 207 236 +29
Lines 7644 8324 +680
Branches 943 1039 +96
=========================================
+ Hits 5019 5686 +667
+ Misses 2267 2248 -19
- Partials 358 390 +32
Continue to review full report at Codecov.
|
ac7da13
to
e6e4e48
Compare
I would only update if specific keys are changed |
Thanks @ryanjbaxter @spencergibb. Yeah, that makes sense and hope change to either |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, we look forward to that update.
1b7b81a
to
166166f
Compare
@spencergibb @ryanjbaxter Checked-in and rebased. I've avoided |
protected boolean shouldUpdate(final Set<String> changedKeys) { | ||
assert changedKeys != null; | ||
|
||
if (clientConfig.shouldUseDnsForFetchingServiceUrls()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain? Should go as a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is there because if the the property eureka.client.use-dns-for-fetching-service-urls
is set to true, service-urls will not be fetched from environment. I've documented it in the Java doc. Will add as a comment here as well.
} | ||
|
||
for (final String key : changedKeys) { | ||
assert key != null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why throw an exception? Use an if.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used an assert
here only to specify the assumption that property keys cannot be null, hence not doing a null check here before calling key.startsWith()
. Since assertions are disabled in production, hope this should be fine? Kindly let me know.
// considered only documented relaxed keys. | ||
if (key.startsWith("eureka.client.service-url.") || | ||
key.startsWith("eureka.client.serviceUrl.") || | ||
key.startsWith("eureka.client.availability-zones.") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In boot 2.0 use only the - case names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the the current master is still not migrated to boot 2.0? Anyways let me keep only the - case names.
18555fe
to
f3c03c6
Compare
@spencergibb I've addressed the review comments. Please have a look. Will rebase once you reviewed. |
@spencergibb @ryanjbaxter Appreciate if you could review and let me know if anything needs to be addressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
return false; | ||
} | ||
|
||
if (changedKeys.contains("eureka.client.region")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small nit here, this if
could be combined in the for
loop below. Small optimization more than anything else.
f3c03c6
to
e2dcf30
Compare
@ryanjbaxter I've rebased it. Kindly let me know if anything is pending from my-side to proceed with merging. |
@fahimfarookme thanks. The only outstanding thing from my side was my comment #2455 (comment). I think this might make sense to do |
Thanks @ryanjbaxter for the review. I did a quick micro-benchmark with JMH since it looks like the submitted PR could perform better than the suggestion. In the benchmark results below:
Here's the JMH results. 1. Throughput (higher the better)
2. Average time (lower the better)
Based on the results above the submitted PR is already the optimized version. Your thoughts please... |
Fixes gh-2421