mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-26 09:35:23 +00:00
fix: ES Rest Client Creation for non ssl authenticated connection (#5056)
* Bug fix for RestClientCreation Fixed bug stated in https://github.com/datahub-project/datahub/issues/5046 * Called overridden method to avoid code redundancy changed as per comments * Added type for builder Co-authored-by: Nirmit Jain <nirmit.jain@navi.com>
This commit is contained in:
parent
3885494f90
commit
ce3ddc9afe
@ -66,6 +66,8 @@ public class RestHighLevelClientFactory {
|
||||
if (useSSL) {
|
||||
restClientBuilder = loadRestHttpsClient(host, port, pathPrefix, threadCount, connectionRequestTimeout, sslContext, username,
|
||||
password);
|
||||
} else if (username != null && password != null) {
|
||||
restClientBuilder = loadRestHttpClient(host, port, pathPrefix, threadCount, connectionRequestTimeout, username, password);
|
||||
} else {
|
||||
restClientBuilder = loadRestHttpClient(host, port, pathPrefix, threadCount, connectionRequestTimeout);
|
||||
}
|
||||
@ -89,6 +91,26 @@ public class RestHighLevelClientFactory {
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static RestClientBuilder loadRestHttpClient(@Nonnull String host, int port, String pathPrefix, int threadCount,
|
||||
int connectionRequestTimeout, String username, String password) {
|
||||
RestClientBuilder builder = loadRestHttpClient(host, port, pathPrefix, threadCount, connectionRequestTimeout);
|
||||
|
||||
builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
|
||||
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpAsyncClientBuilder) {
|
||||
httpAsyncClientBuilder.setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(threadCount).build());
|
||||
|
||||
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
|
||||
httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
|
||||
|
||||
return httpAsyncClientBuilder;
|
||||
}
|
||||
});
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static RestClientBuilder loadRestHttpsClient(@Nonnull String host, int port, String pathPrefix, int threadCount,
|
||||
|
Loading…
x
Reference in New Issue
Block a user