Skip to content

Commit

Permalink
feat: add spark home (#3977)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangsizhu0504 authored Aug 21, 2024
1 parent 1557113 commit a0453e6
Show file tree
Hide file tree
Showing 9 changed files with 608 additions and 0 deletions.
87 changes: 87 additions & 0 deletions streampark-console/streampark-console-webapp/src/api/spark/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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.
*/

import type { SparkCreate, SparkEnv } from './home.type';
import { defHttp } from '/@/utils/http/axios';

enum FLINK_API {
LIST = '/spark/env/list',
CHECK = '/spark/env/check',
CREATE = '/spark/env/create',
UPDATE = '/spark/env/update',
DELETE = '/spark/env/delete',
DEFAULT = '/spark/env/default',
}
/**
* spark environment data
* @returns Promise<SparkEnv[]>
*/
export function fetchSparkEnvList() {
return defHttp.post<SparkEnv[]>({
url: FLINK_API.LIST,
});
}

/**
* Set the default
* @param {String} id
*/
export function fetchSetDefault(id: string) {
return defHttp.post({
url: FLINK_API.DEFAULT,
data: { id },
});
}

/**
* delete flink env
* @param {String} id
*/
export function fetchSparkEnvRemove(id: string) {
return defHttp.post({
url: FLINK_API.DELETE,
data: { id },
});
}

/**
* Check if the environment exists
* @param {Recordable} data
*/
export function fetchSparkEnvCheck(data: {
id: string | null;
sparkName: string;
sparkHome: string;
}) {
return defHttp.post({ url: FLINK_API.CHECK, data });
}

/**
* Create spark
*
*/
export function fetchSparkEnvCreate(data: SparkCreate) {
return defHttp.post({ url: FLINK_API.CREATE, data }, { isTransformResponse: false });
}

/**
* update spark
* @param data
*/
export function fetchSparkEnvUpdate(data: SparkCreate) {
return defHttp.post({ url: FLINK_API.UPDATE, data }, { isTransformResponse: false });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.
*/
// flink home data
export interface SparkEnv {
id: string;
sparkName: string;
sparkHome: string;
sparkConf: string;
description: string;
scalaVersion: string;
version: string;
isDefault: boolean;
createTime: string;
streamParkScalaVersion: string;
versionOfMiddle?: any;
}

export interface SparkCreate {
id?: string | null;
flinkName: string;
flinkHome: string;
description: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum SparkEnvCheckEnum {
INVALID_PATH = -1,
OK = 0,
NAME_REPEATED = 1,
SPARK_DIST_NOT_FOUND = 2,
SPARK_DIST_REPEATED = 3,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.
*/
export default {
title: 'Spark Home',
tips: {
remove: 'The current spark home has been successfully deleted.',
setDefault: 'Successfully set the default spark home.',
sparkName: 'Spark alias, for example: Spark-1.12',
sparkHome:
'The absolute path of the server where Spark is located, for example: /usr/local/spark',
sparkNameIsRequired: 'Spark name is required',
sparkHomeIsRequired: 'Spark Home is required',
sparkNameIsRepeated: 'Spark name already exists',
sparkHomePathIsInvalid: 'Spark Home path is invalid',
sparkDistNotFound: 'spark-dist jar file not found in spark/lib path',
sparkDistIsRepeated:
'Multiple spark-dist jar files exist in spark/lib path, there must be only one!',
createSparkHomeSuccessful: 'Creation successful!',
updateSparkHomeSuccessful: 'Update successful!',
},
form: {
sparkName: 'Spark Name',
sparkHome: 'Installation Path',
description: 'Description',
},
placeholder: {
sparkName: 'Please enter Spark alias',
sparkHome: 'Please enter Spark installation path',
description: 'Spark description',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.
*/
export default {
title: 'Spark Home',
tips: {
remove: '当前的 spark home 已被成功删除。',
setDefault: '成功设置默认spark home',
sparkName: 'Spark别名,举例: Spark-1.12',
sparkHome: 'Spark所在服务器的绝对路径,举例: /usr/local/spark',
sparkNameIsRequired: 'Spark名称必填',
sparkHomeIsRequired: 'Spark Home 不能为空',
sparkNameIsRepeated: 'Spark名称已存在',
sparkHomePathIsInvalid: 'Spark Home路径无效',
sparkDistNotFound: 'spark/lib 路径下未找到 spark-dist jar文件',
sparkDistIsRepeated: 'spark/lib 路径下存在多个spark-dist jar文件, 必须只能有一个!',
createSparkHomeSuccessful: '创建成功!',
updateSparkHomeSuccessful: '更新成功!',
},
form: {
sparkName: 'Spark 名称',
sparkHome: '安装路径',
description: '描述',
},
placeholder: {
sparkName: '请输入Spark别名',
sparkHome: '请输入Spark安装路径',
description: 'Spark描述',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--
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>
Loading

0 comments on commit a0453e6

Please sign in to comment.