OpenSearch
OpenSearch copied to clipboard
[Feature Request] Optimize the api _cat/nodes
Is your feature request related to a problem? Please describe
Now the method is as follows:
return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<>(channel) {
......
nodesInfoRequest.timeout(request.param("timeout"));
client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
......
// wait all the nodes response
nodesStatsRequest.timeout(request.param("timeout"));
client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
......
}
}
}
It seems has two problems:
cluster().nodesInfo()andcluster().nodesStats()use separate timeout, in that case, iftimeoutfrom the client is30s, without addingcluster().state(), the overall time can be60s, which is 2x times that the expect.- Only all nodes return the a NodeInfoResponse in
cluster().nodesInfo()can the nextcluster().nodesStats()be called. It's normal to have a slow node(such as fullGc) in large clusters, the api will become unresponsive, it means that if some of nodes are blocked incluster().nodesInfo(), the overrall api will be blocked.
Describe the solution you'd like
- If
timeoutis30sin_cat/nodes, the overall time should be around 30s. - If some of nodes are blocked, it doesn't affect the rest nodes to get metrics. Each node separately call
cluster().nodesInfo()andcluster().nodesStats().
The code can be like this:
long time1 = threadPool.relativeTimeInMillis();
return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<>(channel) {
......
long time2 = threadPool.relativeTimeInMillis();
nodesInfoRequest.timeout(timeout - (time2-time1)));
for (String nodeId : nodeIds) {
nodesInfoRequest.nodesIds(nodeId);
client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
......
long time3 = threadPool.relativeTimeInMillis();
nodesStatsRequest.timeout(timeout - (time3-time1)));
nodesStatsRequest.nodesIds(nodeId);
client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
......
}
}
}
channel.sendResponse(RestTable.buildResponse(buildTable(fullId, request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel));
}
Related component
Cluster Manager
Describe alternatives you've considered
No response
Additional context
No response