aryangupta1998 commented on code in PR #8409: URL: https://github.com/apache/ozone/pull/8409#discussion_r2077631752
########## 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: I understand, but I feel displaying the count along with the container would be helpful, like, `Container ID: 12377064 Count = 5` We already have a counter(count), we can use it to track the count, no need to implement a separate method! -- 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