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 4efb716 commit 5274258
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 @@ -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>
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 @@ -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
Expand Down

0 comments on commit 5274258

Please sign in to comment.