Ejemplo n.º 1
0
 public RunController(int guid, Config config) {
   this.guid = guid;
   this.config = config;
   this.json = JsonHandler.createRunGson();
   this.props = config.getProperties();
   this.dataScript = config.getContextRootPath() + "/data";
 }
Ejemplo n.º 2
0
  // Run the Runtime Plan
  public void runExecutionPlan(RuntimePlan rplan, ServletContext context) {
    synchronized (WriteLock.Lock) {
      PlanExecutionEngine engine = config.getDomainExecutionEngine();
      engine.getExecutionLogger().setWriterLock(WriteLock.Lock);
      // "execute" below is an asynchronous call
      engine.execute(rplan);

      // Save the engine for an abort if needed
      context.setAttribute("plan_" + rplan.getID(), rplan);
      context.setAttribute("engine_" + rplan.getID(), engine);
    }
  }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
  public void show(PrintWriter out, String runid) {
    // Get Hierarchy
    try {
      out.println("<html>");
      out.println("<head>");
      out.println("<title>Access Run Results</title>");
      JSLoader.setContextInformation(out, config);
      CSSLoader.loadRunViewer(out, config.getContextRootPath());
      JSLoader.loadRunViewer(out, config.getContextRootPath());
      out.println("</head>");

      out.println("<script>");
      out.println("var runViewer_" + guid + ";");
      out.println(
          "Ext.onReady(function() {"
              + "runViewer_"
              + guid
              + " = new RunBrowser("
              + "'"
              + guid
              + "', '"
              + runid
              + "', "
              + "'"
              + config.getScriptPath()
              + "', "
              + "'"
              + this.dataScript
              + "' "
              + ");\n"
              + "runViewer_"
              + guid
              + ".initialize();\n"
              + "});");
      out.println("</script>");
      out.println("</html>");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
  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);
  }
Ejemplo n.º 7
0
 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);
 }