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 b84a7f607 [Improve] spark env improvement (#3985)
b84a7f607 is described below
commit b84a7f607777a688a9efcf716382885b945e42bf
Author: benjobs <[email protected]>
AuthorDate: Thu Aug 22 14:15:13 2024 +0800
[Improve] spark env improvement (#3985)
---
.../streampark/console/core/entity/SparkEnv.java | 20 +++++++++--------
.../src/main/resources/db/data-h2.sql | 4 ++--
.../src/main/resources/db/schema-h2.sql | 2 +-
.../src/views/spark/app.vue | 26 ----------------------
.../views/spark/{ => home}/components/Modal.vue | 14 ++++++------
.../src/views/spark/{ => home}/components/index.ts | 0
.../src/views/spark/{home.vue => home/index.vue} | 0
7 files changed, 21 insertions(+), 45 deletions(-)
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkEnv.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkEnv.java
index cf5d85cbe..83a28234c 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkEnv.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkEnv.java
@@ -35,6 +35,7 @@ import java.io.File;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.Date;
+import java.util.HashMap;
import java.util.Map;
@Data
@@ -74,8 +75,10 @@ public class SparkEnv implements Serializable {
public void doSetSparkConf() throws ApiDetailException {
try {
File yaml = new
File(this.sparkHome.concat("/conf/spark-defaults.conf"));
- String sparkConf = FileUtils.readFileToString(yaml,
StandardCharsets.UTF_8);
- this.sparkConf = DeflaterUtils.zipString(sparkConf);
+ if (yaml.exists()) {
+ String sparkConf = FileUtils.readFileToString(yaml,
StandardCharsets.UTF_8);
+ this.sparkConf = DeflaterUtils.zipString(sparkConf);
+ }
} catch (Exception e) {
throw new ApiDetailException(e);
}
@@ -84,15 +87,12 @@ public class SparkEnv implements Serializable {
public void doSetVersion() {
this.setVersion(this.getSparkVersion().version());
this.setScalaVersion(this.getSparkVersion().scalaVersion());
- if
(!streamParkScalaVersion.startsWith(this.getSparkVersion().scalaVersion())) {
- throw new UnsupportedOperationException(
- String.format(
- "The current Scala version of StreamPark is %s, but the
scala version of Spark to be added is %s, which does not match, Please check",
- streamParkScalaVersion,
this.getSparkVersion().scalaVersion()));
- }
}
public Map<String, String> convertSparkYamlAsMap() {
+ if (sparkConf == null) {
+ return new HashMap<>();
+ }
String sparkYamlString = DeflaterUtils.unzipString(sparkConf);
return PropertiesUtils.loadFlinkConfYaml(sparkYamlString);
}
@@ -106,7 +106,9 @@ public class SparkEnv implements Serializable {
}
public void unzipSparkConf() {
- this.sparkConf = DeflaterUtils.unzipString(this.sparkConf);
+ if (sparkConf != null) {
+ this.sparkConf = DeflaterUtils.unzipString(this.sparkConf);
+ }
}
public String getLargeVersion() {
diff --git
a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
index 78f7538c9..446daec1c 100644
---
a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
+++
b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
@@ -80,8 +80,8 @@ insert into `t_menu` values (110118, 110100, 'app sql
delete', null, null, 'sql:
insert into `t_menu` values (110301, 110300, 'cluster add',
'/flink/add_cluster', 'flink/cluster/Add', 'cluster:create', '', '0', 0, null,
now(), now());
insert into `t_menu` values (110302, 110300, 'cluster edit',
'/flink/edit_cluster', 'flink/cluster/Edit', 'cluster:update', '', '0', 0,
null, now(), now());
-insert into `t_menu` values (120100, 120000, 'spark.application',
'/spark/app', 'spark/app/View', null, null, '0', 1, 2, now(), now());
-insert into `t_menu` values (120200, 120000, 'spark.sparkHome', '/spark/home',
'spark/home/View', null, null, '0', 1, 3, now(), now());
+insert into `t_menu` values (120100, 120000, 'spark.application',
'/spark/app', 'spark/app/index', null, null, '0', 1, 2, now(), now());
+insert into `t_menu` values (120200, 120000, 'spark.sparkHome', '/spark/home',
'spark/home/index', null, null, '0', 1, 3, now(), now());
insert into `t_menu` values (130100, 130000, 'resource.project',
'/resource/project', 'resource/project/View', null, 'github', '0', 1, 2, now(),
now());
insert into `t_menu` values (130200, 130000, 'resource.variable',
'/resource/variable', 'resource/variable/View', null, null, '0', 1, 3, now(),
now());
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 349a5e116..f9b7a45b8 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
@@ -515,7 +515,7 @@ create table if not exists `t_spark_env` (
`spark_home` varchar(255) not null comment 'spark home path',
`version` varchar(64) not null comment 'spark version',
`scala_version` varchar(64) not null comment 'scala version of spark',
- `spark_conf` text not null comment 'spark-conf',
+ `spark_conf` text default null comment 'spark-conf',
`is_default` tinyint not null default 0 comment 'whether default version or
not',
`description` varchar(255) default null comment 'description',
`create_time` datetime not null default current_timestamp comment 'create
time',
diff --git
a/streampark-console/streampark-console-webapp/src/views/spark/app.vue
b/streampark-console/streampark-console-webapp/src/views/spark/app.vue
deleted file mode 100644
index 67aa94dd8..000000000
--- a/streampark-console/streampark-console-webapp/src/views/spark/app.vue
+++ /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
-
- https://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.
--->
-<script lang="ts" setup>
- defineOptions({
- name: 'SparkApplication',
- });
-</script>
-<template>
- <PageWrapper contentFullHeight>
- <div>Coming soon</div>
- </PageWrapper>
-</template>
diff --git
a/streampark-console/streampark-console-webapp/src/views/spark/components/Modal.vue
b/streampark-console/streampark-console-webapp/src/views/spark/home/components/Modal.vue
similarity index 94%
rename from
streampark-console/streampark-console-webapp/src/views/spark/components/Modal.vue
rename to
streampark-console/streampark-console-webapp/src/views/spark/home/components/Modal.vue
index 4e0aa1d2c..cb628357b 100644
---
a/streampark-console/streampark-console-webapp/src/views/spark/components/Modal.vue
+++
b/streampark-console/streampark-console-webapp/src/views/spark/home/components/Modal.vue
@@ -26,7 +26,7 @@
import { fetchSparkEnvCreate } from '/@/api/spark/home';
defineOptions({
- name: 'FlinkModal',
+ name: 'SparkModal',
});
const emit = defineEmits(['reload', 'register']);
const versionId = ref<string | null>(null);
@@ -74,10 +74,10 @@
],
});
const [registerModalInner, { changeOkLoading, closeModal }] =
useModalInner(async (data) => {
- resetFields();
+ await resetFields();
if (data) {
versionId.value = data.versionId;
- setFieldsValue(data);
+ await setFieldsValue(data);
}
});
@@ -94,12 +94,12 @@
changeOkLoading(false);
}
// Detection environment
- const { data: resp } = await fetchSparkEnvCheck({
+ const resp = await fetchSparkEnvCheck({
id: versionId.value,
sparkName: formValue.sparkName,
sparkHome: formValue.sparkHome,
});
- const checkResp = parseInt(resp.data);
+ const checkResp = parseInt(resp);
if (checkResp !== SparkEnvCheckEnum.OK) {
switch (checkResp) {
case SparkEnvCheckEnum.INVALID_PATH:
@@ -127,7 +127,7 @@
const res = await fetchSparkEnvCreate(formValue);
if (res.data) {
success = true;
- message =
formValue.flinkName.concat(t('spark.home.tips.createSparkHomeSuccessful'));
+ message =
formValue.sparkName.concat(t('spark.home.tips.createSparkHomeSuccessful'));
} else {
message = res.message;
}
@@ -138,7 +138,7 @@
...formValue,
});
if (res.data) {
- message =
formValue.flinkName.concat(t('spark.home.tips.updateSparkHomeSuccessful'));
+ message =
formValue.sparkName.concat(t('spark.home.tips.updateSparkHomeSuccessful'));
success = true;
} else {
message = res.message;
diff --git
a/streampark-console/streampark-console-webapp/src/views/spark/components/index.ts
b/streampark-console/streampark-console-webapp/src/views/spark/home/components/index.ts
similarity index 100%
rename from
streampark-console/streampark-console-webapp/src/views/spark/components/index.ts
rename to
streampark-console/streampark-console-webapp/src/views/spark/home/components/index.ts
diff --git
a/streampark-console/streampark-console-webapp/src/views/spark/home.vue
b/streampark-console/streampark-console-webapp/src/views/spark/home/index.vue
similarity index 100%
rename from
streampark-console/streampark-console-webapp/src/views/spark/home.vue
rename to
streampark-console/streampark-console-webapp/src/views/spark/home/index.vue