@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 = "script", method = RequestMethod.GET)
 @ResponseStatus(HttpStatus.OK)
 @ResponseBody
 public Response getScript(
     @RequestParam(defaultValue = "") String clusterName,
     @RequestParam(defaultValue = "") String identifier,
     @RequestParam(defaultValue = "") String taskId) {
   Response response = new Response();
   EngineService engineService = getEngineService(clusterName);
   TaskHistoryRemoteService taskHistoryRemoteService = engineService.getTaskHistoryRemoteService();
   String script = taskHistoryRemoteService.getScript(identifier, taskId);
   response.setObject(script);
   response.setSuccess(true);
   return response;
 }
 @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;
 }
  @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;
  }
  @RequestMapping(value = "logs", method = RequestMethod.GET)
  @ResponseStatus(HttpStatus.OK)
  @ResponseBody
  public Response getLogs(
      @RequestParam(defaultValue = "") String clusterName,
      @RequestParam(defaultValue = "") String identifier,
      @RequestParam(defaultValue = "") String taskId,
      @RequestParam(defaultValue = "") String tabConditionKey) {
    Response response = new Response();
    EngineService engineService = getEngineService(clusterName);
    TaskHistoryRemoteService taskHistoryRemoteService = engineService.getTaskHistoryRemoteService();

    String log;
    String script;
    String command;
    String error;
    Map<String, Object> map = new HashMap<>();

    switch (tabConditionKey) {
      case "log":
        log = taskHistoryRemoteService.getTaskLog(identifier, taskId);
        map.put("log", log);
        break;
      case "script":
        script = taskHistoryRemoteService.getScript(identifier, taskId);
        map.put("script", script);
        break;
      case "command":
        command = taskHistoryRemoteService.getCommand(identifier, taskId);
        map.put("command", command);
        break;
      case "error":
        error = taskHistoryRemoteService.getError(identifier, taskId);
        map.put("error", error);
        break;
    }

    response.getMap().putAll(map);
    response.setSuccess(true);
    return response;
  }