From 205a4e0905d68ac3bc77f21b7b8541072eea8831 Mon Sep 17 00:00:00 2001 From: wudi <676366545@qq.com> Date: Tue, 16 Jan 2024 10:28:11 +0800 Subject: [PATCH] update --- .../org/apache/doris/flink/DorisTestBase.java | 29 +++++++++++++++++++ .../flink/tools/cdc/MySQLDorisE2ECase.java | 24 --------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/flink-doris-connector/src/test/java/org/apache/doris/flink/DorisTestBase.java b/flink-doris-connector/src/test/java/org/apache/doris/flink/DorisTestBase.java index e3478da16..2612fd7e8 100644 --- a/flink-doris-connector/src/test/java/org/apache/doris/flink/DorisTestBase.java +++ b/flink-doris-connector/src/test/java/org/apache/doris/flink/DorisTestBase.java @@ -34,9 +34,14 @@ 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; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.LockSupport; import java.util.stream.Stream; @@ -124,6 +129,7 @@ protected static void initializeJdbcConnection() throws SQLException, MalformedU } while (!isBeReady(resultSet, Duration.ofSeconds(1L))); } LOG.info("Connected to Doris successfully..."); + printClusterStatus(); } private static boolean isBeReady(ResultSet rs, Duration duration) throws SQLException { @@ -135,4 +141,27 @@ private static boolean isBeReady(ResultSet rs, Duration duration) throws SQLExce } return false; } + + protected static void printClusterStatus() throws SQLException { + try (Statement statement = connection.createStatement()) { + ResultSet showFrontends = statement.executeQuery("show frontends"); + LOG.info("Frontends status: {}", convertList(showFrontends)); + ResultSet showBackends = statement.executeQuery("show backends"); + LOG.info("Backends status: {}", convertList(showBackends)); + } + } + + private static List convertList(ResultSet rs) throws SQLException { + List list = new ArrayList<>(); + ResultSetMetaData metaData = rs.getMetaData(); + int columnCount = metaData.getColumnCount(); + while (rs.next()) { + Map rowData = new HashMap<>(); + for (int i = 1; i <= columnCount; i++) { + rowData.put(metaData.getColumnName(i), rs.getObject(i)); + } + list.add(rowData); + } + return list; + } } 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 5de170d4e..242f93f59 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,7 +39,6 @@ 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; @@ -466,27 +465,4 @@ 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, showFrontends.getMetaData())); - LOG.info("Backends status: ", convertList(showBackends, showBackends.getMetaData())); - } - } - - private static List convertList(ResultSet rs, ResultSetMetaData metaData) - throws SQLException { - List list = new ArrayList<>(); - int columnCount = metaData.getColumnCount(); - while (rs.next()) { - Map rowData = new HashMap<>(); - for (int i = 1; i <= columnCount; i++) { - rowData.put(metaData.getColumnName(i), rs.getObject(i)); - } - list.add(rowData); - } - return list; - } }