Skip to content

Commit

Permalink
Optional ccs (#383)
Browse files Browse the repository at this point in the history
* add optional property opensearch.CCSEnabled

* add CCSEnabled as an example

---------

Co-authored-by: thomas loubrieu <thomas.loubrieu@jpl.nasa.gov>
  • Loading branch information
tloubrieu-jpl and thomas loubrieu committed Oct 26, 2023
1 parent f2b715b commit 5366e06
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,22 @@ public class OpenSearchConfig {

@Value("${openSearch.timeOutSeconds:60}")
private int timeOutSeconds;

public int getTimeOutSeconds() {
return timeOutSeconds;
}

public void setTimeOutSeconds(int timeOutSeconds) {
this.timeOutSeconds = timeOutSeconds;
}


@Value("${openSearch.CCSEnabled:true}")
private boolean CCSEnabled;

public boolean getCCSEnabled() {
return CCSEnabled;
}

@Value("${openSearch.username:}")
private String username;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class OpenSearchRegistryConnectionImpl implements ConnectionContext {
public static String CLUSTER_REMOTE_KEY = "cluster.remote";

private static final Logger log = LoggerFactory.getLogger(OpenSearchRegistryConnectionImpl.class);

private RestHighLevelClient restHighLevelClient;
private String registryIndex;
private String registryRefIndex;
Expand Down Expand Up @@ -106,8 +106,15 @@ public HttpAsyncClientBuilder customizeHttpClient(

this.restHighLevelClient = new RestHighLevelClient(clientBuilder);

this.crossClusterNodes = checkCCSConfig();
this.registryIndex = createCCSIndexString(connectionBuilder.getRegistryIndex());
String registryIndex = connectionBuilder.getRegistryIndex();
if (connectionBuilder.getCCSEnabled()) {
this.crossClusterNodes = checkCCSConfig();
this.registryIndex = createCCSIndexString(registryIndex);
}
else {
this.registryIndex = registryIndex;
}

this.registryRefIndex = createCCSIndexString(connectionBuilder.getRegistryRefIndex());
this.timeOutSeconds = connectionBuilder.getTimeOutSeconds();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public int getTimeOutSeconds() {
return timeOutSeconds;
}


public boolean getCCSEnabled() {
return CCSEnabled;
}

public boolean isSsl() {
return ssl;
}
Expand All @@ -66,6 +71,7 @@ public boolean isSslCertificateCNVerification() {
private final String registryIndex;
private final String registryRefIndex;
private final int timeOutSeconds;
private final boolean CCSEnabled;
private final boolean ssl;
private final boolean sslCertificateCNVerification;

Expand All @@ -78,6 +84,7 @@ public OpenSearchRegistryConnectionImplBuilder() {
this.registryIndex = "registry";
this.registryRefIndex = "registry-refs";
this.timeOutSeconds = 5;
this.CCSEnabled = true;
this.username = null;
this.password = null;
this.ssl = false;
Expand All @@ -91,6 +98,7 @@ public OpenSearchRegistryConnectionImplBuilder(OpenSearchConfig openSearchConfig
this.registryIndex = openSearchConfig.getRegistryIndex();
this.registryRefIndex = openSearchConfig.getRegistryRefIndex();
this.timeOutSeconds = openSearchConfig.getTimeOutSeconds();
this.CCSEnabled = openSearchConfig.getCCSEnabled();
this.ssl = openSearchConfig.isSsl();
this.sslCertificateCNVerification = openSearchConfig.doesSslCertificateVCNerification();
this.username = openSearchConfig.getUsername();
Expand Down
1 change: 1 addition & 0 deletions service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ openSearch.host=localhost:9200
openSearch.registryIndex=registry
openSearch.registryRefIndex=registry-refs
openSearch.timeOutSeconds=60
openSearch.CCSEnabled=true
openSearch.username=admin
openSearch.password=admin
openSearch.ssl=true
Expand Down

0 comments on commit 5366e06

Please sign in to comment.