Example #1
0
 /**
  * Stream wf job log
  *
  * @param request servlet request
  * @param response servlet response
  * @throws XServletException
  * @throws IOException
  */
 private void streamWorkflowJobLog(HttpServletRequest request, HttpServletResponse response)
     throws XServletException, IOException {
   DagEngine dagEngine =
       Services.get()
           .get(DagEngineService.class)
           .getDagEngine(getUser(request), getAuthToken(request));
   String jobId = getResourceName(request);
   try {
     dagEngine.streamLog(jobId, response.getWriter());
   } catch (DagEngineException ex) {
     throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
   }
 }
Example #2
0
  /**
   * Rerun a wf job
   *
   * @param request servlet request
   * @param response servlet response
   * @param conf configuration object
   * @throws XServletException
   */
  private void reRunWorkflowJob(
      HttpServletRequest request, HttpServletResponse response, Configuration conf)
      throws XServletException {
    DagEngine dagEngine =
        Services.get()
            .get(DagEngineService.class)
            .getDagEngine(getUser(request), getAuthToken(request));

    String jobId = getResourceName(request);
    try {
      dagEngine.reRun(jobId, conf);
    } catch (DagEngineException ex) {
      throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
    }
  }
Example #3
0
  /**
   * Get wf job definition
   *
   * @param request servlet request
   * @param response servlet response
   * @return String wf definition
   * @throws XServletException
   */
  private String getWorkflowJobDefinition(HttpServletRequest request, HttpServletResponse response)
      throws XServletException {
    DagEngine dagEngine =
        Services.get()
            .get(DagEngineService.class)
            .getDagEngine(getUser(request), getAuthToken(request));

    String wfDefinition;
    String jobId = getResourceName(request);
    try {
      wfDefinition = dagEngine.getDefinition(jobId);
    } catch (DagEngineException ex) {
      throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
    }
    return wfDefinition;
  }
Example #4
0
  /**
   * Get wf action info
   *
   * @param request servlet request
   * @param response servlet response
   * @return JsonBean WorkflowActionBean
   * @throws XServletException
   */
  private JsonBean getWorkflowAction(HttpServletRequest request, HttpServletResponse response)
      throws XServletException {
    DagEngine dagEngine =
        Services.get()
            .get(DagEngineService.class)
            .getDagEngine(getUser(request), getAuthToken(request));

    JsonBean actionBean = null;
    String actionId = getResourceName(request);
    try {
      actionBean = dagEngine.getWorkflowAction(actionId);
    } catch (BaseEngineException ex) {
      throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
    }

    return actionBean;
  }
Example #5
0
  /**
   * Get workflow job
   *
   * @param request servlet request
   * @param response servlet response
   * @return JsonBean WorkflowJobBean
   * @throws XServletException
   */
  private JsonBean getWorkflowJob(HttpServletRequest request, HttpServletResponse response)
      throws XServletException {
    JsonBean jobBean = null;
    String jobId = getResourceName(request);
    String startStr = request.getParameter(RestConstants.OFFSET_PARAM);
    String lenStr = request.getParameter(RestConstants.LEN_PARAM);
    int start = (startStr != null) ? Integer.parseInt(startStr) : 1;
    start = (start < 1) ? 1 : start;
    int len = (lenStr != null) ? Integer.parseInt(lenStr) : 0;
    len = (len < 1) ? Integer.MAX_VALUE : len;
    DagEngine dagEngine =
        Services.get()
            .get(DagEngineService.class)
            .getDagEngine(getUser(request), getAuthToken(request));
    try {
      jobBean = (JsonBean) dagEngine.getJob(jobId, start, len);
    } catch (DagEngineException ex) {
      throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
    }

    return jobBean;
  }