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/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new b212dd98f [Improve] modification of flink home is not allowed when it
is still in use (#2615)
b212dd98f is described below
commit b212dd98f88434a910424abb1925d5e3ceea4521
Author: zhoulii <[email protected]>
AuthorDate: Sun Apr 16 21:43:39 2023 +0800
[Improve] modification of flink home is not allowed when it is still in use
(#2615)
Co-authored-by: zhoulii <[email protected]>
Co-authored-by: benjobs <[email protected]>
---
.../core/controller/FlinkEnvController.java | 6 ++++
.../console/core/service/FlinkEnvService.java | 7 ++++
.../core/service/impl/FlinkEnvServiceImpl.java | 40 ++++++++++++----------
.../src/api/flink/setting/flinkEnv.ts | 14 ++++++++
.../src/views/setting/FlinkHome/index.vue | 20 ++++++-----
5 files changed, 61 insertions(+), 26 deletions(-)
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkEnvController.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkEnvController.java
index 1eab993cc..b5a1e8fd2 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkEnvController.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/FlinkEnvController.java
@@ -100,6 +100,12 @@ public class FlinkEnvController {
return RestResponse.success();
}
+ @PostMapping("checkForUpdateOrDelete")
+ public RestResponse checkForUpdateOrDelete(FlinkEnv version) {
+ flinkEnvService.checkForUpdateOrDelete(version.getId());
+ return RestResponse.success(true);
+ }
+
@Operation(summary = "Update flink environment as default")
@PostMapping("default")
public RestResponse setDefault(Long id) {
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/FlinkEnvService.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/FlinkEnvService.java
index fcf806765..1c480c0b9 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/FlinkEnvService.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/FlinkEnvService.java
@@ -91,4 +91,11 @@ public interface FlinkEnvService extends IService<FlinkEnv> {
* @param id
*/
void syncConf(Long id) throws IOException;
+
+ /**
+ * check for update or delete operation
+ *
+ * @param id
+ */
+ FlinkEnv checkForUpdateOrDelete(Long id);
}
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkEnvServiceImpl.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkEnvServiceImpl.java
index 20a9ef295..6e8402939 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkEnvServiceImpl.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkEnvServiceImpl.java
@@ -90,20 +90,7 @@ public class FlinkEnvServiceImpl extends
ServiceImpl<FlinkEnvMapper, FlinkEnv>
@Override
public void delete(Long id) {
- FlinkEnv flinkEnv = getById(id);
-
- // 1.check exists
- ApiAlertException.throwIfNull(flinkEnv, "The flink home does not exist,
please check.");
-
- // 2.check if it is being used by any flink cluster
- ApiAlertException.throwIfFalse(
- !flinkClusterService.existsByFlinkEnvId(id),
- "The flink home is still in use by some flink cluster, please check.");
-
- // 3.check if it is being used by any application
- ApiAlertException.throwIfFalse(
- !applicationService.existsJobByFlinkEnvId(id),
- "The flink home is still in use by some application, please check.");
+ FlinkEnv flinkEnv = checkForUpdateOrDelete(id);
Long count = this.baseMapper.selectCount(null);
ApiAlertException.throwIfFalse(
@@ -115,10 +102,8 @@ public class FlinkEnvServiceImpl extends
ServiceImpl<FlinkEnvMapper, FlinkEnv>
@Override
public void update(FlinkEnv version) throws IOException {
- FlinkEnv flinkEnv = super.getById(version.getId());
- ApiAlertException.throwIfNull(
- flinkEnv,
- "Flink home message lost, update flink env failed, please check
database status!");
+ FlinkEnv flinkEnv = checkForUpdateOrDelete(version.getId());
+
flinkEnv.setDescription(version.getDescription());
flinkEnv.setFlinkName(version.getFlinkName());
if (!version.getFlinkHome().equals(flinkEnv.getFlinkHome())) {
@@ -160,4 +145,23 @@ public class FlinkEnvServiceImpl extends
ServiceImpl<FlinkEnvMapper, FlinkEnv>
flinkEnv.doSetFlinkConf();
updateById(flinkEnv);
}
+
+ public FlinkEnv checkForUpdateOrDelete(Long id) {
+ FlinkEnv flinkEnv = getById(id);
+
+ // 1.check exists
+ ApiAlertException.throwIfNull(flinkEnv, "The flink home does not exist,
please check.");
+
+ // 2.check if it is being used by any flink cluster
+ ApiAlertException.throwIfFalse(
+ !flinkClusterService.existsByFlinkEnvId(id),
+ "The flink home is still in use by some flink cluster, please check.");
+
+ // 3.check if it is being used by any application
+ ApiAlertException.throwIfFalse(
+ !applicationService.existsJobByFlinkEnvId(id),
+ "The flink home is still in use by some application, please check.");
+
+ return flinkEnv;
+ }
}
diff --git
a/streampark-console/streampark-console-webapp/src/api/flink/setting/flinkEnv.ts
b/streampark-console/streampark-console-webapp/src/api/flink/setting/flinkEnv.ts
index 0c37068f1..7d051317c 100644
---
a/streampark-console/streampark-console-webapp/src/api/flink/setting/flinkEnv.ts
+++
b/streampark-console/streampark-console-webapp/src/api/flink/setting/flinkEnv.ts
@@ -28,6 +28,7 @@ enum FLINK_API {
SYNC = '/flink/env/sync',
UPDATE = '/flink/env/update',
DEFAULT = '/flink/env/default',
+ CHECK_FOR_UPDATE_OR_DELETE = '/flink/env/checkForUpdateOrDelete',
}
/**
* flink environment data
@@ -86,6 +87,19 @@ export function fetchCheckEnv(data: {
}): Promise<AxiosResponse<Result<boolean>>> {
return defHttp.post({ url: FLINK_API.CHECK, data }, {
isReturnNativeResponse: true });
}
+
+/**
+ * check for update or delete operation
+ * @param {String} id
+ * @returns {Promise<Boolean>}
+ */
+export function fetchCheckForUpdateOrDelete(id: string):
Promise<AxiosResponse<Result<boolean>>> {
+ return defHttp.post({
+ url: FLINK_API.CHECK_FOR_UPDATE_OR_DELETE,
+ data: { id },
+ }, { isReturnNativeResponse: true });
+}
+
/**
* Create flink
* @param {FlinkCreate} data
diff --git
a/streampark-console/streampark-console-webapp/src/views/setting/FlinkHome/index.vue
b/streampark-console/streampark-console-webapp/src/views/setting/FlinkHome/index.vue
index 7575d9624..7cbf02a94 100644
---
a/streampark-console/streampark-console-webapp/src/views/setting/FlinkHome/index.vue
+++
b/streampark-console/streampark-console-webapp/src/views/setting/FlinkHome/index.vue
@@ -42,6 +42,7 @@
} from '@ant-design/icons-vue';
import { FlinkEnvModal, FlinkEnvDrawer } from './components';
import {
+ fetchCheckForUpdateOrDelete,
fetchDefaultSet,
fetchFlinkEnv,
fetchFlinkEnvRemove,
@@ -63,14 +64,17 @@
const [registerModal, { openModal: openFlinkModal }] = useModal();
const [registerFlinkDraw, { openDrawer: openEnvDrawer }] = useDrawer();
/* Edit button */
- function handleEditFlink(item: FlinkEnv) {
- versionId.value = item.id;
- openFlinkModal(true, {
- versionId: item.id,
- flinkName: item.flinkName,
- flinkHome: item.flinkHome,
- description: item.description || null,
- });
+ async function handleEditFlink(item: FlinkEnv) {
+ const resp = await fetchCheckForUpdateOrDelete(item.id);
+ if (resp.data.code == 200) {
+ versionId.value = item.id;
+ openFlinkModal(true, {
+ versionId: item.id,
+ flinkName: item.flinkName,
+ flinkHome: item.flinkHome,
+ description: item.description || null,
+ });
+ }
}
/* View configuration */