From 85beb50f03457d9687e9f1761becd4f37ec41766 Mon Sep 17 00:00:00 2001 From: wangbowen <419444275@qq.com> Date: Tue, 21 Dec 2021 14:37:33 +0800 Subject: [PATCH] [Fix-7485][datasource-plugin] Fix create hive datasource using ZooKeeper way in 2.0.1 (#7489) --- .../datasource/api/provider/JDBCDataSourceProvider.java | 6 +++--- .../datasource/api/provider/JDBCDataSourceProviderTest.java | 4 ++-- .../plugin/datasource/hive/HiveDataSourceClient.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/provider/JDBCDataSourceProvider.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/provider/JDBCDataSourceProvider.java index c57573e84d..1d2d4b2721 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/provider/JDBCDataSourceProvider.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/provider/JDBCDataSourceProvider.java @@ -48,7 +48,7 @@ public class JDBCDataSourceProvider { loaderJdbcDriver(classLoader, properties, dbType); dataSource.setDriverClassName(properties.getDriverClassName()); - dataSource.setJdbcUrl(properties.getJdbcUrl()); + dataSource.setJdbcUrl(DataSourceUtils.getJdbcUrl(dbType, properties)); dataSource.setUsername(properties.getUser()); dataSource.setPassword(PasswordUtils.decodePassword(properties.getPassword())); @@ -67,13 +67,13 @@ public class JDBCDataSourceProvider { /** * @return One Session Jdbc DataSource */ - public static HikariDataSource createOneSessionJdbcDataSource(BaseConnectionParam properties) { + public static HikariDataSource createOneSessionJdbcDataSource(BaseConnectionParam properties, DbType dbType) { logger.info("Creating OneSession HikariDataSource pool for maxActive:{}", PropertyUtils.getInt(Constants.SPRING_DATASOURCE_MAX_ACTIVE, 50)); HikariDataSource dataSource = new HikariDataSource(); dataSource.setDriverClassName(properties.getDriverClassName()); - dataSource.setJdbcUrl(properties.getJdbcUrl()); + dataSource.setJdbcUrl(DataSourceUtils.getJdbcUrl(dbType, properties)); dataSource.setUsername(properties.getUser()); dataSource.setPassword(PasswordUtils.decodePassword(properties.getPassword())); diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/provider/JDBCDataSourceProviderTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/provider/JDBCDataSourceProviderTest.java index b4ea165d8b..3a3e90fba3 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/provider/JDBCDataSourceProviderTest.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/provider/JDBCDataSourceProviderTest.java @@ -46,8 +46,8 @@ public class JDBCDataSourceProviderTest { public void testCreateOneSessionJdbcDataSource() { PowerMockito.mockStatic(JDBCDataSourceProvider.class); HikariDataSource dataSource = PowerMockito.mock(HikariDataSource.class); - PowerMockito.when(JDBCDataSourceProvider.createOneSessionJdbcDataSource(Mockito.any())).thenReturn(dataSource); - Assert.assertNotNull(JDBCDataSourceProvider.createOneSessionJdbcDataSource(new MySQLConnectionParam())); + PowerMockito.when(JDBCDataSourceProvider.createOneSessionJdbcDataSource(Mockito.any(), Mockito.any())).thenReturn(dataSource); + Assert.assertNotNull(JDBCDataSourceProvider.createOneSessionJdbcDataSource(new MySQLConnectionParam(), DbType.MYSQL)); } } diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java index 69bd4c74c1..c888fa407f 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java @@ -79,7 +79,7 @@ public class HiveDataSourceClient extends CommonDataSourceClient { logger.info("Create ugi success."); super.initClient(baseConnectionParam, dbType); - this.oneSessionDataSource = JDBCDataSourceProvider.createOneSessionJdbcDataSource(baseConnectionParam); + this.oneSessionDataSource = JDBCDataSourceProvider.createOneSessionJdbcDataSource(baseConnectionParam, dbType); logger.info("Init {} success.", getClass().getName()); }