Search in sources :

Example 1 with JobFlowRequest

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);
}
Also used : JobFlowDag(com.flink.platform.dao.entity.JobFlowDag) JobFlowRequest(com.flink.platform.web.entity.request.JobFlowRequest) JobFlow(com.flink.platform.dao.entity.JobFlow) JobFlowStatus(com.flink.platform.common.enums.JobFlowStatus) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with JobFlowRequest

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);
}
Also used : JobFlowRequest(com.flink.platform.web.entity.request.JobFlowRequest) JobFlow(com.flink.platform.dao.entity.JobFlow) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with JobFlowRequest

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);
}
Also used : JobFlowDag(com.flink.platform.dao.entity.JobFlowDag) JobVertex(com.flink.platform.common.model.JobVertex) JobFlowRequest(com.flink.platform.web.entity.request.JobFlowRequest) JobEdge(com.flink.platform.common.model.JobEdge) LongArrayList(com.flink.platform.dao.entity.LongArrayList) Test(org.junit.Test)

Aggregations

JobFlowRequest (com.flink.platform.web.entity.request.JobFlowRequest)3 JobFlow (com.flink.platform.dao.entity.JobFlow)2 JobFlowDag (com.flink.platform.dao.entity.JobFlowDag)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 JobFlowStatus (com.flink.platform.common.enums.JobFlowStatus)1 JobEdge (com.flink.platform.common.model.JobEdge)1 JobVertex (com.flink.platform.common.model.JobVertex)1 LongArrayList (com.flink.platform.dao.entity.LongArrayList)1 Test (org.junit.Test)1