Search in sources :

Example 1 with JobFlowStatus

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);
}
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 JobFlowStatus

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

Aggregations

JobFlowStatus (com.flink.platform.common.enums.JobFlowStatus)2 JobFlow (com.flink.platform.dao.entity.JobFlow)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 JobFlowDag (com.flink.platform.dao.entity.JobFlowDag)1 JobFlowRun (com.flink.platform.dao.entity.JobFlowRun)1 JobFlowQuartzInfo (com.flink.platform.web.entity.JobFlowQuartzInfo)1 JobFlowRequest (com.flink.platform.web.entity.request.JobFlowRequest)1