update to Elasticsearch 5.1.1, Gradle 3.2.1

This commit is contained in:
Jörg Prante 2016-12-12 11:51:35 +01:00
parent 1888b3630f
commit 6bd2f65a66
12 changed files with 72 additions and 78 deletions

View file

@ -1,13 +1,9 @@
plugins {
id "org.sonarqube" version "2.2"
id "org.ajoberstar.github-pages" version "1.6.0-rc.1"
id "org.xbib.gradle.plugin.jbake" version "1.2.1"
}
group = 'org.xbib'
version = '5.0.1.1'
printf "Host: %s\nOS: %s %s %s\nJVM: %s %s %s %s\nGroovy: %s\nGradle: %s\n" +
"Build: group: ${project.group} name: ${project.name} version: ${project.version}\n",
InetAddress.getLocalHost(),
@ -28,9 +24,15 @@ apply plugin: 'findbugs'
apply plugin: 'pmd'
apply plugin: 'checkstyle'
apply plugin: "jacoco"
apply plugin: 'org.ajoberstar.github-pages'
apply from: 'gradle/ext.gradle'
ext {
user = 'xbib'
name = 'elasticsearch-extras-client'
description = 'Some extras implemented for using Elasticsearch clients (node and transport)'
scmUrl = 'https://github.com/' + user + '/' + name
scmConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git'
scmDeveloperConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git'
}
sourceSets {
integrationTest {
@ -56,7 +58,7 @@ configurations {
dependencies {
compile "org.xbib:metrics:1.0.0"
compile("org.elasticsearch.client:transport:5.0.1") {
compile("org.elasticsearch.client:transport:5.1.1") {
exclude group: 'org.elasticsearch', module: 'securesm'
exclude group: 'org.elasticsearch.plugin', module: 'transport-netty3-client'
exclude group: 'org.elasticsearch.plugin', module: 'reindex-client'

3
gradle.properties Normal file
View file

@ -0,0 +1,3 @@
group = org.xbib
name = elasticsearch-extras-client
version = 5.1.1.0

View file

@ -1,8 +0,0 @@
ext {
user = 'xbib'
name = 'elasticsearch-extras-client'
description = 'Some extras implemented for using Elasticsearch clients (node and transport)'
scmUrl = 'https://github.com/' + user + '/' + name
scmConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git'
scmDeveloperConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git'
}

Binary file not shown.

View file

@ -1,6 +1,6 @@
#Tue Nov 01 14:46:00 CET 2016
#Sun Dec 04 10:06:25 CET 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip

19
gradlew vendored
View file

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
##############################################################################
##
@ -154,16 +154,19 @@ if $cygwin ; then
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save ( ) {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"

View file

@ -1 +1 @@
rootProject.name = 'elasticsearch-extras-client'
rootProject.name = name

View file

@ -22,7 +22,11 @@ import org.junit.Before;
import org.xbib.elasticsearch.extras.client.NetworkUtils;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.HashMap;
import java.util.Map;

View file

@ -11,6 +11,7 @@ import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder;
import org.elasticsearch.action.index.IndexAction;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.junit.Test;
import org.xbib.elasticsearch.NodeTestBase;
@ -20,27 +21,17 @@ import org.xbib.elasticsearch.NodeTestBase;
*/
public class SimpleTest extends NodeTestBase {
protected Settings getNodeSettings() {
return Settings.builder()
.put("cluster.name", getClusterName())
.put("discovery.type", "local")
.put("transport.type", "local")
.put("http.enabled", false)
.put("path.home", getHome())
.put("node.max_local_storage_nodes", 5)
.build();
}
@Test
public void test() throws Exception {
Client client = client("1");
try {
DeleteIndexRequestBuilder deleteIndexRequestBuilder =
new DeleteIndexRequestBuilder(client("1"), DeleteIndexAction.INSTANCE, "test");
new DeleteIndexRequestBuilder(client, DeleteIndexAction.INSTANCE, "test");
deleteIndexRequestBuilder.execute().actionGet();
} catch (Exception e) {
// ignore
}
CreateIndexRequestBuilder createIndexRequestBuilder = new CreateIndexRequestBuilder(client("1"),
CreateIndexRequestBuilder createIndexRequestBuilder = new CreateIndexRequestBuilder(client,
CreateIndexAction.INSTANCE)
.setIndex("test")
.setSettings(Settings.builder()
@ -50,7 +41,7 @@ public class SimpleTest extends NodeTestBase {
.build());
createIndexRequestBuilder.execute().actionGet();
IndexRequestBuilder indexRequestBuilder = new IndexRequestBuilder(client("1"), IndexAction.INSTANCE);
IndexRequestBuilder indexRequestBuilder = new IndexRequestBuilder(client, IndexAction.INSTANCE);
indexRequestBuilder
.setIndex("test")
.setType("test")
@ -60,7 +51,7 @@ public class SimpleTest extends NodeTestBase {
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
.execute()
.actionGet();
String doc = client("1").prepareSearch("test")
String doc = client.prepareSearch("test")
.setTypes("test")
.setQuery(matchQuery("field",
"1%2fPJJP3JV2C24iDfEu9XpHBaYxXh%2fdHTbmchB35SDznXO2g8Vz4D7GTIvY54iMiX_149c95f02a8"))

View file

@ -6,7 +6,6 @@ import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilder;
import org.junit.Test;
import org.xbib.elasticsearch.NodeTestBase;
@ -18,33 +17,23 @@ import java.io.IOException;
*/
public class WildcardTest extends NodeTestBase {
protected Settings getNodeSettings() {
return Settings.builder()
.put("cluster.name", getClusterName())
.put("discovery.type", "local")
.put("transport.type", "local")
.put("http.enabled", false)
.put("path.home", getHome())
.put("node.max_local_storage_nodes", 5)
.build();
}
@Test
public void testWildcard() throws Exception {
index(client("1"), "1", "010");
index(client("1"), "2", "0*0");
Client client = client("1");
index(client, "1", "010");
index(client, "2", "0*0");
// exact
validateCount(client("1"), queryStringQuery("010").defaultField("field"), 1);
validateCount(client("1"), queryStringQuery("0\\*0").defaultField("field"), 1);
validateCount(client, queryStringQuery("010").defaultField("field"), 1);
validateCount(client, queryStringQuery("0\\*0").defaultField("field"), 1);
// pattern
validateCount(client("1"), queryStringQuery("0*0").defaultField("field"), 1); // 2?
validateCount(client("1"), queryStringQuery("0?0").defaultField("field"), 1); // 2?
validateCount(client("1"), queryStringQuery("0**0").defaultField("field"), 1); // 2?
validateCount(client("1"), queryStringQuery("0??0").defaultField("field"), 0);
validateCount(client("1"), queryStringQuery("*10").defaultField("field"), 1);
validateCount(client("1"), queryStringQuery("*1*").defaultField("field"), 1);
validateCount(client("1"), queryStringQuery("*\\*0").defaultField("field"), 0); // 1?
validateCount(client("1"), queryStringQuery("*\\**").defaultField("field"), 0); // 1?
validateCount(client, queryStringQuery("0*0").defaultField("field"), 1); // 2?
validateCount(client, queryStringQuery("0?0").defaultField("field"), 1); // 2?
validateCount(client, queryStringQuery("0**0").defaultField("field"), 1); // 2?
validateCount(client, queryStringQuery("0??0").defaultField("field"), 0);
validateCount(client, queryStringQuery("*10").defaultField("field"), 1);
validateCount(client, queryStringQuery("*1*").defaultField("field"), 1);
validateCount(client, queryStringQuery("*\\*0").defaultField("field"), 0); // 1?
validateCount(client, queryStringQuery("*\\**").defaultField("field"), 0); // 1?
}
private void index(Client client, String id, String fieldValue) throws IOException {

View file

@ -147,7 +147,7 @@ public class BulkProcessor implements Closeable {
* @param request request
* @return his bulk processor
*/
public BulkProcessor add(ActionRequest<?> request) {
public BulkProcessor add(ActionRequest request) {
return add(request, null);
}
@ -158,7 +158,7 @@ public class BulkProcessor implements Closeable {
* @param payload payload
* @return his bulk processor
*/
public BulkProcessor add(ActionRequest<?> request, @Nullable Object payload) {
public BulkProcessor add(ActionRequest request, @Nullable Object payload) {
internalAdd(request, payload);
return this;
}
@ -169,7 +169,7 @@ public class BulkProcessor implements Closeable {
}
}
private synchronized void internalAdd(ActionRequest<?> request, @Nullable Object payload) {
private synchronized void internalAdd(ActionRequest request, @Nullable Object payload) {
ensureOpen();
bulkRequest.add(request, payload);
executeIfNeeded();

View file

@ -40,6 +40,7 @@ import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.NetworkPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.SearchPlugin;
@ -48,6 +49,7 @@ import org.elasticsearch.threadpool.ExecutorBuilder;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.FutureTransportResponseHandler;
import org.elasticsearch.transport.TcpTransport;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;
@ -355,7 +357,7 @@ public class TransportClient extends AbstractClient {
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
protected <R extends ActionRequest<R>, S extends ActionResponse, T extends ActionRequestBuilder<R, S, T>>
protected <R extends ActionRequest, S extends ActionResponse, T extends ActionRequestBuilder<R, S, T>>
void doExecute(Action<R, S, T> action, final R request, final ActionListener<S> listener) {
final TransportActionNodeProxy<R, S> proxyAction = proxy.getProxies().get(action);
if (proxyAction == null) {
@ -425,10 +427,11 @@ public class TransportClient extends AbstractClient {
additionalSettings.addAll(builder.getRegisteredSettings());
}
SettingsModule settingsModule = new SettingsModule(settings, additionalSettings, additionalSettingsFilter);
NetworkModule networkModule = new NetworkModule(networkService, settings, true);
SearchModule searchModule = new SearchModule(settings, true, pluginsService.filterPlugins(SearchPlugin.class));
SearchModule searchModule = new SearchModule(settings, true,
pluginsService.filterPlugins(SearchPlugin.class));
List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
entries.addAll(networkModule.getNamedWriteables());
entries.addAll(NetworkModule.getNamedWriteables());
entries.addAll(searchModule.getNamedWriteables());
entries.addAll(pluginsService.filterPlugins(Plugin.class).stream()
.flatMap(p -> p.getNamedWriteables().stream())
@ -440,27 +443,34 @@ public class TransportClient extends AbstractClient {
for (Module pluginModule : pluginsService.createGuiceModules()) {
modules.add(pluginModule);
}
modules.add(networkModule);
modules.add(b -> b.bind(ThreadPool.class).toInstance(threadPool));
ActionModule actionModule = new ActionModule(false, true, settings, null, settingsModule.getClusterSettings(),
ActionModule actionModule = new ActionModule(false, true,
settings, null, settingsModule.getClusterSettings(),
pluginsService.filterPlugins(ActionPlugin.class));
modules.add(actionModule);
pluginsService.processModules(modules);
CircuitBreakerService circuitBreakerService = Node.createCircuitBreakerService(settingsModule.getSettings(),
settingsModule.getClusterSettings());
resourcesToClose.add(circuitBreakerService);
BigArrays bigArrays = new BigArrays(settings, circuitBreakerService);
resourcesToClose.add(circuitBreakerService);
resourcesToClose.add(bigArrays);
modules.add(settingsModule);
NetworkModule networkModule = new NetworkModule(settings, true,
pluginsService.filterPlugins(NetworkPlugin.class), threadPool,
bigArrays, circuitBreakerService, namedWriteableRegistry, networkService);
final Transport transport = networkModule.getTransportSupplier().get();
final TransportService transportService = new TransportService(settings, transport, threadPool,
networkModule.getTransportInterceptor(), null);
modules.add((b -> {
b.bind(BigArrays.class).toInstance(bigArrays);
b.bind(PluginsService.class).toInstance(pluginsService);
b.bind(CircuitBreakerService.class).toInstance(circuitBreakerService);
b.bind(NamedWriteableRegistry.class).toInstance(namedWriteableRegistry);
b.bind(Transport.class).toInstance(transport);
b.bind(TransportService.class).toInstance(transportService);
b.bind(NetworkService.class).toInstance(networkService);
}));
Injector injector = modules.createInjector();
final TransportService transportService = injector.getInstance(TransportService.class);
final ProxyActionMap proxy = new ProxyActionMap(settings, transportService,
actionModule.getActions().values().stream()
.map(ActionPlugin.ActionHandler::getAction).collect(Collectors.toList()));