Skip to content

Commit

Permalink
[SYNCOPE-1773] Changing ES conf properties to allow for multiple nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Aug 14, 2023
1 parent defa345 commit 7556e88
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,27 @@
*/
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;

private String numberOfShards = "1";

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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ under the License.

<disruptor.version>3.4.4</disruptor.version>

<elasticsearch.version>8.8.2</elasticsearch.version>
<elasticsearch.version>8.9.0</elasticsearch.version>

<commons-jexl.version>3.3</commons-jexl.version>
<commons-text.version>1.10.0</commons-text.version>
Expand Down
4 changes: 1 addition & 3 deletions src/main/asciidoc/reference-guide/usage/customization.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7556e88

Please sign in to comment.