adapt _cat/nodes to node.client removal

_cat/nodes used to return `c` for client node or `d` for data node as part of the node.role column. This commit changes it to return `m` for master eligible, `d` for data and/or `i` for ingest. A node with no explicit roles will be a coordinating only node and marked with `-`. A node can obviously have multiple roles. The master column has been adapted to return only whether a node is the current master (`*`) or not (`-`).
This commit is contained in:
javanna 2016-03-04 11:21:46 +01:00 committed by Luca Cavanna
parent 4224371d8b
commit f786e9866c
3 changed files with 24 additions and 17 deletions

View File

@ -44,11 +44,11 @@ import org.elasticsearch.index.engine.SegmentsStats;
import org.elasticsearch.index.fielddata.FieldDataStats; import org.elasticsearch.index.fielddata.FieldDataStats;
import org.elasticsearch.index.flush.FlushStats; import org.elasticsearch.index.flush.FlushStats;
import org.elasticsearch.index.get.GetStats; import org.elasticsearch.index.get.GetStats;
import org.elasticsearch.index.shard.IndexingStats;
import org.elasticsearch.index.merge.MergeStats; import org.elasticsearch.index.merge.MergeStats;
import org.elasticsearch.index.percolator.PercolateStats; import org.elasticsearch.index.percolator.PercolateStats;
import org.elasticsearch.index.refresh.RefreshStats; import org.elasticsearch.index.refresh.RefreshStats;
import org.elasticsearch.index.search.stats.SearchStats; import org.elasticsearch.index.search.stats.SearchStats;
import org.elasticsearch.index.shard.IndexingStats;
import org.elasticsearch.index.suggest.stats.SuggestStats; import org.elasticsearch.index.suggest.stats.SuggestStats;
import org.elasticsearch.indices.NodeIndicesStats; import org.elasticsearch.indices.NodeIndicesStats;
import org.elasticsearch.monitor.fs.FsInfo; import org.elasticsearch.monitor.fs.FsInfo;
@ -67,7 +67,7 @@ import org.elasticsearch.script.ScriptStats;
import org.elasticsearch.search.suggest.completion.CompletionStats; import org.elasticsearch.search.suggest.completion.CompletionStats;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.stream.Collectors;
import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.GET;
@ -142,8 +142,8 @@ public class RestNodesAction extends AbstractCatAction {
table.addCell("load_5m", "alias:l;text-align:right;desc:5m load avg"); table.addCell("load_5m", "alias:l;text-align:right;desc:5m load avg");
table.addCell("load_15m", "alias:l;text-align:right;desc:15m load avg"); table.addCell("load_15m", "alias:l;text-align:right;desc:15m load avg");
table.addCell("uptime", "default:false;alias:u;text-align:right;desc:node uptime"); table.addCell("uptime", "default:false;alias:u;text-align:right;desc:node uptime");
table.addCell("node.role", "alias:r,role,dc,nodeRole;desc:d:data node, c:client node"); table.addCell("node.role", "alias:r,role,nodeRole;desc:m:master eligible node, d:data node, i:ingest node, -:coordinating node only");
table.addCell("master", "alias:m;desc:m:master-eligible, *:current master"); table.addCell("master", "alias:m;desc:*:current master");
table.addCell("name", "alias:n;desc:node name"); table.addCell("name", "alias:n;desc:node name");
table.addCell("completion.size", "alias:cs,completionSize;default:false;text-align:right;desc:size of completion"); table.addCell("completion.size", "alias:cs,completionSize;default:false;text-align:right;desc:size of completion");
@ -284,8 +284,15 @@ public class RestNodesAction extends AbstractCatAction {
table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[1] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[1])); table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[1] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[1]));
table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[2] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[2])); table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[2] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[2]));
table.addCell(jvmStats == null ? null : jvmStats.getUptime()); table.addCell(jvmStats == null ? null : jvmStats.getUptime());
table.addCell(node.clientNode() ? "c" : node.dataNode() ? "d" : "-");
table.addCell(masterId == null ? "x" : masterId.equals(node.id()) ? "*" : node.masterNode() ? "m" : "-"); String roles;
if (node.getRoles().size() == 0) {
roles = "-";
} else {
roles = node.getRoles().stream().map(DiscoveryNode.Role::getAbbreviation).collect(Collectors.joining());
}
table.addCell(roles);
table.addCell(masterId == null ? "x" : masterId.equals(node.id()) ? "*" : "-");
table.addCell(node.name()); table.addCell(node.name());
CompletionStats completionStats = indicesStats == null ? null : stats.getIndices().getCompletion(); CompletionStats completionStats = indicesStats == null ? null : stats.getIndices().getCompletion();

View File

@ -41,10 +41,10 @@ it?
[source,sh] [source,sh]
-------------------------------------------------- --------------------------------------------------
uptime data/client master name uptime node.role master name
3.5h d m Boneyard 3.5h di - Boneyard
3.5h d * Athena 3.5h md * Athena
3.5h d m Zarek 3.5h i - Zarek
-------------------------------------------------- --------------------------------------------------
[float] [float]
@ -105,9 +105,9 @@ descriptors |1024
|`load` |`l` |No |Most recent load average |0.22 |`load` |`l` |No |Most recent load average |0.22
|`cpu` | |No |Recent system CPU usage as percent |12 |`cpu` | |No |Recent system CPU usage as percent |12
|`uptime` |`u` |No |Node uptime |17.3m |`uptime` |`u` |No |Node uptime |17.3m
|`node.role` |`r`, `role`, `dc`, `nodeRole` |Yes |Data node (d); Client |`node.role` |`r`, `role`, `dc`, `nodeRole` |Yes |Master eligible node (m);
node (c) |d Data node (d); Ingest node (i); Coordinating node only (-) |mdi
|`master` |`m` |Yes |Current master (*); master eligible (m) |m |`master` |`m` |Yes |Current master (*); |*
|`name` |`n` |Yes |Node name |Venom |`name` |`n` |Yes |Node name |Venom
|`completion.size` |`cs`, `completionSize` |No |Size of completion |0b |`completion.size` |`cs`, `completionSize` |No |Size of completion |0b
|`fielddata.memory_size` |`fm`, `fielddataMemory` |No |Used fielddata |`fielddata.memory_size` |`fm`, `fielddataMemory` |No |Used fielddata

View File

@ -6,8 +6,8 @@
- match: - match:
$body: | $body: |
/ #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ [-dc] \s+ [-*mx] \s+ (\S+\s?)+ \n)+ $/ ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dmi]{1,3}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/
- do: - do:
cat.nodes: cat.nodes:
@ -15,8 +15,8 @@
- match: - match:
$body: | $body: |
/^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n
((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ [-dc] \s+ [-*mx] \s+ (\S+\s?)+ \n)+ $/ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dmi]{1,3}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/
- do: - do:
cat.nodes: cat.nodes: