@RequestMapping(value = "/task/log", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public Response getTaskLog( @RequestParam(defaultValue = "") String clusterName, @RequestParam(defaultValue = "") Long id) { EngineService engineService = getEngineService(clusterName); Response response = new Response(); try { TaskHistory taskHistories = engineService.getTaskHistoryRemoteService().select(id); String filename = null; String task = taskHistories.getLogDirectory() + "/task.log"; if (new File(task).exists() && new File(task).length() == 0) { String err = taskHistories.getLogDirectory() + "/err.log"; if (new File(err).exists()) { filename = err; } } else { filename = task; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); FileUtils.copyFile(new File(filename), baos); response.getMap().put("text", new String(baos.toByteArray())); response.setSuccess(true); } catch (Exception ex) { // FIXME 여기 WholeBodyException을 수정해야하지 않을까?? response.setSuccess(false); response.getError().setMessage("Unable to load a log file."); response.getError().setException(ExceptionUtils.getFullStackTrace(ex)); if (ex.getCause() != null) response.getError().setCause(ex.getCause().getMessage()); } return response; }
private WorkflowHistory getSubflow( TaskHistory taskHistory, List<WorkflowHistory> workflowHistories) { String taskId = taskHistory.getTaskId(); for (WorkflowHistory workflowHistory : workflowHistories) { if (workflowHistory != null && workflowHistory.getSf_taskId().equals(taskId)) return workflowHistory; } return null; }
@RequestMapping(value = "/task/get", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody public Response getTask( @RequestParam(defaultValue = "") String clusterName, @RequestParam(defaultValue = "") String identifier, @RequestParam(defaultValue = "") String taskId) { Response response = new Response(); EngineService engineService = getEngineService(clusterName); TaskHistoryRemoteService taskHistoryRemoteService = engineService.getTaskHistoryRemoteService(); TaskHistory history = new TaskHistory(); history.setIdentifier(identifier); history.setTaskId(taskId); TaskHistory taskHistory = taskHistoryRemoteService.selectByTaskIdAndIdentifier(history); response.setObject(taskHistory); response.setSuccess(true); return response; }
private Map getNodeForTask(TaskHistory taskHistory, String node) { Map<String, Object> map = new HashMap<>(); map.put("id", node + "/" + taskHistory.getTaskId()); map.put("rowid", taskHistory.getId()); map.put("taskId", taskHistory.getTaskId()); map.put("identifier", taskHistory.getIdentifier()); map.put("status", taskHistory.getStatus()); map.put("cls", ""); map.put("iconCls", "x-tree-noicon"); map.put("text", taskHistory.getName()); map.put("leaf", true); map.put("type", "task"); return map; }