Skip to content
Snippets Groups Projects
Commit b347bb54 authored by Dania Kodeih (Microsoft)'s avatar Dania Kodeih (Microsoft)
Browse files

Merge branch 'hepola/search-http' into 'master'

added possibility to have elastic connectivity over HTTP through config.

See merge request !15
parents b703244c 7b32a93d
No related branches found
No related tags found
1 merge request!15added possibility to have elastic connectivity over HTTP through config.
Pipeline #5097 passed
...@@ -182,6 +182,7 @@ The following software have components provided under the terms of this license: ...@@ -182,6 +182,7 @@ The following software have components provided under the terms of this license:
- Apache Log4j API (from ) - Apache Log4j API (from )
- Apache Log4j Core (from ) - Apache Log4j Core (from )
- Apache Log4j JUL Adapter (from ) - Apache Log4j JUL Adapter (from )
- Apache Log4j SLF4J Binding (from )
- Apache Log4j to SLF4J Adapter (from ) - Apache Log4j to SLF4J Adapter (from )
- Apache Maven Invoker (from ) - Apache Maven Invoker (from )
- Apache Maven Reporting Implementation (from ) - Apache Maven Reporting Implementation (from )
...@@ -857,8 +858,8 @@ The following software have components provided under the terms of this license: ...@@ -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 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 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) - 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://mockito.org)
- Mockito (from http://www.mockito.org)
- Mockito (from http://mockito.org) - Mockito (from http://mockito.org)
- Mockito (from http://mockito.org) - Mockito (from http://mockito.org)
- Netty/Codec/HTTP (from ) - Netty/Codec/HTTP (from )
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
<dependency> <dependency>
<groupId>org.opengroup.osdu</groupId> <groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId> <artifactId>core-lib-azure</artifactId>
<version>0.0.9</version> <version>0.0.12</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -5,7 +5,8 @@ public class Config { ...@@ -5,7 +5,8 @@ public class Config {
private static final String DEFAULT_ELASTIC_HOST = ""; private static final String DEFAULT_ELASTIC_HOST = "";
private static final String DEFAULT_ELASTIC_USER_NAME = ""; private static final String DEFAULT_ELASTIC_USER_NAME = "";
private static final String DEFAULT_ELASTIC_PASSWORD = ""; 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_INDEXER_HOST = "";
private static final String DEFAULT_SEARCH_HOST = ""; private static final String DEFAULT_SEARCH_HOST = "";
...@@ -62,6 +63,10 @@ public class Config { ...@@ -62,6 +63,10 @@ public class Config {
return getEnvironmentVariableOrDefaultValue("ELASTIC_HOST", DEFAULT_ELASTIC_HOST); 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() { public static String getIndexerBaseURL() {
return getEnvironmentVariableOrDefaultValue("INDEXER_HOST", DEFAULT_INDEXER_HOST); return getEnvironmentVariableOrDefaultValue("INDEXER_HOST", DEFAULT_INDEXER_HOST);
} }
......
...@@ -55,11 +55,13 @@ public class ElasticUtils { ...@@ -55,11 +55,13 @@ public class ElasticUtils {
private final String username; private final String username;
private final String password; private final String password;
private final String host; private final String host;
private final boolean sslEnabled;
public ElasticUtils() { public ElasticUtils() {
this.username = Config.getUserName(); this.username = Config.getUserName();
this.password = Config.getPassword(); this.password = Config.getPassword();
this.host = Config.getElasticHost(); this.host = Config.getElasticHost();
this.sslEnabled = Config.isElasticSslEnabled();
} }
public void createIndex(String index, String mapping) { public void createIndex(String index, String mapping) {
...@@ -275,7 +277,8 @@ public class ElasticUtils { ...@@ -275,7 +277,8 @@ public class ElasticUtils {
} }
public RestClientBuilder createClientBuilder(String host, String usernameAndPassword, int port) { 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) builder.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(REST_CLIENT_CONNECT_TIMEOUT)
.setSocketTimeout(REST_CLIENT_SOCKET_TIMEOUT)); .setSocketTimeout(REST_CLIENT_SOCKET_TIMEOUT));
builder.setMaxRetryTimeoutMillis(REST_CLIENT_RETRY_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