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

Port to es 5.1 #120

Open
wants to merge 2 commits into
base: master
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
58 changes: 38 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
</scm>

<properties>
<lucene.version>5.5.2</lucene.version>
<elasticsearch.version>2.4.2</elasticsearch.version>
<maven.compiler.target>1.7</maven.compiler.target>
<lucene.version>6.3.0</lucene.version>
<elasticsearch.version>5.1.1</elasticsearch.version>
<maven.compiler.target>1.8</maven.compiler.target>

<siren.tools.directory>${project.basedir}/dev-tools</siren.tools.directory>
<siren.license.header>${siren.tools.directory}/license-check/siren_license_header.txt</siren.license.header>
Expand Down Expand Up @@ -196,7 +196,7 @@
<dependency>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>randomizedtesting-runner</artifactId>
<version>2.3.2</version>
<version>2.4.0</version>
<scope>test</scope>
</dependency>

Expand All @@ -223,17 +223,9 @@
</dependency>

<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
<version>${elasticsearch.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
<scope>test</scope>
</dependency>

Expand All @@ -250,6 +242,20 @@
<version>${elasticsearch.version}</version>
</dependency>

<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>${elasticsearch.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand All @@ -262,19 +268,31 @@
<version>0.7.1</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
</dependency>

<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>junit-benchmarks</artifactId>
<version>0.7.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>

</dependencies>

<profiles>
Expand Down
3 changes: 2 additions & 1 deletion src/main/assemblies/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
<useTransitiveFiltering>true</useTransitiveFiltering>
<excludes>
<exclude>org.elasticsearch:elasticsearch</exclude>
<exclude>com.google.guava:guava</exclude>
<exclude>com.carrotsearch:hppc</exclude>
<exclude>org.apache.logging.log4j:log4j-api</exclude>
<exclude>org.apache.logging.log4j:log4j-core</exclude>
</excludes>
</dependencySet>
</dependencySets>
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/solutions/siren/join/SirenJoinNodeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@

import org.elasticsearch.common.inject.AbstractModule;
import solutions.siren.join.action.admin.cache.FilterJoinCacheService;
import solutions.siren.join.action.admin.version.IndexVersionService;

public class SirenJoinNodeModule extends AbstractModule {

private final IndexVersionService indexVersionService;

public SirenJoinNodeModule(IndexVersionService indexVersionService) {
this.indexVersionService = indexVersionService;
}

@Override
protected void configure() {
bind(FilterJoinCacheService.class).asEagerSingleton();
bind(IndexVersionService.class).toInstance(indexVersionService);
}

}
125 changes: 67 additions & 58 deletions src/main/java/solutions/siren/join/SirenJoinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,111 +18,120 @@
*/
package solutions.siren.join;

import org.elasticsearch.action.ActionModule;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.index.cache.IndexCacheModule;
import org.elasticsearch.indices.IndicesModule;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.rest.RestModule;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;

import solutions.siren.join.action.admin.cache.*;
import solutions.siren.join.action.admin.version.GetIndicesVersionAction;
import solutions.siren.join.action.admin.version.IndexVersionShardService;
import solutions.siren.join.action.admin.version.TransportGetIndicesVersionAction;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.index.shard.IndexingOperationListener;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.SearchPlugin;
import org.elasticsearch.rest.RestHandler;
import solutions.siren.join.action.admin.cache.ClearFilterJoinCacheAction;
import solutions.siren.join.action.admin.cache.StatsFilterJoinCacheAction;
import solutions.siren.join.action.admin.cache.TransportClearFilterJoinCacheAction;
import solutions.siren.join.action.admin.cache.TransportStatsFilterJoinCacheAction;
import solutions.siren.join.action.admin.version.*;
import solutions.siren.join.action.coordinate.CoordinateMultiSearchAction;
import solutions.siren.join.action.coordinate.CoordinateSearchAction;
import solutions.siren.join.action.coordinate.TransportCoordinateMultiSearchAction;
import solutions.siren.join.action.coordinate.TransportCoordinateSearchAction;
import solutions.siren.join.action.coordinate.execution.FilterJoinCache;
import solutions.siren.join.action.terms.TermsByQueryAction;
import solutions.siren.join.action.terms.TransportTermsByQueryAction;
import solutions.siren.join.index.query.FieldDataTermsQueryParser;
import solutions.siren.join.index.query.TermsEnumTermsQueryParser;
import solutions.siren.join.index.query.FieldDataTermsQueryBuilder;
import solutions.siren.join.index.query.FilterJoinBuilder;
import solutions.siren.join.index.query.TermsEnumTermsQueryBuilder;
import solutions.siren.join.rest.RestClearFilterJoinCacheAction;
import solutions.siren.join.rest.RestCoordinateMultiSearchAction;
import solutions.siren.join.rest.RestCoordinateSearchAction;
import solutions.siren.join.rest.RestStatsFilterJoinCacheAction;

import java.io.Closeable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
* The SIREn Join plugin.
*/
public class SirenJoinPlugin extends Plugin {
public class SirenJoinPlugin extends Plugin implements ActionPlugin, SearchPlugin {

private final boolean isEnabled;
private final IndexVersionService indexVersionService;

@Inject
public SirenJoinPlugin(Settings settings) {
if (DiscoveryNode.clientNode(settings)) {
if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) {
this.isEnabled = "node".equals(settings.get("client.type"));
} else {
this.isEnabled = false;
}
else {
this.isEnabled = true;
}
}

public void onModule(ActionModule module) {
module.registerAction(TermsByQueryAction.INSTANCE, TransportTermsByQueryAction.class);
module.registerAction(CoordinateSearchAction.INSTANCE, TransportCoordinateSearchAction.class);
module.registerAction(CoordinateMultiSearchAction.INSTANCE, TransportCoordinateMultiSearchAction.class);
module.registerAction(ClearFilterJoinCacheAction.INSTANCE, TransportClearFilterJoinCacheAction.class);
module.registerAction(StatsFilterJoinCacheAction.INSTANCE, TransportStatsFilterJoinCacheAction.class);
module.registerAction(GetIndicesVersionAction.INSTANCE, TransportGetIndicesVersionAction.class);
}

public void onModule(IndicesModule module) {
module.registerQueryParser(FieldDataTermsQueryParser.class);
module.registerQueryParser(TermsEnumTermsQueryParser.class);
}

public void onModule(RestModule module) {
module.addRestAction(RestCoordinateSearchAction.class);
module.addRestAction(RestCoordinateMultiSearchAction.class);
module.addRestAction(RestClearFilterJoinCacheAction.class);
module.addRestAction(RestStatsFilterJoinCacheAction.class);
this.indexVersionService = isEnabled ? new IndexVersionService(settings) : null;
}

@Override
public Collection<Module> nodeModules() {
if (isEnabled) {
return Collections.singletonList((Module) new SirenJoinNodeModule());
}
else {
return Collections.emptyList();
public void onIndexModule(IndexModule indexModule) {
if (!this.isEnabled) return;
IndexVersionEventListener indexVersionEventListener = indexVersionService.getOrDefault(indexModule.getIndex());

if (indexVersionEventListener == null) {
VersionIndexingOperationListener indexingOperationListener = new VersionIndexingOperationListener();
IndexVersionEventListener eventListener = new IndexVersionEventListener(indexingOperationListener);
indexModule.addIndexEventListener(eventListener);
indexModule.addIndexOperationListener(indexingOperationListener);
this.indexVersionService.registerIndexEventListener(indexModule.getIndex(), eventListener);
} else {
indexModule.addIndexEventListener(indexVersionEventListener);
indexModule.addIndexOperationListener(indexVersionEventListener.getOperationListener());
}
}

@Override
public Collection<Module> shardModules(Settings indexSettings) {
return Collections.singletonList((Module) new SirenJoinShardModule());
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return Arrays.asList(
new ActionHandler<>(TermsByQueryAction.INSTANCE, TransportTermsByQueryAction.class),
new ActionHandler<>(CoordinateSearchAction.INSTANCE, TransportCoordinateSearchAction.class),
new ActionHandler<>(CoordinateMultiSearchAction.INSTANCE, TransportCoordinateMultiSearchAction.class),
new ActionHandler<>(ClearFilterJoinCacheAction.INSTANCE, TransportClearFilterJoinCacheAction.class),
new ActionHandler<>(StatsFilterJoinCacheAction.INSTANCE, TransportStatsFilterJoinCacheAction.class),
new ActionHandler<>(GetIndicesVersionAction.INSTANCE, TransportGetIndicesVersionAction.class));
}


@Override
public Collection<Class<? extends Closeable>> shardServices() {
Collection<Class<? extends Closeable>> services = new ArrayList<>();
services.add(IndexVersionShardService.class);
return services;
public List<QuerySpec<?>> getQueries() {
return Arrays.asList(new QuerySpec<>(FieldDataTermsQueryBuilder.NAME, FieldDataTermsQueryBuilder::new, FieldDataTermsQueryBuilder::fromXContent),
new QuerySpec<>(TermsEnumTermsQueryBuilder.NAME, TermsEnumTermsQueryBuilder::new, TermsEnumTermsQueryBuilder::fromXContent),
new QuerySpec<>(FilterJoinBuilder.NAME, FilterJoinBuilder::new, FilterJoinBuilder::fromXContent));
}

@Override
public String name() {
return "SirenJoinPlugin";
public List<Class<? extends RestHandler>> getRestHandlers() {
return Arrays.asList(RestCoordinateSearchAction.class, RestCoordinateMultiSearchAction.class,
RestClearFilterJoinCacheAction.class, RestStatsFilterJoinCacheAction.class);
}

@Override
public String description() {
return "SIREn plugin that adds join capabilities to Elasticsearch";
public Collection<Module> createGuiceModules() {
if (isEnabled) {
return Collections.singletonList(new SirenJoinNodeModule(this.indexVersionService));
}
else {
return Collections.emptyList();
}
}

@Override
public Settings additionalSettings() {
return Settings.builder().put(IndexCacheModule.QUERY_CACHE_EVERYTHING, true).build();
public List<Setting<?>> getSettings() {
return Arrays.asList(Setting.boolSetting(FilterJoinCache.SIREN_FILTERJOIN_CACHE_ENABLED, true, Setting.Property.NodeScope),
Setting.intSetting(FilterJoinCache.SIREN_FILTERJOIN_CACHE_SIZE, FilterJoinCache.DEFAULT_CACHE_SIZE, Setting.Property.NodeScope)
);
}

}
31 changes: 0 additions & 31 deletions src/main/java/solutions/siren/join/SirenJoinShardModule.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class ClearFilterJoinCacheNodeRequest extends BaseNodeRequest {
public ClearFilterJoinCacheNodeRequest() {}

public ClearFilterJoinCacheNodeRequest(String nodeId, ClearFilterJoinCacheRequest request) {
super(request, nodeId);
super(nodeId);
this.request = request;
}

Expand Down
Loading