Search in sources :

Example 1 with CustomizeStatusInfo

use of com.flink.platform.web.monitor.CustomizeStatusInfo in project flink-platform-backend by itinycheng.

the class JobExecuteThread method waitForComplete.

public StatusInfo waitForComplete(String routeUrl, JobRunInfo jobRunInfo) {
    int retryTimes = 0;
    int errorTimes = 0;
    boolean isRemote = isRemoteUrl(routeUrl);
    while (AppRunner.isRunning()) {
        try {
            StatusInfo statusInfo;
            if (isRemote) {
                HttpHeaders headers = new HttpHeaders();
                headers.setContentType(MediaType.APPLICATION_JSON);
                HttpEntity<JobRunInfo> requestEntity = new HttpEntity<>(jobRunInfo, headers);
                statusInfo = restTemplate.postForObject(routeUrl + REST_GET_STATUS, requestEntity, StatusInfo.class);
            } else {
                statusInfo = processJobStatusService.getStatus(jobRunInfo);
            }
            if (jobRunInfo.getExecMode() == STREAMING) {
                if (jobRunInfo.getCreateTime() == null) {
                    jobRunInfo.setCreateTime(LocalDateTime.now());
                }
                statusInfo = updateAndGetStreamJobStatus(statusInfo, jobRunInfo.getCreateTime());
            }
            if (statusInfo != null) {
                log.info("Job runId: {}, name: {} Status: {}", jobRunInfo.getJobId(), jobRunInfo.getName(), statusInfo.getStatus());
                if (statusInfo.getStatus().isTerminalState()) {
                    return statusInfo;
                }
            }
        } catch (Exception e) {
            if (++errorTimes > errorRetries) {
                return new CustomizeStatusInfo(ERROR, LocalDateTime.now(), LocalDateTime.now());
            }
        }
        sleep(++retryTimes);
    }
    return null;
}
Also used : CustomizeStatusInfo(com.flink.platform.web.monitor.CustomizeStatusInfo) HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) StatusInfo(com.flink.platform.web.monitor.StatusInfo) CustomizeStatusInfo(com.flink.platform.web.monitor.CustomizeStatusInfo) JobRunInfo(com.flink.platform.dao.entity.JobRunInfo)

Aggregations

JobRunInfo (com.flink.platform.dao.entity.JobRunInfo)1 CustomizeStatusInfo (com.flink.platform.web.monitor.CustomizeStatusInfo)1 StatusInfo (com.flink.platform.web.monitor.StatusInfo)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpHeaders (org.springframework.http.HttpHeaders)1