Re-use RestClient across DataStores ... only need 1 per host:port:user#113
Open
halfstein wants to merge 3 commits into
Open
Re-use RestClient across DataStores ... only need 1 per host:port:user#113halfstein wants to merge 3 commits into
halfstein wants to merge 3 commits into
Conversation
sjudeng
reviewed
Mar 22, 2020
Contributor
sjudeng
left a comment
There was a problem hiding this comment.
Thanks for the updates. Couple minor comments and question.
| final String clientKey = String.format("%s @ %s:%d", user, hostName, defaultPort); | ||
|
|
||
| /* if we already have the client ... just return it so we don't needlessly create the builder */ | ||
| if(clients.containsKey(clientKey)) |
Contributor
There was a problem hiding this comment.
Can you include {} for consistency? Also include space after if for consistency.
| return clients.get(clientKey); | ||
|
|
||
| /* creating the builder can throw IOException so we can't do it in the following functional call */ | ||
| RestClientBuilder rcb = createClientBuilder(user, password, type, hostName.split(","), defaultPort, sslRejectUnauthorized); |
Contributor
There was a problem hiding this comment.
Looks like this block can be unindented
| }; | ||
|
|
||
| /** | ||
| * The ES RestClient instances created by this factory. We don't want to create |
Contributor
There was a problem hiding this comment.
Can unindent these comment lines by two spaces for consistency with other formatting elsewhere
| final Boolean sslRejectUnauthorized = getValue(SSL_REJECT_UNAUTHORIZED, params); | ||
| final int defaultPort = getValue(HOSTPORT, params); | ||
| final String adminUser = getValue(USER, params); | ||
| final boolean sslRejectUnauthorized = getValue(SSL_REJECT_UNAUTHORIZED, params); |
Contributor
There was a problem hiding this comment.
Does changing these to primitives make them required parameters?
|
|
||
| @Test | ||
| public void testGetRestClientSameClientKey() throws IOException { | ||
| /* multiple calls with same host:port:user should call builder once */ |
Contributor
There was a problem hiding this comment.
Indentation here and below
|
|
||
| /* note: ConcurrentHashMap performs this atomically ... only once per key */ | ||
| return this.clients.computeIfAbsent(clientKey, (key) -> { | ||
| LOGGER.info(String.format("Building a %s RestClient for", type, key)); |
Contributor
There was a problem hiding this comment.
Is this missing a format string for key?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OK, starting with smaller simpler updates and I'll see how the Travis CI goes.