adoroszlai commented on code in PR #8415: URL: https://github.com/apache/ozone/pull/8415#discussion_r2081041976
########## hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/logs/container/utils/ContainerDatanodeDatabase.java: ########## @@ -609,5 +615,179 @@ private List<DatanodeContainerInfo> getContainerLogDataForOpenContainers(Long co return logEntries; } + + /** + * Lists container replicas with key details such as Container ID, Datanode ID, State, BCSID for over- + * or under-replicated containers. + */ + + public void listReplicatedContainers(String overOrUnder, Integer limit) throws SQLException { + String operator; + if ("OVER_REPLICATED".equalsIgnoreCase(overOrUnder)) { + operator = ">"; + } else if ("UNDER_REPLICATED".equalsIgnoreCase(overOrUnder)) { + operator = "<"; + } else { + out.println("Invalid type. Use OVER_REPLICATED or UNDER_REPLICATED."); + return; + } + + String rawQuery = SQLDBConstants.SELECT_REPLICATED_CONTAINERS; + + if (!rawQuery.contains("{operator}")) { + out.println("Query not defined correctly."); + return; + } + + String finalQuery = rawQuery.replace("{operator}", operator); + + boolean limitProvided = limit != Integer.MAX_VALUE; Review Comment: Limit is set to `MAX_VALUE` if `--all` is used. That piece of information is available in the subcommand using `ListOptions` via `isAll()`. I think we should move more of the implementation to the subcommands, to allow access to `out()`, `err()`, and command options. Only core DB functionality and utilities should be in `ContainerDatanodeDatabase`. -- 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: issues-unsubscr...@ozone.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For additional commands, e-mail: issues-h...@ozone.apache.org