Skip to content

Commit

Permalink
add cluster status print log
Browse files Browse the repository at this point in the history
  • Loading branch information
JNSimba committed Jan 16, 2024
1 parent 7ce9390 commit cef3169
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Duration;
Expand Down Expand Up @@ -94,6 +95,7 @@ public static void stopMySQLContainers() {

@Test
public void testMySQL2Doris() throws Exception {
printClusterStatus();
initializeMySQLTable();
JobClient jobClient = submitJob();
// wait 2 times checkpoint
Expand Down Expand Up @@ -173,6 +175,7 @@ public void testMySQL2Doris() throws Exception {

@Test
public void testAutoAddTable() throws Exception {
printClusterStatus();
initializeMySQLTable();
initializeDorisTable();
JobClient jobClient = submitJob();
Expand Down Expand Up @@ -463,4 +466,27 @@ public static void waitUntilCondition(
throw new TimeoutException(errorMsg);
}
}

private void printClusterStatus() throws SQLException {
try (Statement statement = connection.createStatement();
ResultSet showFrontends = statement.executeQuery("show frontends");
ResultSet showBackends = statement.executeQuery("show backends")) {
LOG.info("Frontends status: ", convertList(showFrontends));
LOG.info("Backends status: ", convertList(showBackends));
}
}

private static List<Map> convertList(ResultSet rs) throws SQLException {
List<Map> list = new ArrayList<>();
ResultSetMetaData md = rs.getMetaData();
int columnCount = md.getColumnCount();
while (rs.next()) {
Map<String, Object> rowData = new HashMap<>();
for (int i = 1; i <= columnCount; i++) {
rowData.put(md.getColumnName(i), rs.getObject(i));
}
list.add(rowData);
}
return list;
}
}

0 comments on commit cef3169

Please sign in to comment.