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;
}
Aggregations