Skip to content

Commit

Permalink
[ issue #95 ] Release ES 5.6.16
Browse files Browse the repository at this point in the history
  • Loading branch information
agazzarini committed Nov 16, 2019
1 parent d1052c8 commit d974dc7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion rre-maven-plugin/rre-maven-elasticsearch-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rre-maven-elasticsearch-plugin</artifactId>
<version>6.7.2</version>
<version>5.6.16</version>
<packaging>maven-plugin</packaging>
<name>RRE - Maven Elasticsearch Plugin</name>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>rre-maven-external-elasticsearch-plugin</artifactId>
<version>6.7.2</version>
<version>5.6.16</version>
<packaging>maven-plugin</packaging>
<name>RRE - Maven External Elasticsearch Plugin</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rre-search-platform-elasticsearch-impl</artifactId>
<version>6.7.2</version>
<version>5.6.16</version>
<name>RRE - Elasticsearch platform binding</name>
<dependencies>
<dependency>
Expand Down Expand Up @@ -66,10 +66,10 @@
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.codelibs.elasticsearch.module</groupId>
<artifactId>analysis-common</artifactId>
<version>${project.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.codelibs.elasticsearch.module</groupId>-->
<!-- <artifactId>analysis-common</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.analysis.common.CommonAnalysisPlugin;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentType;
Expand Down Expand Up @@ -65,6 +64,8 @@
import static org.elasticsearch.client.Requests.indicesExistsRequest;
import static org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment;

//import org.elasticsearch.analysis.common.CommonAnalysisPlugin;

/**
* Elasticsearch platform API implementation.
*
Expand All @@ -76,12 +77,7 @@ public class Elasticsearch implements SearchPlatform {

private static class RRENode extends Node {
RRENode(final Settings settings, final Collection<Class<? extends Plugin>> plugins) {
super(prepareEnvironment(settings, null), plugins, true);
}

@Override
protected void registerDerivedNodeNameWithLogger(String s) {
// empty
super(prepareEnvironment(settings, null), plugins);
}
}

Expand Down Expand Up @@ -285,7 +281,7 @@ public boolean isRefreshRequired() {

@SuppressWarnings("unchecked")
private List<Class<? extends Plugin>> plugins(final Map<String, Object> configuration) {
final List<Class<? extends Plugin>> defaultPlugins = asList(Netty4Plugin.class, CommonAnalysisPlugin.class);
final List<Class<? extends Plugin>> defaultPlugins = asList(Netty4Plugin.class);
final List<? extends Class<? extends Plugin>> customPlugins =
ofNullable((List<String>)configuration.get("plugins"))
.map(plugins ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand All @@ -51,6 +51,7 @@ public class ExternalElasticsearch extends Elasticsearch {

private final Map<String, IndexSettings> indexSettingsMap = new HashMap<>();
private final Map<String, RestHighLevelClient> indexClients = new HashMap<>();
private final List<RestClient> indexLowLevelClients = new ArrayList<>();

@Override
public void beforeStart(Map<String, Object> configuration) {
Expand All @@ -72,19 +73,22 @@ public void load(File corpus, File settingsFile, String targetIndexName) {
// Load the index settings for this version of the search platform
IndexSettings settings = mapper.readValue(settingsFile, IndexSettings.class);
indexSettingsMap.put(targetIndexName, settings);
indexClients.put(targetIndexName, initialiseClient(settings.getHostUrls()));

RestClient lowLevelClient = initialiseLowLevelClient(settings.getHostUrls());
indexLowLevelClients.add(lowLevelClient);
indexClients.put(targetIndexName, new RestHighLevelClient(lowLevelClient));
} catch (IOException e) {
LOGGER.error("Could not read settings from " + settingsFile.getName() + " :: " + e.getMessage());
}
}

private RestHighLevelClient initialiseClient(List<String> hosts) {
private RestClient initialiseLowLevelClient(List<String> hosts) {
// Convert hosts to HTTP host objects
HttpHost[] httpHosts = hosts.stream()
.map(HttpHost::create)
.toArray(HttpHost[]::new);

return new RestHighLevelClient(RestClient.builder(httpHosts));
return RestClient.builder(httpHosts).build();
}

@Override
Expand All @@ -111,7 +115,7 @@ private SearchResponse runQuery(final String indexKey, final SearchRequest reque
if (client == null) {
throw new RuntimeException("No HTTP client found for index " + indexKey);
}
return client.search(request, RequestOptions.DEFAULT);
return client.search(request);
}

@Override
Expand All @@ -131,10 +135,10 @@ public boolean isCorporaRequired() {

@Override
public void close() {
indexClients.values().forEach(this::closeClient);
indexLowLevelClients.forEach(this::closeClient);
}

private void closeClient(RestHighLevelClient client) {
private void closeClient(RestClient client) {
try {
client.close();
} catch (IOException e) {
Expand Down

0 comments on commit d974dc7

Please sign in to comment.