Search in sources :

Example 1 with JobQuartzInfo

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

the class UserGroupController method createOrUpdate.

@PostMapping(value = "/createOrUpdate")
public ResultInfo<Long> createOrUpdate(@RequestBody UserGroupRequest userGroupRequest) {
    try {
        ResultInfo<String> sqlInfo = insertSelect(userGroupRequest.getSelect());
        String sql = sqlInfo.getData();
        JobInfo jobInfo = new JobInfo();
        BeanUtils.copyProperties(userGroupRequest, jobInfo);
        jobInfo.setSubject(sql);
        jobInfo.setType(JobType.FLINK_SQL);
        jobInfo.setDeployMode(DeployMode.FLINK_YARN_PER);
        jobInfo.setExecMode(ExecutionMode.BATCH);
        LongArrayList longs = new LongArrayList();
        longs.add(1L);
        jobInfo.setCatalogs(longs);
        jobInfo.setStatus(JobStatus.ONLINE);
        boolean bool = jobInfoService.saveOrUpdate(jobInfo);
        if (bool && userGroupRequest.getId() == null) {
            JobQuartzInfo jobQuartzInfo = new JobQuartzInfo(jobInfo);
            quartzService.runOnce(jobQuartzInfo);
            quartzService.addJobToQuartz(jobQuartzInfo);
        }
        return ResultInfo.success(jobInfo.getId());
    } catch (Exception e) {
        log.error("create or update user group failed", e);
        return ResultInfo.failure(ResponseStatus.SERVICE_ERROR);
    }
}
Also used : JobInfo(com.flink.platform.dao.entity.JobInfo) LongArrayList(com.flink.platform.dao.entity.LongArrayList) JobQuartzInfo(com.flink.platform.web.entity.JobQuartzInfo) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

JobInfo (com.flink.platform.dao.entity.JobInfo)1 LongArrayList (com.flink.platform.dao.entity.LongArrayList)1 JobQuartzInfo (com.flink.platform.web.entity.JobQuartzInfo)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1