[Plugin] Support oceanbase for jdbc (#159)

This commit is contained in:
qianmoQ 2022-11-30 23:28:53 +08:00 committed by GitHub
commit 9052460624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 320 additions and 41 deletions

View File

@ -93,6 +93,9 @@ Here are some of the major database solutions that are supported:
</a>&nbsp;
<a href="https://impala.apache.org/" target="_blank">
<img src="assets/plugin/impala.png" alt="Impala" height="50" />
</a>&nbsp;
<a href="https://www.oceanbase.com/" target="_blank">
<img src="assets/plugin/oceanbase.png" alt="OceanBase" height="50" />
</a>
</p>

BIN
assets/plugin/oceanbase.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>incubator-datacap</artifactId>
<groupId>io.edurt.datacap</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -114,7 +114,7 @@ plugins:
documentation_database_clickhouse: ClickHouse
documentation_database_kylin: Kylin
documentation_database_oracle: Oracle
documentation_v120: 1.2.0-SNAPSHOT
documentation_v120: 1.2.0
documentation_v120_plugin_cratedb: CrateDB
documentation_v120_plugin_tdengine: TDengine
documentation_v120_plugin_impala: Impala
@ -140,7 +140,7 @@ plugins:
documentation_database_clickhouse: ClickHouse
documentation_database_kylin: Kylin
documentation_database_oracle: Oracle
documentation_v120: 1.2.0-SNAPSHOT
documentation_v120: 1.2.0
documentation_v120_plugin_cratedb: CrateDB
documentation_v120_plugin_tdengine: TDengine
documentation_v120_plugin_impala: Impala

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin</artifactId>
<groupId>io.edurt.datacap.plugin</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-http</artifactId>
<groupId>io.edurt.datacap.plugin.http</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-http</artifactId>
<groupId>io.edurt.datacap.plugin.http</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin</artifactId>
<groupId>io.edurt.datacap.plugin</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<artifactId>datacap-plugin-jdbc</artifactId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<artifactId>datacap-plugin-jdbc-db2</artifactId>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<artifactId>datacap-plugin-jdbc</artifactId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<artifactId>datacap-plugin-jdbc-ignite</artifactId>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>datacap-plugin-jdbc-oceanbase</artifactId>
<name>DataCap plugin for jdbc (OceanBase)</name>
<properties>
<oceanbase.version>2.4.0</oceanbase.version>
<plugin.name>jdbc-oceanbase</plugin.name>
</properties>
<dependencies>
<dependency>
<groupId>io.edurt.datacap</groupId>
<artifactId>datacap-spi</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>com.oceanbase</groupId>
<artifactId>oceanbase-client</artifactId>
<version>${oceanbase.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${assembly-plugin.version}</version>
<configuration>
<finalName>${plugin.name}</finalName>
<descriptors>
<descriptor>../../../configure/assembly/assembly-plugin.xml</descriptor>
</descriptors>
<outputDirectory>../../../dist/plugins/${plugin.name}</outputDirectory>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,13 @@
package io.edurt.datacap.plugin.jdbc.oceanbase;
import io.edurt.datacap.spi.adapter.JdbcAdapter;
import io.edurt.datacap.spi.connection.JdbcConnection;
public class OceanBaseAdapter
extends JdbcAdapter
{
public OceanBaseAdapter(JdbcConnection jdbcConnection)
{
super(jdbcConnection);
}
}

View File

@ -0,0 +1,77 @@
package io.edurt.datacap.plugin.jdbc.oceanbase;
import io.edurt.datacap.spi.Plugin;
import io.edurt.datacap.spi.PluginType;
import io.edurt.datacap.spi.adapter.JdbcAdapter;
import io.edurt.datacap.spi.connection.JdbcConfigure;
import io.edurt.datacap.spi.connection.JdbcConnection;
import io.edurt.datacap.spi.model.Configure;
import io.edurt.datacap.spi.model.Response;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.ObjectUtils;
@Slf4j
public class OceanBasePlugin
implements Plugin
{
private JdbcConfigure jdbcConfigure;
private JdbcConnection connection;
private Response response;
@Override
public String name()
{
return "OceanBase";
}
@Override
public String description()
{
return "Integrate OceanBase data sources";
}
@Override
public PluginType type()
{
return PluginType.JDBC;
}
@Override
public void connect(Configure configure)
{
try {
this.response = new Response();
this.jdbcConfigure = new JdbcConfigure();
BeanUtils.copyProperties(this.jdbcConfigure, configure);
this.jdbcConfigure.setJdbcDriver("com.oceanbase.jdbc.Driver");
this.jdbcConfigure.setJdbcType("oceanbase");
this.connection = new JdbcConnection(this.jdbcConfigure, this.response);
}
catch (Exception ex) {
this.response.setIsConnected(Boolean.FALSE);
this.response.setMessage(ex.getMessage());
}
}
@Override
public Response execute(String content)
{
if (ObjectUtils.isNotEmpty(this.connection)) {
log.info("Execute oceanbase plugin logic started");
this.response = this.connection.getResponse();
JdbcAdapter processor = new OceanBaseAdapter(this.connection);
this.response = processor.handlerExecute(content);
log.info("Execute oceanbase plugin logic end");
}
return this.response;
}
@Override
public void destroy()
{
if (ObjectUtils.isNotEmpty(this.connection)) {
this.connection.destroy();
}
}
}

View File

@ -0,0 +1,38 @@
package io.edurt.datacap.plugin.jdbc.oceanbase;
import com.google.inject.multibindings.Multibinder;
import io.edurt.datacap.spi.AbstractPluginModule;
import io.edurt.datacap.spi.Plugin;
import io.edurt.datacap.spi.PluginModule;
import io.edurt.datacap.spi.PluginType;
public class OceanBasePluginModule
extends AbstractPluginModule
implements PluginModule
{
@Override
public String getName()
{
return "OceanBase";
}
@Override
public PluginType getType()
{
return PluginType.JDBC;
}
@Override
public AbstractPluginModule get()
{
return this;
}
protected void configure()
{
Multibinder<String> module = Multibinder.newSetBinder(this.binder(), String.class);
module.addBinding().toInstance(this.getClass().getSimpleName());
Multibinder<Plugin> plugin = Multibinder.newSetBinder(this.binder(), Plugin.class);
plugin.addBinding().to(OceanBasePlugin.class);
}
}

View File

@ -0,0 +1 @@
io.edurt.datacap.plugin.jdbc.oceanbase.OceanBasePluginModule

View File

@ -0,0 +1,30 @@
package io.edurt.datacap.plugin.jdbc.oceanbase;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import io.edurt.datacap.spi.Plugin;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Set;
public class OceanBasePluginModuleTest
{
private Injector injector;
@Before
public void before()
{
this.injector = Guice.createInjector(new OceanBasePluginModule());
}
@Test
public void test()
{
Set<Plugin> plugins = injector.getInstance(Key.get(new TypeLiteral<Set<Plugin>>() {}));
Assert.assertTrue(plugins.size() > 0);
}
}

View File

@ -0,0 +1,44 @@
package io.edurt.datacap.plugin.jdbc.oceanbase;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import io.edurt.datacap.spi.Plugin;
import io.edurt.datacap.spi.model.Configure;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Optional;
import java.util.Set;
public class OceanBasePluginTest
{
private Injector injector;
private Configure configure;
@Before
public void before()
{
injector = Guice.createInjector(new OceanBasePluginModule());
configure = new Configure();
configure.setHost("127.0.0.1");
configure.setPort(2883);
}
@Test
public void test()
{
Set<Plugin> plugins = injector.getInstance(Key.get(new TypeLiteral<Set<Plugin>>() {}));
Optional<Plugin> pluginOptional = plugins.stream()
.filter(v -> v.name().equalsIgnoreCase("OceanBase"))
.findFirst();
if (pluginOptional.isPresent()) {
Plugin plugin = pluginOptional.get();
plugin.connect(configure);
Assert.assertNotNull(plugin.execute(plugin.validator()).getConnection());
plugin.destroy();
}
}
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin</artifactId>
<groupId>io.edurt.datacap.plugin</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
@ -38,5 +38,6 @@
<module>dm</module>
<module>tdengine</module>
<module>impala</module>
<module>oceanbase</module>
</modules>
</project>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>datacap-plugin-jdbc</artifactId>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,12 +5,12 @@
<parent>
<artifactId>incubator-datacap</artifactId>
<groupId>io.edurt.datacap</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>datacap-plugin</artifactId>
<groupId>io.edurt.datacap.plugin</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>DataCap for plugin</name>

View File

@ -4,7 +4,7 @@
<groupId>io.edurt.datacap</groupId>
<artifactId>incubator-datacap</artifactId>
<packaging>pom</packaging>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
<modules>
<module>configure</module>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>incubator-datacap</artifactId>
<groupId>io.edurt.datacap</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -219,6 +219,11 @@
<artifactId>datacap-plugin-jdbc-impala</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
<artifactId>datacap-plugin-jdbc-oceanbase</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>incubator-datacap</artifactId>
<groupId>io.edurt.datacap</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -1,12 +1,12 @@
{
"name": "datacap-console-fe",
"version": "1.2.0",
"version": "1.3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "datacap-console-fe",
"version": "1.2.0",
"version": "1.3.0",
"dependencies": {
"@kangc/v-md-editor": "^2.3.15",
"@types/nprogress": "^0.2.0",

View File

@ -1,7 +1,7 @@
{
"name": "datacap-console-fe",
"description": "DataCap web site",
"version": "1.2.0",
"version": "1.3.0",
"private": true,
"scripts": {
"dev": "vue-cli-service serve",

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>incubator-datacap</artifactId>
<groupId>io.edurt.datacap</groupId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>