From c8ae75dd341ba258a90d2aa75f60d766fdcfef0a Mon Sep 17 00:00:00 2001
From: qianmoQ
Date: Thu, 27 Apr 2023 15:18:32 +0800
Subject: [PATCH 1/3] [Docs] Top scrolling notifications are supported
---
docs/docs/css/datacap.css | 146 ++++++++++++++++++++++++++++++++++++++
docs/docs/index.md | 8 ++-
docs/docs/index.zh.md | 8 ++-
docs/docs/js/datacap.js | 34 +++++++++
docs/mkdocs.yml | 15 +++-
docs/overrides/main.html | 81 +++++++++++++--------
6 files changed, 258 insertions(+), 34 deletions(-)
create mode 100644 docs/docs/css/datacap.css
create mode 100644 docs/docs/js/datacap.js
diff --git a/docs/docs/css/datacap.css b/docs/docs/css/datacap.css
new file mode 100644
index 000000000..5d9d6f8eb
--- /dev/null
+++ b/docs/docs/css/datacap.css
@@ -0,0 +1,146 @@
+.termynal-comment {
+ color: #4a968f;
+ font-style: italic;
+ display: block;
+}
+
+.termy {
+ /* For right to left languages */
+ direction: ltr;
+}
+
+.termy [data-termynal] {
+ white-space: pre-wrap;
+}
+
+a.external-link {
+ /* For right to left languages */
+ direction: ltr;
+ display: inline-block;
+}
+
+a.external-link::after {
+ /* \00A0 is a non-breaking space
+ to make the mark be on the same line as the link
+ */
+ content: "\00A0[↪]";
+}
+
+a.internal-link::after {
+ /* \00A0 is a non-breaking space
+ to make the mark be on the same line as the link
+ */
+ content: "\00A0↪";
+}
+
+.shadow {
+ box-shadow: 5px 5px 10px #999;
+}
+
+/* Give space to lower icons so Gitter chat doesn't get on top of them */
+.md-footer-meta {
+ padding-bottom: 2em;
+}
+
+.user-list {
+ display: flex;
+ flex-wrap: wrap;
+ margin-bottom: 2rem;
+}
+
+.user-list-center {
+ justify-content: space-evenly;
+}
+
+.user {
+ margin: 1em;
+ min-width: 7em;
+}
+
+.user .avatar-wrapper {
+ width: 80px;
+ height: 80px;
+ margin: 10px auto;
+ overflow: hidden;
+ border-radius: 50%;
+ position: relative;
+}
+
+.user .avatar-wrapper img {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+}
+
+.user .title {
+ text-align: center;
+}
+
+.user .count {
+ font-size: 80%;
+ text-align: center;
+}
+
+a.announce-link:link,
+a.announce-link:visited {
+ color: #fff;
+}
+
+a.announce-link:hover {
+ color: var(--md-accent-fg-color);
+}
+
+.announce-wrapper {
+ display: flex;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ align-items: center;
+}
+
+.announce-wrapper div.item {
+ display: none;
+}
+
+.announce-wrapper .sponsor-badge {
+ display: block;
+ position: absolute;
+ top: -10px;
+ right: 0;
+ font-size: 0.5rem;
+ color: #999;
+ background-color: #666;
+ border-radius: 10px;
+ padding: 0 10px;
+ z-index: 10;
+}
+
+.announce-wrapper .sponsor-image {
+ display: block;
+ border-radius: 20px;
+}
+
+.announce-wrapper > div {
+ min-height: 40px;
+ display: flex;
+ align-items: center;
+}
+
+.twitter {
+ color: #00acee;
+}
+
+/* Right to left languages */
+code {
+ direction: ltr;
+ display: inline-block;
+}
+
+.md-content__inner h1 {
+ direction: ltr !important;
+}
+
+.illustration {
+ margin-top: 2em;
+ margin-bottom: 2em;
+}
diff --git a/docs/docs/index.md b/docs/docs/index.md
index be795c354..6737b68c3 100644
--- a/docs/docs/index.md
+++ b/docs/docs/index.md
@@ -70,7 +70,13 @@ Datacap is fast, lightweight, intuitive system.
---
- DataCap can connect to any SQL based datasource through JDBC and native and http.
+ DataCap can connect to any SQL based datasource through JDBC and Native and Http.
+
+- __Highly Customizable__
+
+ ---
+
+ DataCap can quickly connect to new data sources by implementing the methods provided by SPI.
- __Join (DingTalk | WeChat)__
diff --git a/docs/docs/index.zh.md b/docs/docs/index.zh.md
index 5efd7b72e..b57aace74 100644
--- a/docs/docs/index.zh.md
+++ b/docs/docs/index.zh.md
@@ -70,7 +70,13 @@ Datacap 是快速、轻量级、直观的系统。
---
- DataCap 可以通过 JDBC, Native, http 连接到任何基于 SQL 的数据源。
+ DataCap 可以通过 JDBC, Native, Http 连接到任何基于 SQL 的数据源。
+
+- __高度定制化__
+
+ ---
+
+ DataCap 可以通过实现 SPI 提供的方式可以实现快速对接新的数据源。
- __加入 (钉钉 | 微信)__
diff --git a/docs/docs/js/datacap.js b/docs/docs/js/datacap.js
new file mode 100644
index 000000000..bcb98c2b4
--- /dev/null
+++ b/docs/docs/js/datacap.js
@@ -0,0 +1,34 @@
+function shuffle(array) {
+ let currentIndex = array.length, temporaryValue, randomIndex;
+ while (0 !== currentIndex) {
+ randomIndex = Math.floor(Math.random() * currentIndex);
+ currentIndex -= 1;
+ temporaryValue = array[currentIndex];
+ array[currentIndex] = array[randomIndex];
+ array[randomIndex] = temporaryValue;
+ }
+ return array;
+}
+
+function showRandomAnnouncement(groupId, timeInterval) {
+ const announceFastAPI = document.getElementById(groupId);
+ if (announceFastAPI) {
+ let children = [].slice.call(announceFastAPI.children);
+ children = shuffle(children)
+ let index = 0
+ const announceRandom = () => {
+ children.forEach((el, i) => {el.style.display = "none"});
+ children[index].style.display = "block"
+ index = (index + 1) % children.length
+ }
+ announceRandom()
+ setInterval(announceRandom, timeInterval)
+ }
+}
+
+async function main() {
+ showRandomAnnouncement('announce-left', 5000)
+ showRandomAnnouncement('announce-right', 10000)
+}
+
+main()
diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml
index dbcfa2717..2f668396c 100644
--- a/docs/mkdocs.yml
+++ b/docs/mkdocs.yml
@@ -6,7 +6,17 @@ site_description: >-
repo_name: EdurtIO/datacap
repo_url: https://github.com/EdurtIO/datacap
edit_uri: "https://github.com/EdurtIO/datacap/blob/dev/docs/docs"
-current_version: 1.8.0
+
+banners:
+ - title: DataCap 1.8.0 is released
+ link: /release-latest.html
+ description: Do you ❤️ DataCap? Give us a 🌟 on GitHub
+ - title: Support ceresdb
+ link: /reference/connectors/http/ceresdb.html
+ description: newsletter 🎉
+ - title: Support greptimedb
+ link: /reference/connectors/http/greptimedb.html
+ description: newsletter 🎉
copyright: Copyright © 2022 EdurtIO
@@ -65,6 +75,9 @@ extra:
lang: zh
extra_css:
- stylesheets/extra.css
+ - css/datacap.css
+extra_javascript:
+ - js/datacap.js
markdown_extensions:
- admonition
- abbr
diff --git a/docs/overrides/main.html b/docs/overrides/main.html
index 2efaafebb..cbe19cffa 100644
--- a/docs/overrides/main.html
+++ b/docs/overrides/main.html
@@ -3,22 +3,40 @@
-#}
{% extends "base.html" %}
{% block extrahead %}
-
-
+
+
{% endblock %}
{% block announce %}
-
+
+
+ {% for banner in config.banners %}
+
+ {% endfor %}
+
+
+
{% endblock %}
{% block content %}
@@ -44,30 +62,31 @@
{% endblock %}
From d3a1bc6a53ee064836d61d00b9344b045dbf35d4 Mon Sep 17 00:00:00 2001
From: qianmoQ
Date: Fri, 28 Apr 2023 15:19:09 +0800
Subject: [PATCH 2/3] [Plugin] Support apache hadoop hdfs
---
.gitignore | 4 +
README.md | 3 +
core/datacap-server/pom.xml | 5 +
.../src/main/etc/conf/application.properties | 4 +
.../main/etc/conf/plugins/native/hdfs.yaml | 26 ++++
.../server/common/IConfigureCommon.java | 6 +
.../controller/user/SourceController.java | 54 ++++++-
.../datacap/server/entity/SourceEntity.java | 3 +
.../plugin/configure/IConfigureFieldName.java | 1 +
.../plugin/configure/IConfigureFieldType.java | 3 +-
.../service/impl/ExecuteServiceImpl.java | 16 ++-
.../service/impl/SourceServiceImpl.java | 62 +++++++-
.../src/main/resources/schema.sql | 20 ++-
.../src/main/schema/1.9.0/update.sql | 1 +
.../src/main/schema/datacap.sql | 5 +-
.../java/io/edurt/datacap/spi/Plugin.java | 10 +-
.../io/edurt/datacap/spi/PluginModule.java | 7 +-
.../io/edurt/datacap/spi/model/Configure.java | 4 +
.../public/static/images/plugin/Hdfs.png | Bin 0 -> 27101 bytes
.../console-fe/src/i18n/langs/en/common.ts | 4 +-
.../console-fe/src/i18n/langs/zhCn/common.ts | 4 +-
.../console-fe/src/model/SourceModel.ts | 1 +
.../views/pages/admin/source/SourceDetail.vue | 29 +++-
docs/docs/assets/plugin/hdfs.png | Bin 0 -> 27101 bytes
docs/docs/index.md | 3 +
docs/docs/index.zh.md | 3 +
.../connectors/native/hadoop/hdfs.md | 50 +++++++
docs/mkdocs.yml | 2 +
plugin/datacap-native-hdfs/pom.xml | 132 ++++++++++++++++++
.../edurt/datacap/natived/hdfs/HdfsAdapter.kt | 95 +++++++++++++
.../datacap/natived/hdfs/HdfsConnection.kt | 49 +++++++
.../edurt/datacap/natived/hdfs/HdfsModule.kt | 23 +++
.../edurt/datacap/natived/hdfs/HdfsPlugin.kt | 63 +++++++++
.../io.edurt.datacap.spi.PluginModule | 1 +
.../datacap/natived/hdfs/HdfsModuleTest.kt | 27 ++++
.../datacap/natived/hdfs/HdfsPluginTest.kt | 48 +++++++
.../src/test/resources/default/core-site.xml | 61 ++++++++
.../src/test/resources/default/hdfs-site.xml | 28 ++++
pom.xml | 3 +-
39 files changed, 836 insertions(+), 24 deletions(-)
create mode 100644 core/datacap-server/src/main/etc/conf/plugins/native/hdfs.yaml
create mode 100644 core/datacap-server/src/main/schema/1.9.0/update.sql
create mode 100644 core/datacap-web/console-fe/public/static/images/plugin/Hdfs.png
create mode 100644 docs/docs/assets/plugin/hdfs.png
create mode 100644 docs/docs/reference/connectors/native/hadoop/hdfs.md
create mode 100644 plugin/datacap-native-hdfs/pom.xml
create mode 100644 plugin/datacap-native-hdfs/src/main/kotlin/io/edurt/datacap/natived/hdfs/HdfsAdapter.kt
create mode 100644 plugin/datacap-native-hdfs/src/main/kotlin/io/edurt/datacap/natived/hdfs/HdfsConnection.kt
create mode 100644 plugin/datacap-native-hdfs/src/main/kotlin/io/edurt/datacap/natived/hdfs/HdfsModule.kt
create mode 100644 plugin/datacap-native-hdfs/src/main/kotlin/io/edurt/datacap/natived/hdfs/HdfsPlugin.kt
create mode 100644 plugin/datacap-native-hdfs/src/main/resources/META-INF/services/io.edurt.datacap.spi.PluginModule
create mode 100644 plugin/datacap-native-hdfs/src/test/kotlin/io/edurt/datacap/natived/hdfs/HdfsModuleTest.kt
create mode 100644 plugin/datacap-native-hdfs/src/test/kotlin/io/edurt/datacap/natived/hdfs/HdfsPluginTest.kt
create mode 100644 plugin/datacap-native-hdfs/src/test/resources/default/core-site.xml
create mode 100644 plugin/datacap-native-hdfs/src/test/resources/default/hdfs-site.xml
diff --git a/.gitignore b/.gitignore
index 5eae0a6ec..cbc39e5fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,3 +45,7 @@ list
# shaded #
shaded/*/dependency-reduced-pom.xml
+
+# datacap #
+cache/
+config/
diff --git a/README.md b/README.md
index 8982e1065..8e57e0ea6 100644
--- a/README.md
+++ b/README.md
@@ -175,6 +175,9 @@ Here are some of the major database solutions that are supported:
+
+
+
diff --git a/core/datacap-server/pom.xml b/core/datacap-server/pom.xml
index 5b9e80879..50e82a048 100644
--- a/core/datacap-server/pom.xml
+++ b/core/datacap-server/pom.xml
@@ -345,6 +345,11 @@
datacap-jdbc-hologres
${project.version}
+
+ io.edurt.datacap
+ datacap-native-hdfs
+ ${project.version}
+
io.edurt.datacap
diff --git a/core/datacap-server/src/main/etc/conf/application.properties b/core/datacap-server/src/main/etc/conf/application.properties
index 7dce293a6..04e0b4f5a 100644
--- a/core/datacap-server/src/main/etc/conf/application.properties
+++ b/core/datacap-server/src/main/etc/conf/application.properties
@@ -40,3 +40,7 @@ spring.redis.database=0
### If this directory is not set, the system will get the project root directory to build the data subdirectory
datacap.executor.data=
datacap.executor.seatunnel.home=/opt/lib/seatunnel
+
+################################ Upload configure #################################
+datacap.config.data=
+datacap.cache.data=
diff --git a/core/datacap-server/src/main/etc/conf/plugins/native/hdfs.yaml b/core/datacap-server/src/main/etc/conf/plugins/native/hdfs.yaml
new file mode 100644
index 000000000..d4a67c22b
--- /dev/null
+++ b/core/datacap-server/src/main/etc/conf/plugins/native/hdfs.yaml
@@ -0,0 +1,26 @@
+name: HDFS
+supportTime: '2023-04-27'
+configures:
+ - field: name
+ type: String
+ required: true
+ message: name is a required field, please be sure to enter
+ - field: host
+ type: String
+ required: true
+ value: '-'
+ disabled: true
+ message: host is a required field, please be sure to enter
+ - field: port
+ type: Number
+ required: true
+ min: 1
+ max: 65535
+ value: 1
+ disabled: true
+ message: port is a required field, please be sure to enter
+ - field: file
+ type: File
+ required: true
+ value: []
+ group: advanced
diff --git a/core/datacap-server/src/main/java/io/edurt/datacap/server/common/IConfigureCommon.java b/core/datacap-server/src/main/java/io/edurt/datacap/server/common/IConfigureCommon.java
index 7e17638e7..b4e9bf8fe 100644
--- a/core/datacap-server/src/main/java/io/edurt/datacap/server/common/IConfigureCommon.java
+++ b/core/datacap-server/src/main/java/io/edurt/datacap/server/common/IConfigureCommon.java
@@ -65,6 +65,9 @@ public static Configure preparedConfigure(List configures)
case configures:
configure.setEnv(Optional.ofNullable(IConfigureCommon.getMapValue(configures, IConfigureFieldName.configures)));
break;
+ case file:
+ configure.setUsedConfig(true);
+ break;
}
});
configure.setFormat(FormatType.JSON);
@@ -149,6 +152,9 @@ public static SourceEntity preparedSourceEntity(List configures
case configures:
configure.setConfigure(JSON.toJSON(IConfigureCommon.getMapValue(configures, IConfigureFieldName.configures)));
break;
+ case file:
+ configure.setUsedConfig(true);
+ break;
}
});
configure.setCreateTime(Timestamp.from(Instant.now()));
diff --git a/core/datacap-server/src/main/java/io/edurt/datacap/server/controller/user/SourceController.java b/core/datacap-server/src/main/java/io/edurt/datacap/server/controller/user/SourceController.java
index e9b70d4b7..47ed2859f 100644
--- a/core/datacap-server/src/main/java/io/edurt/datacap/server/controller/user/SourceController.java
+++ b/core/datacap-server/src/main/java/io/edurt/datacap/server/controller/user/SourceController.java
@@ -1,12 +1,19 @@
package io.edurt.datacap.server.controller.user;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.edurt.datacap.server.body.SharedSourceBody;
import io.edurt.datacap.server.common.Response;
import io.edurt.datacap.server.entity.PageEntity;
import io.edurt.datacap.server.entity.PluginEntity;
import io.edurt.datacap.server.entity.SourceEntity;
+import io.edurt.datacap.server.entity.UserEntity;
+import io.edurt.datacap.server.security.UserDetailsService;
import io.edurt.datacap.server.service.SourceService;
import io.edurt.datacap.server.validation.ValidationGroup;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.core.env.Environment;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@@ -16,22 +23,30 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.File;
+import java.io.IOException;
import java.util.List;
import java.util.Map;
+@SuppressFBWarnings(value = {"RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"})
@RestController()
@RequestMapping(value = "/api/v1/source")
+@Slf4j
public class SourceController
{
private final SourceService sourceService;
+ private final Environment environment;
- public SourceController(SourceService sourceService)
+ public SourceController(SourceService sourceService, Environment environment)
{
this.sourceService = sourceService;
+ this.environment = environment;
}
@Deprecated
@@ -49,8 +64,7 @@ public Response update(@RequestBody @Validated(ValidationGroup.Cru
}
@GetMapping
- public Response> getAll(@RequestParam(value = "page", defaultValue = "1") int start,
- @RequestParam(value = "size", defaultValue = "10") int end)
+ public Response> getAll(@RequestParam(value = "page", defaultValue = "1") int start, @RequestParam(value = "size", defaultValue = "10") int end)
{
return this.sourceService.getAll(start, end);
}
@@ -86,4 +100,38 @@ public Response