feat(launcher): 增加单独指定集群进行手动压缩的接口
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
package com.lanyuanxiaoyao.service.command.commands;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.command.utils.CommandLineUtils;
|
||||
import com.lanyuanxiaoyao.service.command.utils.TableUtils;
|
||||
import com.lanyuanxiaoyao.service.common.Constants;
|
||||
import com.lanyuanxiaoyao.service.common.entity.TableMeta;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnClusters;
|
||||
import com.lanyuanxiaoyao.service.forest.service.InfoService;
|
||||
import com.lanyuanxiaoyao.service.forest.service.ScheduleService;
|
||||
import com.lanyuanxiaoyao.service.forest.service.launcher.LaunchersService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.shell.standard.ShellComponent;
|
||||
@@ -27,10 +30,14 @@ public class CompactionCommand extends AbstractUtilShellComponent {
|
||||
|
||||
private final InfoService infoService;
|
||||
private final ScheduleService scheduleService;
|
||||
private final YarnClusters yarnClusters;
|
||||
private final LaunchersService launchersService;
|
||||
|
||||
public CompactionCommand(InfoService infoService, ScheduleService scheduleService) {
|
||||
public CompactionCommand(InfoService infoService, ScheduleService scheduleService, YarnClusters yarnClusters, LaunchersService launchersService) {
|
||||
this.infoService = infoService;
|
||||
this.scheduleService = scheduleService;
|
||||
this.yarnClusters = yarnClusters;
|
||||
this.launchersService = launchersService;
|
||||
}
|
||||
|
||||
@ShellMethod("启动表压缩任务")
|
||||
@@ -59,4 +66,40 @@ public class CompactionCommand extends AbstractUtilShellComponent {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ShellMethod("启动表压缩任务")
|
||||
public String compactionDryRun(
|
||||
@ShellOption(
|
||||
help = "集群",
|
||||
defaultValue = ""
|
||||
) String cluster,
|
||||
@ShellOption(help = "Flink job id") Long flinkJobId,
|
||||
@ShellOption(help = "别名") String alias,
|
||||
@ShellOption(
|
||||
help = "Ignore double check",
|
||||
defaultValue = "false"
|
||||
) Boolean ignoreCheck
|
||||
) {
|
||||
if (StrUtil.isBlank(cluster)) {
|
||||
cluster = yarnClusters.getDefaultCompactionCluster();
|
||||
logger.info("Use default compaction cluster: {}", cluster);
|
||||
}
|
||||
String targetCluster = cluster;
|
||||
TableMeta meta = infoService.tableMetaDetail(flinkJobId, alias);
|
||||
return CommandLineUtils.generateResultLines(
|
||||
() -> {
|
||||
if (ObjectUtil.isEmpty(meta)) {
|
||||
return "没有找到指定的表信息";
|
||||
} else {
|
||||
System.out.println(TableUtils.makeTableMeta(meta));
|
||||
if (doubleCheck(RUN_CONFIRMATION_MESSAGE, ignoreCheck)) {
|
||||
launchersService.compactionStart(targetCluster, flinkJobId, alias);
|
||||
return Constants.OPERATION_DONE;
|
||||
} else {
|
||||
return Constants.OPERATION_CANCEL;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user