mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-11-30 02:57:37 +08:00
Add plugin: hive and kyuubi (#48)
This commit is contained in:
commit
3dbffcae99
@ -17,12 +17,12 @@ We'd also love PRs. If you're thinking of a large PR, we advise opening up an is
|
||||
## Submitting a pull request
|
||||
|
||||
1. [Fork][fork] and clone the repository.
|
||||
1. Configure and install the dependencies: `./mvnw clean install -X`.
|
||||
1. Make sure the tests pass on your machine: `./mvnw clean install package -X`, note: these tests also apply the linter, so there's no need to lint separately.
|
||||
1. Create a new branch: `git checkout -b my-branch-name`.
|
||||
1. Make your change, add tests, and make sure the tests still pass.
|
||||
1. Push to your fork and [submit a pull request][pr].
|
||||
1. Pat your self on the back and wait for your pull request to be reviewed and merged.
|
||||
2. Configure and install the dependencies: `./mvnw clean install -X`.
|
||||
3. Make sure the tests pass on your machine: `./mvnw clean install package -X`, note: these tests also apply the linter, so there's no need to lint separately.
|
||||
4. Create a new branch: `git checkout -b my-branch-name`.
|
||||
5. Make your change, add tests, and make sure the tests still pass.
|
||||
6. Push to your fork and [submit a pull request][pr].
|
||||
7. Pat your self on the back and wait for your pull request to be reviewed and merged.
|
||||
|
||||
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
|
||||
|
||||
|
@ -67,6 +67,12 @@ Here are some of the major database solutions that are supported:
|
||||
<a href="https://druid.apache.org/" target="_blank">
|
||||
<img src="./shared/plugin/druid.jpg" alt="Druid" width="50" height="50" />
|
||||
</a>
|
||||
<a href="https://kyuubi.apache.org/" target="_blank">
|
||||
<img src="./shared/plugin/kyuubi.png" alt="Kyuubi" width="50" height="50" />
|
||||
</a>
|
||||
<a href="https://hive.apache.org/" target="_blank">
|
||||
<img src="./shared/plugin/hive.svg" alt="Hive" width="50" height="50" />
|
||||
</a>
|
||||
</code> <br />
|
||||
</div>
|
||||
</div>
|
||||
|
@ -65,13 +65,13 @@
|
||||
<outputDirectory>docs</outputDirectory>
|
||||
<fileMode>0644</fileMode>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>../dist/plugins</directory>
|
||||
<outputDirectory>plugins</outputDirectory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<fileMode>0644</fileMode>
|
||||
</fileSet>
|
||||
<!-- <fileSet>-->
|
||||
<!-- <directory>../dist/plugins</directory>-->
|
||||
<!-- <outputDirectory>plugins</outputDirectory>-->
|
||||
<!-- <includes>-->
|
||||
<!-- <include>**/*</include>-->
|
||||
<!-- </includes>-->
|
||||
<!-- <fileMode>0644</fileMode>-->
|
||||
<!-- </fileSet>-->
|
||||
</fileSets>
|
||||
</assembly>
|
||||
|
@ -21,6 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-spi</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.clickhouse</groupId>
|
||||
|
@ -8,6 +8,7 @@ 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 ClickHousePlugin
|
||||
@ -47,26 +48,29 @@ public class ClickHousePlugin
|
||||
this.clickHouseConnection = new ClickHouseConnection(this.jdbcConfigure, this.response);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
this.response.setIsSuccessful(Boolean.FALSE);
|
||||
this.response.setIsConnected(Boolean.FALSE);
|
||||
this.response.setMessage(ex.getMessage());
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(String content)
|
||||
{
|
||||
log.info("Execute clickhouse plugin logic started");
|
||||
this.response = this.clickHouseConnection.getResponse();
|
||||
JdbcAdapter processor = new ClickHouseAdapter(this.clickHouseConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute clickhouse plugin logic end");
|
||||
if (ObjectUtils.isNotEmpty(this.clickHouseConnection)) {
|
||||
log.info("Execute clickhouse plugin logic started");
|
||||
this.response = this.clickHouseConnection.getResponse();
|
||||
JdbcAdapter processor = new ClickHouseAdapter(this.clickHouseConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute clickhouse plugin logic end");
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
this.clickHouseConnection.destroy();
|
||||
if (ObjectUtils.isNotEmpty(this.clickHouseConnection)) {
|
||||
this.clickHouseConnection.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-spi</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
|
@ -8,6 +8,7 @@ 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 DruidPlugin
|
||||
@ -47,26 +48,29 @@ public class DruidPlugin
|
||||
this.connection = new DruidConnection(this.jdbcConfigure, this.response);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
this.response.setIsSuccessful(Boolean.FALSE);
|
||||
this.response.setIsConnected(Boolean.FALSE);
|
||||
this.response.setMessage(ex.getMessage());
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(String content)
|
||||
{
|
||||
log.info("Execute druid plugin logic started");
|
||||
this.response = this.connection.getResponse();
|
||||
JdbcAdapter processor = new DruidAdapter(this.connection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute druid plugin logic end");
|
||||
if (ObjectUtils.isNotEmpty(this.connection)) {
|
||||
log.info("Execute druid plugin logic started");
|
||||
this.response = this.connection.getResponse();
|
||||
JdbcAdapter processor = new DruidAdapter(this.connection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute druid plugin logic end");
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
this.connection.destroy();
|
||||
if (ObjectUtils.isNotEmpty(this.connection)) {
|
||||
this.connection.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-spi</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch.plugin</groupId>
|
||||
|
@ -8,6 +8,7 @@ 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 ElasticSearchPlugin
|
||||
@ -47,26 +48,29 @@ public class ElasticSearchPlugin
|
||||
this.connection = new ElasticSearchConnection(this.jdbcConfigure, this.response);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
this.response.setIsSuccessful(Boolean.FALSE);
|
||||
this.response.setIsConnected(Boolean.FALSE);
|
||||
this.response.setMessage(ex.getMessage());
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(String content)
|
||||
{
|
||||
log.info("Execute elasticsearch plugin logic started");
|
||||
this.response = this.connection.getResponse();
|
||||
JdbcAdapter processor = new ElasticSearchAdapter(this.connection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute elasticsearch plugin logic end");
|
||||
if (ObjectUtils.isNotEmpty(this.connection)) {
|
||||
log.info("Execute elasticsearch plugin logic started");
|
||||
this.response = this.connection.getResponse();
|
||||
JdbcAdapter processor = new ElasticSearchAdapter(this.connection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute elasticsearch plugin logic end");
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
this.connection.destroy();
|
||||
if (ObjectUtils.isNotEmpty(this.connection)) {
|
||||
this.connection.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
67
plugin/jdbc/hive/pom.xml
Normal file
67
plugin/jdbc/hive/pom.xml
Normal 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.0.0.20221015</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>datacap-plugin-jdbc-hive</artifactId>
|
||||
<name>DataCap plugin for jdbc (Hive)</name>
|
||||
|
||||
<properties>
|
||||
<hive.version>3.1.2</hive.version>
|
||||
<plugin.name>jdbc-hive</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>org.apache.hive</groupId>
|
||||
<artifactId>hive-jdbc</artifactId>
|
||||
<version>${hive.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-runner</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>
|
@ -0,0 +1,13 @@
|
||||
package io.edurt.datacap.plugin.jdbc.hive;
|
||||
|
||||
import io.edurt.datacap.spi.adapter.JdbcAdapter;
|
||||
import io.edurt.datacap.spi.connection.JdbcConnection;
|
||||
|
||||
public class HiveAdapter
|
||||
extends JdbcAdapter
|
||||
{
|
||||
public HiveAdapter(JdbcConnection jdbcConnection)
|
||||
{
|
||||
super(jdbcConnection);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package io.edurt.datacap.plugin.jdbc.hive;
|
||||
|
||||
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 HivePlugin
|
||||
implements Plugin
|
||||
{
|
||||
private JdbcConfigure jdbcConfigure;
|
||||
private JdbcConnection connection;
|
||||
private Response response;
|
||||
|
||||
@Override
|
||||
public String name()
|
||||
{
|
||||
return "Hive";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description()
|
||||
{
|
||||
return "Integrate Hive data sources";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginType type()
|
||||
{
|
||||
return PluginType.SOURCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Configure configure)
|
||||
{
|
||||
try {
|
||||
this.response = new Response();
|
||||
this.jdbcConfigure = new JdbcConfigure();
|
||||
BeanUtils.copyProperties(this.jdbcConfigure, configure);
|
||||
this.jdbcConfigure.setJdbcDriver("org.apache.hive.jdbc.HiveDriver");
|
||||
this.jdbcConfigure.setJdbcType("hive2");
|
||||
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 hive plugin logic started");
|
||||
this.response = this.connection.getResponse();
|
||||
JdbcAdapter processor = new HiveAdapter(this.connection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute hive plugin logic end");
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
if (ObjectUtils.isNotEmpty(this.connection)) {
|
||||
this.connection.destroy();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package io.edurt.datacap.plugin.jdbc.hive;
|
||||
|
||||
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 HivePluginModule
|
||||
extends AbstractPluginModule
|
||||
implements PluginModule
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Hive";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginType getType()
|
||||
{
|
||||
return PluginType.SOURCE;
|
||||
}
|
||||
|
||||
@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(HivePlugin.class);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
io.edurt.datacap.plugin.jdbc.hive.HivePluginModule
|
61
plugin/jdbc/kyuubi/pom.xml
Normal file
61
plugin/jdbc/kyuubi/pom.xml
Normal file
@ -0,0 +1,61 @@
|
||||
<?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.0.0.20221015</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>datacap-plugin-jdbc-kyuubi</artifactId>
|
||||
<name>DataCap plugin for jdbc (Kyuubi)</name>
|
||||
|
||||
<properties>
|
||||
<kyuubi-jdbc.version>1.5.2-incubating</kyuubi-jdbc.version>
|
||||
<plugin.name>jdbc-kyuubi</plugin.name>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-spi</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.kyuubi</groupId>
|
||||
<artifactId>kyuubi-hive-jdbc-shaded</artifactId>
|
||||
<version>${kyuubi-jdbc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
</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>
|
@ -0,0 +1,13 @@
|
||||
package io.edurt.datacap.plugin.jdbc.kyuubi;
|
||||
|
||||
import io.edurt.datacap.spi.adapter.JdbcAdapter;
|
||||
import io.edurt.datacap.spi.connection.JdbcConnection;
|
||||
|
||||
public class KyuubiAdapter
|
||||
extends JdbcAdapter
|
||||
{
|
||||
public KyuubiAdapter(JdbcConnection jdbcConnection)
|
||||
{
|
||||
super(jdbcConnection);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package io.edurt.datacap.plugin.jdbc.kyuubi;
|
||||
|
||||
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 KyuubiPlugin
|
||||
implements Plugin
|
||||
{
|
||||
private JdbcConfigure jdbcConfigure;
|
||||
private JdbcConnection connection;
|
||||
private Response response;
|
||||
|
||||
@Override
|
||||
public String name()
|
||||
{
|
||||
return "Kyuubi";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description()
|
||||
{
|
||||
return "Integrate Kyuubi data sources";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginType type()
|
||||
{
|
||||
return PluginType.SOURCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Configure configure)
|
||||
{
|
||||
try {
|
||||
this.response = new Response();
|
||||
this.jdbcConfigure = new JdbcConfigure();
|
||||
BeanUtils.copyProperties(this.jdbcConfigure, configure);
|
||||
this.jdbcConfigure.setJdbcDriver("org.apache.kyuubi.jdbc.KyuubiHiveDriver");
|
||||
this.jdbcConfigure.setJdbcType("hive2");
|
||||
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 kyuubi plugin logic started");
|
||||
this.response = this.connection.getResponse();
|
||||
JdbcAdapter processor = new KyuubiAdapter(this.connection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute kyuubi plugin logic end");
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
if (ObjectUtils.isNotEmpty(this.connection)) {
|
||||
this.connection.destroy();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package io.edurt.datacap.plugin.jdbc.kyuubi;
|
||||
|
||||
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 KyuubiPluginModule
|
||||
extends AbstractPluginModule
|
||||
implements PluginModule
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Kyuubi";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginType getType()
|
||||
{
|
||||
return PluginType.SOURCE;
|
||||
}
|
||||
|
||||
@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(KyuubiPlugin.class);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
io.edurt.datacap.plugin.jdbc.kyuubi.KyuubiPluginModule
|
@ -0,0 +1,30 @@
|
||||
package io.edurt.datacap.plugin.jdbc.kyuubi;
|
||||
|
||||
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 KyuubiPluginModuleTest
|
||||
{
|
||||
private Injector injector;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
this.injector = Guice.createInjector(new KyuubiPluginModule());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
{
|
||||
Set<Plugin> plugins = injector.getInstance(Key.get(new TypeLiteral<Set<Plugin>>() {}));
|
||||
Assert.assertTrue(plugins.size() > 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package io.edurt.datacap.plugin.jdbc.kyuubi;
|
||||
|
||||
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.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class KyuubiPluginTest
|
||||
{
|
||||
private Injector injector;
|
||||
private Configure configure;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
injector = Guice.createInjector(new KyuubiPluginModule());
|
||||
configure = new Configure();
|
||||
configure.setHost("127.0.0.1");
|
||||
configure.setPort(10009);
|
||||
}
|
||||
|
||||
@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("Kyuubi"))
|
||||
.findFirst();
|
||||
if (pluginOptional.isPresent()) {
|
||||
Plugin plugin = pluginOptional.get();
|
||||
plugin.connect(configure);
|
||||
System.out.println(plugin.execute("SHOW DATABASES"));
|
||||
plugin.destroy();
|
||||
}
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-spi</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
|
@ -8,6 +8,7 @@ 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 MySQLPlugin
|
||||
@ -47,26 +48,29 @@ public class MySQLPlugin
|
||||
this.mySQLConnection = new MySQLConnection(this.jdbcConfigure, this.response);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
this.response.setIsSuccessful(Boolean.FALSE);
|
||||
this.response.setIsConnected(Boolean.FALSE);
|
||||
this.response.setMessage(ex.getMessage());
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(String content)
|
||||
{
|
||||
log.info("Execute mysql plugin logic started");
|
||||
this.response = this.mySQLConnection.getResponse();
|
||||
JdbcAdapter processor = new MySQLAdapter(this.mySQLConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute mysql plugin logic end");
|
||||
if (ObjectUtils.isNotEmpty(this.mySQLConnection)) {
|
||||
log.info("Execute mysql plugin logic started");
|
||||
this.response = this.mySQLConnection.getResponse();
|
||||
JdbcAdapter processor = new MySQLAdapter(this.mySQLConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute mysql plugin logic end");
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
this.mySQLConnection.destroy();
|
||||
if (ObjectUtils.isNotEmpty(this.mySQLConnection)) {
|
||||
this.mySQLConnection.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,5 +22,7 @@
|
||||
<module>trino</module>
|
||||
<module>elasticsearch</module>
|
||||
<module>druid</module>
|
||||
<module>kyuubi</module>
|
||||
<module>hive</module>
|
||||
</modules>
|
||||
</project>
|
@ -21,6 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-spi</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
|
@ -8,6 +8,7 @@ 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 PostgreSQLPlugin
|
||||
@ -47,26 +48,29 @@ public class PostgreSQLPlugin
|
||||
this.postgreSQLConnection = new PostgreSQLConnection(this.jdbcConfigure, this.response);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
this.response.setIsSuccessful(Boolean.FALSE);
|
||||
this.response.setIsConnected(Boolean.FALSE);
|
||||
this.response.setMessage(ex.getMessage());
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(String content)
|
||||
{
|
||||
log.info("Execute postgresql plugin logic started");
|
||||
this.response = this.postgreSQLConnection.getResponse();
|
||||
JdbcAdapter processor = new PostgreSQLAdapter(this.postgreSQLConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute postgresql plugin logic end");
|
||||
if (ObjectUtils.isNotEmpty(this.postgreSQLConnection)) {
|
||||
log.info("Execute postgresql plugin logic started");
|
||||
this.response = this.postgreSQLConnection.getResponse();
|
||||
JdbcAdapter processor = new PostgreSQLAdapter(this.postgreSQLConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute postgresql plugin logic end");
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
this.postgreSQLConnection.destroy();
|
||||
if (ObjectUtils.isNotEmpty(this.postgreSQLConnection)) {
|
||||
this.postgreSQLConnection.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-spi</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.prestosql</groupId>
|
||||
|
@ -9,6 +9,7 @@ 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 PrestoPlugin
|
||||
@ -48,26 +49,29 @@ public class PrestoPlugin
|
||||
this.jdbcConnection = new JdbcConnection(this.jdbcConfigure, this.response);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
this.response.setIsSuccessful(Boolean.FALSE);
|
||||
this.response.setIsConnected(Boolean.FALSE);
|
||||
this.response.setMessage(ex.getMessage());
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(String content)
|
||||
{
|
||||
log.info("Execute plugin logic started");
|
||||
this.response = this.jdbcConnection.getResponse();
|
||||
JdbcAdapter processor = new PrestoAdapter(this.jdbcConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute plugin logic end");
|
||||
if (ObjectUtils.isNotEmpty(this.jdbcConnection)) {
|
||||
log.info("Execute plugin logic started");
|
||||
this.response = this.jdbcConnection.getResponse();
|
||||
JdbcAdapter processor = new PrestoAdapter(this.jdbcConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute plugin logic end");
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
this.jdbcConnection.destroy();
|
||||
if (ObjectUtils.isNotEmpty(this.jdbcConnection)) {
|
||||
this.jdbcConnection.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-spi</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
|
@ -9,6 +9,7 @@ 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 RedisPlugin
|
||||
@ -48,26 +49,29 @@ public class RedisPlugin
|
||||
this.jdbcConnection = new JdbcConnection(this.jdbcConfigure, this.response);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
this.response.setIsSuccessful(Boolean.FALSE);
|
||||
this.response.setIsConnected(Boolean.FALSE);
|
||||
this.response.setMessage(ex.getMessage());
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(String content)
|
||||
{
|
||||
log.info("Execute plugin logic started");
|
||||
this.response = this.jdbcConnection.getResponse();
|
||||
JdbcAdapter processor = new RedisAdapter(this.jdbcConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute plugin logic end");
|
||||
if (ObjectUtils.isNotEmpty(this.jdbcConnection)) {
|
||||
log.info("Execute plugin logic started");
|
||||
this.response = this.jdbcConnection.getResponse();
|
||||
JdbcAdapter processor = new RedisAdapter(this.jdbcConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute plugin logic end");
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
this.jdbcConnection.destroy();
|
||||
if (ObjectUtils.isNotEmpty(this.jdbcConnection)) {
|
||||
this.jdbcConnection.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-spi</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
|
@ -8,6 +8,7 @@ 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 TrinoPlugin
|
||||
@ -47,26 +48,29 @@ public class TrinoPlugin
|
||||
this.trinoConnection = new TrinoConnection(this.jdbcConfigure, this.response);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
this.response.setIsSuccessful(Boolean.FALSE);
|
||||
this.response.setIsConnected(Boolean.FALSE);
|
||||
this.response.setMessage(ex.getMessage());
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(String content)
|
||||
{
|
||||
log.info("Execute trino plugin logic started");
|
||||
this.response = this.trinoConnection.getResponse();
|
||||
JdbcAdapter processor = new TrinoAdapter(this.trinoConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute trino plugin logic end");
|
||||
if (ObjectUtils.isNotEmpty(this.trinoConnection)) {
|
||||
log.info("Execute trino plugin logic started");
|
||||
this.response = this.trinoConnection.getResponse();
|
||||
JdbcAdapter processor = new TrinoAdapter(this.trinoConnection);
|
||||
this.response = processor.handlerJDBCExecute(content);
|
||||
log.info("Execute trino plugin logic end");
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
this.trinoConnection.destroy();
|
||||
if (ObjectUtils.isNotEmpty(this.trinoConnection)) {
|
||||
this.trinoConnection.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,10 @@
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-spi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
|
||||
<artifactId>datacap-plugin-jdbc-mysql</artifactId>
|
||||
@ -114,6 +118,16 @@
|
||||
<artifactId>datacap-plugin-jdbc-druid</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
|
||||
<artifactId>datacap-plugin-jdbc-kyuubi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
|
||||
<artifactId>datacap-plugin-jdbc-hive</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
51
shared/plugin/hive.svg
Normal file
51
shared/plugin/hive.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 14 KiB |
BIN
shared/plugin/kyuubi.png
Normal file
BIN
shared/plugin/kyuubi.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
Loading…
Reference in New Issue
Block a user