Search in sources :

Example 1 with JobKillResult

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());
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) Task(com.webank.wedatasphere.qualitis.entity.Task) DataQualityTask(com.webank.wedatasphere.qualitis.bean.DataQualityTask) ClusterInfo(com.webank.wedatasphere.qualitis.entity.ClusterInfo) JobKillResult(com.webank.wedatasphere.qualitis.bean.JobKillResult) ArrayList(java.util.ArrayList) Date(java.util.Date) ClusterInfoNotConfigException(com.webank.wedatasphere.qualitis.exception.ClusterInfoNotConfigException)

Example 2 with JobKillResult

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);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) JobKillResult(com.webank.wedatasphere.qualitis.bean.JobKillResult) HttpEntity(org.springframework.http.HttpEntity) JobKillException(com.webank.wedatasphere.qualitis.exception.JobKillException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

JobKillResult (com.webank.wedatasphere.qualitis.bean.JobKillResult)2 DataQualityTask (com.webank.wedatasphere.qualitis.bean.DataQualityTask)1 ClusterInfo (com.webank.wedatasphere.qualitis.entity.ClusterInfo)1 Task (com.webank.wedatasphere.qualitis.entity.Task)1 ClusterInfoNotConfigException (com.webank.wedatasphere.qualitis.exception.ClusterInfoNotConfigException)1 JobKillException (com.webank.wedatasphere.qualitis.exception.JobKillException)1 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)1 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpHeaders (org.springframework.http.HttpHeaders)1