diff --git a/docs/configs/docsdev.js b/docs/configs/docsdev.js index 08155a006b23..57682f02483c 100644 --- a/docs/configs/docsdev.js +++ b/docs/configs/docsdev.js @@ -270,6 +270,10 @@ export default { title: 'Remote Shell', link: '/en-us/docs/dev/user_doc/guide/task/remoteshell.html', }, + { + title: 'DolphinDB', + link: '/en-us/docs/dev/user_doc/guide/datasource/dolphindb.html', + }, ], }, { @@ -965,6 +969,10 @@ export default { title: 'Remote Shell', link: '/zh-cn/docs/dev/user_doc/guide/task/remoteshell.html', }, + { + title: 'DolphinDB', + link: '/zh-cn/docs/dev/user_doc/guide/datasource/dolphindb.html', + }, ], }, { diff --git a/docs/docs/en/guide/datasource/dolphindb.md b/docs/docs/en/guide/datasource/dolphindb.md new file mode 100644 index 000000000000..64b885c01b2e --- /dev/null +++ b/docs/docs/en/guide/datasource/dolphindb.md @@ -0,0 +1,20 @@ +# DolphinDB + +![dolphindb](../../../../img/new_ui/dev/datasource/dolphindb-en.png) + +## Datasource Parameters + +| **Parameter** | **Description** | +|----------------------------|--------------------------------------------------------------| +| Datasource | Select DOLPHINDB. | +| Datasource Name | Enter the name of the DataSource. | +| Description | Enter a description of the DataSource. | +| IP/Host Name | Enter the DolphinDB service IP. | +| Port | Enter the DolphinDB service port. | +| Username | Set the username for DolphinDB connection. | +| Password | Set the password for DolphinDB connection. | +| Jdbc connection parameters | Parameter settings for DolphinDB connection, in JSON format. | + +## Native Supported + +Yes, could use this datasource by default. diff --git a/docs/docs/zh/guide/datasource/dolphindb.md b/docs/docs/zh/guide/datasource/dolphindb.md new file mode 100644 index 000000000000..04fcf8dcddb8 --- /dev/null +++ b/docs/docs/zh/guide/datasource/dolphindb.md @@ -0,0 +1,18 @@ +# DOLPHINDB 数据源 + +![dolphindb](../../../../img/new_ui/dev/datasource/dolphindb-zh.png) + +| **参数名称** | **参数描述** | +|-----------|----------------------------------| +| 数据源 | 选择 DOLPHINDB | +| 数据源名称 | 输入数据源的名称 | +| 描述 | 输入数据源的描述 | +| IP 主机名 | 输入连接 DOLPHINDB 的 IP | +| 端口 | 输入连接 DOLPHINDB 的端口 | +| 用户名 | 设置连接 DOLPHINDB 的用户名 | +| 密码 | 设置连接 DOLPHINDB 的密码 | +| JDBC 连接参数 | 用于 DOLPHINDB 连接的参数设置,以 JSON 形式填写 | + +## 是否原生支持 + +是,数据源不需要任务附加操作即可使用。 diff --git a/docs/img/new_ui/dev/datasource/dolphindb-en.png b/docs/img/new_ui/dev/datasource/dolphindb-en.png new file mode 100644 index 000000000000..0a59a0342762 Binary files /dev/null and b/docs/img/new_ui/dev/datasource/dolphindb-en.png differ diff --git a/docs/img/new_ui/dev/datasource/dolphindb-zh.png b/docs/img/new_ui/dev/datasource/dolphindb-zh.png new file mode 100644 index 000000000000..83b344845336 Binary files /dev/null and b/docs/img/new_ui/dev/datasource/dolphindb-zh.png differ diff --git a/dolphinscheduler-bom/pom.xml b/dolphinscheduler-bom/pom.xml index 0635239f8ce2..2618e137088a 100644 --- a/dolphinscheduler-bom/pom.xml +++ b/dolphinscheduler-bom/pom.xml @@ -57,6 +57,7 @@ 9.1.6 2.2.220 8.0.33 + 3.00.0.1 12.0.4-0 21.5.0.0 8.1.2.79 @@ -360,6 +361,11 @@ jackson-core ${jackson.version} + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson.version} + @@ -405,6 +411,12 @@ ${dameng-jdbc.version} + + com.dolphindb + jdbc + ${dolphindb-jdbc.version} + + com.vertica.jdbc vertica-jdbc diff --git a/dolphinscheduler-common/pom.xml b/dolphinscheduler-common/pom.xml index 6c83c580ae25..cb4a2aea96e5 100644 --- a/dolphinscheduler-common/pom.xml +++ b/dolphinscheduler-common/pom.xml @@ -74,6 +74,12 @@ com.fasterxml.jackson.core jackson-databind + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + org.apache.commons commons-collections4 diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/constants/DataSourceConstants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/constants/DataSourceConstants.java index 11347942bde4..138ed3dac6bf 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/constants/DataSourceConstants.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/constants/DataSourceConstants.java @@ -43,6 +43,7 @@ public class DataSourceConstants { public static final String NET_SNOWFLAKE_JDBC_DRIVER = "net.snowflake.client.jdbc.SnowflakeDriver"; public static final String COM_VERTICA_JDBC_DRIVER = "com.vertica.jdbc.Driver"; public static final String COM_HANA_DB_JDBC_DRIVER = "com.sap.db.jdbc.Driver"; + public static final String COM_DOLPHINDB_JDBC_DRIVER = "com.dolphindb.jdbc.Driver"; /** * validation Query @@ -66,6 +67,7 @@ public class DataSourceConstants { public static final String VERTICA_VALIDATION_QUERY = "select 1"; public static final String HANA_VALIDATION_QUERY = "select 1 from DUMMY"; + public static final String DOLPHINDB_VALIDATION_QUERY = "select 1"; /** * jdbc url @@ -91,6 +93,7 @@ public class DataSourceConstants { public static final String JDBC_SNOWFLAKE = "jdbc:snowflake://"; public static final String JDBC_VERTICA = "jdbc:vertica://"; public static final String JDBC_HANA = "jdbc:sap://"; + public static final String JDBC_DOLPHINDB = "jdbc:dolphindb://"; /** * database type diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java index bfc3af2c58ef..2191783b0cb8 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java @@ -60,6 +60,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import com.fasterxml.jackson.databind.type.CollectionType; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.google.common.base.Strings; /** @@ -81,6 +82,7 @@ public final class JSONUtils { .addModule(new SimpleModule() .addSerializer(LocalDateTime.class, new LocalDateTimeSerializer()) .addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer())) + .addModule(new JavaTimeModule()) .defaultTimeZone(TimeZone.getDefault()) .defaultDateFormat(new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS)) .build(); diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-all/pom.xml b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-all/pom.xml index effe3c9abb05..eed1a8ed45f8 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-all/pom.xml +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-all/pom.xml @@ -158,5 +158,10 @@ dolphinscheduler-datasource-hana ${project.version} + + org.apache.dolphinscheduler + dolphinscheduler-datasource-dolphindb + ${project.version} + diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/pom.xml b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/pom.xml new file mode 100644 index 000000000000..063e8166f8f5 --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/pom.xml @@ -0,0 +1,51 @@ + + + + 4.0.0 + + org.apache.dolphinscheduler + dolphinscheduler-datasource-plugin + dev-SNAPSHOT + + + dolphinscheduler-datasource-dolphindb + jar + ${project.artifactId} + + + + org.apache.dolphinscheduler + dolphinscheduler-spi + provided + + + + org.apache.dolphinscheduler + dolphinscheduler-datasource-api + ${project.version} + + + + com.dolphindb + jdbc + + + + + diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBAdHocDataSourceClient.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBAdHocDataSourceClient.java new file mode 100644 index 000000000000..c3b57936f6d8 --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBAdHocDataSourceClient.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb; + +import org.apache.dolphinscheduler.plugin.datasource.api.client.BaseAdHocDataSourceClient; +import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; +import org.apache.dolphinscheduler.spi.enums.DbType; + +public class DolphinDBAdHocDataSourceClient extends BaseAdHocDataSourceClient { + + public DolphinDBAdHocDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) { + super(baseConnectionParam, dbType); + } +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannel.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannel.java new file mode 100644 index 000000000000..900ffdbc459a --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannel.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb; + +import org.apache.dolphinscheduler.spi.datasource.AdHocDataSourceClient; +import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; +import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel; +import org.apache.dolphinscheduler.spi.datasource.PooledDataSourceClient; +import org.apache.dolphinscheduler.spi.enums.DbType; + +public class DolphinDBDataSourceChannel implements DataSourceChannel { + + @Override + public AdHocDataSourceClient createAdHocDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) { + return new DolphinDBAdHocDataSourceClient(baseConnectionParam, dbType); + } + + @Override + public PooledDataSourceClient createPooledDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) { + return new DolphinDBPooledDataSourceClient(baseConnectionParam, dbType); + } +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannelFactory.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannelFactory.java new file mode 100644 index 000000000000..8c020890f7bb --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannelFactory.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb; + +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; + +@AutoService(DataSourceChannelFactory.class) +public class DolphinDBDataSourceChannelFactory implements DataSourceChannelFactory { + + @Override + public String getName() { + return DbType.DOLPHINDB.getName(); + } + + @Override + public DataSourceChannel create() { + return new DolphinDBDataSourceChannel(); + } +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBPooledDataSourceClient.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBPooledDataSourceClient.java new file mode 100644 index 000000000000..10d0002972d0 --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBPooledDataSourceClient.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb; + +import org.apache.dolphinscheduler.plugin.datasource.api.client.BasePooledDataSourceClient; +import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; +import org.apache.dolphinscheduler.spi.enums.DbType; + +public class DolphinDBPooledDataSourceClient extends BasePooledDataSourceClient { + + public DolphinDBPooledDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) { + super(baseConnectionParam, dbType); + } +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBConnectionParam.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBConnectionParam.java new file mode 100644 index 000000000000..888f62e57aeb --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBConnectionParam.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb.param; + +import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; + +public class DolphinDBConnectionParam extends BaseConnectionParam { + + @Override + public String toString() { + return "DolphinDBConnectionParam{" + + "user='" + user + '\'' + + ", password='" + password + '\'' + + ", address='" + address + '\'' + + ", jdbcUrl='" + jdbcUrl + '\'' + + ", driverLocation='" + driverLocation + '\'' + + ", driverClassName='" + driverClassName + '\'' + + ", validationQuery='" + validationQuery + '\'' + + ", other='" + other + '\'' + + '}'; + } +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBDataSourceParamDTO.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBDataSourceParamDTO.java new file mode 100644 index 000000000000..359e23fc2525 --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBDataSourceParamDTO.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb.param; + +import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; +import org.apache.dolphinscheduler.spi.enums.DbType; + +public class DolphinDBDataSourceParamDTO extends BaseDataSourceParamDTO { + + @Override + public String toString() { + return "DolphinDBDataSourceParamDTO{" + + "name='" + name + '\'' + + ", note='" + note + '\'' + + ", host='" + host + '\'' + + ", port=" + port + + ", userName='" + userName + '\'' + + ", password='" + password + '\'' + + ", other='" + other + '\'' + + '}'; + } + + @Override + public DbType getType() { + return DbType.DOLPHINDB; + } +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBDataSourceProcessor.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBDataSourceProcessor.java new file mode 100644 index 000000000000..ba6582f5c84e --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/main/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBDataSourceProcessor.java @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb.param; + +import org.apache.dolphinscheduler.common.constants.Constants; +import org.apache.dolphinscheduler.common.constants.DataSourceConstants; +import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.datasource.api.datasource.AbstractDataSourceProcessor; +import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; +import org.apache.dolphinscheduler.plugin.datasource.api.datasource.DataSourceProcessor; +import org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils; +import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; +import org.apache.dolphinscheduler.spi.enums.DbType; + +import org.apache.commons.collections4.MapUtils; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.google.auto.service.AutoService; + +@AutoService(DataSourceProcessor.class) +public class DolphinDBDataSourceProcessor extends AbstractDataSourceProcessor { + + @Override + public void checkDatasourceParam(BaseDataSourceParamDTO baseDataSourceParamDTO) { + if (!baseDataSourceParamDTO.getType().equals(DbType.REDSHIFT)) { + // due to redshift use not regular hosts + checkHost(baseDataSourceParamDTO.getHost()); + } + checkOther(baseDataSourceParamDTO.getOther()); + } + + @Override + public BaseDataSourceParamDTO castDatasourceParamDTO(String paramJson) { + return JSONUtils.parseObject(paramJson, DolphinDBDataSourceParamDTO.class); + } + + @Override + public BaseDataSourceParamDTO createDatasourceParamDTO(String connectionJson) { + DolphinDBConnectionParam connectionParams = (DolphinDBConnectionParam) createConnectionParams(connectionJson); + DolphinDBDataSourceParamDTO dataSourceParamDTO = new DolphinDBDataSourceParamDTO(); + + dataSourceParamDTO.setUserName(connectionParams.getUser()); + dataSourceParamDTO.setDatabase(connectionParams.getDatabase()); + dataSourceParamDTO.setOther(connectionParams.getOther()); + + String[] hostSeperator = connectionParams.getAddress().split(Constants.DOUBLE_SLASH); + String[] hostPortArray = hostSeperator[hostSeperator.length - 1].split(Constants.COMMA); + dataSourceParamDTO.setPort(Integer.parseInt(hostPortArray[0].split(Constants.COLON)[1])); + dataSourceParamDTO.setHost(hostPortArray[0].split(Constants.COLON)[0]); + + return dataSourceParamDTO; + } + + @Override + public ConnectionParam createConnectionParams(BaseDataSourceParamDTO datasourceParam) { + DolphinDBDataSourceParamDTO dolphinDBParam = (DolphinDBDataSourceParamDTO) datasourceParam; + String address = String.format("%s%s:%s", DataSourceConstants.JDBC_DOLPHINDB, dolphinDBParam.getHost(), + dolphinDBParam.getPort()); + String jdbcUrl = String.format("%s", address); + + DolphinDBConnectionParam dolphinDBConnectionParam = new DolphinDBConnectionParam(); + dolphinDBConnectionParam.setJdbcUrl(jdbcUrl); + dolphinDBConnectionParam.setDatabase(dolphinDBParam.getDatabase()); + dolphinDBConnectionParam.setAddress(address); + dolphinDBConnectionParam.setUser(dolphinDBParam.getUserName()); + dolphinDBConnectionParam.setPassword(PasswordUtils.encodePassword(dolphinDBParam.getPassword())); + dolphinDBConnectionParam.setDriverClassName(getDatasourceDriver()); + dolphinDBConnectionParam.setValidationQuery(getValidationQuery()); + dolphinDBConnectionParam.setOther(dolphinDBParam.getOther()); + + return dolphinDBConnectionParam; + } + + @Override + public ConnectionParam createConnectionParams(String connectionJson) { + return JSONUtils.parseObject(connectionJson, DolphinDBConnectionParam.class); + } + + @Override + public String getDatasourceDriver() { + return DataSourceConstants.COM_DOLPHINDB_JDBC_DRIVER; + } + + @Override + public String getValidationQuery() { + return DataSourceConstants.DOLPHINDB_VALIDATION_QUERY; + } + + @Override + public String getJdbcUrl(ConnectionParam connectionParam) { + DolphinDBConnectionParam dolphinDBConnectionParam = (DolphinDBConnectionParam) connectionParam; + if (MapUtils.isNotEmpty(dolphinDBConnectionParam.getOther())) { + return String.format("%s?%s", dolphinDBConnectionParam.getJdbcUrl(), + transformOther(dolphinDBConnectionParam.getOther())); + } + return dolphinDBConnectionParam.getJdbcUrl(); + } + + @Override + public Connection getConnection(ConnectionParam connectionParam) throws ClassNotFoundException, SQLException { + DolphinDBConnectionParam dolphinDBConnectionParam = (DolphinDBConnectionParam) connectionParam; + Class.forName(getDatasourceDriver()); + return DriverManager.getConnection(getJdbcUrl(connectionParam), + dolphinDBConnectionParam.getUser(), + PasswordUtils.decodePassword(dolphinDBConnectionParam.getPassword())); + } + + @Override + public DbType getDbType() { + return DbType.DOLPHINDB; + } + + @Override + public DataSourceProcessor create() { + return new DolphinDBDataSourceProcessor(); + } + + private String transformOther(Map otherMap) { + if (MapUtils.isEmpty(otherMap)) { + return null; + } + + List list = new ArrayList<>(otherMap.size()); + otherMap.forEach((key, value) -> list.add(String.format("%s=%s", key, value))); + return String.join("&", list); + } +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannelFactoryTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannelFactoryTest.java new file mode 100644 index 000000000000..f1b012e0709b --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannelFactoryTest.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb; + +import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class DolphinDBDataSourceChannelFactoryTest { + + @Test + public void testCreate() { + DolphinDBDataSourceChannelFactory factory = new DolphinDBDataSourceChannelFactory(); + DataSourceChannel channel = factory.create(); + Assertions.assertNotNull(channel); + } +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannelTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannelTest.java new file mode 100644 index 000000000000..ce8248521787 --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/DolphinDBDataSourceChannelTest.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb; + +import org.apache.dolphinscheduler.plugin.datasource.dolphindb.param.DolphinDBConnectionParam; +import org.apache.dolphinscheduler.spi.enums.DbType; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class DolphinDBDataSourceChannelTest { + + @Test + public void testCreateDataSourceClient() { + DolphinDBDataSourceChannel sourceChannel = Mockito.mock(DolphinDBDataSourceChannel.class); + DolphinDBPooledDataSourceClient dataSourceClient = Mockito.mock(DolphinDBPooledDataSourceClient.class); + Mockito.when(sourceChannel.createPooledDataSourceClient(Mockito.any(), Mockito.any())) + .thenReturn(dataSourceClient); + Assertions.assertNotNull( + sourceChannel.createPooledDataSourceClient(new DolphinDBConnectionParam(), DbType.DOLPHINDB)); + } +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBDataSourceProcessorTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBDataSourceProcessorTest.java new file mode 100644 index 000000000000..b59cbaa5fe0f --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/param/DolphinDBDataSourceProcessorTest.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb.param; + +import org.apache.dolphinscheduler.common.constants.DataSourceConstants; +import org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils; +import org.apache.dolphinscheduler.spi.enums.DbType; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class DolphinDBDataSourceProcessorTest { + + private DolphinDBDataSourceProcessor processor = new DolphinDBDataSourceProcessor(); + + @Test + public void testCreateConnectionParams() { + Map props = new HashMap<>(); + props.put("serverTimezone", "utc"); + DolphinDBDataSourceParamDTO dolphinDBDataSourceParamDTO = new DolphinDBDataSourceParamDTO(); + dolphinDBDataSourceParamDTO.setUserName("admin"); + dolphinDBDataSourceParamDTO.setPassword("123456"); + dolphinDBDataSourceParamDTO.setHost("localhost"); + dolphinDBDataSourceParamDTO.setPort(8848); + dolphinDBDataSourceParamDTO.setOther(props); + try (MockedStatic mockedStaticPasswordUtils = Mockito.mockStatic(PasswordUtils.class)) { + mockedStaticPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test"); + DolphinDBConnectionParam connectionParams = (DolphinDBConnectionParam) processor + .createConnectionParams(dolphinDBDataSourceParamDTO); + Assertions.assertEquals("jdbc:dolphindb://localhost:8848", connectionParams.getAddress()); + Assertions.assertEquals("jdbc:dolphindb://localhost:8848", connectionParams.getJdbcUrl()); + } + } + + @Test + public void testCreateConnectionParams2() { + String connectionJson = + "{\"user\":\"admin\",\"password\":\"123456\",\"address\":\"jdbc:dolphindb://localhost:8848\"" + + ",\"jdbcUrl\":\"jdbc:dolphindb://localhost:8848/default\"}"; + DolphinDBConnectionParam connectionParams = (DolphinDBConnectionParam) processor + .createConnectionParams(connectionJson); + Assertions.assertNotNull(connectionJson); + Assertions.assertEquals("admin", connectionParams.getUser()); + } + + @Test + public void testGetDatasourceDriver() { + Assertions.assertEquals(DataSourceConstants.COM_DOLPHINDB_JDBC_DRIVER, + processor.getDatasourceDriver()); + } + + @Test + public void testGetJdbcUrl() { + DolphinDBConnectionParam param = new DolphinDBConnectionParam(); + param.setJdbcUrl("jdbc:dolphindb://localhost:8848"); + Assertions.assertEquals( + "jdbc:dolphindb://localhost:8848", + processor.getJdbcUrl(param)); + } + + @Test + public void testGetDbType() { + Assertions.assertEquals(DbType.DOLPHINDB, processor.getDbType()); + } + + @Test + public void testGetValidationQuery() { + Assertions.assertEquals(DataSourceConstants.DOLPHINDB_VALIDATION_QUERY, + processor.getValidationQuery()); + } + + @Test + public void testGetDatasourceUniqueId() { + DolphinDBConnectionParam param = new DolphinDBConnectionParam(); + param.setJdbcUrl("jdbc:dolphindb://localhost:8848/"); + param.setUser("admin"); + param.setPassword("123456"); + try (MockedStatic mockedPasswordUtils = Mockito.mockStatic(PasswordUtils.class)) { + mockedPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("123456"); + Assertions.assertEquals("dolphindb@admin@123456@jdbc:dolphindb://localhost:8848/", + processor.getDatasourceUniqueId(param, DbType.DOLPHINDB)); + } + } +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/provider/JDBCDataSourceProviderTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/provider/JDBCDataSourceProviderTest.java new file mode 100644 index 000000000000..6f019a9770bd --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/provider/JDBCDataSourceProviderTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb.provider; + +import org.apache.dolphinscheduler.plugin.datasource.api.provider.JDBCDataSourceProvider; +import org.apache.dolphinscheduler.plugin.datasource.dolphindb.param.DolphinDBConnectionParam; +import org.apache.dolphinscheduler.spi.enums.DbType; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.zaxxer.hikari.HikariDataSource; + +@ExtendWith(MockitoExtension.class) +public class JDBCDataSourceProviderTest { + + @Test + public void testCreateOneSessionJdbcDataSource() { + try ( + MockedStatic mockedJDBCDataSourceProvider = + Mockito.mockStatic(JDBCDataSourceProvider.class)) { + HikariDataSource dataSource = Mockito.mock(HikariDataSource.class); + mockedJDBCDataSourceProvider + .when(() -> JDBCDataSourceProvider.createOneSessionJdbcDataSource(Mockito.any(), Mockito.any())) + .thenReturn(dataSource); + Assertions.assertNotNull( + JDBCDataSourceProvider.createOneSessionJdbcDataSource(new DolphinDBConnectionParam(), + DbType.DOLPHINDB)); + } + } + +} diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/utils/DataSourceUtilsTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/utils/DataSourceUtilsTest.java new file mode 100644 index 000000000000..02b78f279ab0 --- /dev/null +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-dolphindb/src/test/java/org/apache/dolphinscheduler/plugin/datasource/dolphindb/utils/DataSourceUtilsTest.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.datasource.dolphindb.utils; + +import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.common.utils.PropertyUtils; +import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; +import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils; +import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; +import org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils; +import org.apache.dolphinscheduler.plugin.datasource.dolphindb.param.DolphinDBConnectionParam; +import org.apache.dolphinscheduler.plugin.datasource.dolphindb.param.DolphinDBDataSourceParamDTO; +import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; +import org.apache.dolphinscheduler.spi.enums.DbType; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class DataSourceUtilsTest { + + @Test + public void testCheckDatasourceParam() { + DolphinDBDataSourceParamDTO paramDTO = new DolphinDBDataSourceParamDTO(); + paramDTO.setHost("localhost"); + Map other = new HashMap<>(); + other.put("serverTimezone", "Asia/Shanghai"); + other.put("queryTimeout", "-1"); + other.put("characterEncoding", "utf8"); + paramDTO.setOther(other); + DataSourceUtils.checkDatasourceParam(paramDTO); + Assertions.assertTrue(true); + } + + @Test + public void testBuildConnectionParams() { + DolphinDBDataSourceParamDTO paramDTO = new DolphinDBDataSourceParamDTO(); + paramDTO.setHost("localhost"); + paramDTO.setUserName("admin"); + paramDTO.setPort(8848); + paramDTO.setPassword("123456"); + + try ( + MockedStatic mockedStaticPasswordUtils = Mockito.mockStatic(PasswordUtils.class); + MockedStatic mockedStaticCommonUtils = Mockito.mockStatic(CommonUtils.class)) { + mockedStaticPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())) + .thenReturn("123456"); + mockedStaticCommonUtils.when(CommonUtils::getKerberosStartupState).thenReturn(false); + ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(paramDTO); + Assertions.assertNotNull(connectionParam); + } + } + + @Test + public void testBuildConnectionParams2() { + DolphinDBDataSourceParamDTO paramDTO = new DolphinDBDataSourceParamDTO(); + paramDTO.setHost("localhost"); + paramDTO.setUserName("root"); + paramDTO.setPort(5433); + paramDTO.setPassword("123456"); + ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(DbType.DOLPHINDB, + JSONUtils.toJsonString(paramDTO)); + Assertions.assertNotNull(connectionParam); + } + + @Test + public void testGetConnection() throws ExecutionException, SQLException { + try ( + MockedStatic mockedStaticPropertyUtils = Mockito.mockStatic(PropertyUtils.class); + MockedStatic mockedStaticDataSourceClientProvider = + Mockito.mockStatic(DataSourceClientProvider.class)) { + mockedStaticPropertyUtils.when(() -> PropertyUtils.getLong("kerberos.expire.time", 24L)).thenReturn(24L); + + Connection connection = Mockito.mock(Connection.class); + Mockito.when(DataSourceClientProvider.getAdHocConnection(Mockito.any(), Mockito.any())) + .thenReturn(connection); + + DolphinDBConnectionParam connectionParam = new DolphinDBConnectionParam(); + connectionParam.setUser("admin"); + connectionParam.setPassword("123456"); + connection = DataSourceClientProvider.getAdHocConnection(DbType.DOLPHINDB, connectionParam); + + Assertions.assertNotNull(connection); + } + + } + + @Test + public void testGetJdbcUrl() { + DolphinDBConnectionParam connectionParam = new DolphinDBConnectionParam(); + connectionParam.setJdbcUrl("jdbc:dolphindb://localhost:8848"); + String jdbcUrl = DataSourceUtils.getJdbcUrl(DbType.DOLPHINDB, connectionParam); + Assertions.assertEquals("jdbc:dolphindb://localhost:8848", jdbcUrl); + } + + @Test + public void testBuildDatasourceParamDTO() { + DolphinDBConnectionParam connectionParam = new DolphinDBConnectionParam(); + connectionParam.setJdbcUrl("jdbc:dolphindb://localhost:8848"); + connectionParam.setAddress("jdbc:dolphindb://localhost:8848"); + connectionParam.setUser("admin"); + connectionParam.setPassword("123456"); + + Assertions.assertNotNull( + DataSourceUtils.buildDatasourceParamDTO(DbType.DOLPHINDB, JSONUtils.toJsonString(connectionParam))); + + } + + @Test + public void testGetDatasourceProcessor() { + Assertions.assertNotNull(DataSourceUtils.getDatasourceProcessor(DbType.DOLPHINDB)); + } + + @Test + public void testGetDatasourceProcessorError() { + Assertions.assertThrows(Exception.class, () -> { + DataSourceUtils.getDatasourceProcessor(null); + }); + } +} diff --git a/dolphinscheduler-datasource-plugin/pom.xml b/dolphinscheduler-datasource-plugin/pom.xml index c30a6b42586b..345143d33c4f 100644 --- a/dolphinscheduler-datasource-plugin/pom.xml +++ b/dolphinscheduler-datasource-plugin/pom.xml @@ -56,6 +56,7 @@ dolphinscheduler-datasource-sagemaker dolphinscheduler-datasource-k8s dolphinscheduler-datasource-hana + dolphinscheduler-datasource-dolphindb diff --git a/dolphinscheduler-dist/release-docs/LICENSE b/dolphinscheduler-dist/release-docs/LICENSE index 1fbd3e6e521b..ec04ffae1cf9 100644 --- a/dolphinscheduler-dist/release-docs/LICENSE +++ b/dolphinscheduler-dist/release-docs/LICENSE @@ -813,3 +813,8 @@ JDOM licenses Vertica Client Driver License ======================================== vertica-jdbc 12.0.4-0: https://mvnrepository.com/artifact/com.vertica.jdbc/vertica-jdbc/12.0.4-0, Vertica Client Driver License + +======================================== +DolphinDB Client Driver License +======================================== + dolphin-jdbc 3.00.0.1: https://mvnrepository.com/artifact/com.dolphindb/jdbc/3.00.0.1, DolphinDB Client Driver License diff --git a/dolphinscheduler-dist/release-docs/NOTICE b/dolphinscheduler-dist/release-docs/NOTICE index 3228e3ff2c2e..cfffedb68322 100644 --- a/dolphinscheduler-dist/release-docs/NOTICE +++ b/dolphinscheduler-dist/release-docs/NOTICE @@ -2113,3 +2113,25 @@ BY SELECTING “ACCEPT AND CONTINUE” BELOW, YOU ARE EXPRESSLY ACKNOWLEDGING AN [ ] I consent and accept the terms and conditions stated in this Agreement. ========================================================================= + +========================================================================= + +DolphinDB Client Driver License NOTICE + +========================================================================= + +Copyright 2016-2024 DolphinDB, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +========================================================================= \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-dolphindb-jdbc.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-dolphindb-jdbc.txt new file mode 100644 index 000000000000..3020791b5051 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-dolphindb-jdbc.txt @@ -0,0 +1,13 @@ +Copyright 2016-2024 DolphinDB, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/DbType.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/DbType.java index 882b170e1190..c356ce2afba8 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/DbType.java +++ b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/DbType.java @@ -55,7 +55,8 @@ public enum DbType { ZEPPELIN(24, "zeppelin", "zeppelin"), SAGEMAKER(25, "sagemaker", "sagemaker"), - K8S(26, "k8s", "k8s"); + K8S(26, "k8s", "k8s"), + DOLPHINDB(27, "dolphindb", "dolphindb"); private static final Map DB_TYPE_MAP = Arrays.stream(DbType.values()).collect(toMap(DbType::getCode, Functions.identity())); @EnumValue diff --git a/dolphinscheduler-ui/src/service/modules/data-source/types.ts b/dolphinscheduler-ui/src/service/modules/data-source/types.ts index 444f5293ddbb..cb1552b47348 100644 --- a/dolphinscheduler-ui/src/service/modules/data-source/types.ts +++ b/dolphinscheduler-ui/src/service/modules/data-source/types.ts @@ -42,6 +42,7 @@ type IDataBase = | 'ZEPPELIN' | 'SAGEMAKER' | 'K8S' + | 'DOLPHINDB' type IDataBaseLabel = | 'MYSQL' @@ -65,6 +66,7 @@ type IDataBaseLabel = | 'ZEPPELIN' | 'SAGEMAKER' | 'K8S' + | 'DOLPHINDB' interface IDataSource { id?: number diff --git a/dolphinscheduler-ui/src/views/datasource/list/use-form.ts b/dolphinscheduler-ui/src/views/datasource/list/use-form.ts index 21916667d2f7..fdc48678809b 100644 --- a/dolphinscheduler-ui/src/views/datasource/list/use-form.ts +++ b/dolphinscheduler-ui/src/views/datasource/list/use-form.ts @@ -244,9 +244,7 @@ export function useForm(id?: number) { const changeType = async (type: IDataBase, options: IDataBaseOption) => { state.detailForm.port = options.previousPort || options.defaultPort state.detailForm.type = type - - state.requiredDataBase = type !== 'POSTGRESQL' && type !== 'ATHENA' - + state.requiredDataBase = type !== 'POSTGRESQL' && type !== 'ATHENA' && type !== 'DOLPHINDB' state.showHost = type !== 'ATHENA' state.showPort = type !== 'ATHENA' state.showAwsRegion = type === 'ATHENA' || type === 'SAGEMAKER' @@ -268,12 +266,18 @@ export function useForm(id?: number) { type === 'SSH' || type === 'ZEPPELIN' || type === 'SAGEMAKER' || - type === 'K8S' + type === 'K8S' || + type === 'DOLPHINDB' ) { + state.showDataBaseName = false state.requiredDataBase = false state.showJDBCConnectParameters = false state.showPublicKey = false + if(type === 'DOLPHINDB'){ + state.showJDBCConnectParameters = true + state.showPublicKey = false + } if (type === 'SSH') { state.showPublicKey = true } @@ -458,7 +462,12 @@ export const datasourceType: IDataBaseOptionKeys = { value: 'K8S', label: 'K8S', defaultPort: 6443 - } + }, + DOLPHINDB: { + value: 'DOLPHINDB', + label: 'DOLPHINDB', + defaultPort: 8848 + } } export const datasourceTypeList: IDataBaseOption[] = Object.values( diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts index 8b4ef0b897ec..ef26cc83e348 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-datasource.ts @@ -157,6 +157,11 @@ export function useDatasource( id: 25, code: 'SAGEMAKER', disabled: false + }, + { + id: 26, + code: 'DOLPHINDB', + disabled: false } ] diff --git a/tools/dependencies/known-dependencies.txt b/tools/dependencies/known-dependencies.txt index 49b2f1367d3b..bf8c0ba7b434 100644 --- a/tools/dependencies/known-dependencies.txt +++ b/tools/dependencies/known-dependencies.txt @@ -520,4 +520,4 @@ semver-5.7.2.jar sigmund-1.0.1.jar wrappy-1.0.2.jar yallist-2.1.2.jar - +dolphindb-jdbc-3.00.0.1.jar