@RequestMapping(value = "mrId", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody public Response mrId( @RequestParam(defaultValue = "") String clusterName, @RequestParam(defaultValue = "") String identifier, @RequestParam(defaultValue = "") String type) { Response response = new Response(); EngineService engineService = getEngineService(clusterName); // FIXME type이 workflow일 경우 처리 if ("task".equals(type)) { TaskHistoryRemoteService taskHistoryRemoteService = engineService.getTaskHistoryRemoteService(); List<TaskHistory> taskHistory = taskHistoryRemoteService.selectByIdentifier(identifier); String[] idList = engineService .getDesignerRemoteService() .idList(taskHistory.get(0).getLogDirectory(), "hadoop."); if (idList != null && idList.length > 0) { for (String file : idList) { if (file.startsWith("hadoop.")) { Map<String, String> map = new HashMap<>(); map.put("id", StringUtils.removePrefix(file, "hadoop.", true)); response.getList().add(map); } } } } response.setSuccess(true); return response; }
@RequestMapping(value = "kill", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @ResponseBody public Response jobKill( @RequestParam(defaultValue = "") String clusterName, @RequestParam(defaultValue = "") String identifier, @RequestParam(defaultValue = "") String type) { Response response = new Response(); EngineConfig engineConfig = getEngineConfig(clusterName); EngineService engineService = getEngineService(clusterName); // FIXME type이 workflow일 경우 처리 if ("task".equals(type)) { TaskHistoryRemoteService taskHistoryRemoteService = engineService.getTaskHistoryRemoteService(); List<TaskHistory> taskHistory = taskHistoryRemoteService.selectByIdentifier(identifier); String[] idList = engineService .getDesignerRemoteService() .idList(taskHistory.get(0).getLogDirectory(), "app."); // applicationId가 없으면 워크플로우를 하둡에 던지기 전이고 또한 java, python, r 등의 모듈이라고 볼 수 있다. 따라서 RUNNIG 중인 // 프로세스를 킬할 수 있다. if (idList != null && idList.length > 0) { for (String file : idList) { if (file.startsWith("app.")) { ResourceManagerRemoteService service = engineService.getResourceManagerRemoteService(); service.killApplication(StringUtils.removePrefix(file, "app.", true), engineConfig); taskHistory.get(0).setStatus(State.FAILED.toString()); taskHistoryRemoteService.updateByTaskIdAndIdentifier(taskHistory.get(0)); } } } else if ("RUNNING".equals(taskHistory.get(0).getStatus())) { engineService.getDesignerRemoteService().killProccess(taskHistory.get(0).getLogDirectory()); taskHistory.get(0).setStatus(State.FAILED.toString()); taskHistoryRemoteService.updateByTaskIdAndIdentifier(taskHistory.get(0)); } } response.setSuccess(true); return response; }