feat(web): overview增加同步任务状态展示

This commit is contained in:
2024-01-11 19:14:13 +08:00
parent 59dd3b29f4
commit 820c8438b1
5 changed files with 213 additions and 5 deletions

View File

@@ -122,6 +122,9 @@ public interface InfoService {
@Get("/info/non_exists_table_by_hdfs")
Boolean nonExistsTableByHdfs(@Query("hdfs") String hdfs);
@Get("/info/all_flink_job_id_and_alias")
ImmutableList<JobIdAndAlias> allFlinkJobIdAndAlias();
@Get("/info/all_flink_job_id")
ImmutableList<Long> allFlinkJobId();

View File

@@ -63,6 +63,12 @@ public class InfoController {
return infoService.jobAndMetas();
}
@GetMapping("/all_flink_job_id_and_alias")
public ImmutableList<JobIdAndAlias> allFlinkJobIdAndAlias() {
return infoService.allTableInfoSearchCache()
.collect(cache -> new JobIdAndAlias(cache.getFlinkJobId(), cache.getAlias()));
}
@GetMapping("/all_flink_job_id")
public ImmutableList<Long> allFlinkJobId(
@RequestParam(value = "key", required = false) String key,

View File

@@ -1,14 +1,13 @@
package com.lanyuanxiaoyao.service.web.controller;
import cn.hutool.core.util.StrUtil;
import com.eshore.odcp.hudi.connector.utils.NameHelper;
import com.lanyuanxiaoyao.service.configuration.ExecutorProvider;
import com.lanyuanxiaoyao.service.configuration.entity.info.JobIdAndAlias;
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnApplication;
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnRootQueue;
import com.lanyuanxiaoyao.service.forest.service.InfoService;
import com.lanyuanxiaoyao.service.forest.service.QueueService;
import com.lanyuanxiaoyao.service.forest.service.ScheduleService;
import com.lanyuanxiaoyao.service.forest.service.YarnService;
import com.lanyuanxiaoyao.service.configuration.entity.zookeeper.ZookeeperNode;
import com.lanyuanxiaoyao.service.forest.service.*;
import com.lanyuanxiaoyao.service.web.controller.base.AmisCrudResponse;
import com.lanyuanxiaoyao.service.web.controller.base.AmisMapResponse;
import com.lanyuanxiaoyao.service.web.controller.base.AmisResponse;
@@ -18,8 +17,10 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.Maps;
import org.eclipse.collections.api.list.ImmutableList;
import org.eclipse.collections.api.list.MutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
@@ -42,13 +43,15 @@ public class OverviewController extends BaseController {
private final YarnService yarnService;
private final QueueService queueService;
private final ScheduleService scheduleService;
private final ZookeeperService zookeeperService;
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public OverviewController(InfoService infoService, YarnService yarnService, QueueService queueService, ScheduleService scheduleService) {
public OverviewController(InfoService infoService, YarnService yarnService, QueueService queueService, ScheduleService scheduleService, ZookeeperService zookeeperService) {
this.infoService = infoService;
this.yarnService = yarnService;
this.queueService = queueService;
this.scheduleService = scheduleService;
this.zookeeperService = zookeeperService;
}
@GetMapping("")
@@ -143,4 +146,44 @@ public class OverviewController extends BaseController {
public AmisCrudResponse scheduleJobs() {
return AmisResponse.responseCrudData(scheduleService.scheduleJobs());
}
@GetMapping("sync_running_status")
public AmisMapResponse syncRunningStatus() {
ImmutableList<String> locks = zookeeperService.getChildren(NameHelper.ZK_SYNC_RUNNING_LOCK_PATH).collect(ZookeeperNode::getPath);
MutableList<JobIdAndAlias> runningJob = Lists.mutable.empty();
MutableList<JobIdAndAlias> unRunningJob = Lists.mutable.empty();
MutableList<JobIdAndAlias> runningTable = Lists.mutable.empty();
MutableList<JobIdAndAlias> unRunningTable = Lists.mutable.empty();
ImmutableList<JobIdAndAlias> idAliases = infoService.allFlinkJobIdAndAlias();
ImmutableList<Long> ids = idAliases.collect(JobIdAndAlias::getId).distinct();
ids
.forEach(id -> {
String lockPath = NameHelper.syncRunningLockPath(id);
if (locks.contains(lockPath)) {
runningJob.add(new JobIdAndAlias(id, ""));
} else {
unRunningJob.add(new JobIdAndAlias(id, ""));
}
});
idAliases
.forEach(ia -> {
String lockPath = NameHelper.syncRunningLockPath(ia.getId(), ia.getAlias());
if (locks.contains(lockPath)) {
runningTable.add(ia);
} else {
unRunningTable.add(ia);
}
});
return AmisResponse.responseMapData()
.setData("totalJob", ids.size())
.setData("runningJob", runningJob.size())
.setData("runningJobList", runningJob)
.setData("unRunningJob", unRunningJob.size())
.setData("unRunningJobList", unRunningJob)
.setData("totalTable", idAliases.size())
.setData("runningTable", runningTable.size())
.setData("runningTableList", runningTable)
.setData("unRunningTable", unRunningTable.size())
.setData("unRunningTableList", unRunningTable);
}
}

View File

@@ -94,6 +94,123 @@ function versionDetailDialog(variable, target) {
}
}
function jobDetailDialog(variable, targetList) {
return {
disabledOn: `${variable} === 0`,
type: 'action',
label: '详情',
level: 'link',
size: 'sm',
actionType: 'dialog',
dialog: {
title: '详情',
size: 'sm',
...readOnlyDialogOptions(),
body: [
{
type: "table",
source: `\${${targetList}}`,
affixHeader: false,
columns: [
{
label: 'Flink job id',
fixed: 'left',
type: 'wrapper',
size: 'none',
body: [
{
type: 'tpl',
tpl: '${id}',
},
{
type: 'action',
level: 'link',
label: '',
icon: 'fa fa-copy',
size: 'xs',
actionType: 'copy',
content: '${id}',
tooltip: '复制 ID',
}
],
},
]
}
]
}
}
}
function tableDetailDialog(variable, targetList) {
return {
disabledOn: `${variable} === 0`,
type: 'action',
label: '详情',
level: 'link',
size: 'sm',
actionType: 'dialog',
dialog: {
title: '详情',
size: 'md',
...readOnlyDialogOptions(),
body: [
{
type: "table",
source: `\${${targetList}}`,
affixHeader: false,
columns: [
{
label: 'Flink job id',
fixed: 'left',
type: 'wrapper',
size: 'none',
body: [
{
type: 'tpl',
tpl: '${id}',
},
{
type: 'action',
level: 'link',
label: '',
icon: 'fa fa-copy',
size: 'xs',
actionType: 'copy',
content: '${id}',
tooltip: '复制 ID',
}
],
},
{
label: '别名',
type: 'wrapper',
fixed: 'left',
size: 'none',
className: 'nowrap',
body: [
{
type: 'tpl',
tpl: '${alias}',
},
{
type: 'action',
level: 'link',
label: '',
icon: 'fa fa-copy',
size: 'xs',
actionType: 'copy',
content: '${alias}',
tooltip: '复制别名',
},
],
},
]
}
]
}
}
}
function overviewYarnJob(cluster, search, queue, yarnQueue) {
return {
className: 'font-mono',
@@ -220,6 +337,42 @@ function overviewTab() {
]
},
{type: 'divider'},
{
type: 'service',
api: '${base}/overview/sync_running_status',
body: [
{
type: 'tpl',
tpl: '任务数<span class="font-bold m-2 font-mono">${totalJob}</span>'
},
{
className: 'mx-2',
type: 'tpl',
tpl: '运行中<span class="font-bold m-2 font-mono">${PADSTART(runningJob, 3)}</span>'
},
{
type: 'tpl',
tpl: '已停止<span class="font-bold m-2 font-mono text-danger">${PADSTART(unRunningJob, 3)}</span>'
},
jobDetailDialog('unRunningJob', 'unRunningJobList'),
'<br/>',
{
type: 'tpl',
tpl: '总表数<span class="font-bold m-2 font-mono">${totalTable}</span>'
},
{
className: 'mx-2',
type: 'tpl',
tpl: '运行中<span class="font-bold m-2 font-mono">${PADSTART(runningTable, 3)}</span>'
},
{
type: 'tpl',
tpl: '已停止<span class="font-bold m-2 font-mono text-danger">${PADSTART(unRunningTable, 3)}</span>'
},
tableDetailDialog('unRunningTable', 'unRunningTableList'),
]
},
{type: 'divider'},
'<span class="italic text-gray-500 my-2">集群 (集群总资源使用,队列资源使用)(调度中任务数,运行中任务数)</span>',
overviewYarnJob('b12', 'Sync', undefined, 'default'),
{type: 'divider'},

View File

@@ -73,3 +73,6 @@ GET {{web-url}}/cloud/deploy_plan
### Get info query services
GET {{services-url}}/cloud/services?service_name=center-gateway-new
### Sync status
GET {{web-url}}/overview/sync_running_status