diff --git a/metadata-service/factories/src/main/java/com/linkedin/gms/factory/common/RestHighLevelClientFactory.java b/metadata-service/factories/src/main/java/com/linkedin/gms/factory/common/RestHighLevelClientFactory.java index 31b0c9c4ab..409702a1f6 100644 --- a/metadata-service/factories/src/main/java/com/linkedin/gms/factory/common/RestHighLevelClientFactory.java +++ b/metadata-service/factories/src/main/java/com/linkedin/gms/factory/common/RestHighLevelClientFactory.java @@ -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,