From a00b1503e380d5cc490822291fb06f36124083e0 Mon Sep 17 00:00:00 2001 From: WangJPLeo Date: Wed, 23 Nov 2022 13:46:40 +0800 Subject: [PATCH] upgrade to 3.0.0 fix --- dolphinscheduler-tools/pom.xml | 6 +++++ .../datasource/DolphinSchedulerManager.java | 2 ++ .../datasource/UpgradeDolphinScheduler.java | 1 - .../tools/datasource/dao/UpgradeDao.java | 9 +++++++ .../src/main/resources/application.yaml | 25 +++---------------- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/dolphinscheduler-tools/pom.xml b/dolphinscheduler-tools/pom.xml index 7b07d279c7..fd87b0906c 100644 --- a/dolphinscheduler-tools/pom.xml +++ b/dolphinscheduler-tools/pom.xml @@ -33,6 +33,12 @@ org.apache.dolphinscheduler dolphinscheduler-dao + + + mysql + mysql-connector-java + compile + diff --git a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/DolphinSchedulerManager.java b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/DolphinSchedulerManager.java index a588fabcfb..ff6c957c8a 100644 --- a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/DolphinSchedulerManager.java +++ b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/DolphinSchedulerManager.java @@ -50,6 +50,7 @@ public class DolphinSchedulerManager { private DbType getCurrentDbType(DataSource dataSource) throws Exception { try (Connection conn = dataSource.getConnection()) { String name = conn.getMetaData().getDatabaseProductName().toUpperCase(); + logger.info("Current db type: {}", name); return DbType.valueOf(name); } } @@ -101,6 +102,7 @@ public class DolphinSchedulerManager { // The target version of the upgrade String schemaVersion = ""; String currentVersion = version; + logger.info("Begin upgrading handle schemaList"); for (String schemaDir : schemaList) { schemaVersion = schemaDir.split("_")[0]; if (SchemaUtils.isAGreatVersion(schemaVersion, version)) { diff --git a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/UpgradeDolphinScheduler.java b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/UpgradeDolphinScheduler.java index 22e1338431..c636c4c243 100644 --- a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/UpgradeDolphinScheduler.java +++ b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/UpgradeDolphinScheduler.java @@ -32,7 +32,6 @@ public class UpgradeDolphinScheduler { } @Component - @Profile("upgrade") static class UpgradeRunner implements CommandLineRunner { private static final Logger logger = LoggerFactory.getLogger(UpgradeRunner.class); diff --git a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/dao/UpgradeDao.java b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/dao/UpgradeDao.java index 8d08dd5e43..39f155741c 100644 --- a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/dao/UpgradeDao.java +++ b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/dao/UpgradeDao.java @@ -291,6 +291,10 @@ public abstract class UpgradeDao { String schemaVersion = schemaDir.split("_")[0]; Resource sqlFilePath = new ClassPathResource(String.format("sql/upgrade/%s/%s/dolphinscheduler_dml.sql", schemaDir, getDbType().name().toLowerCase())); logger.info("sqlSQLFilePath: {}", sqlFilePath); + if (!sqlFilePath.exists()) { + logger.info("sqlSQLFilePath: {} not exist", sqlFilePath); + return; + } Connection conn = null; PreparedStatement pstmt = null; try { @@ -353,6 +357,10 @@ public abstract class UpgradeDao { */ private void upgradeDolphinSchedulerDDL(String schemaDir, String scriptFile) { Resource sqlFilePath = new ClassPathResource(String.format("sql/upgrade/%s/%s/%s", schemaDir, getDbType().name().toLowerCase(), scriptFile)); + if (!sqlFilePath.exists()) { + logger.info("sqlFilePath {} not exist", sqlFilePath); + return; + } Connection conn = null; PreparedStatement pstmt = null; try { @@ -363,6 +371,7 @@ public abstract class UpgradeDao { // Execute the dolphinscheduler ddl.sql for the upgrade ScriptRunner scriptRunner = new ScriptRunner(conn, true, true); Reader sqlReader = new InputStreamReader(sqlFilePath.getInputStream()); + logger.info("Start ddl file: {}-{}", schemaDir, scriptFile); scriptRunner.runScript(sqlReader); } catch (FileNotFoundException e) { diff --git a/dolphinscheduler-tools/src/main/resources/application.yaml b/dolphinscheduler-tools/src/main/resources/application.yaml index 84a89097d8..14f25c41bb 100644 --- a/dolphinscheduler-tools/src/main/resources/application.yaml +++ b/dolphinscheduler-tools/src/main/resources/application.yaml @@ -18,10 +18,10 @@ spring: main: banner-mode: off datasource: - driver-class-name: org.postgresql.Driver - url: jdbc:postgresql://127.0.0.1:5432/dolphinscheduler + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/whalescheduler?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false username: root - password: root + password: root@123 hikari: connection-test-query: select 1 minimum-idle: 5 @@ -33,22 +33,3 @@ spring: idle-timeout: 600000 leak-detection-threshold: 0 initialization-fail-timeout: 1 - -# Override by profile - ---- -spring: - config: - activate: - on-profile: mysql - datasource: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://127.0.0.1:3306/dolphinscheduler?useUnicode=true&characterEncoding=UTF-8 - ---- -spring: - config: - activate: - on-profile: postgresql - datasource: - driver-class-name: org.postgresql.Driver