You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2023/08/14 08:44:38 UTC
[syncope] branch 3_0_X updated: [SYNCOPE-1773] Changing ES conf properties to allow for multiple nodes
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch 3_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/3_0_X by this push:
new 5274258f5f [SYNCOPE-1773] Changing ES conf properties to allow for multiple nodes
5274258f5f is described below
commit 5274258f5f0f096cbbdf0b6ea76863adf40a67e3
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Mon Aug 14 10:44:15 2023 +0200
[SYNCOPE-1773] Changing ES conf properties to allow for multiple nodes
---
.../client/ElasticsearchClientContext.java | 6 ++--
.../client/ElasticsearchProperties.java | 33 +++++-----------------
.../main/resources/core-elasticsearch.properties | 4 +--
pom.xml | 2 +-
.../reference-guide/usage/customization.adoc | 4 +--
5 files changed, 14 insertions(+), 35 deletions(-)
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<String> 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<String> getHosts() {
+ return hosts;
}
- public void setScheme(final String scheme) {
- this.scheme = scheme;
+ public void setHosts(final List<String> 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 48f1c4ef15..df6139913b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -428,7 +428,7 @@ under the License.
<slf4j.version>1.7.36</slf4j.version>
- <elasticsearch.version>8.8.2</elasticsearch.version>
+ <elasticsearch.version>8.9.0</elasticsearch.version>
<log4j2.version>2.20.0</log4j2.version>
<disruptor.version>3.4.4</disruptor.version>
diff --git a/src/main/asciidoc/reference-guide/usage/customization.adoc b/src/main/asciidoc/reference-guide/usage/customization.adoc
index dfbdcc74ad..f314ed5d3a 100644
--- a/src/main/asciidoc/reference-guide/usage/customization.adoc
+++ b/src/main/asciidoc/reference-guide/usage/customization.adoc
@@ -386,9 +386,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