smiklosovic commented on code in PR #3744:
URL: https://github.com/apache/cassandra/pull/3744#discussion_r1886589779
##########
src/java/org/apache/cassandra/tools/nodetool/Status.java:
##########
@@ -48,15 +60,71 @@ public class Status extends NodeToolCmd
@Option(title = "resolve_ip", name = {"-r", "--resolve-ip"}, description =
"Show node domain names instead of IPs")
private boolean resolveIp = false;
+ @Option(title = "sort",
+ name = {"-s", "--sort"},
+ description = "Sort by one of 'ip', 'host', 'load', 'owns', 'id',
'rack' or 'state'. " +
+ "Default ordering is ascending for 'ip', 'host',
'id', 'token', 'rack' and descending for 'load', 'owns', 'state'. " +
+ "Sorting by token is possible only when cluster does
not use vnodes. When using vnodes, default " +
+ "sorting is by id otherwise by token.",
+ allowedValues = {"ip", "host", "load", "owns", "id", "rack",
"state"})
+ private String sortBy = null;
+
+ @Option(title = "sort_order",
+ name = {"-o", "--order"},
+ description = "Sorting order: 'asc' for ascending, 'desc' for
descending.",
+ allowedValues = {"asc", "desc"})
+ private String sortOrder = null;
+
private boolean isTokenPerNode = true;
private Collection<String> joiningNodes, leavingNodes, movingNodes,
liveNodes, unreachableNodes;
private Map<String, String> loadMap, hostIDMap;
private EndpointSnitchInfoMBean epSnitchInfo;
+ private SortBy parseSortBy(String setSortBy, PrintStream out)
+ {
+ if (setSortBy == null)
+ return null;
+
+ try
+ {
+ return
SortBy.valueOf(LocalizeString.toLowerCaseLocalized(setSortBy));
+ }
+ catch (IllegalArgumentException ex)
+ {
+ String enabledValues =
Arrays.stream(SortBy.values()).map(SortBy::name).collect(Collectors.joining(",
"));
+ out.printf("%nError: Illegal value for -s/--sort used: '" +
setSortBy + "'. Supported values are " + enabledValues + ".%n");
+ System.exit(1);
+ return null;
+ }
+ }
+
+ private SortOrder parseSortOrder(String setSortOrder, PrintStream out)
+ {
+ if (setSortOrder == null)
+ return null;
+
+ try
+ {
+ return
SortOrder.valueOf(LocalizeString.toLowerCaseLocalized(setSortOrder));
+ }
+ catch (IllegalArgumentException ex)
+ {
+ String enabledValues =
Arrays.stream(SortOrder.values()).map(SortOrder::name).collect(Collectors.joining(",
"));
+ out.printf("%nError: Illegal value for -o/--order used: '" +
setSortOrder + "'. Supported values are " + enabledValues + ".%n");
+ System.exit(1);
+ return null;
+ }
+ }
+
@Override
public void execute(NodeProbe probe)
{
PrintStream out = probe.output().out;
+ PrintStream errOut = probe.output().err;
Review Comment:
We were wrongly sending errors to out instead of err output across this
class. This is now fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]