You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2022/05/05 08:45:16 UTC
[GitHub] [jackrabbit-oak] fabriziofortino commented on a diff in pull request #557: OAK-9753: ES connection parameters should be easily accessible from E…
fabriziofortino commented on code in PR #557:
URL: https://github.com/apache/jackrabbit-oak/pull/557#discussion_r865677625
##########
oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticConnectionRule.java:
##########
@@ -83,33 +128,62 @@ public ElasticConnection getElasticConnectionFromString() {
int port = uri.getPort();
String query = uri.getQuery();
- String api_key = null;
- String api_secret = null;
+ String apiKey = null;
+ String apiSecret = null;
if (query != null) {
- api_key = query.split(",")[0].split("=")[1];
- api_secret = query.split(",")[1].split("=")[1];
+ apiKey = query.split(",")[0].split("=")[1];
+ apiSecret = query.split(",")[1].split("=")[1];
}
return ElasticConnection.newBuilder()
.withIndexPrefix(indexPrefix + System.currentTimeMillis())
.withConnectionParameters(scheme, host, port)
- .withApiKeys(api_key, api_secret)
+ .withApiKeys(apiKey, apiSecret)
.build();
} catch (URISyntaxException e) {
+ LOG.error("Provided elastic connection string is not valid ", e);
return null;
}
}
+ private boolean isValidUri(String connectionString) {
+ if (connectionString == null) {
+ return false;
+ }
+ try {
+ new URI(connectionString);
+ return true;
+ } catch (URISyntaxException e) {
+ LOG.debug("Provided elastic connection string is not valid ", e);
Review Comment:
extra space. Could it be useful to print `connectionString` as part of the log message?
```suggestion
LOG.debug("Provided elastic connection string is not valid ", e);
```
##########
oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticConnectionRule.java:
##########
@@ -75,6 +80,46 @@ protected void after() {
}
}
+ public ElasticConnectionModel getElasticConnectionModel() {
+ return elasticConnectionModel;
+ }
+
+ private void initializeElasticConnectionModel(String elasticConnectionString) {
+ try {
+ URI uri = new URI(elasticConnectionString);
+ String host = uri.getHost();
+ String scheme = uri.getScheme();
+ int port = uri.getPort();
+ String query = uri.getQuery();
+
+ String apiKey = null;
+ String apiSecret = null;
+ if (query != null) {
+ apiKey = query.split(",")[0].split("=")[1];
+ apiSecret = query.split(",")[1].split("=")[1];
+ }
+ this.elasticConnectionModel = new ElasticConnectionModel();
+ elasticConnectionModel.scheme = scheme;
+ elasticConnectionModel.elasticHost = host;
+ elasticConnectionModel.elasticPort = port;
+ elasticConnectionModel.elasticApiKey = apiKey;
+ elasticConnectionModel.elasticApiSecret = apiSecret;
+ elasticConnectionModel.indexPrefix = indexPrefix + System.currentTimeMillis();
+ } catch (URISyntaxException e) {
+ LOG.error("Provided elastic connection string is not valid ", e);
+ }
+ }
+
+ private void initializeElasticConnectionModel(ElasticsearchContainer elastic) {
+ this.elasticConnectionModel = new ElasticConnectionModel();
+ elasticConnectionModel.scheme = ElasticConnection.DEFAULT_SCHEME;
+ elasticConnectionModel.elasticHost = elastic.getContainerIpAddress();
Review Comment:
`getContainerIpAddress` is deprecated in favour of `getHost`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org