mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-02 03:57:35 +08:00
[Plugin] Support tdengine for jdbc
This commit is contained in:
parent
d472a305fa
commit
d7a5f3288c
@ -87,6 +87,9 @@ Here are some of the major database solutions that are supported:
|
||||
</a>
|
||||
<a href="https://www.dameng.com/DM8.html" target="_blank">
|
||||
<img src="assets/plugin/dameng.png" alt="DaMeng" height="50" />
|
||||
</a>
|
||||
<a href="https://tdengine.com/" target="_blank">
|
||||
<img src="assets/plugin/tdengine.png" alt="TDengine" height="50" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
BIN
assets/plugin/tdengine.png
Normal file
BIN
assets/plugin/tdengine.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
37
docs/docs/reference/plugin/v120/tdengine.md
Normal file
37
docs/docs/reference/plugin/v120/tdengine.md
Normal file
@ -0,0 +1,37 @@
|
||||
#### What is TDengine ?
|
||||
|
||||
TDengine™ is an open-source, cloud-native time series database (TSDB) optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT. It enables efficient, real-time ingestion, processing, and monitoring of terabytes and even petabytes of data per day, generated by billions of sensors and data collectors.
|
||||
|
||||
#### Configure
|
||||
|
||||
---
|
||||
|
||||
!!! note
|
||||
|
||||
When you connect to a TDengine data source, you must configure the database user.
|
||||
|
||||
DataCap connects to TDengine by default
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.taosdata.jdbc</groupId>
|
||||
<artifactId>taos-jdbcdriver</artifactId>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
| Field | Required | Default Value |
|
||||
|------------|-------------------------|---------------|
|
||||
| - | **Configure** | - |
|
||||
| `Name` | :material-check-circle: | - |
|
||||
| `Host` | :material-check-circle: | - |
|
||||
| `Port` | :material-check-circle: | 0 |
|
||||
| - | **SSL** | - |
|
||||
| `SSL` | :material-check-circle: | `false` |
|
||||
| - | **授权** | - |
|
||||
| `UserName` | :material-check-circle: | `root` |
|
||||
|
||||
#### Version (Validation)
|
||||
|
||||
---
|
||||
|
||||
- [x] 3.0.x
|
@ -116,6 +116,7 @@ plugins:
|
||||
documentation_database_oracle: Oracle
|
||||
documentation_v120: 1.2.0-SNAPSHOT
|
||||
documentation_v120_plugin_cratedb: CrateDB
|
||||
documentation_v120_plugin_tdengine: TDengine
|
||||
release: 发布日志
|
||||
release_20221015: 1.0.0.20221015
|
||||
release_20221115: 1.1.0.20221115 (latest)
|
||||
@ -137,6 +138,7 @@ plugins:
|
||||
documentation_database_oracle: Oracle
|
||||
documentation_v120: 1.2.0-SNAPSHOT
|
||||
documentation_v120_plugin_cratedb: CrateDB
|
||||
documentation_v120_plugin_tdengine: TDengine
|
||||
release: Release Note
|
||||
release_20221015: 1.0.0.20221015
|
||||
release_20221115: 1.1.0.20221115 (latest)
|
||||
@ -162,6 +164,7 @@ nav:
|
||||
- documentation_database:
|
||||
- documentation_v120:
|
||||
- documentation_v120_plugin_cratedb: reference/plugin/v120/cratedb.md
|
||||
- documentation_v120_plugin_tdengine: reference/plugin/v120/tdengine.md
|
||||
- documentation_database_mysql: reference/database/mysql.md
|
||||
- documentation_database_clickhouse: reference/database/clickhouse.md
|
||||
- documentation_database_kylin: reference/database/kylin.md
|
||||
|
@ -36,5 +36,6 @@
|
||||
<module>oracle</module>
|
||||
<module>cratedb</module>
|
||||
<module>dm</module>
|
||||
<module>tdengine</module>
|
||||
</modules>
|
||||
</project>
|
61
plugin/jdbc/tdengine/pom.xml
Normal file
61
plugin/jdbc/tdengine/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.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>datacap-plugin-jdbc-tdengine</artifactId>
|
||||
<name>DataCap plugin for jdbc (TDengine)</name>
|
||||
|
||||
<properties>
|
||||
<tdengine.version>3.0.0</tdengine.version>
|
||||
<plugin.name>jdbc-tdengine</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.taosdata.jdbc</groupId>
|
||||
<artifactId>taos-jdbcdriver</artifactId>
|
||||
<version>${tdengine.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.tdengine;
|
||||
|
||||
import io.edurt.datacap.spi.adapter.JdbcAdapter;
|
||||
import io.edurt.datacap.spi.connection.JdbcConnection;
|
||||
|
||||
public class TDengineAdapter
|
||||
extends JdbcAdapter
|
||||
{
|
||||
public TDengineAdapter(JdbcConnection jdbcConnection)
|
||||
{
|
||||
super(jdbcConnection);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package io.edurt.datacap.plugin.jdbc.tdengine;
|
||||
|
||||
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 TDenginePlugin
|
||||
implements Plugin
|
||||
{
|
||||
private JdbcConfigure jdbcConfigure;
|
||||
private JdbcConnection connection;
|
||||
private Response response;
|
||||
|
||||
@Override
|
||||
public String name()
|
||||
{
|
||||
return "TDengine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description()
|
||||
{
|
||||
return "Integrate TDengine 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.taosdata.jdbc.TSDBDriver");
|
||||
this.jdbcConfigure.setJdbcType("TAOS-RS");
|
||||
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 tdengine plugin logic started");
|
||||
this.response = this.connection.getResponse();
|
||||
JdbcAdapter processor = new TDengineAdapter(this.connection);
|
||||
this.response = processor.handlerExecute(content);
|
||||
log.info("Execute tdengine 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.tdengine;
|
||||
|
||||
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 TDenginePluginModule
|
||||
extends AbstractPluginModule
|
||||
implements PluginModule
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "TDengine";
|
||||
}
|
||||
|
||||
@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(TDenginePlugin.class);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
io.edurt.datacap.plugin.jdbc.tdengine.TDenginePluginModule
|
@ -0,0 +1,30 @@
|
||||
package io.edurt.datacap.plugin.jdbc.tdengine;
|
||||
|
||||
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 TDenginePluginModuleTest
|
||||
{
|
||||
private Injector injector;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
this.injector = Guice.createInjector(new TDenginePluginModule());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
{
|
||||
Set<Plugin> plugins = injector.getInstance(Key.get(new TypeLiteral<Set<Plugin>>() {}));
|
||||
Assert.assertTrue(plugins.size() > 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package io.edurt.datacap.plugin.jdbc.tdengine;
|
||||
|
||||
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 TDenginePluginTest
|
||||
{
|
||||
private Injector injector;
|
||||
private Configure configure;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
injector = Guice.createInjector(new TDenginePluginModule());
|
||||
configure = new Configure();
|
||||
configure.setHost("127.0.0.1");
|
||||
configure.setPort(6030);
|
||||
configure.setUsername(Optional.of("root"));
|
||||
configure.setPassword(Optional.of("taosdata"));
|
||||
}
|
||||
|
||||
@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("TDengine"))
|
||||
.findFirst();
|
||||
if (pluginOptional.isPresent()) {
|
||||
Plugin plugin = pluginOptional.get();
|
||||
plugin.connect(configure);
|
||||
Assert.assertNotNull(plugin.execute(plugin.validator()).getConnection());
|
||||
plugin.destroy();
|
||||
}
|
||||
}
|
||||
}
|
@ -209,6 +209,11 @@
|
||||
<artifactId>datacap-plugin-http-clickhouse</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap.plugin.jdbc</groupId>
|
||||
<artifactId>datacap-plugin-jdbc-tdengine</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
5359
web/console-fe/package-lock.json
generated
5359
web/console-fe/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user