Search in sources :

Example 1 with JobKillException

use of com.webank.wedatasphere.qualitis.exception.JobKillException 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)1 JobKillException (com.webank.wedatasphere.qualitis.exception.JobKillException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpHeaders (org.springframework.http.HttpHeaders)1