sreejasahithi commented on code in PR #8409: URL: https://github.com/apache/ozone/pull/8409#discussion_r2077611631
########## hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/logs/container/utils/ContainerDatanodeDatabase.java: ########## @@ -541,5 +541,44 @@ private List<DatanodeContainerInfo> getContainerLogData(Long containerID, Connec return logEntries; } + + private void createIdxContainerlogContainerId(Connection conn) throws SQLException { + String sql = SQLDBConstants.CREATE_CONTAINER_ID_INDEX; + try (Statement stmt = conn.createStatement()) { + stmt.execute(sql); + } + } + + public void findDuplicateOpenContainer() throws SQLException { + String sql = SQLDBConstants.SELECT_DISTINCT_CONTAINER_IDS_QUERY; + + try (Connection connection = getConnection()) { + + createIdxContainerlogContainerId(connection); + + try (PreparedStatement statement = connection.prepareStatement(sql); + ResultSet resultSet = statement.executeQuery()) { + int count = 0; + + while (resultSet.next()) { + Long containerID = resultSet.getLong("container_id"); + List<DatanodeContainerInfo> logEntries = getContainerLogData(containerID, connection); + logEntries.sort(Comparator.comparing(DatanodeContainerInfo::getTimestamp)); + boolean hasIssue = checkForMultipleOpenStates(logEntries); + if (hasIssue) { + count++; + out.println("Container ID: " + containerID); Review Comment: Thanks for the suggestion! The current logic to check duplicate OPEN states is already implemented in `checkForMultipleOpenStates()`, which is also used by another command (ozone debug log container info). In order to get the count as well when we do the check, we would need to implement another method, but the logic would be mostly redundant to the existing one. So if users want more details (like how duplicate OPEN), they can use `ozone debug log container --db=<path to db> info <container id>`. That gives the complete state transition history of a particular container. -- 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