private void handleFetchLogEvent( int execId, HttpServletRequest req, HttpServletResponse resp, Map<String, Object> respMap) throws ServletException { String type = getParam(req, "type"); int startByte = getIntParam(req, "offset"); int length = getIntParam(req, "length"); resp.setContentType("text/plain"); resp.setCharacterEncoding("utf-8"); if (type.equals("flow")) { LogData result; try { result = flowRunnerManager.readFlowLogs(execId, startByte, length); respMap.putAll(result.toObject()); } catch (Exception e) { logger.error(e); respMap.put(RESPONSE_ERROR, e.getMessage()); } } else { int attempt = getIntParam(req, "attempt", 0); String jobId = getParam(req, "jobId"); try { LogData result = flowRunnerManager.readJobLogs(execId, jobId, attempt, startByte, length); respMap.putAll(result.toObject()); } catch (Exception e) { logger.error(e); respMap.put("error", e.getMessage()); } } }
@SuppressWarnings("unchecked") private void handleAjaxUpdateRequest(HttpServletRequest req, Map<String, Object> respMap) throws ServletException, IOException { ArrayList<Object> updateTimesList = (ArrayList<Object>) JSONUtils.parseJSONFromString(getParam(req, UPDATE_TIME_LIST_PARAM)); ArrayList<Object> execIDList = (ArrayList<Object>) JSONUtils.parseJSONFromString(getParam(req, EXEC_ID_LIST_PARAM)); ArrayList<Object> updateList = new ArrayList<Object>(); for (int i = 0; i < execIDList.size(); ++i) { long updateTime = JSONUtils.getLongFromObject(updateTimesList.get(i)); int execId = (Integer) execIDList.get(i); ExecutableFlow flow = flowRunnerManager.getExecutableFlow(execId); if (flow == null) { Map<String, Object> errorResponse = new HashMap<String, Object>(); errorResponse.put(RESPONSE_ERROR, "Flow does not exist"); errorResponse.put(UPDATE_MAP_EXEC_ID, execId); updateList.add(errorResponse); continue; } if (flow.getUpdateTime() > updateTime) { updateList.add(flow.toUpdateObject(updateTime)); } } respMap.put(RESPONSE_UPDATED_FLOWS, updateList); }
private void handleModifyExecutionRequest( Map<String, Object> respMap, int execId, String user, HttpServletRequest req) throws ServletException { if (!hasParam(req, MODIFY_EXECUTION_ACTION_TYPE)) { respMap.put(RESPONSE_ERROR, "Modification type not set."); } String modificationType = getParam(req, MODIFY_EXECUTION_ACTION_TYPE); String modifiedJobList = getParam(req, MODIFY_JOBS_LIST); String[] jobIds = modifiedJobList.split("\\s*,\\s*"); try { if (MODIFY_RETRY_JOBS.equals(modificationType)) { flowRunnerManager.retryJobs(execId, user, jobIds); } else if (MODIFY_CANCEL_JOBS.equals(modificationType)) { } else if (MODIFY_DISABLE_JOBS.equals(modificationType)) { } else if (MODIFY_ENABLE_JOBS.equals(modificationType)) { } else if (MODIFY_PAUSE_JOBS.equals(modificationType)) { } else if (MODIFY_RESUME_JOBS.equals(modificationType)) { } } catch (ExecutorManagerException e) { logger.error(e); respMap.put("error", e.getMessage()); } }
private void handleAjaxFlowStatus(Map<String, Object> respMap, int execid) { ExecutableFlow flow = flowRunnerManager.getExecutableFlow(execid); if (flow == null) { respMap.put(STATUS_PARAM, RESPONSE_NOTFOUND); } else { respMap.put(STATUS_PARAM, flow.getStatus().toString()); respMap.put(RESPONSE_UPDATETIME, flow.getUpdateTime()); } }
private void handleAjaxExecute(HttpServletRequest req, Map<String, Object> respMap, int execId) throws ServletException { try { flowRunnerManager.submitFlow(execId); } catch (ExecutorManagerException e) { e.printStackTrace(); logger.error(e); respMap.put(RESPONSE_ERROR, e.getMessage()); } }
private void handleAjaxCancel(Map<String, Object> respMap, int execid, String user) throws ServletException { if (user == null) { respMap.put(RESPONSE_ERROR, "user has not been set"); return; } try { flowRunnerManager.cancelFlow(execid, user); respMap.put(STATUS_PARAM, RESPONSE_SUCCESS); } catch (ExecutorManagerException e) { logger.error(e); respMap.put(RESPONSE_ERROR, e.getMessage()); } }