mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-16 02:11:15 +08:00
plugin: Add kylin (#63)
This commit is contained in:
commit
2763084db7
@ -74,6 +74,11 @@ Here are some of the major database solutions that are supported:
|
|||||||
<img src="./shared/plugin/hive.svg" alt="Hive" width="50" height="50" />
|
<img src="./shared/plugin/hive.svg" alt="Hive" width="50" height="50" />
|
||||||
</a>
|
</a>
|
||||||
</code> <br />
|
</code> <br />
|
||||||
|
<code>
|
||||||
|
<a href="https://kylin.apache.org" target="_blank">
|
||||||
|
<img src="./shared/plugin/kylin.png" alt="Kylin" width="50" height="50" />
|
||||||
|
</a>
|
||||||
|
</code> <br />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
61
plugin/jdbc/kylin/pom.xml
Normal file
61
plugin/jdbc/kylin/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-kylin</artifactId>
|
||||||
|
<name>DataCap plugin for jdbc (Kylin)</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<kylin.version>2.6.3</kylin.version>
|
||||||
|
<plugin.name>jdbc-kylin</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.kylin</groupId>
|
||||||
|
<artifactId>kylin-jdbc</artifactId>
|
||||||
|
<version>${kylin.version}</version>
|
||||||
|
</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.kylin;
|
||||||
|
|
||||||
|
import io.edurt.datacap.spi.adapter.JdbcAdapter;
|
||||||
|
import io.edurt.datacap.spi.connection.JdbcConnection;
|
||||||
|
|
||||||
|
public class KylinAdapter
|
||||||
|
extends JdbcAdapter
|
||||||
|
{
|
||||||
|
public KylinAdapter(JdbcConnection jdbcConnection)
|
||||||
|
{
|
||||||
|
super(jdbcConnection);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package io.edurt.datacap.plugin.jdbc.kylin;
|
||||||
|
|
||||||
|
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 KylinPlugin
|
||||||
|
implements Plugin
|
||||||
|
{
|
||||||
|
private JdbcConfigure jdbcConfigure;
|
||||||
|
private JdbcConnection connection;
|
||||||
|
private Response response;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "Kylin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String description()
|
||||||
|
{
|
||||||
|
return "Integrate Kylin 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.kylin.jdbc.Driver");
|
||||||
|
this.jdbcConfigure.setJdbcType("kylin");
|
||||||
|
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 kylin plugin logic started");
|
||||||
|
this.response = this.connection.getResponse();
|
||||||
|
JdbcAdapter processor = new KylinAdapter(this.connection);
|
||||||
|
this.response = processor.handlerJDBCExecute(content);
|
||||||
|
log.info("Execute kylin 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.kylin;
|
||||||
|
|
||||||
|
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 KylinPluginModule
|
||||||
|
extends AbstractPluginModule
|
||||||
|
implements PluginModule
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return "Kylin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@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(KylinPlugin.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
io.edurt.datacap.plugin.jdbc.kylin.KylinPluginModule
|
@ -0,0 +1,30 @@
|
|||||||
|
package io.edurt.datacap.plugin.jdbc.kylin;
|
||||||
|
|
||||||
|
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 KylinPluginModuleTest
|
||||||
|
{
|
||||||
|
private Injector injector;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before()
|
||||||
|
{
|
||||||
|
this.injector = Guice.createInjector(new KylinPluginModule());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test()
|
||||||
|
{
|
||||||
|
Set<Plugin> plugins = injector.getInstance(Key.get(new TypeLiteral<Set<Plugin>>() {}));
|
||||||
|
Assert.assertTrue(plugins.size() > 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package io.edurt.datacap.plugin.jdbc.kylin;
|
||||||
|
|
||||||
|
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 KylinPluginTest
|
||||||
|
{
|
||||||
|
private Injector injector;
|
||||||
|
private Configure configure;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before()
|
||||||
|
{
|
||||||
|
injector = Guice.createInjector(new KylinPluginModule());
|
||||||
|
configure = new Configure();
|
||||||
|
configure.setHost("127.0.0.1");
|
||||||
|
configure.setPort(7070);
|
||||||
|
configure.setDatabase(Optional.of("default"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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("Kylin"))
|
||||||
|
.findFirst();
|
||||||
|
if (pluginOptional.isPresent()) {
|
||||||
|
Plugin plugin = pluginOptional.get();
|
||||||
|
plugin.connect(configure);
|
||||||
|
System.out.println(plugin.execute("SHOW DATABASES"));
|
||||||
|
plugin.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,5 +24,6 @@
|
|||||||
<module>druid</module>
|
<module>druid</module>
|
||||||
<module>kyuubi</module>
|
<module>kyuubi</module>
|
||||||
<module>hive</module>
|
<module>hive</module>
|
||||||
|
<module>kylin</module>
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
</project>
|
@ -128,6 +128,11 @@
|
|||||||
<artifactId>datacap-plugin-jdbc-hive</artifactId>
|
<artifactId>datacap-plugin-jdbc-hive</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
|
||||||
|
<artifactId>datacap-plugin-jdbc-kylin</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -54,6 +54,7 @@ public class ExecuteServiceImpl
|
|||||||
_configure.setPort(entity.getPort());
|
_configure.setPort(entity.getPort());
|
||||||
_configure.setUsername(Optional.ofNullable(entity.getUsername()));
|
_configure.setUsername(Optional.ofNullable(entity.getUsername()));
|
||||||
_configure.setPassword(Optional.ofNullable(entity.getPassword()));
|
_configure.setPassword(Optional.ofNullable(entity.getPassword()));
|
||||||
|
_configure.setDatabase(Optional.ofNullable(entity.getDatabase()));
|
||||||
_configure.setEnv(Optional.ofNullable(configure.getEnv()));
|
_configure.setEnv(Optional.ofNullable(configure.getEnv()));
|
||||||
_configure.setFormat(configure.getFormat());
|
_configure.setFormat(configure.getFormat());
|
||||||
plugin.connect(_configure);
|
plugin.connect(_configure);
|
||||||
|
@ -73,6 +73,7 @@ public class SourceServiceImpl
|
|||||||
_configure.setPort(configure.getPort());
|
_configure.setPort(configure.getPort());
|
||||||
_configure.setUsername(Optional.ofNullable(configure.getUsername()));
|
_configure.setUsername(Optional.ofNullable(configure.getUsername()));
|
||||||
_configure.setPassword(Optional.ofNullable(configure.getPassword()));
|
_configure.setPassword(Optional.ofNullable(configure.getPassword()));
|
||||||
|
_configure.setDatabase(Optional.ofNullable(configure.getDatabase()));
|
||||||
_configure.setEnv(Optional.empty());
|
_configure.setEnv(Optional.empty());
|
||||||
_configure.setFormat(FormatType.JSON);
|
_configure.setFormat(FormatType.JSON);
|
||||||
plugin.connect(_configure);
|
plugin.connect(_configure);
|
||||||
|
BIN
shared/plugin/kylin.png
Normal file
BIN
shared/plugin/kylin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Loading…
Reference in New Issue
Block a user