Skip to content

Commit

Permalink
[Improvement-15919][datasource] Improvement datasource get name (apac…
Browse files Browse the repository at this point in the history
  • Loading branch information
sdhzwc authored Apr 28, 2024
1 parent b29965b commit 7a55ade
Show file tree
Hide file tree
Showing 36 changed files with 95 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected Map<String, String> transformOtherParamToMap(String other) {
@Override
public String getDatasourceUniqueId(ConnectionParam connectionParam, DbType dbType) {
BaseConnectionParam baseConnectionParam = (BaseConnectionParam) connectionParam;
return MessageFormat.format("{0}@{1}@{2}@{3}", dbType.getDescp(), baseConnectionParam.getUser(),
return MessageFormat.format("{0}@{1}@{2}@{3}", dbType.getName(), baseConnectionParam.getUser(),
PasswordUtils.encodePassword(baseConnectionParam.getPassword()), baseConnectionParam.getJdbcUrl());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public static DataSourceClient getPooledDataSourceClient(DbType dbType,
String datasourceUniqueId = DataSourceUtils.getDatasourceUniqueId(baseConnectionParam, dbType);
return POOLED_DATASOURCE_CLIENT_CACHE.get(datasourceUniqueId, () -> {
Map<String, DataSourceChannel> dataSourceChannelMap = dataSourcePluginManager.getDataSourceChannelMap();
DataSourceChannel dataSourceChannel = dataSourceChannelMap.get(dbType.getDescp());
DataSourceChannel dataSourceChannel = dataSourceChannelMap.get(dbType.getName());
if (null == dataSourceChannel) {
throw new RuntimeException(String.format("datasource plugin '%s' is not found", dbType.getDescp()));
throw new RuntimeException(String.format("datasource plugin '%s' is not found", dbType.getName()));
}
return dataSourceChannel.createPooledDataSourceClient(baseConnectionParam, dbType);
});
Expand All @@ -85,9 +85,9 @@ public static Connection getPooledConnection(DbType dbType,
public static AdHocDataSourceClient getAdHocDataSourceClient(DbType dbType, ConnectionParam connectionParam) {
BaseConnectionParam baseConnectionParam = (BaseConnectionParam) connectionParam;
Map<String, DataSourceChannel> dataSourceChannelMap = dataSourcePluginManager.getDataSourceChannelMap();
DataSourceChannel dataSourceChannel = dataSourceChannelMap.get(dbType.getDescp());
DataSourceChannel dataSourceChannel = dataSourceChannelMap.get(dbType.getName());
if (null == dataSourceChannel) {
throw new RuntimeException(String.format("datasource plugin '%s' is not found", dbType.getDescp()));
throw new RuntimeException(String.format("datasource plugin '%s' is not found", dbType.getName()));
}
return dataSourceChannel.createAdHocDataSourceClient(baseConnectionParam, dbType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -32,6 +33,6 @@ public DataSourceChannel create() {

@Override
public String getName() {
return "athena";
return DbType.ATHENA.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class AzureSQLDataSourceChannelFactory implements DataSourceChannelFactor

@Override
public String getName() {
return "azuresql";
return DbType.AZURESQL.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class ClickHouseDataSourceChannelFactory implements DataSourceChannelFact

@Override
public String getName() {
return "clickhouse";
return DbType.CLICKHOUSE.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DamengDataSourceChannelFactory implements DataSourceChannelFactory

@Override
public String getName() {
return DbType.DAMENG.getDescp();
return DbType.DAMENG.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class DatabendDataSourceChannelFactory implements DataSourceChannelFactor

@Override
public String getName() {
return "databend";
return DbType.DATABEND.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void testGetJdbcUrl() {
@Test
public void testDbType() {
Assertions.assertEquals(19, DbType.DATABEND.getCode());
Assertions.assertEquals("databend", DbType.DATABEND.getDescp());
Assertions.assertEquals("databend", DbType.DATABEND.getName());
Assertions.assertEquals(DbType.DATABEND, DbType.of(19));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class DB2DataSourceChannelFactory implements DataSourceChannelFactory {

@Override
public String getName() {
return "db2";
return DbType.DB2.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public DataSourceChannel create() {

@Override
public String getName() {
return DbType.DORIS.getDescp();
return DbType.DORIS.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class HanaDataSourceChannelFactory implements DataSourceChannelFactory {

@Override
public String getName() {
return "hana";
return DbType.HANA.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class HiveDataSourceChannelFactory implements DataSourceChannelFactory {

@Override
public String getName() {
return "hive";
return DbType.HIVE.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -32,7 +33,7 @@ public DataSourceChannel create() {

@Override
public String getName() {
return "k8s";
return DbType.K8S.getName();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void checkDatasourceParam(BaseDataSourceParamDTO datasourceParam) {
@Override
public String getDatasourceUniqueId(ConnectionParam connectionParam, DbType dbType) {
K8sConnectionParam baseConnectionParam = (K8sConnectionParam) connectionParam;
return MessageFormat.format("{0}@{1}@{2}", dbType.getDescp(),
return MessageFormat.format("{0}@{1}@{2}", dbType.getName(),
PasswordUtils.encodePassword(baseConnectionParam.getKubeConfig()), baseConnectionParam.getNamespace());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class KyuubiDataSourceChannelFactory implements DataSourceChannelFactory

@Override
public String getName() {
return "kyuubi";
return DbType.KYUUBI.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void testGetJdbcUrl() {
@Test
public void testDbType() {
Assertions.assertEquals(18, DbType.KYUUBI.getCode());
Assertions.assertEquals("kyuubi", DbType.KYUUBI.getDescp());
Assertions.assertEquals("kyuubi", DbType.KYUUBI.getName());
Assertions.assertEquals(DbType.KYUUBI, DbType.of(18));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class MySQLDataSourceChannelFactory implements DataSourceChannelFactory {

@Override
public String getName() {
return "mysql";
return DbType.MYSQL.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class OceanBaseDataSourceChannelFactory implements DataSourceChannelFacto

@Override
public String getName() {
return "oceanbase";
return DbType.OCEANBASE.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class OracleDataSourceChannelFactory implements DataSourceChannelFactory

@Override
public String getName() {
return "oracle";
return DbType.ORACLE.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class PostgreSQLDataSourceChannelFactory implements DataSourceChannelFact

@Override
public String getName() {
return "postgresql";
return DbType.POSTGRESQL.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class PrestoDataSourceChannelFactory implements DataSourceChannelFactory

@Override
public String getName() {
return "presto";
return DbType.PRESTO.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -32,6 +33,6 @@ public DataSourceChannel create() {

@Override
public String getName() {
return "redshift";
return DbType.REDSHIFT.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -32,7 +33,7 @@ public DataSourceChannel create() {

@Override
public String getName() {
return "sagemaker";
return DbType.SAGEMAKER.getName();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void checkDatasourceParam(BaseDataSourceParamDTO datasourceParamDTO) {
@Override
public String getDatasourceUniqueId(ConnectionParam connectionParam, DbType dbType) {
SagemakerConnectionParam baseConnectionParam = (SagemakerConnectionParam) connectionParam;
return MessageFormat.format("{0}@{1}@{2}@{3}", dbType.getDescp(),
return MessageFormat.format("{0}@{1}@{2}@{3}", dbType.getName(),
PasswordUtils.encodePassword(baseConnectionParam.getUserName()),
PasswordUtils.encodePassword(baseConnectionParam.getPassword()),
PasswordUtils.encodePassword(baseConnectionParam.getAwsRegion()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class SnowflakeDataSourceChannelFactory implements DataSourceChannelFacto

@Override
public String getName() {
return "snowflake";
return DbType.SNOWFLAKE.getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void testCreateDatasourceParamDTO() {
@Test
public void testDbType() {
Assertions.assertEquals(20, DbType.SNOWFLAKE.getCode());
Assertions.assertEquals("snowflake", DbType.SNOWFLAKE.getDescp());
Assertions.assertEquals("snowflake", DbType.SNOWFLAKE.getName());
Assertions.assertEquals(DbType.of(20), DbType.SNOWFLAKE);
Assertions.assertEquals(DbType.ofName("SNOWFLAKE"), DbType.SNOWFLAKE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.enums.DbType;

import com.google.auto.service.AutoService;

Expand All @@ -27,7 +28,7 @@ public class SparkDataSourceChannelFactory implements DataSourceChannelFactory {

@Override
public String getName() {
return "spark";
return DbType.SPARK.getName();
}

@Override
Expand Down
Loading

0 comments on commit 7a55ade

Please sign in to comment.