You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2025/05/28 12:16:58 UTC
(streampark) branch dev updated: [Improve] implicitUtil improvement (#4243)
This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new 7983e0ac7 [Improve] implicitUtil improvement (#4243)
7983e0ac7 is described below
commit 7983e0ac742e3b64b2bf56cd3d737908136952c2
Author: benjobs <be...@apache.org>
AuthorDate: Wed May 28 20:16:52 2025 +0800
[Improve] implicitUtil improvement (#4243)
* [Improve] implicitUtil improvement
* Update Implicits.scala
---
.../apache/streampark/common/util/FileUtils.scala | 12 +-
.../apache/streampark/common/util/Implicits.scala | 21 +-
.../org/apache/streampark/common/util/Utils.scala | 3 +-
.../streampark/common/util/ImplicitsTest.scala | 4 +-
.../streampark-console-service/pom.xml | 18 --
.../core/controller/DatabaseController.java | 67 -----
.../core/controller/FlinkCatalogController.java | 92 ------
.../console/core/controller/TableController.java | 134 ---------
.../console/core/entity/Application.java | 48 ---
.../streampark/console/core/entity/Database.java | 38 ---
.../console/core/entity/DistributedTask.java | 47 ---
.../console/core/entity/FlinkApplication.java | 4 +-
.../console/core/entity/SparkApplication.java | 2 +-
.../console/core/mapper/ApplicationMapper.java | 26 --
.../console/core/mapper/DatabaseMapper.java | 28 --
.../console/core/mapper/DistributedTaskMapper.java | 25 --
.../console/core/runner/EnvInitializer.java | 16 -
.../console/core/service/DatabaseService.java | 60 ----
.../core/service/DistributedTaskService.java | 74 -----
.../console/core/service/FlinkCatalogBase.java | 293 ------------------
.../console/core/service/FlinkCatalogService.java | 61 ----
.../console/core/service/RegistryService.java | 31 --
.../console/core/service/TableService.java | 122 --------
.../service/application/ApplicationService.java | 28 --
.../application/impl/ApplicationServiceImpl.java | 49 ---
.../impl/FlinkApplicationActionServiceImpl.java | 31 --
.../impl/FlinkApplicationManageServiceImpl.java | 13 -
.../impl/SparkApplicationActionServiceImpl.java | 30 --
.../impl/SparkApplicationManageServiceImpl.java | 13 -
.../core/service/impl/DatabaseServiceImpl.java | 123 --------
.../service/impl/DistributedTaskServiceImpl.java | 297 -------------------
.../core/service/impl/FlinkCatalogServiceImpl.java | 144 ---------
.../core/service/impl/RegistryServiceImpl.java | 206 -------------
.../core/service/impl/TableServiceImpl.java | 306 -------------------
.../console/core/util/CatalogServiceUtils.java | 81 -----
.../console/core/watcher/FlinkAppHttpWatcher.java | 12 +-
.../console/core/watcher/FlinkClusterWatcher.java | 2 +-
.../console/core/watcher/SparkAppHttpWatcher.java | 12 +-
.../src/main/resources/config.yaml | 38 ---
.../src/main/resources/db/schema-h2.sql | 17 --
.../console/core/service/DatabaseServiceTest.java | 152 ----------
.../core/service/DistributedTaskServiceTest.java | 90 ------
.../core/service/FlinkCatalogServiceTest.java | 119 --------
.../console/core/service/RegistryServiceTest.java | 46 ---
.../console/core/service/TableServiceTest.java | 327 ---------------------
.../core/service/container/MySqlContainer.java | 167 -----------
.../core/service/container/MysqlBaseITCASE.java | 62 ----
.../resources/application-integration-test.yml | 61 ----
.../src/test/resources/application-test.yml | 38 ---
.../src/test/resources/docker/server/my.cnf | 64 ----
.../src/test/resources/docker/setup.sql | 41 ---
streampark-flink/pom.xml | 2 -
.../streampark-flink-catalog-store/pom.xml | 169 -----------
.../apache/streampark/catalog/JacksonUtils.java | 54 ----
.../streampark/catalog/JdbcCatalogStore.java | 175 -----------
.../catalog/JdbcCatalogStoreFactory.java | 101 -------
.../catalog/JdbcCatalogStoreFactoryOptions.java | 71 -----
.../catalog/connections/JdbcConnectionOptions.java | 153 ----------
.../connections/JdbcConnectionProvider.java | 85 ------
.../connections/SimpleJdbcConnectionProvider.java | 150 ----------
.../org.apache.flink.table.factories.Factory | 16 -
.../catalog/JdbcCatalogStoreFactoryTest.java | 56 ----
.../streampark/catalog/JdbcCatalogStoreTest.java | 137 ---------
.../streampark/catalog/mysql/MySqlContainer.java | 175 -----------
.../streampark/catalog/mysql/MysqlBaseITCASE.java | 57 ----
.../src/test/resources/docker/server/my.cnf | 64 ----
.../src/test/resources/docker/setup.sql | 41 ---
.../streampark-flink-connector-plugin/pom.xml | 96 ------
.../java/org/apache/streampark/package-info.java | 21 --
.../java/org/apache/streampark/package-info.java | 21 --
.../flink/kubernetes/KubernetesRetriever.scala | 4 +-
.../helper/KubernetesDeploymentHelper.scala | 10 +-
.../kubernetes/ingress/IngressController.scala | 4 +-
.../kubernetes/ingress/IngressStrategyV1.scala | 8 +-
.../ingress/IngressStrategyV1beta1.scala | 8 +-
.../impl/FlinkYarnApplicationBuildPipeline.scala | 2 +-
.../pipeline/impl/SparkYarnBuildPipeline.scala | 2 +-
.../streampark/flink/proxy/FlinkShimsProxy.scala | 4 +-
.../streampark-flink-shims_flink-1.18/pom.xml | 6 -
.../streampark-flink-shims_flink-1.19/pom.xml | 7 -
.../spark/client/proxy/SparkShimsProxy.scala | 4 +-
81 files changed, 54 insertions(+), 5444 deletions(-)
diff --git a/streampark-common/src/main/scala/org/apache/streampark/common/util/FileUtils.scala b/streampark-common/src/main/scala/org/apache/streampark/common/util/FileUtils.scala
index fbeb6f412..5e6311dbb 100644
--- a/streampark-common/src/main/scala/org/apache/streampark/common/util/FileUtils.scala
+++ b/streampark-common/src/main/scala/org/apache/streampark/common/util/FileUtils.scala
@@ -51,7 +51,7 @@ object FileUtils {
if (input == null) {
throw new RuntimeException("The inputStream can not be null")
}
- input.autoClose(in => {
+ input.using(in => {
val b = new Array[Byte](4)
in.read(b, 0, b.length)
bytesToHexString(b)
@@ -174,7 +174,7 @@ object FileUtils {
@throws[IOException]
def readInputStream(in: InputStream, array: Array[Byte]): Unit = {
- in.autoClose(is => {
+ in.using(is => {
var toRead = array.length
var ret = 0
var off = 0
@@ -196,7 +196,7 @@ object FileUtils {
val array = new Array[Byte](len.toInt)
Files
.newInputStream(file.toPath)
- .autoClose(is => {
+ .using(is => {
readInputStream(is, array)
new String(array, StandardCharsets.UTF_8)
})
@@ -215,7 +215,7 @@ object FileUtils {
@throws[IOException]
def readEndOfFile(file: File, maxSize: Long): Array[Byte] = {
var readSize = maxSize
- new RandomAccessFile(file, "r").autoClose(raFile => {
+ new RandomAccessFile(file, "r").using(raFile => {
if (raFile.length > maxSize) {
raFile.seek(raFile.length - maxSize)
} else if (raFile.length < maxSize) {
@@ -249,7 +249,7 @@ object FileUtils {
throw new IllegalArgumentException(
s"The startOffset $startOffset is great than the file length ${file.length}")
}
- new RandomAccessFile(file, "r").autoClose(raFile => {
+ new RandomAccessFile(file, "r").using(raFile => {
val readSize = Math.min(maxSize, file.length - startOffset)
raFile.seek(startOffset)
val fileContent = new Array[Byte](readSize.toInt)
@@ -275,7 +275,7 @@ object FileUtils {
if (file.exists && file.isFile) {
Files
.lines(Paths.get(path))
- .autoClose(stream =>
+ .using(stream =>
stream
.skip(offset)
.limit(limit)
diff --git a/streampark-common/src/main/scala/org/apache/streampark/common/util/Implicits.scala b/streampark-common/src/main/scala/org/apache/streampark/common/util/Implicits.scala
index 40db96ae5..382e65e8f 100644
--- a/streampark-common/src/main/scala/org/apache/streampark/common/util/Implicits.scala
+++ b/streampark-common/src/main/scala/org/apache/streampark/common/util/Implicits.scala
@@ -17,12 +17,11 @@
package org.apache.streampark.common.util
-import org.apache.streampark.common.util.Utils.close
-
import java.lang.{Boolean => JavaBool, Double => JavaDouble, Float => JavaFloat, Integer => JavaInt, Long => JavaLong, Short => JavaShort}
import scala.collection.convert.{DecorateAsJava, DecorateAsScala, ToJavaImplicits, ToScalaImplicits}
import scala.language.implicitConversions
+import scala.util.Try
object Implicits extends ToScalaImplicits with ToJavaImplicits with DecorateAsJava with DecorateAsScala {
@@ -55,17 +54,25 @@ object Implicits extends ToScalaImplicits with ToJavaImplicits with DecorateAsJa
type JavaShort = java.lang.Short
implicit class AutoCloseImplicits[T <: AutoCloseable](autoCloseable: T) {
-
- implicit def autoClose[R](func: T => R)(implicit excFunc: Throwable => R = null): R = {
+ implicit def using[R](func: T => R)(implicit excFunc: Throwable => R = null): R = {
+ var exception: Option[Throwable] = Option.empty
try {
func(autoCloseable)
} catch {
- case e: Throwable if excFunc != null => excFunc(e)
+ case e: Throwable =>
+ exception = Some(e)
+ if (excFunc != null) {
+ excFunc(e)
+ } else {
+ throw e
+ }
} finally {
- close(autoCloseable)
+ Try(autoCloseable.close()).recover { case e =>
+ exception.foreach(originalEx => e.addSuppressed(originalEx))
+ throw e
+ }
}
}
-
}
implicit class StringImplicits(v: String) {
diff --git a/streampark-common/src/main/scala/org/apache/streampark/common/util/Utils.scala b/streampark-common/src/main/scala/org/apache/streampark/common/util/Utils.scala
index 60eb183f5..36b5ca5ac 100644
--- a/streampark-common/src/main/scala/org/apache/streampark/common/util/Utils.scala
+++ b/streampark-common/src/main/scala/org/apache/streampark/common/util/Utils.scala
@@ -18,7 +18,6 @@
package org.apache.streampark.common.util
import org.apache.streampark.common.util.Implicits._
-import org.apache.streampark.common.util.Implicits.AutoCloseImplicits
import org.apache.commons.lang3.StringUtils
@@ -75,7 +74,7 @@ object Utils extends Logger {
def getJarManifest(jarFile: File): jar.Manifest = {
requireCheckJarFile(jarFile.toURL)
new JarInputStream(new BufferedInputStream(new FileInputStream(jarFile)))
- .autoClose(_.getManifest)
+ .using(_.getManifest)
}
def getJarManClass(jarFile: File): String = {
diff --git a/streampark-common/src/test/scala/org/apache/streampark/common/util/ImplicitsTest.scala b/streampark-common/src/test/scala/org/apache/streampark/common/util/ImplicitsTest.scala
index 7a36475fa..6c922a082 100644
--- a/streampark-common/src/test/scala/org/apache/streampark/common/util/ImplicitsTest.scala
+++ b/streampark-common/src/test/scala/org/apache/streampark/common/util/ImplicitsTest.scala
@@ -23,7 +23,7 @@ import org.scalatest.funsuite.AnyFunSuite
class ImplicitsTest extends AnyFunSuite {
test(
- "AutoCloseImplicits.autoClose should close the resource after execution and handle exceptions") {
+ "AutoCloseImplicits.using should close the resource after execution and handle exceptions") {
class MockResource extends AutoCloseable {
var closed = false
def close(): Unit = closed = true
@@ -35,7 +35,7 @@ class ImplicitsTest extends AnyFunSuite {
val mockResource = new MockResource
assertThrows[RuntimeException] {
- mockResource.autoClose(operation)
+ mockResource.using(operation)
}
assert(mockResource.closed)
}
diff --git a/streampark-console/streampark-console-service/pom.xml b/streampark-console/streampark-console-service/pom.xml
index a9cbafe11..ea09556ea 100644
--- a/streampark-console/streampark-console-service/pom.xml
+++ b/streampark-console/streampark-console-service/pom.xml
@@ -479,18 +479,6 @@
<version>${testcontainer.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.streampark</groupId>
- <artifactId>streampark-flink-connector-plugin</artifactId>
- <version>2.2.0-SNAPSHOT</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.xerial.snappy</groupId>
- <artifactId>snappy-java</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-kubernetes</artifactId>
@@ -612,12 +600,6 @@
<version>${project.version}</version>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</dependency>
- <dependency>
- <groupId>org.apache.streampark</groupId>
- <artifactId>streampark-flink-connector-plugin</artifactId>
- <version>${project.version}</version>
- <outputDirectory>${project.build.directory}/plugins</outputDirectory>
- </dependency>
</artifactItems>
</configuration>
<executions>
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/DatabaseController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/DatabaseController.java
deleted file mode 100644
index c20a3006c..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/DatabaseController.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.controller;
-
-import org.apache.streampark.console.base.domain.RestRequest;
-import org.apache.streampark.console.base.domain.RestResponse;
-import org.apache.streampark.console.core.bean.DatabaseParam;
-import org.apache.streampark.console.core.service.DatabaseService;
-
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.io.IOException;
-import java.util.List;
-
-@Slf4j
-@Validated
-@RestController
-@RequestMapping("flink/database")
-public class DatabaseController {
-
- @Autowired
- private DatabaseService databaseService;
-
- @PostMapping("create")
- @RequiresPermissions("database:create")
- public RestResponse create(DatabaseParam databaseParam) throws IOException {
- boolean saved = databaseService.createDatabase(databaseParam);
- return RestResponse.success(saved);
- }
-
- @PostMapping("list")
- @RequiresPermissions("database:view")
- public RestResponse list(DatabaseParam databaseParam, RestRequest request) {
- List<DatabaseParam> databaseParamList =
- databaseService.listDatabases(databaseParam.getCatalogId());
- return RestResponse.success(databaseParamList);
- }
-
- @PostMapping("delete")
- @RequiresPermissions("database:delete")
- public RestResponse remove(DatabaseParam databaseParam) {
- boolean deleted = databaseService.dropDatabase(databaseParam);
- return RestResponse.success(deleted);
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkCatalogController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkCatalogController.java
deleted file mode 100644
index c8021935b..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkCatalogController.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.controller;
-
-import org.apache.streampark.console.base.domain.RestRequest;
-import org.apache.streampark.console.base.domain.RestResponse;
-import org.apache.streampark.console.core.annotation.Permission;
-import org.apache.streampark.console.core.bean.FlinkCatalogParams;
-import org.apache.streampark.console.core.entity.FlinkCatalog;
-import org.apache.streampark.console.core.service.FlinkCatalogService;
-import org.apache.streampark.console.core.util.ServiceHelper;
-
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.io.IOException;
-
-@Slf4j
-@Validated
-@RestController
-@RequestMapping("flink/catalog")
-public class FlinkCatalogController {
-
- @Autowired
- FlinkCatalogService catalogService;
-
- @Permission(team = "#catalog.teamId")
- @PostMapping("create")
- @RequiresPermissions("catalog:create")
- public RestResponse create(FlinkCatalogParams catalog) throws IOException {
- Long userId = ServiceHelper.getUserId();
- boolean saved = catalogService.create(catalog, userId);
- return RestResponse.success(saved);
- }
-
- @PostMapping("list")
- @Permission(team = "#app.teamId")
- @RequiresPermissions("catalog:view")
- public RestResponse list(FlinkCatalogParams catalog, RestRequest request) {
- IPage<FlinkCatalogParams> catalogList = catalogService.page(catalog, request);
- return RestResponse.success(catalogList);
- }
-
- @GetMapping("get/{catalogName}")
- @Permission(team = "#teamId")
- @RequiresPermissions("catalog:view")
- public RestResponse get(@PathVariable String catalogName, Long teamId) {
- FlinkCatalog catalog = catalogService.getCatalog(catalogName);
- return RestResponse.success(FlinkCatalogParams.of(catalog));
- }
-
- @PostMapping("delete")
- @Permission(team = "#app.teamId")
- @RequiresPermissions("catalog:delete")
- public RestResponse remove(FlinkCatalogParams catalog, RestRequest request) {
- boolean deleted = catalogService.remove(catalog.getId());
- return RestResponse.success(deleted);
- }
-
- @PostMapping("update")
- @Permission(team = "#app.teamId")
- @RequiresPermissions("catalog:update")
- public RestResponse update(FlinkCatalogParams catalog) {
- Long userId = ServiceHelper.getUserId();
- boolean updated = catalogService.update(catalog, userId);
- return RestResponse.success(updated);
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/TableController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/TableController.java
deleted file mode 100644
index 491cb961f..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/TableController.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.controller;
-
-import org.apache.streampark.console.base.domain.RestResponse;
-import org.apache.streampark.console.core.bean.TableParams;
-import org.apache.streampark.console.core.service.TableService;
-
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.TreeMap;
-import java.util.stream.Collectors;
-
-@Slf4j
-@Validated
-@RestController
-@RequestMapping("flink/table")
-public class TableController {
-
- @Autowired
- private TableService tableService;
-
- @PostMapping("create")
- @RequiresPermissions("table:create")
- public RestResponse createTable(TableParams table) {
- boolean saved = tableService.createTable(table);
- return RestResponse.success(saved);
- }
-
- @PostMapping("column/add")
- @RequiresPermissions("table:column:add")
- public RestResponse addColumn(TableParams table) {
- boolean saved = tableService.addColumn(table);
- return RestResponse.success(saved);
- }
-
- @GetMapping("column/list")
- @RequiresPermissions("table:column:list")
- public RestResponse listColumns(
- @RequestParam String catalogName,
- @RequestParam String databaseName,
- @RequestParam String tableName) {
- TableParams tableParams = tableService.listColumns(catalogName, databaseName, tableName);
- return RestResponse.success(tableParams);
- }
-
- @DeleteMapping("column/drop/{catalogName}/{databaseName}/{tableName}/{columnName}")
- @RequiresPermissions("table:column:drop")
- public RestResponse dropColumns(
- @PathVariable String catalogName,
- @PathVariable String databaseName,
- @PathVariable String tableName,
- @PathVariable String columnName) {
- boolean dropped = tableService.dropColumn(catalogName, databaseName, tableName, columnName);
- return RestResponse.success(dropped);
- }
-
- @PostMapping("option/add")
- @RequiresPermissions("option:add")
- public RestResponse addOption(TableParams table) {
- boolean addedOption = tableService.addOption(table);
- return RestResponse.success(addedOption);
- }
-
- @PostMapping("option/remove")
- @RequiresPermissions("option:remove")
- public RestResponse removeOption(
- @RequestParam String catalogName,
- @RequestParam String databaseName,
- @RequestParam String tableName,
- @RequestParam String key) {
- boolean removedOption = tableService.removeOption(catalogName, databaseName, tableName, key);
- return RestResponse.success(removedOption);
- }
-
- @PostMapping("rename")
- @RequiresPermissions("table:update")
- public RestResponse renameTable(
- @RequestParam String catalogName,
- @RequestParam String databaseName,
- @RequestParam String fromTableName,
- @RequestParam String toTableName) {
- boolean renamedOption =
- tableService.renameTable(catalogName, databaseName, fromTableName, toTableName);
- return RestResponse.success(renamedOption);
- }
-
- @PostMapping("list")
- @RequiresPermissions("table:view")
- public RestResponse listTable(TableParams table) {
- List<TableParams> tableParamsList = tableService.listTables(table);
- if (Objects.nonNull(table.getCatalogId()) && Objects.nonNull(table.getDatabaseName())) {
- return RestResponse.success(tableParamsList);
- } else {
- TreeMap<Long, Map<String, List<TableParams>>> collect =
- tableParamsList.stream()
- .collect(
- Collectors.groupingBy(
- TableParams::getCatalogId,
- TreeMap::new,
- Collectors.groupingBy(TableParams::getDatabaseName)));
- return RestResponse.success(collect);
- }
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
deleted file mode 100644
index 9d5e9862c..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.extern.slf4j.Slf4j;
-
-import java.io.Serializable;
-import java.util.Date;
-
-@Getter
-@Setter
-@TableName("t_app")
-@Slf4j
-public class Application implements Serializable {
-
- @TableId(type = IdType.AUTO)
- private Long id;
- /**
- * 1: flink job
- * 2: spark job
- */
- private Integer jobType;
-
- private Date createTime;
-
- private Date modifyTime;
-
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Database.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Database.java
deleted file mode 100644
index fcd507c3d..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Database.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.entity;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class Database {
-
- private String name;
-
- private Integer catalogId;
-
- private String catalogName;
-
- private String description;
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/DistributedTask.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/DistributedTask.java
deleted file mode 100644
index a70be2bd8..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/DistributedTask.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.entity;
-
-import org.apache.streampark.console.core.enums.DistributedTaskEnum;
-import org.apache.streampark.console.core.enums.EngineTypeEnum;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.extern.slf4j.Slf4j;
-
-import java.io.Serializable;
-
-@Getter
-@Setter
-@TableName("t_distributed_task")
-@Slf4j
-public class DistributedTask implements Serializable {
-
- @TableId(type = IdType.AUTO)
- private Long id;
-
- private DistributedTaskEnum action;
-
- private EngineTypeEnum engineType;
-
- private String properties;
-
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkApplication.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkApplication.java
index a88cc25a9..c7fa347fa 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkApplication.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkApplication.java
@@ -65,7 +65,7 @@ import java.util.Optional;
@Slf4j
public class FlinkApplication extends BaseEntity {
- @TableId(type = IdType.INPUT)
+ @TableId(type = IdType.AUTO)
private Long id;
private Long teamId;
@@ -292,9 +292,9 @@ public class FlinkApplication extends BaseEntity {
private transient String savepointPath;
private transient Boolean restoreOrTriggerSavepoint = false;
private transient Boolean drain = false;
- private transient Boolean nativeFormat = false;
private transient Long savepointTimeout = 60L;
private transient Boolean allowNonRestored = false;
+ private transient Boolean nativeFormat = false;
private transient Integer restoreMode;
private transient String socketId;
private transient String projectName;
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java
index 80937fdf5..f048c5712 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java
@@ -62,7 +62,7 @@ import java.util.Objects;
@Slf4j
public class SparkApplication extends BaseEntity {
- @TableId(type = IdType.INPUT)
+ @TableId(type = IdType.AUTO)
private Long id;
private Long teamId;
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/ApplicationMapper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/ApplicationMapper.java
deleted file mode 100644
index 48820fe3b..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/ApplicationMapper.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.mapper;
-
-import org.apache.streampark.console.core.entity.Application;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-public interface ApplicationMapper extends BaseMapper<Application> {
-
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/DatabaseMapper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/DatabaseMapper.java
deleted file mode 100644
index d8d26eb06..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/DatabaseMapper.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.mapper;
-
-import org.apache.streampark.console.core.entity.Database;
-
-import org.apache.ibatis.annotations.Mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-@Mapper
-public interface DatabaseMapper extends BaseMapper<Database> {
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/DistributedTaskMapper.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/DistributedTaskMapper.java
deleted file mode 100644
index a9318e93f..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/DistributedTaskMapper.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.mapper;
-
-import org.apache.streampark.console.core.entity.DistributedTask;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-public interface DistributedTaskMapper extends BaseMapper<DistributedTask> {
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/runner/EnvInitializer.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/runner/EnvInitializer.java
index e4300cc64..4e5ba38ac 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/runner/EnvInitializer.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/runner/EnvInitializer.java
@@ -26,11 +26,9 @@ import org.apache.streampark.common.enums.StorageType;
import org.apache.streampark.common.fs.FsOperator;
import org.apache.streampark.common.util.AssertUtils;
import org.apache.streampark.common.util.SystemPropertyUtils;
-import org.apache.streampark.console.base.util.SpringContextUtils;
import org.apache.streampark.console.base.util.WebUtils;
import org.apache.streampark.console.core.entity.FlinkEnv;
import org.apache.streampark.console.core.entity.SparkEnv;
-import org.apache.streampark.console.core.service.RegistryService;
import org.apache.streampark.console.core.service.SettingService;
import org.apache.commons.lang3.StringUtils;
@@ -83,9 +81,6 @@ public class EnvInitializer implements ApplicationRunner {
// init InternalConfig
initConfig();
- // init RegistryService
- initRegistryService();
-
boolean isTest = Arrays.asList(context.getEnvironment().getActiveProfiles()).contains("test");
if (!isTest) {
// initialize local file system resources
@@ -115,17 +110,6 @@ public class EnvInitializer implements ApplicationRunner {
overrideSystemProp(ConfigKeys.KEY_HADOOP_USER_NAME(), hadoopUserName);
}
- private void initRegistryService() {
- if (WebUtils.isHaEnable()) {
- RegistryService registryService = SpringContextUtils.getBean(RegistryService.class);
- registryService.registry();
- Runtime.getRuntime().addShutdownHook(new Thread(() -> {
- registryService.unRegister();
- log.info("RegistryService unRegister success");
- }));
- }
- }
-
private void overrideSystemProp(String key, String defaultValue) {
String value = context.getEnvironment().getProperty(key, defaultValue);
log.info("initialize system properties: key:{}, value:{}", key, value);
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/DatabaseService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/DatabaseService.java
deleted file mode 100644
index 0a8c749c8..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/DatabaseService.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.console.core.bean.DatabaseParam;
-import org.apache.streampark.console.core.entity.Database;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import java.util.List;
-
-public interface DatabaseService extends IService<Database> {
-
- /**
- * Checks if the specified database exists.
- *
- * @param databaseParam The database to check
- * @return true if the database exists, false otherwise
- */
- boolean databaseExists(DatabaseParam databaseParam);
-
- /**
- * Creates a new database given {@link Database}.
- *
- * @param databaseParam The {@link DatabaseParam} object that contains the detail of the created
- * database
- * @return true if the operation is successful, false otherwise
- */
- boolean createDatabase(DatabaseParam databaseParam);
-
- /**
- * Lists databases given catalog id.
- *
- * @return The list of databases of given catalog
- */
- List<DatabaseParam> listDatabases(Long catalogId);
-
- /**
- * Drops database given database name.
- *
- * @param databaseParam The dropping database
- * @return true if the operation is successful, false otherwise
- */
- boolean dropDatabase(DatabaseParam databaseParam);
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/DistributedTaskService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/DistributedTaskService.java
deleted file mode 100644
index 8f8fd36a3..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/DistributedTaskService.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.console.base.mybatis.entity.BaseEntity;
-import org.apache.streampark.console.core.entity.DistributedTask;
-import org.apache.streampark.console.core.enums.DistributedTaskEnum;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import java.util.Set;
-
-/**
- * DistributedTaskService is the interface for managing tasks.
- */
-public interface DistributedTaskService extends IService<DistributedTask> {
-
- /**
- * Initialize the consistent hash ring.
- * @param allServers All servers
- * @param serverId The name of the current server
- */
- void init(Set<String> allServers, String serverId);
-
- /**
- * This interface is responsible for polling the database to retrieve task records and execute the corresponding operations.
- * @param distributedTask distributedTask
- */
- void executeDistributedTask(DistributedTask distributedTask) throws Exception;
-
- /**
- * This interface handles task redistribution when server nodes are added.
- * @param serverId String
- */
- void addServer(String serverId);
-
- /**
- * This interface handles task redistribution when server nodes are removed.
- * @param serverId String
- */
- void removeServer(String serverId);
-
- /**
- * Determine whether the task is processed locally.
- *
- * @param appId Long
- * @return boolean
- */
- boolean isLocalProcessing(Long appId);
-
- /**
- * Save Distributed Task.
- *
- * @param appParam It may be one of the following values: FlinkApplication, SparkApplication
- * @param autoStart boolean
- * @param action It may be one of the following values: START, RESTART, REVOKE, CANCEL, ABORT
- */
- void saveDistributedTask(BaseEntity appParam, boolean autoStart, DistributedTaskEnum action);
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/FlinkCatalogBase.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/FlinkCatalogBase.java
deleted file mode 100644
index c1558a0eb..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/FlinkCatalogBase.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.console.core.util.CatalogServiceUtils;
-
-import org.apache.flink.table.api.Schema;
-import org.apache.flink.table.catalog.Catalog;
-import org.apache.flink.table.catalog.CatalogBaseTable;
-import org.apache.flink.table.catalog.CatalogDatabase;
-import org.apache.flink.table.catalog.CatalogTable;
-import org.apache.flink.table.catalog.CommonCatalogOptions;
-import org.apache.flink.table.catalog.ObjectPath;
-import org.apache.flink.table.catalog.TableChange;
-import org.apache.flink.table.catalog.exceptions.CatalogException;
-import org.apache.flink.table.catalog.exceptions.DatabaseAlreadyExistException;
-import org.apache.flink.table.catalog.exceptions.DatabaseNotEmptyException;
-import org.apache.flink.table.catalog.exceptions.DatabaseNotExistException;
-import org.apache.flink.table.catalog.exceptions.TableAlreadyExistException;
-import org.apache.flink.table.catalog.exceptions.TableNotExistException;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-@Slf4j
-@Service
-public class FlinkCatalogBase {
-
- @Value("${table.catalog-store.kind:jdbc}")
- private String storeKind;
-
- @Value("${table.catalog-store.jdbc.url:jdbc://mysql:127.0.0.1:3306/flink-test}")
- private String jdbcUrl;
-
- @Value("${table.catalog-store.jdbc.driver:com.mysql.cj.jdbc.Driver}")
- private String jdbcDriver;
-
- @Value("${table.catalog-store.jdbc.username:flinkuser}")
- private String jdbcUserName;
-
- @Value("${table.catalog-store.jdbc.password:flinkpw}")
- private String jdbcPassword;
-
- @Value("${table.catalog-store.jdbc.max-retry-timeout:600")
- private String jdbcMaxRetryTimeout;
-
- private final Map<String, Catalog> catalogMap = new ConcurrentHashMap<>(0);
-
- public List<String> listDatabases(String catalogName, Map<String, String> options) {
- Catalog catalog = getCatalog(catalogName, options);
- return catalog.listDatabases();
- }
-
- public boolean databaseExists(String catalogName, Map<String, String> options, String database) {
- Catalog catalog = getCatalog(catalogName, options);
- return catalog.databaseExists(database);
- }
-
- public boolean createDatabase(
- String catalogName,
- Map<String, String> options,
- String databaseName,
- CatalogDatabase catalogDatabase,
- boolean ignoreIfExists) {
- Catalog catalog = getCatalog(catalogName, options);
- try {
- catalog.createDatabase(databaseName, catalogDatabase, ignoreIfExists);
- return true;
- } catch (CatalogException | DatabaseAlreadyExistException e) {
- log.error("create database {} failed.", databaseName, e);
- throw new CatalogException(
- String.format("The database '%s' already exists in the catalog.", databaseName));
- }
- }
-
- public void dropDatabase(
- String catalogName,
- Map<String, String> options,
- String databaseName,
- boolean cascade,
- boolean ignoreIfExists) {
- Catalog catalog = getCatalog(catalogName, options);
- try {
- catalog.dropDatabase(databaseName, ignoreIfExists, cascade);
- } catch (CatalogException | DatabaseNotEmptyException | DatabaseNotExistException e) {
- log.error("Drop database {} failed.", databaseName, e);
- throw new CatalogException(
- String.format("The database '%s' already exists in the catalog.", databaseName));
- }
- }
-
- public boolean tableExists(
- String catalogName, Map<String, String> options, String databaseName, String tableName) {
- Catalog catalog = getCatalog(catalogName, options);
- try {
- return catalog.tableExists(new ObjectPath(databaseName, tableName));
- } catch (CatalogException e) {
- log.error("Table exists {}.{} failed.", databaseName, tableName, e);
- throw new CatalogException(
- String.format("The table '%s.%s' not exists in the catalog.", databaseName, tableName));
- }
- }
-
- public boolean createTable(
- String catalogName,
- Map<String, String> options,
- String databaseName,
- String tableName,
- CatalogTable catalogTable,
- boolean ignoreIfExists) {
- Catalog catalog = getCatalog(catalogName, options);
- try {
- catalog.createTable(new ObjectPath(databaseName, tableName), catalogTable, ignoreIfExists);
- return true;
- } catch (CatalogException e) {
- log.error("Table {}.{} create failed.", databaseName, tableName, e);
- throw new CatalogException(
- String.format("Table '%s.%s' create failed.", databaseName, tableName));
- } catch (TableAlreadyExistException | DatabaseNotExistException e) {
- log.error(
- "Table {}.{} create failed.because table is exits or database not exist",
- databaseName,
- tableName,
- e);
- throw new RuntimeException(e);
- }
- }
-
- public boolean alterTable(
- String catalogName,
- Map<String, String> options,
- String databaseName,
- String tableName,
- List<TableChange> changes,
- boolean ignoreIfExists) {
- Catalog catalog = getCatalog(catalogName, options);
- try {
- CatalogBaseTable originTable = getTable(catalogName, options, databaseName, tableName);
- CatalogTable currentTable = (CatalogTable) originTable;
-
- Schema currentSchema = currentTable.getUnresolvedSchema();
- final Schema schema = applyChangesToSchema(currentSchema, changes);
- Map<String, String> newOptions = new ConcurrentHashMap<>();
- for (TableChange change : changes) {
- if (change instanceof TableChange.SetOption) {
- newOptions.put(
- ((TableChange.SetOption) change).getKey(),
- ((TableChange.SetOption) change).getValue());
- }
- if (change instanceof TableChange.ResetOption) {
- newOptions.remove(((TableChange.ResetOption) change).getKey());
- }
- }
-
- final CatalogTable newTable =
- CatalogTable.of(
- schema, currentTable.getComment(), currentTable.getPartitionKeys(), newOptions);
- catalog.alterTable(new ObjectPath(databaseName, tableName), newTable, ignoreIfExists);
- return true;
- } catch (TableNotExistException e) {
- throw new RuntimeException(e);
- }
- }
-
- public boolean dropTable(
- String catalogName,
- Map<String, String> options,
- String databaseName,
- String tableName,
- boolean ignoreIfExists) {
- Catalog catalog = getCatalog(catalogName, options);
- try {
- catalog.dropTable(new ObjectPath(databaseName, tableName), ignoreIfExists);
- return true;
- } catch (TableNotExistException e) {
- throw new RuntimeException(e);
- }
- }
-
- public boolean renameTable(
- String catalogName,
- Map<String, String> options,
- String databaseName,
- String fromTableName,
- String toTableName) {
- Catalog catalog = getCatalog(catalogName, options);
- try {
- catalog.renameTable(new ObjectPath(databaseName, fromTableName), toTableName, true);
- return true;
- } catch (TableNotExistException | TableAlreadyExistException e) {
- throw new RuntimeException(e);
- }
- }
-
- public List<String> listTable(
- String catalogName, Map<String, String> options, String databaseName) {
- Catalog catalog = getCatalog(catalogName, options);
- try {
- return catalog.listTables(databaseName);
- } catch (DatabaseNotExistException e) {
- throw new RuntimeException(e);
- }
- }
-
- public CatalogBaseTable getTable(
- String catalogName, Map<String, String> options, String databaseName,
- String tableName) {
- Catalog catalog = getCatalog(catalogName, options);
- try {
- return catalog.getTable(new ObjectPath(databaseName, tableName));
- } catch (TableNotExistException e) {
- throw new RuntimeException(e);
- }
- }
-
- private Schema applyChangesToSchema(Schema currentSchema, List<TableChange> changes) {
- // Clone the current schema to avoid modifying the original
- Schema.Builder schemaBuilder = Schema.newBuilder().fromSchema(currentSchema);
-
- // Iterate over each change and apply it to the schema builder
- Set<String> columnsToDrop = new HashSet<>();
- for (TableChange change : changes) {
- if (change instanceof TableChange.AddColumn) {
- TableChange.AddColumn addColumn = (TableChange.AddColumn) change;
- schemaBuilder.column(addColumn.getColumn().getName(), addColumn.getColumn().getDataType());
- } else if (change instanceof TableChange.ModifyColumn) {
- TableChange.ModifyColumn modifyColumn = (TableChange.ModifyColumn) change;
- schemaBuilder.column(
- modifyColumn.getNewColumn().getName(), modifyColumn.getNewColumn().getDataType());
- } else if (change instanceof TableChange.DropColumn) {
- TableChange.DropColumn removeColumn = (TableChange.DropColumn) change;
- columnsToDrop.add(removeColumn.getColumnName());
- } else {
- throw new UnsupportedOperationException(
- "Unsupported table change type: " + change.getClass().getName());
- }
- }
- // drop columns
- if (!columnsToDrop.isEmpty()) {
- for (Schema.UnresolvedColumn column : currentSchema.getColumns()) {
- if (column instanceof Schema.UnresolvedPhysicalColumn) {
- Schema.UnresolvedPhysicalColumn physicalColumn = (Schema.UnresolvedPhysicalColumn) column;
- if (!columnsToDrop.contains(physicalColumn.getName())) {
- schemaBuilder.column(physicalColumn.getName(), physicalColumn.getDataType());
- }
- }
- }
- }
- // Build the updated schema
- return schemaBuilder.build();
- }
-
- private Catalog getCatalog(String catalogName, Map<String, String> options) {
- if (catalogMap.containsKey(catalogName)) {
- return catalogMap.get(catalogName);
- } else {
- Map<String, String> configuration = new HashMap<>();
- configuration.put(CommonCatalogOptions.TABLE_CATALOG_STORE_KIND.key(), storeKind);
- configuration.put("table.catalog-store.jdbc.url", jdbcUrl);
- configuration.put("table.catalog-store.jdbc.driver", jdbcDriver);
- configuration.put("table.catalog-store.jdbc.username", jdbcUserName);
- configuration.put("table.catalog-store.jdbc.password", jdbcPassword);
- configuration.put("table.catalog-store.jdbc.max-retry-timeout", jdbcMaxRetryTimeout);
- Catalog catalog = CatalogServiceUtils.getCatalog(catalogName, options, configuration);
- catalog.open();
- catalogMap.put(catalogName, catalog);
- return catalog;
- }
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/FlinkCatalogService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/FlinkCatalogService.java
deleted file mode 100644
index 7be26068f..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/FlinkCatalogService.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.console.base.domain.RestRequest;
-import org.apache.streampark.console.core.bean.FlinkCatalogParams;
-import org.apache.streampark.console.core.entity.FlinkCatalog;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/** This interface is used to managed catalog */
-public interface FlinkCatalogService extends IService<FlinkCatalog> {
-
- /**
- * Create Catalog
- *
- * @param catalog The {@link FlinkCatalogParams} object containing the search criteria.
- */
- boolean create(FlinkCatalogParams catalog, Long userId);
-
- /**
- * Remove Catalog
- *
- * @param id The {@link FlinkCatalogParams} object containing the search criteria.
- */
- boolean remove(Long id);
-
- /**
- * Retrieves a page of applications based on the provided parameters. Params: catalog – The
- * Catalog object to be used for filtering the results. request – The REST request object
- * containing additional parameters or headers. Returns: A page of Catalog objects based on the
- * provided parameters.
- */
- IPage<FlinkCatalogParams> page(FlinkCatalogParams catalog, RestRequest request);
-
- FlinkCatalog getCatalog(Long catalogId);
-
- FlinkCatalog getCatalog(String catalogName);
- /**
- * update Catalog
- *
- * @param catalog The {@link FlinkCatalogParams} object containing the search criteria.
- */
- boolean update(FlinkCatalogParams catalog, Long userId);
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/RegistryService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/RegistryService.java
deleted file mode 100644
index d504be67a..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/RegistryService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-public interface RegistryService {
-
- /**
- * Registry the service.
- */
- void registry();
-
- /**
- * Close the registry service.
- */
- void unRegister();
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/TableService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/TableService.java
deleted file mode 100644
index 2dc9bbcf9..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/TableService.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.console.core.bean.TableParams;
-
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-@Service
-public interface TableService {
-
- /**
- * Checks if the specified table exists.
- *
- * @param tableParams The TableParams object containing information about the table
- * @return true if the table exists, false otherwise
- */
- boolean tableExists(TableParams tableParams);
-
- /**
- * Creates a table in the database given ${@link TableParams}.
- *
- * @param tableParams The TableParams object containing information about the table
- * @return true if the operation is successful, false otherwise
- */
- boolean createTable(TableParams tableParams);
-
- /**
- * Adds a column to the table.
- *
- * @param tableParams The TableDTO object containing information about the table
- * @return true if the operation is successful, false otherwise
- */
- boolean addColumn(TableParams tableParams);
-
- /**
- * Drops a column from a table.
- *
- * @param catalogName The name of the catalog
- * @param databaseName The name of the database
- * @param tableName The name of the table
- * @param columnName The name of the column to be dropped
- * @return true if the operation is successful, false otherwise
- */
- boolean dropColumn(String catalogName, String databaseName, String tableName, String columnName);
-
- /**
- * Adds options to a table.
- *
- * @param tableDTO The TableDTO object containing information about the table
- * @return true if the operation is successful, false otherwise
- */
- boolean addOption(TableParams tableDTO);
-
- /**
- * Removes an option from a table.
- *
- * @param catalogName The name of the catalog
- * @param databaseName The name of the database
- * @param tableName The name of the table
- * @param key The key of the option to be removed
- * @return true if the operation is successful, false otherwise
- */
- boolean removeOption(String catalogName, String databaseName, String tableName, String key);
-
- /**
- * Drops a table from the specified database in the given catalog.
- *
- * @param catalogName The name of the catalog from which the table will be dropped
- * @param databaseName The name of the database from which the table will be dropped
- * @param tableName The name of the table to be dropped
- * @return true if the operation is successful, false otherwise
- */
- boolean dropTable(String catalogName, String databaseName, String tableName);
-
- /**
- * Renames a table in the specified database of the given catalog.
- *
- * @param catalogName The name of the catalog where the table resides
- * @param databaseName The name of the database where the table resides
- * @param fromTableName The current name of the table to be renamed
- * @param toTableName The new name for the table
- * @return true if the operation is successful, false otherwise
- */
- boolean renameTable(
- String catalogName, String databaseName, String fromTableName, String toTableName);
-
- /**
- * Lists tables given {@link TableParams} condition.
- *
- * @return Response object containing a list of {@link TableParams} representing the tables
- */
- List<TableParams> listTables(TableParams tableDTO);
-
- /**
- * Retrieves the column details of a specific table within the specified catalog and database.
- *
- * @param catalogName The name of the catalog where the table is located
- * @param databaseName The name of the database where the table is located
- * @param tableName The name of the table whose columns are to be retrieved
- * @return A {@link TableParams} object containing the details of the columns of the specified
- * table
- */
- TableParams listColumns(String catalogName, String databaseName, String tableName);
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/ApplicationService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/ApplicationService.java
deleted file mode 100644
index e6404ad20..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/ApplicationService.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service.application;
-
-import org.apache.streampark.console.core.entity.Application;
-import org.apache.streampark.console.core.enums.EngineTypeEnum;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-public interface ApplicationService extends IService<Application> {
-
- Application create(EngineTypeEnum engineTypeEnum);
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationServiceImpl.java
deleted file mode 100644
index 866ceab92..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationServiceImpl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service.application.impl;
-
-import org.apache.streampark.console.core.entity.Application;
-import org.apache.streampark.console.core.enums.EngineTypeEnum;
-import org.apache.streampark.console.core.mapper.ApplicationMapper;
-import org.apache.streampark.console.core.service.application.ApplicationService;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.Date;
-
-@Slf4j
-@Service
-@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
-public class ApplicationServiceImpl extends ServiceImpl<ApplicationMapper, Application>
- implements
- ApplicationService {
-
- @Override
- public Application create(EngineTypeEnum engineTypeEnum) {
- Application application = new Application();
- application.setJobType(engineTypeEnum.getCode());
- application.setCreateTime(new Date());
- application.setModifyTime(new Date());
- save(application);
- return application;
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/FlinkApplicationActionServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/FlinkApplicationActionServiceImpl.java
index e40c75e2e..4605deb99 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/FlinkApplicationActionServiceImpl.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/FlinkApplicationActionServiceImpl.java
@@ -48,14 +48,12 @@ import org.apache.streampark.console.core.entity.FlinkSql;
import org.apache.streampark.console.core.entity.Resource;
import org.apache.streampark.console.core.enums.CheckPointTypeEnum;
import org.apache.streampark.console.core.enums.ConfigFileTypeEnum;
-import org.apache.streampark.console.core.enums.DistributedTaskEnum;
import org.apache.streampark.console.core.enums.EngineTypeEnum;
import org.apache.streampark.console.core.enums.FlinkAppStateEnum;
import org.apache.streampark.console.core.enums.OperationEnum;
import org.apache.streampark.console.core.enums.OptionStateEnum;
import org.apache.streampark.console.core.enums.ReleaseStateEnum;
import org.apache.streampark.console.core.mapper.FlinkApplicationMapper;
-import org.apache.streampark.console.core.service.DistributedTaskService;
import org.apache.streampark.console.core.service.FlinkClusterService;
import org.apache.streampark.console.core.service.FlinkEnvService;
import org.apache.streampark.console.core.service.FlinkSqlService;
@@ -180,9 +178,6 @@ public class FlinkApplicationActionServiceImpl
@Autowired
private ResourceService resourceService;
- @Autowired
- private DistributedTaskService distributedTaskService;
-
@Autowired
private FlinkClusterWatcher flinkClusterWatcher;
@@ -201,12 +196,6 @@ public class FlinkApplicationActionServiceImpl
ApiAlertException.throwIfNull(
application, String.format("The application id=%s not found, revoke failed.", appId));
- // For HA purposes, if the task is not processed locally, save the Distribution task and return
- if (!distributedTaskService.isLocalProcessing(appId)) {
- distributedTaskService.saveDistributedTask(application, false, DistributedTaskEnum.REVOKE);
- return;
- }
-
// 1) delete files that have been published to workspace
application.getFsOperator().delete(application.getAppHome());
@@ -229,11 +218,6 @@ public class FlinkApplicationActionServiceImpl
@Override
public void restart(FlinkApplication appParam) throws Exception {
- // For HA purposes, if the task is not processed locally, save the Distribution task and return
- if (!distributedTaskService.isLocalProcessing(appParam.getId())) {
- distributedTaskService.saveDistributedTask(appParam, false, DistributedTaskEnum.RESTART);
- return;
- }
this.cancel(appParam);
this.start(appParam, false);
}
@@ -241,11 +225,6 @@ public class FlinkApplicationActionServiceImpl
@Override
public void abort(Long id) {
FlinkApplication application = this.baseMapper.selectApp(id);
- // For HA purposes, if the task is not processed locally, save the Distribution task and return
- if (!distributedTaskService.isLocalProcessing(id)) {
- distributedTaskService.saveDistributedTask(application, false, DistributedTaskEnum.ABORT);
- return;
- }
CompletableFuture<SubmitResponse> startFuture = startFutureMap.remove(id);
CompletableFuture<CancelResponse> cancelFuture = cancelFutureMap.remove(id);
if (application.isKubernetesModeJob()) {
@@ -265,11 +244,6 @@ public class FlinkApplicationActionServiceImpl
@Override
public void cancel(FlinkApplication appParam) throws Exception {
- // For HA purposes, if the task is not processed locally, save the Distribution task and return
- if (!distributedTaskService.isLocalProcessing(appParam.getId())) {
- distributedTaskService.saveDistributedTask(appParam, false, DistributedTaskEnum.CANCEL);
- return;
- }
FlinkAppHttpWatcher.setOptionState(appParam.getId(), OptionStateEnum.CANCELLING);
FlinkApplication application = getById(appParam.getId());
application.setState(FlinkAppStateEnum.CANCELLING.getValue());
@@ -407,11 +381,6 @@ public class FlinkApplicationActionServiceImpl
@Override
public void start(FlinkApplication appParam, boolean auto) throws Exception {
- // For HA purposes, if the task is not processed locally, save the Distribution task and return
- if (!distributedTaskService.isLocalProcessing(appParam.getId())) {
- distributedTaskService.saveDistributedTask(appParam, auto, DistributedTaskEnum.START);
- return;
- }
// 1) check application
final FlinkApplication application = getById(appParam.getId());
AssertUtils.notNull(application);
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/FlinkApplicationManageServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/FlinkApplicationManageServiceImpl.java
index 2c3129fbe..158296f86 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/FlinkApplicationManageServiceImpl.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/FlinkApplicationManageServiceImpl.java
@@ -30,7 +30,6 @@ import org.apache.streampark.console.base.mybatis.pager.MybatisPager;
import org.apache.streampark.console.base.util.ObjectUtils;
import org.apache.streampark.console.base.util.WebUtils;
import org.apache.streampark.console.core.bean.AppControl;
-import org.apache.streampark.console.core.entity.Application;
import org.apache.streampark.console.core.entity.FlinkApplication;
import org.apache.streampark.console.core.entity.FlinkApplicationConfig;
import org.apache.streampark.console.core.entity.FlinkCluster;
@@ -38,7 +37,6 @@ import org.apache.streampark.console.core.entity.FlinkSql;
import org.apache.streampark.console.core.entity.Resource;
import org.apache.streampark.console.core.enums.CandidateTypeEnum;
import org.apache.streampark.console.core.enums.ChangeTypeEnum;
-import org.apache.streampark.console.core.enums.EngineTypeEnum;
import org.apache.streampark.console.core.enums.FlinkAppStateEnum;
import org.apache.streampark.console.core.enums.OptionStateEnum;
import org.apache.streampark.console.core.enums.ReleaseStateEnum;
@@ -52,7 +50,6 @@ import org.apache.streampark.console.core.service.SavepointService;
import org.apache.streampark.console.core.service.SettingService;
import org.apache.streampark.console.core.service.YarnQueueService;
import org.apache.streampark.console.core.service.application.ApplicationLogService;
-import org.apache.streampark.console.core.service.application.ApplicationService;
import org.apache.streampark.console.core.service.application.FlinkApplicationBackupService;
import org.apache.streampark.console.core.service.application.FlinkApplicationBuildPipelineService;
import org.apache.streampark.console.core.service.application.FlinkApplicationConfigService;
@@ -108,9 +105,6 @@ public class FlinkApplicationManageServiceImpl extends ServiceImpl<FlinkApplicat
@Autowired
private ProjectService projectService;
- @Autowired
- private ApplicationService applicationService;
-
@Autowired
private FlinkApplicationBackupService backUpService;
@@ -363,10 +357,6 @@ public class FlinkApplicationManageServiceImpl extends ServiceImpl<FlinkApplicat
appParam.setJarCheckSum(org.apache.commons.io.FileUtils.checksumCRC32(new File(jarPath)));
}
- // 1) save application
- Application application = applicationService.create(EngineTypeEnum.FLINK);
- appParam.setId(application.getId());
-
boolean saveSuccess = save(appParam);
if (saveSuccess) {
FlinkJobType jobType = appParam.getJobTypeEnum();
@@ -450,9 +440,6 @@ public class FlinkApplicationManageServiceImpl extends ServiceImpl<FlinkApplicat
newApp.setTeamId(persist.getTeamId());
newApp.setDependency(persist.getDependency());
- Application application = applicationService.create(EngineTypeEnum.FLINK);
- newApp.setId(application.getId());
-
boolean saved = save(newApp);
if (saved) {
if (newApp.isJobTypeFlinkSqlOrCDC()) {
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationActionServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationActionServiceImpl.java
index f116f9437..18ce26cbe 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationActionServiceImpl.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationActionServiceImpl.java
@@ -39,14 +39,12 @@ import org.apache.streampark.console.core.entity.SparkApplicationConfig;
import org.apache.streampark.console.core.entity.SparkEnv;
import org.apache.streampark.console.core.entity.SparkSql;
import org.apache.streampark.console.core.enums.ConfigFileTypeEnum;
-import org.apache.streampark.console.core.enums.DistributedTaskEnum;
import org.apache.streampark.console.core.enums.EngineTypeEnum;
import org.apache.streampark.console.core.enums.ReleaseStateEnum;
import org.apache.streampark.console.core.enums.SparkAppStateEnum;
import org.apache.streampark.console.core.enums.SparkOperationEnum;
import org.apache.streampark.console.core.enums.SparkOptionStateEnum;
import org.apache.streampark.console.core.mapper.SparkApplicationMapper;
-import org.apache.streampark.console.core.service.DistributedTaskService;
import org.apache.streampark.console.core.service.ResourceService;
import org.apache.streampark.console.core.service.SparkEnvService;
import org.apache.streampark.console.core.service.SparkSqlService;
@@ -132,9 +130,6 @@ public class SparkApplicationActionServiceImpl
@Autowired
private ResourceService resourceService;
- @Autowired
- private DistributedTaskService distributedTaskService;
-
private final Map<Long, CompletableFuture<SubmitResponse>> startJobFutureMap = new ConcurrentHashMap<>();
private final Map<Long, CompletableFuture<CancelResponse>> cancelJobFutureMap = new ConcurrentHashMap<>();
@@ -142,11 +137,6 @@ public class SparkApplicationActionServiceImpl
@Override
public void revoke(Long appId) throws ApplicationException {
SparkApplication application = getById(appId);
- // For HA purposes, if the task is not processed locally, save the Distribution task and return
- if (!distributedTaskService.isLocalProcessing(appId)) {
- distributedTaskService.saveDistributedTask(application, false, DistributedTaskEnum.REVOKE);
- return;
- }
ApiAlertException.throwIfNull(
application, String.format("The application id=%s not found, revoke failed.", appId));
@@ -172,11 +162,6 @@ public class SparkApplicationActionServiceImpl
@Override
public void restart(SparkApplication appParam) throws Exception {
- // For HA purposes, if the task is not processed locally, save the Distribution task and return
- if (!distributedTaskService.isLocalProcessing(appParam.getId())) {
- distributedTaskService.saveDistributedTask(appParam, false, DistributedTaskEnum.RESTART);
- return;
- }
this.cancel(appParam);
this.start(appParam, false);
}
@@ -184,11 +169,6 @@ public class SparkApplicationActionServiceImpl
@Override
public void forcedStop(Long id) {
SparkApplication application = this.baseMapper.selectApp(id);
- // For HA purposes, if the task is not processed locally, save the Distribution task and return
- if (!distributedTaskService.isLocalProcessing(id)) {
- distributedTaskService.saveDistributedTask(application, false, DistributedTaskEnum.FORCED_STOP);
- return;
- }
CompletableFuture<SubmitResponse> startFuture = startJobFutureMap.remove(id);
CompletableFuture<CancelResponse> stopFuture = cancelJobFutureMap.remove(id);
if (startFuture != null) {
@@ -204,11 +184,6 @@ public class SparkApplicationActionServiceImpl
@Override
public void cancel(SparkApplication appParam) throws Exception {
- // For HA purposes, if the task is not processed locally, save the Distribution task and return
- if (!distributedTaskService.isLocalProcessing(appParam.getId())) {
- distributedTaskService.saveDistributedTask(appParam, false, DistributedTaskEnum.CANCEL);
- return;
- }
SparkAppHttpWatcher.setOptionState(appParam.getId(), SparkOptionStateEnum.STOPPING);
SparkApplication application = getById(appParam.getId());
application.setState(SparkAppStateEnum.STOPPING.getValue());
@@ -272,11 +247,6 @@ public class SparkApplicationActionServiceImpl
@Override
public void start(SparkApplication appParam, boolean auto) throws Exception {
- // For HA purposes, if the task is not processed locally, save the Distribution task and return
- if (!distributedTaskService.isLocalProcessing(appParam.getId())) {
- distributedTaskService.saveDistributedTask(appParam, false, DistributedTaskEnum.START);
- return;
- }
// 1) check application
final SparkApplication application = getById(appParam.getId());
AssertUtils.notNull(application);
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationManageServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationManageServiceImpl.java
index e2e00b422..b81d43f03 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationManageServiceImpl.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationManageServiceImpl.java
@@ -28,14 +28,12 @@ import org.apache.streampark.console.base.exception.ApiAlertException;
import org.apache.streampark.console.base.mybatis.pager.MybatisPager;
import org.apache.streampark.console.base.util.WebUtils;
import org.apache.streampark.console.core.bean.AppControl;
-import org.apache.streampark.console.core.entity.Application;
import org.apache.streampark.console.core.entity.Resource;
import org.apache.streampark.console.core.entity.SparkApplication;
import org.apache.streampark.console.core.entity.SparkApplicationConfig;
import org.apache.streampark.console.core.entity.SparkSql;
import org.apache.streampark.console.core.enums.CandidateTypeEnum;
import org.apache.streampark.console.core.enums.ChangeTypeEnum;
-import org.apache.streampark.console.core.enums.EngineTypeEnum;
import org.apache.streampark.console.core.enums.OptionStateEnum;
import org.apache.streampark.console.core.enums.ReleaseStateEnum;
import org.apache.streampark.console.core.enums.SparkAppStateEnum;
@@ -46,7 +44,6 @@ import org.apache.streampark.console.core.service.SparkEffectiveService;
import org.apache.streampark.console.core.service.SparkSqlService;
import org.apache.streampark.console.core.service.YarnQueueService;
import org.apache.streampark.console.core.service.application.ApplicationLogService;
-import org.apache.streampark.console.core.service.application.ApplicationService;
import org.apache.streampark.console.core.service.application.FlinkApplicationBuildPipelineService;
import org.apache.streampark.console.core.service.application.SparkApplicationBackupService;
import org.apache.streampark.console.core.service.application.SparkApplicationConfigService;
@@ -95,9 +92,6 @@ public class SparkApplicationManageServiceImpl
@Autowired
private ProjectService projectService;
- @Autowired
- private ApplicationService applicationService;
-
@Autowired
private SparkApplicationBackupService backUpService;
@@ -292,10 +286,6 @@ public class SparkApplicationManageServiceImpl
appParam.setJarCheckSum(org.apache.commons.io.FileUtils.checksumCRC32(new File(jarPath)));
}
- // 1) save application
- Application application = applicationService.create(EngineTypeEnum.SPARK);
- appParam.setId(application.getId());
-
boolean saveSuccess = save(appParam);
if (saveSuccess) {
@@ -366,9 +356,6 @@ public class SparkApplicationManageServiceImpl
newApp.setModifyTime(newApp.getCreateTime());
newApp.setTags(oldApp.getTags());
- Application application = applicationService.create(EngineTypeEnum.SPARK);
- newApp.setId(application.getId());
-
boolean saved = save(newApp);
if (saved) {
if (newApp.isSparkSqlJob()) {
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/DatabaseServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/DatabaseServiceImpl.java
deleted file mode 100644
index 831d85c24..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/DatabaseServiceImpl.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service.impl;
-
-import org.apache.streampark.console.base.exception.AlertException;
-import org.apache.streampark.console.core.bean.DatabaseParam;
-import org.apache.streampark.console.core.entity.Database;
-import org.apache.streampark.console.core.entity.FlinkCatalog;
-import org.apache.streampark.console.core.mapper.DatabaseMapper;
-import org.apache.streampark.console.core.service.DatabaseService;
-import org.apache.streampark.console.core.service.FlinkCatalogBase;
-import org.apache.streampark.console.core.service.FlinkCatalogService;
-
-import org.apache.flink.table.catalog.CatalogDatabase;
-import org.apache.flink.table.catalog.CatalogDatabaseImpl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static org.apache.streampark.console.core.util.CatalogServiceUtils.getOptions;
-
-@Service
-@Slf4j
-@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
-public class DatabaseServiceImpl extends ServiceImpl<DatabaseMapper, Database>
- implements
- DatabaseService {
-
- @Autowired
- private FlinkCatalogService catalogService;
- @Autowired
- private FlinkCatalogBase flinkCatalogBase;
-
- @Override
- public boolean databaseExists(DatabaseParam databaseParam) {
- AlertException.throwIfNull(databaseParam.getName(), "Database name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(databaseParam.getCatalogId());
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit in database.");
- return flinkCatalogBase.databaseExists(
- flinkCatalog.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- databaseParam.getName());
- }
-
- @Override
- public boolean createDatabase(DatabaseParam databaseParam) {
- AlertException.throwIfNull(databaseParam.getName(), "Database name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(databaseParam.getCatalogId());
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit in database.");
- Map<String, String> dbMap = new ConcurrentHashMap<>();
- dbMap.put("cascade", String.valueOf(databaseParam.isCascade()));
- CatalogDatabase catalogDatabase =
- new CatalogDatabaseImpl(dbMap, databaseParam.getDescription());
- return flinkCatalogBase.createDatabase(
- flinkCatalog.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- databaseParam.getName(),
- catalogDatabase,
- databaseParam.isIgnoreIfExits());
- }
-
- @Override
- public List<DatabaseParam> listDatabases(Long catalogId) {
- FlinkCatalog flinkCatalog = catalogService.getCatalog(catalogId);
- AlertException.throwIfNull(
- flinkCatalog, "The catalog can't be null. get catalog from database failed.");
- List<String> databases =
- flinkCatalogBase.listDatabases(
- flinkCatalog.getCatalogName(), getOptions(flinkCatalog.getConfiguration()));
- if (databases == null || databases.isEmpty()) {
- return Collections.emptyList();
- }
- List<DatabaseParam> databaseList = new ArrayList<>();
- databases.forEach(
- dbName -> {
- DatabaseParam dbParam = new DatabaseParam();
- dbParam.setCatalogId(catalogId);
- dbParam.setCatalogName(flinkCatalog.getCatalogName());
- dbParam.setName(dbName);
- databaseList.add(dbParam);
- });
- return databaseList;
- }
-
- @Override
- public boolean dropDatabase(DatabaseParam databaseParam) {
- AlertException.throwIfNull(databaseParam.getName(), "Database name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(databaseParam.getCatalogId());
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit in database.");
- flinkCatalogBase.dropDatabase(
- flinkCatalog.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- databaseParam.getName(),
- databaseParam.isCascade(),
- databaseParam.isIgnoreIfExits());
- return true;
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/DistributedTaskServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/DistributedTaskServiceImpl.java
deleted file mode 100644
index 639bc3bb1..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/DistributedTaskServiceImpl.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service.impl;
-
-import org.apache.streampark.console.base.mybatis.entity.BaseEntity;
-import org.apache.streampark.console.base.util.ConsistentHash;
-import org.apache.streampark.console.base.util.JacksonUtils;
-import org.apache.streampark.console.base.util.WebUtils;
-import org.apache.streampark.console.core.bean.FlinkTaskItem;
-import org.apache.streampark.console.core.bean.SparkTaskItem;
-import org.apache.streampark.console.core.entity.DistributedTask;
-import org.apache.streampark.console.core.entity.FlinkApplication;
-import org.apache.streampark.console.core.entity.SparkApplication;
-import org.apache.streampark.console.core.enums.DistributedTaskEnum;
-import org.apache.streampark.console.core.enums.EngineTypeEnum;
-import org.apache.streampark.console.core.mapper.DistributedTaskMapper;
-import org.apache.streampark.console.core.service.DistributedTaskService;
-import org.apache.streampark.console.core.service.application.FlinkApplicationActionService;
-import org.apache.streampark.console.core.service.application.SparkApplicationActionService;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executor;
-
-@Slf4j
-@Service
-@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
-public class DistributedTaskServiceImpl extends ServiceImpl<DistributedTaskMapper, DistributedTask>
- implements
- DistributedTaskService {
-
- @Qualifier("streamparkDistributedTaskExecutor")
- @Autowired
- private Executor taskExecutor;
-
- @Autowired
- private FlinkApplicationActionService flinkApplicationActionService;
-
- @Autowired
- private SparkApplicationActionService sparkApplicationActionService;
-
- /**
- * Server Id
- */
- private String serverId;
-
- /**
- * Consistent hash algorithm for task distribution
- */
- private final ConsistentHash<String> consistentHash = new ConsistentHash<>(Collections.emptyList());
-
- /**
- * Task execution status
- */
- private final ConcurrentHashMap<Long, Boolean> runningTasks = new ConcurrentHashMap<>();
-
- /**
- * Initialize the consistent hash ring.
- * @param allServers All servers
- * @param serverId The name of the current server
- */
- public void init(Set<String> allServers, String serverId) {
- this.serverId = serverId;
- for (String server : allServers) {
- consistentHash.add(server);
- }
- }
-
- @Scheduled(fixedDelay = 50)
- public void pollDistributedTask() {
- List<DistributedTask> distributedTaskList = this.list();
- for (DistributedTask DistributedTask : distributedTaskList) {
- long taskId = DistributedTask.getId();
- if (DistributedTask.getEngineType() != EngineTypeEnum.FLINK || !isLocalProcessing(taskId)) {
- continue;
- }
- if (runningTasks.putIfAbsent(taskId, true) == null) {
- taskExecutor.execute(() -> {
- try {
- // Execute Distributed task
- executeDistributedTask(DistributedTask);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- } finally {
- runningTasks.remove(DistributedTask.getId());
- this.removeById(DistributedTask.getId());
- }
- });
- }
- }
- }
-
- /**
- * This interface is responsible for polling the database to retrieve task records and execute the corresponding operations.
- * @param distributedTask distributedTask
- */
- @Override
- public void executeDistributedTask(DistributedTask distributedTask) throws Exception {
- // Execute Distributed task
- log.info("Execute Distributed task: {}", distributedTask);
- if (distributedTask.getEngineType() == EngineTypeEnum.FLINK) {
- FlinkTaskItem flinkTaskItem = getFlinkTaskItem(distributedTask);
- FlinkApplication appParam = getAppByFlinkTaskItem(flinkTaskItem);
- switch (distributedTask.getAction()) {
- case START:
- flinkApplicationActionService.start(appParam, flinkTaskItem.getAutoStart());
- break;
- case RESTART:
- flinkApplicationActionService.restart(appParam);
- break;
- case REVOKE:
- flinkApplicationActionService.revoke(appParam.getId());
- break;
- case CANCEL:
- flinkApplicationActionService.cancel(appParam);
- break;
- case ABORT:
- flinkApplicationActionService.abort(appParam.getId());
- break;
- default:
- log.error("Unsupported flink task action: {}", distributedTask.getAction());
- }
- } else if (distributedTask.getEngineType() == EngineTypeEnum.SPARK) {
- SparkTaskItem sparkTaskItem = getSparkTaskItem(distributedTask);
- SparkApplication appParam = getAppBySparkTaskItem(sparkTaskItem);
- switch (distributedTask.getAction()) {
- case START:
- sparkApplicationActionService.start(appParam, sparkTaskItem.getAutoStart());
- break;
- case RESTART:
- sparkApplicationActionService.restart(appParam);
- break;
- case REVOKE:
- sparkApplicationActionService.revoke(appParam.getId());
- break;
- case CANCEL:
- sparkApplicationActionService.cancel(appParam);
- break;
- case FORCED_STOP:
- sparkApplicationActionService.forcedStop(appParam.getId());
- break;
- default:
- log.error("Unsupported spark task action: {}", distributedTask.getAction());
- }
- }
- }
-
- /**
- * This interface handles task redistribution when server nodes are added.
- *
- * @param serverId String
- */
- @Override
- public void addServer(String serverId) {
- consistentHash.add(serverId);
- }
-
- /**
- * This interface handles task redistribution when server nodes are removed.
- *
- * @param serverId String
- */
- @Override
- public void removeServer(String serverId) {
- consistentHash.remove(serverId);
- }
-
- /**
- * Determine whether the task is processed locally.
- *
- * @param appId Long
- * @return boolean
- */
- @Override
- public boolean isLocalProcessing(Long appId) {
- if (!WebUtils.isHaEnable()) {
- return true;
- }
- return consistentHash.get(appId).equals(serverId);
- }
-
- /**
- * Save Distributed task.
- *
- * @param appParam Application
- * @param autoStart boolean
- * @param action It may be one of the following values: START, RESTART, REVOKE, CANCEL, ABORT
- */
- @Override
- public void saveDistributedTask(BaseEntity appParam, boolean autoStart, DistributedTaskEnum action) {
- try {
- DistributedTask distributedTask;
- if (appParam instanceof FlinkApplication) {
- distributedTask = getDistributedTaskByFlinkApp((FlinkApplication) appParam, autoStart, action);
- } else if (appParam instanceof SparkApplication) {
- distributedTask = getDistributedTaskBySparkApp((SparkApplication) appParam, autoStart, action);
- } else {
- log.error("Unsupported application type: {}", appParam.getClass().getName());
- return;
- }
- this.save(distributedTask);
- } catch (Exception e) {
- log.error("Failed to save Distributed task: {}", e.getMessage());
- }
- }
-
- public DistributedTask getDistributedTaskByFlinkApp(FlinkApplication appParam, boolean autoStart,
- DistributedTaskEnum action) throws Exception {
- FlinkTaskItem flinkTaskItem = new FlinkTaskItem();
- flinkTaskItem.setAppId(appParam.getId());
- flinkTaskItem.setAutoStart(autoStart);
- flinkTaskItem.setArgs(appParam.getArgs());
- flinkTaskItem.setDynamicProperties(appParam.getDynamicProperties());
- flinkTaskItem.setSavepointPath(appParam.getSavepointPath());
- flinkTaskItem.setRestoreOrTriggerSavepoint(appParam.getRestoreOrTriggerSavepoint());
- flinkTaskItem.setDrain(appParam.getDrain());
- flinkTaskItem.setNativeFormat(appParam.getNativeFormat());
- flinkTaskItem.setRestoreMode(appParam.getRestoreMode());
-
- DistributedTask distributedTask = new DistributedTask();
- distributedTask.setAction(action);
- distributedTask.setEngineType(EngineTypeEnum.FLINK);
- distributedTask.setProperties(JacksonUtils.write(flinkTaskItem));
- return distributedTask;
- }
-
- public DistributedTask getDistributedTaskBySparkApp(SparkApplication appParam, boolean autoStart,
- DistributedTaskEnum action) throws Exception {
- SparkTaskItem sparkTaskItem = new SparkTaskItem();
- sparkTaskItem.setAppId(appParam.getId());
- sparkTaskItem.setAutoStart(autoStart);
-
- DistributedTask distributedTask = new DistributedTask();
- distributedTask.setAction(action);
- distributedTask.setEngineType(EngineTypeEnum.SPARK);
- distributedTask.setProperties(JacksonUtils.write(sparkTaskItem));
- return distributedTask;
- }
-
- public FlinkTaskItem getFlinkTaskItem(DistributedTask distributedTask) throws JsonProcessingException {
- return JacksonUtils.read(distributedTask.getProperties(), FlinkTaskItem.class);
- }
-
- public SparkTaskItem getSparkTaskItem(DistributedTask distributedTask) throws JsonProcessingException {
- return JacksonUtils.read(distributedTask.getProperties(), SparkTaskItem.class);
- }
-
- public FlinkApplication getAppByFlinkTaskItem(FlinkTaskItem flinkTaskItem) {
- FlinkApplication appParam = new FlinkApplication();
- appParam.setId(flinkTaskItem.getAppId());
- appParam.setArgs(flinkTaskItem.getArgs());
- appParam.setDynamicProperties(flinkTaskItem.getDynamicProperties());
- appParam.setSavepointPath(flinkTaskItem.getSavepointPath());
- appParam.setRestoreOrTriggerSavepoint(flinkTaskItem.getRestoreOrTriggerSavepoint());
- appParam.setDrain(flinkTaskItem.getDrain());
- appParam.setNativeFormat(flinkTaskItem.getNativeFormat());
- appParam.setRestoreMode(flinkTaskItem.getRestoreMode());
- return appParam;
- }
-
- public SparkApplication getAppBySparkTaskItem(SparkTaskItem sparkTaskItem) {
- SparkApplication appParam = new SparkApplication();
- appParam.setId(sparkTaskItem.getAppId());
- return appParam;
- }
-
- public long getConsistentHashSize() {
- return consistentHash.getSize();
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkCatalogServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkCatalogServiceImpl.java
deleted file mode 100644
index 3c0dfec4a..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkCatalogServiceImpl.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service.impl;
-
-import org.apache.streampark.console.base.domain.RestRequest;
-import org.apache.streampark.console.base.exception.AlertException;
-import org.apache.streampark.console.base.exception.ApiAlertException;
-import org.apache.streampark.console.base.mybatis.pager.MybatisPager;
-import org.apache.streampark.console.core.bean.FlinkCatalogParams;
-import org.apache.streampark.console.core.entity.FlinkCatalog;
-import org.apache.streampark.console.core.mapper.FlinkCatalogMapper;
-import org.apache.streampark.console.core.service.FlinkCatalogService;
-
-import org.apache.commons.lang3.StringUtils;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.regex.Pattern;
-
-/** catalog manage */
-@Service
-@Slf4j
-@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
-public class FlinkCatalogServiceImpl extends ServiceImpl<FlinkCatalogMapper, FlinkCatalog>
- implements
- FlinkCatalogService {
-
- private static final String CATALOG_REGEX = "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$";
-
- @Override
- public boolean create(FlinkCatalogParams catalog, Long userId) {
- AlertException.throwIfNull(
- catalog.getTeamId(), "The teamId can't be null. Create catalog failed.");
- AlertException.throwIfFalse(
- validateCatalogName(catalog.getCatalogName()),
- "Catalog Name only lowercase letters, numbers, and -,.. Symbol composition, cannot end with a symbol.");
- AlertException.throwIfTrue(
- existsByCatalogName(catalog.getCatalogName()), "Catalog name already exists.");
- FlinkCatalog flinkCatalog = FlinkCatalog.of(catalog);
- Date date = new Date();
- flinkCatalog.setCreateTime(date);
- flinkCatalog.setUpdateTime(date);
- return this.save(flinkCatalog);
- }
-
- @Override
- public boolean remove(Long id) {
- FlinkCatalog catalog = getById(id);
- ApiAlertException.throwIfNull(catalog, "Catalog not exist, please check.");
- return this.removeById(id);
- }
-
- @Override
- public IPage<FlinkCatalogParams> page(FlinkCatalogParams catalog, RestRequest request) {
- AlertException.throwIfNull(
- catalog.getTeamId(), "The teamId can't be null. List catalog failed.");
-
- Page<FlinkCatalog> page = MybatisPager.getPage(request);
-
- this.lambdaQuery()
- .eq(FlinkCatalog::getTeamId, catalog.getTeamId())
- .eq(StringUtils.isNotBlank(catalog.getCatalogName()), FlinkCatalog::getCatalogName,
- catalog.getCatalogName())
- .eq(catalog.getUserId() != null, FlinkCatalog::getUserId, catalog.getUserId())
- .page(page);
-
- Page<FlinkCatalogParams> paramsPage = new Page<>();
- BeanUtils.copyProperties(page, paramsPage, "records");
- List<FlinkCatalogParams> paramList = new ArrayList<>();
- page.getRecords()
- .forEach(
- record -> {
- paramList.add(FlinkCatalogParams.of(record));
- });
- paramsPage.setRecords(paramList);
- return paramsPage;
- }
-
- @Override
- public FlinkCatalog getCatalog(Long catalogId) {
- return this.baseMapper.selectById(catalogId);
- }
-
- @Override
- public FlinkCatalog getCatalog(String catalogName) {
- return this.lambdaQuery().eq(FlinkCatalog::getCatalogName, catalogName).one();
- }
-
- @Override
- public boolean update(FlinkCatalogParams catalogParam, Long userId) {
- AlertException.throwIfNull(
- catalogParam.getTeamId(), "The teamId can't be null. List catalog failed.");
- FlinkCatalog catalog = getById(catalogParam.getId());
- FlinkCatalog flinkCatalog = FlinkCatalog.of(catalogParam);
- AlertException.throwIfFalse(
- catalogParam.getCatalogName().equalsIgnoreCase(catalog.getCatalogName()),
- "The catalog name cannot be modified.");
- log.debug(
- "Catalog {} has modify from {} to {}",
- catalog.getCatalogName(),
- catalog.getConfiguration(),
- flinkCatalog.getConfiguration());
- catalog.setConfiguration(flinkCatalog.getConfiguration());
- catalog.setUpdateTime(new Date());
- catalog.setUserId(userId);
- return this.updateById(catalog);
- }
-
- public Boolean existsByCatalogName(String catalogName) {
- return this.lambdaQuery()
- .eq(FlinkCatalog::getCatalogName, catalogName)
- .exists();
- }
-
- /** validate catalog name */
- private boolean validateCatalogName(String catalogName) {
- return Pattern.compile(CATALOG_REGEX).matcher(catalogName).matches();
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/RegistryServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/RegistryServiceImpl.java
deleted file mode 100644
index 1cf2b9c8c..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/RegistryServiceImpl.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service.impl;
-
-import org.apache.streampark.common.util.SystemPropertyUtils;
-import org.apache.streampark.console.core.service.DistributedTaskService;
-import org.apache.streampark.console.core.service.RegistryService;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.data.Stat;
-
-import lombok.Getter;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.net.InetAddress;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import static org.apache.zookeeper.ZooDefs.Ids.OPEN_ACL_UNSAFE;
-
-@Slf4j
-@Service
-public class RegistryServiceImpl implements RegistryService {
-
- private static final String REGISTRY_PATH = "/services";
- private static final int HEARTBEAT_INTERVAL = 10000;
- private static final int HEARTBEAT_TIMEOUT = 60000;
-
- private String zkAddress;
- private ZooKeeper zk;
- private String nodePath;
-
- private final Watcher watcher = event -> {
- if (event.getType() == Watcher.Event.EventType.NodeChildrenChanged
- && event.getPath().equals(REGISTRY_PATH)) {
- handleNodeChanges();
- }
- };
-
- @Getter
- private Set<String> currentNodes = new HashSet<>();
-
- @Autowired
- private DistributedTaskService distributedTaskService;
-
- private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2);
-
- public void registry() {
- try {
- zkAddress = SystemPropertyUtils.get("high-availability.zookeeper.quorum", "localhost:2181");
- zk = new ZooKeeper(zkAddress, HEARTBEAT_TIMEOUT, watcher);
- if (zk.exists(REGISTRY_PATH, false) == null) {
- zk.create(REGISTRY_PATH, new byte[0], OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
- }
-
- String ip = InetAddress.getLocalHost().getHostAddress();
- String port = SystemPropertyUtils.get("server.port", "10000");
- String server_id = ip + ":" + port;
- nodePath = zk.create(REGISTRY_PATH + "/" + server_id, new byte[0],
- OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
-
- currentNodes.add(nodePath);
-
- doRegister();
- } catch (Exception e) {
- log.error("Failed to init ZooKeeper client", e);
- }
- }
-
- public void doRegister() {
- try {
- distributedTaskService.init(currentNodes, nodePath);
- startHeartbeat();
- startHeartbeatChecker();
- handleNodeChanges();
- log.info("ZooKeeper client started: {}", nodePath);
- } catch (Exception e) {
- log.error("Failed to start ZooKeeper client", e);
- }
- }
-
- private void startHeartbeat() {
- scheduler.scheduleAtFixedRate(() -> {
- try {
- zk.setData(nodePath, new byte[0], -1);
- log.info("Heartbeat updated for node: {}", nodePath);
- } catch (KeeperException e) {
- log.info("Zookeeper session expired, attempting to reconnect...");
- reconnectAndRegister();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- log.error("Failed to update heartbeat for node: {}", nodePath, e);
- }
- }, 0, HEARTBEAT_INTERVAL, TimeUnit.MILLISECONDS);
- }
-
- private void startHeartbeatChecker() {
- scheduler.scheduleAtFixedRate(() -> {
- try {
- long now = System.currentTimeMillis();
- List<String> servers = zk.getChildren(REGISTRY_PATH, false);
- for (String server : servers) {
- String serverPath = REGISTRY_PATH + "/" + server;
- Stat stat = zk.exists(serverPath, false);
- if (stat != null && (now - stat.getMtime() > HEARTBEAT_TIMEOUT)) {
- zk.delete(serverPath, -1);
- log.info("Deleted stale node: {}", serverPath);
- }
- }
- } catch (KeeperException e) {
- log.info("Zookeeper session expired, attempting to reconnect...");
- reconnectAndRegister();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- log.error("Failed to check heartbeat", e);
- }
- }, HEARTBEAT_TIMEOUT, HEARTBEAT_TIMEOUT, TimeUnit.MILLISECONDS);
- }
-
- private synchronized void handleNodeChanges() {
- try {
- List<String> nodes = zk.getChildren(REGISTRY_PATH, true);
- Set<String> newNodes = new HashSet<>(nodes);
-
- for (String node : newNodes) {
- if (!currentNodes.contains(node)) {
- log.info("Node added: {}", node);
- distributedTaskService.addServer(node);
- }
- }
-
- for (String node : currentNodes) {
- if (!newNodes.contains(node)) {
- log.info("Node removed: {}", node);
- distributedTaskService.removeServer(node);
- }
- }
-
- currentNodes = newNodes;
- log.info("Online servers: {}", currentNodes);
- } catch (KeeperException e) {
- log.info("Zookeeper session expired, attempting to reconnect...");
- reconnectAndRegister();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- log.error("Failed to handle node changes", e);
- }
- }
-
- private void reconnectAndRegister() {
- int retries = 5;
- while (retries > 0) {
- try {
- zk.close();
- zk = new ZooKeeper(zkAddress, HEARTBEAT_TIMEOUT, watcher);
- zk.create(nodePath, new byte[0], OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
- return;
- } catch (Exception e) {
- retries--;
- log.warn("Retrying connection, attempts left: {}", retries, e);
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ignored) {
- Thread.currentThread().interrupt();
- }
- }
- }
- log.error("Failed to reconnect and register node after multiple attempts.");
- }
-
- @Override
- public void unRegister() {
- try {
- zk.close();
- scheduler.shutdown();
- log.info("ZooKeeper client closed: {}", nodePath);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- log.error("Failed to close ZooKeeper client", e);
- }
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/TableServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/TableServiceImpl.java
deleted file mode 100644
index 1e9a96da1..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/TableServiceImpl.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service.impl;
-
-import org.apache.streampark.console.base.exception.AlertException;
-import org.apache.streampark.console.core.bean.TableColumn;
-import org.apache.streampark.console.core.bean.TableParams;
-import org.apache.streampark.console.core.entity.FlinkCatalog;
-import org.apache.streampark.console.core.service.FlinkCatalogBase;
-import org.apache.streampark.console.core.service.FlinkCatalogService;
-import org.apache.streampark.console.core.service.TableService;
-import org.apache.streampark.console.core.util.DataTypeConverterUtils;
-
-import org.apache.flink.table.api.Schema;
-import org.apache.flink.table.catalog.CatalogBaseTable;
-import org.apache.flink.table.catalog.CatalogTable;
-import org.apache.flink.table.catalog.Column;
-import org.apache.flink.table.catalog.ResolvedSchema;
-import org.apache.flink.table.catalog.TableChange;
-import org.apache.flink.table.catalog.UniqueConstraint;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static org.apache.streampark.console.core.util.CatalogServiceUtils.getOptions;
-
-@Service
-@Slf4j
-@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
-public class TableServiceImpl implements TableService {
-
- @Autowired
- private FlinkCatalogService catalogService;
- @Autowired
- private FlinkCatalogBase flinkCatalogBase;
-
- @Override
- public boolean tableExists(TableParams tableParams) {
- AlertException.throwIfNull(tableParams.getName(), "Table name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(tableParams.getCatalogId());
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit.");
- return flinkCatalogBase.tableExists(
- flinkCatalog.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- tableParams.getDatabaseName(),
- tableParams.getName());
- }
-
- @Override
- public boolean createTable(TableParams tableParams) {
- AlertException.throwIfNull(tableParams.getName(), "Table name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(tableParams.getCatalogId());
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit.");
- AlertException.throwIfNull(tableParams.getTableColumns(), "Table column can not be null.");
- AlertException.throwIfNull(tableParams.getTableOptions(), "Table options can not be null.");
- List<Column> columns = new ArrayList<>();
- List<String> ukColumns = new ArrayList<>();
- AtomicReference<String> ukName = new AtomicReference<>("uk");
- tableParams
- .getTableColumns()
- .forEach(
- tc -> {
- columns.add(
- Column.physical(
- tc.getField(), DataTypeConverterUtils.convertToDataType(tc.getDataType())));
- if (tc.isPk()) {
- ukColumns.add(tc.getField());
- ukName.set(ukName + tc.getField());
- }
- });
- final Schema schema =
- Schema.newBuilder()
- .fromResolvedSchema(
- new ResolvedSchema(
- columns,
- Collections.emptyList(),
- UniqueConstraint.primaryKey(ukName.get(), ukColumns)))
- .build();
- final CatalogTable originTable =
- CatalogTable.of(
- schema,
- tableParams.getDescription(),
- tableParams.getPartitionKey(),
- tableParams.getTableOptions());
- return flinkCatalogBase.createTable(
- flinkCatalog.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- tableParams.getDatabaseName(),
- tableParams.getName(),
- originTable,
- true);
- }
-
- @Override
- public boolean addColumn(TableParams tableParams) {
- AlertException.throwIfNull(tableParams.getName(), "Table name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(tableParams.getCatalogId());
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit.");
- AlertException.throwIfNull(tableParams.getTableColumns(), "Table column can not be null.");
-
- List<TableChange> tableChanges = new ArrayList<>();
- for (TableColumn tableColumn : tableParams.getTableColumns()) {
- Column column =
- Column.physical(
- tableColumn.getField(),
- DataTypeConverterUtils.convertToDataType(tableColumn.getDataType()))
- .withComment(tableColumn.getComment());
- TableChange.AddColumn addColumn = TableChange.add(column);
- tableChanges.add(addColumn);
- }
-
- return flinkCatalogBase.alterTable(
- flinkCatalog.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- tableParams.getDatabaseName(),
- tableParams.getName(),
- tableChanges,
- true);
- }
-
- @Override
- public boolean dropColumn(
- String catalogName, String databaseName, String tableName, String columnName) {
- AlertException.throwIfNull(tableName, "Table name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(catalogName);
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit.");
- AlertException.throwIfNull(columnName, "Table column name can not be null.");
-
- List<TableChange> tableChanges = new ArrayList<>();
- TableChange.DropColumn dropColumn = TableChange.dropColumn(columnName);
- tableChanges.add(dropColumn);
- return flinkCatalogBase.alterTable(
- flinkCatalog.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- databaseName,
- tableName,
- tableChanges,
- true);
- }
-
- @Override
- public boolean addOption(TableParams tableParams) {
-
- AlertException.throwIfNull(tableParams.getName(), "Table name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(tableParams.getCatalogId());
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit.");
- AlertException.throwIfNull(tableParams.getTableOptions(), "Table options can not be null.");
- List<TableChange> tableChanges = new ArrayList<>();
- tableParams
- .getTableOptions()
- .forEach(
- (key, value) -> {
- tableChanges.add(TableChange.set(key, value));
- });
-
- return flinkCatalogBase.alterTable(
- flinkCatalog.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- tableParams.getDatabaseName(),
- tableParams.getName(),
- tableChanges,
- true);
- }
-
- @Override
- public boolean removeOption(
- String catalogName, String databaseName, String tableName, String key) {
- AlertException.throwIfNull(tableName, "Table name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(catalogName);
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit.");
- AlertException.throwIfNull(key, "Table options key can not be null.");
- List<TableChange> tableChanges = new ArrayList<>();
-
- tableChanges.add(new TableChange.ResetOption(key));
-
- return flinkCatalogBase.alterTable(
- flinkCatalog.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- databaseName,
- tableName,
- tableChanges,
- true);
- }
-
- @Override
- public boolean dropTable(String catalogName, String databaseName, String tableName) {
- AlertException.throwIfNull(tableName, "Table name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(catalogName);
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit.");
- return flinkCatalogBase.dropTable(
- catalogName, getOptions(flinkCatalog.getConfiguration()), databaseName, tableName, true);
- }
-
- @Override
- public boolean renameTable(
- String catalogName, String databaseName, String fromTableName, String toTableName) {
- AlertException.throwIfNull(fromTableName, "From table name can not be null.");
- AlertException.throwIfNull(toTableName, "To table name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(catalogName);
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit.");
- return flinkCatalogBase.renameTable(
- catalogName,
- getOptions(flinkCatalog.getConfiguration()),
- databaseName,
- fromTableName,
- toTableName);
- }
-
- @Override
- public List<TableParams> listTables(TableParams tableParams) {
- AlertException.throwIfNull(tableParams.getDatabaseName(), "Database name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(tableParams.getCatalogId());
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit.");
- List<String> tables =
- flinkCatalogBase.listTable(
- tableParams.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- tableParams.getDatabaseName());
-
- if (tables == null || tables.isEmpty()) {
- return null;
- }
- List<TableParams> tableParamsList = new ArrayList<>();
- tables.forEach(
- tableName -> {
- tableParamsList.add(
- covertToTableParams(
- flinkCatalogBase.getTable(
- flinkCatalog.getCatalogName(),
- getOptions(flinkCatalog.getConfiguration()),
- tableParams.getDatabaseName(),
- tableParams.getName())));
- });
-
- return tableParamsList;
- }
-
- @Override
- public TableParams listColumns(String catalogName, String databaseName, String tableName) {
- AlertException.throwIfNull(databaseName, "Database name can not be null.");
- FlinkCatalog flinkCatalog = catalogService.getCatalog(catalogName);
- AlertException.throwIfNull(flinkCatalog, "Catalog is not exit.");
-
- CatalogBaseTable originTable =
- flinkCatalogBase.getTable(
- catalogName, getOptions(flinkCatalog.getConfiguration()), databaseName, tableName);
- TableParams tableParams = covertToTableParams(originTable);
- tableParams.setName(tableName);
- tableParams.setCatalogName(catalogName);
- tableParams.setDatabaseName(catalogName);
- tableParams.setCatalogId(flinkCatalog.getId());
- return tableParams;
- }
-
- private TableParams covertToTableParams(CatalogBaseTable catalogBaseTable) {
- List<TableColumn> tableColumns = new ArrayList<>();
- catalogBaseTable
- .getUnresolvedSchema()
- .getColumns()
- .forEach(
- unresolvedColumn -> {
- TableColumn tableColumn = new TableColumn();
- tableColumn.setField(unresolvedColumn.getName());
- unresolvedColumn.getComment().ifPresent(tableColumn::setComment);
- tableColumns.add(tableColumn);
- });
- catalogBaseTable
- .getUnresolvedSchema()
- .getPrimaryKey()
- .ifPresent(
- unresolvedPrimaryKey -> {
- List<String> primaryKeys = unresolvedPrimaryKey.getColumnNames();
- for (String primary : primaryKeys) {
- for (TableColumn column : tableColumns) {
- if (column.getField().equals(primary)) {
- column.setPk(true);
- }
- }
- }
- });
- return TableParams.builder().tableColumns(tableColumns).build();
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/util/CatalogServiceUtils.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/util/CatalogServiceUtils.java
deleted file mode 100644
index fe0ef3b4b..000000000
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/util/CatalogServiceUtils.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.util;
-
-import org.apache.streampark.console.base.util.JacksonUtils;
-import org.apache.streampark.console.base.util.WebUtils;
-
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.table.catalog.Catalog;
-import org.apache.flink.table.factories.FactoryUtil;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-public class CatalogServiceUtils {
-
- private static final Pattern PATTERN_FLINK_CONNECTOR_PLUGIN =
- Pattern.compile(
- "^streampark-flink-connector-plugin-(\\d+)\\.(\\d+)\\.(\\d+)(?:-([^-]+))?\\.jar$",
- Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
-
- public static Catalog getCatalog(
- String catalogName, Map<String, String> options,
- Map<String, String> configurations) {
- ClassLoader classLoader = getCatalogClassLoader(Thread.currentThread().getContextClassLoader());
- return FactoryUtil.createCatalog(
- catalogName, options, Configuration.fromMap(configurations), classLoader);
- }
-
- /** get catalog classloader, add streampark-flink-connector-plugins */
- protected static ClassLoader getCatalogClassLoader(ClassLoader classLoader) {
- File pluginDir = WebUtils.getPluginDir();
- File[] pluginFiles =
- pluginDir.listFiles(
- pathname -> pathname.getName().matches(PATTERN_FLINK_CONNECTOR_PLUGIN.pattern()));
- if (pluginFiles == null) {
- return classLoader;
- }
- List<URL> pluginUrls = new ArrayList<URL>();
- for (File file : pluginFiles) {
- try {
- URL pluginUrl = file.toURI().toURL();
- pluginUrls.add(pluginUrl);
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- }
- return new URLClassLoader(pluginUrls.toArray(new URL[0]), classLoader);
- }
-
- public static Map<String, String> getOptions(String configuration) {
- try {
- return JacksonUtils.toMap(configuration);
- } catch (JsonProcessingException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/FlinkAppHttpWatcher.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/FlinkAppHttpWatcher.java
index 3733615c1..3e57dce29 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/FlinkAppHttpWatcher.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/FlinkAppHttpWatcher.java
@@ -35,7 +35,6 @@ import org.apache.streampark.console.core.metrics.flink.CheckPoints;
import org.apache.streampark.console.core.metrics.flink.JobsOverview;
import org.apache.streampark.console.core.metrics.flink.Overview;
import org.apache.streampark.console.core.metrics.yarn.YarnAppInfo;
-import org.apache.streampark.console.core.service.DistributedTaskService;
import org.apache.streampark.console.core.service.FlinkClusterService;
import org.apache.streampark.console.core.service.SavepointService;
import org.apache.streampark.console.core.service.alert.AlertService;
@@ -99,9 +98,6 @@ public class FlinkAppHttpWatcher {
@Autowired
private SavepointService savepointService;
- @Autowired
- private DistributedTaskService distributedTaskService;
-
// track interval every 5 seconds
public static final Duration WATCHING_INTERVAL = Duration.ofSeconds(5);
@@ -183,11 +179,7 @@ public class FlinkAppHttpWatcher {
List<FlinkApplication> applications = applicationManageService.list(
new LambdaQueryWrapper<FlinkApplication>()
.eq(FlinkApplication::getTracking, 1)
- .notIn(FlinkApplication::getDeployMode, FlinkDeployMode.getKubernetesMode()))
- .stream()
- .filter(application -> distributedTaskService.isLocalProcessing(application.getId()))
- .collect(Collectors.toList());
-
+ .notIn(FlinkApplication::getDeployMode, FlinkDeployMode.getKubernetesMode()));
applications.forEach(app -> {
Long appId = app.getId();
WATCHING_APPS.put(appId, app);
@@ -210,7 +202,7 @@ public class FlinkAppHttpWatcher {
*
* <p><strong>2) Normal information obtain, once every 5 seconds</strong>
*/
- @Scheduled(fixedDelayString = "${job.state-watcher.fixed-delayed:1000}")
+ @Scheduled(fixedDelay = 1, initialDelay = 5, timeUnit = TimeUnit.SECONDS)
public void start() {
Long timeMillis = System.currentTimeMillis();
if (lastWatchTime == null
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/FlinkClusterWatcher.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/FlinkClusterWatcher.java
index dadea616a..8abab9c0f 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/FlinkClusterWatcher.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/FlinkClusterWatcher.java
@@ -103,7 +103,7 @@ public class FlinkClusterWatcher {
flinkClusters.forEach(cluster -> WATCHER_CLUSTERS.put(cluster.getId(), cluster));
}
- @Scheduled(fixedDelayString = "${job.state-watcher.fixed-delayed:1000}")
+ @Scheduled(fixedDelay = 1, initialDelay = 5, timeUnit = TimeUnit.SECONDS)
private void start() {
Long timeMillis = System.currentTimeMillis();
if (immediateWatch || timeMillis - lastWatchTime >= WATCHER_INTERVAL.toMillis()) {
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/SparkAppHttpWatcher.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/SparkAppHttpWatcher.java
index 14c896fcb..5383629d7 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/SparkAppHttpWatcher.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/watcher/SparkAppHttpWatcher.java
@@ -28,7 +28,6 @@ import org.apache.streampark.console.core.enums.StopFromEnum;
import org.apache.streampark.console.core.metrics.spark.Job;
import org.apache.streampark.console.core.metrics.spark.SparkApplicationSummary;
import org.apache.streampark.console.core.metrics.yarn.YarnAppInfo;
-import org.apache.streampark.console.core.service.DistributedTaskService;
import org.apache.streampark.console.core.service.alert.AlertService;
import org.apache.streampark.console.core.service.application.SparkApplicationActionService;
import org.apache.streampark.console.core.service.application.SparkApplicationInfoService;
@@ -63,7 +62,6 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
@Slf4j
@Component
@@ -78,9 +76,6 @@ public class SparkAppHttpWatcher {
@Autowired
private SparkApplicationInfoService applicationInfoService;
- @Autowired
- private DistributedTaskService distributedTaskService;
-
@Autowired
private AlertService alertService;
@@ -134,10 +129,7 @@ public class SparkAppHttpWatcher {
List<SparkApplication> applications = applicationManageService.list(
new LambdaQueryWrapper<SparkApplication>()
.eq(SparkApplication::getTracking, 1)
- .ne(SparkApplication::getState, SparkAppStateEnum.LOST.getValue()))
- .stream()
- .filter(application -> distributedTaskService.isLocalProcessing(application.getId()))
- .collect(Collectors.toList());
+ .ne(SparkApplication::getState, SparkAppStateEnum.LOST.getValue()));
applications.forEach(app -> {
Long appId = app.getId();
@@ -161,7 +153,7 @@ public class SparkAppHttpWatcher {
*
* <p><strong>2) Normal information obtain, once every 5 seconds</strong>
*/
- @Scheduled(fixedDelayString = "${job.state-watcher.fixed-delayed:1000}")
+ @Scheduled(fixedDelay = 1, initialDelay = 5, timeUnit = TimeUnit.SECONDS)
public void start() {
Long timeMillis = System.currentTimeMillis();
if (lastWatchTime == null
diff --git a/streampark-console/streampark-console-service/src/main/resources/config.yaml b/streampark-console/streampark-console-service/src/main/resources/config.yaml
index 7acf0e77a..96f8426af 100644
--- a/streampark-console/streampark-console-service/src/main/resources/config.yaml
+++ b/streampark-console/streampark-console-service/src/main/resources/config.yaml
@@ -64,8 +64,6 @@ streampark:
project:
# Number of projects allowed to be running at the same time , If there is no limit, -1 can be configured
max-build: 16
- # console heartbeat interval
- max-heartbeat-interval: 10s
# flink on yarn or spark on yarn, when the hadoop cluster enable kerberos authentication, it is necessary to set Kerberos authentication parameters.
security:
@@ -100,39 +98,3 @@ sso:
# Optional, change by authentication client
# Please replace and fill in your client config below when enabled SSO
-## flink catalog store config
-table:
- catalog-store:
- kind: jdbc
- jdbc:
- url: jdbc://mysql:127.0.0.1:3306/flink-test
- # The JDBC database url.
- table-name: t_flink_catalog
- ## catalog store table
- driver: com.mysql.cj.jdbc.Driver
- # The class name of the JDBC driver to use to connect to this URL, if not set, it will automatically be derived from the URL.
- username: flinkuser
- # The JDBC user name. 'username' and 'password' must both be specified if any of them is specified.
- password: flinkpw
- # The JDBC password.
- max-retry-timeout: 600
-
-
-
-registry:
- type: jdbc
- heartbeat-refresh-interval: 1s
- session-timeout: 3s
-
-network:
- # network interface preferred like eth0, default: empty
- preferred-interface: ""
- # network interface restricted like docker0, default: empty
- restrict-interface: docker0
- # network IP gets priority, default inner outer
- priority-strategy: default
-
- # Add configurable job.state-watcher.fixed-delayed
-job:
- state-watcher:
- fixed-delayed: 1000
diff --git a/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql b/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql
index b415785b2..3197caf56 100644
--- a/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql
+++ b/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql
@@ -487,7 +487,6 @@ create table if not exists `t_access_token` (
primary key(`id`)
);
-
-- ----------------------------
-- Table of t_external_link definition
-- ----------------------------
@@ -502,7 +501,6 @@ create table if not exists `t_external_link` (
primary key(`id`)
);
-
-- ----------------------------
-- table structure for t_yarn_queue
-- ----------------------------
@@ -518,21 +516,6 @@ create table if not exists `t_yarn_queue` (
primary key (`id`)
);
--- ----------------------------
--- Table structure for t_flink_catalog
--- ----------------------------
-create table if not exists t_flink_catalog (
- `id` BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
- `team_id` bigint not null,
- `user_id` bigint default null,
- `catalog_type` varchar(255) not NULL,
- `catalog_name` VARCHAR(255) NOT NULL,
- `configuration` text,
- `create_time` TIMESTAMP WITHOUT TIME ZONE DEFAULT NULL,
- `update_time` TIMESTAMP WITHOUT TIME ZONE DEFAULT NULL,
- CONSTRAINT uniq_catalog_name UNIQUE (`catalog_name`)
-);
-
-- ----------------------------
-- Table structure for t_spark_env
-- ----------------------------
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/DatabaseServiceTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/DatabaseServiceTest.java
deleted file mode 100644
index 99bf17ba4..000000000
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/DatabaseServiceTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.common.enums.CatalogType;
-import org.apache.streampark.console.base.exception.ApiAlertException;
-import org.apache.streampark.console.core.bean.DatabaseParam;
-import org.apache.streampark.console.core.bean.FlinkCatalogParams;
-import org.apache.streampark.console.core.entity.FlinkCatalog;
-import org.apache.streampark.console.core.service.container.MysqlBaseITCASE;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class DatabaseServiceTest extends MysqlBaseITCASE {
-
- @Autowired
- private FlinkCatalogService catalogService;
-
- @Autowired
- private DatabaseService databaseService;
-
- private FlinkCatalogParams flinkCatalog = new FlinkCatalogParams();
-
- @BeforeEach
- public void setup() {
- flinkCatalog.setCatalogName("flink-test");
- flinkCatalog.setTeamId(1L);
- flinkCatalog.setUserId(1L);
- flinkCatalog.setCatalogType(CatalogType.JDBC);
- FlinkCatalogParams.FlinkJDBCCatalog flinkJDBCCatalog =
- new FlinkCatalogParams.FlinkJDBCCatalog();
- flinkJDBCCatalog.setBaseUrl(MYSQL_CONTAINER.getJdbcUrl());
- flinkJDBCCatalog.setType(CatalogType.JDBC.name().toLowerCase());
- flinkJDBCCatalog.setDefaultDatabase(MYSQL_CONTAINER.getDatabaseName());
- flinkJDBCCatalog.setUsername(MYSQL_CONTAINER.getUsername());
- flinkJDBCCatalog.setPassword(MYSQL_CONTAINER.getPassword());
- flinkCatalog.setFlinkJDBCCatalog(flinkJDBCCatalog);
- catalogService.create(flinkCatalog, 1L);
- FlinkCatalog fc = catalogService.getCatalog("flink-test");
- flinkCatalog.setId(fc.getId());
- }
-
- @AfterEach
- void destroy() {
- FlinkCatalog fc = catalogService.getCatalog("flink-test");
- catalogService.remove(flinkCatalog.getId());
- }
-
- // @Test
- public void testDatabaseExists_Positive() {
- DatabaseParam dbParam = new DatabaseParam();
- dbParam.setCatalogId(flinkCatalog.getId());
- dbParam.setCatalogName(flinkCatalog.getCatalogName());
- dbParam.setName(MYSQL_CONTAINER.getDatabaseName());
-
- assertTrue(databaseService.databaseExists(dbParam));
- }
-
- // @Test
- public void testCreateDatabase_Negative() {
- DatabaseParam dbParam = new DatabaseParam();
- dbParam.setCatalogId(flinkCatalog.getId());
- dbParam.setName("new_db");
- dbParam.setIgnoreIfExits(false);
-
- Exception exception =
- assertThrows(
- UnsupportedOperationException.class,
- () -> {
- databaseService.createDatabase(dbParam);
- });
- assertNull(exception.getMessage());
- }
-
- // @Test
- public void testListDatabases_Positive() {
- List<DatabaseParam> databaseParamList = databaseService.listDatabases(flinkCatalog.getId());
- assertNotNull(databaseParamList);
- }
-
- // @Test
- public void testListDatabases_Negative_NoDatabases() {
-
- Exception exception =
- assertThrows(
- ApiAlertException.class,
- () -> {
- databaseService.listDatabases(null);
- });
-
- assertEquals(
- "The catalog can't be null. get catalog from database failed.", exception.getMessage());
- }
-
- // @Test
- public void testDropDatabase_Positive() {
- DatabaseParam dbParam = new DatabaseParam();
- dbParam.setCatalogId(flinkCatalog.getId());
- dbParam.setCatalogName(flinkCatalog.getCatalogName());
- dbParam.setName(MYSQL_CONTAINER.getDatabaseName());
- dbParam.setCascade(true);
- dbParam.setIgnoreIfExits(true);
- Exception exception =
- assertThrows(
- UnsupportedOperationException.class,
- () -> {
- databaseService.dropDatabase(dbParam);
- });
- assertEquals(null, exception.getMessage());
- }
-
- // @Test
- public void testDropDatabase_Negative_NullDatabaseName() {
- DatabaseParam dbParam = new DatabaseParam();
- dbParam.setCatalogId(1L);
- dbParam.setName(null);
-
- Exception exception =
- assertThrows(
- ApiAlertException.class,
- () -> {
- databaseService.dropDatabase(dbParam);
- });
-
- assertEquals("Database name can not be null.", exception.getMessage());
- }
-}
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/DistributedTaskServiceTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/DistributedTaskServiceTest.java
deleted file mode 100644
index 9149101b0..000000000
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/DistributedTaskServiceTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.console.core.bean.FlinkTaskItem;
-import org.apache.streampark.console.core.bean.SparkTaskItem;
-import org.apache.streampark.console.core.entity.DistributedTask;
-import org.apache.streampark.console.core.entity.FlinkApplication;
-import org.apache.streampark.console.core.entity.SparkApplication;
-import org.apache.streampark.console.core.enums.DistributedTaskEnum;
-import org.apache.streampark.console.core.service.impl.DistributedTaskServiceImpl;
-
-import lombok.extern.slf4j.Slf4j;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-@Slf4j
-class DistributedTaskServiceTest {
-
- private final DistributedTaskServiceImpl distributionTaskService = new DistributedTaskServiceImpl();
-
- private final String serverId = "testServer";
- private final Set<String> allServers = new HashSet<>(Collections.singleton(serverId));
-
- // the number of virtual nodes for each server
- private final int numberOfReplicas = 2 << 16;
-
- @Test
- void testInit() {
- distributionTaskService.init(allServers, serverId);
- assert (distributionTaskService.getConsistentHashSize() == numberOfReplicas);
- }
-
- @Test
- void testIsLocalProcessing() {
- distributionTaskService.init(allServers, serverId);
- for (long i = 0; i < numberOfReplicas; i++) {
- assert (distributionTaskService.isLocalProcessing(i));
- }
- }
-
- @Test
- void testFlinkTaskAndApp() {
- FlinkApplication application = new FlinkApplication();
- application.setId(0L);
- try {
- DistributedTask distributedTask =
- distributionTaskService.getDistributedTaskByFlinkApp(application, false, DistributedTaskEnum.START);
- FlinkTaskItem flinkTaskItem = distributionTaskService.getFlinkTaskItem(distributedTask);
- FlinkApplication newApplication = distributionTaskService.getAppByFlinkTaskItem(flinkTaskItem);
- assert (application.equals(newApplication));
- } catch (Exception e) {
- log.error("testFlinkTaskAndApp failed:", e);
- }
- }
-
- @Test
- void testSparkTaskAndApp() {
- SparkApplication application = new SparkApplication();
- application.setId(0L);
- try {
- DistributedTask distributedTask =
- distributionTaskService.getDistributedTaskBySparkApp(application, false, DistributedTaskEnum.START);
- SparkTaskItem sparkTaskItem = distributionTaskService.getSparkTaskItem(distributedTask);
- SparkApplication newApplication = distributionTaskService.getAppBySparkTaskItem(sparkTaskItem);
- assert (application.equals(newApplication));
- } catch (Exception e) {
- log.error("testSparkTaskAndApp failed:", e);
- }
- }
-
-}
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/FlinkCatalogServiceTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/FlinkCatalogServiceTest.java
deleted file mode 100644
index b6089adf9..000000000
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/FlinkCatalogServiceTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.common.enums.CatalogType;
-import org.apache.streampark.console.SpringUnitTestBase;
-import org.apache.streampark.console.base.domain.RestRequest;
-import org.apache.streampark.console.core.bean.FlinkCatalogParams;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Order;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/** CatalogService Tests */
-public class FlinkCatalogServiceTest extends SpringUnitTestBase {
-
- @Autowired
- private FlinkCatalogService catalogService;
-
- @AfterEach
- void cleanTestRecordsInDatabase() {
- catalogService.remove(new QueryWrapper<>());
- }
-
- @Test
- @Order(1)
- public void create() {
- FlinkCatalogParams catalog = new FlinkCatalogParams();
- catalog.setTeamId(1L);
- catalog.setCatalogType(CatalogType.JDBC);
- catalog.setCatalogName("catalog-name");
- FlinkCatalogParams.FlinkJDBCCatalog flinkJDBCCatalog =
- new FlinkCatalogParams.FlinkJDBCCatalog();
- flinkJDBCCatalog.setType("jdbc");
- flinkJDBCCatalog.setDefaultDatabase("aa");
- flinkJDBCCatalog.setPassword("11");
- flinkJDBCCatalog.setUsername("user");
- flinkJDBCCatalog.setBaseUrl("url");
- catalog.setFlinkJDBCCatalog(flinkJDBCCatalog);
-
- boolean create = catalogService.create(catalog, 1L);
- assertThat(create).isTrue();
- }
-
- @Test
- @Order(2)
- public void update() {
- FlinkCatalogParams catalog = new FlinkCatalogParams();
- catalog.setTeamId(1L);
- catalog.setCatalogType(CatalogType.JDBC);
- catalog.setCatalogName("catalog-name");
- FlinkCatalogParams.FlinkJDBCCatalog flinkJDBCCatalog =
- new FlinkCatalogParams.FlinkJDBCCatalog();
- flinkJDBCCatalog.setType("jdbc");
- flinkJDBCCatalog.setDefaultDatabase("aa");
- flinkJDBCCatalog.setPassword("11");
- flinkJDBCCatalog.setUsername("user");
- flinkJDBCCatalog.setBaseUrl("url1");
- catalog.setFlinkJDBCCatalog(flinkJDBCCatalog);
- RestRequest request = new RestRequest();
- catalogService.create(catalog, 1L);
-
- IPage<FlinkCatalogParams> catalogIPage = catalogService.page(catalog, request);
- FlinkCatalogParams catalogs = catalogIPage.getRecords().get(0);
- catalogs.getFlinkJDBCCatalog().setBaseUrl("url2");
- catalogService.update(catalogs, 2L);
-
- IPage<FlinkCatalogParams> catalogResult = catalogService.page(catalog, request);
-
- assertThat(
- catalogResult.getRecords().get(0).getFlinkJDBCCatalog().getBaseUrl().contains("url2"))
- .isTrue();
- assertThat(catalogResult.getRecords().get(0).getUserId().equals(2L)).isTrue();
- assertThat(catalogResult.getRecords().get(0).getCatalogType().equals(CatalogType.JDBC))
- .isTrue();
- }
-
- @Test
- @Order(3)
- public void remove() {
- FlinkCatalogParams catalog = new FlinkCatalogParams();
- catalog.setTeamId(1L);
- catalog.setCatalogType(CatalogType.JDBC);
- catalog.setCatalogName("catalog-name");
- FlinkCatalogParams.FlinkJDBCCatalog flinkJDBCCatalog =
- new FlinkCatalogParams.FlinkJDBCCatalog();
- flinkJDBCCatalog.setType("jdbc");
- flinkJDBCCatalog.setDefaultDatabase("aa");
- flinkJDBCCatalog.setPassword("11");
- flinkJDBCCatalog.setUsername("user");
- flinkJDBCCatalog.setBaseUrl("url");
- catalog.setFlinkJDBCCatalog(flinkJDBCCatalog);
- catalogService.create(catalog, 1L);
- RestRequest request = new RestRequest();
- IPage<FlinkCatalogParams> catalogIPage = catalogService.page(catalog, request);
- boolean deleted = catalogService.remove(catalogIPage.getRecords().get(0).getId());
- assertThat(deleted).isTrue();
- }
-}
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/RegistryServiceTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/RegistryServiceTest.java
deleted file mode 100644
index 66e3c73a7..000000000
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/RegistryServiceTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.common.util.SystemPropertyUtils;
-import org.apache.streampark.console.core.service.impl.RegistryServiceImpl;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class RegistryServiceTest {
-
- private final RegistryServiceImpl registryService = new RegistryServiceImpl();
-
- @Test
- public void testRegister() {
- if (enableHA()) {
- try {
- registryService.registry();
- } catch (Exception e) {
- Assertions.assertEquals(1, registryService.getCurrentNodes().size());
- registryService.unRegister();
- }
- }
- }
-
- public boolean enableHA() {
- return SystemPropertyUtils.get("high-availability.enable", "false").equals("true");
- }
-
-}
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/TableServiceTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/TableServiceTest.java
deleted file mode 100644
index 38bfeb3d4..000000000
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/TableServiceTest.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service;
-
-import org.apache.streampark.common.enums.CatalogType;
-import org.apache.streampark.console.base.exception.ApiAlertException;
-import org.apache.streampark.console.core.bean.FlinkCatalogParams;
-import org.apache.streampark.console.core.bean.FlinkDataType;
-import org.apache.streampark.console.core.bean.TableColumn;
-import org.apache.streampark.console.core.bean.TableParams;
-import org.apache.streampark.console.core.entity.FlinkCatalog;
-import org.apache.streampark.console.core.service.container.MysqlBaseITCASE;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Order;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class TableServiceTest extends MysqlBaseITCASE {
-
- @Autowired
- private FlinkCatalogService catalogService;
- @Autowired
- private TableService tableService;
- private FlinkCatalogParams flinkCatalog = new FlinkCatalogParams();
- private final String FLINK_TABLE = "flink_test";
- private final String FLINK_NEW_TABLE = "flink_test_new";
-
- @BeforeEach
- public void setUp() {
- flinkCatalog.setCatalogName("flink-test");
- flinkCatalog.setTeamId(1L);
- flinkCatalog.setUserId(1L);
- flinkCatalog.setCatalogType(CatalogType.JDBC);
- FlinkCatalogParams.FlinkJDBCCatalog flinkJDBCCatalog =
- new FlinkCatalogParams.FlinkJDBCCatalog();
- flinkJDBCCatalog.setBaseUrl(MYSQL_CONTAINER.getJdbcUrl());
- flinkJDBCCatalog.setType(CatalogType.JDBC.name().toLowerCase());
- flinkJDBCCatalog.setDefaultDatabase(MYSQL_CONTAINER.getDatabaseName());
- flinkJDBCCatalog.setUsername(MYSQL_CONTAINER.getUsername());
- flinkJDBCCatalog.setPassword(MYSQL_CONTAINER.getPassword());
- flinkCatalog.setFlinkJDBCCatalog(flinkJDBCCatalog);
- catalogService.create(flinkCatalog, 1L);
- FlinkCatalog fc = catalogService.getCatalog("flink-test");
- flinkCatalog.setId(fc.getId());
- }
-
- @AfterEach
- void destroy() {
- FlinkCatalog fc = catalogService.getCatalog("flink-test");
- catalogService.remove(flinkCatalog.getId());
- }
-
- // @Test
- @Order(1)
- public void testTableExists_Positive() {
- TableParams tableParams = new TableParams();
- tableParams.setCatalogId(flinkCatalog.getId());
- tableParams.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
- tableParams.setName(FLINK_TABLE);
-
- assertTrue(tableService.tableExists(tableParams));
- }
-
- // @Test
- @Order(2)
- public void testTableExists_Negative_CatalogNotFound() {
- TableParams tableParams = new TableParams();
- tableParams.setCatalogId(-100L);
- tableParams.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
- tableParams.setName(FLINK_TABLE);
-
- Exception exception =
- assertThrows(ApiAlertException.class, () -> tableService.tableExists(tableParams));
- assertEquals("Catalog is not exit.", exception.getMessage());
- }
-
- // @Test
- @Order(3)
- public void testCreateTable_Positive() {
- TableParams tableParams = new TableParams();
- tableParams.setCatalogId(flinkCatalog.getId());
- tableParams.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
- tableParams.setName(FLINK_TABLE);
- tableParams.setDescription("Test table");
- List<String> partitionKeyList = new ArrayList();
- partitionKeyList.add("A");
- tableParams.setPartitionKey(partitionKeyList);
- Map<String, String> optionMap = new HashMap<>();
- optionMap.put("A", "A");
- tableParams.setTableOptions(optionMap);
- FlinkDataType flinkDataType = new FlinkDataType("INT", true, 8, 16);
- tableParams.setTableColumns(
- Collections.singletonList(
- new TableColumn(1, "A", flinkDataType, "table test", true, "1", 1)));
-
- Exception exception =
- assertThrows(
- UnsupportedOperationException.class, () -> tableService.createTable(tableParams));
- assertEquals(null, exception.getMessage());
- }
-
- // @Test
- @Order(4)
- public void testCreateTable_Negative_TableNameNull() {
- TableParams tableParams = new TableParams();
- tableParams.setCatalogId(flinkCatalog.getId());
- tableParams.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
- tableParams.setName(null);
- tableParams.setDescription("Test table");
- FlinkDataType flinkDataType = new FlinkDataType("INT", true, 8, 16);
- tableParams.setTableColumns(
- Collections.singletonList(
- new TableColumn(1, "A", flinkDataType, "table test", false, "1", 1)));
-
- Exception exception =
- assertThrows(ApiAlertException.class, () -> tableService.createTable(tableParams));
- assertEquals("Table name can not be null.", exception.getMessage());
- }
-
- // @Test
- @Order(5)
- public void testAddColumn_Positive() {
- TableParams tableParams = new TableParams();
- tableParams.setCatalogId(flinkCatalog.getId());
- tableParams.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
- tableParams.setName(FLINK_TABLE);
- tableParams.setDescription("Test table");
- FlinkDataType flinkDataType = new FlinkDataType("INT", true, 8, 16);
- tableParams.setTableColumns(
- Collections.singletonList(
- new TableColumn(1, "B", flinkDataType, "table test", false, "1", 1)));
-
- Exception exception =
- assertThrows(
- UnsupportedOperationException.class, () -> tableService.addColumn(tableParams));
- assertEquals(null, exception.getMessage());
- }
-
- // @Test
- @Order(6)
- public void testAddColumn_Negative_TableNameNull() {
- TableParams tableParams = new TableParams();
- tableParams.setCatalogId(flinkCatalog.getId());
- tableParams.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
- tableParams.setName(null);
- tableParams.setDescription("Test table");
- FlinkDataType flinkDataType = new FlinkDataType("INT", true, 8, 16);
- tableParams.setTableColumns(
- Collections.singletonList(
- new TableColumn(1, "A", flinkDataType, "table test", false, "1", 1)));
-
- Exception exception =
- assertThrows(ApiAlertException.class, () -> tableService.addColumn(tableParams));
- assertEquals("Table name can not be null.", exception.getMessage());
- }
-
- // @Test
- @Order(7)
- public void testDropColumn() {
- String catalogName = flinkCatalog.getCatalogName();
- String databaseName = MYSQL_CONTAINER.getDatabaseName();
- String tableName = FLINK_TABLE;
- String columnName = "A";
- Exception exception =
- assertThrows(
- UnsupportedOperationException.class,
- () -> tableService.dropColumn(catalogName, databaseName, tableName, columnName));
- assertEquals(null, exception.getMessage());
- }
-
- // @Test
- @Order(8)
- public void testDropColumn_Negative_TableNameNull() {
- String catalogName = "flink-test";
- String databaseName = "test_db";
- String columnName = "old_column";
-
- Exception exception =
- assertThrows(
- ApiAlertException.class,
- () -> tableService.dropColumn(catalogName, databaseName, null, columnName));
- assertEquals("Table name can not be null.", exception.getMessage());
- }
-
- // @Test
- @Order(9)
- public void testAddOption() {
- TableParams tableParams = new TableParams();
- tableParams.setCatalogId(flinkCatalog.getId());
- tableParams.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
- tableParams.setName(FLINK_TABLE);
- tableParams.setTableOptions(Collections.singletonMap("key", "value"));
-
- Exception exception =
- assertThrows(
- UnsupportedOperationException.class, () -> tableService.addOption(tableParams));
- assertEquals(
- "Unsupported table change type: org.apache.flink.table.catalog.TableChange$SetOption",
- exception.getMessage());
- }
-
- // @Test
- @Order(10)
- public void testAddOption_Negative_OptionsNull() {
- TableParams tableParams = new TableParams();
- tableParams.setCatalogId(flinkCatalog.getId());
- tableParams.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
- tableParams.setName(FLINK_TABLE);
-
- Exception exception =
- assertThrows(ApiAlertException.class, () -> tableService.addOption(tableParams));
- assertEquals("Table options can not be null.", exception.getMessage());
- }
-
- // @Test
- @Order(12)
- public void testDropTable_Negative_TableNameNull() {
- String catalogName = "test_catalog";
- String databaseName = "test_db";
-
- Exception exception =
- assertThrows(
- ApiAlertException.class, () -> tableService.dropTable(catalogName, databaseName, null));
- assertEquals("Table name can not be null.", exception.getMessage());
- }
-
- // @Test
- @Order(13)
- public void testRenameTable() {
- String catalogName = flinkCatalog.getCatalogName();
- String databaseName = MYSQL_CONTAINER.getDatabaseName();
- Exception exception =
- assertThrows(
- UnsupportedOperationException.class,
- () -> tableService.renameTable(catalogName, databaseName, FLINK_TABLE, FLINK_NEW_TABLE));
- assertEquals(null, exception.getMessage());
- }
-
- // @Test
- @Order(14)
- public void testRenameTable_Negative_FromTableNameNull() {
- String catalogName = "test_catalog";
- String databaseName = "test_db";
- String toTableName = "new_table";
-
- Exception exception =
- assertThrows(
- ApiAlertException.class,
- () -> tableService.renameTable(catalogName, databaseName, null, toTableName));
- assertEquals("From table name can not be null.", exception.getMessage());
- }
-
- // @Test
- @Order(15)
- public void testListTables_Positive() {
- TableParams tableParams = new TableParams();
- tableParams.setCatalogId(flinkCatalog.getId());
- tableParams.setCatalogName(flinkCatalog.getCatalogName());
- tableParams.setDatabaseName(MYSQL_CONTAINER.getDatabaseName());
- tableParams.setName(FLINK_TABLE);
-
- List<TableParams> result = tableService.listTables(tableParams);
- assertNotNull(result);
- assertEquals(1, result.size());
- }
-
- // @Test
- @Order(16)
- public void testListTables_Negative_DatabaseNameNull() {
- TableParams tableParams = new TableParams();
- tableParams.setCatalogId(flinkCatalog.getId());
- tableParams.setDatabaseName(null);
- tableParams.setName("test_table");
-
- Exception exception =
- assertThrows(ApiAlertException.class, () -> tableService.listTables(tableParams));
- assertEquals("Database name can not be null.", exception.getMessage());
- }
-
- // @Test
- @Order(17)
- public void testListColumns_Positive() {
- String catalogName = flinkCatalog.getCatalogName();
- String databaseName = MYSQL_CONTAINER.getDatabaseName();
- TableParams result = tableService.listColumns(catalogName, databaseName, FLINK_TABLE);
- assertNotNull(result);
- }
-
- // @Test
- @Order(17)
- public void testListColumns_Negative_DatabaseNameNull() {
- String catalogName = "test_catalog";
- String tableName = "test_table";
-
- Exception exception =
- assertThrows(
- ApiAlertException.class, () -> tableService.listColumns(catalogName, null, tableName));
- assertEquals("Database name can not be null.", exception.getMessage());
- }
-}
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/container/MySqlContainer.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/container/MySqlContainer.java
deleted file mode 100644
index 0a29307c7..000000000
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/container/MySqlContainer.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service.container;
-
-import org.testcontainers.containers.ContainerLaunchException;
-import org.testcontainers.containers.JdbcDatabaseContainer;
-import org.testcontainers.utility.DockerImageName;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class MySqlContainer extends JdbcDatabaseContainer {
-
- public static final String IMAGE = "mysql";
-
- public static final String MYSQL_VERSION = "8.0";
- public static final Integer MYSQL_PORT = 3306;
-
- private static final String MY_CNF_CONFIG_OVERRIDE_PARAM_NAME = "MY_CNF";
- private static final String SETUP_SQL_PARAM_NAME = "SETUP_SQL";
- private static final String MYSQL_ROOT_USER = "root";
-
- private String databaseName = "test";
- private String username = "test";
- private String password = "test";
-
- public MySqlContainer() {
- this(MYSQL_VERSION);
- }
-
- public MySqlContainer(String version) {
- super(DockerImageName.parse(IMAGE + ":" + version));
- addExposedPort(MYSQL_PORT);
- }
-
- @Override
- protected Set<Integer> getLivenessCheckPorts() {
- return new HashSet<>(getMappedPort(MYSQL_PORT));
- }
-
- @Override
- protected void configure() {
- optionallyMapResourceParameterAsVolume(
- MY_CNF_CONFIG_OVERRIDE_PARAM_NAME, "/etc/mysql/", "mysql-default-conf");
-
- if (parameters.containsKey(SETUP_SQL_PARAM_NAME)) {
- optionallyMapResourceParameterAsVolume(
- SETUP_SQL_PARAM_NAME, "/docker-entrypoint-initdb.d/", "N/A");
- }
-
- addEnv("MYSQL_DATABASE", databaseName);
- addEnv("MYSQL_USER", username);
- if (password != null && !password.isEmpty()) {
- addEnv("MYSQL_PASSWORD", password);
- addEnv("MYSQL_ROOT_PASSWORD", password);
- } else if (MYSQL_ROOT_USER.equalsIgnoreCase(username)) {
- addEnv("MYSQL_ALLOW_EMPTY_PASSWORD", "yes");
- } else {
- throw new ContainerLaunchException("Empty password can be used only with the root user");
- }
- setStartupAttempts(3);
- }
-
- @Override
- public String getDriverClassName() {
- try {
- Class.forName("com.mysql.cj.jdbc.Driver");
- return "com.mysql.cj.jdbc.Driver";
- } catch (ClassNotFoundException e) {
- return "com.mysql.jdbc.Driver";
- }
- }
-
- public String getJdbcUrl(String databaseName) {
- return "jdbc:mysql://" + getHost() + ":" + getDatabasePort();
- }
-
- @Override
- public String getJdbcUrl() {
- return getJdbcUrl(databaseName);
- }
-
- public int getDatabasePort() {
- return getMappedPort(MYSQL_PORT);
- }
-
- @Override
- protected String constructUrlForConnection(String queryString) {
- String url = super.constructUrlForConnection(queryString);
-
- if (!url.contains("useSSL=")) {
- String separator = url.contains("?") ? "&" : "?";
- url = url + separator + "useSSL=false";
- }
-
- if (!url.contains("allowPublicKeyRetrieval=")) {
- url = url + "&allowPublicKeyRetrieval=true";
- }
-
- return url;
- }
-
- @Override
- public String getDatabaseName() {
- return databaseName;
- }
-
- @Override
- public String getUsername() {
- return username;
- }
-
- @Override
- public String getPassword() {
- return password;
- }
-
- @Override
- protected String getTestQueryString() {
- return "SELECT 1";
- }
-
- @SuppressWarnings("unchecked")
- public MySqlContainer withConfigurationOverride(String s) {
- parameters.put(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME, s);
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public MySqlContainer withSetupSQL(String sqlPath) {
- parameters.put(SETUP_SQL_PARAM_NAME, sqlPath);
- return this;
- }
-
- @Override
- public MySqlContainer withDatabaseName(final String databaseName) {
- this.databaseName = databaseName;
- return this;
- }
-
- @Override
- public MySqlContainer withUsername(final String username) {
- this.username = username;
- return this;
- }
-
- @Override
- public MySqlContainer withPassword(final String password) {
- this.password = password;
- return this;
- }
-}
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/container/MysqlBaseITCASE.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/container/MysqlBaseITCASE.java
deleted file mode 100644
index f00bfa1f8..000000000
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/container/MysqlBaseITCASE.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.console.core.service.container;
-
-import org.apache.streampark.console.SpringUnitTestBase;
-
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.output.Slf4jLogConsumer;
-import org.testcontainers.lifecycle.Startables;
-
-import java.util.stream.Stream;
-
-public class MysqlBaseITCASE extends SpringUnitTestBase {
-
- private static final Logger LOG = LoggerFactory.getLogger(MysqlBaseITCASE.class);
- protected static final MySqlContainer MYSQL_CONTAINER =
- createMySqlContainer("docker/server/my.cnf");
-
- @BeforeAll
- public static void startContainers() {
- LOG.info("Starting containers...");
- Startables.deepStart(Stream.of(MYSQL_CONTAINER)).join();
- LOG.info("Containers are started.");
- }
-
- @AfterAll
- public static void stopContainers() {
- LOG.info("Stopping containers...");
- if (MYSQL_CONTAINER != null) {
- MYSQL_CONTAINER.stop();
- }
- LOG.info("Containers are stopped.");
- }
-
- protected static MySqlContainer createMySqlContainer(String configPath) {
- return (MySqlContainer) new MySqlContainer(MySqlContainer.MYSQL_VERSION)
- .withConfigurationOverride(configPath)
- .withSetupSQL("docker/setup.sql")
- .withDatabaseName("flink-test")
- .withUsername("flinkuser")
- .withPassword("flinkpw")
- .withLogConsumer(new Slf4jLogConsumer(LOG));
- }
-}
diff --git a/streampark-console/streampark-console-service/src/test/resources/application-integration-test.yml b/streampark-console/streampark-console-service/src/test/resources/application-integration-test.yml
deleted file mode 100644
index e66514e53..000000000
--- a/streampark-console/streampark-console-service/src/test/resources/application-integration-test.yml
+++ /dev/null
@@ -1,61 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-logging:
- level:
- root: info
-
-spring:
- datasource:
- driver-class-name: org.h2.Driver
- url: jdbc:h2:mem:streampark;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;INIT=runscript from 'classpath:db/schema-h2.sql'
- username: sa
- password: sa
- sql:
- init:
- data-locations: classpath:db/data-h2.sql
- continue-on-error: true
- username: sa
- password: sa
- mode: always
-server:
- port: 6666
-
-streampark:
- workspace:
- local: /tmp
- # remote: hdfs://hdfscluster/streampark
- # hadoop-user-name: root
-
-job:
- state-watcher:
- fixed-delayed: 1000
-
-table:
- catalog-store:
- kind: jdbc
- jdbc:
- url: jdbc://mysql:127.0.0.1:3306/flink-test
- # The JDBC database url.
- table-name: t_flink_catalog
- ## catalog store table
- driver: com.mysql.cj.jdbc.Driver
- # The class name of the JDBC driver to use to connect to this URL, if not set, it will automatically be derived from the URL.
- username: flinkuser
- # The JDBC user name. 'username' and 'password' must both be specified if any of them is specified.
- password: flinkpw
- # The JDBC password.
- max-retry-timeout: 600
diff --git a/streampark-console/streampark-console-service/src/test/resources/application-test.yml b/streampark-console/streampark-console-service/src/test/resources/application-test.yml
index 9b3d1e1ce..d702d2adb 100644
--- a/streampark-console/streampark-console-service/src/test/resources/application-test.yml
+++ b/streampark-console/streampark-console-service/src/test/resources/application-test.yml
@@ -35,41 +35,3 @@ spring:
username: sa
password: sa
mode: always
-## flink catalog store config
-table:
- catalog-store:
- kind: jdbc
- jdbc:
- url: jdbc://mysql:127.0.0.1:3306/flink-test
- # The JDBC database url.
- table-name: t_flink_catalog
- ## catalog store table
- driver: com.mysql.cj.jdbc.Driver
- # The class name of the JDBC driver to use to connect to this URL, if not set, it will automatically be derived from the URL.
- username: flinkuser
- # The JDBC user name. 'username' and 'password' must both be specified if any of them is specified.
- password: flinkpw
- # The JDBC password.
- max-retry-timeout: 600
-
-streampark:
- # console heartbeat interval
- max-heartbeat-interval: 10s
-
-registry:
- # default using jdbc as registry
- type: jdbc
- heartbeat-refresh-interval: 1s
- session-timeout: 3s
-
-network:
- # network interface preferred like eth0, default: empty
- preferred-interface: ""
- # network interface restricted like docker0, default: empty
- restrict-interface: docker0
- # network IP gets priority, default inner outer
- priority-strategy: default
-
-job:
- state-watcher:
- fixed-delayed: 1000
diff --git a/streampark-console/streampark-console-service/src/test/resources/docker/server/my.cnf b/streampark-console/streampark-console-service/src/test/resources/docker/server/my.cnf
deleted file mode 100644
index 953ffe8f9..000000000
--- a/streampark-console/streampark-console-service/src/test/resources/docker/server/my.cnf
+++ /dev/null
@@ -1,64 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# For advice on how to change settings please see
-# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
-
-[mysqld]
-#
-# Remove leading # and set to the amount of RAM for the most important data
-# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
-# innodb_buffer_pool_size = 128M
-#
-# Remove leading # to turn on a very important data integrity option: logging
-# changes to the binary log between backups.
-# log_bin
-#
-# Remove leading # to set options mainly useful for reporting servers.
-# The server defaults are faster for transactions and fast SELECTs.
-# Adjust sizes as needed, experiment to find the optimal values.
-# join_buffer_size = 128M
-# sort_buffer_size = 2M
-# read_rnd_buffer_size = 2M
-skip-host-cache
-skip-name-resolve
-#datadir=/var/lib/mysql
-#socket=/var/lib/mysql/mysql.sock
-secure-file-priv=/var/lib/mysql
-user=mysql
-
-# Disabling symbolic-links is recommended to prevent assorted security risks
-symbolic-links=0
-
-#log-error=/var/log/mysqld.log
-#pid-file=/var/run/mysqld/mysqld.pid
-
-# ----------------------------------------------
-# Enable the binlog for replication & CDC
-# ----------------------------------------------
-
-# Enable binary replication log and set the prefix, expiration, and log format.
-# The prefix is arbitrary, expiration can be short for integration tests but would
-# be longer on a production system. Row-level info is required for ingest to work.
-# Server ID is required, but this will vary on production systems.
-server-id = 223344
-log_bin = mysql-bin
-binlog_format = row
-# Make binlog_expire_logs_seconds = 1 and max_binlog_size = 4096 to test the exception
-# message when the binlog expires in the server.
-binlog_expire_logs_seconds = 1
-max_binlog_size = 4096
-
-# enable gtid mode
-gtid_mode = on
-enforce_gtid_consistency = on
\ No newline at end of file
diff --git a/streampark-console/streampark-console-service/src/test/resources/docker/setup.sql b/streampark-console/streampark-console-service/src/test/resources/docker/setup.sql
deleted file mode 100644
index ee1bf53f5..000000000
--- a/streampark-console/streampark-console-service/src/test/resources/docker/setup.sql
+++ /dev/null
@@ -1,41 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one or more
--- contributor license agreements. See the NOTICE file distributed with
--- this work for additional information regarding copyright ownership.
--- The ASF licenses this file to You under the Apache License, Version 2.0
--- (the "License"); you may not use this file except in compliance with
--- the License. You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- In production you would almost certainly limit the replication user must be on the follower (slave) machine,
--- to prevent other clients accessing the log from other machines. For example, 'replicator'@'follower.acme.com'.
--- However, in this database we'll grant 2 users different privileges:
---
--- 1) 'flinkuser' - all privileges required by the snapshot reader AND binlog reader (used for testing)
--- 2) 'mysqluser' - all privileges
---
-GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT, LOCK TABLES ON *.* TO 'flinkuser'@'%';
-CREATE USER 'mysqluser' IDENTIFIED BY 'mysqlpw';
-GRANT ALL PRIVILEGES ON *.* TO 'mysqluser'@'%';
-
--- ----------------------------------------------------------------------------------------------------------------
--- DATABASE: emptydb
--- ----------------------------------------------------------------------------------------------------------------
-CREATE DATABASE emptydb;
-USE flink-test;
-create table flink_test (
- `id` bigint NOT NULL AUTO_INCREMENT,
- `catalog_name` varchar(255) NOT NULL,
- `configuration` text,
- `create_time` datetime DEFAULT NULL,
- `update_time` datetime DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE INDEX `uniq_catalog_name` (`catalog_name`) USING BTREE
-)
-
diff --git a/streampark-flink/pom.xml b/streampark-flink/pom.xml
index 154362715..44f95abaa 100644
--- a/streampark-flink/pom.xml
+++ b/streampark-flink/pom.xml
@@ -37,8 +37,6 @@
<module>streampark-flink-proxy</module>
<module>streampark-flink-packer</module>
<module>streampark-flink-kubernetes</module>
- <module>streampark-flink-catalog-store</module>
- <module>streampark-flink-connector-plugin</module>
<module>streampark-flink-cdcclient</module>
</modules>
diff --git a/streampark-flink/streampark-flink-catalog-store/pom.xml b/streampark-flink/streampark-flink-catalog-store/pom.xml
deleted file mode 100644
index 8105e29d0..000000000
--- a/streampark-flink/streampark-flink-catalog-store/pom.xml
+++ /dev/null
@@ -1,169 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<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">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.streampark</groupId>
- <artifactId>streampark-flink</artifactId>
- <version>2.2.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>streampark-flink-catalog-store</artifactId>
- <name>StreamPark : Flink Catalog Store</name>
-
- <properties>
- <flink.shaded.version19>19.0</flink.shaded.version19>
- <flink.shaded.jackson.version>2.15.3</flink.shaded.jackson.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-annotations</artifactId>
- <version>${flink.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-table-common</artifactId>
- <version>${flink.version}</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-shaded-jackson</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-compress</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-table-api-java</artifactId>
- <version>${flink.version}</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-shaded-jackson</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-compress</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-sql-gateway-api</artifactId>
- <version>${flink.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-shaded-jackson</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-table-api-java</artifactId>
- <version>${flink.version}</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-shaded-jackson</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-table-api-java-uber</artifactId>
- <version>${flink.version}</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-shaded-jackson</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-shaded-jackson</artifactId>
- <version>${flink.shaded.jackson.version}-${flink.shaded.version19}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.testcontainers</groupId>
- <artifactId>mysql</artifactId>
- <version>${testcontainer.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>shade</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <createDependencyReducedPom>true</createDependencyReducedPom>
- <dependencyReducedPomLocation>${project.basedir}/target/dependency-reduced-pom.xml</dependencyReducedPomLocation>
- <artifactSet>
- <includes>
- <include>org.apache.streampark:*</include>
- <include>org.apache.flink:flink-sql-gateway-api</include>
- </includes>
- </artifactSet>
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JacksonUtils.java b/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JacksonUtils.java
deleted file mode 100644
index 11cb6906e..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JacksonUtils.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog;
-
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.type.TypeReference;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationFeature;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.SerializationFeature;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.module.SimpleModule;
-
-/** Serialization utils */
-public final class JacksonUtils {
-
- private JacksonUtils() {
- }
-
- private static final ObjectMapper MAPPER;
-
- static {
- MAPPER = new ObjectMapper();
- MAPPER.registerModule(new SimpleModule());
- MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- MAPPER.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
- MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
- }
-
- public static <T> T read(String json, Class<T> clazz) throws JsonProcessingException {
- return MAPPER.readValue(json, clazz);
- }
-
- public static <T> T read(String json, TypeReference<T> typeReference) throws JsonProcessingException {
- return MAPPER.readValue(json, typeReference);
- }
-
- public static String write(Object object) throws JsonProcessingException {
- return MAPPER.writeValueAsString(object);
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JdbcCatalogStore.java b/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JdbcCatalogStore.java
deleted file mode 100644
index feeb76841..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JdbcCatalogStore.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog;
-
-import org.apache.streampark.catalog.connections.JdbcConnectionProvider;
-
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException;
-import org.apache.flink.table.catalog.AbstractCatalogStore;
-import org.apache.flink.table.catalog.CatalogDescriptor;
-import org.apache.flink.table.catalog.exceptions.CatalogException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-/**
- * Catalog Store for Jdbc.
- */
-public class JdbcCatalogStore extends AbstractCatalogStore {
-
- private static final Logger LOG = LoggerFactory.getLogger(JdbcCatalogStore.class);
- private final JdbcConnectionProvider jdbcConnectionProvider;
- private transient Connection connection;
- private transient Statement statement;
- private transient ResultSet resultSet;
-
- private final String catalogTableName;
-
- public JdbcCatalogStore(JdbcConnectionProvider jdbcConnectionProvider, String catalogTableName) {
- this.jdbcConnectionProvider = jdbcConnectionProvider;
- this.catalogTableName = catalogTableName;
- }
-
- @Override
- public void open() {
- try {
- this.connection = jdbcConnectionProvider.getOrEstablishConnection();
- this.statement = this.connection.createStatement();
- super.open();
- } catch (SQLException | ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void close() {
- closeResultSetAndStatement();
- try {
- jdbcConnectionProvider.close();
- } catch (Exception e) {
- throw new CatalogException(e);
- }
- super.close();
- }
-
- @Override
- public void storeCatalog(String catalogName, CatalogDescriptor catalogDescriptor) throws CatalogException {
- checkOpenState();
- try {
- if (!contains(catalogName)) {
- statement.executeUpdate(String.format(
- "insert into %s (catalog_name,configuration,create_time,update_time) values ('%s','%s',now(),now())",
- this.catalogTableName, catalogName,
- JacksonUtils.write(catalogDescriptor.getConfiguration().toMap())));
- } else {
- LOG.error("catalog {} is exist.", catalogName);
- }
- } catch (SQLException | JsonProcessingException e) {
- throw new CatalogException(String.format("Store catalog %s failed!", catalogName), e);
- }
- }
-
- @Override
- public void removeCatalog(String catalogName, boolean ignoreIfNotExists) throws CatalogException {
- checkOpenState();
- try {
- int effectRow = statement.executeUpdate(
- String.format("delete from %s where catalog_name='%s'", this.catalogTableName, catalogName));
-
- if (effectRow == 0 && !ignoreIfNotExists) {
- throw new CatalogException(String.format("Remove catalog %s failed!", catalogName));
- }
- } catch (SQLException e) {
- LOG.error("Remove catalog {} failed!", catalogName, e);
- throw new CatalogException(String.format("Remove catalog %s failed!", catalogName));
- }
- }
-
- @Override
- public Optional<CatalogDescriptor> getCatalog(String catalogName) throws CatalogException {
- checkOpenState();
- try {
- resultSet = statement
- .executeQuery(
- String.format("select * from %s where catalog_name='%s'", this.catalogTableName, catalogName));
- while (resultSet.next()) {
- return Optional.of(CatalogDescriptor.of(catalogName,
- Configuration.fromMap(JacksonUtils.read(resultSet.getString("configuration"), Map.class))));
- }
- } catch (SQLException | JsonProcessingException e) {
- throw new CatalogException(String.format("Get catalog %s failed!", catalogName), e);
- }
- return Optional.empty();
- }
-
- @Override
- public Set<String> listCatalogs() throws CatalogException {
- checkOpenState();
- Set<String> catalogs = new HashSet<>();
- try {
- resultSet = statement.executeQuery(String.format("select * from %s;", this.catalogTableName));
- while (resultSet.next()) {
- catalogs.add(resultSet.getString("catalog_name"));
- }
- return catalogs;
- } catch (SQLException e) {
- throw new CatalogException("List catalogs failed!", e);
- }
- }
-
- @Override
- public boolean contains(String catalogName) throws CatalogException {
- checkOpenState();
- try {
- resultSet = statement.executeQuery(
- String.format("select * from %s where catalog_name='%s';", this.catalogTableName, catalogName));
- while (resultSet.next()) {
- resultSet.getString("catalog_name");
- return true;
- }
- } catch (SQLException e) {
- throw new CatalogException(String.format("Catalog %s is contains failed!", catalogName), e);
- }
- return false;
- }
-
- private void closeResultSetAndStatement() {
- try {
- if (resultSet != null && !resultSet.isClosed()) {
- resultSet.close();
- }
- if (statement != null && !statement.isClosed()) {
- statement.close();
- }
- resultSet = null;
- statement = null;
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JdbcCatalogStoreFactory.java b/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JdbcCatalogStoreFactory.java
deleted file mode 100644
index 38aa6e5c7..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JdbcCatalogStoreFactory.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog;
-
-import org.apache.streampark.catalog.connections.JdbcConnectionOptions;
-import org.apache.streampark.catalog.connections.JdbcConnectionProvider;
-import org.apache.streampark.catalog.connections.SimpleJdbcConnectionProvider;
-
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ReadableConfig;
-import org.apache.flink.table.catalog.CatalogStore;
-import org.apache.flink.table.factories.CatalogStoreFactory;
-import org.apache.flink.table.factories.FactoryUtil;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.apache.flink.table.factories.FactoryUtil.createCatalogStoreFactoryHelper;
-import static org.apache.streampark.catalog.JdbcCatalogStoreFactoryOptions.DRIVER;
-import static org.apache.streampark.catalog.JdbcCatalogStoreFactoryOptions.IDENTIFIER;
-import static org.apache.streampark.catalog.JdbcCatalogStoreFactoryOptions.MAX_RETRY_TIMEOUT;
-import static org.apache.streampark.catalog.JdbcCatalogStoreFactoryOptions.PASSWORD;
-import static org.apache.streampark.catalog.JdbcCatalogStoreFactoryOptions.TABLE_NAME;
-import static org.apache.streampark.catalog.JdbcCatalogStoreFactoryOptions.URL;
-import static org.apache.streampark.catalog.JdbcCatalogStoreFactoryOptions.USERNAME;
-
-/** Catalog Store Factory for Jdbc. */
-public class JdbcCatalogStoreFactory implements CatalogStoreFactory {
-
- private JdbcConnectionProvider jdbcConnectionProvider;
- private transient String catalogTableName;
-
- @Override
- public CatalogStore createCatalogStore() {
- return new JdbcCatalogStore(jdbcConnectionProvider, this.catalogTableName);
- }
-
- @Override
- public void open(Context context) {
- FactoryUtil.FactoryHelper<CatalogStoreFactory> factoryHelper =
- createCatalogStoreFactoryHelper(this, context);
- factoryHelper.validate();
-
- ReadableConfig options = factoryHelper.getOptions();
- JdbcConnectionOptions jdbcConnectionOptions =
- new JdbcConnectionOptions.JdbcConnectionOptionsBuilder()
- .withUrl(options.get(URL))
- .withDriverName(options.get(DRIVER))
- .withUsername(options.get(USERNAME))
- .withPassword(options.get(PASSWORD))
- .withConnectionCheckTimeoutSeconds(options.get(MAX_RETRY_TIMEOUT))
- .build();
-
- this.catalogTableName = options.get(TABLE_NAME);
- this.jdbcConnectionProvider = new SimpleJdbcConnectionProvider(jdbcConnectionOptions);
- }
-
- @Override
- public void close() {
- this.jdbcConnectionProvider.closeConnection();
- }
-
- @Override
- public String factoryIdentifier() {
- return IDENTIFIER;
- }
-
- @Override
- public Set<ConfigOption<?>> requiredOptions() {
- Set<ConfigOption<?>> options = new HashSet<>();
- options.add(URL);
- options.add(DRIVER);
- options.add(USERNAME);
- options.add(PASSWORD);
- options.add(TABLE_NAME);
- return Collections.unmodifiableSet(options);
- }
-
- @Override
- public Set<ConfigOption<?>> optionalOptions() {
- Set<ConfigOption<?>> options = new HashSet<>();
- options.add(MAX_RETRY_TIMEOUT);
- return Collections.unmodifiableSet(options);
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JdbcCatalogStoreFactoryOptions.java b/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JdbcCatalogStoreFactoryOptions.java
deleted file mode 100644
index 85a324bb5..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/JdbcCatalogStoreFactoryOptions.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog;
-
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ConfigOptions;
-
-/**
- * Catalog Store Options for Jdbc.
- */
-public class JdbcCatalogStoreFactoryOptions {
-
- public static final String IDENTIFIER = "jdbc";
-
- public static final ConfigOption<String> URL =
- ConfigOptions.key("url")
- .stringType()
- .noDefaultValue()
- .withDescription(
- "The JDBC database url.");
- public static final ConfigOption<String> TABLE_NAME =
- ConfigOptions.key("table-name")
- .stringType()
- .noDefaultValue()
- .withDescription(
- "The name of JDBC table to connect.");
- public static final ConfigOption<String> DRIVER =
- ConfigOptions.key("driver")
- .stringType()
- .noDefaultValue()
- .withDescription(
- "The class name of the JDBC driver to use to connect to this URL, if not set, it will automatically be derived from the URL.");
- public static final ConfigOption<String> USERNAME =
- ConfigOptions.key("username")
- .stringType()
- .noDefaultValue()
- .withDescription(
- "The JDBC user name. 'username' and 'password' must both be specified if any of them is specified.");
-
- public static final ConfigOption<String> PASSWORD =
- ConfigOptions.key("password")
- .stringType()
- .noDefaultValue()
- .withDescription(
- "The JDBC password.");
-
- public static final ConfigOption<Integer> MAX_RETRY_TIMEOUT =
- ConfigOptions.key("max-retry-timeout")
- .intType()
- .defaultValue(60)
- .withDescription(
- "Maximum timeout between retries. The timeout should be in second granularity and shouldn't be smaller than 1 second.");
-
- private JdbcCatalogStoreFactoryOptions() {
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/connections/JdbcConnectionOptions.java b/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/connections/JdbcConnectionOptions.java
deleted file mode 100644
index 62f460d4e..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/connections/JdbcConnectionOptions.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog.connections;
-
-import org.apache.flink.util.Preconditions;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import java.io.Serializable;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Properties;
-
-public class JdbcConnectionOptions implements Serializable {
-
- public static final String USER_KEY = "user";
- public static final String PASSWORD_KEY = "password";
-
- private static final long serialVersionUID = 1L;
-
- protected final String url;
- @Nullable
- protected final String driverName;
- protected final int connectionCheckTimeoutSeconds;
- @Nonnull
- protected final Properties properties;
-
- protected JdbcConnectionOptions(
- String url,
- @Nullable String driverName,
- int connectionCheckTimeoutSeconds,
- @Nonnull Properties properties) {
- Preconditions.checkArgument(
- connectionCheckTimeoutSeconds > 0,
- "Connection check timeout seconds shouldn't be smaller than 1");
- this.url = Preconditions.checkNotNull(url, "jdbc url is empty");
- this.driverName = driverName;
- this.connectionCheckTimeoutSeconds = connectionCheckTimeoutSeconds;
- this.properties =
- Preconditions.checkNotNull(properties, "Connection properties must be non-null");
- }
-
- public String getDbURL() {
- return url;
- }
-
- @Nullable
- public String getDriverName() {
- return driverName;
- }
-
- public Optional<String> getUsername() {
- return Optional.ofNullable(properties.getProperty(USER_KEY));
- }
-
- public Optional<String> getPassword() {
- return Optional.ofNullable(properties.getProperty(PASSWORD_KEY));
- }
-
- public int getConnectionCheckTimeoutSeconds() {
- return connectionCheckTimeoutSeconds;
- }
-
- @Nonnull
- public Properties getProperties() {
- return properties;
- }
-
- @Nonnull
- public static Properties getBriefAuthProperties(String user, String password) {
- final Properties result = new Properties();
- if (Objects.nonNull(user)) {
- result.put(USER_KEY, user);
- }
- if (Objects.nonNull(password)) {
- result.put(PASSWORD_KEY, password);
- }
- return result;
- }
-
- /** Builder for {@link JdbcConnectionOptions}. */
- public static class JdbcConnectionOptionsBuilder {
-
- private String url;
- private String driverName;
- private int connectionCheckTimeoutSeconds = 60;
- private final Properties properties = new Properties();
-
- public JdbcConnectionOptionsBuilder withUrl(String url) {
- this.url = url;
- return this;
- }
-
- public JdbcConnectionOptionsBuilder withDriverName(String driverName) {
- this.driverName = driverName;
- return this;
- }
-
- public JdbcConnectionOptionsBuilder withProperty(String propKey, String propVal) {
- Preconditions.checkNotNull(propKey, "Connection property key mustn't be null");
- Preconditions.checkNotNull(propVal, "Connection property value mustn't be null");
- this.properties.put(propKey, propVal);
- return this;
- }
-
- public JdbcConnectionOptionsBuilder withUsername(String username) {
- if (Objects.nonNull(username)) {
- this.properties.put(USER_KEY, username);
- }
- return this;
- }
-
- public JdbcConnectionOptionsBuilder withPassword(String password) {
- if (Objects.nonNull(password)) {
- this.properties.put(PASSWORD_KEY, password);
- }
- return this;
- }
-
- /**
- * Set the maximum timeout between retries, default is 60 seconds.
- *
- * @param connectionCheckTimeoutSeconds the timeout seconds, shouldn't smaller than 1
- * second.
- */
- public JdbcConnectionOptionsBuilder withConnectionCheckTimeoutSeconds(
- int connectionCheckTimeoutSeconds) {
- this.connectionCheckTimeoutSeconds = connectionCheckTimeoutSeconds;
- return this;
- }
-
- public JdbcConnectionOptions build() {
- return new JdbcConnectionOptions(
- url, driverName, connectionCheckTimeoutSeconds, properties);
- }
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/connections/JdbcConnectionProvider.java b/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/connections/JdbcConnectionProvider.java
deleted file mode 100644
index c49cb1fc7..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/connections/JdbcConnectionProvider.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog.connections;
-
-import org.apache.flink.annotation.PublicEvolving;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Properties;
-
-/** JDBC connection provider. */
-@PublicEvolving
-public interface JdbcConnectionProvider extends Serializable, AutoCloseable {
-
- /**
- * Get existing connection.
- *
- * @return existing connection
- */
- @Nullable
- Connection getConnection();
-
- /**
- * Get existing connection properties.
- *
- * @return existing connection properties
- */
- @Nonnull
- default Properties getProperties() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Check whether possible existing connection is valid or not through {@link
- * Connection#isValid(int)}.
- *
- * @return true if existing connection is valid
- * @throws SQLException sql exception throw from {@link Connection#isValid(int)}
- */
- boolean isConnectionValid() throws SQLException;
-
- /**
- * Get existing connection or establish an new one if there is none.
- *
- * @return existing connection or newly established connection
- * @throws SQLException sql exception
- * @throws ClassNotFoundException driver class not found
- */
- Connection getOrEstablishConnection() throws SQLException, ClassNotFoundException;
-
- /** Close possible existing connection. */
- void closeConnection();
-
- /**
- * Close possible existing connection and establish an new one.
- *
- * @return newly established connection
- * @throws SQLException sql exception
- * @throws ClassNotFoundException driver class not found
- */
- Connection reestablishConnection() throws SQLException, ClassNotFoundException;
-
- default void close() throws Exception {
- closeConnection();
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/connections/SimpleJdbcConnectionProvider.java b/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/connections/SimpleJdbcConnectionProvider.java
deleted file mode 100644
index e78c0bfbe..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/main/java/org/apache/streampark/catalog/connections/SimpleJdbcConnectionProvider.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog.connections;
-
-import org.apache.flink.annotation.PublicEvolving;
-import org.apache.flink.util.Preconditions;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nonnull;
-import javax.annotation.concurrent.NotThreadSafe;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.Enumeration;
-import java.util.Properties;
-
-/** Simple JDBC connection provider. */
-@NotThreadSafe
-@PublicEvolving
-public class SimpleJdbcConnectionProvider implements JdbcConnectionProvider, Serializable {
-
- private static final Logger LOG = LoggerFactory.getLogger(SimpleJdbcConnectionProvider.class);
-
- private static final long serialVersionUID = 1L;
-
- private final JdbcConnectionOptions jdbcOptions;
-
- private transient Driver loadedDriver;
- private transient Connection connection;
-
- static {
- // Load DriverManager first to avoid deadlock between DriverManager's
- // static initialization block and specific driver class's static
- // initialization block when two different driver classes are loading
- // concurrently using Class.forName while DriverManager is uninitialized
- // before.
- //
- // This could happen in JDK 8 but not above as driver loading has been
- // moved out of DriverManager's static initialization block since JDK 9.
- DriverManager.getDrivers();
- }
-
- public SimpleJdbcConnectionProvider(JdbcConnectionOptions jdbcOptions) {
- this.jdbcOptions = jdbcOptions;
- }
-
- @Override
- public Connection getConnection() {
- return connection;
- }
-
- @Nonnull
- @Override
- public Properties getProperties() {
- return jdbcOptions.getProperties();
- }
-
- @Override
- public boolean isConnectionValid() throws SQLException {
- return connection != null
- && connection.isValid(jdbcOptions.getConnectionCheckTimeoutSeconds());
- }
-
- private Driver loadDriver(String driverName) throws SQLException, ClassNotFoundException {
- Preconditions.checkNotNull(driverName);
- Enumeration<Driver> drivers = DriverManager.getDrivers();
- while (drivers.hasMoreElements()) {
- Driver driver = drivers.nextElement();
- if (driver.getClass().getName().equals(driverName)) {
- return driver;
- }
- }
- // We could reach here for reasons:
- // * Class loader hell of DriverManager(see JDK-8146872).
- // * driver is not installed as a service provider.
- Class<?> clazz =
- Class.forName(driverName, true, Thread.currentThread().getContextClassLoader());
- try {
- return (Driver) clazz.newInstance();
- } catch (Exception ex) {
- throw new SQLException("Fail to create driver of class " + driverName, ex);
- }
- }
-
- private Driver getLoadedDriver() throws SQLException, ClassNotFoundException {
- if (loadedDriver == null) {
- loadedDriver = loadDriver(jdbcOptions.getDriverName());
- }
- return loadedDriver;
- }
-
- @Override
- public Connection getOrEstablishConnection() throws SQLException, ClassNotFoundException {
- if (isConnectionValid()) {
- return connection;
- }
- if (jdbcOptions.getDriverName() == null) {
- connection = DriverManager.getConnection(jdbcOptions.getDbURL(), getProperties());
- } else {
- Driver driver = getLoadedDriver();
- connection = driver.connect(jdbcOptions.getDbURL(), getProperties());
- if (connection == null) {
- // Throw same exception as DriverManager.getConnection when no driver found to match
- // caller expectation.
- throw new SQLException(
- "No suitable driver found for " + jdbcOptions.getDbURL(), "08001");
- }
- }
- return connection;
- }
-
- @Override
- public void closeConnection() {
- if (connection != null) {
- try {
- connection.close();
- } catch (SQLException e) {
- LOG.warn("JDBC connection close failed.", e);
- } finally {
- connection = null;
- }
- }
- }
-
- @Override
- public Connection reestablishConnection() throws SQLException, ClassNotFoundException {
- closeConnection();
- return getOrEstablishConnection();
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory b/streampark-flink/streampark-flink-catalog-store/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory
deleted file mode 100644
index 9bcdf4448..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-org.apache.streampark.catalog.JdbcCatalogStoreFactory
diff --git a/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/JdbcCatalogStoreFactoryTest.java b/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/JdbcCatalogStoreFactoryTest.java
deleted file mode 100644
index 59842e1b4..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/JdbcCatalogStoreFactoryTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog;
-
-import org.apache.streampark.catalog.mysql.MysqlBaseITCASE;
-
-import org.apache.flink.table.catalog.CatalogStore;
-import org.apache.flink.table.factories.CatalogStoreFactory;
-import org.apache.flink.table.factories.FactoryUtil;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-
-public class JdbcCatalogStoreFactoryTest extends MysqlBaseITCASE {
-
- @org.junit.Test
- public void testCatalogStoreFactoryDiscovery() {
-
- String factoryIdentifier = JdbcCatalogStoreFactoryOptions.IDENTIFIER;
- Map<String, String> options = new HashMap<>();
- options.put("url", MYSQL_CONTAINER.getJdbcUrl());
- options.put("table-name", "t_mysql_catalog");
- options.put("driver", MYSQL_CONTAINER.getDriverClassName());
- options.put("username", MYSQL_CONTAINER.getUsername());
- options.put("password", MYSQL_CONTAINER.getPassword());
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- final FactoryUtil.DefaultCatalogStoreContext discoveryContext =
- new FactoryUtil.DefaultCatalogStoreContext(options, null, classLoader);
- final CatalogStoreFactory factory =
- FactoryUtil.discoverFactory(
- classLoader, CatalogStoreFactory.class, factoryIdentifier);
- factory.open(discoveryContext);
-
- CatalogStore catalogStore = factory.createCatalogStore();
- assertThat(catalogStore instanceof JdbcCatalogStore).isTrue();
-
- factory.close();
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/JdbcCatalogStoreTest.java b/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/JdbcCatalogStoreTest.java
deleted file mode 100644
index 626768863..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/JdbcCatalogStoreTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog;
-
-import org.apache.streampark.catalog.connections.JdbcConnectionOptions;
-import org.apache.streampark.catalog.connections.JdbcConnectionProvider;
-import org.apache.streampark.catalog.connections.SimpleJdbcConnectionProvider;
-import org.apache.streampark.catalog.mysql.MysqlBaseITCASE;
-
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.table.catalog.CatalogDescriptor;
-import org.apache.flink.table.catalog.CatalogStore;
-import org.apache.flink.table.catalog.CommonCatalogOptions;
-import org.apache.flink.table.catalog.GenericInMemoryCatalogFactoryOptions;
-import org.apache.flink.table.catalog.exceptions.CatalogException;
-
-import org.assertj.core.api.ThrowableAssert;
-
-import java.util.Set;
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
-
-public class JdbcCatalogStoreTest extends MysqlBaseITCASE {
-
- private static final String DUMMY = "dummy";
- private static final CatalogDescriptor DUMMY_CATALOG;
-
- static {
- Configuration conf = new Configuration();
- conf.set(CommonCatalogOptions.CATALOG_TYPE, DUMMY);
- conf.set(GenericInMemoryCatalogFactoryOptions.DEFAULT_DATABASE, "dummy_db");
-
- DUMMY_CATALOG = CatalogDescriptor.of(DUMMY, conf);
- }
- @org.junit.Test
- public void testNotOpened() {
- CatalogStore catalogStore = initCatalogStore();
-
- assertCatalogStoreNotOpened(catalogStore::listCatalogs);
- assertCatalogStoreNotOpened(() -> catalogStore.contains(DUMMY));
- assertCatalogStoreNotOpened(() -> catalogStore.getCatalog(DUMMY));
- assertCatalogStoreNotOpened(() -> catalogStore.storeCatalog(DUMMY, DUMMY_CATALOG));
- assertCatalogStoreNotOpened(() -> catalogStore.removeCatalog(DUMMY, true));
- }
-
- @org.junit.Test
- public void testStore() {
- CatalogStore catalogStore = initCatalogStore();
- catalogStore.open();
-
- catalogStore.storeCatalog(DUMMY, DUMMY_CATALOG);
-
- Set<String> storedCatalogs = catalogStore.listCatalogs();
- assertThat(storedCatalogs.size()).isEqualTo(1);
- assertThat(storedCatalogs.contains(DUMMY)).isTrue();
- }
-
- @org.junit.Test
- public void testRemoveExisting() {
- CatalogStore catalogStore = initCatalogStore();
- catalogStore.open();
-
- catalogStore.storeCatalog(DUMMY, DUMMY_CATALOG);
- assertThat(catalogStore.listCatalogs().size()).isEqualTo(1);
-
- catalogStore.removeCatalog(DUMMY, false);
- assertThat(catalogStore.listCatalogs().size()).isEqualTo(0);
- assertThat(catalogStore.contains(DUMMY)).isFalse();
- }
-
- @org.junit.Test
- public void testRemoveNonExisting() {
- CatalogStore catalogStore = initCatalogStore();
- catalogStore.open();
-
- catalogStore.removeCatalog(DUMMY, true);
-
- assertThatThrownBy(() -> catalogStore.removeCatalog(DUMMY, false))
- .isInstanceOf(CatalogException.class)
- .hasMessageContaining(
- "Remove catalog " + DUMMY + " failed!");
- }
-
- @org.junit.Test
- public void testClosed() {
- CatalogStore catalogStore = initCatalogStore();
-
- catalogStore.open();
-
- catalogStore.storeCatalog(DUMMY, DUMMY_CATALOG);
- assertThat(catalogStore.listCatalogs().size()).isEqualTo(1);
-
- catalogStore.close();
-
- assertCatalogStoreNotOpened(catalogStore::listCatalogs);
- assertCatalogStoreNotOpened(() -> catalogStore.contains(DUMMY));
- assertCatalogStoreNotOpened(() -> catalogStore.getCatalog(DUMMY));
- assertCatalogStoreNotOpened(() -> catalogStore.storeCatalog(DUMMY, DUMMY_CATALOG));
- assertCatalogStoreNotOpened(() -> catalogStore.removeCatalog(DUMMY, true));
- }
-
- private void assertCatalogStoreNotOpened(
- ThrowableAssert.ThrowingCallable shouldRaiseThrowable) {
- assertThatThrownBy(shouldRaiseThrowable)
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("CatalogStore is not opened yet.");
- }
-
- private JdbcCatalogStore initCatalogStore() {
- JdbcConnectionOptions jdbcConnectionOptions = new JdbcConnectionOptions.JdbcConnectionOptionsBuilder()
- .withUrl(MYSQL_CONTAINER.getJdbcUrl())
- .withDriverName(MYSQL_CONTAINER.getDriverClassName())
- .withUsername(MYSQL_CONTAINER.getUsername())
- .withPassword(MYSQL_CONTAINER.getPassword())
- .build();
-
- JdbcConnectionProvider jdbcConnectionProvider = new SimpleJdbcConnectionProvider(jdbcConnectionOptions);
- return new JdbcCatalogStore(jdbcConnectionProvider, "t_mysql_catalog");
-
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/mysql/MySqlContainer.java b/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/mysql/MySqlContainer.java
deleted file mode 100644
index 94a5c2f7e..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/mysql/MySqlContainer.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog.mysql;
-
-import org.testcontainers.containers.ContainerLaunchException;
-import org.testcontainers.containers.JdbcDatabaseContainer;
-import org.testcontainers.utility.DockerImageName;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class MySqlContainer extends JdbcDatabaseContainer {
-
- public static final String IMAGE = "mysql";
-
- public static final String MYSQL_VERSION = "8.0";
- public static final Integer MYSQL_PORT = 3306;
-
- private static final String MY_CNF_CONFIG_OVERRIDE_PARAM_NAME = "MY_CNF";
- private static final String SETUP_SQL_PARAM_NAME = "SETUP_SQL";
- private static final String MYSQL_ROOT_USER = "root";
-
- private String databaseName = "test";
- private String username = "test";
- private String password = "test";
-
- public MySqlContainer() {
- this(MYSQL_VERSION);
- }
-
- public MySqlContainer(String version) {
- super(DockerImageName.parse(IMAGE + ":" + version));
- addExposedPort(MYSQL_PORT);
- }
-
- @Override
- protected Set<Integer> getLivenessCheckPorts() {
- return new HashSet<>(getMappedPort(MYSQL_PORT));
- }
-
- @Override
- protected void configure() {
- optionallyMapResourceParameterAsVolume(
- MY_CNF_CONFIG_OVERRIDE_PARAM_NAME, "/etc/mysql/", "mysql-default-conf");
-
- if (parameters.containsKey(SETUP_SQL_PARAM_NAME)) {
- optionallyMapResourceParameterAsVolume(
- SETUP_SQL_PARAM_NAME, "/docker-entrypoint-initdb.d/", "N/A");
- }
-
- addEnv("MYSQL_DATABASE", databaseName);
- addEnv("MYSQL_USER", username);
- if (password != null && !password.isEmpty()) {
- addEnv("MYSQL_PASSWORD", password);
- addEnv("MYSQL_ROOT_PASSWORD", password);
- } else if (MYSQL_ROOT_USER.equalsIgnoreCase(username)) {
- addEnv("MYSQL_ALLOW_EMPTY_PASSWORD", "yes");
- } else {
- throw new ContainerLaunchException(
- "Empty password can be used only with the root user");
- }
- setStartupAttempts(3);
- }
-
- @Override
- public String getDriverClassName() {
- try {
- Class.forName("com.mysql.cj.jdbc.Driver");
- return "com.mysql.cj.jdbc.Driver";
- } catch (ClassNotFoundException e) {
- return "com.mysql.jdbc.Driver";
- }
- }
-
- public String getJdbcUrl(String databaseName) {
- String additionalUrlParams = constructUrlParameters("?", "&");
- return "jdbc:mysql://"
- + getHost()
- + ":"
- + getDatabasePort()
- + "/"
- + databaseName
- + additionalUrlParams;
- }
-
- @Override
- public String getJdbcUrl() {
- return getJdbcUrl(databaseName);
- }
-
- public int getDatabasePort() {
- return getMappedPort(MYSQL_PORT);
- }
-
- @Override
- protected String constructUrlForConnection(String queryString) {
- String url = super.constructUrlForConnection(queryString);
-
- if (!url.contains("useSSL=")) {
- String separator = url.contains("?") ? "&" : "?";
- url = url + separator + "useSSL=false";
- }
-
- if (!url.contains("allowPublicKeyRetrieval=")) {
- url = url + "&allowPublicKeyRetrieval=true";
- }
-
- return url;
- }
-
- @Override
- public String getDatabaseName() {
- return databaseName;
- }
-
- @Override
- public String getUsername() {
- return username;
- }
-
- @Override
- public String getPassword() {
- return password;
- }
-
- @Override
- protected String getTestQueryString() {
- return "SELECT 1";
- }
-
- @SuppressWarnings("unchecked")
- public MySqlContainer withConfigurationOverride(String s) {
- parameters.put(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME, s);
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public MySqlContainer withSetupSQL(String sqlPath) {
- parameters.put(SETUP_SQL_PARAM_NAME, sqlPath);
- return this;
- }
-
- @Override
- public MySqlContainer withDatabaseName(final String databaseName) {
- this.databaseName = databaseName;
- return this;
- }
-
- @Override
- public MySqlContainer withUsername(final String username) {
- this.username = username;
- return this;
- }
-
- @Override
- public MySqlContainer withPassword(final String password) {
- this.password = password;
- return this;
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/mysql/MysqlBaseITCASE.java b/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/mysql/MysqlBaseITCASE.java
deleted file mode 100644
index 799335b96..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/test/java/org/apache/streampark/catalog/mysql/MysqlBaseITCASE.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.streampark.catalog.mysql;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.output.Slf4jLogConsumer;
-import org.testcontainers.lifecycle.Startables;
-
-import java.util.stream.Stream;
-
-public class MysqlBaseITCASE {
-
- private static final Logger LOG = LoggerFactory.getLogger(MysqlBaseITCASE.class);
- protected static final MySqlContainer MYSQL_CONTAINER = createMySqlContainer("docker/server/my.cnf");
-
- @org.junit.BeforeClass
- public static void startContainers() {
- LOG.info("Starting containers...");
- Startables.deepStart(Stream.of(MYSQL_CONTAINER)).join();
- LOG.info("Containers are started.");
- }
-
- @org.junit.AfterClass
- public static void stopContainers() {
- LOG.info("Stopping containers...");
- if (MYSQL_CONTAINER != null) {
- MYSQL_CONTAINER.stop();
- }
- LOG.info("Containers are stopped.");
- }
-
- protected static MySqlContainer createMySqlContainer(String configPath) {
- return (MySqlContainer) new MySqlContainer(MySqlContainer.MYSQL_VERSION)
- .withConfigurationOverride(configPath)
- .withSetupSQL("docker/setup.sql")
- .withDatabaseName("flink-test")
- .withUsername("flinkuser")
- .withPassword("flinkpw")
- .withLogConsumer(new Slf4jLogConsumer(LOG));
- }
-}
diff --git a/streampark-flink/streampark-flink-catalog-store/src/test/resources/docker/server/my.cnf b/streampark-flink/streampark-flink-catalog-store/src/test/resources/docker/server/my.cnf
deleted file mode 100644
index 953ffe8f9..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/test/resources/docker/server/my.cnf
+++ /dev/null
@@ -1,64 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# For advice on how to change settings please see
-# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
-
-[mysqld]
-#
-# Remove leading # and set to the amount of RAM for the most important data
-# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
-# innodb_buffer_pool_size = 128M
-#
-# Remove leading # to turn on a very important data integrity option: logging
-# changes to the binary log between backups.
-# log_bin
-#
-# Remove leading # to set options mainly useful for reporting servers.
-# The server defaults are faster for transactions and fast SELECTs.
-# Adjust sizes as needed, experiment to find the optimal values.
-# join_buffer_size = 128M
-# sort_buffer_size = 2M
-# read_rnd_buffer_size = 2M
-skip-host-cache
-skip-name-resolve
-#datadir=/var/lib/mysql
-#socket=/var/lib/mysql/mysql.sock
-secure-file-priv=/var/lib/mysql
-user=mysql
-
-# Disabling symbolic-links is recommended to prevent assorted security risks
-symbolic-links=0
-
-#log-error=/var/log/mysqld.log
-#pid-file=/var/run/mysqld/mysqld.pid
-
-# ----------------------------------------------
-# Enable the binlog for replication & CDC
-# ----------------------------------------------
-
-# Enable binary replication log and set the prefix, expiration, and log format.
-# The prefix is arbitrary, expiration can be short for integration tests but would
-# be longer on a production system. Row-level info is required for ingest to work.
-# Server ID is required, but this will vary on production systems.
-server-id = 223344
-log_bin = mysql-bin
-binlog_format = row
-# Make binlog_expire_logs_seconds = 1 and max_binlog_size = 4096 to test the exception
-# message when the binlog expires in the server.
-binlog_expire_logs_seconds = 1
-max_binlog_size = 4096
-
-# enable gtid mode
-gtid_mode = on
-enforce_gtid_consistency = on
\ No newline at end of file
diff --git a/streampark-flink/streampark-flink-catalog-store/src/test/resources/docker/setup.sql b/streampark-flink/streampark-flink-catalog-store/src/test/resources/docker/setup.sql
deleted file mode 100644
index 1b22107de..000000000
--- a/streampark-flink/streampark-flink-catalog-store/src/test/resources/docker/setup.sql
+++ /dev/null
@@ -1,41 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one or more
--- contributor license agreements. See the NOTICE file distributed with
--- this work for additional information regarding copyright ownership.
--- The ASF licenses this file to You under the Apache License, Version 2.0
--- (the "License"); you may not use this file except in compliance with
--- the License. You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- In production you would almost certainly limit the replication user must be on the follower (slave) machine,
--- to prevent other clients accessing the log from other machines. For example, 'replicator'@'follower.acme.com'.
--- However, in this database we'll grant 2 users different privileges:
---
--- 1) 'flinkuser' - all privileges required by the snapshot reader AND binlog reader (used for testing)
--- 2) 'mysqluser' - all privileges
---
-GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT, LOCK TABLES ON *.* TO 'flinkuser'@'%';
-CREATE USER 'mysqluser' IDENTIFIED BY 'mysqlpw';
-GRANT ALL PRIVILEGES ON *.* TO 'mysqluser'@'%';
-
--- ----------------------------------------------------------------------------------------------------------------
--- DATABASE: emptydb
--- ----------------------------------------------------------------------------------------------------------------
-CREATE DATABASE emptydb;
-USE flink-test;
-create table t_mysql_catalog (
- `id` bigint NOT NULL AUTO_INCREMENT,
- `catalog_name` varchar(255) NOT NULL,
- `configuration` text,
- `create_time` datetime DEFAULT NULL,
- `update_time` datetime DEFAULT NULL,
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE INDEX `uniq_catalog_name` (`catalog_name`) USING BTREE
-)
-
diff --git a/streampark-flink/streampark-flink-connector-plugin/pom.xml b/streampark-flink/streampark-flink-connector-plugin/pom.xml
deleted file mode 100644
index 6a8a2702d..000000000
--- a/streampark-flink/streampark-flink-connector-plugin/pom.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<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">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.streampark</groupId>
- <artifactId>streampark-flink</artifactId>
- <version>2.2.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>streampark-flink-connector-plugin</artifactId>
- <name>StreamPark : Flink Connector Plugin</name>
- <properties>
- <flink.version>1.18.1</flink.version>
- <paimon.version>0.8.2</paimon.version>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-connector-jdbc</artifactId>
- <version>${flink.connector.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-sql-connector-hive-2.3.9_${scala.binary.version}</artifactId>
- <version>${flink.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.paimon</groupId>
- <artifactId>paimon-flink-1.18</artifactId>
- <version>${paimon.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.streampark</groupId>
- <artifactId>streampark-flink-catalog-store</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>shade</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <createDependencyReducedPom>true</createDependencyReducedPom>
- <dependencyReducedPomLocation>${project.basedir}/target/dependency-reduced-pom.xml</dependencyReducedPomLocation>
- <artifactSet>
- <includes>
- <include>org.apache.streampark:*</include>
- <include>org.apache.flink:*</include>
- <include>org.apache.paimon:*</include>
- </includes>
- </artifactSet>
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"></transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/streampark-flink/streampark-flink-connector-plugin/src/main/java/org/apache/streampark/package-info.java b/streampark-flink/streampark-flink-connector-plugin/src/main/java/org/apache/streampark/package-info.java
deleted file mode 100644
index 96017d83a..000000000
--- a/streampark-flink/streampark-flink-connector-plugin/src/main/java/org/apache/streampark/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides compilers for Java code.
- */
-package org.apache.streampark;
diff --git a/streampark-flink/streampark-flink-connector-plugin/src/test/java/org/apache/streampark/package-info.java b/streampark-flink/streampark-flink-connector-plugin/src/test/java/org/apache/streampark/package-info.java
deleted file mode 100644
index 96017d83a..000000000
--- a/streampark-flink/streampark-flink-connector-plugin/src/test/java/org/apache/streampark/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides compilers for Java code.
- */
-package org.apache.streampark;
diff --git a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/KubernetesRetriever.scala b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/KubernetesRetriever.scala
index 093a11b2e..21b96b41a 100644
--- a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/KubernetesRetriever.scala
+++ b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/KubernetesRetriever.scala
@@ -88,7 +88,7 @@ object KubernetesRetriever extends Logger {
.getClusterClientFactory(flinkConfig)
.createClusterDescriptor(flinkConfig)
.asInstanceOf[KubernetesClusterDescriptor]
- .autoClose(clusterProvider =>
+ .using(clusterProvider =>
Try {
clusterProvider
.retrieve(flinkConfig.getString(KubernetesConfigOptions.CLUSTER_ID))
@@ -113,7 +113,7 @@ object KubernetesRetriever extends Logger {
KubernetesRetriever
.newK8sClient()
- .autoClose(client => {
+ .using(client => {
client
.apps()
.deployments()
diff --git a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/helper/KubernetesDeploymentHelper.scala b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/helper/KubernetesDeploymentHelper.scala
index 2df17d6c0..a0421fc0d 100644
--- a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/helper/KubernetesDeploymentHelper.scala
+++ b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/helper/KubernetesDeploymentHelper.scala
@@ -35,7 +35,7 @@ object KubernetesDeploymentHelper extends Logger {
private[this] def getPods(nameSpace: String, deploymentName: String): List[Pod] = {
KubernetesRetriever
.newK8sClient()
- .autoClose(client => {
+ .using(client => {
Try {
client.pods
.inNamespace(nameSpace)
@@ -72,7 +72,7 @@ object KubernetesDeploymentHelper extends Logger {
private[this] def deleteDeployment(nameSpace: String, deploymentName: String): Unit = {
KubernetesRetriever
.newK8sClient()
- .autoClose(client => {
+ .using(client => {
val map = client.apps.deployments.inNamespace(nameSpace)
map.withLabel("app", deploymentName).delete
map.withName(deploymentName).delete()
@@ -82,7 +82,7 @@ object KubernetesDeploymentHelper extends Logger {
private[this] def deleteConfigMap(nameSpace: String, deploymentName: String): Unit = {
KubernetesRetriever
.newK8sClient()
- .autoClose(client => {
+ .using(client => {
val map = client.configMaps().inNamespace(nameSpace)
map.withLabel("app", deploymentName).delete
map.withName(deploymentName).delete()
@@ -106,7 +106,7 @@ object KubernetesDeploymentHelper extends Logger {
def watchDeploymentLog(nameSpace: String, jobName: String, jobId: String): String = {
KubernetesRetriever
.newK8sClient()
- .autoClose(client => {
+ .using(client => {
val path = KubernetesDeploymentHelper.getJobLog(jobId)
val file = new File(path)
val log = client.apps.deployments
@@ -121,7 +121,7 @@ object KubernetesDeploymentHelper extends Logger {
def watchPodTerminatedLog(nameSpace: String, jobName: String, jobId: String): String = {
KubernetesRetriever
.newK8sClient()
- .autoClose(client =>
+ .using(client =>
Try {
val podName = getPods(nameSpace, jobName).head.getMetadata.getName
val path = KubernetesDeploymentHelper.getJobErrorLog(jobId)
diff --git a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressController.scala b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressController.scala
index 25b11a643..a39880ff4 100644
--- a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressController.scala
+++ b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressController.scala
@@ -17,7 +17,7 @@
package org.apache.streampark.flink.kubernetes.ingress
-import org.apache.streampark.common.util.Implicits.AutoCloseImplicits
+import org.apache.streampark.common.util.Implicits._
import org.apache.streampark.common.util.Logger
import org.apache.flink.client.program.ClusterClient
@@ -27,7 +27,7 @@ object IngressController extends Logger {
private[this] val VERSION_REGEXP = "(\\d+\\.\\d+)".r
- private lazy val clusterVersion = new DefaultKubernetesClient().autoClose(client => {
+ private lazy val clusterVersion = new DefaultKubernetesClient().using(client => {
VERSION_REGEXP.findFirstIn(client.getVersion.getGitVersion).get.toDouble
})
diff --git a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressStrategyV1.scala b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressStrategyV1.scala
index 48f9d647b..d4984949d 100644
--- a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressStrategyV1.scala
+++ b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressStrategyV1.scala
@@ -31,7 +31,7 @@ class IngressStrategyV1 extends IngressStrategy {
nameSpace: String,
clusterId: String,
clusterClient: ClusterClient[_]): String = {
- new DefaultKubernetesClient().autoClose(client =>
+ new DefaultKubernetesClient().using(client =>
Try {
Option(
Try(
@@ -49,8 +49,8 @@ class IngressStrategyV1 extends IngressStrategy {
val newPath = Option(path).filter(_.nonEmpty).map(_.replaceAll("\\/+$", "")).getOrElse("")
s"http://$host$newPath"
}
- .getOrElse(clusterClient.autoClose(_.getWebInterfaceURL))
- case None => clusterClient.autoClose(_.getWebInterfaceURL)
+ .getOrElse(clusterClient.using(_.getWebInterfaceURL))
+ case None => clusterClient.using(_.getWebInterfaceURL)
}
} match {
case Success(value) => value
@@ -75,7 +75,7 @@ class IngressStrategyV1 extends IngressStrategy {
}
override def configureIngress(domainName: String, clusterId: String, nameSpace: String): Unit = {
- new DefaultKubernetesClient().autoClose(client => {
+ new DefaultKubernetesClient().using(client => {
val ownerReference = getOwnerReference(nameSpace, clusterId, client)
val ingressBackendRestServicePort =
touchIngressBackendRestPort(client, clusterId, nameSpace)
diff --git a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressStrategyV1beta1.scala b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressStrategyV1beta1.scala
index f8d33d8a2..28bd54755 100644
--- a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressStrategyV1beta1.scala
+++ b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressStrategyV1beta1.scala
@@ -33,7 +33,7 @@ class IngressStrategyV1beta1 extends IngressStrategy {
nameSpace: String,
clusterId: String,
clusterClient: ClusterClient[_]): String = {
- new DefaultKubernetesClient().autoClose(client => {
+ new DefaultKubernetesClient().using(client => {
Try {
Option(
Try(
@@ -47,8 +47,8 @@ class IngressStrategyV1beta1 extends IngressStrategy {
.map(ingress => ingress.getSpec.getRules.head)
.map(rule => rule.getHost -> rule.getHttp.getPaths.head.getPath)
.map { case (host, path) => s"http://$host$path" }
- .getOrElse(clusterClient.autoClose(_.getWebInterfaceURL))
- case None => clusterClient.autoClose(_.getWebInterfaceURL)
+ .getOrElse(clusterClient.using(_.getWebInterfaceURL))
+ case None => clusterClient.using(_.getWebInterfaceURL)
}
} match {
case Success(value) => value
@@ -70,7 +70,7 @@ class IngressStrategyV1beta1 extends IngressStrategy {
}
override def configureIngress(domainName: String, clusterId: String, nameSpace: String): Unit = {
- new DefaultKubernetesClient().autoClose(client => {
+ new DefaultKubernetesClient().using(client => {
val ownerReference = getOwnerReference(nameSpace, clusterId, client)
val ingress = new IngressBuilder()
.withNewMetadata()
diff --git a/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/pipeline/impl/FlinkYarnApplicationBuildPipeline.scala b/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/pipeline/impl/FlinkYarnApplicationBuildPipeline.scala
index 402ab1e96..3f5fc9f7d 100644
--- a/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/pipeline/impl/FlinkYarnApplicationBuildPipeline.scala
+++ b/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/pipeline/impl/FlinkYarnApplicationBuildPipeline.scala
@@ -93,7 +93,7 @@ class FlinkYarnApplicationBuildPipeline(request: FlinkYarnApplicationBuildReques
val uploadFile =
s"${Workspace.remote.APP_UPLOADS}/${originFile.getName}"
if (fsOperator.exists(uploadFile)) {
- new FileInputStream(originFile).autoClose(inputStream => {
+ new FileInputStream(originFile).using(inputStream => {
if (DigestUtils.md5Hex(inputStream) != fsOperator.fileMd5(uploadFile)) {
fsOperator.upload(originFile.getAbsolutePath, uploadFile)
}
diff --git a/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/pipeline/impl/SparkYarnBuildPipeline.scala b/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/pipeline/impl/SparkYarnBuildPipeline.scala
index 9daeab677..2c92067b6 100644
--- a/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/pipeline/impl/SparkYarnBuildPipeline.scala
+++ b/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/pipeline/impl/SparkYarnBuildPipeline.scala
@@ -96,7 +96,7 @@ class SparkYarnBuildPipeline(request: SparkYarnBuildRequest)
val uploadFile =
s"${Workspace.remote.APP_UPLOADS}/${originFile.getName}"
if (fsOperator.exists(uploadFile)) {
- new FileInputStream(originFile).autoClose(inputStream => {
+ new FileInputStream(originFile).using(inputStream => {
if (DigestUtils.md5Hex(inputStream) != fsOperator.fileMd5(uploadFile)) {
fsOperator.upload(originFile.getAbsolutePath, uploadFile)
}
diff --git a/streampark-flink/streampark-flink-proxy/src/main/scala/org/apache/streampark/flink/proxy/FlinkShimsProxy.scala b/streampark-flink/streampark-flink-proxy/src/main/scala/org/apache/streampark/flink/proxy/FlinkShimsProxy.scala
index bbd96110b..8d6c8cd12 100644
--- a/streampark-flink/streampark-flink-proxy/src/main/scala/org/apache/streampark/flink/proxy/FlinkShimsProxy.scala
+++ b/streampark-flink/streampark-flink-proxy/src/main/scala/org/apache/streampark/flink/proxy/FlinkShimsProxy.scala
@@ -216,12 +216,12 @@ object FlinkShimsProxy extends Logger {
def getObject[T](loader: ClassLoader, obj: Object): T = {
val arrayOutputStream = new ByteArrayOutputStream
new ObjectOutputStream(arrayOutputStream)
- .autoClose(out => {
+ .using(out => {
out.writeObject(obj)
val byteArrayInputStream =
new ByteArrayInputStream(arrayOutputStream.toByteArray)
new ClassLoaderObjectInputStream(loader, byteArrayInputStream)
- .autoClose(_.readObject())
+ .using(_.readObject())
})
.asInstanceOf[T]
}
diff --git a/streampark-flink/streampark-flink-shims/streampark-flink-shims_flink-1.18/pom.xml b/streampark-flink/streampark-flink-shims/streampark-flink-shims_flink-1.18/pom.xml
index 47a845164..1ef0bf33d 100644
--- a/streampark-flink/streampark-flink-shims/streampark-flink-shims_flink-1.18/pom.xml
+++ b/streampark-flink/streampark-flink-shims/streampark-flink-shims_flink-1.18/pom.xml
@@ -115,11 +115,6 @@
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.streampark</groupId>
- <artifactId>streampark-flink-catalog-store</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
<build>
@@ -139,7 +134,6 @@
<artifactSet>
<includes>
<include>org.apache.flink:flink-table-api-scala-bridge_${scala.binary.version}</include>
- <include>org.apache.streampark:streampark-flink-catalog-store</include>
</includes>
</artifactSet>
<filters>
diff --git a/streampark-flink/streampark-flink-shims/streampark-flink-shims_flink-1.19/pom.xml b/streampark-flink/streampark-flink-shims/streampark-flink-shims_flink-1.19/pom.xml
index 9fb04838c..e0cceaf1e 100644
--- a/streampark-flink/streampark-flink-shims/streampark-flink-shims_flink-1.19/pom.xml
+++ b/streampark-flink/streampark-flink-shims/streampark-flink-shims_flink-1.19/pom.xml
@@ -114,12 +114,6 @@
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.streampark</groupId>
- <artifactId>streampark-flink-catalog-store</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
<build>
@@ -139,7 +133,6 @@
<artifactSet>
<includes>
<include>org.apache.flink:flink-table-api-scala-bridge_${scala.binary.version}</include>
- <include>org.apache.streampark:streampark-flink-catalog-store</include>
</includes>
</artifactSet>
<filters>
diff --git a/streampark-spark/streampark-spark-client/streampark-spark-client-api/src/main/scala/org/apache/streampark/spark/client/proxy/SparkShimsProxy.scala b/streampark-spark/streampark-spark-client/streampark-spark-client-api/src/main/scala/org/apache/streampark/spark/client/proxy/SparkShimsProxy.scala
index 86268f8c7..f0a7933f0 100644
--- a/streampark-spark/streampark-spark-client/streampark-spark-client-api/src/main/scala/org/apache/streampark/spark/client/proxy/SparkShimsProxy.scala
+++ b/streampark-spark/streampark-spark-client/streampark-spark-client-api/src/main/scala/org/apache/streampark/spark/client/proxy/SparkShimsProxy.scala
@@ -190,12 +190,12 @@ object SparkShimsProxy extends Logger {
def getObject[T](loader: ClassLoader, obj: Object): T = {
val arrayOutputStream = new ByteArrayOutputStream
new ObjectOutputStream(arrayOutputStream)
- .autoClose(objectOutputStream => {
+ .using(objectOutputStream => {
objectOutputStream.writeObject(obj)
val byteArrayInputStream =
new ByteArrayInputStream(arrayOutputStream.toByteArray)
new ClassLoaderObjectInputStream(loader, byteArrayInputStream)
- .autoClose(_.readObject())
+ .using(_.readObject())
})
.asInstanceOf[T]
}