This commit is contained in:
yinxiaolog 2024-06-12 14:18:08 +08:00 committed by GitHub
commit 0dc3b2dd59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 927 additions and 7 deletions

View File

@ -274,6 +274,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',
},
],
},
{
@ -977,6 +981,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',
},
],
},
{

View File

@ -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.

View File

@ -0,0 +1,18 @@
# DOLPHINDB 数据源
![dolphindb](../../../../img/new_ui/dev/datasource/dolphindb-zh.png)
| **参数名称** | **参数描述** |
|-----------|----------------------------------|
| 数据源 | 选择 DOLPHINDB |
| 数据源名称 | 输入数据源的名称 |
| 描述 | 输入数据源的描述 |
| IP 主机名 | 输入连接 DOLPHINDB 的 IP |
| 端口 | 输入连接 DOLPHINDB 的端口 |
| 用户名 | 设置连接 DOLPHINDB 的用户名 |
| 密码 | 设置连接 DOLPHINDB 的密码 |
| JDBC 连接参数 | 用于 DOLPHINDB 连接的参数设置,以 JSON 形式填写 |
## 是否原生支持
是,数据源不需要任务附加操作即可使用。

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

View File

@ -58,6 +58,7 @@
<cron-utils.version>9.1.6</cron-utils.version>
<h2.version>2.2.220</h2.version>
<mysql-connector.version>8.0.33</mysql-connector.version>
<dolphindb-jdbc.version>3.00.0.1</dolphindb-jdbc.version>
<vertica-jdbc.version>12.0.4-0</vertica-jdbc.version>
<oracle-jdbc.version>21.5.0.0</oracle-jdbc.version>
<dameng-jdbc.version>8.1.2.79</dameng-jdbc.version>
@ -366,6 +367,11 @@
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>
<!--protostuff-->
<dependency>
@ -411,6 +417,12 @@
<version>${dameng-jdbc.version}</version>
</dependency>
<dependency>
<groupId>com.dolphindb</groupId>
<artifactId>jdbc</artifactId>
<version>${dolphindb-jdbc.version}</version>
</dependency>
<dependency>
<groupId>com.vertica.jdbc</groupId>
<artifactId>vertica-jdbc</artifactId>

View File

@ -74,6 +74,12 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>

View File

@ -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

View File

@ -60,6 +60,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
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();

View File

@ -158,5 +158,10 @@
<artifactId>dolphinscheduler-datasource-hana</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-datasource-dolphindb</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-datasource-plugin</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<artifactId>dolphinscheduler-datasource-dolphindb</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-spi</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-datasource-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.dolphindb</groupId>
<artifactId>jdbc</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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 + '\''
+ '}';
}
}

View File

@ -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;
}
}

View File

@ -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<String, String> otherMap) {
if (MapUtils.isEmpty(otherMap)) {
return null;
}
List<String> list = new ArrayList<>(otherMap.size());
otherMap.forEach((key, value) -> list.add(String.format("%s=%s", key, value)));
return String.join("&", list);
}
}

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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<String, String> 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<PasswordUtils> 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<PasswordUtils> 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));
}
}
}

View File

@ -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<JDBCDataSourceProvider> 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));
}
}
}

View File

@ -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<String, String> 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<PasswordUtils> mockedStaticPasswordUtils = Mockito.mockStatic(PasswordUtils.class);
MockedStatic<CommonUtils> 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<PropertyUtils> mockedStaticPropertyUtils = Mockito.mockStatic(PropertyUtils.class);
MockedStatic<DataSourceClientProvider> 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);
});
}
}

View File

@ -56,6 +56,7 @@
<module>dolphinscheduler-datasource-sagemaker</module>
<module>dolphinscheduler-datasource-k8s</module>
<module>dolphinscheduler-datasource-hana</module>
<module>dolphinscheduler-datasource-dolphindb</module>
</modules>
<dependencyManagement>

View File

@ -814,3 +814,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

View File

@ -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.
=========================================================================

View File

@ -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.

View File

@ -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<Integer, DbType> DB_TYPE_MAP =
Arrays.stream(DbType.values()).collect(toMap(DbType::getCode, Functions.identity()));
@EnumValue

View File

@ -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

View File

@ -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(

View File

@ -157,6 +157,11 @@ export function useDatasource(
id: 25,
code: 'SAGEMAKER',
disabled: false
},
{
id: 26,
code: 'DOLPHINDB',
disabled: false
}
]

View File

@ -521,4 +521,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