use of com.webank.wedatasphere.qualitis.exception.LogPartialException in project Qualitis by WeBankFinTech.
the class LinkisJobSubmitter method getJobPartialLog.
@Override
public LogResult getJobPartialLog(Long taskId, Integer begin, String user, String remoteAddress, String clusterName) throws LogPartialException, ClusterInfoNotConfigException {
Integer begin1 = 0;
String jobStatus = null;
String logPath = null;
String execId = null;
try {
Map response = getTaskDetail(taskId, user, remoteAddress, clusterName);
jobStatus = (String) ((Map) ((Map) response.get("data")).get("task")).get("status");
logPath = (String) ((Map) ((Map) response.get("data")).get("task")).get("logPath");
execId = (String) ((Map) ((Map) response.get("data")).get("task")).get("strongerExecId");
} catch (TaskNotExistException e) {
throw new LogPartialException(e);
}
String log = "";
if (isTaskRunning(jobStatus)) {
String url = getPath(remoteAddress).path(linkisConfig.getRunningLog()).toString();
url = url.replace("{id}", execId);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Token-User", user);
headers.add("Token-Code", getToken(clusterName));
HttpEntity entity = new HttpEntity<>(headers);
LOGGER.info("Start to get job log from linkis. url: {}, method: {}, body: {}", url, javax.ws.rs.HttpMethod.GET, entity);
Map response = restTemplate.exchange(url, HttpMethod.GET, entity, Map.class).getBody();
LOGGER.info("Succeed to get job log from linkis. repsonse: {}", response);
if (!checkResponse(response)) {
throw new LogPartialException("Failed to get partial logs, task ID: " + taskId);
}
log = (String) ((List) ((Map) response.get("data")).get("log")).get(3);
} else {
String url = getPath(remoteAddress).path(linkisConfig.getFinishLog()).toString() + "?path=" + logPath;
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Token-User", user);
headers.add("Token-Code", getToken(clusterName));
HttpEntity entity = new HttpEntity<>(headers);
LOGGER.info("Start to get job log from linkis. url: {}, method: {}, body: {}", url, javax.ws.rs.HttpMethod.GET, entity);
Map response = restTemplate.exchange(url, HttpMethod.GET, entity, Map.class).getBody();
LOGGER.info("Succeed to get job log from linkis. repsonse: {}", response);
if (!checkResponse(response)) {
throw new LogPartialException("Failed to get partial logs, task ID: " + taskId);
}
log = (String) ((List) ((Map) response.get("data")).get("log")).get(3);
}
// 将账号敏感信息脱敏替换成 ******
log = maskAccountInfo(log);
Integer end = getEnd(log) + begin1;
return new LogResult(log, begin1, end, getLast(log));
}
use of com.webank.wedatasphere.qualitis.exception.LogPartialException in project Qualitis by WeBankFinTech.
the class OuterExecutionServiceImpl method getTaskLog.
@Override
public GeneralResponse<?> getTaskLog(GetTaskLogRequest request) throws UnExpectedRequestException, PermissionDeniedRequestException {
// Check Arguments
GetTaskLogRequest.checkRequest(request);
Task task = taskDao.findByRemoteTaskIdAndClusterName(request.getTaskId(), request.getClusterId());
if (task == null) {
throw new UnExpectedRequestException("Task_id {&DOES_NOT_EXIST}");
}
ClusterInfo clusterInfo = clusterInfoDao.findByClusterName(request.getClusterId());
if (clusterInfo == null) {
throw new UnExpectedRequestException("cluster : [" + request.getClusterId() + "] {&DOES_NOT_EXIST}");
}
String executeUser = task.getApplication().getExecuteUser();
// Check if user has permissions proxying execution user
checkPermissionCreateUserProxyExecuteUser(request.getCreateUser(), executeUser);
// Check if user has permissions to view this task
if (!request.getCreateUser().equals(task.getApplication().getCreateUser())) {
throw new UnExpectedRequestException(String.format("User: %s {&HAS_NO_PERMISSION_TO_ACCESS} task: %s", request.getCreateUser(), request.getTaskId()), 403);
}
LogResult logResult;
try {
logResult = monitorManager.getTaskPartialLog(request.getTaskId(), 0, executeUser, clusterInfo.getLinkisAddress(), clusterInfo.getClusterName());
} catch (LogPartialException | ClusterInfoNotConfigException e) {
throw new UnExpectedRequestException(e.getMessage());
}
LOGGER.info("Succeed to get log of the task. task_id: {}, cluster_id: {}", request.getTaskId(), request.getClusterId());
return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_TASK_LOG}", logResult.getLog());
}
use of com.webank.wedatasphere.qualitis.exception.LogPartialException in project Qualitis by WeBankFinTech.
the class JobServiceImpl method getTaskLog.
@Override
public GeneralResponse<?> getTaskLog(Long taskId, String clusterName) throws UnExpectedRequestException {
Task task = taskDao.findById(taskId);
if (task == null) {
throw new UnExpectedRequestException("{&JOB_ID_DOES_NOT_EXIST}");
}
ClusterInfo clusterInfo = clusterInfoDao.findByClusterName(clusterName);
if (clusterInfo == null) {
throw new UnExpectedRequestException("Cluster info {&DOES_NOT_EXIST}");
}
LogResult logResult;
String proxyUser = task.getTaskProxyUser();
try {
logResult = monitorManager.getTaskPartialLog(task.getTaskRemoteId(), 0, StringUtils.isNotBlank(proxyUser) ? proxyUser : task.getApplication().getExecuteUser(), clusterInfo.getLinkisAddress(), clusterName);
} catch (LogPartialException | ClusterInfoNotConfigException e) {
throw new UnExpectedRequestException(e.getMessage());
}
LOGGER.info("Succeed to get task log, task_id: {}, cluster_id: {}", taskId, clusterName);
return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_TASK_LOG}", logResult.getLog());
}
Aggregations