Skip to content

Add node id to _cat apis #10246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions rest-api-spec/test/cat.plugins/10_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"Help":
- do:
cat.plugins:
help: true

- match:
$body: |
/^ id .+ \n
name .+ \n
component .+ \n
version .+ \n
type .+ \n
url .+ \n
description .+ \n
$/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!!!

1 change: 1 addition & 0 deletions rest-api-spec/test/cat.segments/10_basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
shard .+ \n
prirep .+ \n
ip .+ \n
id .+ \n
segment .+ \n
generation .+ \n
docs.count .+ \n
Expand Down
69 changes: 69 additions & 0 deletions rest-api-spec/test/cat.shards/10_basic.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,73 @@
---
"Help":
- do:
cat.shards:
help: true

- match:
$body: |
/^ index .+ \n
shard .+ \n
prirep .+ \n
state .+ \n
docs .+ \n
store .+ \n
ip .+ \n
id .+ \n
node .+ \n
completion.size .+ \n
fielddata.memory_size .+ \n
fielddata.evictions .+ \n
filter_cache.memory_size .+ \n
filter_cache.evictions .+ \n
flush.total .+ \n
flush.total_time .+ \n
get.current .+ \n
get.time .+ \n
get.total .+ \n
get.exists_time .+ \n
get.exists_total .+ \n
get.missing_time .+ \n
get.missing_total .+ \n
id_cache.memory_size .+ \n
indexing.delete_current .+ \n
indexing.delete_time .+ \n
indexing.delete_total .+ \n
indexing.index_current .+ \n
indexing.index_time .+ \n
indexing.index_total .+ \n
merges.current .+ \n
merges.current_docs .+ \n
merges.current_size .+ \n
merges.total .+ \n
merges.total_docs .+ \n
merges.total_size .+ \n
merges.total_time .+ \n
percolate.current .+ \n
percolate.memory_size .+ \n
percolate.queries .+ \n
percolate.time .+ \n
percolate.total .+ \n
refresh.total .+ \n
refresh.time .+ \n
search.fetch_current .+ \n
search.fetch_time .+ \n
search.fetch_total .+ \n
search.open_contexts .+ \n
search.query_current .+ \n
search.query_time .+ \n
search.query_total .+ \n
segments.count .+ \n
segments.memory .+ \n
segments.index_writer_memory .+ \n
segments.index_writer_max_memory .+ \n
segments.version_map_memory .+ \n
segments.fixed_bitset_memory .+ \n
warmer.current .+ \n
warmer.total .+ \n
warmer.total_time .+ \n
$/
---
"Test cat shards output":

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public RestResponse buildResponse(final NodesInfoResponse nodesInfoResponse) thr
Table getTableWithHeader(final RestRequest request) {
Table table = new Table();
table.startHeaders();
table.addCell("id", "alias:i;default:false;desc:unique node id");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we want to drop the i alias here and be consistent with the other cat apis? id seems short enough already no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good :)

table.addCell("name", "alias:n;desc:node name");
table.addCell("component", "alias:c;desc:component");
table.addCell("version", "alias:v;desc:component version");
Expand All @@ -96,6 +97,7 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR

for (PluginInfo pluginInfo : info.getPlugins().getInfos()) {
table.startRow();
table.addCell(node.id());
table.addCell(node.name());
table.addCell(pluginInfo.getName());
table.addCell(pluginInfo.getVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Table getTableWithHeader(RestRequest request) {
table.addCell("shard", "default:true;alias:s,sh;desc:shard name");
table.addCell("prirep", "alias:p,pr,primaryOrReplica;default:true;desc:primary or replica");
table.addCell("ip", "default:true;desc:ip of node where it lives");
table.addCell("id", "default:false;desc:unique id of node where it lives");
table.addCell("segment", "default:true;alias:seg;desc:segment name");
table.addCell("generation", "default:true;alias:g,gen;text-align:right;desc:segment generation");
table.addCell("docs.count", "default:true;alias:dc,docsCount;text-align:right;desc:number of docs in segment");
Expand Down Expand Up @@ -123,6 +124,7 @@ private Table buildTable(final RestRequest request, ClusterStateResponse state,
table.addCell(shardSegment.getShardId());
table.addCell(shardSegment.getShardRouting().primary() ? "p" : "r");
table.addCell(nodes.get(shardSegment.getShardRouting().currentNodeId()).getHostAddress());
table.addCell(shardSegment.getShardRouting().currentNodeId());
table.addCell(segment.getName());
table.addCell(segment.getGeneration());
table.addCell(segment.getNumDocs());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Table getTableWithHeader(final RestRequest request) {
.addCell("docs", "alias:d,dc;text-align:right;desc:number of docs in shard")
.addCell("store", "alias:sto;text-align:right;desc:store size of shard (how much disk it uses)")
.addCell("ip", "default:true;desc:ip of node where it lives")
.addCell("id", "default:false;desc:unique id of node where it lives")
.addCell("node", "default:true;alias:n;desc:name of node where it lives");

table.addCell("completion.size", "alias:cs,completionSize;default:false;text-align:right;desc:size of completion");
Expand Down Expand Up @@ -186,21 +187,27 @@ private Table buildTable(RestRequest request, ClusterStateResponse state, Indice
table.addCell(shardStats == null ? null : shardStats.getStore().getSize());
if (shard.assignedToNode()) {
String ip = state.getState().nodes().get(shard.currentNodeId()).getHostAddress();
String nodeId = shard.currentNodeId();
StringBuilder name = new StringBuilder();
name.append(state.getState().nodes().get(shard.currentNodeId()).name());
if (shard.relocating()) {
String reloIp = state.getState().nodes().get(shard.relocatingNodeId()).getHostAddress();
String reloNme = state.getState().nodes().get(shard.relocatingNodeId()).name();
String reloNodeId = shard.relocatingNodeId();
name.append(" -> ");
name.append(reloIp);
name.append(" ");
name.append(reloNodeId);
name.append(" ");
name.append(reloNme);
}
table.addCell(ip);
table.addCell(nodeId);
table.addCell(name);
} else {
table.addCell(null);
table.addCell(null);
table.addCell(null);
}

table.addCell(shardStats == null ? null : shardStats.getCompletion().getSize());
Expand Down