Merge branch 'master' into feature/http_client

Original commit: elastic/x-pack-elasticsearch@f11da04658
This commit is contained in:
javanna 2016-06-09 17:44:06 +02:00 committed by Luca Cavanna
commit c4ea0ae34d
79 changed files with 317 additions and 330 deletions

View File

@ -14,6 +14,7 @@ subprojects {
}
task bundlePack(type: Zip) {
onlyIf { project('kibana').bundlePlugin.enabled }
dependsOn 'elasticsearch:x-pack:bundlePlugin'
dependsOn 'kibana:bundlePlugin'
from { zipTree(project('elasticsearch:x-pack').bundlePlugin.outputs.files.singleFile) }

View File

@ -11,6 +11,7 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.script.groovy.GroovyPlugin;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.watcher.condition.script.ExecutableScriptCondition;
import org.elasticsearch.xpack.watcher.condition.script.ScriptCondition;
@ -49,7 +50,7 @@ public class GroovyScriptConditionIT extends AbstractWatcherIntegrationTestCase
@BeforeClass
public static void startThreadPool() {
THREAD_POOL = new ThreadPool(GroovyScriptConditionIT.class.getSimpleName());
THREAD_POOL = new TestThreadPool(GroovyScriptConditionIT.class.getSimpleName());
}
@Before

View File

@ -18,6 +18,7 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.InternalSearchHits;
import org.elasticsearch.search.internal.InternalSearchResponse;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.watcher.condition.script.ExecutableScriptCondition;
import org.elasticsearch.xpack.watcher.condition.script.ScriptCondition;
@ -50,7 +51,7 @@ public class ScriptConditionSearchIT extends AbstractWatcherIntegrationTestCase
@Before
public void init() throws Exception {
tp = new ThreadPool(ThreadPool.Names.SAME);
tp = new TestThreadPool(ThreadPool.Names.SAME);
scriptService = MessyTestUtils.getScriptServiceProxy(tp);
}

View File

@ -17,6 +17,7 @@ import org.elasticsearch.script.GeneralScriptException;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.search.internal.InternalSearchResponse;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.watcher.condition.Condition;
import org.elasticsearch.xpack.watcher.condition.script.ExecutableScriptCondition;
@ -49,7 +50,7 @@ public class ScriptConditionTests extends ESTestCase {
@Before
public void init() {
tp = new ThreadPool(ThreadPool.Names.SAME);
tp = new TestThreadPool(ThreadPool.Names.SAME);
}
@After

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph;
package org.elasticsearch.xpack.graph;
import org.elasticsearch.action.ActionModule;
import org.elasticsearch.common.component.LifecycleComponent;
@ -12,11 +12,11 @@ import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.graph.action.GraphExploreAction;
import org.elasticsearch.graph.action.TransportGraphExploreAction;
import org.elasticsearch.graph.rest.action.RestGraphAction;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.graph.action.GraphExploreAction;
import org.elasticsearch.xpack.graph.action.TransportGraphExploreAction;
import org.elasticsearch.xpack.graph.rest.action.RestGraphAction;
import java.util.Collection;
import java.util.Collections;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph;
package org.elasticsearch.xpack.graph;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.inject.Inject;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph;
package org.elasticsearch.xpack.graph;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph;
package org.elasticsearch.xpack.graph;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.util.Providers;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.action;
package org.elasticsearch.xpack.graph.action;
import com.carrotsearch.hppc.ObjectIntHashMap;
@ -11,7 +11,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.graph.action.Vertex.VertexId;
import org.elasticsearch.xpack.graph.action.Vertex.VertexId;
import java.io.IOException;
import java.util.Map;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.action;
package org.elasticsearch.xpack.graph.action;
import org.elasticsearch.action.Action;
import org.elasticsearch.client.ElasticsearchClient;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.action;
package org.elasticsearch.xpack.graph.action;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.action;
package org.elasticsearch.xpack.graph.action;
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.support.IndicesOptions;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.action;
package org.elasticsearch.xpack.graph.action;
import com.carrotsearch.hppc.ObjectIntHashMap;
@ -15,8 +15,8 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.graph.action.Connection.ConnectionId;
import org.elasticsearch.graph.action.Vertex.VertexId;
import org.elasticsearch.xpack.graph.action.Connection.ConnectionId;
import org.elasticsearch.xpack.graph.action.Vertex.VertexId;
import java.io.IOException;
import java.util.Collection;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.action;
package org.elasticsearch.xpack.graph.action;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ValidateActions;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.action;
package org.elasticsearch.xpack.graph.action;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.util.PriorityQueue;
@ -21,10 +21,6 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.graph.action.Connection.ConnectionId;
import org.elasticsearch.graph.action.GraphExploreRequest.TermBoost;
import org.elasticsearch.graph.action.Vertex.VertexId;
import org.elasticsearch.graph.GraphLicensee;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.license.plugin.core.LicenseUtils;
@ -41,6 +37,10 @@ import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.graph.GraphLicensee;
import org.elasticsearch.xpack.graph.action.Connection.ConnectionId;
import org.elasticsearch.xpack.graph.action.GraphExploreRequest.TermBoost;
import org.elasticsearch.xpack.graph.action.Vertex.VertexId;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.action;
package org.elasticsearch.xpack.graph.action;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;

View File

@ -3,11 +3,11 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.action;
package org.elasticsearch.xpack.graph.action;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.graph.action.GraphExploreRequest.TermBoost;
import org.elasticsearch.xpack.graph.action.GraphExploreRequest.TermBoost;
import java.io.IOException;
import java.util.HashMap;

View File

@ -3,7 +3,16 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.rest.action;
package org.elasticsearch.xpack.graph.rest.action;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.xpack.graph.action.GraphExploreAction.INSTANCE;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.support.IndicesOptions;
@ -16,11 +25,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.graph.action.GraphExploreRequest;
import org.elasticsearch.graph.action.GraphExploreRequest.TermBoost;
import org.elasticsearch.graph.action.GraphExploreResponse;
import org.elasticsearch.graph.action.Hop;
import org.elasticsearch.graph.action.VertexRequest;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
import org.elasticsearch.rest.BaseRestHandler;
@ -29,15 +33,12 @@ import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.support.RestActions;
import org.elasticsearch.rest.action.support.RestToXContentListener;
import org.elasticsearch.xpack.graph.action.GraphExploreRequest;
import org.elasticsearch.xpack.graph.action.GraphExploreResponse;
import org.elasticsearch.xpack.graph.action.Hop;
import org.elasticsearch.xpack.graph.action.VertexRequest;
import org.elasticsearch.xpack.graph.action.GraphExploreRequest.TermBoost;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import static org.elasticsearch.graph.action.GraphExploreAction.INSTANCE;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestRequest.Method.POST;
/**
* @see GraphExploreRequest

View File

@ -3,11 +3,13 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph;
package org.elasticsearch.xpack.graph;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.graph.GraphFeatureSet;
import org.elasticsearch.xpack.graph.GraphLicensee;
import org.junit.Before;
import static org.hamcrest.core.Is.is;

View File

@ -3,12 +3,12 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.license;
package org.elasticsearch.xpack.graph.license;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.graph.GraphLicensee;
import org.elasticsearch.license.core.License.OperationMode;
import org.elasticsearch.license.plugin.core.AbstractLicenseeTestCase;
import org.elasticsearch.xpack.graph.GraphLicensee;
import static org.hamcrest.Matchers.is;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.graph.test;
package org.elasticsearch.xpack.graph.test;
import org.apache.lucene.search.BooleanQuery;
import org.elasticsearch.action.ActionRequestValidationException;
@ -11,13 +11,6 @@ import org.elasticsearch.action.search.ShardSearchFailure;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.Settings.Builder;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.graph.action.GraphExploreAction;
import org.elasticsearch.graph.action.GraphExploreRequest;
import org.elasticsearch.graph.action.GraphExploreRequestBuilder;
import org.elasticsearch.graph.action.GraphExploreResponse;
import org.elasticsearch.graph.action.Hop;
import org.elasticsearch.graph.action.Vertex;
import org.elasticsearch.graph.action.VertexRequest;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.ScriptQueryBuilder;
import org.elasticsearch.marvel.Monitoring;
@ -32,6 +25,13 @@ import org.elasticsearch.shield.Security;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.xpack.watcher.Watcher;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.graph.action.GraphExploreAction;
import org.elasticsearch.xpack.graph.action.GraphExploreRequest;
import org.elasticsearch.xpack.graph.action.GraphExploreRequestBuilder;
import org.elasticsearch.xpack.graph.action.GraphExploreResponse;
import org.elasticsearch.xpack.graph.action.Hop;
import org.elasticsearch.xpack.graph.action.Vertex;
import org.elasticsearch.xpack.graph.action.VertexRequest;
import java.util.Collection;
import java.util.Map;

View File

@ -12,7 +12,6 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.graph.Graph;
import org.elasticsearch.license.core.License;
import org.elasticsearch.license.plugin.action.put.PutLicenseAction;
import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder;
@ -31,6 +30,7 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.xpack.watcher.Watcher;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.graph.Graph;
import java.util.ArrayList;
import java.util.Collection;

View File

@ -20,7 +20,6 @@ import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
import org.elasticsearch.graph.Graph;
import org.elasticsearch.marvel.Monitoring;
import org.elasticsearch.node.Node;
import org.elasticsearch.plugins.Plugin;
@ -31,6 +30,7 @@ import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.NodeConfigurationSource;
import org.elasticsearch.test.TestCluster;
import org.elasticsearch.xpack.graph.Graph;
import org.elasticsearch.xpack.watcher.Watcher;
import java.util.ArrayList;

View File

@ -30,6 +30,7 @@ import org.elasticsearch.marvel.agent.exporter.Exporters;
import org.elasticsearch.marvel.agent.exporter.MonitoringDoc;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.transport.CapturingTransport;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.junit.After;
@ -74,7 +75,7 @@ public class TransportMonitoringBulkActionTests extends ESTestCase {
@BeforeClass
public static void beforeClass() {
threadPool = new ThreadPool(TransportMonitoringBulkActionTests.class.getSimpleName());
threadPool = new TestThreadPool(TransportMonitoringBulkActionTests.class.getSimpleName());
}
@AfterClass

View File

@ -25,6 +25,7 @@ import org.junit.After;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
@ -58,7 +59,7 @@ public class ShardsTests extends MarvelIntegTestCase {
public void testShards() throws Exception {
logger.debug("--> creating some indices so that shards collector reports data");
for (int i = 0; i < randomIntBetween(1, 5); i++) {
client().prepareIndex(INDEX_PREFIX + i, "foo").setRefresh(true).setSource("field1", "value1").get();
client().prepareIndex(INDEX_PREFIX + i, "foo").setRefreshPolicy(IMMEDIATE).setSource("field1", "value1").get();
}
securedFlush();

View File

@ -11,6 +11,7 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.marvel.MonitoringSettings;
import org.elasticsearch.marvel.MonitoringLicensee;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
@ -40,7 +41,7 @@ public class CleanerServiceTests extends ESTestCase {
@Before
public void start() {
clusterSettings = new ClusterSettings(Settings.EMPTY, Collections.singleton(MonitoringSettings.HISTORY_DURATION));
threadPool = new ThreadPool("CleanerServiceTests");
threadPool = new TestThreadPool("CleanerServiceTests");
}
@After

View File

@ -7,6 +7,8 @@ package org.elasticsearch.shield.action.role;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
@ -24,13 +26,13 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
/**
* Request object for adding a role to the shield index
*/
public class PutRoleRequest extends ActionRequest<PutRoleRequest> {
public class PutRoleRequest extends ActionRequest<PutRoleRequest> implements WriteRequest<PutRoleRequest> {
private String name;
private String[] clusterPrivileges = Strings.EMPTY_ARRAY;
private List<RoleDescriptor.IndicesPrivileges> indicesPrivileges = new ArrayList<>();
private String[] runAs = Strings.EMPTY_ARRAY;
private boolean refresh = true;
private RefreshPolicy refreshPolicy = RefreshPolicy.IMMEDIATE;
public PutRoleRequest() {
}
@ -69,8 +71,19 @@ public class PutRoleRequest extends ActionRequest<PutRoleRequest> {
this.runAs = usernames;
}
public void refresh(boolean refresh) {
this.refresh = refresh;
@Override
public PutRoleRequest setRefreshPolicy(RefreshPolicy refreshPolicy) {
this.refreshPolicy = refreshPolicy;
return this;
}
/**
* Should this request trigger a refresh ({@linkplain RefreshPolicy#IMMEDIATE}, the default), wait for a refresh (
* {@linkplain RefreshPolicy#WAIT_UNTIL}), or proceed ignore refreshes entirely ({@linkplain RefreshPolicy#NONE}).
*/
@Override
public WriteRequest.RefreshPolicy getRefreshPolicy() {
return refreshPolicy;
}
public String name() {
@ -89,10 +102,6 @@ public class PutRoleRequest extends ActionRequest<PutRoleRequest> {
return runAs;
}
public boolean refresh() {
return refresh;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
@ -104,7 +113,7 @@ public class PutRoleRequest extends ActionRequest<PutRoleRequest> {
indicesPrivileges.add(RoleDescriptor.IndicesPrivileges.createFrom(in));
}
runAs = in.readStringArray();
refresh = in.readBoolean();
refreshPolicy = RefreshPolicy.readFrom(in);
}
@Override
@ -117,7 +126,7 @@ public class PutRoleRequest extends ActionRequest<PutRoleRequest> {
index.writeTo(out);
}
out.writeStringArray(runAs);
out.writeBoolean(refresh);
refreshPolicy.writeTo(out);
}
RoleDescriptor roleDescriptor() {

View File

@ -6,6 +6,7 @@
package org.elasticsearch.shield.action.role;
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.support.WriteRequestBuilder;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.bytes.BytesReference;
@ -14,7 +15,8 @@ import org.elasticsearch.shield.authz.RoleDescriptor;
/**
* Builder for requests to add a role to the administrative index
*/
public class PutRoleRequestBuilder extends ActionRequestBuilder<PutRoleRequest, PutRoleResponse, PutRoleRequestBuilder> {
public class PutRoleRequestBuilder extends ActionRequestBuilder<PutRoleRequest, PutRoleResponse, PutRoleRequestBuilder>
implements WriteRequestBuilder<PutRoleRequestBuilder> {
public PutRoleRequestBuilder(ElasticsearchClient client) {
this(client, PutRoleAction.INSTANCE);
@ -54,9 +56,4 @@ public class PutRoleRequestBuilder extends ActionRequestBuilder<PutRoleRequest,
request.addIndex(indices, privileges, fields, query);
return this;
}
public PutRoleRequestBuilder refresh(boolean refresh) {
request.refresh(refresh);
return this;
}
}

View File

@ -7,6 +7,8 @@ package org.elasticsearch.shield.action.user;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@ -17,12 +19,14 @@ import java.io.IOException;
import static org.elasticsearch.action.ValidateActions.addValidationError;
/**
* Request to change a user's password.
*/
public class ChangePasswordRequest extends ActionRequest<ChangePasswordRequest> implements UserRequest {
public class ChangePasswordRequest extends ActionRequest<ChangePasswordRequest>
implements UserRequest, WriteRequest<ChangePasswordRequest> {
private String username;
private char[] passwordHash;
private boolean refresh = true;
private RefreshPolicy refreshPolicy = RefreshPolicy.IMMEDIATE;
@Override
public ActionRequestValidationException validate() {
@ -52,12 +56,19 @@ public class ChangePasswordRequest extends ActionRequest<ChangePasswordRequest>
this.passwordHash = passwordHash;
}
public boolean refresh() {
return refresh;
/**
* Should this request trigger a refresh ({@linkplain RefreshPolicy#IMMEDIATE}, the default), wait for a refresh (
* {@linkplain RefreshPolicy#WAIT_UNTIL}), or proceed ignore refreshes entirely ({@linkplain RefreshPolicy#NONE}).
*/
@Override
public RefreshPolicy getRefreshPolicy() {
return refreshPolicy;
}
public void refresh(boolean refresh) {
this.refresh = refresh;
@Override
public ChangePasswordRequest setRefreshPolicy(RefreshPolicy refreshPolicy) {
this.refreshPolicy = refreshPolicy;
return this;
}
@Override
@ -70,6 +81,7 @@ public class ChangePasswordRequest extends ActionRequest<ChangePasswordRequest>
super.readFrom(in);
username = in.readString();
passwordHash = CharArrays.utf8BytesToChars(in.readBytesReference().array());
refreshPolicy = RefreshPolicy.readFrom(in);
}
@Override
@ -77,5 +89,6 @@ public class ChangePasswordRequest extends ActionRequest<ChangePasswordRequest>
super.writeTo(out);
out.writeString(username);
out.writeBytesReference(new BytesArray(CharArrays.toUtf8Bytes(passwordHash)));
refreshPolicy.writeTo(out);
}
}

View File

@ -7,25 +7,28 @@ package org.elasticsearch.shield.action.user;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.support.WriteRequestBuilder;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.ValidationException;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.shield.user.User;
import org.elasticsearch.shield.authc.support.Hasher;
import org.elasticsearch.shield.authc.support.SecuredString;
import org.elasticsearch.shield.support.Validation;
import org.elasticsearch.shield.user.User;
import org.elasticsearch.xpack.common.xcontent.XContentUtils;
import java.io.IOException;
import java.util.Arrays;
/**
* Request to change a user's password.
*/
public class ChangePasswordRequestBuilder
extends ActionRequestBuilder<ChangePasswordRequest, ChangePasswordResponse, ChangePasswordRequestBuilder> {
extends ActionRequestBuilder<ChangePasswordRequest, ChangePasswordResponse, ChangePasswordRequestBuilder>
implements WriteRequestBuilder<ChangePasswordRequestBuilder> {
public ChangePasswordRequestBuilder(ElasticsearchClient client) {
this(client, ChangePasswordAction.INSTANCE);
@ -81,9 +84,4 @@ public class ChangePasswordRequestBuilder
}
return this;
}
public ChangePasswordRequestBuilder refresh(boolean refresh) {
request.refresh(refresh);
return this;
}
}

View File

@ -7,6 +7,8 @@ package org.elasticsearch.shield.action.user;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
@ -22,7 +24,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
/**
* Request object to put a native user.
*/
public class PutUserRequest extends ActionRequest<PutUserRequest> implements UserRequest {
public class PutUserRequest extends ActionRequest<PutUserRequest> implements UserRequest, WriteRequest<PutUserRequest> {
private String username;
private String[] roles;
@ -30,7 +32,7 @@ public class PutUserRequest extends ActionRequest<PutUserRequest> implements Use
private String email;
private Map<String, Object> metadata;
private char[] passwordHash;
private boolean refresh = true;
private RefreshPolicy refreshPolicy = RefreshPolicy.IMMEDIATE;
public PutUserRequest() {
}
@ -72,8 +74,19 @@ public class PutUserRequest extends ActionRequest<PutUserRequest> implements Use
this.passwordHash = passwordHash;
}
public void refresh(boolean refresh) {
this.refresh = refresh;
/**
* Should this request trigger a refresh ({@linkplain RefreshPolicy#IMMEDIATE}, the default), wait for a refresh (
* {@linkplain RefreshPolicy#WAIT_UNTIL}), or proceed ignore refreshes entirely ({@linkplain RefreshPolicy#NONE}).
*/
@Override
public RefreshPolicy getRefreshPolicy() {
return refreshPolicy;
}
@Override
public PutUserRequest setRefreshPolicy(RefreshPolicy refreshPolicy) {
this.refreshPolicy = refreshPolicy;
return this;
}
public String username() {
@ -101,10 +114,6 @@ public class PutUserRequest extends ActionRequest<PutUserRequest> implements Use
return passwordHash;
}
public boolean refresh() {
return refresh;
}
@Override
public String[] usernames() {
return new String[] { username };
@ -124,7 +133,7 @@ public class PutUserRequest extends ActionRequest<PutUserRequest> implements Use
fullName = in.readOptionalString();
email = in.readOptionalString();
metadata = in.readBoolean() ? in.readMap() : null;
refresh = in.readBoolean();
refreshPolicy = RefreshPolicy.readFrom(in);
}
@Override
@ -147,6 +156,6 @@ public class PutUserRequest extends ActionRequest<PutUserRequest> implements Use
out.writeBoolean(true);
out.writeMap(metadata);
}
out.writeBoolean(refresh);
refreshPolicy.writeTo(out);
}
}

View File

@ -7,6 +7,7 @@ package org.elasticsearch.shield.action.user;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.support.WriteRequestBuilder;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseFieldMatcher;
@ -15,17 +16,18 @@ import org.elasticsearch.common.ValidationException;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.shield.user.User;
import org.elasticsearch.shield.authc.support.Hasher;
import org.elasticsearch.shield.authc.support.SecuredString;
import org.elasticsearch.shield.support.Validation;
import org.elasticsearch.shield.user.User;
import org.elasticsearch.xpack.common.xcontent.XContentUtils;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
public class PutUserRequestBuilder extends ActionRequestBuilder<PutUserRequest, PutUserResponse, PutUserRequestBuilder> {
public class PutUserRequestBuilder extends ActionRequestBuilder<PutUserRequest, PutUserResponse, PutUserRequestBuilder>
implements WriteRequestBuilder<PutUserRequestBuilder> {
private final Hasher hasher = Hasher.BCRYPT;
@ -77,11 +79,6 @@ public class PutUserRequestBuilder extends ActionRequestBuilder<PutUserRequest,
return this;
}
public PutUserRequestBuilder refresh(boolean refresh) {
request.refresh(refresh);
return this;
}
public PutUserRequestBuilder source(String username, BytesReference source) throws IOException {
username(username);
try (XContentParser parser = XContentHelper.createParser(source)) {

View File

@ -9,6 +9,7 @@ import com.carrotsearch.hppc.ObjectHashSet;
import com.carrotsearch.hppc.ObjectLongHashMap;
import com.carrotsearch.hppc.ObjectLongMap;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
@ -23,6 +24,7 @@ import org.elasticsearch.action.search.ClearScrollResponse;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchScrollRequest;
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterChangedEvent;
@ -49,9 +51,6 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.shield.InternalClient;
import org.elasticsearch.shield.ShieldTemplateService;
import org.elasticsearch.shield.user.SystemUser;
import org.elasticsearch.shield.user.User;
import org.elasticsearch.shield.user.User.Fields;
import org.elasticsearch.shield.action.realm.ClearRealmCacheRequest;
import org.elasticsearch.shield.action.realm.ClearRealmCacheResponse;
import org.elasticsearch.shield.action.user.ChangePasswordRequest;
@ -61,6 +60,9 @@ import org.elasticsearch.shield.authc.support.Hasher;
import org.elasticsearch.shield.authc.support.SecuredString;
import org.elasticsearch.shield.client.SecurityClient;
import org.elasticsearch.shield.support.SelfReschedulingRunnable;
import org.elasticsearch.shield.user.SystemUser;
import org.elasticsearch.shield.user.User;
import org.elasticsearch.shield.user.User.Fields;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPool.Names;
@ -324,7 +326,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
client.prepareUpdate(ShieldTemplateService.SECURITY_INDEX_NAME, docType, username)
.setDoc(Fields.PASSWORD.getPreferredName(), String.valueOf(request.passwordHash()))
.setRefresh(request.refresh())
.setRefreshPolicy(request.getRefreshPolicy())
.execute(new ActionListener<UpdateResponse>() {
@Override
public void onResponse(UpdateResponse updateResponse) {
@ -345,7 +347,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
}
if (docType.equals(RESERVED_USER_DOC_TYPE)) {
createReservedUser(username, request.passwordHash(), request.refresh(), listener);
createReservedUser(username, request.passwordHash(), request.getRefreshPolicy(), listener);
} else {
logger.debug("failed to change password for user [{}]", cause, request.username());
ValidationException validationException = new ValidationException();
@ -356,10 +358,10 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
});
}
private void createReservedUser(String username, char[] passwordHash, boolean refresh, ActionListener<Void> listener) {
private void createReservedUser(String username, char[] passwordHash, RefreshPolicy refresh, ActionListener<Void> listener) {
client.prepareIndex(ShieldTemplateService.SECURITY_INDEX_NAME, RESERVED_USER_DOC_TYPE, username)
.setSource(Fields.PASSWORD.getPreferredName(), String.valueOf(passwordHash))
.setRefresh(refresh)
.setRefreshPolicy(refresh)
.execute(new ActionListener<IndexResponse>() {
@Override
public void onResponse(IndexResponse indexResponse) {
@ -400,7 +402,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
User.Fields.FULL_NAME.getPreferredName(), putUserRequest.fullName(),
User.Fields.EMAIL.getPreferredName(), putUserRequest.email(),
User.Fields.METADATA.getPreferredName(), putUserRequest.metadata())
.setRefresh(putUserRequest.refresh())
.setRefreshPolicy(putUserRequest.getRefreshPolicy())
.execute(new ActionListener<UpdateResponse>() {
@Override
public void onResponse(UpdateResponse updateResponse) {
@ -440,7 +442,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
User.Fields.FULL_NAME.getPreferredName(), putUserRequest.fullName(),
User.Fields.EMAIL.getPreferredName(), putUserRequest.email(),
User.Fields.METADATA.getPreferredName(), putUserRequest.metadata())
.setRefresh(putUserRequest.refresh())
.setRefreshPolicy(putUserRequest.getRefreshPolicy())
.execute(new ActionListener<IndexResponse>() {
@Override
public void onResponse(IndexResponse indexResponse) {
@ -470,7 +472,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
DeleteRequest request = client.prepareDelete(ShieldTemplateService.SECURITY_INDEX_NAME,
USER_DOC_TYPE, deleteUserRequest.username()).request();
request.indicesOptions().ignoreUnavailable();
request.refresh(deleteUserRequest.refresh());
request.setRefreshPolicy(deleteUserRequest.refresh() ? RefreshPolicy.IMMEDIATE : RefreshPolicy.WAIT_UNTIL);
client.delete(request, new ActionListener<DeleteResponse>() {
@Override
public void onResponse(DeleteResponse deleteResponse) {

View File

@ -18,6 +18,7 @@ import org.elasticsearch.action.search.ClearScrollResponse;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchScrollRequest;
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterState;
@ -269,7 +270,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
try {
DeleteRequest request = client.prepareDelete(ShieldTemplateService.SECURITY_INDEX_NAME,
ROLE_DOC_TYPE, deleteRoleRequest.name()).request();
request.refresh(deleteRoleRequest.refresh());
request.setRefreshPolicy(deleteRoleRequest.refresh() ? RefreshPolicy.IMMEDIATE : RefreshPolicy.WAIT_UNTIL);
client.delete(request, new ActionListener<DeleteResponse>() {
@Override
public void onResponse(DeleteResponse deleteResponse) {
@ -299,7 +300,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
try {
client.prepareIndex(ShieldTemplateService.SECURITY_INDEX_NAME, ROLE_DOC_TYPE, role.getName())
.setSource(role.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS))
.setRefresh(request.refresh())
.setRefreshPolicy(request.getRefreshPolicy())
.execute(new ActionListener<IndexResponse>() {
@Override
public void onResponse(IndexResponse indexResponse) {

View File

@ -36,9 +36,7 @@ public class RestPutRoleAction extends BaseRestHandler {
@Override
protected void handleRequest(RestRequest request, final RestChannel channel, Client client) throws Exception {
PutRoleRequestBuilder requestBuilder = new SecurityClient(client).preparePutRole(request.param("name"), request.content());
if (request.hasParam("refresh")) {
requestBuilder.refresh(request.paramAsBoolean("refresh", true));
}
requestBuilder.setRefreshPolicy(request.param("refresh"));
requestBuilder.execute(new RestBuilderListener<PutRoleResponse>(channel) {
@Override
public RestResponse buildResponse(PutRoleResponse putRoleResponse, XContentBuilder builder) throws Exception {

View File

@ -47,7 +47,7 @@ public class RestChangePasswordAction extends BaseRestHandler {
}
new SecurityClient(client).prepareChangePassword(username, request.content())
.refresh(request.paramAsBoolean("refresh", true))
.setRefreshPolicy(request.param("refresh"))
.execute(new RestBuilderListener<ChangePasswordResponse>(channel) {
@Override
public RestResponse buildResponse(ChangePasswordResponse changePasswordResponse, XContentBuilder builder) throws

View File

@ -37,7 +37,7 @@ public class RestPutUserAction extends BaseRestHandler {
protected void handleRequest(RestRequest request, final RestChannel channel, Client client) throws Exception {
PutUserRequestBuilder requestBuilder = new SecurityClient(client).preparePutUser(request.param("username"), request.content());
if (request.hasParam("refresh")) {
requestBuilder.refresh(request.paramAsBoolean("refresh", true));
requestBuilder.setRefreshPolicy(request.param("refresh"));
}
requestBuilder.execute(new RestBuilderListener<PutUserResponse>(channel) {
@Override

View File

@ -32,10 +32,13 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.NONE;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
/**
* Test for the Shield clear roles API that changes the polling aspect of shield to only run once an hour in order to
* test the cache clearing APIs.
@ -92,13 +95,12 @@ public class ClearRolesCacheTests extends NativeRealmIntegTestCase {
int modifiedRolesCount = randomIntBetween(1, roles.length);
List<String> toModify = randomSubsetOf(modifiedRolesCount, roles);
logger.debug("--> modifying roles {} to have run_as", toModify);
final boolean refresh = randomBoolean();
for (String role : toModify) {
PutRoleResponse response = securityClient.preparePutRole(role)
.cluster("none")
.addIndices(new String[] { "*" }, new String[] { "ALL" }, null, null)
.runAs(role)
.refresh(refresh)
.setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE)
.get();
assertThat(response.isCreated(), is(false));
logger.debug("--> updated role [{}] with run_as", role);
@ -116,7 +118,7 @@ public class ClearRolesCacheTests extends NativeRealmIntegTestCase {
UpdateResponse response = internalClient().prepareUpdate().setId(role).setIndex(ShieldTemplateService.SECURITY_INDEX_NAME)
.setType(NativeRolesStore.ROLE_DOC_TYPE)
.setDoc("run_as", new String[] { role })
.setRefresh(refresh)
.setRefreshPolicy(refresh ? IMMEDIATE : NONE)
.get();
assertThat(response.isCreated(), is(false));
logger.debug("--> updated role [{}] with run_as", role);
@ -159,7 +161,7 @@ public class ClearRolesCacheTests extends NativeRealmIntegTestCase {
final boolean refresh = randomBoolean();
DeleteResponse response = internalClient()
.prepareDelete(ShieldTemplateService.SECURITY_INDEX_NAME, NativeRolesStore.ROLE_DOC_TYPE, role)
.setRefresh(refresh)
.setRefreshPolicy(refresh ? IMMEDIATE : NONE)
.get();
assertThat(response.isFound(), is(true));

View File

@ -23,6 +23,8 @@ import org.elasticsearch.test.ShieldIntegTestCase;
import java.util.Collections;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.NONE;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
@ -64,7 +66,8 @@ public class DateMathExpressionIntegTests extends ShieldIntegTestCase {
CreateIndexResponse response = client.admin().indices().prepareCreate(expression).get();
assertThat(response.isAcknowledged(), is(true));
}
IndexResponse response = client.prepareIndex(expression, "type").setSource("foo", "bar").setRefresh(refeshOnOperation).get();
IndexResponse response = client.prepareIndex(expression, "type").setSource("foo", "bar")
.setRefreshPolicy(refeshOnOperation ? IMMEDIATE : NONE).get();
assertThat(response.isCreated(), is(true));
assertThat(response.getIndex(), containsString(expectedIndexName));
@ -84,7 +87,7 @@ public class DateMathExpressionIntegTests extends ShieldIntegTestCase {
UpdateResponse updateResponse = client.prepareUpdate(expression, "type", response.getId())
.setDoc("new", "field")
.setRefresh(refeshOnOperation)
.setRefreshPolicy(refeshOnOperation ? IMMEDIATE : NONE)
.get();
assertThat(updateResponse.isCreated(), is(false));

View File

@ -17,6 +17,7 @@ import org.elasticsearch.xpack.XPackPlugin;
import java.util.Collections;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.BASIC_AUTH_HEADER;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@ -94,10 +95,10 @@ public class DocumentAndFieldLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text", "field2", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type1", "2").setSource("field2", "value2")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
SearchResponse response = client().filterWithHeader(
@ -133,10 +134,10 @@ public class DocumentAndFieldLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text", "field2", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type1", "2").setSource("field2", "value2")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// Both users have the same role query, but user3 has access to field2 and not field1, which should result in zero hits:

View File

@ -33,6 +33,7 @@ import org.elasticsearch.xpack.XPackPlugin;
import java.util.Collections;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
import static org.elasticsearch.index.query.QueryBuilders.hasParentQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
@ -108,13 +109,13 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text", "field2", "type=text", "field3", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type1", "2").setSource("field2", "value2")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type1", "3").setSource("field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
SearchResponse response = client()
@ -289,13 +290,13 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
"field3", "type=text,term_vector=with_positions_offsets_payloads")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type1", "2").setSource("field2", "value2")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type1", "3").setSource("field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
boolean realtime = randomBoolean();
@ -354,13 +355,13 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
"field3", "type=text,term_vector=with_positions_offsets_payloads")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type1", "2").setSource("field2", "value2")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type1", "3").setSource("field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
boolean realtime = randomBoolean();
@ -419,13 +420,13 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text", "field2", "type=text,fielddata=true", "field3", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type1", "2").setSource("field2", "value2")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type1", "3").setSource("field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
SearchResponse response = client().prepareSearch("test")
@ -483,11 +484,11 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type2", "_parent", "type=type1", "field3", "type=text,fielddata=true")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test", "type2", "2").setSource("field3", "value3")
.setParent("1")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
SearchResponse response = client().prepareSearch("test")
@ -705,7 +706,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type", "field1", "type=text", "field2", "type=text")
);
client().prepareIndex("test", "type", "1").setSource("field1", "value1")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// With document level security enabled the update is not allowed:

View File

@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.BASIC_AUTH_HEADER;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
@ -141,7 +142,7 @@ public class FieldLevelSecurityRandomTests extends ShieldIntegTestCase {
assertAcked(client().admin().indices().prepareCreate("test")
.addMapping("type1", (Object[])fieldMappers)
);
client().prepareIndex("test", "type1", "1").setSource(doc).setRefresh(true).get();
client().prepareIndex("test", "type1", "1").setSource(doc).setRefreshPolicy(IMMEDIATE).get();
for (String allowedField : allowedFields) {
logger.info("Checking allowed field [{}]", allowedField);

View File

@ -32,6 +32,7 @@ import org.elasticsearch.xpack.XPackPlugin;
import java.util.Collections;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
@ -136,7 +137,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text", "field2", "type=text", "field3", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2", "field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// user1 has access to field1, so the query should match with the document:
@ -488,7 +489,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text", "field2", "type=text", "field3", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2", "field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// user1 is granted access to field1 only:
@ -622,7 +623,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text", "field2", "type=text", "field3", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2", "field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
int max = scaledRandomIntBetween(4, 32);
@ -660,7 +661,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text", "field2", "type=text", "field3", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
int max = scaledRandomIntBetween(4, 32);
@ -702,7 +703,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
"field3", "type=text,store=true")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2", "field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// user1 is granted access to field1 only:
@ -799,7 +800,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text", "field2", "type=text", "field3", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2", "field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// user1 is granted access to field1 only:
@ -873,7 +874,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
);
client().prepareIndex("test", "type1", "1").setSource("field1", 1d, "field2", 2d)
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// user1 is granted to use field1, so it is included in the sort_values
@ -911,7 +912,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text,fielddata=true", "field2", "type=text,fielddata=true")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// user1 is authorized to use field1, so buckets are include for a term agg on field1
@ -951,7 +952,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
"field3", "type=text,term_vector=with_positions_offsets_payloads")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2", "field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
boolean realtime = randomBoolean();
@ -1035,7 +1036,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
"field3", "type=text,term_vector=with_positions_offsets_payloads")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2", "field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
boolean realtime = randomBoolean();
@ -1155,7 +1156,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
);
client().prepareIndex("test", "type", "1")
.setSource("field1", "value1", "field2", "value1")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// With field level security enabled the update is not allowed:
@ -1200,7 +1201,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.addMapping("type1", "field1", "type=text", "field2", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// user6 has access to all fields, so the query should match with the document:

View File

@ -16,6 +16,7 @@ import org.elasticsearch.xpack.XPackPlugin;
import java.util.Collections;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.BASIC_AUTH_HEADER;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@ -72,7 +73,7 @@ public class IndicesPermissionsWithAliasesWildcardsAndRegexsTests extends Shield
.addAlias(new Alias("an_alias"))
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2", "field3", "value3")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
GetResponse getResponse = client()

View File

@ -25,6 +25,7 @@ import org.elasticsearch.test.ShieldIntegTestCase;
import java.util.Locale;
import static java.util.Collections.singletonMap;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
@ -183,7 +184,7 @@ public class KibanaUserRoleIntegTests extends ShieldIntegTestCase {
.setIndex(index)
.setType("dashboard")
.setSource("foo", "bar")
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
assertThat(response.isCreated(), is(true));

View File

@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.BASIC_AUTH_HEADER;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
@ -63,7 +64,7 @@ public class ShieldClearScrollTests extends ShieldIntegTestCase {
@Before
public void indexRandomDocuments() {
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk().setRefresh(true);
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk().setRefreshPolicy(IMMEDIATE);
for (int i = 0; i < randomIntBetween(10, 50); i++) {
bulkRequestBuilder.add(client().prepareIndex("index", "type", String.valueOf(i)).setSource("{ \"foo\" : \"bar\" }"));
}

View File

@ -17,6 +17,7 @@ import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.indices.breaker.CircuitBreakerModule;
import org.elasticsearch.shield.audit.logfile.LoggingAuditTrail;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPoolModule;
import org.elasticsearch.transport.Transport;
@ -55,7 +56,7 @@ public class AuditTrailModuleTests extends ESTestCase {
.put(AuditTrailModule.ENABLED_SETTING.getKey(), true)
.put("client.type", "node")
.build();
ThreadPool pool = new ThreadPool("testLogFile");
ThreadPool pool = new TestThreadPool("testLogFile");
try {
SettingsModule settingsModule = new SettingsModule(settings);
settingsModule.registerSetting(AuditTrailModule.ENABLED_SETTING);

View File

@ -25,6 +25,7 @@ import org.elasticsearch.shield.transport.filter.ShieldIpFilterRule;
import org.elasticsearch.shield.user.SystemUser;
import org.elasticsearch.shield.user.User;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportMessage;
@ -58,7 +59,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase {
when(transport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { DummyTransportAddress.INSTANCE },
DummyTransportAddress.INSTANCE));
threadPool = new ThreadPool("index audit trail tests");
threadPool = new TestThreadPool("index audit trail tests");
transportClient = TransportClient.builder().settings(Settings.EMPTY).build();
clientCalled = new AtomicBoolean(false);
client = new InternalClient(transportClient) {

View File

@ -43,6 +43,7 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.ShieldIntegTestCase;
import org.elasticsearch.test.ShieldSettingsSource;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportInfo;
@ -260,7 +261,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
BoundTransportAddress boundTransportAddress = new BoundTransportAddress(new TransportAddress[]{DummyTransportAddress.INSTANCE},
DummyTransportAddress.INSTANCE);
when(transport.boundAddress()).thenReturn(boundTransportAddress);
threadPool = new ThreadPool("index audit trail tests");
threadPool = new TestThreadPool("index audit trail tests");
enqueuedMessage = new SetOnce<>();
auditor = new IndexAuditTrail(settings, transport, Providers.of(internalClient()), threadPool, mock(ClusterService.class)) {
@Override

View File

@ -14,6 +14,7 @@ import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.test.ShieldIntegTestCase;
import org.elasticsearch.test.rest.FakeRestRequest;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
import org.junit.After;
@ -39,7 +40,7 @@ public class IndexAuditTrailUpdateMappingTests extends ShieldIntegTestCase {
@Before
public void setup() {
threadPool = new ThreadPool("index audit trail update mapping tests");
threadPool = new TestThreadPool("index audit trail update mapping tests");
}
public void testMappingIsUpdated() throws Exception {

View File

@ -22,6 +22,7 @@ import org.elasticsearch.shield.authc.support.SecuredString;
import org.elasticsearch.shield.authc.support.SecuredStringTests;
import org.elasticsearch.shield.authc.support.UsernamePasswordToken;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.junit.After;
@ -92,7 +93,7 @@ public class ActiveDirectoryRealmTests extends ESTestCase {
directoryServer.startListening();
directoryServers[i] = directoryServer;
}
threadPool = new ThreadPool("active directory realm tests");
threadPool = new TestThreadPool("active directory realm tests");
resourceWatcherService = new ResourceWatcherService(Settings.EMPTY, threadPool);
globalSettings = Settings.builder().put("path.home", createTempDir()).build();
}

View File

@ -44,6 +44,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.containsString;
@ -205,7 +206,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase {
createIndex("idx");
ensureGreen("idx");
// Index a document with the default test user
client().prepareIndex("idx", "doc", "1").setSource("body", "foo").setRefresh(true).get();
client().prepareIndex("idx", "doc", "1").setSource("body", "foo").setRefreshPolicy(IMMEDIATE).get();
String token = basicAuthHeaderValue("joe", new SecuredString("s3krit".toCharArray()));
SearchResponse searchResp = client().filterWithHeader(Collections.singletonMap("Authorization", token)).prepareSearch("idx").get();
@ -227,7 +228,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase {
createIndex("idx");
ensureGreen("idx");
// Index a document with the default test user
client().prepareIndex("idx", "doc", "1").setSource("body", "foo").setRefresh(true).get();
client().prepareIndex("idx", "doc", "1").setSource("body", "foo").setRefreshPolicy(IMMEDIATE).get();
String token = basicAuthHeaderValue("joe", new SecuredString("s3krit".toCharArray()));
SearchResponse searchResp = client().filterWithHeader(Collections.singletonMap("Authorization", token)).prepareSearch("idx").get();
@ -262,7 +263,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase {
createIndex("idx");
ensureGreen("idx");
// Index a document with the default test user
client().prepareIndex("idx", "doc", "1").setSource("body", "foo").setRefresh(true).get();
client().prepareIndex("idx", "doc", "1").setSource("body", "foo").setRefreshPolicy(IMMEDIATE).get();
String token = basicAuthHeaderValue("joe", new SecuredString("s3krit".toCharArray()));
SearchResponse searchResp = client().filterWithHeader(Collections.singletonMap("Authorization", token)).prepareSearch("idx").get();

View File

@ -16,6 +16,7 @@ import org.elasticsearch.shield.authc.support.Hasher;
import org.elasticsearch.shield.authc.support.RefreshListener;
import org.elasticsearch.shield.authc.support.SecuredStringTests;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.junit.After;
@ -62,7 +63,7 @@ public class FileUserPasswdStoreTests extends ESTestCase {
.put("path.home", createTempDir())
.build();
env = new Environment(settings);
threadPool = new ThreadPool("test");
threadPool = new TestThreadPool("test");
}
@After

View File

@ -15,6 +15,7 @@ import org.elasticsearch.shield.audit.logfile.CapturingLogger;
import org.elasticsearch.shield.authc.RealmConfig;
import org.elasticsearch.shield.authc.support.RefreshListener;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.elasticsearch.xpack.XPackPlugin;
@ -63,7 +64,7 @@ public class FileUserRolesStoreTests extends ESTestCase {
.put("path.home", createTempDir())
.build();
env = new Environment(settings);
threadPool = new ThreadPool("test");
threadPool = new TestThreadPool("test");
}
@After
@ -224,7 +225,7 @@ public class FileUserRolesStoreTests extends ESTestCase {
public void testParseFileEmptyRolesDoesNotCauseNPE() throws Exception {
ThreadPool threadPool = null;
try {
threadPool = new ThreadPool("test");
threadPool = new TestThreadPool("test");
Path usersRoles = writeUsersRoles("role1:admin");
Settings settings = Settings.builder()

View File

@ -15,6 +15,7 @@ import org.elasticsearch.shield.authc.support.SecuredString;
import org.elasticsearch.shield.authc.support.SecuredStringTests;
import org.elasticsearch.shield.authc.support.UsernamePasswordToken;
import org.elasticsearch.shield.user.User;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.junit.After;
@ -49,7 +50,7 @@ public class LdapRealmTests extends LdapTestCase {
@Before
public void init() throws Exception {
threadPool = new ThreadPool("ldap realm tests");
threadPool = new TestThreadPool("ldap realm tests");
resourceWatcherService = new ResourceWatcherService(Settings.EMPTY, threadPool);
globalSettings = Settings.builder().put("path.home", createTempDir()).build();
}

View File

@ -13,6 +13,7 @@ import org.elasticsearch.shield.authc.RealmConfig;
import org.elasticsearch.shield.authc.activedirectory.ActiveDirectoryRealm;
import org.elasticsearch.shield.authc.ldap.LdapRealm;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.junit.After;
@ -69,7 +70,7 @@ public class DnRoleMapperTests extends ESTestCase {
.put("path.home", createTempDir())
.build();
env = new Environment(settings);
threadPool = new ThreadPool("test");
threadPool = new TestThreadPool("test");
}
@After

View File

@ -17,6 +17,7 @@ import org.elasticsearch.shield.authz.permission.RunAsPermission;
import org.elasticsearch.shield.authz.privilege.ClusterPrivilege;
import org.elasticsearch.shield.authz.privilege.IndexPrivilege;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.elasticsearch.xpack.XPackPlugin;
@ -257,7 +258,7 @@ public class FileRolesStoreTests extends ESTestCase {
.build();
Environment env = new Environment(settings);
threadPool = new ThreadPool("test");
threadPool = new TestThreadPool("test");
watcherService = new ResourceWatcherService(settings, threadPool);
final CountDownLatch latch = new CountDownLatch(1);
FileRolesStore store = new FileRolesStore(settings, env, watcherService, new RefreshListener() {

View File

@ -10,6 +10,7 @@ import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.junit.After;
@ -53,7 +54,7 @@ public class InternalCryptoServiceTests extends ESTestCase {
.put("path.home", createTempDir())
.build();
env = new Environment(settings);
threadPool = new ThreadPool("test");
threadPool = new TestThreadPool("test");
watcherService = new ResourceWatcherService(settings, threadPool);
watcherService.start();
}

View File

@ -15,6 +15,7 @@ import org.elasticsearch.shield.ssl.SSLConfiguration.Custom;
import org.elasticsearch.shield.ssl.SSLConfiguration.Global;
import org.elasticsearch.shield.ssl.TrustConfig.Reloadable.Listener;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
@ -321,7 +322,7 @@ public class SSLConfigurationTests extends ESTestCase {
AtomicReference<Exception> exceptionRef = new AtomicReference<>();
Listener listener = createRefreshListener(latch, exceptionRef);
ThreadPool threadPool = new ThreadPool("reload");
ThreadPool threadPool = new TestThreadPool("reload");
try {
ResourceWatcherService resourceWatcherService =
new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start();
@ -384,7 +385,7 @@ public class SSLConfigurationTests extends ESTestCase {
AtomicReference<Exception> exceptionRef = new AtomicReference<>();
Listener listener = createRefreshListener(latch, exceptionRef);
ThreadPool threadPool = new ThreadPool("reload pem");
ThreadPool threadPool = new TestThreadPool("reload pem");
try {
ResourceWatcherService resourceWatcherService =
new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start();
@ -460,7 +461,7 @@ public class SSLConfigurationTests extends ESTestCase {
AtomicReference<Exception> exceptionRef = new AtomicReference<>();
Listener listener = createRefreshListener(latch, exceptionRef);
ThreadPool threadPool = new ThreadPool("reload");
ThreadPool threadPool = new TestThreadPool("reload");
try {
ResourceWatcherService resourceWatcherService =
new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start();
@ -506,7 +507,7 @@ public class SSLConfigurationTests extends ESTestCase {
AtomicReference<Exception> exceptionRef = new AtomicReference<>();
Listener listener = createRefreshListener(latch, exceptionRef);
ThreadPool threadPool = new ThreadPool("reload");
ThreadPool threadPool = new TestThreadPool("reload");
try {
ResourceWatcherService resourceWatcherService =
new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start();
@ -554,7 +555,7 @@ public class SSLConfigurationTests extends ESTestCase {
AtomicReference<Exception> exceptionRef = new AtomicReference<>();
Listener listener = createRefreshListener(latch, exceptionRef);
ThreadPool threadPool = new ThreadPool("reload");
ThreadPool threadPool = new TestThreadPool("reload");
try {
ResourceWatcherService resourceWatcherService =
new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start();
@ -603,7 +604,7 @@ public class SSLConfigurationTests extends ESTestCase {
AtomicReference<Exception> exceptionRef = new AtomicReference<>();
Listener listener = createRefreshListener(latch, exceptionRef);
ThreadPool threadPool = new ThreadPool("reload pem");
ThreadPool threadPool = new TestThreadPool("reload pem");
try {
ResourceWatcherService resourceWatcherService =
new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start();
@ -654,7 +655,7 @@ public class SSLConfigurationTests extends ESTestCase {
AtomicReference<Exception> exceptionRef = new AtomicReference<>();
Listener listener = createRefreshListener(latch, exceptionRef);
ThreadPool threadPool = new ThreadPool("reload");
ThreadPool threadPool = new TestThreadPool("reload");
try {
ResourceWatcherService resourceWatcherService =
new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start();
@ -693,7 +694,7 @@ public class SSLConfigurationTests extends ESTestCase {
AtomicReference<Exception> exceptionRef = new AtomicReference<>();
Listener listener = createRefreshListener(latch, exceptionRef);
ThreadPool threadPool = new ThreadPool("reload");
ThreadPool threadPool = new TestThreadPool("reload");
try {
ResourceWatcherService resourceWatcherService =
new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start();

View File

@ -10,6 +10,7 @@ import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPool.Names;
@ -189,7 +190,7 @@ public class SelfReschedulingRunnableTests extends ESTestCase {
}
public void testStopPreventsRunning() throws Exception {
final ThreadPool threadPool = new ThreadPool("test-stop-self-schedule");
final ThreadPool threadPool = new TestThreadPool("test-stop-self-schedule");
final AtomicInteger failureCounter = new AtomicInteger(0);
final AtomicInteger runCounter = new AtomicInteger(0);
final AbstractRunnable runnable = new AbstractRunnable() {
@ -232,7 +233,7 @@ public class SelfReschedulingRunnableTests extends ESTestCase {
}
public void testStopPreventsRescheduling() throws Exception {
final ThreadPool threadPool = new ThreadPool("test-stop-self-schedule");
final ThreadPool threadPool = new TestThreadPool("test-stop-self-schedule");
final CountDownLatch threadRunningLatch = new CountDownLatch(randomIntBetween(1, 16));
final CountDownLatch stopCalledLatch = new CountDownLatch(1);
final AbstractRunnable runnable = new AbstractRunnable() {

View File

@ -217,7 +217,7 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ
return getSSLSettingsForPEMFiles("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.pem", "testnode",
Collections.singletonList("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.crt"),
Arrays.asList("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode-client-profile.crt",
"/org/elasticsearch/shield/transport/ssl/certs/simple/activedir.crt",
"/org/elasticsearch/shield/transport/ssl/certs/simple/active-directory-ca.crt",
"/org/elasticsearch/shield/transport/ssl/certs/simple/testclient.crt",
"/org/elasticsearch/shield/transport/ssl/certs/simple/openldap.crt",
"/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.crt"),

View File

@ -9,12 +9,12 @@ import org.apache.lucene.util.IOUtils;
import org.elasticsearch.action.Action;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.graph.Graph;
import org.elasticsearch.license.plugin.Licensing;
import org.elasticsearch.shield.action.ShieldActionModule;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ShieldIntegTestCase;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.graph.Graph;
import org.junit.BeforeClass;
import java.io.IOException;

View File

@ -0,0 +1,23 @@
-----BEGIN CERTIFICATE-----
MIID1zCCAr+gAwIBAgIQWA24rVK7FopAgOHfEio/VjANBgkqhkiG9w0BAQsFADB+
MRMwEQYKCZImiZPyLGQBGRYDY29tMR0wGwYKCZImiZPyLGQBGRYNZWxhc3RpY3Nl
YXJjaDEUMBIGCgmSJomT8ixkARkWBHRlc3QxEjAQBgoJkiaJk/IsZAEZFgJhZDEe
MBwGA1UEAxMVYWQtRUxBU1RJQ1NFQVJDSEFELUNBMB4XDTE0MDgyNzE2MjI0MloX
DTI5MDgyNzE2MzI0MlowfjETMBEGCgmSJomT8ixkARkWA2NvbTEdMBsGCgmSJomT
8ixkARkWDWVsYXN0aWNzZWFyY2gxFDASBgoJkiaJk/IsZAEZFgR0ZXN0MRIwEAYK
CZImiZPyLGQBGRYCYWQxHjAcBgNVBAMTFWFkLUVMQVNUSUNTRUFSQ0hBRC1DQTCC
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALNNZsDJ+lhsE/pCIkNlq6/F
xwv3PU2M+E1/SbWrLEtfbb1ATnn98DwxjpCj00wS0bt26/7zrhHKyX5LaxyS27ER
8bKpLSO4qcVWzDIQnVNk2XfBrYS/Og+6Pi/Lw/ylt/vE++kHWIJBc4O6i+pPByOM
oypM6bh71kTkpK8OTPqf+HiPp0qKhRah6XVtqTc+kOCOku2+wkELbCz8RNzF9ca6
Uu3YxLi73pNdk0wDTmg6JVaUyVRpSkjJH4BAp9SVma6Rxy6tbh4e5P+8K8lY9ptM
TBzTsDS1EhNK/92xULfQbGT814Z294pF3ARMEJ89N+aegS++kz7CqjciZ1+bA6EC
AwEAAaNRME8wCwYDVR0PBAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
FIEKG0KdSVNknKcMZkbTlKo7N8MjMBAGCSsGAQQBgjcVAQQDAgEAMA0GCSqGSIb3
DQEBCwUAA4IBAQBgbWBXPbEMTEsiVWzoxmTw1wJASBdPahx6CggutjGq3ASjby4p
nVCTwE4xdDEVyFGmeslSp9+23XjBuaiqVPtYw8P8hnG269J0q4cOF/VXOccRLeOw
HVDBv2a7xzgBSwc1KB50TLv07stcBmBYNu8anN6EwGksdgjb8IjRV6U3U+IvFNrI
rGifuIc/iRZD4Clhnpxw8tCsgcrcmz9CU7CN5RxKVEpZ6ou6ZjHO8l8H0t9zWrSI
PL+33iBGHNWlyU63N93XgJtxV1em1hHryLtTTtaVZJJ3R0OrLrUpG8SQ7zCUy62f
YtImFPClUMXY03yH+4DAhflueRvY/D1AKL12
-----END CERTIFICATE-----

View File

@ -1,38 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIGkjCCBXqgAwIBAgITSwAAAAP/F57VuIEUDQAAAAAAAzANBgkqhkiG9w0BAQsF
ADB+MRMwEQYKCZImiZPyLGQBGRYDY29tMR0wGwYKCZImiZPyLGQBGRYNZWxhc3Rp
Y3NlYXJjaDEUMBIGCgmSJomT8ixkARkWBHRlc3QxEjAQBgoJkiaJk/IsZAEZFgJh
ZDEeMBwGA1UEAxMVYWQtRUxBU1RJQ1NFQVJDSEFELUNBMB4XDTE1MDcxNjE4MzI1
MFoXDTE2MDcxNTE4MzI1MFowODE2MDQGA1UEAxMtRWxhc3RpY1NlYXJjaEFkVGVz
dC5hZC50ZXN0LmVsYXN0aWNzZWFyY2guY29tMIIBIjANBgkqhkiG9w0BAQEFAAOC
AQ8AMIIBCgKCAQEAqO9hYAASE1ZFdTnm784j58JvpQySpx81LvecQl4gE4d2yJk6
9ibn8cgfGF+P+n/WRXwhb9C2oZeHnou2WokhDbw1Q+iOtRjIYP+P6s9KXBRaA71D
+yvFfgFSHl3k1gd+BP2KGdfrs4ElFX4uZCNFtYDH7LFDWT1Ens3cHcyxB+zGewmY
1xox2LrQcUPNu2XRoSFZUNulj1UOQgJXAuslyzUOt4Djmz1195hbYB6kaR9noZJn
mMyzWAMjAzEdF4/ivHWZR9BNFwwJXgwOKldbGiDuYi/x9XLrNoY5A2UZ1tlVB/Yv
k1o0e8gL+C2U0ZK1yp/qbxCYpB4fx4Tui8gyQwIDAQABo4IDTTCCA0kwLwYJKwYB
BAGCNxQCBCIeIABEAG8AbQBhAGkAbgBDAG8AbgB0AHIAbwBsAGwAZQByMB0GA1Ud
JQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATAOBgNVHQ8BAf8EBAMCBaAweAYJKoZI
hvcNAQkPBGswaTAOBggqhkiG9w0DAgICAIAwDgYIKoZIhvcNAwQCAgCAMAsGCWCG
SAFlAwQBKjALBglghkgBZQMEAS0wCwYJYIZIAWUDBAECMAsGCWCGSAFlAwQBBTAH
BgUrDgMCBzAKBggqhkiG9w0DBzBZBgNVHREEUjBQoB8GCSsGAQQBgjcZAaASBBA6
UzhVceE7RKuubA/hfhl9gi1FbGFzdGljU2VhcmNoQWRUZXN0LmFkLnRlc3QuZWxh
c3RpY3NlYXJjaC5jb20wHQYDVR0OBBYEFIHEUmmmaXZ3cmIuSAgVikHSiKcqMB8G
A1UdIwQYMBaAFIEKG0KdSVNknKcMZkbTlKo7N8MjMIHzBgNVHR8EgeswgegwgeWg
geKggd+GgdxsZGFwOi8vL0NOPWFkLUVMQVNUSUNTRUFSQ0hBRC1DQSxDTj1FbGFz
dGljU2VhcmNoQWRUZXN0LENOPUNEUCxDTj1QdWJsaWMlMjBLZXklMjBTZXJ2aWNl
cyxDTj1TZXJ2aWNlcyxDTj1Db25maWd1cmF0aW9uLERDPWFkLERDPXRlc3QsREM9
ZWxhc3RpY3NlYXJjaCxEQz1jb20/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdD9i
YXNlP29iamVjdENsYXNzPWNSTERpc3RyaWJ1dGlvblBvaW50MIHbBggrBgEFBQcB
AQSBzjCByzCByAYIKwYBBQUHMAKGgbtsZGFwOi8vL0NOPWFkLUVMQVNUSUNTRUFS
Q0hBRC1DQSxDTj1BSUEsQ049UHVibGljJTIwS2V5JTIwU2VydmljZXMsQ049U2Vy
dmljZXMsQ049Q29uZmlndXJhdGlvbixEQz1hZCxEQz10ZXN0LERDPWVsYXN0aWNz
ZWFyY2gsREM9Y29tP2NBQ2VydGlmaWNhdGU/YmFzZT9vYmplY3RDbGFzcz1jZXJ0
aWZpY2F0aW9uQXV0aG9yaXR5MA0GCSqGSIb3DQEBCwUAA4IBAQCP0mbcAsnw7qxt
jCSR38k0BteM0iEkR43ZrrBPLC/TlhULzC25EdFnZrb0cjd8UxTFEQo2UfTmw0Aj
IGe/N2CNvnwwq2hevK9IYAwQNj+0CB9LKdHztIBumxWj7a02rZpLSxuTMbljVEHT
yWGGDbndFUlAM6yOUAgHDiBLL9q2Ar6mqzd1XIs2MdqKbHgE8mhsmwm4vpKGg2hx
VfBYv/6RUw3M9+ep6PEGo6bYbcDbBMfLz4GR/hTm00MyhunYDYeuBUEn1SA/JOBK
c+Mcv8SNpQeAHIhdLYyzgIIqeBOFvz25kkPZvdHZzT4lNkSc7+v3pycrT7Pgk7s3
aGRGqK0c
-----END CERTIFICATE-----

View File

@ -18,7 +18,6 @@ import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.env.Environment;
import org.elasticsearch.graph.Graph;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.license.plugin.Licensing;
import org.elasticsearch.marvel.Monitoring;
@ -26,6 +25,8 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.shield.Security;
import org.elasticsearch.shield.authc.AuthenticationModule;
import org.elasticsearch.threadpool.ExecutorBuilder;
import org.elasticsearch.threadpool.ThreadPoolModule;
import org.elasticsearch.xpack.action.TransportXPackInfoAction;
import org.elasticsearch.xpack.action.TransportXPackUsageAction;
import org.elasticsearch.xpack.action.XPackInfoAction;
@ -36,6 +37,7 @@ import org.elasticsearch.xpack.common.init.LazyInitializationService;
import org.elasticsearch.xpack.common.secret.SecretModule;
import org.elasticsearch.xpack.extensions.XPackExtension;
import org.elasticsearch.xpack.extensions.XPackExtensionsService;
import org.elasticsearch.xpack.graph.Graph;
import org.elasticsearch.xpack.notification.Notification;
import org.elasticsearch.xpack.notification.email.Account;
import org.elasticsearch.xpack.notification.email.support.BodyPartSource;
@ -51,6 +53,7 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class XPackPlugin extends Plugin {
@ -201,6 +204,11 @@ public class XPackPlugin extends Plugin {
licensing.onModule(module);
}
@Override
public List<ExecutorBuilder<?>> getExecutorBuilders(final Settings settings) {
return watcher.getExecutorBuilders(settings);
}
public void onModule(NetworkModule module) {
if (!transportClientMode) {
module.registerRestHandler(RestXPackInfoAction.class);

View File

@ -29,7 +29,7 @@ public class TransportXPackUsageAction extends HandledTransportAction<XPackUsage
public TransportXPackUsageAction(Settings settings, ThreadPool threadPool, TransportService transportService,
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
Set<XPackFeatureSet> featureSets) {
super(settings, XPackInfoAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver,
super(settings, XPackUsageAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver,
XPackUsageRequest::new);
this.featureSets = featureSets;
}

View File

@ -20,13 +20,18 @@ import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.threadpool.ExecutorBuilder;
import org.elasticsearch.threadpool.FixedExecutorBuilder;
import org.elasticsearch.threadpool.ThreadPoolModule;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.common.init.LazyInitializationModule;
import org.elasticsearch.xpack.watcher.actions.WatcherActionModule;
import org.elasticsearch.xpack.watcher.client.WatcherClientModule;
import org.elasticsearch.xpack.watcher.condition.ConditionModule;
import org.elasticsearch.xpack.watcher.execution.ExecutionModule;
import org.elasticsearch.xpack.watcher.execution.InternalWatchExecutor;
import org.elasticsearch.xpack.watcher.history.HistoryModule;
import org.elasticsearch.xpack.watcher.history.HistoryStore;
import org.elasticsearch.xpack.watcher.input.InputModule;
@ -132,14 +137,7 @@ public class Watcher {
}
public Settings additionalSettings() {
if (enabled == false || transportClient) {
return Settings.EMPTY;
}
Settings additionalSettings = Settings.builder()
.put(HistoryModule.additionalSettings(settings))
.build();
return additionalSettings;
return Settings.EMPTY;
}
public void onModule(ScriptModule module) {
@ -171,6 +169,20 @@ public class Watcher {
module.registerSetting(Setting.simpleString("xpack.watcher.start_immediately", Setting.Property.NodeScope));
}
public List<ExecutorBuilder<?>> getExecutorBuilders(final Settings settings) {
if (XPackPlugin.featureEnabled(settings, Watcher.NAME, true)) {
final FixedExecutorBuilder builder =
new FixedExecutorBuilder(
settings,
InternalWatchExecutor.THREAD_POOL_NAME,
5 * EsExecutors.boundedNumberOfProcessors(settings),
1000,
"xpack.watcher.thread_pool");
return Collections.singletonList(builder);
}
return Collections.emptyList();
}
public void onModule(NetworkModule module) {
if (enabled && transportClient == false) {
module.registerRestHandler(RestPutWatchAction.class);

View File

@ -6,37 +6,17 @@
package org.elasticsearch.xpack.watcher.execution;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.watcher.Watcher;
import org.elasticsearch.xpack.watcher.support.ThreadPoolSettingsBuilder;
import java.util.concurrent.BlockingQueue;
import java.util.stream.Stream;
/**
*
*/
public class InternalWatchExecutor implements WatchExecutor {
public static final String THREAD_POOL_NAME = Watcher.NAME;
public static Settings additionalSettings(Settings nodeSettings) {
Settings settings = nodeSettings.getAsSettings("threadpool." + THREAD_POOL_NAME);
if (!settings.names().isEmpty()) {
// the TP is already configured in the node settings
// no need for additional settings
return Settings.EMPTY;
}
int availableProcessors = EsExecutors.boundedNumberOfProcessors(nodeSettings);
return new ThreadPoolSettingsBuilder.Fixed(THREAD_POOL_NAME)
.size(5 * availableProcessors)
.queueSize(1000)
.build();
}
private final ThreadPool threadPool;
@Inject
@ -67,4 +47,5 @@ public class InternalWatchExecutor implements WatchExecutor {
private EsThreadPoolExecutor executor() {
return (EsThreadPoolExecutor) threadPool.executor(THREAD_POOL_NAME);
}
}

View File

@ -21,7 +21,4 @@ public class HistoryModule extends AbstractModule {
bind(HistoryStore.class).asEagerSingleton();
}
public static Settings additionalSettings(Settings nodeSettings) {
return InternalWatchExecutor.additionalSettings(nodeSettings);
}
}

View File

@ -1,62 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.watcher.support;
import org.elasticsearch.common.settings.Settings;
/**
*
*/
public abstract class ThreadPoolSettingsBuilder<B extends ThreadPoolSettingsBuilder> {
public static Same same(String name) {
return new Same(name);
}
protected final String name;
private final Settings.Builder builder = Settings.builder();
protected ThreadPoolSettingsBuilder(String name, String type) {
this.name = name;
put("type", type);
}
public Settings build() {
return builder.build();
}
protected B put(String setting, Object value) {
builder.put("threadpool." + name + "." + setting, value);
return (B) this;
}
protected B put(String setting, int value) {
builder.put("threadpool." + name + "." + setting, value);
return (B) this;
}
public static class Same extends ThreadPoolSettingsBuilder<Same> {
public Same(String name) {
super(name, "same");
}
}
public static class Fixed extends ThreadPoolSettingsBuilder<Fixed> {
public Fixed(String name) {
super(name, "fixed");
}
public Fixed size(int size) {
return put("size", size);
}
public Fixed queueSize(int queueSize) {
return put("queue_size", queueSize);
}
}
}

View File

@ -17,6 +17,7 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.InternalSearchHits;
import org.elasticsearch.search.internal.InternalSearchResponse;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
import org.elasticsearch.xpack.watcher.support.Script;
@ -40,7 +41,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
@Before
public void init() throws Exception {
tp = new ThreadPool(ThreadPool.Names.SAME);
tp = new TestThreadPool(ThreadPool.Names.SAME);
scriptService = WatcherTestUtils.getScriptServiceProxy(tp);
}

View File

@ -18,6 +18,7 @@ import org.elasticsearch.script.GeneralScriptException;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.search.internal.InternalSearchResponse;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.watcher.condition.Condition;
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
@ -48,7 +49,7 @@ public class ScriptConditionTests extends ESTestCase {
@Before
public void init() {
tp = new ThreadPool(ThreadPool.Names.SAME);
tp = new TestThreadPool(ThreadPool.Names.SAME);
}
@After

View File

@ -17,6 +17,7 @@ import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.xpack.watcher.actions.ActionBuilders.indexAction;
@ -42,7 +43,7 @@ public class ChainIntegrationTests extends AbstractWatcherIntegrationTestCase {
public void testChainedInputsAreWorking() throws Exception {
String index = "the-most-awesome-index-ever";
createIndex(index);
client().prepareIndex(index, "type", "id").setSource("{}").setRefresh(true).get();
client().prepareIndex(index, "type", "id").setSource("{}").setRefreshPolicy(IMMEDIATE).get();
InetSocketAddress address = internalCluster().httpAddresses()[0];
HttpInput.Builder httpInputBuilder = httpInput(HttpRequestTemplate.builder(address.getHostString(), address.getPort())

View File

@ -24,6 +24,7 @@ import org.elasticsearch.xpack.watcher.trigger.schedule.IntervalSchedule;
import java.net.InetSocketAddress;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
@ -49,7 +50,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
@TestLogging("watcher.support.http:TRACE")
public void testHttpInput() throws Exception {
createIndex("index");
client().prepareIndex("index", "type", "id").setSource("{}").setRefresh(true).get();
client().prepareIndex("index", "type", "id").setSource("{}").setRefreshPolicy(IMMEDIATE).get();
InetSocketAddress address = internalCluster().httpAddresses()[0];
watcherClient().preparePutWatch("_name")

View File

@ -32,6 +32,7 @@ import org.joda.time.DateTimeZone;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
@ -140,7 +141,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
.endObject()
.endObject())
.setConsistencyLevel(WriteConsistencyLevel.ALL)
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// unknown condition:
@ -158,7 +159,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
.endObject()
.endObject())
.setConsistencyLevel(WriteConsistencyLevel.ALL)
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
// unknown trigger:
@ -176,7 +177,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
.endObject()
.endObject())
.setConsistencyLevel(WriteConsistencyLevel.ALL)
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
stopWatcher();
@ -200,7 +201,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
.endObject()
.endObject())
.setConsistencyLevel(WriteConsistencyLevel.ALL)
.setRefresh(true)
.setRefreshPolicy(IMMEDIATE)
.get();
stopWatcher();

View File

@ -15,6 +15,7 @@ import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.GeneralScriptException;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
import org.elasticsearch.xpack.watcher.support.Script;
@ -53,7 +54,7 @@ public class ScriptTransformTests extends ESTestCase {
@Before
public void init() {
tp = new ThreadPool(ThreadPool.Names.SAME);
tp = new TestThreadPool(ThreadPool.Names.SAME);
}
@After