Skip to content

Commit

Permalink
[Feature][DataSource] add oceanbase datasource (apache#13675)
Browse files Browse the repository at this point in the history
Co-authored-by: Jay Chung <[email protected]>
  • Loading branch information
whhe and zhongjiajie authored Mar 7, 2023
1 parent c9066e8 commit 35d8e8a
Show file tree
Hide file tree
Showing 21 changed files with 525 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .dlc.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
"retryOn429": true,
"retryCount": 10,
"fallbackRetryDelay": "1000s",
"aliveStatusCodes": [200, 401, 0]
"aliveStatusCodes": [200, 401, 403, 0]
}
40 changes: 40 additions & 0 deletions docs/configs/docsdev.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,22 @@ export default {
title: 'Azure SQL Database',
link: '/en-us/docs/dev/user_doc/guide/datasource/azure-sql.html',
},
{
title: 'Trino',
link: '/en-us/docs/dev/user_doc/guide/datasource/trino.html',
},
{
title: 'StarRocks',
link: '/en-us/docs/dev/user_doc/guide/datasource/starrocks.html',
},
{
title: 'DAMENG',
link: '/en-us/docs/dev/user_doc/guide/datasource/dameng.html',
},
{
title: 'OceanBase',
link: '/en-us/docs/dev/user_doc/guide/datasource/oceanbase.html',
},
],
},
{
Expand Down Expand Up @@ -948,6 +964,30 @@ export default {
title: 'Azure SQL Database',
link: '/zh-cn/docs/dev/user_doc/guide/datasource/azure-sql.html',
},
{
title: 'Redshift',
link: '/zh-cn/docs/dev/user_doc/guide/datasource/redshift.html',
},
{
title: 'Oracle',
link: '/zh-cn/docs/dev/user_doc/guide/datasource/oracle.html',
},
{
title: 'Trino',
link: '/zh-cn/docs/dev/user_doc/guide/datasource/trino.html',
},
{
title: 'StarRocks',
link: '/zh-cn/docs/dev/user_doc/guide/datasource/starrocks.html',
},
{
title: 'DAMENG',
link: '/zh-cn/docs/dev/user_doc/guide/datasource/dameng.html',
},
{
title: 'OceanBase',
link: '/zh-cn/docs/dev/user_doc/guide/datasource/oceanbase.html',
},
],
},
{
Expand Down
24 changes: 24 additions & 0 deletions docs/docs/en/guide/datasource/oceanbase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# OceanBase

![oceanbase](../../../../img/new_ui/dev/datasource/oceanbase.png)

## Datasource Parameters

| **Datasource** | **Description** |
|----------------------------|--------------------------------------------------------------|
| Datasource | Select OCEANBASE. |
| Datasource name | Enter the name of the DataSource. |
| Description | Enter a description of the DataSource. |
| IP/Host name | Enter the OceanBase service IP. |
| Port | Enter the OceanBase service port. |
| Username | Set the username for OceanBase connection. |
| Password | Set the password for OceanBase connection. |
| Database name | Enter the database name of the OceanBase connection. |
| Compatible mode | Set the compatible mode of the OceanBase connection. |
| Jdbc connection parameters | Parameter settings for OceanBase connection, in JSON format. |

## Native Supported

No, you need to import the OceanBase jdbc driver [oceanbase-client](https://mvnrepository.com/artifact/com.oceanbase/oceanbase-client) first, refer to the section example in [datasource-setting](../howto/datasource-setting.md) `DataSource Center` section.

The compatible mode of the datasource can be 'mysql' or 'oracle', if you only use OceanBase with 'mysql' mode, you can also treat OceanBase as MySQL and manage the datasource referring to [mysql datasource](mysql.md)
21 changes: 21 additions & 0 deletions docs/docs/zh/guide/datasource/oceanbase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# OceanBase 数据源

![oceanbase](../../../../img/new_ui/dev/datasource/oceanbase.png)

- 数据源:选择 OCEANBASE
- 数据源名称:输入数据源的名称
- 描述:输入数据源的描述
- IP 主机名:输入连接 OceanBase 的 IP
- 端口:输入连接 OceanBase 的端口
- 用户名:设置连接 OceanBase 的用户名
- 密码:设置连接 OceanBase 的密码
- 数据库名:输入连接 OceanBase 的数据库名称
- 兼容模式:输入连接 OceanBase 的兼容模式
- Jdbc 连接参数:用于 OceanBase 连接的参数设置,以 JSON 形式填写

## 是否原生支持

否,使用前需要先引入 OceanBase 的 JDBC 驱动 [oceanbase-client](https://mvnrepository.com/artifact/com.oceanbase/oceanbase-client),请参考 [数据源配置](../howto/datasource-setting.md) 中的 "数据源中心" 章节。

OceanBase 数据源的兼容模式可以是 'mysql' 或 'oracle',如果你只使用 mysql 模式,你也可以选择将 OceanBase 数据源当作 MySQL 数据源来使用,请参考 [MySQL 数据源](mysql.md)

Binary file added docs/img/new_ui/dev/datasource/oceanbase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class DataSourceConstants {
public static final String COM_ATHENA_JDBC_DRIVER = "com.simba.athena.jdbc.Driver";
public static final String COM_TRINO_JDBC_DRIVER = "io.trino.jdbc.TrinoDriver";
public static final String COM_DAMENG_JDBC_DRIVER = "dm.jdbc.driver.DmDriver";
public static final String COM_OCEANBASE_JDBC_DRIVER = "com.oceanbase.jdbc.Driver";

/**
* validation Query
Expand Down Expand Up @@ -71,6 +72,7 @@ public class DataSourceConstants {
public static final String JDBC_ATHENA = "jdbc:awsathena://";
public static final String JDBC_TRINO = "jdbc:trino://";
public static final String JDBC_DAMENG = "jdbc:dm://";
public static final String JDBC_OCEANBASE = "jdbc:oceanbase://";

/**
* database type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<artifactId>dolphinscheduler-datasource-mysql</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-datasource-oceanbase</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-datasource-oracle</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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-oceanbase</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>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.oceanbase;

import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.apache.dolphinscheduler.spi.datasource.DataSourceClient;
import org.apache.dolphinscheduler.spi.enums.DbType;

public class OceanBaseDataSourceChannel implements DataSourceChannel {

@Override
public DataSourceClient createDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) {
return new OceanBaseDataSourceClient(baseConnectionParam, dbType);
}
}
Original file line number Diff line number Diff line change
@@ -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.oceanbase;

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

import com.google.auto.service.AutoService;

@AutoService(DataSourceChannelFactory.class)
public class OceanBaseDataSourceChannelFactory implements DataSourceChannelFactory {

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

@Override
public DataSourceChannel create() {
return new OceanBaseDataSourceChannel();
}
}
Original file line number Diff line number Diff line change
@@ -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.oceanbase;

import org.apache.dolphinscheduler.plugin.datasource.api.client.CommonDataSourceClient;
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;

public class OceanBaseDataSourceClient extends CommonDataSourceClient {

public OceanBaseDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) {
super(baseConnectionParam, dbType);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.oceanbase.param;

import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam;

import lombok.Data;

@Data
public class OceanBaseConnectionParam extends BaseConnectionParam {

protected String compatibleMode;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.oceanbase.param;

import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO;
import org.apache.dolphinscheduler.spi.enums.DbType;

public class OceanBaseDataSourceParamDTO extends BaseDataSourceParamDTO {

protected String compatibleMode;

public String getCompatibleMode() {
return compatibleMode;
}

public void setCompatibleMode(String compatibleMode) {
this.compatibleMode = compatibleMode;
}

@Override
public DbType getType() {
return DbType.OCEANBASE;
}
}
Loading

0 comments on commit 35d8e8a

Please sign in to comment.