Expose nodes operation timeout in REST API

Currently it's not possible to specify a timeout for nodes operations (such as node info, node stats, cluster stats and hot threads) via REST-based APIs.
This commit is contained in:
Igor Motov 2015-10-06 16:46:27 -04:00
parent 42718936d9
commit a358f34276
8 changed files with 21 additions and 1 deletions

View File

@ -58,6 +58,7 @@ public class RestNodesHotThreadsAction extends BaseRestHandler {
nodesHotThreadsRequest.type(request.param("type", nodesHotThreadsRequest.type()));
nodesHotThreadsRequest.interval(TimeValue.parseTimeValue(request.param("interval"), nodesHotThreadsRequest.interval(), "interval"));
nodesHotThreadsRequest.snapshots(request.paramAsInt("snapshots", nodesHotThreadsRequest.snapshots()));
nodesHotThreadsRequest.timeout(request.param("timeout"));
client.admin().cluster().nodesHotThreads(nodesHotThreadsRequest, new RestResponseListener<NodesHotThreadsResponse>(channel) {
@Override
public RestResponse buildResponse(NodesHotThreadsResponse response) throws Exception {

View File

@ -87,6 +87,7 @@ public class RestNodesInfoAction extends BaseRestHandler {
}
final NodesInfoRequest nodesInfoRequest = new NodesInfoRequest(nodeIds);
nodesInfoRequest.timeout(request.param("timeout"));
// shortcut, dont do checks if only all is specified
if (metrics.size() == 1 && metrics.contains("_all")) {
nodesInfoRequest.all();

View File

@ -60,6 +60,7 @@ public class RestNodesStatsAction extends BaseRestHandler {
Set<String> metrics = Strings.splitStringByCommaToSet(request.param("metric", "_all"));
NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(nodesIds);
nodesStatsRequest.timeout(request.param("timeout"));
if (metrics.size() == 1 && metrics.contains("_all")) {
nodesStatsRequest.all();

View File

@ -43,6 +43,7 @@ public class RestClusterStatsAction extends BaseRestHandler {
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
ClusterStatsRequest clusterStatsRequest = new ClusterStatsRequest().nodesIds(request.paramAsStringArray("nodeId", null));
clusterStatsRequest.timeout(request.param("timeout"));
client.admin().cluster().clusterStats(clusterStatsRequest, new RestToXContentListener<ClusterStatsResponse>(channel));
}
}

View File

@ -20,6 +20,10 @@
"type": "boolean",
"description": "Whether to return time and byte values in human-readable format.",
"default": false
},
"timeout": {
"type" : "time",
"description" : "Explicit operation timeout"
}
}
},

View File

@ -24,7 +24,7 @@
"type" : "number",
"description" : "Specify the number of threads to provide information for (default: 3)"
},
"ignore_idle_threads": {
"ignore_idle_threads": {
"type" : "boolean",
"description" : "Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true)"
},
@ -32,6 +32,10 @@
"type" : "enum",
"options" : ["cpu", "wait", "block"],
"description" : "The type to sample (default: cpu)"
},
"timeout": {
"type" : "time",
"description" : "Explicit operation timeout"
}
}
},

View File

@ -25,6 +25,10 @@
"type": "boolean",
"description": "Whether to return time and byte values in human-readable format.",
"default": false
},
"timeout": {
"type" : "time",
"description" : "Explicit operation timeout"
}
}
},

View File

@ -59,6 +59,10 @@
"types" : {
"type" : "list",
"description" : "A comma-separated list of document types for the `indexing` index metric"
},
"timeout": {
"type" : "time",
"description" : "Explicit operation timeout"
}
}
},