-
Notifications
You must be signed in to change notification settings - Fork 86
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
Re-use RestClient across DataStores ... only need 1 per host:port:user #113
base: master
Are you sure you want to change the base?
Conversation
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.
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)) |
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 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); |
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 this block can be unindented
@@ -136,6 +137,15 @@ | |||
GRID_THRESHOLD | |||
}; | |||
|
|||
/** | |||
* The ES RestClient instances created by this factory. We don't want to create |
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 unindent these comment lines by two spaces for consistency with other formatting elsewhere
final String adminUser = getValue(USER, params); | ||
final boolean sslRejectUnauthorized = getValue(SSL_REJECT_UNAUTHORIZED, params); |
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.
Does changing these to primitives make them required parameters?
@@ -192,6 +192,47 @@ public void testBuildClientWithMultipleHosts() throws IOException { | |||
assertNotNull(credentialsProviderCaptor.getValue().getCredentials(new AuthScope("localhost2", 9201))); | |||
} | |||
|
|||
@Test | |||
public void testGetRestClientSameClientKey() throws IOException { | |||
/* multiple calls with same host:port:user should call builder once */ |
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.
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)); |
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.
Is this missing a format string for key
?
OK, starting with smaller simpler updates and I'll see how the Travis CI goes.