Search in sources :

Example 1 with LongArrayList

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

Example 2 with LongArrayList

use of com.flink.platform.dao.entity.LongArrayList 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

LongArrayList (com.flink.platform.dao.entity.LongArrayList)2 JobEdge (com.flink.platform.common.model.JobEdge)1 JobVertex (com.flink.platform.common.model.JobVertex)1 JobFlowDag (com.flink.platform.dao.entity.JobFlowDag)1 JobInfo (com.flink.platform.dao.entity.JobInfo)1 JobQuartzInfo (com.flink.platform.web.entity.JobQuartzInfo)1 JobFlowRequest (com.flink.platform.web.entity.request.JobFlowRequest)1 Test (org.junit.Test)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1