fixed Java API docs
- wrote an intro where we tell how to get the watcher jar and we tall about the `WatcherClient` - cleaned up the code snippets - removed a reference to the `Watch.Parser` - Also renamed `WatcherStatsResponse#getWatchServiceState` to `watcherStatsResponse.getWatcherState` Original commit: elastic/x-pack-elasticsearch@814329cba7
This commit is contained in:
parent
5ecf1dbdcd
commit
1a9db6140a
|
@ -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")
|
||||
|
|
|
@ -58,7 +58,7 @@ public class TransportWatcherStatsAction extends WatcherTransportAction<WatcherS
|
|||
@Override
|
||||
protected void masterOperation(WatcherStatsRequest request, ClusterState state, ActionListener<WatcherStatsResponse> 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());
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue