use of com.flink.platform.web.entity.request.JobFlowRequest 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.web.entity.request.JobFlowRequest in project flink-platform-backend by itinycheng.
the class JobFlowController method stop.
@GetMapping(value = "/schedule/stop/{flowId}")
public ResultInfo<Long> stop(@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());
if (jobFlow == null) {
return failure(SERVICE_ERROR, "Job flow not found");
}
jobFlowQuartzService.stopJob(jobFlow);
return ResultInfo.success(flowId);
}
use of com.flink.platform.web.entity.request.JobFlowRequest in project flink-platform-backend by itinycheng.
the class JobFlowTest method test1.
@Test
public void test1() {
JobFlowDag dag = new JobFlowDag();
JobVertex jobVertex1 = new JobVertex(19L, 19L);
JobVertex jobVertex2 = new JobVertex(20L, 20L);
dag.addVertex(jobVertex1);
dag.addVertex(jobVertex2);
JobEdge jobEdge = new JobEdge(19L, 20L, SUCCESS);
dag.addEdge(jobEdge);
JobFlowRequest jobFlowRequest = new JobFlowRequest();
jobFlowRequest.setCode(UuidGenerator.generateShortUuid());
jobFlowRequest.setName("test_1");
jobFlowRequest.setUserId(0L);
jobFlowRequest.setDescription("description");
jobFlowRequest.setCronExpr("0 0/10 * * * ?");
jobFlowRequest.setFlow(dag);
jobFlowRequest.setPriority(8);
jobFlowRequest.setAlerts(new LongArrayList());
jobFlowRequest.setStatus(OFFLINE);
String json = JsonUtil.toJsonString(jobFlowRequest.getJobFlow());
System.out.println(json);
}
Aggregations