From cef3169cdf0e5d50d0e04affde63164bd850b68f Mon Sep 17 00:00:00 2001 From: wudi <676366545@qq.com> Date: Tue, 16 Jan 2024 10:10:29 +0800 Subject: [PATCH] add cluster status print log --- .../flink/tools/cdc/MySQLDorisE2ECase.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/flink-doris-connector/src/test/java/org/apache/doris/flink/tools/cdc/MySQLDorisE2ECase.java b/flink-doris-connector/src/test/java/org/apache/doris/flink/tools/cdc/MySQLDorisE2ECase.java index 2f5568e94..30889aa3b 100644 --- a/flink-doris-connector/src/test/java/org/apache/doris/flink/tools/cdc/MySQLDorisE2ECase.java +++ b/flink-doris-connector/src/test/java/org/apache/doris/flink/tools/cdc/MySQLDorisE2ECase.java @@ -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; @@ -94,6 +95,7 @@ public static void stopMySQLContainers() { @Test public void testMySQL2Doris() throws Exception { + printClusterStatus(); initializeMySQLTable(); JobClient jobClient = submitJob(); // wait 2 times checkpoint @@ -173,6 +175,7 @@ public void testMySQL2Doris() throws Exception { @Test public void testAutoAddTable() throws Exception { + printClusterStatus(); initializeMySQLTable(); initializeDorisTable(); JobClient jobClient = submitJob(); @@ -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 convertList(ResultSet rs) throws SQLException { + List list = new ArrayList<>(); + ResultSetMetaData md = rs.getMetaData(); + int columnCount = md.getColumnCount(); + while (rs.next()) { + Map rowData = new HashMap<>(); + for (int i = 1; i <= columnCount; i++) { + rowData.put(md.getColumnName(i), rs.getObject(i)); + } + list.add(rowData); + } + return list; + } }