Watcher: Rename ClientProxy to WatcherClientProxy
Original commit: elastic/x-pack-elasticsearch@84c17d1bc0
This commit is contained in:
parent
f4eb0e7c7c
commit
146f91f730
|
@ -34,7 +34,7 @@ import org.elasticsearch.watcher.input.search.SearchInput;
|
||||||
import org.elasticsearch.watcher.input.search.SearchInputFactory;
|
import org.elasticsearch.watcher.input.search.SearchInputFactory;
|
||||||
import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput;
|
import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput;
|
||||||
import org.elasticsearch.watcher.input.simple.SimpleInput;
|
import org.elasticsearch.watcher.input.simple.SimpleInput;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.support.text.TextTemplate;
|
import org.elasticsearch.watcher.support.text.TextTemplate;
|
||||||
import org.elasticsearch.watcher.trigger.schedule.IntervalSchedule;
|
import org.elasticsearch.watcher.trigger.schedule.IntervalSchedule;
|
||||||
import org.elasticsearch.watcher.trigger.schedule.ScheduleTrigger;
|
import org.elasticsearch.watcher.trigger.schedule.ScheduleTrigger;
|
||||||
|
@ -132,7 +132,7 @@ public class SearchInputIT extends ESIntegTestCase {
|
||||||
.source(searchSourceBuilder);
|
.source(searchSourceBuilder);
|
||||||
|
|
||||||
ExecutableSearchInput searchInput = new ExecutableSearchInput(new SearchInput(request, null, null, null), logger,
|
ExecutableSearchInput searchInput = new ExecutableSearchInput(new SearchInput(request, null, null, null), logger,
|
||||||
ClientProxy.of(client()), null);
|
WatcherClientProxy.of(client()), null);
|
||||||
WatchExecutionContext ctx = new TriggeredExecutionContext(
|
WatchExecutionContext ctx = new TriggeredExecutionContext(
|
||||||
new Watch("test-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))),
|
||||||
|
@ -244,7 +244,7 @@ public class SearchInputIT extends ESIntegTestCase {
|
||||||
.source(searchSourceBuilder);
|
.source(searchSourceBuilder);
|
||||||
|
|
||||||
ExecutableSearchInput searchInput = new ExecutableSearchInput(new SearchInput(request, null, null, null), logger,
|
ExecutableSearchInput searchInput = new ExecutableSearchInput(new SearchInput(request, null, null, null), logger,
|
||||||
ClientProxy.of(client()), null);
|
WatcherClientProxy.of(client()), null);
|
||||||
WatchExecutionContext ctx = new TriggeredExecutionContext(
|
WatchExecutionContext ctx = new TriggeredExecutionContext(
|
||||||
new Watch("test-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))),
|
||||||
|
@ -281,7 +281,7 @@ public class SearchInputIT extends ESIntegTestCase {
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
IndicesQueriesRegistry indicesQueryRegistry = internalCluster().getInstance(IndicesQueriesRegistry.class);
|
IndicesQueriesRegistry indicesQueryRegistry = internalCluster().getInstance(IndicesQueriesRegistry.class);
|
||||||
SearchInputFactory factory = new SearchInputFactory(Settings.EMPTY, ClientProxy.of(client()), indicesQueryRegistry, null);
|
SearchInputFactory factory = new SearchInputFactory(Settings.EMPTY, WatcherClientProxy.of(client()), indicesQueryRegistry, null);
|
||||||
|
|
||||||
SearchInput searchInput = factory.parseInput("_id", parser);
|
SearchInput searchInput = factory.parseInput("_id", parser);
|
||||||
assertEquals(SearchInput.TYPE, searchInput.type());
|
assertEquals(SearchInput.TYPE, searchInput.type());
|
||||||
|
@ -311,7 +311,7 @@ public class SearchInputIT extends ESIntegTestCase {
|
||||||
|
|
||||||
SearchInput si = siBuilder.build();
|
SearchInput si = siBuilder.build();
|
||||||
|
|
||||||
ExecutableSearchInput searchInput = new ExecutableSearchInput(si, logger, ClientProxy.of(client()), null);
|
ExecutableSearchInput searchInput = new ExecutableSearchInput(si, logger, WatcherClientProxy.of(client()), null);
|
||||||
return searchInput.execute(ctx, new Payload.Simple());
|
return searchInput.execute(ctx, new Payload.Simple());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.elasticsearch.watcher.execution.TriggeredExecutionContext;
|
||||||
import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
||||||
import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput;
|
import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput;
|
||||||
import org.elasticsearch.watcher.input.simple.SimpleInput;
|
import org.elasticsearch.watcher.input.simple.SimpleInput;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.support.text.TextTemplate;
|
import org.elasticsearch.watcher.support.text.TextTemplate;
|
||||||
import org.elasticsearch.watcher.transform.Transform;
|
import org.elasticsearch.watcher.transform.Transform;
|
||||||
import org.elasticsearch.watcher.transform.TransformBuilders;
|
import org.elasticsearch.watcher.transform.TransformBuilders;
|
||||||
|
@ -154,7 +154,7 @@ public class SearchTransformIT extends ESIntegTestCase {
|
||||||
|
|
||||||
SearchRequest request = Requests.searchRequest("idx").source(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()));
|
SearchRequest request = Requests.searchRequest("idx").source(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()));
|
||||||
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
||||||
ExecutableSearchTransform transform = new ExecutableSearchTransform(searchTransform, logger, ClientProxy.of(client()), null);
|
ExecutableSearchTransform transform = new ExecutableSearchTransform(searchTransform, logger, WatcherClientProxy.of(client()), null);
|
||||||
|
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", EMPTY_PAYLOAD);
|
WatchExecutionContext ctx = mockExecutionContext("_name", EMPTY_PAYLOAD);
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ public class SearchTransformIT extends ESIntegTestCase {
|
||||||
new SearchSourceBuilder().query(QueryBuilders.wrapperQuery(jsonBuilder().startObject()
|
new SearchSourceBuilder().query(QueryBuilders.wrapperQuery(jsonBuilder().startObject()
|
||||||
.startObject("_unknown_query_").endObject().endObject().bytes())));
|
.startObject("_unknown_query_").endObject().endObject().bytes())));
|
||||||
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
||||||
ExecutableSearchTransform transform = new ExecutableSearchTransform(searchTransform, logger, ClientProxy.of(client()), null);
|
ExecutableSearchTransform transform = new ExecutableSearchTransform(searchTransform, logger, WatcherClientProxy.of(client()), null);
|
||||||
|
|
||||||
WatchExecutionContext ctx = mockExecutionContext("_name", EMPTY_PAYLOAD);
|
WatchExecutionContext ctx = mockExecutionContext("_name", EMPTY_PAYLOAD);
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ public class SearchTransformIT extends ESIntegTestCase {
|
||||||
.must(termQuery("value", "{{ctx.payload.value}}"))));
|
.must(termQuery("value", "{{ctx.payload.value}}"))));
|
||||||
|
|
||||||
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
||||||
ExecutableSearchTransform transform = new ExecutableSearchTransform(searchTransform, logger, ClientProxy.of(client()), null);
|
ExecutableSearchTransform transform = new ExecutableSearchTransform(searchTransform, logger, WatcherClientProxy.of(client()), null);
|
||||||
|
|
||||||
ScheduleTriggerEvent event = new ScheduleTriggerEvent("_name", parseDate("2015-01-04T00:00:00", UTC),
|
ScheduleTriggerEvent event = new ScheduleTriggerEvent("_name", parseDate("2015-01-04T00:00:00", UTC),
|
||||||
parseDate("2015-01-01T00:00:00", UTC));
|
parseDate("2015-01-01T00:00:00", UTC));
|
||||||
|
@ -318,7 +318,7 @@ public class SearchTransformIT extends ESIntegTestCase {
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
IndicesQueriesRegistry indicesQueryRegistry = internalCluster().getInstance(IndicesQueriesRegistry.class);
|
IndicesQueriesRegistry indicesQueryRegistry = internalCluster().getInstance(IndicesQueriesRegistry.class);
|
||||||
SearchTransformFactory transformFactory = new SearchTransformFactory(Settings.EMPTY, ClientProxy.of(client()),
|
SearchTransformFactory transformFactory = new SearchTransformFactory(Settings.EMPTY, WatcherClientProxy.of(client()),
|
||||||
indicesQueryRegistry,
|
indicesQueryRegistry,
|
||||||
null);
|
null);
|
||||||
ExecutableSearchTransform executable = transformFactory.parseExecutable("_id", parser);
|
ExecutableSearchTransform executable = transformFactory.parseExecutable("_id", parser);
|
||||||
|
@ -482,7 +482,7 @@ public class SearchTransformIT extends ESIntegTestCase {
|
||||||
|
|
||||||
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
|
||||||
ExecutableSearchTransform executableSearchTransform = new ExecutableSearchTransform(searchTransform, logger,
|
ExecutableSearchTransform executableSearchTransform = new ExecutableSearchTransform(searchTransform, logger,
|
||||||
ClientProxy.of(client()), null);
|
WatcherClientProxy.of(client()), null);
|
||||||
|
|
||||||
return executableSearchTransform.execute(ctx, Payload.Simple.EMPTY);
|
return executableSearchTransform.execute(ctx, Payload.Simple.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.elasticsearch.watcher.actions.ExecutableAction;
|
||||||
import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
||||||
import org.elasticsearch.watcher.support.ArrayObjectIterator;
|
import org.elasticsearch.watcher.support.ArrayObjectIterator;
|
||||||
import org.elasticsearch.watcher.support.WatcherDateTimeUtils;
|
import org.elasticsearch.watcher.support.WatcherDateTimeUtils;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.support.xcontent.XContentSource;
|
import org.elasticsearch.watcher.support.xcontent.XContentSource;
|
||||||
import org.elasticsearch.watcher.watch.Payload;
|
import org.elasticsearch.watcher.watch.Payload;
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@ import static org.elasticsearch.watcher.support.Exceptions.illegalState;
|
||||||
|
|
||||||
public class ExecutableIndexAction extends ExecutableAction<IndexAction> {
|
public class ExecutableIndexAction extends ExecutableAction<IndexAction> {
|
||||||
|
|
||||||
private final ClientProxy client;
|
private final WatcherClientProxy client;
|
||||||
private final TimeValue timeout;
|
private final TimeValue timeout;
|
||||||
|
|
||||||
public ExecutableIndexAction(IndexAction action, ESLogger logger, ClientProxy client, @Nullable TimeValue defaultTimeout) {
|
public ExecutableIndexAction(IndexAction action, ESLogger logger, WatcherClientProxy client, @Nullable TimeValue defaultTimeout) {
|
||||||
super(action, logger);
|
super(action, logger);
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.timeout = action.timeout != null ? action.timeout : defaultTimeout;
|
this.timeout = action.timeout != null ? action.timeout : defaultTimeout;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.watcher.actions.ActionFactory;
|
import org.elasticsearch.watcher.actions.ActionFactory;
|
||||||
import org.elasticsearch.watcher.actions.email.ExecutableEmailAction;
|
import org.elasticsearch.watcher.actions.email.ExecutableEmailAction;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class IndexActionFactory extends ActionFactory<IndexAction, ExecutableIndexAction> {
|
public class IndexActionFactory extends ActionFactory<IndexAction, ExecutableIndexAction> {
|
||||||
|
|
||||||
private final ClientProxy client;
|
private final WatcherClientProxy client;
|
||||||
private final TimeValue defaultTimeout;
|
private final TimeValue defaultTimeout;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public IndexActionFactory(Settings settings, ClientProxy client) {
|
public IndexActionFactory(Settings settings, WatcherClientProxy client) {
|
||||||
super(Loggers.getLogger(ExecutableEmailAction.class, settings));
|
super(Loggers.getLogger(ExecutableEmailAction.class, settings));
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.defaultTimeout = settings.getAsTime("watcher.actions.index.default_timeout", null);
|
this.defaultTimeout = settings.getAsTime("watcher.actions.index.default_timeout", null);
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
import org.elasticsearch.search.sort.SortBuilders;
|
import org.elasticsearch.search.sort.SortBuilders;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -47,7 +47,7 @@ public class TriggeredWatchStore extends AbstractComponent {
|
||||||
public static final String DOC_TYPE = "triggered_watch";
|
public static final String DOC_TYPE = "triggered_watch";
|
||||||
|
|
||||||
private final int scrollSize;
|
private final int scrollSize;
|
||||||
private final ClientProxy client;
|
private final WatcherClientProxy client;
|
||||||
private final TimeValue scrollTimeout;
|
private final TimeValue scrollTimeout;
|
||||||
private final TriggeredWatch.Parser triggeredWatchParser;
|
private final TriggeredWatch.Parser triggeredWatchParser;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class TriggeredWatchStore extends AbstractComponent {
|
||||||
private final AtomicBoolean started = new AtomicBoolean(false);
|
private final AtomicBoolean started = new AtomicBoolean(false);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TriggeredWatchStore(Settings settings, ClientProxy client, TriggeredWatch.Parser triggeredWatchParser) {
|
public TriggeredWatchStore(Settings settings, WatcherClientProxy client, TriggeredWatch.Parser triggeredWatchParser) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.scrollSize = settings.getAsInt("watcher.execution.scroll.size", 100);
|
this.scrollSize = settings.getAsInt("watcher.execution.scroll.size", 100);
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.index.engine.VersionConflictEngineException;
|
import org.elasticsearch.index.engine.VersionConflictEngineException;
|
||||||
import org.elasticsearch.watcher.WatcherModule;
|
import org.elasticsearch.watcher.WatcherModule;
|
||||||
import org.elasticsearch.watcher.execution.ExecutionState;
|
import org.elasticsearch.watcher.execution.ExecutionState;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
|
@ -36,7 +36,7 @@ public class HistoryStore extends AbstractComponent {
|
||||||
|
|
||||||
static final DateTimeFormatter indexTimeFormat = DateTimeFormat.forPattern("YYYY.MM.dd");
|
static final DateTimeFormatter indexTimeFormat = DateTimeFormat.forPattern("YYYY.MM.dd");
|
||||||
|
|
||||||
private final ClientProxy client;
|
private final WatcherClientProxy client;
|
||||||
|
|
||||||
private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
||||||
private final Lock putUpdateLock = readWriteLock.readLock();
|
private final Lock putUpdateLock = readWriteLock.readLock();
|
||||||
|
@ -44,7 +44,7 @@ public class HistoryStore extends AbstractComponent {
|
||||||
private final AtomicBoolean started = new AtomicBoolean(false);
|
private final AtomicBoolean started = new AtomicBoolean(false);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public HistoryStore(Settings settings, ClientProxy client) {
|
public HistoryStore(Settings settings, WatcherClientProxy client) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
||||||
import org.elasticsearch.watcher.input.ExecutableInput;
|
import org.elasticsearch.watcher.input.ExecutableInput;
|
||||||
import org.elasticsearch.watcher.support.WatcherUtils;
|
import org.elasticsearch.watcher.support.WatcherUtils;
|
||||||
import org.elasticsearch.watcher.support.XContentFilterKeysUtils;
|
import org.elasticsearch.watcher.support.XContentFilterKeysUtils;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.watch.Payload;
|
import org.elasticsearch.watcher.watch.Payload;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -34,10 +34,10 @@ 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 final ClientProxy client;
|
private final WatcherClientProxy client;
|
||||||
private final @Nullable TimeValue timeout;
|
private final @Nullable TimeValue timeout;
|
||||||
|
|
||||||
public ExecutableSearchInput(SearchInput input, ESLogger logger, ClientProxy client, @Nullable TimeValue defaultTimeout) {
|
public ExecutableSearchInput(SearchInput input, ESLogger logger, WatcherClientProxy client, @Nullable TimeValue defaultTimeout) {
|
||||||
super(input, logger);
|
super(input, logger);
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.timeout = input.getTimeout() != null ? input.getTimeout() : defaultTimeout;
|
this.timeout = input.getTimeout() != null ? input.getTimeout() : defaultTimeout;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
||||||
import org.elasticsearch.watcher.input.InputFactory;
|
import org.elasticsearch.watcher.input.InputFactory;
|
||||||
import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput;
|
import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -24,13 +24,14 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Result, ExecutableSearchInput> {
|
public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Result, ExecutableSearchInput> {
|
||||||
|
|
||||||
private final ClientProxy client;
|
private final WatcherClientProxy client;
|
||||||
private final TimeValue defaultTimeout;
|
private final TimeValue defaultTimeout;
|
||||||
private IndicesQueriesRegistry queryRegistry;
|
private IndicesQueriesRegistry queryRegistry;
|
||||||
private AggregatorParsers aggParsers;
|
private AggregatorParsers aggParsers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SearchInputFactory(Settings settings, ClientProxy client, IndicesQueriesRegistry queryRegistry, AggregatorParsers aggParsers) {
|
public SearchInputFactory(Settings settings, WatcherClientProxy client, IndicesQueriesRegistry queryRegistry,
|
||||||
|
AggregatorParsers aggParsers) {
|
||||||
super(Loggers.getLogger(ExecutableSimpleInput.class, settings));
|
super(Loggers.getLogger(ExecutableSimpleInput.class, settings));
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.queryRegistry = queryRegistry;
|
this.queryRegistry = queryRegistry;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.gateway.GatewayService;
|
import org.elasticsearch.gateway.GatewayService;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.watch.WatchStore;
|
import org.elasticsearch.watcher.watch.WatchStore;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -38,7 +38,7 @@ import static java.util.Collections.unmodifiableSet;
|
||||||
public class WatcherIndexTemplateRegistry extends AbstractComponent implements ClusterStateListener {
|
public class WatcherIndexTemplateRegistry extends AbstractComponent implements ClusterStateListener {
|
||||||
private static final String FORBIDDEN_INDEX_SETTING = "index.mapper.dynamic";
|
private static final String FORBIDDEN_INDEX_SETTING = "index.mapper.dynamic";
|
||||||
|
|
||||||
private final ClientProxy client;
|
private final WatcherClientProxy client;
|
||||||
private final ThreadPool threadPool;
|
private final ThreadPool threadPool;
|
||||||
private final ClusterService clusterService;
|
private final ClusterService clusterService;
|
||||||
private final Set<TemplateConfig> indexTemplates;
|
private final Set<TemplateConfig> indexTemplates;
|
||||||
|
@ -47,7 +47,7 @@ public class WatcherIndexTemplateRegistry extends AbstractComponent implements C
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public WatcherIndexTemplateRegistry(Settings settings, ClusterSettings clusterSettings, ClusterService clusterService,
|
public WatcherIndexTemplateRegistry(Settings settings, ClusterSettings clusterSettings, ClusterService clusterService,
|
||||||
ThreadPool threadPool, ClientProxy client, Set<TemplateConfig> configs) {
|
ThreadPool threadPool, WatcherClientProxy client, Set<TemplateConfig> configs) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.threadPool = threadPool;
|
this.threadPool = threadPool;
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.watcher.support.init;
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
||||||
import org.elasticsearch.watcher.input.chain.ChainInputFactory;
|
import org.elasticsearch.watcher.input.chain.ChainInputFactory;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy;
|
import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy;
|
||||||
import org.elasticsearch.watcher.transform.chain.ChainTransformFactory;
|
import org.elasticsearch.watcher.transform.chain.ChainTransformFactory;
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@ public class InitializingModule extends AbstractModule {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
|
||||||
bind(ClientProxy.class).asEagerSingleton();
|
bind(WatcherClientProxy.class).asEagerSingleton();
|
||||||
bind(ScriptServiceProxy.class).asEagerSingleton();
|
bind(ScriptServiceProxy.class).asEagerSingleton();
|
||||||
bind(ChainInputFactory.class).asEagerSingleton();
|
bind(ChainInputFactory.class).asEagerSingleton();
|
||||||
|
|
||||||
Multibinder<InitializingService.Initializable> mbinder = Multibinder.newSetBinder(binder(),
|
Multibinder<InitializingService.Initializable> mbinder = Multibinder.newSetBinder(binder(),
|
||||||
InitializingService.Initializable.class);
|
InitializingService.Initializable.class);
|
||||||
mbinder.addBinding().to(ClientProxy.class);
|
mbinder.addBinding().to(WatcherClientProxy.class);
|
||||||
mbinder.addBinding().to(ScriptServiceProxy.class);
|
mbinder.addBinding().to(ScriptServiceProxy.class);
|
||||||
mbinder.addBinding().to(ChainTransformFactory.class);
|
mbinder.addBinding().to(ChainTransformFactory.class);
|
||||||
mbinder.addBinding().to(ChainInputFactory.class);
|
mbinder.addBinding().to(ChainInputFactory.class);
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.elasticsearch.watcher.support.init.InitializingService;
|
||||||
* A lazily initialized proxy to an elasticsearch {@link Client}. Inject this proxy whenever a client
|
* A lazily initialized proxy to an elasticsearch {@link Client}. Inject this proxy whenever a client
|
||||||
* needs to injected to be avoid circular dependencies issues.
|
* needs to injected to be avoid circular dependencies issues.
|
||||||
*/
|
*/
|
||||||
public class ClientProxy implements InitializingService.Initializable {
|
public class WatcherClientProxy implements InitializingService.Initializable {
|
||||||
|
|
||||||
private final TimeValue defaultSearchTimeout;
|
private final TimeValue defaultSearchTimeout;
|
||||||
private final TimeValue defaultIndexTimeout;
|
private final TimeValue defaultIndexTimeout;
|
||||||
|
@ -45,7 +45,7 @@ public class ClientProxy implements InitializingService.Initializable {
|
||||||
private InternalClient client;
|
private InternalClient client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ClientProxy(Settings settings) {
|
public WatcherClientProxy(Settings settings) {
|
||||||
defaultSearchTimeout = settings.getAsTime("watcher.internal.ops.search.default_timeout", TimeValue.timeValueSeconds(30));
|
defaultSearchTimeout = settings.getAsTime("watcher.internal.ops.search.default_timeout", TimeValue.timeValueSeconds(30));
|
||||||
defaultIndexTimeout = settings.getAsTime("watcher.internal.ops.index.default_timeout", TimeValue.timeValueSeconds(60));
|
defaultIndexTimeout = settings.getAsTime("watcher.internal.ops.index.default_timeout", TimeValue.timeValueSeconds(60));
|
||||||
defaultBulkTimeout = settings.getAsTime("watcher.internal.ops.bulk.default_timeout", TimeValue.timeValueSeconds(120));
|
defaultBulkTimeout = settings.getAsTime("watcher.internal.ops.bulk.default_timeout", TimeValue.timeValueSeconds(120));
|
||||||
|
@ -54,8 +54,8 @@ public class ClientProxy implements InitializingService.Initializable {
|
||||||
/**
|
/**
|
||||||
* Creates a proxy to the given internal client (can be used for testing)
|
* Creates a proxy to the given internal client (can be used for testing)
|
||||||
*/
|
*/
|
||||||
public static ClientProxy of(Client client) {
|
public static WatcherClientProxy of(Client client) {
|
||||||
ClientProxy proxy = new ClientProxy(Settings.EMPTY);
|
WatcherClientProxy proxy = new WatcherClientProxy(Settings.EMPTY);
|
||||||
proxy.client = client instanceof InternalClient ? (InternalClient) client : new InternalClient.Insecure(client);
|
proxy.client = client instanceof InternalClient ? (InternalClient) client : new InternalClient.Insecure(client);
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
|
@ -13,7 +13,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
||||||
import org.elasticsearch.watcher.support.WatcherUtils;
|
import org.elasticsearch.watcher.support.WatcherUtils;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.transform.ExecutableTransform;
|
import org.elasticsearch.watcher.transform.ExecutableTransform;
|
||||||
import org.elasticsearch.watcher.watch.Payload;
|
import org.elasticsearch.watcher.watch.Payload;
|
||||||
|
|
||||||
|
@ -24,10 +24,11 @@ public class ExecutableSearchTransform extends ExecutableTransform<SearchTransfo
|
||||||
|
|
||||||
public static final SearchType DEFAULT_SEARCH_TYPE = SearchType.QUERY_THEN_FETCH;
|
public static final SearchType DEFAULT_SEARCH_TYPE = SearchType.QUERY_THEN_FETCH;
|
||||||
|
|
||||||
protected final ClientProxy client;
|
protected final WatcherClientProxy client;
|
||||||
protected final @Nullable TimeValue timeout;
|
protected final @Nullable TimeValue timeout;
|
||||||
|
|
||||||
public ExecutableSearchTransform(SearchTransform transform, ESLogger logger, ClientProxy client, @Nullable TimeValue defaultTimeout) {
|
public ExecutableSearchTransform(SearchTransform transform, ESLogger logger, WatcherClientProxy client,
|
||||||
|
@Nullable TimeValue defaultTimeout) {
|
||||||
super(transform, logger);
|
super(transform, logger);
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.timeout = transform.getTimeout() != null ? transform.getTimeout() : defaultTimeout;
|
this.timeout = transform.getTimeout() != null ? transform.getTimeout() : defaultTimeout;
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.transform.TransformFactory;
|
import org.elasticsearch.watcher.transform.TransformFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -23,13 +23,13 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class SearchTransformFactory extends TransformFactory<SearchTransform, SearchTransform.Result, ExecutableSearchTransform> {
|
public class SearchTransformFactory extends TransformFactory<SearchTransform, SearchTransform.Result, ExecutableSearchTransform> {
|
||||||
|
|
||||||
protected final ClientProxy client;
|
protected final WatcherClientProxy client;
|
||||||
private final TimeValue defaultTimeout;
|
private final TimeValue defaultTimeout;
|
||||||
private IndicesQueriesRegistry queryRegistry;
|
private IndicesQueriesRegistry queryRegistry;
|
||||||
private AggregatorParsers aggParsers;
|
private AggregatorParsers aggParsers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SearchTransformFactory(Settings settings, ClientProxy client, IndicesQueriesRegistry queryRegistry,
|
public SearchTransformFactory(Settings settings, WatcherClientProxy client, IndicesQueriesRegistry queryRegistry,
|
||||||
AggregatorParsers aggParsers) {
|
AggregatorParsers aggParsers) {
|
||||||
super(Loggers.getLogger(ExecutableSearchTransform.class, settings));
|
super(Loggers.getLogger(ExecutableSearchTransform.class, settings));
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
import org.elasticsearch.search.sort.SortBuilders;
|
import org.elasticsearch.search.sort.SortBuilders;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -49,7 +49,7 @@ public class WatchStore extends AbstractComponent {
|
||||||
public static final String INDEX = ".watches";
|
public static final String INDEX = ".watches";
|
||||||
public static final String DOC_TYPE = "watch";
|
public static final String DOC_TYPE = "watch";
|
||||||
|
|
||||||
private final ClientProxy client;
|
private final WatcherClientProxy client;
|
||||||
private final Watch.Parser watchParser;
|
private final Watch.Parser watchParser;
|
||||||
|
|
||||||
private final ConcurrentMap<String, Watch> watches;
|
private final ConcurrentMap<String, Watch> watches;
|
||||||
|
@ -59,7 +59,7 @@ public class WatchStore extends AbstractComponent {
|
||||||
private final TimeValue scrollTimeout;
|
private final TimeValue scrollTimeout;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public WatchStore(Settings settings, ClientProxy client, Watch.Parser watchParser) {
|
public WatchStore(Settings settings, WatcherClientProxy client, Watch.Parser watchParser) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.watchParser = watchParser;
|
this.watchParser = watchParser;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.elasticsearch.watcher.actions.Action;
|
||||||
import org.elasticsearch.watcher.actions.Action.Result.Status;
|
import org.elasticsearch.watcher.actions.Action.Result.Status;
|
||||||
import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
||||||
import org.elasticsearch.watcher.support.WatcherDateTimeUtils;
|
import org.elasticsearch.watcher.support.WatcherDateTimeUtils;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.support.xcontent.XContentSource;
|
import org.elasticsearch.watcher.support.xcontent.XContentSource;
|
||||||
import org.elasticsearch.watcher.test.WatcherTestUtils;
|
import org.elasticsearch.watcher.test.WatcherTestUtils;
|
||||||
import org.elasticsearch.watcher.watch.Payload;
|
import org.elasticsearch.watcher.watch.Payload;
|
||||||
|
@ -72,7 +72,7 @@ public class IndexActionTests extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexAction action = new IndexAction("test-index", "test-type", timestampField, null, null);
|
IndexAction action = new IndexAction("test-index", "test-type", timestampField, null, null);
|
||||||
ExecutableIndexAction executable = new ExecutableIndexAction(action, logger, ClientProxy.of(client()), null);
|
ExecutableIndexAction executable = new ExecutableIndexAction(action, logger, WatcherClientProxy.of(client()), null);
|
||||||
DateTime executionTime = DateTime.now(UTC);
|
DateTime executionTime = DateTime.now(UTC);
|
||||||
Payload payload = randomBoolean() ? new Payload.Simple("foo", "bar") : new Payload.Simple("_doc", singletonMap("foo", "bar"));
|
Payload payload = randomBoolean() ? new Payload.Simple("foo", "bar") : new Payload.Simple("_doc", singletonMap("foo", "bar"));
|
||||||
WatchExecutionContext ctx = WatcherTestUtils.mockExecutionContext("_id", executionTime, payload);
|
WatchExecutionContext ctx = WatcherTestUtils.mockExecutionContext("_id", executionTime, payload);
|
||||||
|
@ -132,7 +132,7 @@ public class IndexActionTests extends ESIntegTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
IndexAction action = new IndexAction("test-index", "test-type", timestampField, null, null);
|
IndexAction action = new IndexAction("test-index", "test-type", timestampField, null, null);
|
||||||
ExecutableIndexAction executable = new ExecutableIndexAction(action, logger, ClientProxy.of(client()), null);
|
ExecutableIndexAction executable = new ExecutableIndexAction(action, logger, WatcherClientProxy.of(client()), null);
|
||||||
DateTime executionTime = DateTime.now(UTC);
|
DateTime executionTime = DateTime.now(UTC);
|
||||||
WatchExecutionContext ctx = WatcherTestUtils.mockExecutionContext("_id", executionTime, new Payload.Simple("_doc", list));
|
WatchExecutionContext ctx = WatcherTestUtils.mockExecutionContext("_id", executionTime, new Payload.Simple("_doc", list));
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ public class IndexActionTests extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, ClientProxy.of(client()));
|
IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, WatcherClientProxy.of(client()));
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ public class IndexActionTests extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, ClientProxy.of(client()));
|
IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, WatcherClientProxy.of(client()));
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
|
||||||
import org.elasticsearch.watcher.actions.Action;
|
import org.elasticsearch.watcher.actions.Action;
|
||||||
import org.elasticsearch.watcher.actions.Action.Result.Status;
|
import org.elasticsearch.watcher.actions.Action.Result.Status;
|
||||||
import org.elasticsearch.watcher.actions.email.service.Attachment;
|
import org.elasticsearch.watcher.actions.email.service.Attachment;
|
||||||
|
@ -32,12 +31,10 @@ import org.elasticsearch.watcher.support.http.HttpRequestTemplate;
|
||||||
import org.elasticsearch.watcher.support.http.HttpResponse;
|
import org.elasticsearch.watcher.support.http.HttpResponse;
|
||||||
import org.elasticsearch.watcher.support.http.auth.HttpAuthRegistry;
|
import org.elasticsearch.watcher.support.http.auth.HttpAuthRegistry;
|
||||||
import org.elasticsearch.watcher.support.http.auth.basic.BasicAuthFactory;
|
import org.elasticsearch.watcher.support.http.auth.basic.BasicAuthFactory;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy;
|
|
||||||
import org.elasticsearch.watcher.support.secret.SecretService;
|
import org.elasticsearch.watcher.support.secret.SecretService;
|
||||||
import org.elasticsearch.watcher.support.text.TextTemplate;
|
import org.elasticsearch.watcher.support.text.TextTemplate;
|
||||||
import org.elasticsearch.watcher.support.text.TextTemplateEngine;
|
import org.elasticsearch.watcher.support.text.TextTemplateEngine;
|
||||||
import org.elasticsearch.watcher.support.text.DefaultTextTemplateEngine;
|
|
||||||
import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTestCase;
|
import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTestCase;
|
||||||
import org.elasticsearch.watcher.test.MockTextTemplateEngine;
|
import org.elasticsearch.watcher.test.MockTextTemplateEngine;
|
||||||
import org.elasticsearch.watcher.test.WatcherTestUtils;
|
import org.elasticsearch.watcher.test.WatcherTestUtils;
|
||||||
|
@ -46,7 +43,6 @@ import org.elasticsearch.watcher.watch.Payload;
|
||||||
import org.elasticsearch.watcher.watch.Watch;
|
import org.elasticsearch.watcher.watch.Watch;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import javax.mail.internet.AddressException;
|
import javax.mail.internet.AddressException;
|
||||||
|
@ -242,7 +238,7 @@ public class WebhookActionTests extends ESTestCase {
|
||||||
|
|
||||||
ExecutableWebhookAction executable = new ExecutableWebhookAction(action, logger, httpClient, templateEngine);
|
ExecutableWebhookAction executable = new ExecutableWebhookAction(action, logger, httpClient, templateEngine);
|
||||||
String watchId = "test_url_encode" + randomAsciiOfLength(10);
|
String watchId = "test_url_encode" + randomAsciiOfLength(10);
|
||||||
Watch watch = createWatch(watchId, mock(ClientProxy.class), "account1");
|
Watch watch = createWatch(watchId, mock(WatcherClientProxy.class), "account1");
|
||||||
WatchExecutionContext ctx = new TriggeredExecutionContext(watch, new DateTime(UTC),
|
WatchExecutionContext ctx = new TriggeredExecutionContext(watch, new DateTime(UTC),
|
||||||
new ScheduleTriggerEvent(watchId, new DateTime(UTC), new DateTime(UTC)), timeValueSeconds(5));
|
new ScheduleTriggerEvent(watchId, new DateTime(UTC), new DateTime(UTC)), timeValueSeconds(5));
|
||||||
executable.execute("_id", ctx, new Payload.Simple());
|
executable.execute("_id", ctx, new Payload.Simple());
|
||||||
|
@ -268,14 +264,14 @@ public class WebhookActionTests extends ESTestCase {
|
||||||
|
|
||||||
ExecutableWebhookAction executable = new ExecutableWebhookAction(action, logger, client, templateEngine);
|
ExecutableWebhookAction executable = new ExecutableWebhookAction(action, logger, client, templateEngine);
|
||||||
|
|
||||||
Watch watch = createWatch(watchId, mock(ClientProxy.class), "account1");
|
Watch watch = createWatch(watchId, mock(WatcherClientProxy.class), "account1");
|
||||||
WatchExecutionContext ctx = new TriggeredExecutionContext(watch, new DateTime(UTC),
|
WatchExecutionContext ctx = new TriggeredExecutionContext(watch, new DateTime(UTC),
|
||||||
new ScheduleTriggerEvent(watchId, new DateTime(UTC), new DateTime(UTC)), timeValueSeconds(5));
|
new ScheduleTriggerEvent(watchId, new DateTime(UTC), new DateTime(UTC)), timeValueSeconds(5));
|
||||||
Action.Result result = executable.execute("_id", ctx, new Payload.Simple());
|
Action.Result result = executable.execute("_id", ctx, new Payload.Simple());
|
||||||
assertThat(result, Matchers.instanceOf(WebhookAction.Result.Success.class));
|
assertThat(result, Matchers.instanceOf(WebhookAction.Result.Success.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Watch createWatch(String watchId, ClientProxy client, final String account) throws AddressException, IOException {
|
private Watch createWatch(String watchId, WatcherClientProxy client, final String account) throws AddressException, IOException {
|
||||||
return WatcherTestUtils.createTestWatch(watchId,
|
return WatcherTestUtils.createTestWatch(watchId,
|
||||||
client,
|
client,
|
||||||
ExecuteScenario.Success.client(),
|
ExecuteScenario.Success.client(),
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.elasticsearch.search.internal.InternalSearchHit;
|
||||||
import org.elasticsearch.search.internal.InternalSearchHits;
|
import org.elasticsearch.search.internal.InternalSearchHits;
|
||||||
import org.elasticsearch.search.internal.InternalSearchResponse;
|
import org.elasticsearch.search.internal.InternalSearchResponse;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.hamcrest.core.IsNull;
|
import org.hamcrest.core.IsNull;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
@ -53,13 +53,13 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class TriggeredWatchStoreTests extends ESTestCase {
|
public class TriggeredWatchStoreTests extends ESTestCase {
|
||||||
private ClientProxy clientProxy;
|
private WatcherClientProxy clientProxy;
|
||||||
private TriggeredWatch.Parser parser;
|
private TriggeredWatch.Parser parser;
|
||||||
private TriggeredWatchStore triggeredWatchStore;
|
private TriggeredWatchStore triggeredWatchStore;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
clientProxy = mock(ClientProxy.class);
|
clientProxy = mock(WatcherClientProxy.class);
|
||||||
parser = mock(TriggeredWatch.Parser.class);
|
parser = mock(TriggeredWatch.Parser.class);
|
||||||
triggeredWatchStore = new TriggeredWatchStore(Settings.EMPTY, clientProxy, parser);
|
triggeredWatchStore = new TriggeredWatchStore(Settings.EMPTY, clientProxy, parser);
|
||||||
triggeredWatchStore.start();
|
triggeredWatchStore.start();
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.watcher.WatcherModule;
|
import org.elasticsearch.watcher.WatcherModule;
|
||||||
import org.elasticsearch.watcher.execution.ExecutionState;
|
import org.elasticsearch.watcher.execution.ExecutionState;
|
||||||
import org.elasticsearch.watcher.execution.Wid;
|
import org.elasticsearch.watcher.execution.Wid;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.trigger.schedule.ScheduleTriggerEvent;
|
import org.elasticsearch.watcher.trigger.schedule.ScheduleTriggerEvent;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -31,11 +31,11 @@ import static org.mockito.Mockito.when;
|
||||||
*/
|
*/
|
||||||
public class HistoryStoreTests extends ESTestCase {
|
public class HistoryStoreTests extends ESTestCase {
|
||||||
private HistoryStore historyStore;
|
private HistoryStore historyStore;
|
||||||
private ClientProxy clientProxy;
|
private WatcherClientProxy clientProxy;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
clientProxy = mock(ClientProxy.class);
|
clientProxy = mock(WatcherClientProxy.class);
|
||||||
historyStore = new HistoryStore(Settings.EMPTY, clientProxy);
|
historyStore = new HistoryStore(Settings.EMPTY, clientProxy);
|
||||||
historyStore.start();
|
historyStore.start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ import org.elasticsearch.watcher.support.WatcherUtils;
|
||||||
import org.elasticsearch.watcher.support.http.HttpClient;
|
import org.elasticsearch.watcher.support.http.HttpClient;
|
||||||
import org.elasticsearch.watcher.support.http.HttpMethod;
|
import org.elasticsearch.watcher.support.http.HttpMethod;
|
||||||
import org.elasticsearch.watcher.support.http.HttpRequestTemplate;
|
import org.elasticsearch.watcher.support.http.HttpRequestTemplate;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy;
|
import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy;
|
||||||
import org.elasticsearch.watcher.support.secret.Secret;
|
import org.elasticsearch.watcher.support.secret.Secret;
|
||||||
import org.elasticsearch.watcher.support.text.TextTemplate;
|
import org.elasticsearch.watcher.support.text.TextTemplate;
|
||||||
|
@ -172,11 +172,11 @@ public final class WatcherTestUtils {
|
||||||
|
|
||||||
public static Watch createTestWatch(String watchName, HttpClient httpClient, EmailService emailService,
|
public static Watch createTestWatch(String watchName, HttpClient httpClient, EmailService emailService,
|
||||||
ESLogger logger) throws AddressException {
|
ESLogger logger) throws AddressException {
|
||||||
return createTestWatch(watchName, ClientProxy.of(ESIntegTestCase.client()), httpClient, emailService, logger);
|
return createTestWatch(watchName, WatcherClientProxy.of(ESIntegTestCase.client()), httpClient, emailService, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Watch createTestWatch(String watchName, ClientProxy client, HttpClient httpClient, EmailService emailService,
|
public static Watch createTestWatch(String watchName, WatcherClientProxy client, HttpClient httpClient, EmailService emailService,
|
||||||
ESLogger logger) throws AddressException {
|
ESLogger logger) throws AddressException {
|
||||||
|
|
||||||
SearchRequest conditionRequest = newInputSearchRequest("my-condition-index").source(searchSource().query(matchAllQuery()));
|
SearchRequest conditionRequest = newInputSearchRequest("my-condition-index").source(searchSource().query(matchAllQuery()));
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.elasticsearch.search.SearchHitField;
|
||||||
import org.elasticsearch.search.internal.InternalSearchHit;
|
import org.elasticsearch.search.internal.InternalSearchHit;
|
||||||
import org.elasticsearch.search.internal.InternalSearchHits;
|
import org.elasticsearch.search.internal.InternalSearchHits;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -52,12 +52,12 @@ import static org.mockito.Mockito.when;
|
||||||
*/
|
*/
|
||||||
public class WatchStoreTests extends ESTestCase {
|
public class WatchStoreTests extends ESTestCase {
|
||||||
private WatchStore watchStore;
|
private WatchStore watchStore;
|
||||||
private ClientProxy clientProxy;
|
private WatcherClientProxy clientProxy;
|
||||||
private Watch.Parser parser;
|
private Watch.Parser parser;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
clientProxy = mock(ClientProxy.class);
|
clientProxy = mock(WatcherClientProxy.class);
|
||||||
parser = mock(Watch.Parser.class);
|
parser = mock(Watch.Parser.class);
|
||||||
watchStore = new WatchStore(Settings.EMPTY, clientProxy, parser);
|
watchStore = new WatchStore(Settings.EMPTY, clientProxy, parser);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ import org.elasticsearch.watcher.support.http.HttpMethod;
|
||||||
import org.elasticsearch.watcher.support.http.HttpRequestTemplate;
|
import org.elasticsearch.watcher.support.http.HttpRequestTemplate;
|
||||||
import org.elasticsearch.watcher.support.http.auth.HttpAuthRegistry;
|
import org.elasticsearch.watcher.support.http.auth.HttpAuthRegistry;
|
||||||
import org.elasticsearch.watcher.support.http.auth.basic.BasicAuthFactory;
|
import org.elasticsearch.watcher.support.http.auth.basic.BasicAuthFactory;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy;
|
import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy;
|
||||||
import org.elasticsearch.watcher.support.secret.SecretService;
|
import org.elasticsearch.watcher.support.secret.SecretService;
|
||||||
import org.elasticsearch.watcher.support.text.TextTemplate;
|
import org.elasticsearch.watcher.support.text.TextTemplate;
|
||||||
|
@ -141,7 +141,7 @@ import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
public class WatchTests extends ESTestCase {
|
public class WatchTests extends ESTestCase {
|
||||||
private ScriptServiceProxy scriptService;
|
private ScriptServiceProxy scriptService;
|
||||||
private ClientProxy client;
|
private WatcherClientProxy client;
|
||||||
private HttpClient httpClient;
|
private HttpClient httpClient;
|
||||||
private EmailService emailService;
|
private EmailService emailService;
|
||||||
private TextTemplateEngine templateEngine;
|
private TextTemplateEngine templateEngine;
|
||||||
|
@ -155,7 +155,7 @@ public class WatchTests extends ESTestCase {
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
scriptService = mock(ScriptServiceProxy.class);
|
scriptService = mock(ScriptServiceProxy.class);
|
||||||
client = mock(ClientProxy.class);
|
client = mock(WatcherClientProxy.class);
|
||||||
httpClient = mock(HttpClient.class);
|
httpClient = mock(HttpClient.class);
|
||||||
emailService = mock(EmailService.class);
|
emailService = mock(EmailService.class);
|
||||||
templateEngine = mock(TextTemplateEngine.class);
|
templateEngine = mock(TextTemplateEngine.class);
|
||||||
|
|
Loading…
Reference in New Issue