Watcher: Rename ClientProxy to WatcherClientProxy

Original commit: elastic/x-pack-elasticsearch@84c17d1bc0
This commit is contained in:
Tanguy Leroux 2016-03-08 13:34:13 +01:00
parent f4eb0e7c7c
commit 146f91f730
21 changed files with 75 additions and 77 deletions

View File

@ -34,7 +34,7 @@ import org.elasticsearch.watcher.input.search.SearchInput;
import org.elasticsearch.watcher.input.search.SearchInputFactory;
import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput;
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.trigger.schedule.IntervalSchedule;
import org.elasticsearch.watcher.trigger.schedule.ScheduleTrigger;
@ -132,7 +132,7 @@ public class SearchInputIT extends ESIntegTestCase {
.source(searchSourceBuilder);
ExecutableSearchInput searchInput = new ExecutableSearchInput(new SearchInput(request, null, null, null), logger,
ClientProxy.of(client()), null);
WatcherClientProxy.of(client()), null);
WatchExecutionContext ctx = new TriggeredExecutionContext(
new Watch("test-watch",
new ScheduleTrigger(new IntervalSchedule(new IntervalSchedule.Interval(1, IntervalSchedule.Interval.Unit.MINUTES))),
@ -244,7 +244,7 @@ public class SearchInputIT extends ESIntegTestCase {
.source(searchSourceBuilder);
ExecutableSearchInput searchInput = new ExecutableSearchInput(new SearchInput(request, null, null, null), logger,
ClientProxy.of(client()), null);
WatcherClientProxy.of(client()), null);
WatchExecutionContext ctx = new TriggeredExecutionContext(
new Watch("test-watch",
new ScheduleTrigger(new IntervalSchedule(new IntervalSchedule.Interval(1, IntervalSchedule.Interval.Unit.MINUTES))),
@ -281,7 +281,7 @@ public class SearchInputIT extends ESIntegTestCase {
parser.nextToken();
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);
assertEquals(SearchInput.TYPE, searchInput.type());
@ -311,7 +311,7 @@ public class SearchInputIT extends ESIntegTestCase {
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());
}

View File

@ -37,7 +37,7 @@ import org.elasticsearch.watcher.execution.TriggeredExecutionContext;
import org.elasticsearch.watcher.execution.WatchExecutionContext;
import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput;
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.transform.Transform;
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()));
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);
@ -188,7 +188,7 @@ public class SearchTransformIT extends ESIntegTestCase {
new SearchSourceBuilder().query(QueryBuilders.wrapperQuery(jsonBuilder().startObject()
.startObject("_unknown_query_").endObject().endObject().bytes())));
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);
@ -252,7 +252,7 @@ public class SearchTransformIT extends ESIntegTestCase {
.must(termQuery("value", "{{ctx.payload.value}}"))));
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),
parseDate("2015-01-01T00:00:00", UTC));
@ -318,7 +318,7 @@ public class SearchTransformIT extends ESIntegTestCase {
parser.nextToken();
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,
null);
ExecutableSearchTransform executable = transformFactory.parseExecutable("_id", parser);
@ -482,7 +482,7 @@ public class SearchTransformIT extends ESIntegTestCase {
SearchTransform searchTransform = TransformBuilders.searchTransform(request).build();
ExecutableSearchTransform executableSearchTransform = new ExecutableSearchTransform(searchTransform, logger,
ClientProxy.of(client()), null);
WatcherClientProxy.of(client()), null);
return executableSearchTransform.execute(ctx, Payload.Simple.EMPTY);
}

View File

@ -21,7 +21,7 @@ import org.elasticsearch.watcher.actions.ExecutableAction;
import org.elasticsearch.watcher.execution.WatchExecutionContext;
import org.elasticsearch.watcher.support.ArrayObjectIterator;
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.watch.Payload;
@ -34,10 +34,10 @@ import static org.elasticsearch.watcher.support.Exceptions.illegalState;
public class ExecutableIndexAction extends ExecutableAction<IndexAction> {
private final ClientProxy client;
private final WatcherClientProxy client;
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);
this.client = client;
this.timeout = action.timeout != null ? action.timeout : defaultTimeout;

View File

@ -12,7 +12,7 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.watcher.actions.ActionFactory;
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;
@ -21,11 +21,11 @@ import java.io.IOException;
*/
public class IndexActionFactory extends ActionFactory<IndexAction, ExecutableIndexAction> {
private final ClientProxy client;
private final WatcherClientProxy client;
private final TimeValue defaultTimeout;
@Inject
public IndexActionFactory(Settings settings, ClientProxy client) {
public IndexActionFactory(Settings settings, WatcherClientProxy client) {
super(Loggers.getLogger(ExecutableEmailAction.class, settings));
this.client = client;
this.defaultTimeout = settings.getAsTime("watcher.actions.index.default_timeout", null);

View File

@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
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.util.ArrayList;
@ -47,7 +47,7 @@ public class TriggeredWatchStore extends AbstractComponent {
public static final String DOC_TYPE = "triggered_watch";
private final int scrollSize;
private final ClientProxy client;
private final WatcherClientProxy client;
private final TimeValue scrollTimeout;
private final TriggeredWatch.Parser triggeredWatchParser;
@ -57,7 +57,7 @@ public class TriggeredWatchStore extends AbstractComponent {
private final AtomicBoolean started = new AtomicBoolean(false);
@Inject
public TriggeredWatchStore(Settings settings, ClientProxy client, TriggeredWatch.Parser triggeredWatchParser) {
public TriggeredWatchStore(Settings settings, WatcherClientProxy client, TriggeredWatch.Parser triggeredWatchParser) {
super(settings);
this.scrollSize = settings.getAsInt("watcher.execution.scroll.size", 100);
this.client = client;

View File

@ -14,7 +14,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.elasticsearch.watcher.WatcherModule;
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.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
@ -36,7 +36,7 @@ public class HistoryStore extends AbstractComponent {
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 Lock putUpdateLock = readWriteLock.readLock();
@ -44,7 +44,7 @@ public class HistoryStore extends AbstractComponent {
private final AtomicBoolean started = new AtomicBoolean(false);
@Inject
public HistoryStore(Settings settings, ClientProxy client) {
public HistoryStore(Settings settings, WatcherClientProxy client) {
super(settings);
this.client = client;
}

View File

@ -20,7 +20,7 @@ import org.elasticsearch.watcher.execution.WatchExecutionContext;
import org.elasticsearch.watcher.input.ExecutableInput;
import org.elasticsearch.watcher.support.WatcherUtils;
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 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;
private final ClientProxy client;
private final WatcherClientProxy client;
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);
this.client = client;
this.timeout = input.getTimeout() != null ? input.getTimeout() : defaultTimeout;

View File

@ -15,7 +15,7 @@ import org.elasticsearch.indices.query.IndicesQueriesRegistry;
import org.elasticsearch.search.aggregations.AggregatorParsers;
import org.elasticsearch.watcher.input.InputFactory;
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;
@ -24,13 +24,14 @@ import java.io.IOException;
*/
public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Result, ExecutableSearchInput> {
private final ClientProxy client;
private final WatcherClientProxy client;
private final TimeValue defaultTimeout;
private IndicesQueriesRegistry queryRegistry;
private AggregatorParsers aggParsers;
@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));
this.client = client;
this.queryRegistry = queryRegistry;

View File

@ -20,7 +20,7 @@ import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.gateway.GatewayService;
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 java.io.InputStream;
@ -38,7 +38,7 @@ import static java.util.Collections.unmodifiableSet;
public class WatcherIndexTemplateRegistry extends AbstractComponent implements ClusterStateListener {
private static final String FORBIDDEN_INDEX_SETTING = "index.mapper.dynamic";
private final ClientProxy client;
private final WatcherClientProxy client;
private final ThreadPool threadPool;
private final ClusterService clusterService;
private final Set<TemplateConfig> indexTemplates;
@ -47,7 +47,7 @@ public class WatcherIndexTemplateRegistry extends AbstractComponent implements C
@Inject
public WatcherIndexTemplateRegistry(Settings settings, ClusterSettings clusterSettings, ClusterService clusterService,
ThreadPool threadPool, ClientProxy client, Set<TemplateConfig> configs) {
ThreadPool threadPool, WatcherClientProxy client, Set<TemplateConfig> configs) {
super(settings);
this.client = client;
this.threadPool = threadPool;

View File

@ -8,7 +8,7 @@ package org.elasticsearch.watcher.support.init;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.multibindings.Multibinder;
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.transform.chain.ChainTransformFactory;
@ -20,13 +20,13 @@ public class InitializingModule extends AbstractModule {
@Override
protected void configure() {
bind(ClientProxy.class).asEagerSingleton();
bind(WatcherClientProxy.class).asEagerSingleton();
bind(ScriptServiceProxy.class).asEagerSingleton();
bind(ChainInputFactory.class).asEagerSingleton();
Multibinder<InitializingService.Initializable> mbinder = Multibinder.newSetBinder(binder(),
InitializingService.Initializable.class);
mbinder.addBinding().to(ClientProxy.class);
mbinder.addBinding().to(WatcherClientProxy.class);
mbinder.addBinding().to(ScriptServiceProxy.class);
mbinder.addBinding().to(ChainTransformFactory.class);
mbinder.addBinding().to(ChainInputFactory.class);

View File

@ -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
* 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 defaultIndexTimeout;
@ -45,7 +45,7 @@ public class ClientProxy implements InitializingService.Initializable {
private InternalClient client;
@Inject
public ClientProxy(Settings settings) {
public WatcherClientProxy(Settings settings) {
defaultSearchTimeout = settings.getAsTime("watcher.internal.ops.search.default_timeout", TimeValue.timeValueSeconds(30));
defaultIndexTimeout = settings.getAsTime("watcher.internal.ops.index.default_timeout", TimeValue.timeValueSeconds(60));
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)
*/
public static ClientProxy of(Client client) {
ClientProxy proxy = new ClientProxy(Settings.EMPTY);
public static WatcherClientProxy of(Client client) {
WatcherClientProxy proxy = new WatcherClientProxy(Settings.EMPTY);
proxy.client = client instanceof InternalClient ? (InternalClient) client : new InternalClient.Insecure(client);
return proxy;
}

View File

@ -13,7 +13,7 @@ import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.watcher.execution.WatchExecutionContext;
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.watch.Payload;
@ -24,10 +24,11 @@ public class ExecutableSearchTransform extends ExecutableTransform<SearchTransfo
public static final SearchType DEFAULT_SEARCH_TYPE = SearchType.QUERY_THEN_FETCH;
protected final ClientProxy client;
protected final WatcherClientProxy client;
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);
this.client = client;
this.timeout = transform.getTimeout() != null ? transform.getTimeout() : defaultTimeout;

View File

@ -13,7 +13,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
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 java.io.IOException;
@ -23,14 +23,14 @@ import java.io.IOException;
*/
public class SearchTransformFactory extends TransformFactory<SearchTransform, SearchTransform.Result, ExecutableSearchTransform> {
protected final ClientProxy client;
protected final WatcherClientProxy client;
private final TimeValue defaultTimeout;
private IndicesQueriesRegistry queryRegistry;
private AggregatorParsers aggParsers;
@Inject
public SearchTransformFactory(Settings settings, ClientProxy client, IndicesQueriesRegistry queryRegistry,
AggregatorParsers aggParsers) {
public SearchTransformFactory(Settings settings, WatcherClientProxy client, IndicesQueriesRegistry queryRegistry,
AggregatorParsers aggParsers) {
super(Loggers.getLogger(ExecutableSearchTransform.class, settings));
this.client = client;
this.queryRegistry = queryRegistry;

View File

@ -31,7 +31,7 @@ import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
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.util.Collection;
@ -49,7 +49,7 @@ public class WatchStore extends AbstractComponent {
public static final String INDEX = ".watches";
public static final String DOC_TYPE = "watch";
private final ClientProxy client;
private final WatcherClientProxy client;
private final Watch.Parser watchParser;
private final ConcurrentMap<String, Watch> watches;
@ -59,7 +59,7 @@ public class WatchStore extends AbstractComponent {
private final TimeValue scrollTimeout;
@Inject
public WatchStore(Settings settings, ClientProxy client, Watch.Parser watchParser) {
public WatchStore(Settings settings, WatcherClientProxy client, Watch.Parser watchParser) {
super(settings);
this.client = client;
this.watchParser = watchParser;

View File

@ -20,7 +20,7 @@ import org.elasticsearch.watcher.actions.Action;
import org.elasticsearch.watcher.actions.Action.Result.Status;
import org.elasticsearch.watcher.execution.WatchExecutionContext;
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.test.WatcherTestUtils;
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);
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);
Payload payload = randomBoolean() ? new Payload.Simple("foo", "bar") : new Payload.Simple("_doc", singletonMap("foo", "bar"));
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);
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);
WatchExecutionContext ctx = WatcherTestUtils.mockExecutionContext("_id", executionTime, new Payload.Simple("_doc", list));
@ -196,7 +196,7 @@ public class IndexActionTests extends ESIntegTestCase {
}
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());
parser.nextToken();
@ -224,7 +224,7 @@ public class IndexActionTests extends ESIntegTestCase {
}
}
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());
parser.nextToken();
try {

View File

@ -15,7 +15,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.env.Environment;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.actions.Action;
import org.elasticsearch.watcher.actions.Action.Result.Status;
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.auth.HttpAuthRegistry;
import org.elasticsearch.watcher.support.http.auth.basic.BasicAuthFactory;
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy;
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
import org.elasticsearch.watcher.support.secret.SecretService;
import org.elasticsearch.watcher.support.text.TextTemplate;
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.MockTextTemplateEngine;
import org.elasticsearch.watcher.test.WatcherTestUtils;
@ -46,7 +43,6 @@ import org.elasticsearch.watcher.watch.Payload;
import org.elasticsearch.watcher.watch.Watch;
import org.hamcrest.Matchers;
import org.joda.time.DateTime;
import org.junit.After;
import org.junit.Before;
import javax.mail.internet.AddressException;
@ -242,7 +238,7 @@ public class WebhookActionTests extends ESTestCase {
ExecutableWebhookAction executable = new ExecutableWebhookAction(action, logger, httpClient, templateEngine);
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),
new ScheduleTriggerEvent(watchId, new DateTime(UTC), new DateTime(UTC)), timeValueSeconds(5));
executable.execute("_id", ctx, new Payload.Simple());
@ -268,14 +264,14 @@ public class WebhookActionTests extends ESTestCase {
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),
new ScheduleTriggerEvent(watchId, new DateTime(UTC), new DateTime(UTC)), timeValueSeconds(5));
Action.Result result = executable.execute("_id", ctx, new Payload.Simple());
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,
client,
ExecuteScenario.Success.client(),

View File

@ -33,7 +33,7 @@ import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.InternalSearchHits;
import org.elasticsearch.search.internal.InternalSearchResponse;
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.junit.Before;
@ -53,13 +53,13 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
public class TriggeredWatchStoreTests extends ESTestCase {
private ClientProxy clientProxy;
private WatcherClientProxy clientProxy;
private TriggeredWatch.Parser parser;
private TriggeredWatchStore triggeredWatchStore;
@Before
public void init() {
clientProxy = mock(ClientProxy.class);
clientProxy = mock(WatcherClientProxy.class);
parser = mock(TriggeredWatch.Parser.class);
triggeredWatchStore = new TriggeredWatchStore(Settings.EMPTY, clientProxy, parser);
triggeredWatchStore.start();

View File

@ -13,7 +13,7 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.watcher.WatcherModule;
import org.elasticsearch.watcher.execution.ExecutionState;
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.joda.time.DateTime;
import org.junit.Before;
@ -31,11 +31,11 @@ import static org.mockito.Mockito.when;
*/
public class HistoryStoreTests extends ESTestCase {
private HistoryStore historyStore;
private ClientProxy clientProxy;
private WatcherClientProxy clientProxy;
@Before
public void init() {
clientProxy = mock(ClientProxy.class);
clientProxy = mock(WatcherClientProxy.class);
historyStore = new HistoryStore(Settings.EMPTY, clientProxy);
historyStore.start();
}

View File

@ -50,7 +50,7 @@ import org.elasticsearch.watcher.support.WatcherUtils;
import org.elasticsearch.watcher.support.http.HttpClient;
import org.elasticsearch.watcher.support.http.HttpMethod;
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.secret.Secret;
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,
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 {
SearchRequest conditionRequest = newInputSearchRequest("my-condition-index").source(searchSource().query(matchAllQuery()));

View File

@ -32,7 +32,7 @@ import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.InternalSearchHits;
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 java.util.Collections;
@ -52,12 +52,12 @@ import static org.mockito.Mockito.when;
*/
public class WatchStoreTests extends ESTestCase {
private WatchStore watchStore;
private ClientProxy clientProxy;
private WatcherClientProxy clientProxy;
private Watch.Parser parser;
@Before
public void init() {
clientProxy = mock(ClientProxy.class);
clientProxy = mock(WatcherClientProxy.class);
parser = mock(Watch.Parser.class);
watchStore = new WatchStore(Settings.EMPTY, clientProxy, parser);
}

View File

@ -76,7 +76,7 @@ import org.elasticsearch.watcher.support.http.HttpMethod;
import org.elasticsearch.watcher.support.http.HttpRequestTemplate;
import org.elasticsearch.watcher.support.http.auth.HttpAuthRegistry;
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.text.TextTemplate;
@ -141,7 +141,7 @@ import static org.mockito.Mockito.mock;
public class WatchTests extends ESTestCase {
private ScriptServiceProxy scriptService;
private ClientProxy client;
private WatcherClientProxy client;
private HttpClient httpClient;
private EmailService emailService;
private TextTemplateEngine templateEngine;
@ -155,7 +155,7 @@ public class WatchTests extends ESTestCase {
@Before
public void init() throws Exception {
scriptService = mock(ScriptServiceProxy.class);
client = mock(ClientProxy.class);
client = mock(WatcherClientProxy.class);
httpClient = mock(HttpClient.class);
emailService = mock(EmailService.class);
templateEngine = mock(TextTemplateEngine.class);