Beispiel #1
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);
    }
  }
Beispiel #2
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);
 }
Beispiel #3
0
  public String runExpandedTemplate(
      String origtplid,
      String templatejson,
      String consjson,
      String seedjson,
      String seedconsjson,
      ServletContext context) {
    Gson json = JsonHandler.createTemplateGson();
    Template xtpl = JsonHandler.getTemplateFromJSON(json, templatejson, consjson);
    Template seedtpl = JsonHandler.getTemplateFromJSON(json, seedjson, seedconsjson);

    String requestid = UuidGen.generateAUuid("");
    WorkflowGenerationAPI wg =
        new WorkflowGenerationKB(
            props,
            DataFactory.getReasoningAPI(props),
            ComponentFactory.getReasoningAPI(props),
            ResourceFactory.getAPI(props),
            requestid);
    ExecutionPlan plan = wg.getExecutionPlan(xtpl);

    if (plan != null) {
      synchronized (WriteLock.Lock) {
        // Save the expanded template, seeded template and plan
        if (!xtpl.save()) return "";
        if (!seedtpl.save()) return "";
        plan.save();
      }
      RuntimePlan rplan = new RuntimePlan(plan);
      rplan.setExpandedTemplateID(xtpl.getID());
      rplan.setOriginalTemplateID(origtplid);
      rplan.setSeededTemplateId(seedtpl.getID());
      this.runExecutionPlan(rplan, context);
      return rplan.getID();
    }
    return "";
  }