Merge branch 'master' into enhancement/use_shard_bulk_for_single_ops
Original commit: elastic/x-pack-elasticsearch@f71ce64fb3
This commit is contained in:
commit
f64b1ea3eb
|
@ -30,4 +30,9 @@ public class PreBuiltXPackTransportClientTests extends RandomizedTest {
|
|||
}
|
||||
}
|
||||
|
||||
// dummy test so that the tests pass on JDK9 as the only test in this module is disabled on JDK9
|
||||
@Test
|
||||
public void testDummy() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.elasticsearch.plugins.ScriptPlugin;
|
|||
import org.elasticsearch.rest.RestHandler;
|
||||
import org.elasticsearch.script.ScriptContext;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.threadpool.ExecutorBuilder;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
|
@ -96,7 +95,6 @@ import java.security.AccessController;
|
|||
import java.security.PrivilegedAction;
|
||||
import java.time.Clock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -221,7 +219,7 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
|||
@Override
|
||||
public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool,
|
||||
ResourceWatcherService resourceWatcherService, ScriptService scriptService,
|
||||
SearchRequestParsers searchRequestParsers, NamedXContentRegistry xContentRegistry) {
|
||||
NamedXContentRegistry xContentRegistry) {
|
||||
List<Object> components = new ArrayList<>();
|
||||
components.add(sslService);
|
||||
|
||||
|
@ -255,7 +253,7 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
|||
httpTemplateParser, scriptService, httpAuthRegistry);
|
||||
components.addAll(notificationComponents);
|
||||
|
||||
components.addAll(watcher.createComponents(getClock(), scriptService, internalClient, searchRequestParsers, licenseState,
|
||||
components.addAll(watcher.createComponents(getClock(), scriptService, internalClient, licenseState,
|
||||
httpClient, httpTemplateParser, threadPool, clusterService, security.getCryptoService(), xContentRegistry, components));
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.elasticsearch.plugins.ScriptPlugin;
|
|||
import org.elasticsearch.rest.RestHandler;
|
||||
import org.elasticsearch.script.ScriptContext;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.threadpool.ExecutorBuilder;
|
||||
import org.elasticsearch.threadpool.FixedExecutorBuilder;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -219,7 +218,7 @@ public class Watcher implements ActionPlugin, ScriptPlugin {
|
|||
}
|
||||
|
||||
public Collection<Object> createComponents(Clock clock, ScriptService scriptService, InternalClient internalClient,
|
||||
SearchRequestParsers searchRequestParsers, XPackLicenseState licenseState,
|
||||
XPackLicenseState licenseState,
|
||||
HttpClient httpClient, HttpRequestTemplate.Parser httpTemplateParser,
|
||||
ThreadPool threadPool, ClusterService clusterService, CryptoService cryptoService,
|
||||
NamedXContentRegistry xContentRegistry, Collection<Object> components) {
|
||||
|
@ -237,8 +236,7 @@ public class Watcher implements ActionPlugin, ScriptPlugin {
|
|||
final ConditionRegistry conditionRegistry = new ConditionRegistry(Collections.unmodifiableMap(parsers), clock);
|
||||
final Map<String, TransformFactory> transformFactories = new HashMap<>();
|
||||
transformFactories.put(ScriptTransform.TYPE, new ScriptTransformFactory(settings, scriptService));
|
||||
transformFactories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, internalClient, searchRequestParsers,
|
||||
xContentRegistry, scriptService));
|
||||
transformFactories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, internalClient, xContentRegistry, scriptService));
|
||||
final TransformRegistry transformRegistry = new TransformRegistry(settings, Collections.unmodifiableMap(transformFactories));
|
||||
|
||||
final Map<String, ActionFactory> actionFactoryMap = new HashMap<>();
|
||||
|
@ -261,7 +259,7 @@ public class Watcher implements ActionPlugin, ScriptPlugin {
|
|||
|
||||
final Map<String, InputFactory> inputFactories = new HashMap<>();
|
||||
inputFactories.put(SearchInput.TYPE,
|
||||
new SearchInputFactory(settings, internalClient, searchRequestParsers, xContentRegistry, scriptService));
|
||||
new SearchInputFactory(settings, internalClient, xContentRegistry, scriptService));
|
||||
inputFactories.put(SimpleInput.TYPE, new SimpleInputFactory(settings));
|
||||
inputFactories.put(HttpInput.TYPE, new HttpInputFactory(settings, httpClient, templateEngine, httpTemplateParser));
|
||||
inputFactories.put(NoneInput.TYPE, new NoneInputFactory(settings));
|
||||
|
@ -294,7 +292,7 @@ public class Watcher implements ActionPlugin, ScriptPlugin {
|
|||
final TriggeredWatchStore triggeredWatchStore = new TriggeredWatchStore(settings, watcherClientProxy, triggeredWatchParser);
|
||||
|
||||
final WatcherSearchTemplateService watcherSearchTemplateService =
|
||||
new WatcherSearchTemplateService(settings, scriptService, searchRequestParsers, xContentRegistry);
|
||||
new WatcherSearchTemplateService(settings, scriptService, xContentRegistry);
|
||||
final WatchExecutor watchExecutor = getWatchExecutor(threadPool);
|
||||
final Watch.Parser watchParser = new Watch.Parser(settings, triggerService, registry, inputRegistry, cryptoService, clock);
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.xpack.security.InternalClient;
|
||||
import org.elasticsearch.xpack.watcher.input.InputFactory;
|
||||
import org.elasticsearch.xpack.watcher.input.simple.ExecutableSimpleInput;
|
||||
|
@ -25,17 +24,17 @@ public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Re
|
|||
private final TimeValue defaultTimeout;
|
||||
private final WatcherSearchTemplateService searchTemplateService;
|
||||
|
||||
public SearchInputFactory(Settings settings, InternalClient client, SearchRequestParsers searchRequestParsers,
|
||||
NamedXContentRegistry xContentRegistry, ScriptService scriptService) {
|
||||
this(settings, new WatcherClientProxy(settings, client), searchRequestParsers, xContentRegistry, scriptService);
|
||||
public SearchInputFactory(Settings settings, InternalClient client, NamedXContentRegistry xContentRegistry,
|
||||
ScriptService scriptService) {
|
||||
this(settings, new WatcherClientProxy(settings, client), xContentRegistry, scriptService);
|
||||
}
|
||||
|
||||
public SearchInputFactory(Settings settings, WatcherClientProxy client, SearchRequestParsers searchRequestParsers,
|
||||
NamedXContentRegistry xContentRegistry, ScriptService scriptService) {
|
||||
public SearchInputFactory(Settings settings, WatcherClientProxy client, NamedXContentRegistry xContentRegistry,
|
||||
ScriptService scriptService) {
|
||||
super(Loggers.getLogger(ExecutableSimpleInput.class, settings));
|
||||
this.client = client;
|
||||
this.defaultTimeout = settings.getAsTime("xpack.watcher.input.search.default_timeout", null);
|
||||
this.searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, searchRequestParsers, xContentRegistry);
|
||||
this.searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, xContentRegistry);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.elasticsearch.index.query.QueryParseContext;
|
|||
import org.elasticsearch.script.CompiledScript;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||
|
@ -35,14 +34,11 @@ public class WatcherSearchTemplateService extends AbstractComponent {
|
|||
|
||||
private final ScriptService scriptService;
|
||||
private final ParseFieldMatcher parseFieldMatcher;
|
||||
private final SearchRequestParsers searchRequestParsers;
|
||||
private final NamedXContentRegistry xContentRegistry;
|
||||
|
||||
public WatcherSearchTemplateService(Settings settings, ScriptService scriptService, SearchRequestParsers searchRequestParsers,
|
||||
NamedXContentRegistry xContentRegistry) {
|
||||
public WatcherSearchTemplateService(Settings settings, ScriptService scriptService, NamedXContentRegistry xContentRegistry) {
|
||||
super(settings);
|
||||
this.scriptService = scriptService;
|
||||
this.searchRequestParsers = searchRequestParsers;
|
||||
this.parseFieldMatcher = new ParseFieldMatcher(settings);
|
||||
this.xContentRegistry = xContentRegistry;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.xpack.security.InternalClient;
|
||||
import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy;
|
||||
import org.elasticsearch.xpack.watcher.support.search.WatcherSearchTemplateService;
|
||||
|
@ -24,17 +23,17 @@ public class SearchTransformFactory extends TransformFactory<SearchTransform, Se
|
|||
private final TimeValue defaultTimeout;
|
||||
private final WatcherSearchTemplateService searchTemplateService;
|
||||
|
||||
public SearchTransformFactory(Settings settings, InternalClient client, SearchRequestParsers searchRequestParsers,
|
||||
NamedXContentRegistry xContentRegistry, ScriptService scriptService) {
|
||||
this(settings, new WatcherClientProxy(settings, client), searchRequestParsers, xContentRegistry, scriptService);
|
||||
public SearchTransformFactory(Settings settings, InternalClient client, NamedXContentRegistry xContentRegistry,
|
||||
ScriptService scriptService) {
|
||||
this(settings, new WatcherClientProxy(settings, client), xContentRegistry, scriptService);
|
||||
}
|
||||
|
||||
public SearchTransformFactory(Settings settings, WatcherClientProxy client, SearchRequestParsers searchRequestParsers,
|
||||
NamedXContentRegistry xContentRegistry, ScriptService scriptService) {
|
||||
public SearchTransformFactory(Settings settings, WatcherClientProxy client, NamedXContentRegistry xContentRegistry,
|
||||
ScriptService scriptService) {
|
||||
super(Loggers.getLogger(ExecutableSearchTransform.class, settings));
|
||||
this.client = client;
|
||||
this.defaultTimeout = settings.getAsTime("xpack.watcher.transform.search.default_timeout", null);
|
||||
this.searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, searchRequestParsers, xContentRegistry);
|
||||
this.searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, xContentRegistry);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,9 +9,7 @@ import org.elasticsearch.ElasticsearchException;
|
|||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.PlainActionFuture;
|
||||
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.ClusterStateUpdateTask;
|
||||
import org.elasticsearch.cluster.LocalClusterUpdateTask;
|
||||
import org.elasticsearch.cluster.NodeConnectionsService;
|
||||
import org.elasticsearch.cluster.block.ClusterBlocks;
|
||||
|
@ -44,7 +42,6 @@ import java.io.IOException;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -101,12 +98,12 @@ public class TransportMonitoringBulkActionTests extends ESTestCase {
|
|||
Version.CURRENT));
|
||||
clusterService.setNodeConnectionsService(new NodeConnectionsService(Settings.EMPTY, null, null) {
|
||||
@Override
|
||||
public void connectToNodes(List<DiscoveryNode> addedNodes) {
|
||||
public void connectToNodes(Iterable<DiscoveryNode> discoveryNodes) {
|
||||
// skip
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnectFromNodes(List<DiscoveryNode> removedNodes) {
|
||||
public void disconnectFromNodesExcept(Iterable<DiscoveryNode> nodesToKeep) {
|
||||
// skip
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.watcher.actions.throttler;
|
|||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
|
@ -40,8 +41,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.elasticsearch.xpack.watcher.actions.ActionBuilders.indexAction;
|
||||
import static org.elasticsearch.xpack.watcher.actions.ActionBuilders.loggingAction;
|
||||
import static org.elasticsearch.xpack.watcher.actions.ActionBuilders.webhookAction;
|
||||
import static org.elasticsearch.xpack.watcher.client.WatchSourceBuilders.watchBuilder;
|
||||
import static org.elasticsearch.xpack.watcher.trigger.TriggerBuilders.schedule;
|
||||
import static org.elasticsearch.xpack.watcher.trigger.schedule.Schedules.interval;
|
||||
|
@ -287,8 +288,21 @@ public class ActionThrottleTests extends AbstractWatcherIntegrationTestCase {
|
|||
}, 20, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@AwaitsFix(bugUrl = "https://github.com/elastic/x-pack/issues/4561")
|
||||
public void testFailingActionDoesGetThrottled() throws Exception {
|
||||
// create a mapping with a wrong @timestamp field, so that the index action of the watch below will fail
|
||||
String mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("bar")
|
||||
.startObject("properties")
|
||||
.startObject("@timestamp")
|
||||
.field("type", "integer")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject().string();
|
||||
|
||||
client().admin().indices().prepareCreate("foo").addMapping("bar", mapping).get();
|
||||
|
||||
TimeValue throttlePeriod = new TimeValue(60, TimeUnit.MINUTES);
|
||||
|
||||
watcherClient().preparePutWatch("_id").setSource(watchBuilder()
|
||||
|
@ -296,8 +310,7 @@ public class ActionThrottleTests extends AbstractWatcherIntegrationTestCase {
|
|||
new IntervalSchedule.Interval(60, IntervalSchedule.Interval.Unit.MINUTES))))
|
||||
.defaultThrottlePeriod(throttlePeriod)
|
||||
.addAction("logging", loggingAction("test out"))
|
||||
// no DNS resolution here please
|
||||
.addAction("failing_hook", webhookAction(HttpRequestTemplate.builder("http://127.0.0.1/foobar", 80))))
|
||||
.addAction("failing_hook", indexAction("foo", "bar").setExecutionTimeField("@timestamp")))
|
||||
.get();
|
||||
refresh(Watch.INDEX);
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.elasticsearch.plugins.ScriptPlugin;
|
|||
import org.elasticsearch.script.MockMustacheScriptEngine;
|
||||
import org.elasticsearch.script.ScriptContext;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
|
@ -144,9 +143,8 @@ public class SearchInputTests extends ESIntegTestCase {
|
|||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
SearchRequestParsers searchParsers = new SearchRequestParsers();
|
||||
SearchInputFactory factory = new SearchInputFactory(Settings.EMPTY, WatcherClientProxy.of(client()),
|
||||
searchParsers, xContentRegistry(), scriptService());
|
||||
xContentRegistry(), scriptService());
|
||||
|
||||
SearchInput searchInput = factory.parseInput("_id", parser);
|
||||
assertEquals(SearchInput.TYPE, searchInput.type());
|
||||
|
@ -157,7 +155,6 @@ public class SearchInputTests extends ESIntegTestCase {
|
|||
String master = internalCluster().getMasterName();
|
||||
return new WatcherSearchTemplateService(internalCluster().clusterService(master).getSettings(),
|
||||
internalCluster().getInstance(ScriptService.class, master),
|
||||
internalCluster().getInstance(SearchRequestParsers.class, master),
|
||||
internalCluster().getInstance(NamedXContentRegistry.class, master)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.elasticsearch.script.Script;
|
|||
import org.elasticsearch.script.ScriptContext;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.script.ScriptType;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
|
@ -212,9 +211,8 @@ public class SearchTransformTests extends ESIntegTestCase {
|
|||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
SearchRequestParsers searchRequestParsers = internalCluster().getInstance(SearchRequestParsers.class);
|
||||
SearchTransformFactory transformFactory = new SearchTransformFactory(Settings.EMPTY, WatcherClientProxy.of(client()),
|
||||
searchRequestParsers, xContentRegistry(), scriptService());
|
||||
xContentRegistry(), scriptService());
|
||||
ExecutableSearchTransform executable = transformFactory.parseExecutable("_id", parser);
|
||||
|
||||
assertThat(executable, notNullValue());
|
||||
|
@ -284,7 +282,6 @@ public class SearchTransformTests extends ESIntegTestCase {
|
|||
String master = internalCluster().getMasterName();
|
||||
return new WatcherSearchTemplateService(internalCluster().clusterService(master).getSettings(),
|
||||
internalCluster().getInstance(ScriptService.class, master),
|
||||
internalCluster().getInstance(SearchRequestParsers.class, master),
|
||||
xContentRegistry()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.elasticsearch.index.query.ScriptQueryBuilder;
|
|||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
|
@ -288,9 +287,7 @@ public class WatchTests extends ESTestCase {
|
|||
ActionRegistry actionRegistry = registry(Collections.emptyList(), conditionRegistry, transformRegistry);
|
||||
Watch.Parser watchParser = new Watch.Parser(settings, triggerService, actionRegistry, inputRegistry, null, Clock.systemUTC());
|
||||
|
||||
SearchRequestParsers searchParsers = new SearchRequestParsers();
|
||||
WatcherSearchTemplateService searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, searchParsers,
|
||||
xContentRegistry());
|
||||
WatcherSearchTemplateService searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, xContentRegistry());
|
||||
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
|
@ -409,8 +406,7 @@ public class WatchTests extends ESTestCase {
|
|||
Map<String, InputFactory> parsers = new HashMap<>();
|
||||
switch (inputType) {
|
||||
case SearchInput.TYPE:
|
||||
SearchRequestParsers searchParsers = new SearchRequestParsers();
|
||||
parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, searchParsers, xContentRegistry(), scriptService));
|
||||
parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, xContentRegistry(), scriptService));
|
||||
return new InputRegistry(Settings.EMPTY, parsers);
|
||||
default:
|
||||
parsers.put(SimpleInput.TYPE, new SimpleInputFactory(settings));
|
||||
|
@ -457,10 +453,9 @@ public class WatchTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private TransformRegistry transformRegistry() {
|
||||
SearchRequestParsers searchParsers = new SearchRequestParsers();
|
||||
Map<String, TransformFactory> factories = new HashMap<>();
|
||||
factories.put(ScriptTransform.TYPE, new ScriptTransformFactory(settings, scriptService));
|
||||
factories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, client, searchParsers, xContentRegistry(), scriptService));
|
||||
factories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, client, xContentRegistry(), scriptService));
|
||||
return new TransformRegistry(Settings.EMPTY, unmodifiableMap(factories));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue