Search in sources :

Example 1 with JobFlowQuartzInfo

use of com.flink.platform.web.entity.JobFlowQuartzInfo 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)

Example 2 with JobFlowQuartzInfo

use of com.flink.platform.web.entity.JobFlowQuartzInfo in project flink-platform-backend by itinycheng.

the class JobFlowQuartzService method scheduleJob.

@Transactional(rollbackFor = Exception.class)
public boolean scheduleJob(JobFlow jobFlow) {
    JobFlowQuartzInfo jobFlowQuartzInfo = new JobFlowQuartzInfo(jobFlow);
    boolean bool = quartzService.addJobToQuartz(jobFlowQuartzInfo);
    JobFlow newJobFlow = new JobFlow();
    newJobFlow.setId(jobFlow.getId());
    newJobFlow.setStatus(SCHEDULING);
    jobFlowService.updateById(newJobFlow);
    return bool;
}
Also used : JobFlowQuartzInfo(com.flink.platform.web.entity.JobFlowQuartzInfo) JobFlow(com.flink.platform.dao.entity.JobFlow) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with JobFlowQuartzInfo

use of com.flink.platform.web.entity.JobFlowQuartzInfo in project flink-platform-backend by itinycheng.

the class JobFlowQuartzService method stopJob.

@Transactional(rollbackFor = Exception.class)
public boolean stopJob(JobFlow jobFlow) {
    JobFlowQuartzInfo jobFlowQuartzInfo = new JobFlowQuartzInfo(jobFlow);
    quartzService.removeJob(jobFlowQuartzInfo);
    JobFlow newJobFlow = new JobFlow();
    newJobFlow.setId(jobFlow.getId());
    newJobFlow.setStatus(ONLINE);
    jobFlowService.updateById(newJobFlow);
    return true;
}
Also used : JobFlowQuartzInfo(com.flink.platform.web.entity.JobFlowQuartzInfo) JobFlow(com.flink.platform.dao.entity.JobFlow) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

JobFlow (com.flink.platform.dao.entity.JobFlow)3 JobFlowQuartzInfo (com.flink.platform.web.entity.JobFlowQuartzInfo)3 Transactional (org.springframework.transaction.annotation.Transactional)2 JobFlowStatus (com.flink.platform.common.enums.JobFlowStatus)1 JobFlowRun (com.flink.platform.dao.entity.JobFlowRun)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1