Logging: Drop remaining Settings log ctor (#34149)

Drops the last logging constructor that takes `Settings` because it is
no longer needed.

Watcher goes through a lot of effort to pass `Settings` to `Logger`
constructors and dropping `Settings` from all of those calls allowed us
to remove quite a bit of log-based ceremony from watcher.
This commit is contained in:
Nik Everett 2018-10-04 09:18:04 -04:00 committed by GitHub
parent ef5007b6d8
commit ab8a5563f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 157 additions and 224 deletions

View File

@ -28,7 +28,6 @@ import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.Configurator; import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.LoggerConfig; import org.apache.logging.log4j.core.config.LoggerConfig;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index; import org.elasticsearch.index.Index;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardId;
@ -65,16 +64,6 @@ public class Loggers {
return getLogger(clazz, asArrayList(Loggers.SPACE, index.getName(), prefixes).toArray(new String[0])); return getLogger(clazz, asArrayList(Loggers.SPACE, index.getName(), prefixes).toArray(new String[0]));
} }
/**
* Get a logger.
* @deprecated prefer {@link #getLogger(Class, String...)} or {@link LogManager#getLogger}
* as the Settings is no longer needed
*/
@Deprecated
public static Logger getLogger(Class<?> clazz, Settings settings, String... prefixes) {
return ESLoggerFactory.getLogger(formatPrefix(prefixes), clazz);
}
public static Logger getLogger(Class<?> clazz, String... prefixes) { public static Logger getLogger(Class<?> clazz, String... prefixes) {
return ESLoggerFactory.getLogger(formatPrefix(prefixes), clazz); return ESLoggerFactory.getLogger(formatPrefix(prefixes), clazz);
} }

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.core.watcher.input; package org.elasticsearch.xpack.core.watcher.input;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
@ -17,11 +16,9 @@ import java.io.IOException;
public abstract class ExecutableInput<I extends Input, R extends Input.Result> implements ToXContentObject { public abstract class ExecutableInput<I extends Input, R extends Input.Result> implements ToXContentObject {
protected final I input; protected final I input;
protected final Logger logger;
protected ExecutableInput(I input, Logger logger) { protected ExecutableInput(I input) {
this.input = input; this.input = input;
this.logger = logger;
} }
/** /**

View File

@ -311,32 +311,32 @@ public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin, Reloa
final ConditionRegistry conditionRegistry = new ConditionRegistry(Collections.unmodifiableMap(parsers), getClock()); final ConditionRegistry conditionRegistry = new ConditionRegistry(Collections.unmodifiableMap(parsers), getClock());
final Map<String, TransformFactory> transformFactories = new HashMap<>(); final Map<String, TransformFactory> transformFactories = new HashMap<>();
transformFactories.put(ScriptTransform.TYPE, new ScriptTransformFactory(settings, scriptService)); transformFactories.put(ScriptTransform.TYPE, new ScriptTransformFactory(scriptService));
transformFactories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, client, xContentRegistry, scriptService)); transformFactories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, client, xContentRegistry, scriptService));
final TransformRegistry transformRegistry = new TransformRegistry(Collections.unmodifiableMap(transformFactories)); final TransformRegistry transformRegistry = new TransformRegistry(Collections.unmodifiableMap(transformFactories));
// actions // actions
final Map<String, ActionFactory> actionFactoryMap = new HashMap<>(); final Map<String, ActionFactory> actionFactoryMap = new HashMap<>();
actionFactoryMap.put(EmailAction.TYPE, new EmailActionFactory(settings, emailService, templateEngine, emailAttachmentsParser)); actionFactoryMap.put(EmailAction.TYPE, new EmailActionFactory(settings, emailService, templateEngine, emailAttachmentsParser));
actionFactoryMap.put(WebhookAction.TYPE, new WebhookActionFactory(settings, httpClient, templateEngine)); actionFactoryMap.put(WebhookAction.TYPE, new WebhookActionFactory(httpClient, templateEngine));
actionFactoryMap.put(IndexAction.TYPE, new IndexActionFactory(settings, client)); actionFactoryMap.put(IndexAction.TYPE, new IndexActionFactory(settings, client));
actionFactoryMap.put(LoggingAction.TYPE, new LoggingActionFactory(templateEngine)); actionFactoryMap.put(LoggingAction.TYPE, new LoggingActionFactory(templateEngine));
actionFactoryMap.put(HipChatAction.TYPE, new HipChatActionFactory(settings, templateEngine, hipChatService)); actionFactoryMap.put(HipChatAction.TYPE, new HipChatActionFactory(templateEngine, hipChatService));
actionFactoryMap.put(JiraAction.TYPE, new JiraActionFactory(settings, templateEngine, jiraService)); actionFactoryMap.put(JiraAction.TYPE, new JiraActionFactory(templateEngine, jiraService));
actionFactoryMap.put(SlackAction.TYPE, new SlackActionFactory(settings, templateEngine, slackService)); actionFactoryMap.put(SlackAction.TYPE, new SlackActionFactory(templateEngine, slackService));
actionFactoryMap.put(PagerDutyAction.TYPE, new PagerDutyActionFactory(settings, templateEngine, pagerDutyService)); actionFactoryMap.put(PagerDutyAction.TYPE, new PagerDutyActionFactory(templateEngine, pagerDutyService));
final ActionRegistry registry = new ActionRegistry(actionFactoryMap, conditionRegistry, transformRegistry, getClock(), final ActionRegistry registry = new ActionRegistry(actionFactoryMap, conditionRegistry, transformRegistry, getClock(),
getLicenseState()); getLicenseState());
// inputs // inputs
final Map<String, InputFactory> inputFactories = new HashMap<>(); final Map<String, InputFactory> inputFactories = new HashMap<>();
inputFactories.put(SearchInput.TYPE, new SearchInputFactory(settings, client, xContentRegistry, scriptService)); inputFactories.put(SearchInput.TYPE, new SearchInputFactory(settings, client, xContentRegistry, scriptService));
inputFactories.put(SimpleInput.TYPE, new SimpleInputFactory(settings)); inputFactories.put(SimpleInput.TYPE, new SimpleInputFactory());
inputFactories.put(HttpInput.TYPE, new HttpInputFactory(settings, httpClient, templateEngine)); inputFactories.put(HttpInput.TYPE, new HttpInputFactory(settings, httpClient, templateEngine));
inputFactories.put(NoneInput.TYPE, new NoneInputFactory(settings)); inputFactories.put(NoneInput.TYPE, new NoneInputFactory());
inputFactories.put(TransformInput.TYPE, new TransformInputFactory(settings, transformRegistry)); inputFactories.put(TransformInput.TYPE, new TransformInputFactory(transformRegistry));
final InputRegistry inputRegistry = new InputRegistry(settings, inputFactories); final InputRegistry inputRegistry = new InputRegistry(inputFactories);
inputFactories.put(ChainInput.TYPE, new ChainInputFactory(settings, inputRegistry)); inputFactories.put(ChainInput.TYPE, new ChainInputFactory(inputRegistry));
bulkProcessor = BulkProcessor.builder(ClientHelper.clientWithOrigin(client, WATCHER_ORIGIN), new BulkProcessor.Listener() { bulkProcessor = BulkProcessor.builder(ClientHelper.clientWithOrigin(client, WATCHER_ORIGIN), new BulkProcessor.Listener() {
@Override @Override
@ -438,7 +438,7 @@ public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin, Reloa
} }
protected Consumer<Iterable<TriggerEvent>> getTriggerEngineListener(ExecutionService executionService) { protected Consumer<Iterable<TriggerEvent>> getTriggerEngineListener(ExecutionService executionService) {
return new AsyncTriggerEventConsumer(settings, executionService); return new AsyncTriggerEventConsumer(executionService);
} }
@Override @Override

View File

@ -5,7 +5,7 @@
*/ */
package org.elasticsearch.xpack.watcher.actions.email; package org.elasticsearch.xpack.watcher.actions.email;
import org.elasticsearch.common.logging.Loggers; import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory;
@ -25,7 +25,7 @@ public class EmailActionFactory extends ActionFactory {
public EmailActionFactory(Settings settings, EmailService emailService, TextTemplateEngine templateEngine, public EmailActionFactory(Settings settings, EmailService emailService, TextTemplateEngine templateEngine,
EmailAttachmentsParser emailAttachmentsParser) { EmailAttachmentsParser emailAttachmentsParser) {
super(Loggers.getLogger(ExecutableEmailAction.class, settings)); super(LogManager.getLogger(ExecutableEmailAction.class));
this.emailService = emailService; this.emailService = emailService;
this.templateEngine = templateEngine; this.templateEngine = templateEngine;
this.htmlSanitizer = new HtmlSanitizer(settings); this.htmlSanitizer = new HtmlSanitizer(settings);

View File

@ -5,8 +5,7 @@
*/ */
package org.elasticsearch.xpack.watcher.actions.hipchat; package org.elasticsearch.xpack.watcher.actions.hipchat;
import org.elasticsearch.common.logging.Loggers; import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory;
import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine;
@ -20,8 +19,8 @@ public class HipChatActionFactory extends ActionFactory {
private final TextTemplateEngine templateEngine; private final TextTemplateEngine templateEngine;
private final HipChatService hipchatService; private final HipChatService hipchatService;
public HipChatActionFactory(Settings settings, TextTemplateEngine templateEngine, HipChatService hipchatService) { public HipChatActionFactory(TextTemplateEngine templateEngine, HipChatService hipchatService) {
super(Loggers.getLogger(ExecutableHipChatAction.class, settings)); super(LogManager.getLogger(ExecutableHipChatAction.class));
this.templateEngine = templateEngine; this.templateEngine = templateEngine;
this.hipchatService = hipchatService; this.hipchatService = hipchatService;
} }

View File

@ -5,8 +5,8 @@
*/ */
package org.elasticsearch.xpack.watcher.actions.index; package org.elasticsearch.xpack.watcher.actions.index;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
@ -21,7 +21,7 @@ public class IndexActionFactory extends ActionFactory {
private final TimeValue bulkDefaultTimeout; private final TimeValue bulkDefaultTimeout;
public IndexActionFactory(Settings settings, Client client) { public IndexActionFactory(Settings settings, Client client) {
super(Loggers.getLogger(IndexActionFactory.class, settings)); super(LogManager.getLogger(IndexActionFactory.class));
this.client = client; this.client = client;
this.indexDefaultTimeout = settings.getAsTime("xpack.watcher.actions.index.default_timeout", TimeValue.timeValueSeconds(30)); this.indexDefaultTimeout = settings.getAsTime("xpack.watcher.actions.index.default_timeout", TimeValue.timeValueSeconds(30));
this.bulkDefaultTimeout = settings.getAsTime("xpack.watcher.actions.bulk.default_timeout", TimeValue.timeValueMinutes(1)); this.bulkDefaultTimeout = settings.getAsTime("xpack.watcher.actions.bulk.default_timeout", TimeValue.timeValueMinutes(1));

View File

@ -5,8 +5,7 @@
*/ */
package org.elasticsearch.xpack.watcher.actions.jira; package org.elasticsearch.xpack.watcher.actions.jira;
import org.elasticsearch.common.logging.Loggers; import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory;
import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine;
@ -19,8 +18,8 @@ public class JiraActionFactory extends ActionFactory {
private final TextTemplateEngine templateEngine; private final TextTemplateEngine templateEngine;
private final JiraService jiraService; private final JiraService jiraService;
public JiraActionFactory(Settings settings, TextTemplateEngine templateEngine, JiraService jiraService) { public JiraActionFactory(TextTemplateEngine templateEngine, JiraService jiraService) {
super(Loggers.getLogger(ExecutableJiraAction.class, settings)); super(LogManager.getLogger(ExecutableJiraAction.class));
this.templateEngine = templateEngine; this.templateEngine = templateEngine;
this.jiraService = jiraService; this.jiraService = jiraService;
} }

View File

@ -5,8 +5,7 @@
*/ */
package org.elasticsearch.xpack.watcher.actions.pagerduty; package org.elasticsearch.xpack.watcher.actions.pagerduty;
import org.elasticsearch.common.logging.Loggers; import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory;
import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine;
@ -19,8 +18,8 @@ public class PagerDutyActionFactory extends ActionFactory {
private final TextTemplateEngine templateEngine; private final TextTemplateEngine templateEngine;
private final PagerDutyService pagerDutyService; private final PagerDutyService pagerDutyService;
public PagerDutyActionFactory(Settings settings, TextTemplateEngine templateEngine, PagerDutyService pagerDutyService) { public PagerDutyActionFactory(TextTemplateEngine templateEngine, PagerDutyService pagerDutyService) {
super(Loggers.getLogger(ExecutablePagerDutyAction.class, settings)); super(LogManager.getLogger(ExecutablePagerDutyAction.class));
this.templateEngine = templateEngine; this.templateEngine = templateEngine;
this.pagerDutyService = pagerDutyService; this.pagerDutyService = pagerDutyService;
} }

View File

@ -5,8 +5,7 @@
*/ */
package org.elasticsearch.xpack.watcher.actions.slack; package org.elasticsearch.xpack.watcher.actions.slack;
import org.elasticsearch.common.logging.Loggers; import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory;
import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine;
@ -18,8 +17,8 @@ public class SlackActionFactory extends ActionFactory {
private final TextTemplateEngine templateEngine; private final TextTemplateEngine templateEngine;
private final SlackService slackService; private final SlackService slackService;
public SlackActionFactory(Settings settings, TextTemplateEngine templateEngine, SlackService slackService) { public SlackActionFactory(TextTemplateEngine templateEngine, SlackService slackService) {
super(Loggers.getLogger(ExecutableSlackAction.class, settings)); super(LogManager.getLogger(ExecutableSlackAction.class));
this.templateEngine = templateEngine; this.templateEngine = templateEngine;
this.slackService = slackService; this.slackService = slackService;
} }

View File

@ -5,8 +5,7 @@
*/ */
package org.elasticsearch.xpack.watcher.actions.webhook; package org.elasticsearch.xpack.watcher.actions.webhook;
import org.elasticsearch.common.logging.Loggers; import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory;
import org.elasticsearch.xpack.watcher.common.http.HttpClient; import org.elasticsearch.xpack.watcher.common.http.HttpClient;
@ -19,9 +18,8 @@ public class WebhookActionFactory extends ActionFactory {
private final HttpClient httpClient; private final HttpClient httpClient;
private final TextTemplateEngine templateEngine; private final TextTemplateEngine templateEngine;
public WebhookActionFactory(Settings settings, HttpClient httpClient, TextTemplateEngine templateEngine) { public WebhookActionFactory(HttpClient httpClient, TextTemplateEngine templateEngine) {
super(LogManager.getLogger(ExecutableWebhookAction.class));
super(Loggers.getLogger(ExecutableWebhookAction.class, settings));
this.httpClient = httpClient; this.httpClient = httpClient;
this.templateEngine = templateEngine; this.templateEngine = templateEngine;
} }

View File

@ -6,10 +6,9 @@
package org.elasticsearch.xpack.watcher.execution; package org.elasticsearch.xpack.watcher.execution;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier; import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xpack.core.watcher.trigger.TriggerEvent; import org.elasticsearch.xpack.core.watcher.trigger.TriggerEvent;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -17,12 +16,10 @@ import java.util.function.Consumer;
import static java.util.stream.StreamSupport.stream; import static java.util.stream.StreamSupport.stream;
public class AsyncTriggerEventConsumer implements Consumer<Iterable<TriggerEvent>> { public class AsyncTriggerEventConsumer implements Consumer<Iterable<TriggerEvent>> {
private static final Logger logger = LogManager.getLogger(SyncTriggerEventConsumer.class);
private final Logger logger;
private final ExecutionService executionService; private final ExecutionService executionService;
public AsyncTriggerEventConsumer(Settings settings, ExecutionService executionService) { public AsyncTriggerEventConsumer(ExecutionService executionService) {
this.logger = Loggers.getLogger(SyncTriggerEventConsumer.class, settings);
this.executionService = executionService; this.executionService = executionService;
} }

View File

@ -6,10 +6,9 @@
package org.elasticsearch.xpack.watcher.execution; package org.elasticsearch.xpack.watcher.execution;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier; import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xpack.core.watcher.trigger.TriggerEvent; import org.elasticsearch.xpack.core.watcher.trigger.TriggerEvent;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -17,12 +16,11 @@ import java.util.function.Consumer;
import static java.util.stream.StreamSupport.stream; import static java.util.stream.StreamSupport.stream;
public class SyncTriggerEventConsumer implements Consumer<Iterable<TriggerEvent>> { public class SyncTriggerEventConsumer implements Consumer<Iterable<TriggerEvent>> {
private static final Logger logger = LogManager.getLogger(SyncTriggerEventConsumer.class);
private final ExecutionService executionService; private final ExecutionService executionService;
private final Logger logger;
public SyncTriggerEventConsumer(Settings settings, ExecutionService executionService) { public SyncTriggerEventConsumer(ExecutionService executionService) {
this.logger = Loggers.getLogger(SyncTriggerEventConsumer.class, settings);
this.executionService = executionService; this.executionService = executionService;
} }

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.input; package org.elasticsearch.xpack.watcher.input;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput;
import org.elasticsearch.xpack.core.watcher.input.Input; import org.elasticsearch.xpack.core.watcher.input.Input;
@ -16,13 +15,6 @@ import java.io.IOException;
* Parses xcontent to a concrete input of the same type. * Parses xcontent to a concrete input of the same type.
*/ */
public abstract class InputFactory<I extends Input, R extends Input.Result, E extends ExecutableInput<I, R>> { public abstract class InputFactory<I extends Input, R extends Input.Result, E extends ExecutableInput<I, R>> {
protected final Logger inputLogger;
public InputFactory(Logger inputLogger) {
this.inputLogger = inputLogger;
}
/** /**
* @return The type of the input * @return The type of the input
*/ */

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.watcher.input; package org.elasticsearch.xpack.watcher.input;
import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput;
import org.elasticsearch.xpack.watcher.input.chain.ChainInput; import org.elasticsearch.xpack.watcher.input.chain.ChainInput;
@ -21,9 +20,9 @@ public class InputRegistry {
private final Map<String, InputFactory> factories; private final Map<String, InputFactory> factories;
public InputRegistry(Settings settings, Map<String, InputFactory> factories) { public InputRegistry(Map<String, InputFactory> factories) {
Map<String, InputFactory> map = new HashMap<>(factories); Map<String, InputFactory> map = new HashMap<>(factories);
map.put(ChainInput.TYPE, new ChainInputFactory(settings, this)); map.put(ChainInput.TYPE, new ChainInputFactory(this));
this.factories = Collections.unmodifiableMap(map); this.factories = Collections.unmodifiableMap(map);
} }

View File

@ -6,8 +6,6 @@
package org.elasticsearch.xpack.watcher.input.chain; package org.elasticsearch.xpack.watcher.input.chain;
import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput;
import org.elasticsearch.xpack.core.watcher.input.Input; import org.elasticsearch.xpack.core.watcher.input.Input;
@ -22,8 +20,7 @@ public class ChainInputFactory extends InputFactory<ChainInput, ChainInput.Resul
private final InputRegistry inputRegistry; private final InputRegistry inputRegistry;
public ChainInputFactory(Settings settings, InputRegistry inputRegistry) { public ChainInputFactory(InputRegistry inputRegistry) {
super(Loggers.getLogger(ExecutableChainInput.class, settings));
this.inputRegistry = inputRegistry; this.inputRegistry = inputRegistry;
} }
@ -45,6 +42,6 @@ public class ChainInputFactory extends InputFactory<ChainInput, ChainInput.Resul
executableInputs.add(new Tuple<>(tuple.v1(), executableInput)); executableInputs.add(new Tuple<>(tuple.v1(), executableInput));
} }
return new ExecutableChainInput(input, executableInputs, inputLogger); return new ExecutableChainInput(input, executableInputs);
} }
} }

View File

@ -6,6 +6,7 @@
package org.elasticsearch.xpack.watcher.input.chain; package org.elasticsearch.xpack.watcher.input.chain;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext; import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext;
import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput;
@ -20,11 +21,12 @@ import java.util.Map;
import static org.elasticsearch.xpack.watcher.input.chain.ChainInput.TYPE; import static org.elasticsearch.xpack.watcher.input.chain.ChainInput.TYPE;
public class ExecutableChainInput extends ExecutableInput<ChainInput,ChainInput.Result> { public class ExecutableChainInput extends ExecutableInput<ChainInput,ChainInput.Result> {
private static final Logger logger = LogManager.getLogger(ExecutableChainInput.class);
private List<Tuple<String, ExecutableInput>> inputs; private List<Tuple<String, ExecutableInput>> inputs;
public ExecutableChainInput(ChainInput input, List<Tuple<String, ExecutableInput>> inputs, Logger logger) { public ExecutableChainInput(ChainInput input, List<Tuple<String, ExecutableInput>> inputs) {
super(input, logger); super(input);
this.inputs = inputs; this.inputs = inputs;
} }

View File

@ -7,6 +7,7 @@ package org.elasticsearch.xpack.watcher.input.http;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@ -31,12 +32,13 @@ import java.util.Map;
import static org.elasticsearch.xpack.watcher.input.http.HttpInput.TYPE; import static org.elasticsearch.xpack.watcher.input.http.HttpInput.TYPE;
public class ExecutableHttpInput extends ExecutableInput<HttpInput, HttpInput.Result> { public class ExecutableHttpInput extends ExecutableInput<HttpInput, HttpInput.Result> {
private static final Logger logger = LogManager.getLogger(ExecutableHttpInput.class);
private final HttpClient client; private final HttpClient client;
private final TextTemplateEngine templateEngine; private final TextTemplateEngine templateEngine;
public ExecutableHttpInput(HttpInput input, Logger logger, HttpClient client, TextTemplateEngine templateEngine) { public ExecutableHttpInput(HttpInput input, HttpClient client, TextTemplateEngine templateEngine) {
super(input, logger); super(input);
this.client = client; this.client = client;
this.templateEngine = templateEngine; this.templateEngine = templateEngine;
} }

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.input.http; package org.elasticsearch.xpack.watcher.input.http;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.watcher.common.http.HttpClient; import org.elasticsearch.xpack.watcher.common.http.HttpClient;
@ -20,7 +19,6 @@ public final class HttpInputFactory extends InputFactory<HttpInput, HttpInput.Re
private final TextTemplateEngine templateEngine; private final TextTemplateEngine templateEngine;
public HttpInputFactory(Settings settings, HttpClient httpClient, TextTemplateEngine templateEngine) { public HttpInputFactory(Settings settings, HttpClient httpClient, TextTemplateEngine templateEngine) {
super(Loggers.getLogger(ExecutableHttpInput.class, settings));
this.templateEngine = templateEngine; this.templateEngine = templateEngine;
this.httpClient = httpClient; this.httpClient = httpClient;
} }
@ -37,6 +35,6 @@ public final class HttpInputFactory extends InputFactory<HttpInput, HttpInput.Re
@Override @Override
public ExecutableHttpInput createExecutable(HttpInput input) { public ExecutableHttpInput createExecutable(HttpInput input) {
return new ExecutableHttpInput(input, inputLogger, httpClient, templateEngine); return new ExecutableHttpInput(input, httpClient, templateEngine);
} }
} }

View File

@ -5,8 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.input.none; package org.elasticsearch.xpack.watcher.input.none;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext; import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext;
import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput;
import org.elasticsearch.xpack.core.watcher.input.none.NoneInput; import org.elasticsearch.xpack.core.watcher.input.none.NoneInput;
@ -14,8 +12,8 @@ import org.elasticsearch.xpack.core.watcher.watch.Payload;
public class ExecutableNoneInput extends ExecutableInput<NoneInput, NoneInput.Result> { public class ExecutableNoneInput extends ExecutableInput<NoneInput, NoneInput.Result> {
public ExecutableNoneInput(Logger logger) { public ExecutableNoneInput() {
super(NoneInput.INSTANCE, logger); super(NoneInput.INSTANCE);
} }
@Override @Override

View File

@ -5,8 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.input.none; package org.elasticsearch.xpack.watcher.input.none;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.input.none.NoneInput; import org.elasticsearch.xpack.core.watcher.input.none.NoneInput;
import org.elasticsearch.xpack.watcher.input.InputFactory; import org.elasticsearch.xpack.watcher.input.InputFactory;
@ -14,11 +12,6 @@ import org.elasticsearch.xpack.watcher.input.InputFactory;
import java.io.IOException; import java.io.IOException;
public class NoneInputFactory extends InputFactory<NoneInput, NoneInput.Result, ExecutableNoneInput> { public class NoneInputFactory extends InputFactory<NoneInput, NoneInput.Result, ExecutableNoneInput> {
public NoneInputFactory(Settings settings) {
super(Loggers.getLogger(ExecutableNoneInput.class, settings));
}
@Override @Override
public String type() { public String type() {
return NoneInput.TYPE; return NoneInput.TYPE;
@ -31,6 +24,6 @@ public class NoneInputFactory extends InputFactory<NoneInput, NoneInput.Result,
@Override @Override
public ExecutableNoneInput createExecutable(NoneInput input) { public ExecutableNoneInput createExecutable(NoneInput input) {
return new ExecutableNoneInput(inputLogger); return new ExecutableNoneInput();
} }
} }

View File

@ -6,6 +6,7 @@
package org.elasticsearch.xpack.watcher.input.search; package org.elasticsearch.xpack.watcher.input.search;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType; import org.elasticsearch.action.search.SearchType;
@ -39,13 +40,15 @@ public class ExecutableSearchInput extends ExecutableInput<SearchInput, SearchIn
public static final SearchType DEFAULT_SEARCH_TYPE = SearchType.QUERY_THEN_FETCH; public static final SearchType DEFAULT_SEARCH_TYPE = SearchType.QUERY_THEN_FETCH;
private static final Logger logger = LogManager.getLogger(ExecutableSearchInput.class);
private final Client client; private final Client client;
private final WatcherSearchTemplateService searchTemplateService; private final WatcherSearchTemplateService searchTemplateService;
private final TimeValue timeout; private final TimeValue timeout;
public ExecutableSearchInput(SearchInput input, Logger logger, Client client, WatcherSearchTemplateService searchTemplateService, public ExecutableSearchInput(SearchInput input, Client client, WatcherSearchTemplateService searchTemplateService,
TimeValue defaultTimeout) { TimeValue defaultTimeout) {
super(input, logger); super(input);
this.client = client; this.client = client;
this.searchTemplateService = searchTemplateService; this.searchTemplateService = searchTemplateService;
this.timeout = input.getTimeout() != null ? input.getTimeout() : defaultTimeout; this.timeout = input.getTimeout() != null ? input.getTimeout() : defaultTimeout;

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.watcher.input.search; package org.elasticsearch.xpack.watcher.input.search;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@ -25,7 +24,6 @@ public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Re
public SearchInputFactory(Settings settings, Client client, NamedXContentRegistry xContentRegistry, public SearchInputFactory(Settings settings, Client client, NamedXContentRegistry xContentRegistry,
ScriptService scriptService) { ScriptService scriptService) {
super(Loggers.getLogger(ExecutableSearchInput.class, settings));
this.client = client; this.client = client;
this.defaultTimeout = settings.getAsTime("xpack.watcher.input.search.default_timeout", TimeValue.timeValueMinutes(1)); this.defaultTimeout = settings.getAsTime("xpack.watcher.input.search.default_timeout", TimeValue.timeValueMinutes(1));
this.searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, xContentRegistry); this.searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, xContentRegistry);
@ -43,6 +41,6 @@ public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Re
@Override @Override
public ExecutableSearchInput createExecutable(SearchInput input) { public ExecutableSearchInput createExecutable(SearchInput input) {
return new ExecutableSearchInput(input, inputLogger, client, searchTemplateService, defaultTimeout); return new ExecutableSearchInput(input, client, searchTemplateService, defaultTimeout);
} }
} }

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.input.simple; package org.elasticsearch.xpack.watcher.input.simple;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext; import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext;
import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput;
import org.elasticsearch.xpack.core.watcher.watch.Payload; import org.elasticsearch.xpack.core.watcher.watch.Payload;
@ -15,8 +14,8 @@ import org.elasticsearch.xpack.core.watcher.watch.Payload;
*/ */
public class ExecutableSimpleInput extends ExecutableInput<SimpleInput, SimpleInput.Result> { public class ExecutableSimpleInput extends ExecutableInput<SimpleInput, SimpleInput.Result> {
public ExecutableSimpleInput(SimpleInput input, Logger logger) { public ExecutableSimpleInput(SimpleInput input) {
super(input, logger); super(input);
} }
@Override @Override

View File

@ -5,19 +5,12 @@
*/ */
package org.elasticsearch.xpack.watcher.input.simple; package org.elasticsearch.xpack.watcher.input.simple;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.watcher.input.InputFactory; import org.elasticsearch.xpack.watcher.input.InputFactory;
import java.io.IOException; import java.io.IOException;
public class SimpleInputFactory extends InputFactory<SimpleInput, SimpleInput.Result, ExecutableSimpleInput> { public class SimpleInputFactory extends InputFactory<SimpleInput, SimpleInput.Result, ExecutableSimpleInput> {
public SimpleInputFactory(Settings settings) {
super(Loggers.getLogger(ExecutableSimpleInput.class, settings));
}
@Override @Override
public String type() { public String type() {
return SimpleInput.TYPE; return SimpleInput.TYPE;
@ -30,6 +23,6 @@ public class SimpleInputFactory extends InputFactory<SimpleInput, SimpleInput.Re
@Override @Override
public ExecutableSimpleInput createExecutable(SimpleInput input) { public ExecutableSimpleInput createExecutable(SimpleInput input) {
return new ExecutableSimpleInput(input, inputLogger); return new ExecutableSimpleInput(input);
} }
} }

View File

@ -5,7 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.input.transform; package org.elasticsearch.xpack.watcher.input.transform;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext; import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext;
import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput;
import org.elasticsearch.xpack.core.watcher.transform.ExecutableTransform; import org.elasticsearch.xpack.core.watcher.transform.ExecutableTransform;
@ -16,8 +15,8 @@ public final class ExecutableTransformInput extends ExecutableInput<TransformInp
private final ExecutableTransform executableTransform; private final ExecutableTransform executableTransform;
ExecutableTransformInput(TransformInput input, Logger logger, ExecutableTransform executableTransform) { ExecutableTransformInput(TransformInput input, ExecutableTransform executableTransform) {
super(input, logger); super(input);
this.executableTransform = executableTransform; this.executableTransform = executableTransform;
} }

View File

@ -5,8 +5,6 @@
*/ */
package org.elasticsearch.xpack.watcher.input.transform; package org.elasticsearch.xpack.watcher.input.transform;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentParserUtils; import org.elasticsearch.common.xcontent.XContentParserUtils;
import org.elasticsearch.xpack.core.watcher.transform.ExecutableTransform; import org.elasticsearch.xpack.core.watcher.transform.ExecutableTransform;
@ -31,8 +29,7 @@ public final class TransformInputFactory extends InputFactory<TransformInput, Tr
private final TransformRegistry transformRegistry; private final TransformRegistry transformRegistry;
public TransformInputFactory(Settings settings, TransformRegistry transformRegistry) { public TransformInputFactory(TransformRegistry transformRegistry) {
super(Loggers.getLogger(ExecutableTransformInput.class, settings));
this.transformRegistry = transformRegistry; this.transformRegistry = transformRegistry;
} }
@ -53,6 +50,6 @@ public final class TransformInputFactory extends InputFactory<TransformInput, Tr
Transform transform = input.getTransform(); Transform transform = input.getTransform();
TransformFactory factory = transformRegistry.factory(transform.type()); TransformFactory factory = transformRegistry.factory(transform.type());
ExecutableTransform executableTransform = factory.createExecutable(transform); ExecutableTransform executableTransform = factory.createExecutable(transform);
return new ExecutableTransformInput(input, inputLogger, executableTransform); return new ExecutableTransformInput(input, executableTransform);
} }
} }

View File

@ -5,8 +5,7 @@
*/ */
package org.elasticsearch.xpack.watcher.transform.script; package org.elasticsearch.xpack.watcher.transform.script;
import org.elasticsearch.common.logging.Loggers; import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.ScriptService;
import org.elasticsearch.xpack.core.watcher.transform.TransformFactory; import org.elasticsearch.xpack.core.watcher.transform.TransformFactory;
@ -17,8 +16,8 @@ public class ScriptTransformFactory extends TransformFactory<ScriptTransform, Sc
private final ScriptService scriptService; private final ScriptService scriptService;
public ScriptTransformFactory(Settings settings, ScriptService scriptService) { public ScriptTransformFactory(ScriptService scriptService) {
super(Loggers.getLogger(ExecutableScriptTransform.class, settings)); super(LogManager.getLogger(ExecutableScriptTransform.class));
this.scriptService = scriptService; this.scriptService = scriptService;
} }

View File

@ -5,8 +5,8 @@
*/ */
package org.elasticsearch.xpack.watcher.transform.search; package org.elasticsearch.xpack.watcher.transform.search;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@ -24,7 +24,7 @@ public class SearchTransformFactory extends TransformFactory<SearchTransform, Se
private final WatcherSearchTemplateService searchTemplateService; private final WatcherSearchTemplateService searchTemplateService;
public SearchTransformFactory(Settings settings, Client client, NamedXContentRegistry xContentRegistry, ScriptService scriptService) { public SearchTransformFactory(Settings settings, Client client, NamedXContentRegistry xContentRegistry, ScriptService scriptService) {
super(Loggers.getLogger(ExecutableSearchTransform.class, settings)); super(LogManager.getLogger(ExecutableSearchTransform.class));
this.client = client; this.client = client;
this.defaultTimeout = settings.getAsTime("xpack.watcher.transform.search.default_timeout", TimeValue.timeValueMinutes(1)); this.defaultTimeout = settings.getAsTime("xpack.watcher.transform.search.default_timeout", TimeValue.timeValueMinutes(1));
this.searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, xContentRegistry); this.searchTemplateService = new WatcherSearchTemplateService(settings, scriptService, xContentRegistry);

View File

@ -68,7 +68,7 @@ public class WatchParser extends AbstractComponent {
this.inputRegistry = inputRegistry; this.inputRegistry = inputRegistry;
this.cryptoService = cryptoService; this.cryptoService = cryptoService;
this.clock = clock; this.clock = clock;
this.defaultInput = new ExecutableNoneInput(logger); this.defaultInput = new ExecutableNoneInput();
this.defaultCondition = InternalAlwaysCondition.INSTANCE; this.defaultCondition = InternalAlwaysCondition.INSTANCE;
this.defaultActions = Collections.emptyList(); this.defaultActions = Collections.emptyList();
} }

View File

@ -231,7 +231,7 @@ public class WatcherServiceTests extends ESTestCase {
Watch watch = mock(Watch.class); Watch watch = mock(Watch.class);
when(watch.trigger()).thenReturn(trigger); when(watch.trigger()).thenReturn(trigger);
when(watch.condition()).thenReturn(InternalAlwaysCondition.INSTANCE); when(watch.condition()).thenReturn(InternalAlwaysCondition.INSTANCE);
ExecutableNoneInput noneInput = new ExecutableNoneInput(logger); ExecutableNoneInput noneInput = new ExecutableNoneInput();
when(watch.input()).thenReturn(noneInput); when(watch.input()).thenReturn(noneInput);
triggerService.add(watch); triggerService.add(watch);

View File

@ -281,8 +281,7 @@ public class EmailActionTests extends ESTestCase {
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes); XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
parser.nextToken(); parser.nextToken();
ExecutableEmailAction executable = new EmailActionFactory(Settings.EMPTY, emailService, engine, ExecutableEmailAction executable = new EmailActionFactory(Settings.EMPTY, emailService, engine, emailAttachmentParser)
emailAttachmentParser)
.parseExecutable(randomAlphaOfLength(8), randomAlphaOfLength(3), parser); .parseExecutable(randomAlphaOfLength(8), randomAlphaOfLength(3), parser);
assertThat(executable, notNullValue()); assertThat(executable, notNullValue());
@ -530,8 +529,8 @@ public class EmailActionTests extends ESTestCase {
parser.nextToken(); parser.nextToken();
ExecutableEmailAction executableEmailAction = new EmailActionFactory(Settings.EMPTY, emailService, engine, ExecutableEmailAction executableEmailAction = new EmailActionFactory(Settings.EMPTY, emailService, engine, emailAttachmentsParser)
emailAttachmentsParser).parseExecutable(randomAlphaOfLength(3), randomAlphaOfLength(7), parser); .parseExecutable(randomAlphaOfLength(3), randomAlphaOfLength(7), parser);
DateTime now = DateTime.now(DateTimeZone.UTC); DateTime now = DateTime.now(DateTimeZone.UTC);
Wid wid = new Wid(randomAlphaOfLength(5), now); Wid wid = new Wid(randomAlphaOfLength(5), now);

View File

@ -72,7 +72,7 @@ public class EmailMessageIdTests extends ESTestCase {
ExecutableEmailAction secondEmailAction = new ExecutableEmailAction(emailAction, logger, emailService, textTemplateEngine, ExecutableEmailAction secondEmailAction = new ExecutableEmailAction(emailAction, logger, emailService, textTemplateEngine,
htmlSanitizer, Collections.emptyMap()); htmlSanitizer, Collections.emptyMap());
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
firstEmailAction.execute("my_first_action_id", ctx, Payload.EMPTY); firstEmailAction.execute("my_first_action_id", ctx, Payload.EMPTY);
secondEmailAction.execute("my_second_action_id", ctx, Payload.EMPTY); secondEmailAction.execute("my_second_action_id", ctx, Payload.EMPTY);

View File

@ -32,7 +32,7 @@ public class HipChatActionFactoryTests extends ESTestCase {
@Before @Before
public void init() throws Exception { public void init() throws Exception {
hipchatService = mock(HipChatService.class); hipchatService = mock(HipChatService.class);
factory = new HipChatActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), hipchatService); factory = new HipChatActionFactory(mock(TextTemplateEngine.class), hipchatService);
} }
public void testParseAction() throws Exception { public void testParseAction() throws Exception {
@ -53,7 +53,7 @@ public class HipChatActionFactoryTests extends ESTestCase {
public void testParseActionUnknownAccount() throws Exception { public void testParseActionUnknownAccount() throws Exception {
hipchatService = new HipChatService(Settings.EMPTY, null, new ClusterSettings(Settings.EMPTY, hipchatService = new HipChatService(Settings.EMPTY, null, new ClusterSettings(Settings.EMPTY,
new HashSet<>(HipChatService.getSettings()))); new HashSet<>(HipChatService.getSettings())));
factory = new HipChatActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), hipchatService); factory = new HipChatActionFactory(mock(TextTemplateEngine.class), hipchatService);
HipChatAction action = hipchatAction("_unknown", "_body").build(); HipChatAction action = hipchatAction("_unknown", "_body").build();
XContentBuilder jsonBuilder = jsonBuilder().value(action); XContentBuilder jsonBuilder = jsonBuilder().value(action);
XContentParser parser = createParser(jsonBuilder); XContentParser parser = createParser(jsonBuilder);

View File

@ -31,7 +31,7 @@ public class PagerDutyActionFactoryTests extends ESTestCase {
@Before @Before
public void init() throws Exception { public void init() throws Exception {
service = mock(PagerDutyService.class); service = mock(PagerDutyService.class);
factory = new PagerDutyActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), service); factory = new PagerDutyActionFactory(mock(TextTemplateEngine.class), service);
} }
public void testParseAction() throws Exception { public void testParseAction() throws Exception {
@ -49,7 +49,7 @@ public class PagerDutyActionFactoryTests extends ESTestCase {
} }
public void testParseActionUnknownAccount() throws Exception { public void testParseActionUnknownAccount() throws Exception {
factory = new PagerDutyActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), new PagerDutyService(Settings.EMPTY, null, factory = new PagerDutyActionFactory(mock(TextTemplateEngine.class), new PagerDutyService(Settings.EMPTY, null,
new ClusterSettings(Settings.EMPTY, new HashSet<>(PagerDutyService.getSettings())))); new ClusterSettings(Settings.EMPTY, new HashSet<>(PagerDutyService.getSettings()))));
PagerDutyAction action = triggerPagerDutyAction("_unknown", "_body").build(); PagerDutyAction action = triggerPagerDutyAction("_unknown", "_body").build();
XContentBuilder jsonBuilder = jsonBuilder().value(action); XContentBuilder jsonBuilder = jsonBuilder().value(action);

View File

@ -31,7 +31,7 @@ public class SlackActionFactoryTests extends ESTestCase {
@Before @Before
public void init() throws Exception { public void init() throws Exception {
service = mock(SlackService.class); service = mock(SlackService.class);
factory = new SlackActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), service); factory = new SlackActionFactory(mock(TextTemplateEngine.class), service);
} }
public void testParseAction() throws Exception { public void testParseAction() throws Exception {
@ -50,7 +50,7 @@ public class SlackActionFactoryTests extends ESTestCase {
public void testParseActionUnknownAccount() throws Exception { public void testParseActionUnknownAccount() throws Exception {
SlackService service = new SlackService(Settings.EMPTY, null, new ClusterSettings(Settings.EMPTY, SlackService service = new SlackService(Settings.EMPTY, null, new ClusterSettings(Settings.EMPTY,
new HashSet<>(SlackService.getSettings()))); new HashSet<>(SlackService.getSettings())));
factory = new SlackActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), service); factory = new SlackActionFactory(mock(TextTemplateEngine.class), service);
SlackAction action = slackAction("_unknown", createRandomTemplate()).build(); SlackAction action = slackAction("_unknown", createRandomTemplate()).build();
XContentBuilder jsonBuilder = jsonBuilder().value(action); XContentBuilder jsonBuilder = jsonBuilder().value(action);
XContentParser parser = createParser(jsonBuilder); XContentParser parser = createParser(jsonBuilder);

View File

@ -208,7 +208,7 @@ public class WebhookActionTests extends ESTestCase {
} }
private WebhookActionFactory webhookFactory(HttpClient client) { private WebhookActionFactory webhookFactory(HttpClient client) {
return new WebhookActionFactory(Settings.EMPTY, client, templateEngine); return new WebhookActionFactory(client, templateEngine);
} }
public void testThatSelectingProxyWorks() throws Exception { public void testThatSelectingProxyWorks() throws Exception {

View File

@ -1015,7 +1015,7 @@ public class ExecutionServiceTests extends ESTestCase {
public void testUpdateWatchStatusDoesNotUpdateState() throws Exception { public void testUpdateWatchStatusDoesNotUpdateState() throws Exception {
WatchStatus status = new WatchStatus(DateTime.now(UTC), Collections.emptyMap()); WatchStatus status = new WatchStatus(DateTime.now(UTC), Collections.emptyMap());
Watch watch = new Watch("_id", new ManualTrigger(), new ExecutableNoneInput(logger), InternalAlwaysCondition.INSTANCE, null, null, Watch watch = new Watch("_id", new ManualTrigger(), new ExecutableNoneInput(), InternalAlwaysCondition.INSTANCE, null, null,
Collections.emptyList(), null, status, 1L); Collections.emptyList(), null, status, 1L);
final AtomicBoolean assertionsTriggered = new AtomicBoolean(false); final AtomicBoolean assertionsTriggered = new AtomicBoolean(false);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.watcher.input; package org.elasticsearch.xpack.watcher.input;
import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
@ -17,7 +16,7 @@ import static org.hamcrest.Matchers.containsString;
public class InputRegistryTests extends ESTestCase { public class InputRegistryTests extends ESTestCase {
public void testParseEmptyInput() throws Exception { public void testParseEmptyInput() throws Exception {
InputRegistry registry = new InputRegistry(Settings.EMPTY, emptyMap()); InputRegistry registry = new InputRegistry(emptyMap());
XContentParser parser = createParser(jsonBuilder().startObject().endObject()); XContentParser parser = createParser(jsonBuilder().startObject().endObject());
parser.nextToken(); parser.nextToken();
try { try {
@ -29,7 +28,7 @@ public class InputRegistryTests extends ESTestCase {
} }
public void testParseArrayInput() throws Exception { public void testParseArrayInput() throws Exception {
InputRegistry registry = new InputRegistry(Settings.EMPTY, emptyMap()); InputRegistry registry = new InputRegistry(emptyMap());
XContentParser parser = createParser(jsonBuilder().startArray().endArray()); XContentParser parser = createParser(jsonBuilder().startArray().endArray());
parser.nextToken(); parser.nextToken();
try { try {

View File

@ -10,7 +10,6 @@ import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
@ -63,11 +62,11 @@ public class ChainInputTests extends ESTestCase {
*/ */
public void testThatExecutionWorks() throws Exception { public void testThatExecutionWorks() throws Exception {
Map<String, InputFactory> factories = new HashMap<>(); Map<String, InputFactory> factories = new HashMap<>();
factories.put("simple", new SimpleInputFactory(Settings.EMPTY)); factories.put("simple", new SimpleInputFactory());
// hackedy hack... // hackedy hack...
InputRegistry inputRegistry = new InputRegistry(Settings.EMPTY, factories); InputRegistry inputRegistry = new InputRegistry(factories);
ChainInputFactory chainInputFactory = new ChainInputFactory(Settings.EMPTY, inputRegistry); ChainInputFactory chainInputFactory = new ChainInputFactory(inputRegistry);
factories.put("chain", chainInputFactory); factories.put("chain", chainInputFactory);
XContentBuilder builder = jsonBuilder().startObject().startArray("inputs") XContentBuilder builder = jsonBuilder().startObject().startArray("inputs")
@ -88,7 +87,7 @@ public class ChainInputTests extends ESTestCase {
// now execute // now execute
ExecutableChainInput executableChainInput = chainInputFactory.createExecutable(chainInput); ExecutableChainInput executableChainInput = chainInputFactory.createExecutable(chainInput);
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
ChainInput.Result result = executableChainInput.execute(ctx, new Payload.Simple()); ChainInput.Result result = executableChainInput.execute(ctx, new Payload.Simple());
Payload payload = result.payload(); Payload payload = result.payload();
assertThat(payload.data(), hasKey("first")); assertThat(payload.data(), hasKey("first"));
@ -117,10 +116,10 @@ public class ChainInputTests extends ESTestCase {
// parsing it back as well! // parsing it back as well!
Map<String, InputFactory> factories = new HashMap<>(); Map<String, InputFactory> factories = new HashMap<>();
factories.put("simple", new SimpleInputFactory(Settings.EMPTY)); factories.put("simple", new SimpleInputFactory());
InputRegistry inputRegistry = new InputRegistry(Settings.EMPTY, factories); InputRegistry inputRegistry = new InputRegistry(factories);
ChainInputFactory chainInputFactory = new ChainInputFactory(Settings.EMPTY, inputRegistry); ChainInputFactory chainInputFactory = new ChainInputFactory(inputRegistry);
factories.put("chain", chainInputFactory); factories.put("chain", chainInputFactory);
XContentParser parser = createParser(builder); XContentParser parser = createParser(builder);
@ -177,10 +176,10 @@ public class ChainInputTests extends ESTestCase {
*/ */
public void testParsingShouldBeStrictWhenClosingInputs() throws Exception { public void testParsingShouldBeStrictWhenClosingInputs() throws Exception {
Map<String, InputFactory> factories = new HashMap<>(); Map<String, InputFactory> factories = new HashMap<>();
factories.put("simple", new SimpleInputFactory(Settings.EMPTY)); factories.put("simple", new SimpleInputFactory());
InputRegistry inputRegistry = new InputRegistry(Settings.EMPTY, factories); InputRegistry inputRegistry = new InputRegistry(factories);
ChainInputFactory chainInputFactory = new ChainInputFactory(Settings.EMPTY, inputRegistry); ChainInputFactory chainInputFactory = new ChainInputFactory(inputRegistry);
factories.put("chain", chainInputFactory); factories.put("chain", chainInputFactory);
XContentBuilder builder = jsonBuilder().startObject().startArray("inputs").startObject() XContentBuilder builder = jsonBuilder().startObject().startArray("inputs").startObject()
@ -206,10 +205,10 @@ public class ChainInputTests extends ESTestCase {
*/ */
public void testParsingShouldBeStrictWhenStartingInputs() throws Exception { public void testParsingShouldBeStrictWhenStartingInputs() throws Exception {
Map<String, InputFactory> factories = new HashMap<>(); Map<String, InputFactory> factories = new HashMap<>();
factories.put("simple", new SimpleInputFactory(Settings.EMPTY)); factories.put("simple", new SimpleInputFactory());
InputRegistry inputRegistry = new InputRegistry(Settings.EMPTY, factories); InputRegistry inputRegistry = new InputRegistry(factories);
ChainInputFactory chainInputFactory = new ChainInputFactory(Settings.EMPTY, inputRegistry); ChainInputFactory chainInputFactory = new ChainInputFactory(inputRegistry);
factories.put("chain", chainInputFactory); factories.put("chain", chainInputFactory);
XContentBuilder builder = jsonBuilder().startObject().startArray("inputs") XContentBuilder builder = jsonBuilder().startObject().startArray("inputs")

View File

@ -32,7 +32,7 @@ public class ExecutableChainInputTests extends ESTestCase {
ChainInput chainInput = new ChainInput(Arrays.asList(new Tuple<>("whatever", new SimpleInput(Payload.EMPTY)))); ChainInput chainInput = new ChainInput(Arrays.asList(new Tuple<>("whatever", new SimpleInput(Payload.EMPTY))));
Tuple<String, ExecutableInput> tuple = new Tuple<>("whatever", new FailingExecutableInput()); Tuple<String, ExecutableInput> tuple = new Tuple<>("whatever", new FailingExecutableInput());
ExecutableChainInput executableChainInput = new ExecutableChainInput(chainInput, Arrays.asList(tuple), logger); ExecutableChainInput executableChainInput = new ExecutableChainInput(chainInput, Arrays.asList(tuple));
ChainInput.Result result = executableChainInput.execute(ctx, Payload.EMPTY); ChainInput.Result result = executableChainInput.execute(ctx, Payload.EMPTY);
assertThat(result.status(), is(Status.SUCCESS)); assertThat(result.status(), is(Status.SUCCESS));
} }
@ -40,7 +40,7 @@ public class ExecutableChainInputTests extends ESTestCase {
private class FailingExecutableInput extends ExecutableInput<SimpleInput, Input.Result> { private class FailingExecutableInput extends ExecutableInput<SimpleInput, Input.Result> {
protected FailingExecutableInput() { protected FailingExecutableInput() {
super(new SimpleInput(Payload.EMPTY), ExecutableChainInputTests.this.logger); super(new SimpleInput(Payload.EMPTY));
} }
@Override @Override

View File

@ -113,11 +113,11 @@ public class HttpInputTests extends ESTestCase {
break; break;
} }
ExecutableHttpInput input = new ExecutableHttpInput(httpInput, logger, httpClient, templateEngine); ExecutableHttpInput input = new ExecutableHttpInput(httpInput, httpClient, templateEngine);
when(httpClient.execute(any(HttpRequest.class))).thenReturn(response); when(httpClient.execute(any(HttpRequest.class))).thenReturn(response);
when(templateEngine.render(eq(new TextTemplate("_body")), any(Map.class))).thenReturn("_body"); when(templateEngine.render(eq(new TextTemplate("_body")), any(Map.class))).thenReturn("_body");
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
HttpInput.Result result = input.execute(ctx, new Payload.Simple()); HttpInput.Result result = input.execute(ctx, new Payload.Simple());
assertThat(result.type(), equalTo(HttpInput.TYPE)); assertThat(result.type(), equalTo(HttpInput.TYPE));
assertThat(result.payload().data(), hasEntry("key", "value")); assertThat(result.payload().data(), hasEntry("key", "value"));
@ -130,13 +130,13 @@ public class HttpInputTests extends ESTestCase {
.method(HttpMethod.POST) .method(HttpMethod.POST)
.body("_body"); .body("_body");
HttpInput httpInput = InputBuilders.httpInput(request.build()).expectedResponseXContentType(HttpContentType.TEXT).build(); HttpInput httpInput = InputBuilders.httpInput(request.build()).expectedResponseXContentType(HttpContentType.TEXT).build();
ExecutableHttpInput input = new ExecutableHttpInput(httpInput, logger, httpClient, templateEngine); ExecutableHttpInput input = new ExecutableHttpInput(httpInput, httpClient, templateEngine);
String notJson = "This is not json"; String notJson = "This is not json";
HttpResponse response = new HttpResponse(123, notJson.getBytes(StandardCharsets.UTF_8)); HttpResponse response = new HttpResponse(123, notJson.getBytes(StandardCharsets.UTF_8));
when(httpClient.execute(any(HttpRequest.class))).thenReturn(response); when(httpClient.execute(any(HttpRequest.class))).thenReturn(response);
when(templateEngine.render(eq(new TextTemplate("_body")), any(Map.class))).thenReturn("_body"); when(templateEngine.render(eq(new TextTemplate("_body")), any(Map.class))).thenReturn("_body");
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
HttpInput.Result result = input.execute(ctx, new Payload.Simple()); HttpInput.Result result = input.execute(ctx, new Payload.Simple());
assertThat(result.type(), equalTo(HttpInput.TYPE)); assertThat(result.type(), equalTo(HttpInput.TYPE));
assertThat(result.payload().data().get("_value").toString(), equalTo(notJson)); assertThat(result.payload().data().get("_value").toString(), equalTo(notJson));
@ -232,7 +232,7 @@ public class HttpInputTests extends ESTestCase {
HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080); HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080);
HttpInput httpInput = InputBuilders.httpInput(request.build()).build(); HttpInput httpInput = InputBuilders.httpInput(request.build()).build();
ExecutableHttpInput input = new ExecutableHttpInput(httpInput, logger, httpClient, templateEngine); ExecutableHttpInput input = new ExecutableHttpInput(httpInput, httpClient, templateEngine);
Map<String, String[]> responseHeaders = new HashMap<>(); Map<String, String[]> responseHeaders = new HashMap<>();
responseHeaders.put(headerName, new String[] { headerValue }); responseHeaders.put(headerName, new String[] { headerValue });
@ -248,7 +248,7 @@ public class HttpInputTests extends ESTestCase {
when(templateEngine.render(eq(new TextTemplate("_body")), any(Map.class))).thenReturn("_body"); when(templateEngine.render(eq(new TextTemplate("_body")), any(Map.class))).thenReturn("_body");
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
HttpInput.Result result = input.execute(ctx, new Payload.Simple()); HttpInput.Result result = input.execute(ctx, new Payload.Simple());
assertThat(result.type(), equalTo(HttpInput.TYPE)); assertThat(result.type(), equalTo(HttpInput.TYPE));
@ -264,7 +264,7 @@ public class HttpInputTests extends ESTestCase {
public void testThatExpectedContentTypeOverridesReturnedContentType() throws Exception { public void testThatExpectedContentTypeOverridesReturnedContentType() throws Exception {
HttpRequestTemplate template = HttpRequestTemplate.builder("http:://127.0.0.1:12345").build(); HttpRequestTemplate template = HttpRequestTemplate.builder("http:://127.0.0.1:12345").build();
HttpInput httpInput = new HttpInput(template, HttpContentType.TEXT, null); HttpInput httpInput = new HttpInput(template, HttpContentType.TEXT, null);
ExecutableHttpInput input = new ExecutableHttpInput(httpInput, logger, httpClient, templateEngine); ExecutableHttpInput input = new ExecutableHttpInput(httpInput, httpClient, templateEngine);
Map<String, String[]> headers = new HashMap<>(1); Map<String, String[]> headers = new HashMap<>(1);
String contentType = randomFrom("application/json", "application/json; charset=UTF-8", "text/html", "application/yaml", String contentType = randomFrom("application/json", "application/json; charset=UTF-8", "text/html", "application/yaml",
@ -274,7 +274,7 @@ public class HttpInputTests extends ESTestCase {
HttpResponse httpResponse = new HttpResponse(200, body, headers); HttpResponse httpResponse = new HttpResponse(200, body, headers);
when(httpClient.execute(any())).thenReturn(httpResponse); when(httpClient.execute(any())).thenReturn(httpResponse);
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
HttpInput.Result result = input.execute(ctx, Payload.EMPTY); HttpInput.Result result = input.execute(ctx, Payload.EMPTY);
assertThat(result.payload().data(), hasEntry("_value", body)); assertThat(result.payload().data(), hasEntry("_value", body));
assertThat(result.payload().data(), not(hasKey("foo"))); assertThat(result.payload().data(), not(hasKey("foo")));
@ -286,9 +286,9 @@ public class HttpInputTests extends ESTestCase {
HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080); HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080);
HttpInput httpInput = InputBuilders.httpInput(request.build()).build(); HttpInput httpInput = InputBuilders.httpInput(request.build()).build();
ExecutableHttpInput input = new ExecutableHttpInput(httpInput, logger, httpClient, templateEngine); ExecutableHttpInput input = new ExecutableHttpInput(httpInput, httpClient, templateEngine);
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
HttpInput.Result result = input.execute(ctx, new Payload.Simple()); HttpInput.Result result = input.execute(ctx, new Payload.Simple());
assertThat(result.statusCode, is(200)); assertThat(result.statusCode, is(200));
assertThat(result.payload().data(), hasKey("_status_code")); assertThat(result.payload().data(), hasKey("_status_code"));
@ -303,9 +303,9 @@ public class HttpInputTests extends ESTestCase {
HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080); HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080);
HttpInput httpInput = InputBuilders.httpInput(request.build()).build(); HttpInput httpInput = InputBuilders.httpInput(request.build()).build();
ExecutableHttpInput input = new ExecutableHttpInput(httpInput, logger, httpClient, templateEngine); ExecutableHttpInput input = new ExecutableHttpInput(httpInput, httpClient, templateEngine);
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
HttpInput.Result result = input.execute(ctx, new Payload.Simple()); HttpInput.Result result = input.execute(ctx, new Payload.Simple());
assertThat(result.statusCode, is(200)); assertThat(result.statusCode, is(200));
assertThat(result.payload().data(), not(hasKey("_value"))); assertThat(result.payload().data(), not(hasKey("_value")));
@ -322,9 +322,9 @@ public class HttpInputTests extends ESTestCase {
HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080); HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080);
HttpInput httpInput = InputBuilders.httpInput(request.build()).build(); HttpInput httpInput = InputBuilders.httpInput(request.build()).build();
ExecutableHttpInput input = new ExecutableHttpInput(httpInput, logger, httpClient, templateEngine); ExecutableHttpInput input = new ExecutableHttpInput(httpInput, httpClient, templateEngine);
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
HttpInput.Result result = input.execute(ctx, new Payload.Simple()); HttpInput.Result result = input.execute(ctx, new Payload.Simple());
assertThat(result.getException(), is(notNullValue())); assertThat(result.getException(), is(notNullValue()));

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.watcher.input.simple; package org.elasticsearch.xpack.watcher.input.simple;
import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
@ -29,7 +28,7 @@ public class SimpleInputTests extends ESTestCase {
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("foo", "bar"); data.put("foo", "bar");
data.put("baz", new ArrayList<String>() ); data.put("baz", new ArrayList<String>() );
ExecutableInput staticInput = new ExecutableSimpleInput(new SimpleInput(new Payload.Simple(data)), logger); ExecutableInput staticInput = new ExecutableSimpleInput(new SimpleInput(new Payload.Simple(data)));
Input.Result staticResult = staticInput.execute(null, new Payload.Simple()); Input.Result staticResult = staticInput.execute(null, new Payload.Simple());
assertEquals(staticResult.payload().data().get("foo"), "bar"); assertEquals(staticResult.payload().data().get("foo"), "bar");
@ -43,7 +42,7 @@ public class SimpleInputTests extends ESTestCase {
data.put("baz", new ArrayList<String>()); data.put("baz", new ArrayList<String>());
XContentBuilder jsonBuilder = jsonBuilder().map(data); XContentBuilder jsonBuilder = jsonBuilder().map(data);
InputFactory parser = new SimpleInputFactory(Settings.builder().build()); InputFactory parser = new SimpleInputFactory();
XContentParser xContentParser = createParser(jsonBuilder); XContentParser xContentParser = createParser(jsonBuilder);
xContentParser.nextToken(); xContentParser.nextToken();
ExecutableInput input = parser.parseExecutable("_id", xContentParser); ExecutableInput input = parser.parseExecutable("_id", xContentParser);
@ -59,7 +58,7 @@ public class SimpleInputTests extends ESTestCase {
public void testParserInvalid() throws Exception { public void testParserInvalid() throws Exception {
XContentBuilder jsonBuilder = jsonBuilder().value("just a string"); XContentBuilder jsonBuilder = jsonBuilder().value("just a string");
InputFactory parser = new SimpleInputFactory(Settings.builder().build()); InputFactory parser = new SimpleInputFactory();
XContentParser xContentParser = createParser(jsonBuilder); XContentParser xContentParser = createParser(jsonBuilder);
xContentParser.nextToken(); xContentParser.nextToken();
try { try {

View File

@ -7,7 +7,6 @@ package org.elasticsearch.xpack.watcher.input.transform;
import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
@ -52,7 +51,7 @@ public class TransformInputTests extends ESTestCase {
TransformInput transformInput = new TransformInput(scriptTransform); TransformInput transformInput = new TransformInput(scriptTransform);
ExecutableTransform executableTransform = new ExecutableScriptTransform(scriptTransform, logger, scriptService); ExecutableTransform executableTransform = new ExecutableScriptTransform(scriptTransform, logger, scriptService);
ExecutableInput input = new ExecutableTransformInput(transformInput, logger, executableTransform); ExecutableInput input = new ExecutableTransformInput(transformInput, executableTransform);
WatchExecutionContext ctx = WatcherTestUtils.mockExecutionContext("_id", Payload.EMPTY); WatchExecutionContext ctx = WatcherTestUtils.mockExecutionContext("_id", Payload.EMPTY);
Input.Result result = input.execute(ctx, new Payload.Simple()); Input.Result result = input.execute(ctx, new Payload.Simple());
@ -62,9 +61,9 @@ public class TransformInputTests extends ESTestCase {
public void testParserValid() throws Exception { public void testParserValid() throws Exception {
Map<String, TransformFactory> transformFactories = Collections.singletonMap("script", Map<String, TransformFactory> transformFactories = Collections.singletonMap("script",
new ScriptTransformFactory(Settings.EMPTY, scriptService)); new ScriptTransformFactory(scriptService));
TransformRegistry registry = new TransformRegistry(transformFactories); TransformRegistry registry = new TransformRegistry(transformFactories);
TransformInputFactory factory = new TransformInputFactory(Settings.EMPTY, registry); TransformInputFactory factory = new TransformInputFactory(registry);
// { "script" : { "lang" : "mockscript", "source" : "1" } } // { "script" : { "lang" : "mockscript", "source" : "1" } }
XContentBuilder builder = jsonBuilder().startObject().startObject("script") XContentBuilder builder = jsonBuilder().startObject().startObject("script")
@ -86,9 +85,9 @@ public class TransformInputTests extends ESTestCase {
XContentBuilder jsonBuilder = jsonBuilder().value("just a string"); XContentBuilder jsonBuilder = jsonBuilder().value("just a string");
Map<String, TransformFactory> transformFactories = Collections.singletonMap("script", Map<String, TransformFactory> transformFactories = Collections.singletonMap("script",
new ScriptTransformFactory(Settings.EMPTY, scriptService)); new ScriptTransformFactory(scriptService));
TransformRegistry registry = new TransformRegistry(transformFactories); TransformRegistry registry = new TransformRegistry(transformFactories);
TransformInputFactory factory = new TransformInputFactory(Settings.EMPTY, registry); TransformInputFactory factory = new TransformInputFactory(registry);
XContentParser parser = createParser(jsonBuilder); XContentParser parser = createParser(jsonBuilder);
parser.nextToken(); parser.nextToken();
@ -105,9 +104,9 @@ public class TransformInputTests extends ESTestCase {
public void testTransformInputToXContentIsSameAsParsing() throws Exception { public void testTransformInputToXContentIsSameAsParsing() throws Exception {
Map<String, TransformFactory> transformFactories = Collections.singletonMap("script", Map<String, TransformFactory> transformFactories = Collections.singletonMap("script",
new ScriptTransformFactory(Settings.EMPTY, scriptService)); new ScriptTransformFactory(scriptService));
TransformRegistry registry = new TransformRegistry(transformFactories); TransformRegistry registry = new TransformRegistry(transformFactories);
TransformInputFactory factory = new TransformInputFactory(Settings.EMPTY, registry); TransformInputFactory factory = new TransformInputFactory(registry);
XContentBuilder jsonBuilder = jsonBuilder().startObject().startObject("script") XContentBuilder jsonBuilder = jsonBuilder().startObject().startObject("script")
.field("source", "1") .field("source", "1")

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.watcher.test; package org.elasticsearch.xpack.watcher.test;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.logging.Loggers; import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
@ -30,13 +30,13 @@ import java.util.function.Consumer;
import java.util.stream.Stream; import java.util.stream.Stream;
public class TimeWarpedWatcher extends LocalStateCompositeXPackPlugin { public class TimeWarpedWatcher extends LocalStateCompositeXPackPlugin {
private static final Logger logger = LogManager.getLogger(TimeWarpedWatcher.class);
// use a single clock across all nodes using this plugin, this lets keep it static // use a single clock across all nodes using this plugin, this lets keep it static
private static final ClockMock clock = new ClockMock(); private static final ClockMock clock = new ClockMock();
public TimeWarpedWatcher(final Settings settings, final Path configPath) throws Exception { public TimeWarpedWatcher(final Settings settings, final Path configPath) throws Exception {
super(settings, configPath); super(settings, configPath);
Logger logger = Loggers.getLogger(TimeWarpedWatcher.class, settings);
logger.info("using time warped watchers plugin"); logger.info("using time warped watchers plugin");
TimeWarpedWatcher thisVar = this; TimeWarpedWatcher thisVar = this;
@ -69,7 +69,7 @@ public class TimeWarpedWatcher extends LocalStateCompositeXPackPlugin {
@Override @Override
protected Consumer<Iterable<TriggerEvent>> getTriggerEngineListener(ExecutionService executionService){ protected Consumer<Iterable<TriggerEvent>> getTriggerEngineListener(ExecutionService executionService){
return new SyncTriggerEventConsumer(settings, executionService); return new SyncTriggerEventConsumer(executionService);
} }
}); });
} }

View File

@ -125,10 +125,10 @@ public final class WatcherTestUtils {
.buildMock(); .buildMock();
} }
public static WatchExecutionContext createWatchExecutionContext(Logger logger) throws Exception { public static WatchExecutionContext createWatchExecutionContext() throws Exception {
Watch watch = new Watch("test-watch", Watch watch = new Watch("test-watch",
new ScheduleTrigger(new IntervalSchedule(new IntervalSchedule.Interval(1, IntervalSchedule.Interval.Unit.MINUTES))), new ScheduleTrigger(new IntervalSchedule(new IntervalSchedule.Interval(1, IntervalSchedule.Interval.Unit.MINUTES))),
new ExecutableSimpleInput(new SimpleInput(new Payload.Simple()), logger), new ExecutableSimpleInput(new SimpleInput(new Payload.Simple())),
InternalAlwaysCondition.INSTANCE, InternalAlwaysCondition.INSTANCE,
null, null,
null, null,
@ -175,7 +175,7 @@ public final class WatcherTestUtils {
return new Watch( return new Watch(
watchName, watchName,
new ScheduleTrigger(new CronSchedule("0/5 * * * * ? *")), new ScheduleTrigger(new CronSchedule("0/5 * * * * ? *")),
new ExecutableSimpleInput(new SimpleInput(new Payload.Simple(Collections.singletonMap("bar", "foo"))), logger), new ExecutableSimpleInput(new SimpleInput(new Payload.Simple(Collections.singletonMap("bar", "foo")))),
InternalAlwaysCondition.INSTANCE, InternalAlwaysCondition.INSTANCE,
new ExecutableSearchTransform(searchTransform, logger, client, searchTemplateService, TimeValue.timeValueMinutes(1)), new ExecutableSearchTransform(searchTransform, logger, client, searchTemplateService, TimeValue.timeValueMinutes(1)),
new TimeValue(0), new TimeValue(0),

View File

@ -5,9 +5,7 @@
*/ */
package org.elasticsearch.xpack.watcher.test.bench; package org.elasticsearch.xpack.watcher.test.bench;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.metrics.MeanMetric; import org.elasticsearch.common.metrics.MeanMetric;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xpack.core.watcher.trigger.TriggerEvent; import org.elasticsearch.xpack.core.watcher.trigger.TriggerEvent;
@ -33,9 +31,6 @@ import static org.elasticsearch.xpack.watcher.trigger.schedule.Schedules.interva
@SuppressForbidden(reason = "benchmark") @SuppressForbidden(reason = "benchmark")
public class ScheduleEngineTriggerBenchmark { public class ScheduleEngineTriggerBenchmark {
private static final Logger logger = ESLoggerFactory.getLogger(ScheduleEngineTriggerBenchmark.class);
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
int numWatches = 1000; int numWatches = 1000;
int interval = 2; int interval = 2;
@ -61,7 +56,7 @@ public class ScheduleEngineTriggerBenchmark {
.build(); .build();
List<Watch> watches = new ArrayList<>(numWatches); List<Watch> watches = new ArrayList<>(numWatches);
for (int i = 0; i < numWatches; i++) { for (int i = 0; i < numWatches; i++) {
watches.add(new Watch("job_" + i, new ScheduleTrigger(interval(interval + "s")), new ExecutableNoneInput(logger), watches.add(new Watch("job_" + i, new ScheduleTrigger(interval(interval + "s")), new ExecutableNoneInput(),
InternalAlwaysCondition.INSTANCE, null, null, Collections.emptyList(), null, null, 1L)); InternalAlwaysCondition.INSTANCE, null, null, Collections.emptyList(), null, null, 1L));
} }
ScheduleRegistry scheduleRegistry = new ScheduleRegistry(emptySet()); ScheduleRegistry scheduleRegistry = new ScheduleRegistry(emptySet());

View File

@ -5,8 +5,8 @@
*/ */
package org.elasticsearch.xpack.watcher.test.bench; package org.elasticsearch.xpack.watcher.test.bench;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.node.MockNode; import org.elasticsearch.node.MockNode;
@ -207,7 +207,7 @@ public class WatcherExecutorServiceBenchmark {
public BenchmarkWatcher(Settings settings) { public BenchmarkWatcher(Settings settings) {
super(settings); super(settings);
Loggers.getLogger(BenchmarkWatcher.class, settings).info("using watcher benchmark plugin"); LogManager.getLogger(BenchmarkWatcher.class).info("using watcher benchmark plugin");
} }
@Override @Override

View File

@ -101,9 +101,9 @@ public class SearchInputTests extends ESTestCase {
SearchSourceBuilder searchSourceBuilder = searchSource().query(boolQuery().must(matchQuery("event_type", "a"))); SearchSourceBuilder searchSourceBuilder = searchSource().query(boolQuery().must(matchQuery("event_type", "a")));
WatcherSearchTemplateRequest request = WatcherTestUtils.templateRequest(searchSourceBuilder); WatcherSearchTemplateRequest request = WatcherTestUtils.templateRequest(searchSourceBuilder);
ExecutableSearchInput searchInput = new ExecutableSearchInput(new SearchInput(request, null, null, null), logger, ExecutableSearchInput searchInput = new ExecutableSearchInput(new SearchInput(request, null, null, null),
client, watcherSearchTemplateService(), TimeValue.timeValueMinutes(1)); client, watcherSearchTemplateService(), TimeValue.timeValueMinutes(1));
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
SearchInput.Result result = searchInput.execute(ctx, new Payload.Simple()); SearchInput.Result result = searchInput.execute(ctx, new Payload.Simple());
@ -127,9 +127,9 @@ public class SearchInputTests extends ESTestCase {
SearchType searchType = getRandomSupportedSearchType(); SearchType searchType = getRandomSupportedSearchType();
WatcherSearchTemplateRequest request = WatcherTestUtils.templateRequest(searchSourceBuilder, searchType); WatcherSearchTemplateRequest request = WatcherTestUtils.templateRequest(searchSourceBuilder, searchType);
ExecutableSearchInput searchInput = new ExecutableSearchInput(new SearchInput(request, null, null, null), logger, ExecutableSearchInput searchInput = new ExecutableSearchInput(new SearchInput(request, null, null, null),
client, watcherSearchTemplateService(), TimeValue.timeValueMinutes(1)); client, watcherSearchTemplateService(), TimeValue.timeValueMinutes(1));
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
SearchInput.Result result = searchInput.execute(ctx, new Payload.Simple()); SearchInput.Result result = searchInput.execute(ctx, new Payload.Simple());
assertThat(result.status(), is(Input.Result.Status.SUCCESS)); assertThat(result.status(), is(Input.Result.Status.SUCCESS));
@ -179,7 +179,7 @@ public class SearchInputTests extends ESTestCase {
assertThat(input.getRequest().getSearchSource(), is(BytesArray.EMPTY)); assertThat(input.getRequest().getSearchSource(), is(BytesArray.EMPTY));
ExecutableSearchInput executableSearchInput = factory.createExecutable(input); ExecutableSearchInput executableSearchInput = factory.createExecutable(input);
WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext();
SearchInput.Result result = executableSearchInput.execute(ctx, Payload.Simple.EMPTY); SearchInput.Result result = executableSearchInput.execute(ctx, Payload.Simple.EMPTY);
assertThat(result.status(), is(Input.Result.Status.SUCCESS)); assertThat(result.status(), is(Input.Result.Status.SUCCESS));
// no body in the search request // no body in the search request

View File

@ -133,7 +133,7 @@ public class ScriptTransformTests extends ESTestCase {
XContentParser parser = createParser(builder); XContentParser parser = createParser(builder);
parser.nextToken(); parser.nextToken();
ExecutableScriptTransform transform = new ScriptTransformFactory(Settings.EMPTY, service).parseExecutable("_id", parser); ExecutableScriptTransform transform = new ScriptTransformFactory(service).parseExecutable("_id", parser);
Script script = new Script(type, type == ScriptType.STORED ? null : "_lang", "_script", singletonMap("key", "value")); Script script = new Script(type, type == ScriptType.STORED ? null : "_lang", "_script", singletonMap("key", "value"));
assertThat(transform.transform().getScript(), equalTo(script)); assertThat(transform.transform().getScript(), equalTo(script));
} }
@ -144,7 +144,7 @@ public class ScriptTransformTests extends ESTestCase {
XContentParser parser = createParser(builder); XContentParser parser = createParser(builder);
parser.nextToken(); parser.nextToken();
ExecutableScriptTransform transform = new ScriptTransformFactory(Settings.EMPTY, service).parseExecutable("_id", parser); ExecutableScriptTransform transform = new ScriptTransformFactory(service).parseExecutable("_id", parser);
assertEquals(new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "_script", emptyMap()), transform.transform().getScript()); assertEquals(new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "_script", emptyMap()), transform.transform().getScript());
} }
@ -155,7 +155,7 @@ public class ScriptTransformTests extends ESTestCase {
Collections.emptyList(), "whatever", "whatever"); Collections.emptyList(), "whatever", "whatever");
when(scriptService.compile(anyObject(), eq(WatcherTransformScript.CONTEXT))).thenThrow(scriptException); when(scriptService.compile(anyObject(), eq(WatcherTransformScript.CONTEXT))).thenThrow(scriptException);
ScriptTransformFactory transformFactory = new ScriptTransformFactory(Settings.builder().build(), scriptService); ScriptTransformFactory transformFactory = new ScriptTransformFactory(scriptService);
XContentBuilder builder = jsonBuilder().startObject() XContentBuilder builder = jsonBuilder().startObject()
.field(scriptTypeField(randomFrom(ScriptType.values())), "whatever") .field(scriptTypeField(randomFrom(ScriptType.values())), "whatever")
@ -170,7 +170,7 @@ public class ScriptTransformTests extends ESTestCase {
} }
public void testScriptConditionParserBadLang() throws Exception { public void testScriptConditionParserBadLang() throws Exception {
ScriptTransformFactory transformFactory = new ScriptTransformFactory(Settings.builder().build(), createScriptService()); ScriptTransformFactory transformFactory = new ScriptTransformFactory(createScriptService());
String script = "return true"; String script = "return true";
XContentBuilder builder = jsonBuilder().startObject() XContentBuilder builder = jsonBuilder().startObject()
.field(scriptTypeField(ScriptType.INLINE), script) .field(scriptTypeField(ScriptType.INLINE), script)

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.watcher.trigger; package org.elasticsearch.xpack.watcher.trigger;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.logging.Loggers; import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
@ -30,13 +30,12 @@ import java.util.concurrent.ConcurrentMap;
* jobCount. * jobCount.
*/ */
public class ScheduleTriggerEngineMock extends ScheduleTriggerEngine { public class ScheduleTriggerEngineMock extends ScheduleTriggerEngine {
private static final Logger logger = LogManager.getLogger(ScheduleTriggerEngineMock.class);
private final Logger logger;
private final ConcurrentMap<String, Watch> watches = new ConcurrentHashMap<>(); private final ConcurrentMap<String, Watch> watches = new ConcurrentHashMap<>();
public ScheduleTriggerEngineMock(Settings settings, ScheduleRegistry scheduleRegistry, Clock clock) { public ScheduleTriggerEngineMock(Settings settings, ScheduleRegistry scheduleRegistry, Clock clock) {
super(settings, scheduleRegistry, clock); super(settings, scheduleRegistry, clock);
this.logger = Loggers.getLogger(ScheduleTriggerEngineMock.class, settings);
} }
@Override @Override

View File

@ -144,7 +144,7 @@ public class TriggerServiceTests extends ESTestCase {
} }
private void setInput(Watch watch) { private void setInput(Watch watch) {
ExecutableNoneInput noneInput = new ExecutableNoneInput(logger); ExecutableNoneInput noneInput = new ExecutableNoneInput();
when(watch.input()).thenReturn(noneInput); when(watch.input()).thenReturn(noneInput);
} }

View File

@ -255,7 +255,7 @@ public class TickerScheduleEngineTests extends ESTestCase {
} }
private Watch createWatch(String name, Schedule schedule) { private Watch createWatch(String name, Schedule schedule) {
return new Watch(name, new ScheduleTrigger(schedule), new ExecutableNoneInput(logger), return new Watch(name, new ScheduleTrigger(schedule), new ExecutableNoneInput(),
InternalAlwaysCondition.INSTANCE, null, null, InternalAlwaysCondition.INSTANCE, null, null,
Collections.emptyList(), null, null, Versions.MATCH_ANY); Collections.emptyList(), null, null, Versions.MATCH_ANY);
} }

View File

@ -298,7 +298,7 @@ public class WatchTests extends ESTestCase {
TriggerService triggerService = new TriggerService(Settings.EMPTY, singleton(triggerEngine)); TriggerService triggerService = new TriggerService(Settings.EMPTY, singleton(triggerEngine));
ConditionRegistry conditionRegistry = conditionRegistry(); ConditionRegistry conditionRegistry = conditionRegistry();
InputRegistry inputRegistry = registry(new ExecutableNoneInput(logger).type()); InputRegistry inputRegistry = registry(new ExecutableNoneInput().type());
TransformRegistry transformRegistry = transformRegistry(); TransformRegistry transformRegistry = transformRegistry();
ActionRegistry actionRegistry = registry(Collections.emptyList(), conditionRegistry, transformRegistry); ActionRegistry actionRegistry = registry(Collections.emptyList(), conditionRegistry, transformRegistry);
@ -509,10 +509,10 @@ public class WatchTests extends ESTestCase {
SearchInput searchInput = searchInput(WatcherTestUtils.templateRequest(searchSource(), "idx")) SearchInput searchInput = searchInput(WatcherTestUtils.templateRequest(searchSource(), "idx"))
.timeout(randomBoolean() ? null : timeValueSeconds(between(1, 10000))) .timeout(randomBoolean() ? null : timeValueSeconds(between(1, 10000)))
.build(); .build();
return new ExecutableSearchInput(searchInput, logger, client, searchTemplateService, null); return new ExecutableSearchInput(searchInput, client, searchTemplateService, null);
default: default:
SimpleInput simpleInput = InputBuilders.simpleInput(singletonMap("_key", "_val")).build(); SimpleInput simpleInput = InputBuilders.simpleInput(singletonMap("_key", "_val")).build();
return new ExecutableSimpleInput(simpleInput, logger); return new ExecutableSimpleInput(simpleInput);
} }
} }
@ -521,10 +521,10 @@ public class WatchTests extends ESTestCase {
switch (inputType) { switch (inputType) {
case SearchInput.TYPE: case SearchInput.TYPE:
parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, xContentRegistry(), scriptService)); parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, xContentRegistry(), scriptService));
return new InputRegistry(Settings.EMPTY, parsers); return new InputRegistry(parsers);
default: default:
parsers.put(SimpleInput.TYPE, new SimpleInputFactory(settings)); parsers.put(SimpleInput.TYPE, new SimpleInputFactory());
return new InputRegistry(Settings.EMPTY, parsers); return new InputRegistry(parsers);
} }
} }
@ -568,7 +568,7 @@ public class WatchTests extends ESTestCase {
private TransformRegistry transformRegistry() { private TransformRegistry transformRegistry() {
Map<String, TransformFactory> factories = new HashMap<>(); Map<String, TransformFactory> factories = new HashMap<>();
factories.put(ScriptTransform.TYPE, new ScriptTransformFactory(settings, scriptService)); factories.put(ScriptTransform.TYPE, new ScriptTransformFactory(scriptService));
factories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, client, xContentRegistry(), scriptService)); factories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, client, xContentRegistry(), scriptService));
return new TransformRegistry(unmodifiableMap(factories)); return new TransformRegistry(unmodifiableMap(factories));
} }
@ -618,7 +618,7 @@ public class WatchTests extends ESTestCase {
parsers.put(IndexAction.TYPE, new IndexActionFactory(settings, client)); parsers.put(IndexAction.TYPE, new IndexActionFactory(settings, client));
break; break;
case WebhookAction.TYPE: case WebhookAction.TYPE:
parsers.put(WebhookAction.TYPE, new WebhookActionFactory(settings, httpClient, templateEngine)); parsers.put(WebhookAction.TYPE, new WebhookActionFactory(httpClient, templateEngine));
break; break;
case LoggingAction.TYPE: case LoggingAction.TYPE:
parsers.put(LoggingAction.TYPE, new LoggingActionFactory(new MockTextTemplateEngine())); parsers.put(LoggingAction.TYPE, new LoggingActionFactory(new MockTextTemplateEngine()));