feature(web): 增加历史压缩情况查询
This commit is contained in:
@@ -11,9 +11,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.lanyuanxiaoyao.service.configuration.ExecutorProvider;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.PageResponse;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.info.CompactionMetrics;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.info.JobIdAndAlias;
|
||||
import com.lanyuanxiaoyao.service.forest.service.InfoService;
|
||||
import com.lanyuanxiaoyao.service.forest.service.ZookeeperService;
|
||||
import com.lanyuanxiaoyao.service.web.entity.CompactionMetricsVO;
|
||||
import com.lanyuanxiaoyao.service.web.entity.FlinkJobVO;
|
||||
import com.lanyuanxiaoyao.service.web.entity.SyncStateVO;
|
||||
import com.lanyuanxiaoyao.service.web.entity.TableVO;
|
||||
@@ -158,4 +160,26 @@ public class TableController extends BaseController {
|
||||
.withData("flinkJob", new FlinkJobVO(flinkJobFuture.get()))
|
||||
.withData("tableMeta", tableMetaFuture.get());
|
||||
}
|
||||
|
||||
@GetMapping("list_compaction_metrics")
|
||||
public AmisResponse listCompactionMetrics(
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "count", defaultValue = "10") Integer count,
|
||||
@RequestParam(value = "order", required = false) String order,
|
||||
@RequestParam(value = "direction", required = false) String direction,
|
||||
@RequestParam(value = "search_flink_job_id") String searchFlinkJobId,
|
||||
@RequestParam(value = "search_alias") String searchAlias,
|
||||
@RequestParam(value = "filter_completes", required = false) List<Boolean> filterCompletes
|
||||
) throws Exception {
|
||||
if (ObjectUtil.isNull(searchFlinkJobId) || ObjectUtil.isNull(searchAlias)) {
|
||||
throw new Exception("flink job id or alias is null");
|
||||
}
|
||||
MutableMap<String, Object> queryMap = buildQueryMap(page, count, order, direction, searchFlinkJobId, searchAlias);
|
||||
if (ObjectUtil.isNotEmpty(filterCompletes)) {
|
||||
queryMap.put("filter_completes", filterCompletes);
|
||||
}
|
||||
PageResponse<CompactionMetrics> pageResponse = infoService.compactionMetrics(queryMap);
|
||||
ImmutableList<CompactionMetricsVO> vos = Lists.immutable.ofAll(pageResponse.getData()).collect(CompactionMetricsVO::new);
|
||||
return responseCrudData(vos, pageResponse.getTotal());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.lanyuanxiaoyao.service.web.entity;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.info.CompactionMetrics;
|
||||
import com.lanyuanxiaoyao.service.web.utils.DatetimeUtil;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2023-06-14
|
||||
*/
|
||||
public class CompactionMetricsVO {
|
||||
private final String flinkJobId;
|
||||
private final String alias;
|
||||
private final String applicationId;
|
||||
private final String cluster;
|
||||
private final String compactionPlanInstant;
|
||||
private final Boolean complete;
|
||||
private final Long startedTime;
|
||||
private final Long finishedTime;
|
||||
|
||||
|
||||
private String startedTimeFromNow;
|
||||
private String finishedTimeFromNow;
|
||||
|
||||
public CompactionMetricsVO(CompactionMetrics metrics) {
|
||||
this.flinkJobId = metrics.getFlinkJobId().toString();
|
||||
this.alias = metrics.getAlias();
|
||||
this.applicationId = metrics.getApplicationId();
|
||||
this.cluster = metrics.getCluster();
|
||||
this.compactionPlanInstant = metrics.getCompactionPlanInstant();
|
||||
this.complete = metrics.getComplete();
|
||||
this.startedTime = metrics.getStartedTime();
|
||||
this.finishedTime = metrics.getFinishedTime();
|
||||
|
||||
long now = Instant.now().toEpochMilli();
|
||||
if (ObjectUtil.isNotNull(metrics.getStartedTime()) && metrics.getStartedTime() != 0) {
|
||||
startedTimeFromNow = DatetimeUtil.fromNow(now, metrics.getStartedTime());
|
||||
}
|
||||
if (ObjectUtil.isNotNull(metrics.getFinishedTime()) && metrics.getFinishedTime() != 0) {
|
||||
finishedTimeFromNow = DatetimeUtil.fromNow(now, metrics.getFinishedTime());
|
||||
}
|
||||
}
|
||||
|
||||
public String getFlinkJobId() {
|
||||
return flinkJobId;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public String getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
public String getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
public String getCompactionPlanInstant() {
|
||||
return compactionPlanInstant;
|
||||
}
|
||||
|
||||
public Boolean getComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
public Long getStartedTime() {
|
||||
return startedTime;
|
||||
}
|
||||
|
||||
public Long getFinishedTime() {
|
||||
return finishedTime;
|
||||
}
|
||||
|
||||
public String getStartedTimeFromNow() {
|
||||
return startedTimeFromNow;
|
||||
}
|
||||
|
||||
public String getFinishedTimeFromNow() {
|
||||
return finishedTimeFromNow;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user