From ab8a5563f2d5f580e62fbd228c1de7c0d590662e Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 4 Oct 2018 09:18:04 -0400 Subject: [PATCH] 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. --- .../elasticsearch/common/logging/Loggers.java | 11 -------- .../core/watcher/input/ExecutableInput.java | 5 +--- .../elasticsearch/xpack/watcher/Watcher.java | 24 ++++++++-------- .../actions/email/EmailActionFactory.java | 4 +-- .../actions/hipchat/HipChatActionFactory.java | 7 ++--- .../actions/index/IndexActionFactory.java | 4 +-- .../actions/jira/JiraActionFactory.java | 7 ++--- .../pagerduty/PagerDutyActionFactory.java | 7 ++--- .../actions/slack/SlackActionFactory.java | 7 ++--- .../actions/webhook/WebhookActionFactory.java | 8 ++---- .../execution/AsyncTriggerEventConsumer.java | 9 ++---- .../execution/SyncTriggerEventConsumer.java | 8 ++---- .../xpack/watcher/input/InputFactory.java | 8 ------ .../xpack/watcher/input/InputRegistry.java | 5 ++-- .../input/chain/ChainInputFactory.java | 7 ++--- .../input/chain/ExecutableChainInput.java | 6 ++-- .../input/http/ExecutableHttpInput.java | 6 ++-- .../watcher/input/http/HttpInputFactory.java | 4 +-- .../input/none/ExecutableNoneInput.java | 6 ++-- .../watcher/input/none/NoneInputFactory.java | 9 +----- .../input/search/ExecutableSearchInput.java | 7 +++-- .../input/search/SearchInputFactory.java | 4 +-- .../input/simple/ExecutableSimpleInput.java | 5 ++-- .../input/simple/SimpleInputFactory.java | 9 +----- .../transform/ExecutableTransformInput.java | 5 ++-- .../transform/TransformInputFactory.java | 7 ++--- .../script/ScriptTransformFactory.java | 7 ++--- .../search/SearchTransformFactory.java | 4 +-- .../xpack/watcher/watch/WatchParser.java | 2 +- .../xpack/watcher/WatcherServiceTests.java | 2 +- .../actions/email/EmailActionTests.java | 7 ++--- .../actions/email/EmailMessageIdTests.java | 2 +- .../hipchat/HipChatActionFactoryTests.java | 4 +-- .../PagerDutyActionFactoryTests.java | 4 +-- .../slack/SlackActionFactoryTests.java | 4 +-- .../actions/webhook/WebhookActionTests.java | 2 +- .../execution/ExecutionServiceTests.java | 2 +- .../watcher/input/InputRegistryTests.java | 5 ++-- .../watcher/input/chain/ChainInputTests.java | 27 +++++++++--------- .../chain/ExecutableChainInputTests.java | 4 +-- .../watcher/input/http/HttpInputTests.java | 28 +++++++++---------- .../input/simple/SimpleInputTests.java | 7 ++--- .../input/transform/TransformInputTests.java | 15 +++++----- .../xpack/watcher/test/TimeWarpedWatcher.java | 6 ++-- .../xpack/watcher/test/WatcherTestUtils.java | 6 ++-- .../bench/ScheduleEngineTriggerBenchmark.java | 7 +---- .../WatcherExecutorServiceBenchmark.java | 4 +-- .../test/integration/SearchInputTests.java | 10 +++---- .../script/ScriptTransformTests.java | 8 +++--- .../trigger/ScheduleTriggerEngineMock.java | 5 ++-- .../watcher/trigger/TriggerServiceTests.java | 2 +- .../engine/TickerScheduleEngineTests.java | 2 +- .../xpack/watcher/watch/WatchTests.java | 16 +++++------ 53 files changed, 157 insertions(+), 224 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/logging/Loggers.java b/server/src/main/java/org/elasticsearch/common/logging/Loggers.java index a772867c084..ff889e470c7 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/Loggers.java +++ b/server/src/main/java/org/elasticsearch/common/logging/Loggers.java @@ -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.LoggerConfig; import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; 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])); } - /** - * 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) { return ESLoggerFactory.getLogger(formatPrefix(prefixes), clazz); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/input/ExecutableInput.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/input/ExecutableInput.java index 1c08af3cf90..63d68c62192 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/input/ExecutableInput.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/input/ExecutableInput.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.xpack.core.watcher.input; -import org.apache.logging.log4j.Logger; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -17,11 +16,9 @@ import java.io.IOException; public abstract class ExecutableInput implements ToXContentObject { protected final I input; - protected final Logger logger; - protected ExecutableInput(I input, Logger logger) { + protected ExecutableInput(I input) { this.input = input; - this.logger = logger; } /** diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index eaf64e6ef8f..5eaaa5e2ed5 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -311,32 +311,32 @@ public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin, Reloa final ConditionRegistry conditionRegistry = new ConditionRegistry(Collections.unmodifiableMap(parsers), getClock()); final Map 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)); final TransformRegistry transformRegistry = new TransformRegistry(Collections.unmodifiableMap(transformFactories)); // actions final Map actionFactoryMap = new HashMap<>(); 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(LoggingAction.TYPE, new LoggingActionFactory(templateEngine)); - actionFactoryMap.put(HipChatAction.TYPE, new HipChatActionFactory(settings, templateEngine, hipChatService)); - actionFactoryMap.put(JiraAction.TYPE, new JiraActionFactory(settings, templateEngine, jiraService)); - actionFactoryMap.put(SlackAction.TYPE, new SlackActionFactory(settings, templateEngine, slackService)); - actionFactoryMap.put(PagerDutyAction.TYPE, new PagerDutyActionFactory(settings, templateEngine, pagerDutyService)); + actionFactoryMap.put(HipChatAction.TYPE, new HipChatActionFactory(templateEngine, hipChatService)); + actionFactoryMap.put(JiraAction.TYPE, new JiraActionFactory(templateEngine, jiraService)); + actionFactoryMap.put(SlackAction.TYPE, new SlackActionFactory(templateEngine, slackService)); + actionFactoryMap.put(PagerDutyAction.TYPE, new PagerDutyActionFactory(templateEngine, pagerDutyService)); final ActionRegistry registry = new ActionRegistry(actionFactoryMap, conditionRegistry, transformRegistry, getClock(), getLicenseState()); // inputs final Map inputFactories = new HashMap<>(); 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(NoneInput.TYPE, new NoneInputFactory(settings)); - inputFactories.put(TransformInput.TYPE, new TransformInputFactory(settings, transformRegistry)); - final InputRegistry inputRegistry = new InputRegistry(settings, inputFactories); - inputFactories.put(ChainInput.TYPE, new ChainInputFactory(settings, inputRegistry)); + inputFactories.put(NoneInput.TYPE, new NoneInputFactory()); + inputFactories.put(TransformInput.TYPE, new TransformInputFactory(transformRegistry)); + final InputRegistry inputRegistry = new InputRegistry(inputFactories); + inputFactories.put(ChainInput.TYPE, new ChainInputFactory(inputRegistry)); bulkProcessor = BulkProcessor.builder(ClientHelper.clientWithOrigin(client, WATCHER_ORIGIN), new BulkProcessor.Listener() { @Override @@ -438,7 +438,7 @@ public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin, Reloa } protected Consumer> getTriggerEngineListener(ExecutionService executionService) { - return new AsyncTriggerEventConsumer(settings, executionService); + return new AsyncTriggerEventConsumer(executionService); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionFactory.java index c2dae2855fb..44ad7952d9c 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionFactory.java @@ -5,7 +5,7 @@ */ 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.xcontent.XContentParser; 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, EmailAttachmentsParser emailAttachmentsParser) { - super(Loggers.getLogger(ExecutableEmailAction.class, settings)); + super(LogManager.getLogger(ExecutableEmailAction.class)); this.emailService = emailService; this.templateEngine = templateEngine; this.htmlSanitizer = new HtmlSanitizer(settings); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactory.java index 081dc2e331b..6b9f053d1db 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactory.java @@ -5,8 +5,7 @@ */ package org.elasticsearch.xpack.watcher.actions.hipchat; -import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.settings.Settings; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; @@ -20,8 +19,8 @@ public class HipChatActionFactory extends ActionFactory { private final TextTemplateEngine templateEngine; private final HipChatService hipchatService; - public HipChatActionFactory(Settings settings, TextTemplateEngine templateEngine, HipChatService hipchatService) { - super(Loggers.getLogger(ExecutableHipChatAction.class, settings)); + public HipChatActionFactory(TextTemplateEngine templateEngine, HipChatService hipchatService) { + super(LogManager.getLogger(ExecutableHipChatAction.class)); this.templateEngine = templateEngine; this.hipchatService = hipchatService; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionFactory.java index 7f9b13a6de9..29e6160cdd4 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionFactory.java @@ -5,8 +5,8 @@ */ package org.elasticsearch.xpack.watcher.actions.index; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.Client; -import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentParser; @@ -21,7 +21,7 @@ public class IndexActionFactory extends ActionFactory { private final TimeValue bulkDefaultTimeout; public IndexActionFactory(Settings settings, Client client) { - super(Loggers.getLogger(IndexActionFactory.class, settings)); + super(LogManager.getLogger(IndexActionFactory.class)); this.client = client; 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)); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactory.java index 3d2184283a5..ac95f7fe8a4 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactory.java @@ -5,8 +5,7 @@ */ package org.elasticsearch.xpack.watcher.actions.jira; -import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.settings.Settings; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; @@ -19,8 +18,8 @@ public class JiraActionFactory extends ActionFactory { private final TextTemplateEngine templateEngine; private final JiraService jiraService; - public JiraActionFactory(Settings settings, TextTemplateEngine templateEngine, JiraService jiraService) { - super(Loggers.getLogger(ExecutableJiraAction.class, settings)); + public JiraActionFactory(TextTemplateEngine templateEngine, JiraService jiraService) { + super(LogManager.getLogger(ExecutableJiraAction.class)); this.templateEngine = templateEngine; this.jiraService = jiraService; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactory.java index 5cd18af3af6..703c9eaac4d 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactory.java @@ -5,8 +5,7 @@ */ package org.elasticsearch.xpack.watcher.actions.pagerduty; -import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.settings.Settings; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; @@ -19,8 +18,8 @@ public class PagerDutyActionFactory extends ActionFactory { private final TextTemplateEngine templateEngine; private final PagerDutyService pagerDutyService; - public PagerDutyActionFactory(Settings settings, TextTemplateEngine templateEngine, PagerDutyService pagerDutyService) { - super(Loggers.getLogger(ExecutablePagerDutyAction.class, settings)); + public PagerDutyActionFactory(TextTemplateEngine templateEngine, PagerDutyService pagerDutyService) { + super(LogManager.getLogger(ExecutablePagerDutyAction.class)); this.templateEngine = templateEngine; this.pagerDutyService = pagerDutyService; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactory.java index 8392976f273..45d94b894f1 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactory.java @@ -5,8 +5,7 @@ */ package org.elasticsearch.xpack.watcher.actions.slack; -import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.settings.Settings; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; @@ -18,8 +17,8 @@ public class SlackActionFactory extends ActionFactory { private final TextTemplateEngine templateEngine; private final SlackService slackService; - public SlackActionFactory(Settings settings, TextTemplateEngine templateEngine, SlackService slackService) { - super(Loggers.getLogger(ExecutableSlackAction.class, settings)); + public SlackActionFactory(TextTemplateEngine templateEngine, SlackService slackService) { + super(LogManager.getLogger(ExecutableSlackAction.class)); this.templateEngine = templateEngine; this.slackService = slackService; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionFactory.java index 5a7a1069932..a600acd09bf 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionFactory.java @@ -5,8 +5,7 @@ */ package org.elasticsearch.xpack.watcher.actions.webhook; -import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.settings.Settings; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.xpack.core.watcher.actions.ActionFactory; import org.elasticsearch.xpack.watcher.common.http.HttpClient; @@ -19,9 +18,8 @@ public class WebhookActionFactory extends ActionFactory { private final HttpClient httpClient; private final TextTemplateEngine templateEngine; - public WebhookActionFactory(Settings settings, HttpClient httpClient, TextTemplateEngine templateEngine) { - - super(Loggers.getLogger(ExecutableWebhookAction.class, settings)); + public WebhookActionFactory(HttpClient httpClient, TextTemplateEngine templateEngine) { + super(LogManager.getLogger(ExecutableWebhookAction.class)); this.httpClient = httpClient; this.templateEngine = templateEngine; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/AsyncTriggerEventConsumer.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/AsyncTriggerEventConsumer.java index 61a34e554d2..bd48534589e 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/AsyncTriggerEventConsumer.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/AsyncTriggerEventConsumer.java @@ -6,10 +6,9 @@ package org.elasticsearch.xpack.watcher.execution; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.message.ParameterizedMessage; 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 java.util.function.Consumer; @@ -17,12 +16,10 @@ import java.util.function.Consumer; import static java.util.stream.StreamSupport.stream; public class AsyncTriggerEventConsumer implements Consumer> { - - private final Logger logger; + private static final Logger logger = LogManager.getLogger(SyncTriggerEventConsumer.class); private final ExecutionService executionService; - public AsyncTriggerEventConsumer(Settings settings, ExecutionService executionService) { - this.logger = Loggers.getLogger(SyncTriggerEventConsumer.class, settings); + public AsyncTriggerEventConsumer(ExecutionService executionService) { this.executionService = executionService; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/SyncTriggerEventConsumer.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/SyncTriggerEventConsumer.java index 7608ad2908f..957e988cfdc 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/SyncTriggerEventConsumer.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/SyncTriggerEventConsumer.java @@ -6,10 +6,9 @@ package org.elasticsearch.xpack.watcher.execution; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.message.ParameterizedMessage; 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 java.util.function.Consumer; @@ -17,12 +16,11 @@ import java.util.function.Consumer; import static java.util.stream.StreamSupport.stream; public class SyncTriggerEventConsumer implements Consumer> { + private static final Logger logger = LogManager.getLogger(SyncTriggerEventConsumer.class); private final ExecutionService executionService; - private final Logger logger; - public SyncTriggerEventConsumer(Settings settings, ExecutionService executionService) { - this.logger = Loggers.getLogger(SyncTriggerEventConsumer.class, settings); + public SyncTriggerEventConsumer(ExecutionService executionService) { this.executionService = executionService; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputFactory.java index 25deb2227c6..c154293b560 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputFactory.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.xpack.watcher.input; -import org.apache.logging.log4j.Logger; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; 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. */ public abstract class InputFactory> { - - protected final Logger inputLogger; - - public InputFactory(Logger inputLogger) { - this.inputLogger = inputLogger; - } - /** * @return The type of the input */ diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java index 732653d8293..87bd8f3bdd5 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.watcher.input; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.watcher.input.chain.ChainInput; @@ -21,9 +20,9 @@ public class InputRegistry { private final Map factories; - public InputRegistry(Settings settings, Map factories) { + public InputRegistry(Map factories) { Map map = new HashMap<>(factories); - map.put(ChainInput.TYPE, new ChainInputFactory(settings, this)); + map.put(ChainInput.TYPE, new ChainInputFactory(this)); this.factories = Collections.unmodifiableMap(map); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java index ac3f7b820c2..06d49efcc65 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java @@ -6,8 +6,6 @@ package org.elasticsearch.xpack.watcher.input.chain; 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.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.input.Input; @@ -22,8 +20,7 @@ public class ChainInputFactory extends InputFactory(tuple.v1(), executableInput)); } - return new ExecutableChainInput(input, executableInputs, inputLogger); + return new ExecutableChainInput(input, executableInputs); } } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java index 2643876bdb6..9b959e7c017 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.watcher.input.chain; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionContext; 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; public class ExecutableChainInput extends ExecutableInput { + private static final Logger logger = LogManager.getLogger(ExecutableChainInput.class); private List> inputs; - public ExecutableChainInput(ChainInput input, List> inputs, Logger logger) { - super(input, logger); + public ExecutableChainInput(ChainInput input, List> inputs) { + super(input); this.inputs = inputs; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java index 5d738772f21..79d3918f7a2 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.watcher.input.http; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -31,12 +32,13 @@ import java.util.Map; import static org.elasticsearch.xpack.watcher.input.http.HttpInput.TYPE; public class ExecutableHttpInput extends ExecutableInput { + private static final Logger logger = LogManager.getLogger(ExecutableHttpInput.class); private final HttpClient client; private final TextTemplateEngine templateEngine; - public ExecutableHttpInput(HttpInput input, Logger logger, HttpClient client, TextTemplateEngine templateEngine) { - super(input, logger); + public ExecutableHttpInput(HttpInput input, HttpClient client, TextTemplateEngine templateEngine) { + super(input); this.client = client; this.templateEngine = templateEngine; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInputFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInputFactory.java index 7a68a77ddd2..f50c08ffe40 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInputFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInputFactory.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.xpack.watcher.input.http; -import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.xpack.watcher.common.http.HttpClient; @@ -20,7 +19,6 @@ public final class HttpInputFactory extends InputFactory { - public ExecutableNoneInput(Logger logger) { - super(NoneInput.INSTANCE, logger); + public ExecutableNoneInput() { + super(NoneInput.INSTANCE); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInputFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInputFactory.java index b44d788ae56..370d7360c4a 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInputFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInputFactory.java @@ -5,8 +5,6 @@ */ 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.xpack.core.watcher.input.none.NoneInput; import org.elasticsearch.xpack.watcher.input.InputFactory; @@ -14,11 +12,6 @@ import org.elasticsearch.xpack.watcher.input.InputFactory; import java.io.IOException; public class NoneInputFactory extends InputFactory { - - public NoneInputFactory(Settings settings) { - super(Loggers.getLogger(ExecutableNoneInput.class, settings)); - } - @Override public String type() { return NoneInput.TYPE; @@ -31,6 +24,6 @@ public class NoneInputFactory extends InputFactory { - public ExecutableSimpleInput(SimpleInput input, Logger logger) { - super(input, logger); + public ExecutableSimpleInput(SimpleInput input) { + super(input); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputFactory.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputFactory.java index 91089f165dd..e431167d791 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputFactory.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputFactory.java @@ -5,19 +5,12 @@ */ 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.xpack.watcher.input.InputFactory; import java.io.IOException; public class SimpleInputFactory extends InputFactory { - - public SimpleInputFactory(Settings settings) { - super(Loggers.getLogger(ExecutableSimpleInput.class, settings)); - } - @Override public String type() { return SimpleInput.TYPE; @@ -30,6 +23,6 @@ public class SimpleInputFactory extends InputFactory(HipChatService.getSettings()))); - factory = new HipChatActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), hipchatService); + factory = new HipChatActionFactory(mock(TextTemplateEngine.class), hipchatService); HipChatAction action = hipchatAction("_unknown", "_body").build(); XContentBuilder jsonBuilder = jsonBuilder().value(action); XContentParser parser = createParser(jsonBuilder); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactoryTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactoryTests.java index e48dab8b36d..cef91c69358 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactoryTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactoryTests.java @@ -31,7 +31,7 @@ public class PagerDutyActionFactoryTests extends ESTestCase { @Before public void init() throws Exception { 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 { @@ -49,7 +49,7 @@ public class PagerDutyActionFactoryTests extends ESTestCase { } 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())))); PagerDutyAction action = triggerPagerDutyAction("_unknown", "_body").build(); XContentBuilder jsonBuilder = jsonBuilder().value(action); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactoryTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactoryTests.java index 3b3e7fa981b..031f451c79a 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactoryTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactoryTests.java @@ -31,7 +31,7 @@ public class SlackActionFactoryTests extends ESTestCase { @Before public void init() throws Exception { 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 { @@ -50,7 +50,7 @@ public class SlackActionFactoryTests extends ESTestCase { public void testParseActionUnknownAccount() throws Exception { SlackService service = new SlackService(Settings.EMPTY, null, new ClusterSettings(Settings.EMPTY, 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(); XContentBuilder jsonBuilder = jsonBuilder().value(action); XContentParser parser = createParser(jsonBuilder); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java index 755e3dffe5c..511fcd7698e 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java @@ -208,7 +208,7 @@ public class WebhookActionTests extends ESTestCase { } private WebhookActionFactory webhookFactory(HttpClient client) { - return new WebhookActionFactory(Settings.EMPTY, client, templateEngine); + return new WebhookActionFactory(client, templateEngine); } public void testThatSelectingProxyWorks() throws Exception { diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java index d3f46d3d452..069dca8f2b1 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java @@ -1015,7 +1015,7 @@ public class ExecutionServiceTests extends ESTestCase { public void testUpdateWatchStatusDoesNotUpdateState() throws Exception { 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); final AtomicBoolean assertionsTriggered = new AtomicBoolean(false); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/InputRegistryTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/InputRegistryTests.java index 83c3457c4f6..8347140a561 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/InputRegistryTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/InputRegistryTests.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.watcher.input; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.test.ESTestCase; @@ -17,7 +16,7 @@ import static org.hamcrest.Matchers.containsString; public class InputRegistryTests extends ESTestCase { public void testParseEmptyInput() throws Exception { - InputRegistry registry = new InputRegistry(Settings.EMPTY, emptyMap()); + InputRegistry registry = new InputRegistry(emptyMap()); XContentParser parser = createParser(jsonBuilder().startObject().endObject()); parser.nextToken(); try { @@ -29,7 +28,7 @@ public class InputRegistryTests extends ESTestCase { } public void testParseArrayInput() throws Exception { - InputRegistry registry = new InputRegistry(Settings.EMPTY, emptyMap()); + InputRegistry registry = new InputRegistry(emptyMap()); XContentParser parser = createParser(jsonBuilder().startArray().endArray()); parser.nextToken(); try { diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java index 2e1e7858f16..278a2c08d7b 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java @@ -10,7 +10,6 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.collect.Tuple; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -63,11 +62,11 @@ public class ChainInputTests extends ESTestCase { */ public void testThatExecutionWorks() throws Exception { Map factories = new HashMap<>(); - factories.put("simple", new SimpleInputFactory(Settings.EMPTY)); + factories.put("simple", new SimpleInputFactory()); // hackedy hack... - InputRegistry inputRegistry = new InputRegistry(Settings.EMPTY, factories); - ChainInputFactory chainInputFactory = new ChainInputFactory(Settings.EMPTY, inputRegistry); + InputRegistry inputRegistry = new InputRegistry(factories); + ChainInputFactory chainInputFactory = new ChainInputFactory(inputRegistry); factories.put("chain", chainInputFactory); XContentBuilder builder = jsonBuilder().startObject().startArray("inputs") @@ -88,7 +87,7 @@ public class ChainInputTests extends ESTestCase { // now execute ExecutableChainInput executableChainInput = chainInputFactory.createExecutable(chainInput); - WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); + WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(); ChainInput.Result result = executableChainInput.execute(ctx, new Payload.Simple()); Payload payload = result.payload(); assertThat(payload.data(), hasKey("first")); @@ -117,10 +116,10 @@ public class ChainInputTests extends ESTestCase { // parsing it back as well! Map factories = new HashMap<>(); - factories.put("simple", new SimpleInputFactory(Settings.EMPTY)); + factories.put("simple", new SimpleInputFactory()); - InputRegistry inputRegistry = new InputRegistry(Settings.EMPTY, factories); - ChainInputFactory chainInputFactory = new ChainInputFactory(Settings.EMPTY, inputRegistry); + InputRegistry inputRegistry = new InputRegistry(factories); + ChainInputFactory chainInputFactory = new ChainInputFactory(inputRegistry); factories.put("chain", chainInputFactory); XContentParser parser = createParser(builder); @@ -177,10 +176,10 @@ public class ChainInputTests extends ESTestCase { */ public void testParsingShouldBeStrictWhenClosingInputs() throws Exception { Map factories = new HashMap<>(); - factories.put("simple", new SimpleInputFactory(Settings.EMPTY)); + factories.put("simple", new SimpleInputFactory()); - InputRegistry inputRegistry = new InputRegistry(Settings.EMPTY, factories); - ChainInputFactory chainInputFactory = new ChainInputFactory(Settings.EMPTY, inputRegistry); + InputRegistry inputRegistry = new InputRegistry(factories); + ChainInputFactory chainInputFactory = new ChainInputFactory(inputRegistry); factories.put("chain", chainInputFactory); XContentBuilder builder = jsonBuilder().startObject().startArray("inputs").startObject() @@ -206,10 +205,10 @@ public class ChainInputTests extends ESTestCase { */ public void testParsingShouldBeStrictWhenStartingInputs() throws Exception { Map factories = new HashMap<>(); - factories.put("simple", new SimpleInputFactory(Settings.EMPTY)); + factories.put("simple", new SimpleInputFactory()); - InputRegistry inputRegistry = new InputRegistry(Settings.EMPTY, factories); - ChainInputFactory chainInputFactory = new ChainInputFactory(Settings.EMPTY, inputRegistry); + InputRegistry inputRegistry = new InputRegistry(factories); + ChainInputFactory chainInputFactory = new ChainInputFactory(inputRegistry); factories.put("chain", chainInputFactory); XContentBuilder builder = jsonBuilder().startObject().startArray("inputs") diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java index 0ae6e0b3c96..03b9b1d993b 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java @@ -32,7 +32,7 @@ public class ExecutableChainInputTests extends ESTestCase { ChainInput chainInput = new ChainInput(Arrays.asList(new Tuple<>("whatever", new SimpleInput(Payload.EMPTY)))); Tuple 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); assertThat(result.status(), is(Status.SUCCESS)); } @@ -40,7 +40,7 @@ public class ExecutableChainInputTests extends ESTestCase { private class FailingExecutableInput extends ExecutableInput { protected FailingExecutableInput() { - super(new SimpleInput(Payload.EMPTY), ExecutableChainInputTests.this.logger); + super(new SimpleInput(Payload.EMPTY)); } @Override diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java index 7d81ff2203d..c29b3e1f8b4 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java @@ -113,11 +113,11 @@ public class HttpInputTests extends ESTestCase { 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(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()); assertThat(result.type(), equalTo(HttpInput.TYPE)); assertThat(result.payload().data(), hasEntry("key", "value")); @@ -130,13 +130,13 @@ public class HttpInputTests extends ESTestCase { .method(HttpMethod.POST) .body("_body"); 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"; HttpResponse response = new HttpResponse(123, notJson.getBytes(StandardCharsets.UTF_8)); when(httpClient.execute(any(HttpRequest.class))).thenReturn(response); 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()); assertThat(result.type(), equalTo(HttpInput.TYPE)); 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); HttpInput httpInput = InputBuilders.httpInput(request.build()).build(); - ExecutableHttpInput input = new ExecutableHttpInput(httpInput, logger, httpClient, templateEngine); + ExecutableHttpInput input = new ExecutableHttpInput(httpInput, httpClient, templateEngine); Map responseHeaders = new HashMap<>(); 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"); - WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); + WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(); HttpInput.Result result = input.execute(ctx, new Payload.Simple()); assertThat(result.type(), equalTo(HttpInput.TYPE)); @@ -264,7 +264,7 @@ public class HttpInputTests extends ESTestCase { public void testThatExpectedContentTypeOverridesReturnedContentType() throws Exception { HttpRequestTemplate template = HttpRequestTemplate.builder("http:://127.0.0.1:12345").build(); HttpInput httpInput = new HttpInput(template, HttpContentType.TEXT, null); - ExecutableHttpInput input = new ExecutableHttpInput(httpInput, logger, httpClient, templateEngine); + ExecutableHttpInput input = new ExecutableHttpInput(httpInput, httpClient, templateEngine); Map headers = new HashMap<>(1); 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); when(httpClient.execute(any())).thenReturn(httpResponse); - WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); + WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(); HttpInput.Result result = input.execute(ctx, Payload.EMPTY); assertThat(result.payload().data(), hasEntry("_value", body)); assertThat(result.payload().data(), not(hasKey("foo"))); @@ -286,9 +286,9 @@ public class HttpInputTests extends ESTestCase { HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080); 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()); assertThat(result.statusCode, is(200)); assertThat(result.payload().data(), hasKey("_status_code")); @@ -303,9 +303,9 @@ public class HttpInputTests extends ESTestCase { HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080); 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()); assertThat(result.statusCode, is(200)); assertThat(result.payload().data(), not(hasKey("_value"))); @@ -322,9 +322,9 @@ public class HttpInputTests extends ESTestCase { HttpRequestTemplate.Builder request = HttpRequestTemplate.builder("localhost", 8080); 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()); assertThat(result.getException(), is(notNullValue())); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java index b435e7ba38a..d690cfe15f3 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.watcher.input.simple; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.test.ESTestCase; @@ -29,7 +28,7 @@ public class SimpleInputTests extends ESTestCase { Map data = new HashMap<>(); data.put("foo", "bar"); data.put("baz", new ArrayList() ); - 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()); assertEquals(staticResult.payload().data().get("foo"), "bar"); @@ -43,7 +42,7 @@ public class SimpleInputTests extends ESTestCase { data.put("baz", new ArrayList()); XContentBuilder jsonBuilder = jsonBuilder().map(data); - InputFactory parser = new SimpleInputFactory(Settings.builder().build()); + InputFactory parser = new SimpleInputFactory(); XContentParser xContentParser = createParser(jsonBuilder); xContentParser.nextToken(); ExecutableInput input = parser.parseExecutable("_id", xContentParser); @@ -59,7 +58,7 @@ public class SimpleInputTests extends ESTestCase { public void testParserInvalid() throws Exception { XContentBuilder jsonBuilder = jsonBuilder().value("just a string"); - InputFactory parser = new SimpleInputFactory(Settings.builder().build()); + InputFactory parser = new SimpleInputFactory(); XContentParser xContentParser = createParser(jsonBuilder); xContentParser.nextToken(); try { diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java index 0ac5932586e..72f473a611d 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.watcher.input.transform; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -52,7 +51,7 @@ public class TransformInputTests extends ESTestCase { TransformInput transformInput = new TransformInput(scriptTransform); 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); Input.Result result = input.execute(ctx, new Payload.Simple()); @@ -62,9 +61,9 @@ public class TransformInputTests extends ESTestCase { public void testParserValid() throws Exception { Map transformFactories = Collections.singletonMap("script", - new ScriptTransformFactory(Settings.EMPTY, scriptService)); + new ScriptTransformFactory(scriptService)); TransformRegistry registry = new TransformRegistry(transformFactories); - TransformInputFactory factory = new TransformInputFactory(Settings.EMPTY, registry); + TransformInputFactory factory = new TransformInputFactory(registry); // { "script" : { "lang" : "mockscript", "source" : "1" } } XContentBuilder builder = jsonBuilder().startObject().startObject("script") @@ -86,9 +85,9 @@ public class TransformInputTests extends ESTestCase { XContentBuilder jsonBuilder = jsonBuilder().value("just a string"); Map transformFactories = Collections.singletonMap("script", - new ScriptTransformFactory(Settings.EMPTY, scriptService)); + new ScriptTransformFactory(scriptService)); TransformRegistry registry = new TransformRegistry(transformFactories); - TransformInputFactory factory = new TransformInputFactory(Settings.EMPTY, registry); + TransformInputFactory factory = new TransformInputFactory(registry); XContentParser parser = createParser(jsonBuilder); parser.nextToken(); @@ -105,9 +104,9 @@ public class TransformInputTests extends ESTestCase { public void testTransformInputToXContentIsSameAsParsing() throws Exception { Map transformFactories = Collections.singletonMap("script", - new ScriptTransformFactory(Settings.EMPTY, scriptService)); + new ScriptTransformFactory(scriptService)); TransformRegistry registry = new TransformRegistry(transformFactories); - TransformInputFactory factory = new TransformInputFactory(Settings.EMPTY, registry); + TransformInputFactory factory = new TransformInputFactory(registry); XContentBuilder jsonBuilder = jsonBuilder().startObject().startObject("script") .field("source", "1") diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java index b1c263299f7..99cf45e583d 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java @@ -6,7 +6,7 @@ package org.elasticsearch.xpack.watcher.test; 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.license.XPackLicenseState; import org.elasticsearch.threadpool.ThreadPool; @@ -30,13 +30,13 @@ import java.util.function.Consumer; import java.util.stream.Stream; 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 private static final ClockMock clock = new ClockMock(); public TimeWarpedWatcher(final Settings settings, final Path configPath) throws Exception { super(settings, configPath); - Logger logger = Loggers.getLogger(TimeWarpedWatcher.class, settings); logger.info("using time warped watchers plugin"); TimeWarpedWatcher thisVar = this; @@ -69,7 +69,7 @@ public class TimeWarpedWatcher extends LocalStateCompositeXPackPlugin { @Override protected Consumer> getTriggerEngineListener(ExecutionService executionService){ - return new SyncTriggerEventConsumer(settings, executionService); + return new SyncTriggerEventConsumer(executionService); } }); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java index 75c6a908b99..bb5a6eabdd5 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java @@ -125,10 +125,10 @@ public final class WatcherTestUtils { .buildMock(); } - public static WatchExecutionContext createWatchExecutionContext(Logger logger) throws Exception { + public static WatchExecutionContext createWatchExecutionContext() throws Exception { Watch watch = new Watch("test-watch", 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, null, null, @@ -175,7 +175,7 @@ public final class WatcherTestUtils { return new Watch( watchName, 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, new ExecutableSearchTransform(searchTransform, logger, client, searchTemplateService, TimeValue.timeValueMinutes(1)), new TimeValue(0), diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/ScheduleEngineTriggerBenchmark.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/ScheduleEngineTriggerBenchmark.java index c1967d9e8ce..d1b8963950d 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/ScheduleEngineTriggerBenchmark.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/ScheduleEngineTriggerBenchmark.java @@ -5,9 +5,7 @@ */ package org.elasticsearch.xpack.watcher.test.bench; -import org.apache.logging.log4j.Logger; import org.elasticsearch.common.SuppressForbidden; -import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.metrics.MeanMetric; import org.elasticsearch.common.settings.Settings; 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") public class ScheduleEngineTriggerBenchmark { - - private static final Logger logger = ESLoggerFactory.getLogger(ScheduleEngineTriggerBenchmark.class); - public static void main(String[] args) throws Exception { int numWatches = 1000; int interval = 2; @@ -61,7 +56,7 @@ public class ScheduleEngineTriggerBenchmark { .build(); List watches = new ArrayList<>(numWatches); 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)); } ScheduleRegistry scheduleRegistry = new ScheduleRegistry(emptySet()); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java index 4ca412c5ce0..80e802cf817 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java @@ -5,8 +5,8 @@ */ package org.elasticsearch.xpack.watcher.test.bench; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.Client; -import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.node.MockNode; @@ -207,7 +207,7 @@ public class WatcherExecutorServiceBenchmark { public BenchmarkWatcher(Settings settings) { super(settings); - Loggers.getLogger(BenchmarkWatcher.class, settings).info("using watcher benchmark plugin"); + LogManager.getLogger(BenchmarkWatcher.class).info("using watcher benchmark plugin"); } @Override diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java index b66a70c23af..45b85caacc0 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java @@ -101,9 +101,9 @@ public class SearchInputTests extends ESTestCase { SearchSourceBuilder searchSourceBuilder = searchSource().query(boolQuery().must(matchQuery("event_type", "a"))); 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)); - WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); + WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(); SearchInput.Result result = searchInput.execute(ctx, new Payload.Simple()); @@ -127,9 +127,9 @@ public class SearchInputTests extends ESTestCase { SearchType searchType = getRandomSupportedSearchType(); 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)); - WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); + WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(); SearchInput.Result result = searchInput.execute(ctx, new Payload.Simple()); assertThat(result.status(), is(Input.Result.Status.SUCCESS)); @@ -179,7 +179,7 @@ public class SearchInputTests extends ESTestCase { assertThat(input.getRequest().getSearchSource(), is(BytesArray.EMPTY)); ExecutableSearchInput executableSearchInput = factory.createExecutable(input); - WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(logger); + WatchExecutionContext ctx = WatcherTestUtils.createWatchExecutionContext(); SearchInput.Result result = executableSearchInput.execute(ctx, Payload.Simple.EMPTY); assertThat(result.status(), is(Input.Result.Status.SUCCESS)); // no body in the search request diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java index 752b753f028..daaad496f69 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java @@ -133,7 +133,7 @@ public class ScriptTransformTests extends ESTestCase { XContentParser parser = createParser(builder); 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")); assertThat(transform.transform().getScript(), equalTo(script)); } @@ -144,7 +144,7 @@ public class ScriptTransformTests extends ESTestCase { XContentParser parser = createParser(builder); 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()); } @@ -155,7 +155,7 @@ public class ScriptTransformTests extends ESTestCase { Collections.emptyList(), "whatever", "whatever"); 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() .field(scriptTypeField(randomFrom(ScriptType.values())), "whatever") @@ -170,7 +170,7 @@ public class ScriptTransformTests extends ESTestCase { } public void testScriptConditionParserBadLang() throws Exception { - ScriptTransformFactory transformFactory = new ScriptTransformFactory(Settings.builder().build(), createScriptService()); + ScriptTransformFactory transformFactory = new ScriptTransformFactory(createScriptService()); String script = "return true"; XContentBuilder builder = jsonBuilder().startObject() .field(scriptTypeField(ScriptType.INLINE), script) diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/ScheduleTriggerEngineMock.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/ScheduleTriggerEngineMock.java index 331416bd690..4f0c78b1e0d 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/ScheduleTriggerEngineMock.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/ScheduleTriggerEngineMock.java @@ -6,7 +6,7 @@ package org.elasticsearch.xpack.watcher.trigger; 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.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentParser; @@ -30,13 +30,12 @@ import java.util.concurrent.ConcurrentMap; * jobCount. */ public class ScheduleTriggerEngineMock extends ScheduleTriggerEngine { + private static final Logger logger = LogManager.getLogger(ScheduleTriggerEngineMock.class); - private final Logger logger; private final ConcurrentMap watches = new ConcurrentHashMap<>(); public ScheduleTriggerEngineMock(Settings settings, ScheduleRegistry scheduleRegistry, Clock clock) { super(settings, scheduleRegistry, clock); - this.logger = Loggers.getLogger(ScheduleTriggerEngineMock.class, settings); } @Override diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java index 4aa34738cef..f0d3e88b127 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java @@ -144,7 +144,7 @@ public class TriggerServiceTests extends ESTestCase { } private void setInput(Watch watch) { - ExecutableNoneInput noneInput = new ExecutableNoneInput(logger); + ExecutableNoneInput noneInput = new ExecutableNoneInput(); when(watch.input()).thenReturn(noneInput); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleEngineTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleEngineTests.java index db1d3767b59..5fd5ad5b16f 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleEngineTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleEngineTests.java @@ -255,7 +255,7 @@ public class TickerScheduleEngineTests extends ESTestCase { } 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, Collections.emptyList(), null, null, Versions.MATCH_ANY); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java index fff07cfa010..2e09c7446db 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java @@ -298,7 +298,7 @@ public class WatchTests extends ESTestCase { TriggerService triggerService = new TriggerService(Settings.EMPTY, singleton(triggerEngine)); ConditionRegistry conditionRegistry = conditionRegistry(); - InputRegistry inputRegistry = registry(new ExecutableNoneInput(logger).type()); + InputRegistry inputRegistry = registry(new ExecutableNoneInput().type()); TransformRegistry transformRegistry = transformRegistry(); ActionRegistry actionRegistry = registry(Collections.emptyList(), conditionRegistry, transformRegistry); @@ -509,10 +509,10 @@ public class WatchTests extends ESTestCase { SearchInput searchInput = searchInput(WatcherTestUtils.templateRequest(searchSource(), "idx")) .timeout(randomBoolean() ? null : timeValueSeconds(between(1, 10000))) .build(); - return new ExecutableSearchInput(searchInput, logger, client, searchTemplateService, null); + return new ExecutableSearchInput(searchInput, client, searchTemplateService, null); default: 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) { case SearchInput.TYPE: parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, xContentRegistry(), scriptService)); - return new InputRegistry(Settings.EMPTY, parsers); + return new InputRegistry(parsers); default: - parsers.put(SimpleInput.TYPE, new SimpleInputFactory(settings)); - return new InputRegistry(Settings.EMPTY, parsers); + parsers.put(SimpleInput.TYPE, new SimpleInputFactory()); + return new InputRegistry(parsers); } } @@ -568,7 +568,7 @@ public class WatchTests extends ESTestCase { private TransformRegistry transformRegistry() { Map 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)); return new TransformRegistry(unmodifiableMap(factories)); } @@ -618,7 +618,7 @@ public class WatchTests extends ESTestCase { parsers.put(IndexAction.TYPE, new IndexActionFactory(settings, client)); break; case WebhookAction.TYPE: - parsers.put(WebhookAction.TYPE, new WebhookActionFactory(settings, httpClient, templateEngine)); + parsers.put(WebhookAction.TYPE, new WebhookActionFactory(httpClient, templateEngine)); break; case LoggingAction.TYPE: parsers.put(LoggingAction.TYPE, new LoggingActionFactory(new MockTextTemplateEngine()));