Stats api: fix serialization issue
Renamed pending watches left overs to queued watches Original commit: elastic/x-pack-elasticsearch@c2bcdf547c
This commit is contained in:
parent
0890001470
commit
47247dc46a
|
@ -14,8 +14,6 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.watcher.actions.ActionWrapper;
|
import org.elasticsearch.watcher.actions.ActionWrapper;
|
||||||
import org.elasticsearch.watcher.actions.ExecutableActions;
|
import org.elasticsearch.watcher.actions.ExecutableActions;
|
||||||
import org.elasticsearch.watcher.execution.ExecutionPhase;
|
|
||||||
import org.elasticsearch.watcher.execution.ExecutionService;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -88,7 +86,7 @@ public class WatchExecutionSnapshot implements Streamable, ToXContent {
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
String declaringClass = in.readString();
|
String declaringClass = in.readString();
|
||||||
String methodName = in.readString();
|
String methodName = in.readString();
|
||||||
String fileName = in.readString();
|
String fileName = in.readOptionalString();
|
||||||
int lineNumber = in.readInt();
|
int lineNumber = in.readInt();
|
||||||
executionStackTrace[i] = new StackTraceElement(declaringClass, methodName, fileName, lineNumber);
|
executionStackTrace[i] = new StackTraceElement(declaringClass, methodName, fileName, lineNumber);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +103,7 @@ public class WatchExecutionSnapshot implements Streamable, ToXContent {
|
||||||
for (StackTraceElement element : executionStackTrace) {
|
for (StackTraceElement element : executionStackTrace) {
|
||||||
out.writeString(element.getClassName());
|
out.writeString(element.getClassName());
|
||||||
out.writeString(element.getMethodName());
|
out.writeString(element.getMethodName());
|
||||||
out.writeString(element.getFileName());
|
out.writeOptionalString(element.getFileName());
|
||||||
out.writeInt(element.getLineNumber());
|
out.writeInt(element.getLineNumber());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,10 @@ public class RestWatcherStatsAction extends WatcherRestHandler {
|
||||||
WatcherStatsRequest request = new WatcherStatsRequest();
|
WatcherStatsRequest request = new WatcherStatsRequest();
|
||||||
if (metrics.contains("_all")) {
|
if (metrics.contains("_all")) {
|
||||||
request.includeCurrentWatches(true);
|
request.includeCurrentWatches(true);
|
||||||
request.includePendingWatches(true);
|
request.includeQueuedWatches(true);
|
||||||
} else {
|
} else {
|
||||||
request.includeCurrentWatches(metrics.contains("queued_watches"));
|
request.includeCurrentWatches(metrics.contains("queued_watches"));
|
||||||
request.includePendingWatches(metrics.contains("pending_watches"));
|
request.includeQueuedWatches(metrics.contains("pending_watches"));
|
||||||
}
|
}
|
||||||
|
|
||||||
client.watcherStats(request, new RestBuilderListener<WatcherStatsResponse>(restChannel) {
|
client.watcherStats(request, new RestBuilderListener<WatcherStatsResponse>(restChannel) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class TransportWatcherStatsAction extends WatcherTransportAction<WatcherS
|
||||||
if (request.includeCurrentWatches()) {
|
if (request.includeCurrentWatches()) {
|
||||||
statsResponse.setSnapshots(executionService.currentExecutions());
|
statsResponse.setSnapshots(executionService.currentExecutions());
|
||||||
}
|
}
|
||||||
if (request.includePendingWatches()) {
|
if (request.includeQueuedWatches()) {
|
||||||
statsResponse.setQueuedWatches(executionService.queuedWatches());
|
statsResponse.setQueuedWatches(executionService.queuedWatches());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.io.IOException;
|
||||||
public class WatcherStatsRequest extends MasterNodeOperationRequest<WatcherStatsRequest> {
|
public class WatcherStatsRequest extends MasterNodeOperationRequest<WatcherStatsRequest> {
|
||||||
|
|
||||||
private boolean includeCurrentWatches;
|
private boolean includeCurrentWatches;
|
||||||
private boolean includePendingWatches;
|
private boolean includeQueuedWatches;
|
||||||
|
|
||||||
public WatcherStatsRequest() {
|
public WatcherStatsRequest() {
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,12 @@ public class WatcherStatsRequest extends MasterNodeOperationRequest<WatcherStats
|
||||||
this.includeCurrentWatches = currentWatches;
|
this.includeCurrentWatches = currentWatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean includePendingWatches() {
|
public boolean includeQueuedWatches() {
|
||||||
return includePendingWatches;
|
return includeQueuedWatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void includePendingWatches(boolean includePendingWatches) {
|
public void includeQueuedWatches(boolean includeQueuedWatches) {
|
||||||
this.includePendingWatches = includePendingWatches;
|
this.includeQueuedWatches = includeQueuedWatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,14 +48,14 @@ public class WatcherStatsRequest extends MasterNodeOperationRequest<WatcherStats
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
super.readFrom(in);
|
super.readFrom(in);
|
||||||
includeCurrentWatches = in.readBoolean();
|
includeCurrentWatches = in.readBoolean();
|
||||||
includePendingWatches = in.readBoolean();
|
includeQueuedWatches = in.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
super.writeTo(out);
|
super.writeTo(out);
|
||||||
out.writeBoolean(includeCurrentWatches);
|
out.writeBoolean(includeCurrentWatches);
|
||||||
out.writeBoolean(includeCurrentWatches);
|
out.writeBoolean(includeQueuedWatches);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,8 +23,8 @@ public class WatcherStatsRequestBuilder extends MasterNodeOperationRequestBuilde
|
||||||
request().includeCurrentWatches(includeCurrentWatches);
|
request().includeCurrentWatches(includeCurrentWatches);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public WatcherStatsRequestBuilder setIncludePendingWatches(boolean includePendingWatches) {
|
public WatcherStatsRequestBuilder setIncludeQueuedWatches(boolean includeQueuedWatches) {
|
||||||
request().includePendingWatches(includePendingWatches);
|
request().includeQueuedWatches(includeQueuedWatches);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.*;
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@LuceneTestCase.Slow
|
@LuceneTestCase.Slow
|
||||||
@ElasticsearchIntegrationTest.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1)
|
@ElasticsearchIntegrationTest.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 2)
|
||||||
public class SlowWatchStatsTests extends AbstractWatcherIntegrationTests {
|
public class SlowWatchStatsTests extends AbstractWatcherIntegrationTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,7 +88,7 @@ public class SlowWatchStatsTests extends AbstractWatcherIntegrationTests {
|
||||||
assertBusy(new Runnable() {
|
assertBusy(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
WatcherStatsResponse response = watcherClient().prepareWatcherStats().setIncludePendingWatches(true).get();
|
WatcherStatsResponse response = watcherClient().prepareWatcherStats().setIncludeQueuedWatches(true).get();
|
||||||
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
|
||||||
assertThat(response.getWatchesCount(), equalTo(5l));
|
assertThat(response.getWatchesCount(), equalTo(5l));
|
||||||
assertThat(response.getSnapshots(), nullValue());
|
assertThat(response.getSnapshots(), nullValue());
|
||||||
|
|
Loading…
Reference in New Issue