Skip to content

Commit

Permalink
重新上线
Browse files Browse the repository at this point in the history
  • Loading branch information
aiwenmo committed Mar 6, 2022
1 parent 24edc06 commit 67d9e72
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public JobResult submitByTaskId(Integer id) {
public JobResult restartByTaskId(Integer id) {
Task task = this.getTaskInfoById(id);
Asserts.checkNull(task, Tips.TASK_NOT_EXIST);
if(Asserts.isNotNull(task.getJobInstanceId())||task.getJobInstanceId()!=0){
if(Asserts.isNotNull(task.getJobInstanceId())&&task.getJobInstanceId()!=0){
savepointTask(task, SavePointType.CANCEL.getValue());
}
if (Dialect.isSql(task.getDialect())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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.
-->

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder/>

<dubbo:application name="demo-consumer"/>

<dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>

<!-- <dubbo:reference id="demoService" check="true" interface="com.dlink.service.DemoService" version="1.0.0"/>-->

</beans>
4 changes: 4 additions & 0 deletions dlink-web/src/components/Studio/StudioEvent/DDL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ export function showFlinkJobs(clusterId:number) {
export function cancelJob(clusterId:number,jobId:string) {
return getData('api/studio/cancel',{clusterId:clusterId,jobId:jobId});
}
/*--- 重启 Flink Jobs ---*/
export function restartJob(id: number) {
return getData('api/task/restartTask',{id});
}
/*--- 停止 SavePoint Jobs ---*/
export function savepointJob(clusterId:number,jobId:string,savePointType:string,name:string,taskId:number) {
return getData('api/studio/savepoint',{clusterId,jobId,savePointType,name,taskId});
Expand Down
24 changes: 22 additions & 2 deletions dlink-web/src/pages/DevOps/JobInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import moment from "moment";
import BaseInfo from "@/pages/DevOps/JobInfo/BaseInfo";
import Config from "@/pages/DevOps/JobInfo/Config";
import JobStatus, {isStatusDone} from "@/components/Common/JobStatus";
import {cancelJob, savepointJob} from "@/components/Studio/StudioEvent/DDL";
import {cancelJob, restartJob, savepointJob} from "@/components/Studio/StudioEvent/DDL";

const {Link} = Typography;

Expand Down Expand Up @@ -96,6 +96,26 @@ const JobInfo = (props: any) => {
});
};

const handleRestart = () => {
Modal.confirm({
title: '重新上线任务',
content: `确定重新上线该作业吗?`,
okText: '确认',
cancelText: '取消',
onOk: async () => {
if (!job?.cluster?.id) return;
const res = restartJob(job?.instance?.taskId);
res.then((result) => {
if (result.datas.success == true) {
message.success("重新上线成功");
} else {
message.error("重新上线失败");
}
});
}
});
};

const getButtons = () => {
let buttons = [
<Button key="back" type="dashed" onClick={handleBack}>返回</Button>,
Expand All @@ -107,7 +127,7 @@ const JobInfo = (props: any) => {
FlinkWebUI
</Link></Button>);
}
buttons.push(<Button key="autorestart" type="primary">重新上线</Button>);
buttons.push(<Button key="autorestart" type="primary" onClick={handleRestart}>重新上线</Button>);
if(!isStatusDone(job?.instance?.status as string)){
buttons.push(<Button key="autostop" type="primary" danger onClick={()=>{handleSavepoint('cancel')}}>下线</Button>);
buttons.push(<Dropdown
Expand Down

0 comments on commit 67d9e72

Please sign in to comment.