use of com.webank.wedatasphere.qualitis.bean.JobKillResult in project Qualitis by WeBankFinTech.
the class ExecutionManagerImpl method killApplication.
@Override
public GeneralResponse<?> killApplication(Application applicationInDb, String user) throws JobKillException, UnExpectedRequestException, ClusterInfoNotConfigException {
List<Task> tasks = taskDao.findByApplication(applicationInDb);
List<JobKillResult> results = new ArrayList<>();
if (tasks == null || tasks.isEmpty()) {
throw new UnExpectedRequestException("Sub tasks {&CAN_NOT_BE_NULL_OR_EMPTY}");
}
for (Task task : tasks) {
ClusterInfo clusterInfo = clusterInfoDao.findByClusterName(task.getClusterName());
if (clusterInfo == null) {
throw new ClusterInfoNotConfigException("Failed to find cluster id: " + task.getClusterName() + " configuration");
}
results.add(abstractJobSubmitter.killJob(user, clusterInfo.getClusterName(), task));
task.setStatus(TaskStatusEnum.CANCELLED.getCode());
task.setEndTime(ExecutionManagerImpl.PRINT_TIME_FORMAT.format(new Date()));
taskDao.save(task);
}
return new GeneralResponse<>("200", "{&SUCCESS_TO_KILL_TASK}", results.size());
}
use of com.webank.wedatasphere.qualitis.bean.JobKillResult in project Qualitis by WeBankFinTech.
the class LinkisJobSubmitter method killJob.
@Override
public JobKillResult killJob(String user, String clusterName, Task task) throws ClusterInfoNotConfigException, JobKillException {
String url = getPath(task.getSubmitAddress()).path(linkisConfig.getKillJob()).path(task.getTaskExecId()).path("kill").queryParam("taskID", task.getTaskRemoteId()).toString();
LOGGER.info("Finish to construct kill job url. Url: {}", url);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Token-User", user);
headers.add("Token-Code", getToken(clusterName));
HttpEntity<Object> entity = new HttpEntity<>(headers);
LOGGER.info("Start to kill job to linkis. url: {}, method: {}", url, javax.ws.rs.HttpMethod.GET);
Map response = restTemplate.exchange(url, HttpMethod.GET, entity, Map.class).getBody();
LOGGER.info("Succeed to kill job to linkis. response: {}", response);
if (!checkResponse(response)) {
String message = (String) response.get("message");
throw new JobKillException("{&FAILED_TO_KILL_TO_LINKIS}. Exception: " + message);
}
String message = (String) response.get("message");
return new JobKillResult(message);
}
Aggregations