diff --git a/build.gradle b/build.gradle index 78a6222af03..ebffdb9973b 100644 --- a/build.gradle +++ b/build.gradle @@ -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) } diff --git a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/GroovyScriptConditionIT.java b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/GroovyScriptConditionIT.java index f286832382e..bd751eed42f 100644 --- a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/GroovyScriptConditionIT.java +++ b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/GroovyScriptConditionIT.java @@ -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 diff --git a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptConditionSearchIT.java b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptConditionSearchIT.java index 042de64dfb3..d467b68a68c 100644 --- a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptConditionSearchIT.java +++ b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptConditionSearchIT.java @@ -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); } diff --git a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptConditionTests.java b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptConditionTests.java index 500d35e70da..9c3679edc47 100644 --- a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptConditionTests.java +++ b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptConditionTests.java @@ -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 diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/Graph.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/Graph.java similarity index 90% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/Graph.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/Graph.java index 4b9a338fe4b..9c435dba74f 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/Graph.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/Graph.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphFeatureSet.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSet.java similarity index 97% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphFeatureSet.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSet.java index 008a6942e11..2cba904304c 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphFeatureSet.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSet.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphLicensee.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/GraphLicensee.java similarity index 98% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphLicensee.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/GraphLicensee.java index 4aaec502c59..01bf5f8e536 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphLicensee.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/GraphLicensee.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphModule.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/GraphModule.java similarity index 96% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphModule.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/GraphModule.java index eaf145e5e9c..f4108bcd90a 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphModule.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/GraphModule.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Connection.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/Connection.java similarity index 97% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Connection.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/Connection.java index 0b3d44ab287..02d07f882e5 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Connection.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/Connection.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreAction.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreAction.java similarity index 95% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreAction.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreAction.java index 1d3537c80e6..9375a95d92f 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreAction.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreAction.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreRequest.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreRequest.java similarity index 99% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreRequest.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreRequest.java index 69f7f16de7c..8500bbb52fc 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreRequest.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreRequest.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreRequestBuilder.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreRequestBuilder.java similarity index 99% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreRequestBuilder.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreRequestBuilder.java index 9177a12b02d..55e4942d1c7 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreRequestBuilder.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreRequestBuilder.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreResponse.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreResponse.java similarity index 97% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreResponse.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreResponse.java index 24dfe28a119..2869871a67d 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreResponse.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreResponse.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Hop.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/Hop.java similarity index 99% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Hop.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/Hop.java index 3ae01c472c4..83bd6f09f1d 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Hop.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/Hop.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/TransportGraphExploreAction.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java similarity index 99% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/TransportGraphExploreAction.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java index 5323002ea62..ec4d045ce10 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/TransportGraphExploreAction.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Vertex.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/Vertex.java similarity index 99% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Vertex.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/Vertex.java index 002483223a8..24f75bed1c9 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/Vertex.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/Vertex.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/VertexRequest.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/VertexRequest.java similarity index 97% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/VertexRequest.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/VertexRequest.java index 78e09152eca..140c4071b2a 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/VertexRequest.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/action/VertexRequest.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/rest/action/RestGraphAction.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java similarity index 97% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/rest/action/RestGraphAction.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java index 6e5a9582af4..518229fecab 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/rest/action/RestGraphAction.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java @@ -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 diff --git a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/GraphFeatureSetTests.java b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/GraphFeatureSetTests.java similarity index 93% rename from elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/GraphFeatureSetTests.java rename to elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/GraphFeatureSetTests.java index 6e87584d976..56d3b949bbe 100644 --- a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/GraphFeatureSetTests.java +++ b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/GraphFeatureSetTests.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/license/LicenseTests.java similarity index 98% rename from elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java rename to elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/license/LicenseTests.java index c27a43b495c..0ad59d8bc56 100644 --- a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java +++ b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/license/LicenseTests.java @@ -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; diff --git a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java similarity index 97% rename from elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java rename to elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java index c4fd6576c07..9fe576c8dc5 100644 --- a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java +++ b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java @@ -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; diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTestCase.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTestCase.java index b4c8abb20c2..6b5134d2caa 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTestCase.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTestCase.java @@ -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; diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java index 0ba61a72e1e..6e48dece27e 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java @@ -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; diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/TransportMonitoringBulkActionTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/TransportMonitoringBulkActionTests.java index f9876038b73..d37e19023c3 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/TransportMonitoringBulkActionTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/TransportMonitoringBulkActionTests.java @@ -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 diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/shards/ShardsTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/shards/ShardsTests.java index 970e714fd49..9c5a2ab8447 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/shards/ShardsTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/shards/ShardsTests.java @@ -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(); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/CleanerServiceTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/CleanerServiceTests.java index 97b3e7da384..769ee62f4a3 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/CleanerServiceTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/CleanerServiceTests.java @@ -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 diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/PutRoleRequest.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/PutRoleRequest.java index b7a59d83d3d..05f45513aee 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/PutRoleRequest.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/PutRoleRequest.java @@ -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 { +public class PutRoleRequest extends ActionRequest implements WriteRequest { private String name; private String[] clusterPrivileges = Strings.EMPTY_ARRAY; private List 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 { 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 { 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 { 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 { index.writeTo(out); } out.writeStringArray(runAs); - out.writeBoolean(refresh); + refreshPolicy.writeTo(out); } RoleDescriptor roleDescriptor() { diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/PutRoleRequestBuilder.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/PutRoleRequestBuilder.java index 8674f5ed205..8b63fc32de4 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/PutRoleRequestBuilder.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/PutRoleRequestBuilder.java @@ -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 { +public class PutRoleRequestBuilder extends ActionRequestBuilder + implements WriteRequestBuilder { public PutRoleRequestBuilder(ElasticsearchClient client) { this(client, PutRoleAction.INSTANCE); @@ -54,9 +56,4 @@ public class PutRoleRequestBuilder extends ActionRequestBuilder implements UserRequest { +public class ChangePasswordRequest extends ActionRequest + implements UserRequest, WriteRequest { 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 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 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 super.writeTo(out); out.writeString(username); out.writeBytesReference(new BytesArray(CharArrays.toUtf8Bytes(passwordHash))); + refreshPolicy.writeTo(out); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/ChangePasswordRequestBuilder.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/ChangePasswordRequestBuilder.java index 994f2901eea..7177f1b56eb 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/ChangePasswordRequestBuilder.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/ChangePasswordRequestBuilder.java @@ -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 { + extends ActionRequestBuilder + implements WriteRequestBuilder { 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; - } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequest.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequest.java index ce9fa89a747..bcf4891f882 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequest.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequest.java @@ -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 implements UserRequest { +public class PutUserRequest extends ActionRequest implements UserRequest, WriteRequest { private String username; private String[] roles; @@ -30,7 +32,7 @@ public class PutUserRequest extends ActionRequest implements Use private String email; private Map metadata; private char[] passwordHash; - private boolean refresh = true; + private RefreshPolicy refreshPolicy = RefreshPolicy.IMMEDIATE; public PutUserRequest() { } @@ -72,8 +74,19 @@ public class PutUserRequest extends ActionRequest 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 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 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 implements Use out.writeBoolean(true); out.writeMap(metadata); } - out.writeBoolean(refresh); + refreshPolicy.writeTo(out); } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequestBuilder.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequestBuilder.java index 11f061c2d9b..3a5bf7b54d4 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequestBuilder.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/user/PutUserRequestBuilder.java @@ -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 { +public class PutUserRequestBuilder extends ActionRequestBuilder + implements WriteRequestBuilder { private final Hasher hasher = Hasher.BCRYPT; @@ -77,11 +79,6 @@ public class PutUserRequestBuilder extends ActionRequestBuilder() { @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 listener) { + private void createReservedUser(String username, char[] passwordHash, RefreshPolicy refresh, ActionListener 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() { @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() { @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() { @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() { @Override public void onResponse(DeleteResponse deleteResponse) { diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/NativeRolesStore.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/NativeRolesStore.java index afb7d220080..46bfb0c3c71 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/NativeRolesStore.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/store/NativeRolesStore.java @@ -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() { @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() { @Override public void onResponse(IndexResponse indexResponse) { diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/role/RestPutRoleAction.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/role/RestPutRoleAction.java index 20334f56efc..d1a1a6c227d 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/role/RestPutRoleAction.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/role/RestPutRoleAction.java @@ -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(channel) { @Override public RestResponse buildResponse(PutRoleResponse putRoleResponse, XContentBuilder builder) throws Exception { diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/user/RestChangePasswordAction.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/user/RestChangePasswordAction.java index 9be684b4598..ce31c587e24 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/user/RestChangePasswordAction.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/user/RestChangePasswordAction.java @@ -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(channel) { @Override public RestResponse buildResponse(ChangePasswordResponse changePasswordResponse, XContentBuilder builder) throws diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/user/RestPutUserAction.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/user/RestPutUserAction.java index 863a960d47e..261495f4ac1 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/user/RestPutUserAction.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/action/user/RestPutUserAction.java @@ -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(channel) { @Override diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java index 5475eadfd72..d53f7536c01 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java @@ -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 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)); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java index 5b626b3c2f8..36f8ff1083a 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java @@ -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)); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java index 716b58652e8..8869367b79f 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java @@ -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: diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java index f99bfef4aff..f2fd3632f5a 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java @@ -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: diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityRandomTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityRandomTests.java index fc14ae859a9..541bb73623f 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityRandomTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityRandomTests.java @@ -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); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java index a887783b017..6de93265d9c 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java @@ -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: diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java index 916321f80ba..068b3f97ef4 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java @@ -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() diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java index bc76aadcc1e..372426e4751 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java @@ -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)); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ShieldClearScrollTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ShieldClearScrollTests.java index 7c745794f1d..4d050ad6704 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ShieldClearScrollTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ShieldClearScrollTests.java @@ -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\" }")); } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/AuditTrailModuleTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/AuditTrailModuleTests.java index 13581354c22..46bb410fca3 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/AuditTrailModuleTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/AuditTrailModuleTests.java @@ -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); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailMutedTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailMutedTests.java index a91bc3729b5..5e76ebd3921 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailMutedTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailMutedTests.java @@ -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) { diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java index be3a74d833f..066ee7b773e 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java @@ -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 diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailUpdateMappingTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailUpdateMappingTests.java index e87b7026fba..11b567456f0 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailUpdateMappingTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailUpdateMappingTests.java @@ -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 { diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/activedirectory/ActiveDirectoryRealmTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/activedirectory/ActiveDirectoryRealmTests.java index 547807fc2cd..68b4186dd46 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/activedirectory/ActiveDirectoryRealmTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/activedirectory/ActiveDirectoryRealmTests.java @@ -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(); } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/esnative/NativeRealmIntegTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/esnative/NativeRealmIntegTests.java index 8ef07027eb1..f30b5b18f11 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/esnative/NativeRealmIntegTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/esnative/NativeRealmIntegTests.java @@ -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(); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/FileUserPasswdStoreTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/FileUserPasswdStoreTests.java index 72c261e0c08..cb4735eec51 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/FileUserPasswdStoreTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/FileUserPasswdStoreTests.java @@ -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 diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/FileUserRolesStoreTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/FileUserRolesStoreTests.java index e74569c7eb0..09dfd3133e7 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/FileUserRolesStoreTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/FileUserRolesStoreTests.java @@ -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() diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/ldap/LdapRealmTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/ldap/LdapRealmTests.java index 7ab06210a42..4be76a5c787 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/ldap/LdapRealmTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/ldap/LdapRealmTests.java @@ -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(); } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/support/DnRoleMapperTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/support/DnRoleMapperTests.java index 3dd07e2e15c..2ae0276059b 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/support/DnRoleMapperTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/support/DnRoleMapperTests.java @@ -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 diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/store/FileRolesStoreTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/store/FileRolesStoreTests.java index 6dc6bbabd26..0a0ccfd206c 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/store/FileRolesStoreTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/store/FileRolesStoreTests.java @@ -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() { diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/crypto/InternalCryptoServiceTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/crypto/InternalCryptoServiceTests.java index d97d5fcf095..ef6d5cc9404 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/crypto/InternalCryptoServiceTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/crypto/InternalCryptoServiceTests.java @@ -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(); } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ssl/SSLConfigurationTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ssl/SSLConfigurationTests.java index f356e916728..9d0f4a76807 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ssl/SSLConfigurationTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ssl/SSLConfigurationTests.java @@ -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 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 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 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 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 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 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 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 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(); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/support/SelfReschedulingRunnableTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/support/SelfReschedulingRunnableTests.java index 04bb5e1f73e..d3d7cd21553 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/support/SelfReschedulingRunnableTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/support/SelfReschedulingRunnableTests.java @@ -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() { diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java index 6e148315bda..f438116cd7c 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java @@ -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"), diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/transport/KnownActionsTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/transport/KnownActionsTests.java index 4f994db7f90..5153754b62b 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/transport/KnownActionsTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/transport/KnownActionsTests.java @@ -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; diff --git a/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/authc/ldap/support/ldaptrust.jks b/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/authc/ldap/support/ldaptrust.jks index 37f8edfe844..2b8287d88f0 100644 Binary files a/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/authc/ldap/support/ldaptrust.jks and b/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/authc/ldap/support/ldaptrust.jks differ diff --git a/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/active-directory-ca.crt b/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/active-directory-ca.crt new file mode 100644 index 00000000000..453d1361ce4 --- /dev/null +++ b/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/active-directory-ca.crt @@ -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----- diff --git a/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/activedir.crt b/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/activedir.crt deleted file mode 100644 index 49a4416a2cf..00000000000 --- a/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/activedir.crt +++ /dev/null @@ -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----- diff --git a/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/testnode-no-subjaltname.jks b/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/testnode-no-subjaltname.jks index 81f947afcc1..ec482775bd0 100644 Binary files a/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/testnode-no-subjaltname.jks and b/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/testnode-no-subjaltname.jks differ diff --git a/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks b/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks index 39955d91a2e..f034f5b005a 100644 Binary files a/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks and b/elasticsearch/x-pack/shield/src/test/resources/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks differ diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java index b519da5d489..456f8db3598 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java @@ -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> getExecutorBuilders(final Settings settings) { + return watcher.getExecutorBuilders(settings); + } + public void onModule(NetworkModule module) { if (!transportClientMode) { module.registerRestHandler(RestXPackInfoAction.class); diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/TransportXPackUsageAction.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/TransportXPackUsageAction.java index 0aab9211c00..86dca578ad6 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/TransportXPackUsageAction.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/TransportXPackUsageAction.java @@ -29,7 +29,7 @@ public class TransportXPackUsageAction extends HandledTransportAction featureSets) { - super(settings, XPackInfoAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, + super(settings, XPackUsageAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, XPackUsageRequest::new); this.featureSets = featureSets; } diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index 3852826defd..2f8b1e1ce2f 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -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> 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); diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java index 4d270496c08..668bdc53d6b 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java @@ -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); } + } diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryModule.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryModule.java index e9e65252e7d..3c325c0f0e0 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryModule.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryModule.java @@ -21,7 +21,4 @@ public class HistoryModule extends AbstractModule { bind(HistoryStore.class).asEagerSingleton(); } - public static Settings additionalSettings(Settings nodeSettings) { - return InternalWatchExecutor.additionalSettings(nodeSettings); - } } diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/ThreadPoolSettingsBuilder.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/ThreadPoolSettingsBuilder.java deleted file mode 100644 index b477be19c25..00000000000 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/ThreadPoolSettingsBuilder.java +++ /dev/null @@ -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 { - - 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 { - public Same(String name) { - super(name, "same"); - } - } - - public static class Fixed extends ThreadPoolSettingsBuilder { - - 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); - } - } - -} diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/script/ScriptConditionSearchTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/script/ScriptConditionSearchTests.java index a8fc5743f6c..f814c67f1f9 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/script/ScriptConditionSearchTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/script/ScriptConditionSearchTests.java @@ -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); } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/script/ScriptConditionTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/script/ScriptConditionTests.java index c24b79efd5e..b495fe3f3cc 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/script/ScriptConditionTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/script/ScriptConditionTests.java @@ -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 diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainIntegrationTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainIntegrationTests.java index 77b2029dc44..a760116dd11 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainIntegrationTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainIntegrationTests.java @@ -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()) diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputIntegrationTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputIntegrationTests.java index 2ff6a291474..a22d6262be7 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputIntegrationTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputIntegrationTests.java @@ -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") diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java index 210e295db79..dcda61a5813 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java @@ -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(); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java index 910ee7a8341..6e971535e16 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java @@ -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