Skip to content
Snippets Groups Projects
Commit 7b32a93d authored by Hema Vishnu Pola [Microsoft]'s avatar Hema Vishnu Pola [Microsoft] Committed by Dania Kodeih (Microsoft)
Browse files

added possibility to have elastic connectivity over HTTP through config.

parent b703244c
No related branches found
No related tags found
No related merge requests found
......@@ -182,6 +182,7 @@ The following software have components provided under the terms of this license:
- Apache Log4j API (from )
- Apache Log4j Core (from )
- Apache Log4j JUL Adapter (from )
- Apache Log4j SLF4J Binding (from )
- Apache Log4j to SLF4J Adapter (from )
- Apache Maven Invoker (from )
- Apache Maven Reporting Implementation (from )
......@@ -857,8 +858,8 @@ The following software have components provided under the terms of this license:
- Microsoft Azure client library for Identity (from https://github.com/Azure/azure-sdk-for-java)
- Microsoft Azure client library for KeyVault Secrets (from https://github.com/Azure/azure-sdk-for-java)
- Microsoft Azure common module for Storage (from https://github.com/Azure/azure-sdk-for-java)
- Mockito (from http://www.mockito.org)
- Mockito (from http://mockito.org)
- Mockito (from http://www.mockito.org)
- Mockito (from http://mockito.org)
- Mockito (from http://mockito.org)
- Netty/Codec/HTTP (from )
......
......@@ -98,7 +98,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<version>0.0.9</version>
<version>0.0.12</version>
</dependency>
<dependency>
......
......@@ -5,7 +5,8 @@ public class Config {
private static final String DEFAULT_ELASTIC_HOST = "";
private static final String DEFAULT_ELASTIC_USER_NAME = "";
private static final String DEFAULT_ELASTIC_PASSWORD = "";
static final int PORT = 9243;
private static final int PORT = 9243;
private static final String DEFAULT_ELASTIC_SSL_ENABLED = "true";
private static final String DEFAULT_INDEXER_HOST = "";
private static final String DEFAULT_SEARCH_HOST = "";
......@@ -62,6 +63,10 @@ public class Config {
return getEnvironmentVariableOrDefaultValue("ELASTIC_HOST", DEFAULT_ELASTIC_HOST);
}
public static boolean isElasticSslEnabled() {
return Boolean.parseBoolean(getEnvironmentVariableOrDefaultValue("ELASTIC_SSL_ENABLED", DEFAULT_ELASTIC_SSL_ENABLED));
}
public static String getIndexerBaseURL() {
return getEnvironmentVariableOrDefaultValue("INDEXER_HOST", DEFAULT_INDEXER_HOST);
}
......
......@@ -55,11 +55,13 @@ public class ElasticUtils {
private final String username;
private final String password;
private final String host;
private final boolean sslEnabled;
public ElasticUtils() {
this.username = Config.getUserName();
this.password = Config.getPassword();
this.host = Config.getElasticHost();
this.sslEnabled = Config.isElasticSslEnabled();
}
public void createIndex(String index, String mapping) {
......@@ -275,7 +277,8 @@ public class ElasticUtils {
}
public RestClientBuilder createClientBuilder(String host, String usernameAndPassword, int port) {
RestClientBuilder builder = RestClient.builder(new HttpHost(host, port, "https"));
String scheme = this.sslEnabled ? "https" : "http";
RestClientBuilder builder = RestClient.builder(new HttpHost(host, port, scheme));
builder.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(REST_CLIENT_CONNECT_TIMEOUT)
.setSocketTimeout(REST_CLIENT_SOCKET_TIMEOUT));
builder.setMaxRetryTimeoutMillis(REST_CLIENT_RETRY_TIMEOUT);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment