From 52cb7b5167fabb8272fa24a01f2cfa6091c43102 Mon Sep 17 00:00:00 2001 From: benjobs Date: Sun, 16 Jun 2024 22:08:54 +0800 Subject: [PATCH] [Improve] sync some minor improvements from dev-2.1.5 --- .../controller/ApplicationController.java | 6 +-- .../application/ApplicationActionService.java | 2 +- .../impl/ApplicationActionServiceImpl.java | 14 ++--- .../src/api/flink/app.ts | 8 +-- .../Form/src/components/FormItem.vue | 8 +-- .../Modal/src/components/ModalWrapper.vue | 4 +- .../src/hooks/setting/useMenuSetting.ts | 10 ++-- .../src/locales/lang/en/flink/app.ts | 2 +- .../src/locales/lang/zh-CN/flink/app.ts | 2 +- .../src/utils/props.ts | 51 ++++++++++--------- .../src/views/base/error-log/data.tsx | 12 ++--- .../src/views/flink/app/EditStreamPark.vue | 2 +- .../AppView/StartApplicationModal.vue | 4 +- .../src/views/flink/app/hooks/useApp.tsx | 16 +++--- .../flink/app/hooks/useAppTableAction.ts | 6 +-- .../flink/app/hooks/useCreateAndEditSchema.ts | 3 +- .../views/flink/app/hooks/useFlinkRender.tsx | 7 ++- .../src/views/system/token/token.data.ts | 1 - 18 files changed, 82 insertions(+), 76 deletions(-) diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java index 9665404dba..dbe3ebf979 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java @@ -259,10 +259,10 @@ public RestResponse cancel(@Parameter(hidden = true) Application app) throws Exc /** force stop(stop normal start or in progress) */ @PermissionScope(app = "#app.id") - @PostMapping("forcedStop") + @PostMapping("abort") @RequiresPermissions("app:cancel") - public RestResponse forcedStop(Application app) { - applicationActionService.forcedStop(app.getId()); + public RestResponse abort(Application app) { + applicationActionService.abort(app.getId()); return RestResponse.success(); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/ApplicationActionService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/ApplicationActionService.java index 2ab14f91e5..535d546301 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/ApplicationActionService.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/ApplicationActionService.java @@ -66,5 +66,5 @@ public interface ApplicationActionService extends IService { * * @param id the application's id which need to be stopped */ - void forcedStop(Long id); + void abort(Long id); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationActionServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationActionServiceImpl.java index 3fddda4c94..7334f7cf7d 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationActionServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationActionServiceImpl.java @@ -206,7 +206,7 @@ public void restart(Application appParam) throws Exception { } @Override - public void forcedStop(Long id) { + public void abort(Long id) { CompletableFuture startFuture = startFutureMap.remove(id); CompletableFuture cancelFuture = cancelFutureMap.remove(id); Application application = this.baseMapper.selectApp(id); @@ -225,7 +225,7 @@ public void forcedStop(Long id) { cancelFuture.cancel(true); } if (startFuture == null && cancelFuture == null) { - this.doStopped(id); + this.doAbort(id); } } @@ -308,7 +308,7 @@ public void cancel(Application appParam) throws Exception { cancelFutureMap.put(application.getId(), cancelFuture); - cancelFuture.whenComplete( + cancelFuture.whenCompleteAsync( (cancelResponse, throwable) -> { cancelFutureMap.remove(application.getId()); @@ -319,7 +319,7 @@ public void cancel(Application appParam) throws Exception { applicationLogService.save(applicationLog); if (throwable instanceof CancellationException) { - doStopped(application.getId()); + doAbort(application.getId()); } else { log.error("stop flink job failed.", throwable); application.setOptionState(OptionStateEnum.NONE.getValue()); @@ -465,7 +465,7 @@ public void start(Application appParam, boolean auto) throws Exception { startFutureMap.put(application.getId(), future); - future.whenComplete( + future.whenCompleteAsync( (response, throwable) -> { // 1) remove Future startFutureMap.remove(application.getId()); @@ -567,7 +567,7 @@ private void processForException( applicationLog.setSuccess(false); applicationLogService.save(applicationLog); if (throwable instanceof CancellationException) { - doStopped(application.getId()); + doAbort(application.getId()); } else { Application app = getById(appParam.getId()); app.setState(FlinkAppStateEnum.FAILED.getValue()); @@ -782,7 +782,7 @@ private Map getProperties(Application application) { return properties; } - private void doStopped(Long id) { + private void doAbort(Long id) { Application application = getById(id); application.setOptionState(OptionStateEnum.NONE.getValue()); application.setState(FlinkAppStateEnum.CANCELED.getValue()); diff --git a/streampark-console/streampark-console-webapp/src/api/flink/app.ts b/streampark-console/streampark-console-webapp/src/api/flink/app.ts index f32dbda465..3842a437aa 100644 --- a/streampark-console/streampark-console-webapp/src/api/flink/app.ts +++ b/streampark-console/streampark-console-webapp/src/api/flink/app.ts @@ -36,7 +36,7 @@ enum APP_API { NAME = '/flink/app/name', CHECK_NAME = '/flink/app/checkName', CANCEL = '/flink/app/cancel', - FORCED_STOP = '/flink/app/forcedStop', + ABORT = '/flink/app/abort', DELETE = '/flink/app/delete', DELETE_BAK = '/flink/app/deletebak', CREATE = '/flink/app/create', @@ -167,12 +167,12 @@ export function fetchDeleteOperationLog(id: string) { } /** - * forced stop + * abort job * @returns * @param data */ -export function fetchForcedStop(data: { id: string }): Promise { - return defHttp.post({ url: APP_API.FORCED_STOP, data }); +export function fetchAbort(data: { id: string }): Promise { + return defHttp.post({ url: APP_API.ABORT, data }); } export function fetchStart(data): Promise> { diff --git a/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue b/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue index 9bbb5023fa..137ae94d6c 100644 --- a/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue +++ b/streampark-console/streampark-console-webapp/src/components/Form/src/components/FormItem.vue @@ -333,8 +333,8 @@ return slot ? getSlot(slots, slot, unref(getValues)) : render - ? render(unref(getValues)) - : renderComponent(); + ? render(unref(getValues)) + : renderComponent(); }; const showSuffix = !!suffix; @@ -382,8 +382,8 @@ return colSlot ? getSlot(slots, colSlot, values) : renderColContent - ? renderColContent(values) - : renderItem(); + ? renderColContent(values) + : renderItem(); }; return ( diff --git a/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue b/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue index 52c8b5eb8b..1b1b9a6137 100644 --- a/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue +++ b/streampark-console/streampark-console-webapp/src/components/Modal/src/components/ModalWrapper.vue @@ -153,8 +153,8 @@ realHeightRef.value = props.height ? props.height : realHeight > maxHeight - ? maxHeight - : realHeight; + ? maxHeight + : realHeight; } emit('height-change', unref(realHeightRef)); } catch (error) { diff --git a/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts b/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts index f501c6e80d..3566bfd27c 100644 --- a/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts +++ b/streampark-console/streampark-console-webapp/src/hooks/setting/useMenuSetting.ts @@ -105,8 +105,8 @@ export function useMenuSetting() { return siderHidden ? 0 : collapsedShowTitle - ? SIDE_BAR_SHOW_TIT_MINI_WIDTH - : SIDE_BAR_MINI_WIDTH; + ? SIDE_BAR_SHOW_TIT_MINI_WIDTH + : SIDE_BAR_MINI_WIDTH; }); const getCalcContentWidth = computed(() => { @@ -114,9 +114,9 @@ export function useMenuSetting() { unref(getIsTopMenu) || !unref(getShowMenu) || (unref(getSplit) && unref(getMenuHidden)) ? 0 : unref(getIsMixSidebar) - ? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH) + - (unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0) - : unref(getRealWidth); + ? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH) + + (unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0) + : unref(getRealWidth); return `calc(100% - ${unref(width)}px)`; }); diff --git a/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/app.ts b/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/app.ts index d13a4989f7..ff29d99808 100644 --- a/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/app.ts +++ b/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/app.ts @@ -214,7 +214,7 @@ export default { savepoint: 'Trigger Savepoint', detail: 'View Detail', startLog: 'See Flink Start log', - force: 'Forced Stop Job', + abort: 'Abort Job', copy: 'Copy Job', remapping: 'Remapping Job', deleteTip: 'Are you sure delete this job ?', diff --git a/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/app.ts b/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/app.ts index 01660a4dcb..2aee8d0cb0 100644 --- a/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/app.ts +++ b/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/app.ts @@ -202,7 +202,7 @@ export default { savepoint: '触发 Savepoint', detail: '作业详情', startLog: '查看 Flink 启动日志', - force: '强制停止作业', + abort: '终止作业', copy: '复制作业', remapping: '重新映射作业', deleteTip: '你确定要删除这个作业?', diff --git a/streampark-console/streampark-console-webapp/src/utils/props.ts b/streampark-console/streampark-console-webapp/src/utils/props.ts index 150dd01f4d..368f490f21 100644 --- a/streampark-console/streampark-console-webapp/src/utils/props.ts +++ b/streampark-console/streampark-console-webapp/src/utils/props.ts @@ -15,8 +15,9 @@ type ResolveProp = ExtractPropTypes<{ key: { type: T; required: true }; }>['key']; type ResolvePropType = ResolveProp extends { type: infer V } ? V : ResolveProp; -type ResolvePropTypeWithReadonly = - Readonly extends Readonly> ? ResolvePropType : ResolvePropType; +type ResolvePropTypeWithReadonly = Readonly extends Readonly> + ? ResolvePropType + : ResolvePropType; type IfUnknown = [unknown] extends [T] ? V : T; @@ -27,8 +28,8 @@ export type BuildPropOption, R, V, C> = { default?: R extends true ? never : D extends Record | Array - ? () => D - : (() => D) | D; + ? () => D + : (() => D) | D; validator?: ((val: any) => val is C) | ((val: any) => boolean); }; @@ -36,8 +37,8 @@ type _BuildPropType = | (T extends PropWrapper ? T[typeof wrapperKey] : [V] extends [never] - ? ResolvePropTypeWithReadonly - : never) + ? ResolvePropTypeWithReadonly + : never) | V | C; export type BuildPropType = _BuildPropType< @@ -52,8 +53,8 @@ type _BuildPropDefault = [T] extends [ ] ? D : D extends () => T - ? ReturnType - : D; + ? ReturnType + : D; export type BuildPropDefault = R extends true ? { readonly default?: undefined } @@ -145,12 +146,12 @@ export const buildProps = < [K in keyof O]: O[K] extends BuildPropReturn ? O[K] : [O[K]] extends NativePropType - ? O[K] - : O[K] extends BuildPropOption - ? D extends BuildPropType - ? BuildPropOption - : never - : never; + ? O[K] + : O[K] extends BuildPropOption + ? D extends BuildPropType + ? BuildPropOption + : never + : never; }, >( props: O, @@ -161,17 +162,17 @@ export const buildProps = < [K in keyof O]: O[K] extends { [propKey]: boolean } ? O[K] : [O[K]] extends NativePropType - ? O[K] - : O[K] extends BuildPropOption< - infer T, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - infer _D, - infer R, - infer V, - infer C - > - ? BuildPropReturn - : never; + ? O[K] + : O[K] extends BuildPropOption< + infer T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + infer _D, + infer R, + infer V, + infer C + > + ? BuildPropReturn + : never; }; export const definePropType = (val: any) => ({ [wrapperKey]: val }) as PropWrapper; diff --git a/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx b/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx index 73120a425e..3ffc2f4537 100644 --- a/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx +++ b/streampark-console/streampark-console-webapp/src/views/base/error-log/data.tsx @@ -16,12 +16,12 @@ export function getColumns(): BasicColumn[] { text === ErrorTypeEnum.VUE ? 'green' : text === ErrorTypeEnum.RESOURCE - ? 'cyan' - : text === ErrorTypeEnum.PROMISE - ? 'blue' - : ErrorTypeEnum.AJAX - ? 'red' - : 'purple'; + ? 'cyan' + : text === ErrorTypeEnum.PROMISE + ? 'blue' + : ErrorTypeEnum.AJAX + ? 'red' + : 'purple'; return {() => text}; }, }, diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/EditStreamPark.vue b/streampark-console/streampark-console-webapp/src/views/flink/app/EditStreamPark.vue index 266e12109c..47eead8a76 100644 --- a/streampark-console/streampark-console-webapp/src/views/flink/app/EditStreamPark.vue +++ b/streampark-console/streampark-console-webapp/src/views/flink/app/EditStreamPark.vue @@ -48,7 +48,7 @@ import { useGo } from '/@/hooks/web/usePage'; import ProgramArgs from './components/ProgramArgs.vue'; import VariableReview from './components/VariableReview.vue'; - import { ClusterStateEnum, ExecModeEnum, JobTypeEnum, UseStrategyEnum } from '/@/enums/flinkEnum'; + import { ExecModeEnum, JobTypeEnum, UseStrategyEnum } from '/@/enums/flinkEnum'; const route = useRoute(); const go = useGo(); diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/components/AppView/StartApplicationModal.vue b/streampark-console/streampark-console-webapp/src/views/flink/app/components/AppView/StartApplicationModal.vue index a786998294..fc64533ef8 100644 --- a/streampark-console/streampark-console-webapp/src/views/flink/app/components/AppView/StartApplicationModal.vue +++ b/streampark-console/streampark-console-webapp/src/views/flink/app/components/AppView/StartApplicationModal.vue @@ -31,7 +31,7 @@ import { BasicModal, useModalInner } from '/@/components/Modal'; import { useMessage } from '/@/hooks/web/useMessage'; import { useRouter } from 'vue-router'; - import { fetchCheckStart, fetchForcedStop, fetchStart } from '/@/api/flink/app'; + import { fetchCheckStart, fetchAbort, fetchStart } from '/@/api/flink/app'; import { AppExistsEnum } from '/@/enums/flinkEnum'; const SelectOption = Select.Option; @@ -116,7 +116,7 @@ id: receiveData.application.id, }); if (resp.data.data === AppExistsEnum.IN_YARN) { - await fetchForcedStop({ + await fetchAbort({ id: receiveData.application.id, }); } diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useApp.tsx b/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useApp.tsx index 82f6167659..d7fec2f607 100644 --- a/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useApp.tsx +++ b/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useApp.tsx @@ -17,7 +17,7 @@ import { Alert, Form, Input, Tag } from 'ant-design-vue'; import { h, onMounted, reactive, ref, unref, VNode } from 'vue'; import { handleAppBuildStatueText } from '../utils'; -import { fetchCheckName, fetchCopy, fetchForcedStop, fetchMapping } from '/@/api/flink/app'; +import { fetchCheckName, fetchCopy, fetchAbort, fetchMapping } from '/@/api/flink/app'; import { fetchBuild, fetchBuildDetail } from '/@/api/flink/flinkBuild'; import { fetchSavePonitHistory } from '/@/api/flink/savepoint'; import { fetchAppOwners } from '/@/api/system/user'; @@ -168,7 +168,7 @@ export const useFlinkApplication = (openStartModal: Fn) => { } return false; } - function handleForcedStop(app: Recordable) { + function handleAbort(app: Recordable) { let option = 'starting'; const optionState = app['optionState']; const stateMap = { @@ -189,21 +189,21 @@ export const useFlinkApplication = (openStartModal: Fn) => { } Swal.fire({ title: 'Are you sure?', - text: `current job is ${option}, are you sure forced stop?`, + text: `current job is ${option}, are you sure abort the job?`, icon: 'warning', showCancelButton: true, - confirmButtonText: 'Yes, forced stop!', + confirmButtonText: 'Yes, abort job!', denyButtonText: `No, cancel`, confirmButtonColor: '#d33', cancelButtonColor: '#3085d6', }).then(async (result) => { if (result.isConfirmed) { - Swal.fire('forced stopping', '', 'success'); - const res = await fetchForcedStop({ + Swal.fire('abort job', '', 'success'); + const res = await fetchAbort({ id: app.id, }); if (res) { - createMessage.success('forced stopping'); + createMessage.success('abort job starting'); } return Promise.resolve(); } @@ -383,7 +383,7 @@ export const useFlinkApplication = (openStartModal: Fn) => { handleCheckReleaseApp, handleAppCheckStart, handleCanStop, - handleForcedStop, + handleAbort, handleCopy, handleMapping, users, diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useAppTableAction.ts b/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useAppTableAction.ts index 59dad2a2f9..bebbde2266 100644 --- a/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useAppTableAction.ts +++ b/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useAppTableAction.ts @@ -56,7 +56,7 @@ export const useAppTableAction = ( handleCheckReleaseApp, handleAppCheckStart, handleCanStop, - handleForcedStop, + handleAbort, handleCopy, handleMapping, users, @@ -130,11 +130,11 @@ export const useAppTableAction = ( onClick: handleSavepoint.bind(null, record), }, { - tooltip: { title: t('flink.app.operation.force') }, + tooltip: { title: t('flink.app.operation.abort') }, ifShow: handleCanStop(record), auth: 'app:cancel', icon: 'ant-design:pause-circle-outlined', - onClick: handleForcedStop.bind(null, record), + onClick: handleAbort.bind(null, record), }, { label: t('flink.app.operation.copy'), diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useCreateAndEditSchema.ts b/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useCreateAndEditSchema.ts index 871ed3fbe9..25847a28f7 100644 --- a/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useCreateAndEditSchema.ts +++ b/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useCreateAndEditSchema.ts @@ -51,7 +51,7 @@ import { fetchFlinkEnv, fetchListFlinkEnv } from '/@/api/flink/flinkEnv'; import { FlinkEnv } from '/@/api/flink/flinkEnv.type'; import { AlertSetting } from '/@/api/setting/types/alert.type'; import { FlinkCluster } from '/@/api/flink/flinkCluster.type'; -import { AppTypeEnum, ClusterStateEnum, ExecModeEnum, JobTypeEnum } from '/@/enums/flinkEnum'; +import { AppTypeEnum, ExecModeEnum, JobTypeEnum } from '/@/enums/flinkEnum'; import { isK8sExecMode } from '../utils'; import { useI18n } from '/@/hooks/web/useI18n'; import { fetchCheckHadoop } from '/@/api/setting'; @@ -63,6 +63,7 @@ export interface HistoryRecord { k8sSessionClusterId: Array; flinkImage: Array; } + export const useCreateAndEditSchema = ( dependencyRef: Ref | null, edit?: { appId: string; mode: 'streampark' | 'flink' }, diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useFlinkRender.tsx b/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useFlinkRender.tsx index 505d7e2dc7..45b22f1d54 100644 --- a/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useFlinkRender.tsx +++ b/streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useFlinkRender.tsx @@ -39,7 +39,12 @@ import { handleConfTemplate } from '/@/api/flink/config'; import { decodeByBase64 } from '/@/utils/cipher'; import { useMessage } from '/@/hooks/web/useMessage'; import { SelectValue } from 'ant-design-vue/lib/select'; -import { CandidateTypeEnum, FailoverStrategyEnum, RestoreModeEnum, ClusterStateEnum } from '/@/enums/flinkEnum'; +import { + CandidateTypeEnum, + FailoverStrategyEnum, + RestoreModeEnum, + ClusterStateEnum, +} from '/@/enums/flinkEnum'; import { useI18n } from '/@/hooks/web/useI18n'; import { fetchYarnQueueList } from '/@/api/setting/yarnQueue'; import { ApiSelect } from '/@/components/Form'; diff --git a/streampark-console/streampark-console-webapp/src/views/system/token/token.data.ts b/streampark-console/streampark-console-webapp/src/views/system/token/token.data.ts index 192a711122..1d1918e00a 100644 --- a/streampark-console/streampark-console-webapp/src/views/system/token/token.data.ts +++ b/streampark-console/streampark-console-webapp/src/views/system/token/token.data.ts @@ -20,7 +20,6 @@ import { Switch } from 'ant-design-vue'; import { useMessage } from '/@/hooks/web/useMessage'; import { fetTokenStatusToggle } from '/@/api/system/token'; import { getNoTokenUserList } from '/@/api/system/user'; -import dayjs from 'dayjs'; import { useI18n } from '/@/hooks/web/useI18n'; const { t } = useI18n();