public boolean stopRun(String runid, ServletContext context) { ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); if (monitor.getRunDetails(runid).getRuntimeInfo().getStatus() == RuntimeInfo.Status.RUNNING) { PlanExecutionEngine engine = (PlanExecutionEngine) context.getAttribute("engine_" + runid); RuntimePlan rplan = (RuntimePlan) context.getAttribute("plan_" + runid); if (engine != null && rplan != null) { engine.abort(rplan); return true; } } return false; }
public String getRunJSON(String runid) { ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); RuntimePlan plan = monitor.getRunDetails(runid); if (plan.getPlan() != null) { for (ExecutionStep step : plan.getPlan().getAllExecutionSteps()) { for (ExecutionFile file : step.getInputFiles()) { file.loadMetadataFromLocation(); } for (ExecutionFile file : step.getOutputFiles()) { file.loadMetadataFromLocation(); } } } return json.toJson(plan); }
public String deleteRun(String rjson, ServletContext context) { HashMap<String, Object> ret = new HashMap<String, Object>(); ret.put("success", false); JsonElement el = new JsonParser().parse(rjson); if (el == null) return json.toJson(ret); String runid = el.getAsJsonObject().get("id").getAsString(); ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); if (monitor.runExists(runid)) { this.stopRun(runid, context); if (!monitor.deleteRun(runid)) return json.toJson(ret); } ret.put("success", true); return json.toJson(ret); }
public String getRunListJSON() { ExecutionMonitorAPI monitor = config.getDomainExecutionMonitor(); ArrayList<Object> list = new ArrayList<Object>(); for (RuntimePlan exe : monitor.getRunList()) { HashMap<String, Object> map = new HashMap<String, Object>(); map.put("runtimeInfo", exe.getRuntimeInfo()); map.put("id", exe.getID()); if (exe.getQueue() != null) { int numtotal = exe.getQueue().getAllSteps().size(); int numdone = exe.getQueue().getFinishedSteps().size(); ArrayList<RuntimeStep> running_steps = exe.getQueue().getRunningSteps(); ArrayList<RuntimeStep> failed_steps = exe.getQueue().getFailedSteps(); map.put("running_jobs", this.getStepIds(running_steps)); map.put("failed_jobs", this.getStepIds(failed_steps)); map.put("percent_done", numdone * 100.0 / numtotal); map.put("percent_running", running_steps.size() * 100.0 / numtotal); map.put("percent_failed", failed_steps.size() * 100.0 / numtotal); } list.add(map); } return json.toJson(list); }