diff --git a/src/main/java/org/elasticsearch/watcher/rest/action/RestWatcherStatsAction.java b/src/main/java/org/elasticsearch/watcher/rest/action/RestWatcherStatsAction.java index 9a0c3fbe3ac..99eefc62359 100644 --- a/src/main/java/org/elasticsearch/watcher/rest/action/RestWatcherStatsAction.java +++ b/src/main/java/org/elasticsearch/watcher/rest/action/RestWatcherStatsAction.java @@ -35,7 +35,7 @@ public class RestWatcherStatsAction extends WatcherRestHandler { @Override public RestResponse buildResponse(WatcherStatsResponse watcherStatsResponse, XContentBuilder builder) throws Exception { builder.startObject(); - builder.field("watcher_state", watcherStatsResponse.getWatchServiceState().toString().toLowerCase(Locale.ROOT)) + builder.field("watcher_state", watcherStatsResponse.getWatcherState().toString().toLowerCase(Locale.ROOT)) .field("watch_count", watcherStatsResponse.getWatchesCount()); builder.startObject("execution_queue") diff --git a/src/main/java/org/elasticsearch/watcher/transport/actions/stats/TransportWatcherStatsAction.java b/src/main/java/org/elasticsearch/watcher/transport/actions/stats/TransportWatcherStatsAction.java index 1ef93e6df8c..1d9ffdf14b3 100644 --- a/src/main/java/org/elasticsearch/watcher/transport/actions/stats/TransportWatcherStatsAction.java +++ b/src/main/java/org/elasticsearch/watcher/transport/actions/stats/TransportWatcherStatsAction.java @@ -58,7 +58,7 @@ public class TransportWatcherStatsAction extends WatcherTransportAction listener) throws ElasticsearchException { WatcherStatsResponse statsResponse = new WatcherStatsResponse(); - statsResponse.setWatchServiceState(watcherService.state()); + statsResponse.setWatcherState(watcherService.state()); statsResponse.setWatchExecutionQueueSize(executionService.queueSize()); statsResponse.setWatchesCount(watcherService.watchesCount()); statsResponse.setWatchExecutionQueueMaxSize(executionService.largestQueueSize()); diff --git a/src/main/java/org/elasticsearch/watcher/transport/actions/stats/WatcherStatsResponse.java b/src/main/java/org/elasticsearch/watcher/transport/actions/stats/WatcherStatsResponse.java index 21e83be202d..c3ec1e32871 100644 --- a/src/main/java/org/elasticsearch/watcher/transport/actions/stats/WatcherStatsResponse.java +++ b/src/main/java/org/elasticsearch/watcher/transport/actions/stats/WatcherStatsResponse.java @@ -19,7 +19,7 @@ public class WatcherStatsResponse extends ActionResponse { private WatcherVersion version; private WatcherBuild build; private long watchesCount; - private WatcherState watchServiceState; + private WatcherState watcherState; private long watchExecutionQueueSize; private long watchExecutionQueueMaxSize; @@ -62,12 +62,12 @@ public class WatcherStatsResponse extends ActionResponse { /** * @return The state of the watch service. */ - public WatcherState getWatchServiceState() { - return watchServiceState; + public WatcherState getWatcherState() { + return watcherState; } - void setWatchServiceState(WatcherState watcherServiceState) { - this.watchServiceState = watcherServiceState; + void setWatcherState(WatcherState watcherServiceState) { + this.watcherState = watcherServiceState; } /** @@ -98,7 +98,7 @@ public class WatcherStatsResponse extends ActionResponse { watchesCount = in.readLong(); watchExecutionQueueSize = in.readLong(); watchExecutionQueueMaxSize = in.readLong(); - watchServiceState = WatcherState.fromId(in.readByte()); + watcherState = WatcherState.fromId(in.readByte()); version = WatcherVersion.readVersion(in); build = WatcherBuild.readBuild(in); } @@ -109,7 +109,7 @@ public class WatcherStatsResponse extends ActionResponse { out.writeLong(watchesCount); out.writeLong(watchExecutionQueueSize); out.writeLong(watchExecutionQueueMaxSize); - out.writeByte(watchServiceState.getId()); + out.writeByte(watcherState.getId()); WatcherVersion.writeVersion(version, out); WatcherBuild.writeBuild(build, out); } diff --git a/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTests.java b/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTests.java index dd356294c9e..3f2886e10e0 100644 --- a/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTests.java +++ b/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTests.java @@ -185,14 +185,14 @@ public abstract class AbstractWatcherIntegrationTests extends ElasticsearchInteg private void startWatcherIfNodesExist() throws Exception { if (internalTestCluster().size() > 0) { WatcherStatsResponse response = watcherClient().prepareWatcherStats().get(); - if (response.getWatchServiceState() == WatcherState.STOPPED) { + if (response.getWatcherState() == WatcherState.STOPPED) { logger.info("[{}#{}]: starting watcher", getTestClass().getSimpleName(), getTestName()); startWatcher(); - } else if (response.getWatchServiceState() == WatcherState.STARTING) { + } else if (response.getWatcherState() == WatcherState.STARTING) { logger.info("[{}#{}]: watcher is starting, waiting for it to get in a started state", getTestClass().getSimpleName(), getTestName()); ensureWatcherStarted(false); } else { - logger.info("[{}#{}]: not starting watcher, because watcher is in state [{}]", getTestClass().getSimpleName(), getTestName(), response.getWatchServiceState()); + logger.info("[{}#{}]: not starting watcher, because watcher is in state [{}]", getTestClass().getSimpleName(), getTestName(), response.getWatcherState()); } } else { logger.info("[{}#{}]: not starting watcher, because test cluster has no nodes", getTestClass().getSimpleName(), getTestName()); @@ -403,7 +403,7 @@ public abstract class AbstractWatcherIntegrationTests extends ElasticsearchInteg @Override public void run() { if (useClient) { - assertThat(watcherClient().prepareWatcherStats().get().getWatchServiceState(), is(WatcherState.STARTED)); + assertThat(watcherClient().prepareWatcherStats().get().getWatcherState(), is(WatcherState.STARTED)); } else { assertThat(getInstanceFromMaster(WatcherService.class).state(), is(WatcherState.STARTED)); } @@ -431,7 +431,7 @@ public abstract class AbstractWatcherIntegrationTests extends ElasticsearchInteg @Override public void run() { if (useClient) { - assertThat(watcherClient().prepareWatcherStats().get().getWatchServiceState(), is(WatcherState.STOPPED)); + assertThat(watcherClient().prepareWatcherStats().get().getWatcherState(), is(WatcherState.STOPPED)); } else { assertThat(getInstanceFromMaster(WatcherService.class).state(), is(WatcherState.STOPPED)); } diff --git a/src/test/java/org/elasticsearch/watcher/test/bench/WatcherScheduleEngineBenchmark.java b/src/test/java/org/elasticsearch/watcher/test/bench/WatcherScheduleEngineBenchmark.java index ab9b380ad90..aa43c667c19 100644 --- a/src/test/java/org/elasticsearch/watcher/test/bench/WatcherScheduleEngineBenchmark.java +++ b/src/test/java/org/elasticsearch/watcher/test/bench/WatcherScheduleEngineBenchmark.java @@ -143,7 +143,7 @@ public class WatcherScheduleEngineBenchmark { Clock clock = node.injector().getInstance(Clock.class); WatcherClient watcherClient = node.injector().getInstance(WatcherClient.class); - while (watcherClient.prepareWatcherStats().get().getWatchServiceState() != WatcherState.STARTED) { + while (watcherClient.prepareWatcherStats().get().getWatcherState() != WatcherState.STARTED) { Thread.sleep(100); } long actualLoadedWatches = watcherClient.prepareWatcherStats().get().getWatchesCount(); diff --git a/src/test/java/org/elasticsearch/watcher/test/integration/BootStrapTests.java b/src/test/java/org/elasticsearch/watcher/test/integration/BootStrapTests.java index 254ef1a3cb6..62e51d1ee81 100644 --- a/src/test/java/org/elasticsearch/watcher/test/integration/BootStrapTests.java +++ b/src/test/java/org/elasticsearch/watcher/test/integration/BootStrapTests.java @@ -116,7 +116,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTests { startWatcher(); WatcherStatsResponse response = watcherClient().prepareWatcherStats().get(); - assertThat(response.getWatchServiceState(), equalTo(WatcherState.STARTED)); + assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED)); // Only the valid watch should been loaded assertThat(response.getWatchesCount(), equalTo(1l)); assertThat(watcherClient().prepareGetWatch("_id0").get().getId(), Matchers.equalTo("_id0")); @@ -204,7 +204,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTests { startWatcher(); WatcherStatsResponse response = watcherClient().prepareWatcherStats().get(); - assertThat(response.getWatchServiceState(), equalTo(WatcherState.STARTED)); + assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED)); assertThat(response.getWatchesCount(), equalTo(1l)); } @@ -266,7 +266,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTests { startWatcher(); WatcherStatsResponse response = watcherClient().prepareWatcherStats().get(); - assertThat(response.getWatchServiceState(), equalTo(WatcherState.STARTED)); + assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED)); assertThat(response.getWatchesCount(), equalTo((long) numWatches)); } @@ -275,7 +275,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTests { public void testWatchRecordLoading() throws Exception { createIndex("output"); WatcherStatsResponse response = watcherClient().prepareWatcherStats().get(); - assertThat(response.getWatchServiceState(), equalTo(WatcherState.STARTED)); + assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED)); assertThat(response.getWatchesCount(), equalTo(0L)); String watchId = "_id"; @@ -312,7 +312,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTests { // We need to wait until all the records are processed from the internal execution queue, only then we can assert // that numRecords watch records have been processed as part of starting up. WatcherStatsResponse response = watcherClient().prepareWatcherStats().get(); - assertThat(response.getWatchServiceState(), equalTo(WatcherState.STARTED)); + assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED)); assertThat(response.getExecutionQueueSize(), equalTo(0l)); // but even then since the execution of the watch record is async it may take a little bit before @@ -328,7 +328,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTests { public void testMixedWatchRecordLoading() throws Exception { createIndex("output"); WatcherStatsResponse response = watcherClient().prepareWatcherStats().get(); - assertThat(response.getWatchServiceState(), equalTo(WatcherState.STARTED)); + assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED)); assertThat(response.getWatchesCount(), equalTo(0L)); String watchId = "_id"; @@ -383,7 +383,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTests { // We need to wait until all the records are processed from the internal execution queue, only then we can assert // that numRecords watch records have been processed as part of starting up. WatcherStatsResponse response = watcherClient().prepareWatcherStats().get(); - assertThat(response.getWatchServiceState(), equalTo(WatcherState.STARTED)); + assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED)); assertThat(response.getExecutionQueueSize(), equalTo(0l)); // but even then since the execution of the watch record is async it may take a little bit before @@ -441,7 +441,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTests { startWatcher(); WatcherStatsResponse response = watcherClient().prepareWatcherStats().get(); - assertThat(response.getWatchServiceState(), equalTo(WatcherState.STARTED)); + assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED)); final long totalHistoryEntries = numberOfWatchRecordsPerIndex * numberOfWatchHistoryIndices; assertBusy(new Runnable() { diff --git a/src/test/java/org/elasticsearch/watcher/test/integration/WatchStatsTests.java b/src/test/java/org/elasticsearch/watcher/test/integration/WatchStatsTests.java index cf0776aece1..83dd44b17f7 100644 --- a/src/test/java/org/elasticsearch/watcher/test/integration/WatchStatsTests.java +++ b/src/test/java/org/elasticsearch/watcher/test/integration/WatchStatsTests.java @@ -43,7 +43,7 @@ public class WatchStatsTests extends AbstractWatcherIntegrationTests { WatcherStatsRequest watcherStatsRequest = watcherClient().prepareWatcherStats().request(); WatcherStatsResponse response = watcherClient().watcherStats(watcherStatsRequest).actionGet(); - assertThat(response.getWatchServiceState(), is(WatcherState.STARTED)); + assertThat(response.getWatcherState(), is(WatcherState.STARTED)); assertThat(response.getExecutionQueueSize(), is(0L)); assertThat(response.getWatchesCount(), is(0L)); assertThat(response.getWatchExecutionQueueMaxSize(), is(timeWarped() ? 1L : 0L)); @@ -58,7 +58,7 @@ public class WatchStatsTests extends AbstractWatcherIntegrationTests { WatcherStatsRequest watcherStatsRequest = watcherClient.prepareWatcherStats().request(); WatcherStatsResponse response = watcherClient.watcherStats(watcherStatsRequest).actionGet(); - assertThat(response.getWatchServiceState(), equalTo(WatcherState.STARTED)); + assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED)); SearchRequest searchRequest = WatcherTestUtils.newInputSearchRequest("idx").source(searchSource().query(termQuery("field", "value"))); watcherClient().preparePutWatch("_name") @@ -78,7 +78,7 @@ public class WatchStatsTests extends AbstractWatcherIntegrationTests { response = watcherClient().watcherStats(watcherStatsRequest).actionGet(); - assertThat(response.getWatchServiceState(), is(WatcherState.STARTED)); + assertThat(response.getWatcherState(), is(WatcherState.STARTED)); assertThat(response.getWatchesCount(), is(1L)); assertThat(response.getWatchExecutionQueueMaxSize(), greaterThan(0L)); }