diff --git a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchClientContext.java b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchClientContext.java index 499922b80b..f46b62ff9f 100644 --- a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchClientContext.java +++ b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchClientContext.java @@ -19,11 +19,12 @@ package org.apache.syncope.ext.elasticsearch.client; import co.elastic.clients.elasticsearch.ElasticsearchClient; -import java.util.List; +import java.util.stream.Collectors; import org.apache.http.HttpHost; import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO; import org.apache.syncope.core.persistence.api.dao.GroupDAO; import org.apache.syncope.core.persistence.api.dao.UserDAO; +import org.identityconnectors.common.CollectionUtil; import org.springframework.boot.actuate.health.HealthContributor; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -39,7 +40,8 @@ public class ElasticsearchClientContext { @Bean public ElasticsearchClientFactoryBean elasticsearchClientFactoryBean(final ElasticsearchProperties props) { return new ElasticsearchClientFactoryBean( - List.of(new HttpHost(props.getHostname(), props.getPort(), props.getScheme()))); + CollectionUtil.nullAsEmpty(props.getHosts()).stream(). + map(HttpHost::create).collect(Collectors.toList())); } @ConditionalOnMissingBean diff --git a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchProperties.java b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchProperties.java index 4a86dca700..793da71bd0 100644 --- a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchProperties.java +++ b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchProperties.java @@ -18,17 +18,14 @@ */ package org.apache.syncope.ext.elasticsearch.client; -import org.apache.http.HttpHost; +import java.util.ArrayList; +import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties("elasticsearch") public class ElasticsearchProperties { - private String hostname = "localhost"; - - private int port = 9200; - - private String scheme = HttpHost.DEFAULT_SCHEME_NAME; + private List hosts = new ArrayList<>(); private int indexMaxResultWindow = 10000; @@ -36,28 +33,12 @@ public class ElasticsearchProperties { private String numberOfReplicas = "1"; - public String getHostname() { - return hostname; - } - - public void setHostname(final String hostname) { - this.hostname = hostname; - } - - public int getPort() { - return port; - } - - public void setPort(final int port) { - this.port = port; - } - - public String getScheme() { - return scheme; + public List getHosts() { + return hosts; } - public void setScheme(final String scheme) { - this.scheme = scheme; + public void setHosts(final List hosts) { + this.hosts = hosts; } public int getIndexMaxResultWindow() { diff --git a/fit/core-reference/src/main/resources/core-elasticsearch.properties b/fit/core-reference/src/main/resources/core-elasticsearch.properties index d426e44d97..02961d9d60 100644 --- a/fit/core-reference/src/main/resources/core-elasticsearch.properties +++ b/fit/core-reference/src/main/resources/core-elasticsearch.properties @@ -15,9 +15,7 @@ # specific language governing permissions and limitations # under the License. -elasticsearch.hostname=localhost -elasticsearch.port=9200 -elasticsearch.scheme=http +elasticsearch.hosts[0]=http://localhost:9200 elasticsearch.indexMaxResultWindow=10000 elasticsearch.numberOfShards=1 elasticsearch.numberOfReplicas=1 diff --git a/pom.xml b/pom.xml index 86a5a66a2f..e3720f59fb 100644 --- a/pom.xml +++ b/pom.xml @@ -425,7 +425,7 @@ under the License. 3.4.4 - 8.8.2 + 8.9.0 3.3 1.10.0 diff --git a/src/main/asciidoc/reference-guide/usage/customization.adoc b/src/main/asciidoc/reference-guide/usage/customization.adoc index 2dfea4b686..c7d64feb14 100644 --- a/src/main/asciidoc/reference-guide/usage/customization.adoc +++ b/src/main/asciidoc/reference-guide/usage/customization.adoc @@ -385,9 +385,7 @@ Create [source] .... -elasticsearch.hostname=localhost -elasticsearch.port=9200 -elasticsearch.scheme=http +elasticsearch.hosts[0]=http://localhost:9200 elasticsearch.indexMaxResultWindow=10000 elasticsearch.numberOfShards=1 elasticsearch.numberOfReplicas=1