From e6e27cf132d737f451ce95b49cb3802d3b48f2d6 Mon Sep 17 00:00:00 2001 From: wangbw Date: Sun, 19 Dec 2021 01:43:17 +0800 Subject: [PATCH] [Fix-7485][datasource-plugin] Fix create hive datasource using ZooKeeper way in 2.0.1 --- .../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 c57573e84d5f..1d2d4b2721f4 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 static HikariDataSource createJdbcDataSource(BaseConnectionParam properti 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 static HikariDataSource createJdbcDataSource(BaseConnectionParam properti /** * @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 b4ea165d8b63..3a3e90fba386 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 void testCreateJdbcDataSource() { 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 69bd4c74c1b1..c888fa407f0d 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 @@ protected void initClient(BaseConnectionParam baseConnectionParam, DbType dbType 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()); }