use of com.flink.platform.common.enums.JobFlowStatus in project flink-platform-backend by itinycheng.
the class JobFlowController method start.
@GetMapping(value = "/schedule/start/{flowId}")
public ResultInfo<Long> start(@PathVariable Long flowId) {
JobFlowRequest jobFlowRequest = new JobFlowRequest();
jobFlowRequest.setId(flowId);
String errorMsg = jobFlowRequest.verifyId();
if (StringUtils.isNotBlank(errorMsg)) {
return failure(ERROR_PARAMETER, errorMsg);
}
JobFlow jobFlow = jobFlowService.getById(jobFlowRequest.getId());
JobFlowStatus status = jobFlow.getStatus();
if (status == null || !status.isRunnable()) {
return failure(NOT_RUNNABLE_STATUS);
}
if (StringUtils.isEmpty(jobFlow.getCronExpr())) {
return failure(NO_CRONTAB_SET);
}
JobFlowDag flow = jobFlow.getFlow();
if (flow == null || jobFlowService.containsStreamingJob(flow)) {
return failure(UNABLE_SCHEDULE_STREAMING_JOB);
}
jobFlowQuartzService.scheduleJob(jobFlow);
return ResultInfo.success(flowId);
}
use of com.flink.platform.common.enums.JobFlowStatus in project flink-platform-backend by itinycheng.
the class JobFlowController method runOnce.
@GetMapping(value = "/schedule/runOnce/{flowId}")
public ResultInfo<Long> runOnce(@PathVariable Long flowId) {
JobFlow jobFlow = jobFlowService.getById(flowId);
JobFlowStatus status = jobFlow.getStatus();
if (status == null || !status.isRunnable()) {
return failure(NOT_RUNNABLE_STATUS);
}
// TODO better in sync lock.
JobFlowRun jobFlowRun = jobFlowRunService.getById(flowId);
if (jobFlowRun != null && !jobFlowRun.getStatus().isTerminalState()) {
return failure(SERVICE_ERROR);
}
JobFlowQuartzInfo jobFlowQuartzInfo = new JobFlowQuartzInfo(jobFlow);
if (quartzService.runOnce(jobFlowQuartzInfo)) {
return ResultInfo.success(flowId);
} else {
return failure(SERVICE_ERROR);
}
}
Aggregations