Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove es.url and use the components (es.protocol, es.host, es.port) instead #111

Open
wants to merge 1 commit into
base: 44-elasticsearch-config-env
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/test/resources/WEB-INF/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ usersavedselection.watchlist.searchurl=catalog.search#/search?_uuid={{filter}}
usersavedselection.watchlist.recordurl=api/records/{{index:uuid}}


es.url=http://localhost:9200

es.port=9200
es.host=localhost
es.protocol=http
Expand Down
4 changes: 1 addition & 3 deletions docs/manual/docs/install-guide/installing-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ By default, GeoNetwork expects Elasticsearch to be running at <http://localhost:
* Define the connection details in Java properties.

```shell
export JAVA_OPTS="$JAVA_OPTS -Des.protocol=http -Des.port=9200 -Des.host=localhost -Des.url=http://localhost:9200 -Des.username= -Des.password="
export JAVA_OPTS="$JAVA_OPTS -Des.protocol=http -Des.port=9200 -Des.host=localhost -Des.protocol=http -Des.username= -Des.password="
```

* Define the connection details in environment variables.
Expand All @@ -122,7 +122,6 @@ By default, GeoNetwork expects Elasticsearch to be running at <http://localhost:
export GEONETWORK_ES_HOST=localhost
export GEONETWORK_ES_PROTOCOL=http
export GEONETWORK_ES_PORT=9200
export GEONETWORK_ES_URL=$GEONETWORK_ES_PROTOCOL://$GEONETWORK_ES_HOST:$GEONETWORK_ES_PORT
export GEONETWORK_ES_USERNAME=
export GEONETWORK_ES_PASSWORD=
```
Expand All @@ -133,7 +132,6 @@ By default, GeoNetwork expects Elasticsearch to be running at <http://localhost:
es.protocol=#{systemEnvironment['GEONETWORK_ES_PROTOCOL']?:'http'}
es.port=#{systemEnvironment['GEONETWORK_ES_PORT']?:9200}
es.host=#{systemEnvironment['GEONETWORK_ES_HOST']?:'localhost'}
es.url=#{systemEnvironment['GEONETWORK_ES_URL']?:'http://localhost:9200'}
es.username=#{systemEnvironment['GEONETWORK_ES_USERNAME']?:''}
es.password=#{systemEnvironment['GEONETWORK_ES_PASSWORD']?:''}
```
Expand Down
4 changes: 3 additions & 1 deletion docs/manual/docs/tutorials/introduction/deployment/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ Once you have Tomcat installed on your system, locate the webapps folder and pla
Open the file /geonetwork/WEB-INF/config.properties and alter the elasticsearch connection

``` bash
$ es.url=http://localhost:9200
es.protocol=http
es.host=localhost
es.port=9200
```

Then (re)start Jetty/Tomcat.
Expand Down
1 change: 0 additions & 1 deletion harvesters/src/test/resources/WEB-INF/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ usersavedselection.watchlist.searchurl=catalog.search#/search?_uuid={{filter}}
# Define the link to each record sent by email by the watchlist notifier
usersavedselection.watchlist.recordurl=api/records/{{index:uuid}}

es.url=http://localhost:9200
es.port=9200
es.host=localhost
es.protocol=http
Expand Down
12 changes: 10 additions & 2 deletions index/src/main/java/org/fao/geonet/index/es/EsRestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class EsRestClient implements InitializingBean {

private ElasticsearchAsyncClient asyncClient;

@Value("${es.url}")

private String serverUrl;

@Value("${es.protocol}")
Expand Down Expand Up @@ -128,10 +128,18 @@ public void setDashboardAppUrl(String dashboardAppUrl) {

@Override
public void afterPropertiesSet() throws Exception {
if (StringUtils.isBlank(serverProtocol) || StringUtils.isBlank(serverHost) || StringUtils.isBlank(serverPort)) {
Log.error("geonetwork.index", String.format(
"Elasticsearch URL defined by serverProtocol='%s', serverHost='%s', serverPort='%s' is missing. "
+ "Check configuration.", this.serverProtocol,this.serverHost,this.serverPort));
}

//build server URL
serverUrl = serverProtocol + "://" + serverHost + ":" + serverPort;
if (StringUtils.isNotEmpty(serverUrl)) {
RestClientBuilder builder = RestClient.builder(new HttpHost(serverHost, Integer.parseInt(serverPort), serverProtocol));

if (serverUrl.startsWith("https://")) {
if (serverProtocol.startsWith("https")) {
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(
null, new TrustStrategy() {
public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
Expand Down
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,6 @@
<es.protocol>http</es.protocol>
<es.port>9200</es.port>
<es.host>localhost</es.host>
<es.url>${es.protocol}://${es.host}:${es.port}</es.url>
<es.index.features>gn-features</es.index.features>
<es.index.features.type>features</es.index.features.type>
<es.index.records>gn-records</es.index.records>
Expand Down
5 changes: 3 additions & 2 deletions schemas-test/src/main/webapp/WEB-INF/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ usersavedselection.watchlist.searchurl=catalog.search#/search?_uuid={{filter}}
# Define the link to each record sent by email by the watchlist notifier
usersavedselection.watchlist.recordurl=api/records/{{index:uuid}}


es.url=http://localhost:9200
es.protocol=http
es.host=localhost
es.port=9200
es.index.features=features
es.index.records=records
es.index.searchlogs=searchlogs
Expand Down
3 changes: 2 additions & 1 deletion services/src/main/webapp/WEB-INF/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ usersavedselection.watchlist.searchurl=catalog.search#/search?_uuid={{filter}}
# Define the link to each record sent by email by the watchlist notifier
usersavedselection.watchlist.recordurl=api/records/{{index:uuid}}

es.protocol=http
es.host=localhost
es.port=9200
es.url=http://localhost:9200
es.index.features=features
es.index.records=records
es.index.searchlogs=searchlogs
Expand Down
3 changes: 1 addition & 2 deletions services/src/test/resources/WEB-INF/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ usersavedselection.watchlist.searchurl=catalog.search#/search?_uuid={{filter}}
# Define the link to each record sent by email by the watchlist notifier
usersavedselection.watchlist.recordurl=api/records/{{index:uuid}}

es.url=http://localhost:9200
es.port=9200
es.port=9200
es.host=localhost
es.protocol=http
es.index.features=features
Expand Down
1 change: 0 additions & 1 deletion web/src/main/webResources/WEB-INF/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ usersavedselection.watchlist.recordurl=api/records/{{index:uuid}}
es.protocol=#{systemEnvironment['GEONETWORK_ES_PROTOCOL']?:'${es.protocol}'}
es.port=#{systemEnvironment['GEONETWORK_ES_PORT']?:${es.port}}
es.host=#{systemEnvironment['GEONETWORK_ES_HOST']?:'${es.host}'}
es.url=#{systemEnvironment['GEONETWORK_ES_URL']?:'${es.url}'}
es.username=#{systemEnvironment['GEONETWORK_ES_USERNAME']?:'${es.username}'}
es.password=#{systemEnvironment['GEONETWORK_ES_PASSWORD']?:'${es.password}'}
es.index.features=${es.index.features}
Expand Down
2 changes: 1 addition & 1 deletion web/src/main/webResources/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
<servlet-class>org.fao.geonet.proxy.URITemplateProxyServlet</servlet-class>
<init-param>
<param-name>targetUri</param-name>
<param-value>${es.url}/${es.index.features}/{_}</param-value>
<param-value>${es.protocol}://${es.host}:${es.post}/${es.index.features}/{_}</param-value>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josegar74 - please verify this.

</init-param>
<init-param>
<param-name>log</param-name>
Expand Down