feature(web): 优化flink job id和alias的自动匹配获取

This commit is contained in:
2023-07-14 14:56:19 +08:00
parent 5c43617315
commit 1a0bc8b7ef
6 changed files with 161 additions and 87 deletions

View File

@@ -60,20 +60,6 @@ public class TableController extends BaseController {
this.infoService = infoService;
this.zookeeperService = zookeeperService;
this.mapper = jackson2ObjectMapperBuilder.build();
this.cache = Caffeine.newBuilder()
.expireAfterAccess(Duration.ofMinutes(5))
.build(key -> {
switch (key) {
case "flink_job_id":
return this.infoService.allFlinkJobId().collect(Objects::toString);
case "alias":
return this.infoService.allAlias();
case "hdfs":
return this.infoService.allHdfs();
default:
return Lists.immutable.empty();
}
});
}
@GetMapping("list")
@@ -209,24 +195,36 @@ public class TableController extends BaseController {
return AmisResponse.responseCrudData(vos, pageResponse.getTotal());
}
private final LoadingCache<String, ImmutableList<String>> cache;
@SuppressWarnings("DataFlowIssue")
@GetMapping("all_flink_job_id")
public AmisCrudResponse allFlinkJobId(@RequestParam(value = "key", required = false) String key) {
public AmisCrudResponse allFlinkJobId(
@RequestParam(value = "key", required = false) String key,
@RequestParam(value = "alias", required = false) String alias
) {
if (StrUtil.isBlank(key)) {
return AmisResponse.responseCrudData(Lists.immutable.empty());
}
return AmisResponse.responseCrudData(cache.get("flink_job_id").select(id -> StrUtil.contains(id, key)));
if (StrUtil.isBlank(alias)) {
return AmisResponse.responseCrudData(infoService.allFlinkJobId(key).collect(Objects::toString));
} else {
return AmisResponse.responseCrudData(infoService.allFlinkJobId(key, alias).collect(Objects::toString));
}
}
@SuppressWarnings("DataFlowIssue")
@GetMapping("all_alias")
public AmisCrudResponse allAlias(@RequestParam(value = "key", required = false) String key) {
if (StrUtil.isBlank(key)) {
public AmisCrudResponse allAlias(
@RequestParam(value = "key", required = false) String key,
@RequestParam(value = "flink_job_id", required = false) String flinkJobId
) {
if (StrUtil.isBlank(key) && StrUtil.isBlank(flinkJobId)) {
return AmisResponse.responseCrudData(Lists.immutable.empty());
}
return AmisResponse.responseCrudData(cache.get("alias").select(id -> StrUtil.contains(id, key)));
if (StrUtil.isBlank(flinkJobId)) {
return AmisResponse.responseCrudData(infoService.allAlias(key));
} else {
return AmisResponse.responseCrudData(infoService.allAlias(key, flinkJobId));
}
}
@SuppressWarnings("DataFlowIssue")
@@ -235,6 +233,6 @@ public class TableController extends BaseController {
if (StrUtil.isBlank(key)) {
return AmisResponse.responseCrudData(Lists.immutable.empty());
}
return AmisResponse.responseCrudData(cache.get("hdfs").select(id -> StrUtil.contains(id, key)));
return AmisResponse.responseCrudData(infoService.allHdfs(key));
}
}