feature(web): 新增 Flink 相关查询内容
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package com.lanyuanxiaoyao.service.web.controller;
|
||||
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.flink.FlinkOverview;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.flink.FlinkVertex;
|
||||
import com.lanyuanxiaoyao.service.forest.service.FlinkService;
|
||||
import com.lanyuanxiaoyao.service.web.entity.FlinkOverviewVO;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Flink 接口
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2023-05-05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("flink")
|
||||
public class FlinkController extends BaseController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FlinkController.class);
|
||||
private static final ExecutorService EXECUTOR = Executors.newWorkStealingPool(20);
|
||||
|
||||
private final FlinkService flinkService;
|
||||
|
||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||
public FlinkController(FlinkService flinkService) {
|
||||
this.flinkService = flinkService;
|
||||
}
|
||||
|
||||
@GetMapping("overview")
|
||||
public AmisResponse overview(@RequestParam("url") String url) throws ExecutionException, InterruptedException {
|
||||
CompletableFuture<FlinkOverview> overviewFuture = CompletableFuture.supplyAsync(() -> flinkService.overview(url), EXECUTOR);
|
||||
CompletableFuture<ImmutableList<FlinkVertex>> jobsFuture = CompletableFuture.supplyAsync(() -> flinkService.vertexOverview(url)
|
||||
.getJobs()
|
||||
.asParallel(EXECUTOR, 1)
|
||||
.collect(vertex -> flinkService.vertex(url, vertex.getJid()))
|
||||
.toList()
|
||||
.toImmutable(), EXECUTOR);
|
||||
CompletableFuture.allOf(overviewFuture).get();
|
||||
|
||||
return responseDetail(new FlinkOverviewVO(
|
||||
overviewFuture.get(),
|
||||
jobsFuture.get()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.lanyuanxiaoyao.service.web.entity;
|
||||
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.flink.FlinkOverview;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.flink.FlinkVertex;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
|
||||
/**
|
||||
* Flink overview
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2023-05-05
|
||||
*/
|
||||
public class FlinkOverviewVO {
|
||||
private final FlinkOverview overview;
|
||||
private final ImmutableList<FlinkVertex> jobs;
|
||||
|
||||
public FlinkOverviewVO(FlinkOverview overview, ImmutableList<FlinkVertex> jobs) {
|
||||
this.overview = overview;
|
||||
this.jobs = jobs;
|
||||
}
|
||||
|
||||
public FlinkOverview getOverview() {
|
||||
return overview;
|
||||
}
|
||||
|
||||
public ImmutableList<FlinkVertex> getJobs() {
|
||||
return jobs;
|
||||
}
|
||||
}
|
||||
@@ -175,20 +175,75 @@ function simpleYarnDialog(cluster, title, filterField) {
|
||||
actions: [],
|
||||
size: 'xl',
|
||||
body: [
|
||||
/*{
|
||||
{
|
||||
type: 'service',
|
||||
api: {
|
||||
method: 'get',
|
||||
url: `\${base}/${mode}_yarn/job_current`,
|
||||
url: '${base}/yarn/job_current',
|
||||
data: {
|
||||
name: `\${${mode}JobName}`,
|
||||
clusters: `${cluster}`,
|
||||
name: `\${${filterField}}`,
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'iframe',
|
||||
src: '${current.trackingUrl}',
|
||||
type: 'wrapper',
|
||||
size: 'none',
|
||||
visibleOn: '${hasCurrent}',
|
||||
body: [
|
||||
{
|
||||
type: 'service',
|
||||
api: {
|
||||
method: 'get',
|
||||
url: '${base}/flink/overview',
|
||||
data: {
|
||||
url: '${current.trackingUrl}'
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'property',
|
||||
title: 'Flink 基本信息',
|
||||
column: 4,
|
||||
items: [
|
||||
{label: 'Flink 版本', content: '${detail.overview.flinkVersion}'},
|
||||
{label: 'Flink 小版本', content: '${detail.overview.flinkCommit}', span: 3},
|
||||
{label: '运行中', content: '${detail.overview.jobsRunning}'},
|
||||
{label: '已结束', content: '${detail.overview.jobsFinished}'},
|
||||
{label: '已失败', content: '${detail.overview.jobsFailed}'},
|
||||
{label: '被取消', content: '${detail.overview.jobsCanceled}'},
|
||||
{label: 'Slot (可用/总数)', content: '${detail.overview.slotsAvailable}/${detail.overview.slotsTotal}', span: 4},
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'table',
|
||||
title: '任务详情',
|
||||
source: '${detail.jobs}',
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
label: '名称',
|
||||
width: 2000,
|
||||
},
|
||||
{
|
||||
name: 'metrics.readRecords',
|
||||
label: '读记录数',
|
||||
width: 60,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
},
|
||||
{
|
||||
name: 'metrics.writeRecords',
|
||||
label: '写记录数',
|
||||
width: 60,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'tpl',
|
||||
@@ -196,7 +251,8 @@ function simpleYarnDialog(cluster, title, filterField) {
|
||||
visibleOn: '${!hasCurrent}',
|
||||
},
|
||||
],
|
||||
},*/
|
||||
},
|
||||
{type: 'divider'},
|
||||
{
|
||||
type: 'crud',
|
||||
api: {
|
||||
|
||||
Reference in New Issue
Block a user