@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;
  }
示例#2
0
 private Map getSubWorkflowVariables(Workflow wf) {
   try {
     return JsonUtils.unmarshal((StringUtils.unescape((String) wf.getVariable())));
   } catch (Exception ex) {
     throw new ServiceException("Unable to parse the workflow variables.", ex);
   }
 }
  @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;
  }
示例#4
0
  /** command line 명령어를 생성한다. */
  private String buildCommand(String working) {
    List<String> command = new LinkedList<>();

    try {
      Map<String, String> defaultEnvs = getDefaultEnvs(working);
      Set<String> keys = defaultEnvs.keySet();
      for (String key : keys) {
        if (!isEmpty(defaultEnvs.get(key))) {
          command.add(
              MessageFormatter.arrayFormat(
                      "export {}={}\n", new Object[] {key, defaultEnvs.get(key)})
                  .getMessage());
        }
      }

      command.add(getHelper().get("sqoop.home") + "/bin/sqoop");

      command.add("import");

      if (variable.get("jdbcUrl") != null
          && !StringUtils.isEmpty(variable.get("jdbcUrl").toString())) {
        command.add("--connect");
        command.add(variable.getProperty("jdbcUrl"));
      }

      if (variable.get("jdbcDriver") != null
          && !StringUtils.isEmpty(variable.get("jdbcDriver").toString())) {
        command.add("--driver");
        command.add(variable.getProperty("jdbcDriver"));
      }

      if (variable.get("sqoopTable") != null
          && !StringUtils.isEmpty(variable.get("sqoopTable").toString())) {
        command.add("--table");
        command.add(variable.getProperty("sqoopTable"));
      }

      if (variable.get("sqoopUsername") != null
          && !StringUtils.isEmpty(variable.get("sqoopUsername").toString())) {
        command.add("--username");
        command.add(variable.getProperty("sqoopUsername"));
      }

      if (variable.get("sqoopPassword") != null
          && !StringUtils.isEmpty(variable.get("sqoopPassword").toString())) {
        command.add("--password");
        command.add(variable.getProperty("sqoopPassword"));
      }

      if (variable.get("output") != null
          && !StringUtils.isEmpty(variable.get("output").toString())) {
        command.add("--target-dir");
        command.add(variable.getProperty("output"));
      }

      command.add("--num-mappers");
      command.add("1");
    } catch (Exception e) {
      throw new ServiceException("You can not create a Sqoop import command.", e);
    }

    return org.opencloudengine.flamingo2.util.StringUtils.listToDelimitedString(command, " ");
  }