Package org.apache.oodt.cas.workflow.lifecycle

Examples of org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycle


  public void execute(final TaskProcessor taskProcessor) throws Exception {
    Thread worker = new Thread() {

      @Override
      public void run() {
        WorkflowLifecycle lifecycle = getLifecycle(taskProcessor);
        WorkflowTask workflowTask = getTaskFromProcessor(taskProcessor);
        WorkflowTaskInstance inst = GenericWorkflowObjectFactory
            .getTaskObjectFromClassName(workflowTask.getTaskInstanceClassName());
        try {
          inst.run(taskProcessor.getWorkflowInstance().getSharedContext(),
              workflowTask.getTaskConfig());
          String msg = "Task: [" + workflowTask.getTaskName()
              + "] for instance id: ["
              + taskProcessor.getWorkflowInstance().getId()
              + "] completed successfully";
          LOG.log(Level.INFO, msg);
          WorkflowState state = lifecycle.createState("ExecutionComplete", "transition", msg);
          taskProcessor.getWorkflowInstance().setState(state);
          persist(taskProcessor.getWorkflowInstance());
        } catch (Exception e) {
          e.printStackTrace();
          String msg = "Exception executing task: ["
              + workflowTask.getTaskName() + "]: Message: " + e.getMessage();
          LOG.log(Level.WARNING, msg);
          WorkflowState state = lifecycle.createState("Failure", "done", msg);
          taskProcessor.getWorkflowInstance().setState(state);
          persist(taskProcessor.getWorkflowInstance());
        }

      }
View Full Code Here


      for (WorkflowProcessor processor : processors) {
        // OK now get its lifecycle
        WorkflowProcessorHelper helper = new WorkflowProcessorHelper(
            processor.getLifecycleManager());
        WorkflowLifecycle lifecycle = helper
            .getLifecycleForProcessor(processor);

        LOG.log(Level.FINE, "TaskQuerier: dispositioning processor with id: ["
            + processor.getWorkflowInstance().getId() + "]: state: "
            + processor.getWorkflowInstance().getState());

        if (!processor.isAnyCategory("done", "holding")
            && !processor.isAnyState("Executing")
            && processor.getRunnableWorkflowProcessors().size() > 0) {
          for (TaskProcessor tp : processor.getRunnableWorkflowProcessors()) {
            WorkflowState state = lifecycle.createState("WaitingOnResources",
                "waiting", "Added to Runnable queue");
            tp.getWorkflowInstance().setState(state);
            persist(tp.getWorkflowInstance());
            LOG.log(Level.INFO, "Added processor with priority: ["
                + tp.getWorkflowInstance().getPriority() + "]");
View Full Code Here

    inst.setStartDate(Calendar.getInstance().getTime());
    inst.setCurrentTaskId(workflow.getTasks().get(0).getTaskId());
    inst.setSharedContext(metadata);
    inst.setPriority(Priority.getDefault()); // FIXME: this should be sensed or
                                             // passed in
    WorkflowLifecycle cycle = getLifecycleForWorkflow(workflow);
    WorkflowState state = cycle.createState("Null", "initial",
        "Workflow created by Engine.");
    inst.setState(state);
    persist(inst);
    return inst;
  }
View Full Code Here

      ParentChildWorkflow model, boolean isCondition,
      Map<String, Class<? extends WorkflowProcessor>> modelToProcessorMap)
      throws Exception {
    WorkflowProcessor wp = modelToProcessorMap.get(
        model.getGraph().getExecutionType()).newInstance();
    WorkflowLifecycle wLifecycle = getLifecycle(model);
    // FIXME: I'm not sure what these excused processor Ids are. I didn't seem
    // need them in the PackagedWorkflowRepository, so not sure what they do.
    // wp.setExcusedSubProcessorIds(model.getGraph().getExcusedSubProcessorIds());
    wp.getWorkflowInstance().setId(instanceId);
    if (model.getPreConditions() != null)
      wp.setPreConditions(buildProcessor(instanceId, model,
          modelToProcessorMap, true));
    if (model.getPostConditions() != null)
      wp.setPostConditions(buildProcessor(instanceId, model,
          modelToProcessorMap, false));
    wp.getWorkflowInstance().setPriority(Priority.getDefault());
    wp.setMinReqSuccessfulSubProcessors(Integer.parseInt(model.getGraph()
        .getMinReqSuccessfulSubProcessors()));
    wp.getWorkflowInstance().setSharedContext(new Metadata());
    wp.getWorkflowInstance().setState(
        wLifecycle.createState("Loaded",
            wLifecycle.getStageForWorkflow("Loaded").getName(), ""));
    if (wp instanceof TaskProcessor)
      ((TaskProcessor) wp)
          .setInstanceClass((Class<? extends WorkflowTaskInstance>) Class
              .forName(model.getGraph().getTask().getTaskInstanceClassName()));
    return wp;
View Full Code Here

      List<WorkflowProcessor> processors = processorQueue.getProcessors();
      List<WorkflowProcessor> processorsToRun = new Vector<WorkflowProcessor>();

      for (WorkflowProcessor processor : processors) {
        // OK now get its lifecycle
        WorkflowLifecycle lifecycle = getLifecycleForProcessor(processor);
        if (!(processor.getState().getCategory().getName().equals("done") || processor
            .getState().getCategory().getName().equals("holding"))) {
            for (TaskProcessor tp : processor.getRunnableWorkflowProcessors()) {
              tp.setState(lifecycle.createState("Executing", "running",
                  "Added to Runnable queue"));
              System.out.println("Added processor with priority: ["+tp.getPriority()+"]");
              processorsToRun.add(processor);
            }
           
View Full Code Here

      ParentChildWorkflow model, boolean isCondition,
      Map<String, Class<? extends WorkflowProcessor>> modelToProcessorMap)
      throws Exception {
    WorkflowProcessor wp = modelToProcessorMap.get(
        model.getGraph().getExecutionType()).newInstance();
    WorkflowLifecycle wLifecycle = lifecycle.getLifecycleForWorkflow(model) != null ? lifecycle
        .getLifecycleForWorkflow(model) : lifecycle.getDefaultLifecycle();
    // FIXME: I'm not sure what these excused processor Ids are. I didn't seem
    // need them in the PackagedWorkflowRepository, so not sure what they do.
    // wp.setExcusedSubProcessorIds(model.getGraph().getExcusedSubProcessorIds());
    wp.getWorkflowInstance().setId(instanceId);
    wp.setConditionProcessor(isCondition);
    wp.setExecutionType(model.getGraph().getExecutionType());
    if (model.getPreConditions() != null)
      wp.setPreConditions(buildProcessor(instanceId, model,
          modelToProcessorMap, true));
    if (model.getPostConditions() != null)
      wp.setPostConditions(buildProcessor(instanceId, model,
          modelToProcessorMap, false));
    wp.setPriority(Priority.getDefault());
    wp.setMinReqSuccessfulSubProcessors(Integer.parseInt(model.getGraph()
        .getMinReqSuccessfulSubProcessors()));
    wp.setStaticMetadata(new Metadata());
    wp.setState(wLifecycle.createState("Loaded", wLifecycle
        .getStageForWorkflow("Loaded").getName(), ""));
    if (wp instanceof TaskProcessor)
      ((TaskProcessor) wp)
          .setInstanceClass((Class<? extends WorkflowTaskInstance>) Class
              .forName(model.getGraph().getTask().getTaskInstanceClassName()));
View Full Code Here

  }

  public void validateWorkflowProcessor(WorkflowProcessor wp) {
    if (wp instanceof TaskProcessor) {
      WorkflowState state = wp.getState();
      WorkflowLifecycle lc = this.lifecycle.getLifecycleForWorkflow(wp
          .getWorkflowInstance().getWorkflow());
      if (lc == null)
        lc = this.lifecycle.getDefaultLifecycle();
      if ((state.getName().equals("WaitingOnResources") && state.getPrevState()
          .getName().equals("Executing"))
          || state.getName().equals("Executing"))
        wp.setState(lc.createState("Queued", "waiting",
            "Marked back to queued state because of system failure"));
      else
        wp.setState(state);
    } else {
      if (wp.getPreConditions() != null)
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.