refactor(web): 优化单表调度提交

This commit is contained in:
2023-07-11 18:50:40 +08:00
parent 5abfe2d017
commit 2cfc009c51
4 changed files with 29 additions and 22 deletions

View File

@@ -1,21 +1,18 @@
package com.lanyuanxiaoyao.service.web.controller;
import cn.hutool.core.util.ReUtil;
import com.dtflys.forest.annotation.Get;
import com.lanyuanxiaoyao.service.configuration.entity.info.JobIdAndAlias;
import com.lanyuanxiaoyao.service.configuration.exception.TableNotFoundException;
import com.lanyuanxiaoyao.service.forest.service.InfoService;
import com.lanyuanxiaoyao.service.forest.service.ScheduleService;
import com.lanyuanxiaoyao.service.web.controller.base.AmisResponse;
import com.lanyuanxiaoyao.service.web.controller.base.BaseController;
import java.util.regex.Pattern;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.list.ImmutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* 调度
@@ -38,7 +35,7 @@ public class ScheduleController extends BaseController {
}
@PostMapping("table_batch")
public void tableBatch(@RequestParam("lines") String lines) throws TableNotFoundException {
public AmisResponse<Object> tableBatch(@RequestParam("lines") String lines) throws TableNotFoundException {
Pattern p = Pattern.compile("^(\\d+)\\s*(\\S+)$");
ImmutableList<JobIdAndAlias> jobIdAndAliases = Lists.immutable.of(lines.trim().split("\n"))
.collect(line -> {
@@ -50,14 +47,18 @@ public class ScheduleController extends BaseController {
checkTableExists(infoService, jobIdAndAlias.getId(), jobIdAndAlias.getAlias());
}
jobIdAndAliases.forEach(item -> scheduleService.scheduleTable(item.getId(), item.getAlias()));
return AmisResponse.responseSuccess();
}
@Get("table")
public void table(
@GetMapping("table")
public AmisResponse<Object> table(
@RequestParam("flink_job_id") Long flinkJobId,
@RequestParam("alias") String alias
@RequestParam("alias") String alias,
@RequestParam(value = "force", required = false) String forceCluster,
@RequestParam(value = "recommend", required = false) String recommendCluster
) throws TableNotFoundException {
checkTableExists(infoService, flinkJobId, alias);
scheduleService.scheduleTable(flinkJobId, alias);
// checkTableExists(infoService, flinkJobId, alias);
// scheduleService.scheduleTable(flinkJobId, alias);
return AmisResponse.responseSuccess();
}
}