You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2012/04/14 18:29:38 UTC
svn commit: r1326140 - in /oodt/trunk/workflow/src/main:
java/org/apache/oodt/cas/workflow/engine/
java/org/apache/oodt/cas/workflow/lifecycle/
java/org/apache/oodt/cas/workflow/structs/ resources/examples/
resources/examples/wengine/
Author: mattmann
Date: Sat Apr 14 16:29:37 2012
New Revision: 1326140
URL: http://svn.apache.org/viewvc?rev=1326140&view=rev
Log:
OODT-215 and OODT-310 WIP: Workflow2 Engine Updates and Lifecycle updates.
Modified:
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/PrioritizedQueueBasedWorkflowEngine.java
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/SynchronousLocalEngineRunner.java
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecycle.java
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecycleStage.java
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecyclesReader.java
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Graph.java
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/ParentChildWorkflow.java
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Workflow.java
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java
oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowTask.java
oodt/trunk/workflow/src/main/resources/examples/wengine/wengine-lifecycle.xml
oodt/trunk/workflow/src/main/resources/examples/workflow-lifecycle.xml
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/PrioritizedQueueBasedWorkflowEngine.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/PrioritizedQueueBasedWorkflowEngine.java?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/PrioritizedQueueBasedWorkflowEngine.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/PrioritizedQueueBasedWorkflowEngine.java Sat Apr 14 16:29:37 2012
@@ -18,13 +18,18 @@
package org.apache.oodt.cas.workflow.engine;
import java.net.URL;
+import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.UUID;
import java.util.Vector;
+import java.util.logging.Logger;
import org.apache.oodt.cas.metadata.Metadata;
import org.apache.oodt.cas.workflow.instrepo.WorkflowInstanceRepository;
+import org.apache.oodt.cas.workflow.structs.HighestFIFOPrioritySorter;
import org.apache.oodt.cas.workflow.structs.PrioritySorter;
import org.apache.oodt.cas.workflow.structs.Workflow;
import org.apache.oodt.cas.workflow.structs.WorkflowInstance;
@@ -37,33 +42,58 @@ import org.apache.oodt.commons.util.Date
*
* Describe your class here.
*
+ * @author bfoster
* @author mattmann
* @version $Revision$
*
*/
public class PrioritizedQueueBasedWorkflowEngine implements WorkflowEngine {
- private WorkflowInstanceRepository repo;
- private PrioritySorter prioritizer;
-
- private URL wmgrUrl;
+ private static final Logger LOG = Logger.getLogger(PrioritizedQueueBasedWorkflowEngine.class.getName());
+ private Map<String, WorkflowPro> processorQueue;
+ private List<WorkflowProcessor> runnableTasks;
+ private Map<String, WorkflowProcessor> executingTasks;
+ private WorkflowProcessorLock processorLock;
+ private List<String> metadataKeysToCache;
+ private boolean debugMode;
+ private boolean allowQueuerToWork;
+ private Thread queuerThread;
+ private WorkflowInstanceRepository repo;
+ private PrioritySorter prioritizer;
+ private URL wmgrUrl;
private long conditionWait;
public PrioritizedQueueBasedWorkflowEngine(WorkflowInstanceRepository repo, PrioritySorter prioritizer, long conditionWait){
this.repo = repo;
- this.prioritizer = prioritizer;
+ this.prioritizer = prioritizer != null ? new HighestFIFOPrioritySorter(secondsBetweenBoosts, boostAmount, boostCap):
+ prioritizer;
this.wmgrUrl = null;
this.conditionWait = conditionWait;
+ this.processorQueue = Collections.synchronizedMap(new HashMap<String, CachedWorkflowProcessor>());
+ this.runnableTasks = new Vector<WorkflowProcessor>();
+ this.executingTasks = Collections.synchronizedMap(new HashMap<String, WorkflowProcessor>());
+ this.processorLock = new WorkflowProcessorLock();
+ if (metadataKeysToCache != null)
+ this.metadataKeysToCache = new Vector<String>(metadataKeysToCache);
+ this.debugMode = debugMode;
+ this.allowQueuerToWork = true;
+
+ try {
+ this.loadProcessorRepo();
+ }catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Task QUEUER thread
+ queuerThread = new Thread(new TaskQuerier());
+ queuerThread.start();
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.oodt.cas.workflow.engine.WorkflowEngine#startWorkflow(org.apache
- * .oodt.cas.workflow.structs.Workflow, org.apache.oodt.cas.metadata.Metadata)
+
+ /* (non-Javadoc)
+ * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#startWorkflow(org.apache.oodt.cas.workflow.structs.Workflow, org.apache.oodt.cas.metadata.Metadata)
*/
@Override
public WorkflowInstance startWorkflow(Workflow workflow, Metadata metadata)
@@ -72,50 +102,35 @@ public class PrioritizedQueueBasedWorkfl
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.oodt.cas.workflow.engine.WorkflowEngine#stopWorkflow(java.lang
- * .String)
+ /* (non-Javadoc)
+ * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#stopWorkflow(java.lang.String)
*/
@Override
public void stopWorkflow(String workflowInstId) {
// TODO Auto-generated method stub
-
+
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.oodt.cas.workflow.engine.WorkflowEngine#pauseWorkflowInstance
- * (java.lang.String)
+ /* (non-Javadoc)
+ * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#pauseWorkflowInstance(java.lang.String)
*/
@Override
public void pauseWorkflowInstance(String workflowInstId) {
// TODO Auto-generated method stub
-
+
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.oodt.cas.workflow.engine.WorkflowEngine#resumeWorkflowInstance
- * (java.lang.String)
+ /* (non-Javadoc)
+ * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#resumeWorkflowInstance(java.lang.String)
*/
@Override
public void resumeWorkflowInstance(String workflowInstId) {
// TODO Auto-generated method stub
-
+
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.oodt.cas.workflow.engine.WorkflowEngine#getInstanceRepository()
+ /* (non-Javadoc)
+ * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#getInstanceRepository()
*/
@Override
public WorkflowInstanceRepository getInstanceRepository() {
@@ -123,12 +138,8 @@ public class PrioritizedQueueBasedWorkfl
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.oodt.cas.workflow.engine.WorkflowEngine#updateMetadata(java.
- * lang.String, org.apache.oodt.cas.metadata.Metadata)
+ /* (non-Javadoc)
+ * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#updateMetadata(java.lang.String, org.apache.oodt.cas.metadata.Metadata)
*/
@Override
public boolean updateMetadata(String workflowInstId, Metadata met) {
@@ -136,25 +147,17 @@ public class PrioritizedQueueBasedWorkfl
return false;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.oodt.cas.workflow.engine.WorkflowEngine#setWorkflowManagerUrl
- * (java.net.URL)
+ /* (non-Javadoc)
+ * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#setWorkflowManagerUrl(java.net.URL)
*/
@Override
public void setWorkflowManagerUrl(URL url) {
// TODO Auto-generated method stub
-
+
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.oodt.cas.workflow.engine.WorkflowEngine#getWallClockMinutes(
- * java.lang.String)
+ /* (non-Javadoc)
+ * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#getWallClockMinutes(java.lang.String)
*/
@Override
public double getWallClockMinutes(String workflowInstId) {
@@ -162,11 +165,8 @@ public class PrioritizedQueueBasedWorkfl
return 0;
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#
- * getCurrentTaskWallClockMinutes(java.lang.String)
+ /* (non-Javadoc)
+ * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#getCurrentTaskWallClockMinutes(java.lang.String)
*/
@Override
public double getCurrentTaskWallClockMinutes(String workflowInstId) {
@@ -174,107 +174,450 @@ public class PrioritizedQueueBasedWorkfl
return 0;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.oodt.cas.workflow.engine.WorkflowEngine#getWorkflowInstanceMetadata
- * (java.lang.String)
+ /* (non-Javadoc)
+ * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#getWorkflowInstanceMetadata(java.lang.String)
*/
@Override
public Metadata getWorkflowInstanceMetadata(String workflowInstId) {
// TODO Auto-generated method stub
return null;
}
-
- class QueueWorker implements Runnable{
- private boolean work;
-
- public QueueWorker(){
- this.work = true;
+ public void loadProcessorRepo() throws Exception {
+ if (this.processorRepo != null) {
+ for (String instanceId : this.processorRepo.getStoredInstanceIds())
+ this.processorQueue.put(instanceId, new CachedWorkflowProcessor(instanceId));
}
-
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- public void run() {
- while(work) {
+ }
+
+ public void shutdown() {
+ this.allowQueuerToWork = false;
+ try {
+ this.queuerThread.join(5000);
+ }catch(Exception e) {}
+ }
+
+ public void addToQueue(WorkflowProcessor workflowProcessor) throws Exception {
+ workflowProcessor.setStateRecur(new QueuedState(""));
+ this.processorQueue.put(workflowProcessor.getInstanceId(), new CachedWorkflowProcessor(workflowProcessor));
+ }
+
+ public TaskInstance getNext() throws Exception {
+ WorkflowProcessor stub = null;
+ synchronized (this.runnableTasks) {
+ if (!this.runnableTasks.isEmpty())
+ stub = this.runnableTasks.remove(0);
+ }
+ if (stub != null) {
+ CachedWorkflowProcessor cachedWP = this.processorQueue.get(stub.getInstanceId());
+ try {
+ cachedWP.uncache();
+ processorLock.lock(cachedWP.getInstanceId());
+ TaskProcessor taskProcessor = (TaskProcessor) WorkflowUtils.findProcessor(cachedWP.getWorkflowProcessor(), stub.getModelId());
+ TaskInstance taskInstance = this.makeInstance(taskProcessor);
+ this.executingTasks.put(taskProcessor.getInstanceId() + ":" + taskProcessor.getModelId(), taskProcessor.getStub());
+ return taskInstance;
+ }catch (Exception e) {
+ throw e;
+ }finally {
+ processorLock.unlock(cachedWP.getInstanceId());
+ cachedWP.cache();
+ }
+ }else {
+ return null;
+ }
+ }
+
+ private TaskInstance makeInstance(TaskProcessor taskProcessor) throws InstantiationException, IllegalAccessException {
+ TaskInstance ti = taskProcessor.getInstanceClass().newInstance();
+ ti.setInstanceId(taskProcessor.getInstanceId());
+ ti.setDynamicMetadata(taskProcessor.getDynamicMetadata());
+ ti.setStaticMetadata(taskProcessor.getStaticMetadata());
+ ti.setModelId(taskProcessor.getModelId());
+ ti.setExecutionType(taskProcessor.getExecutionType());
+ ti.setJobId(UUID.randomUUID().toString());
+ taskProcessor.setJobId(ti.getJobId());
+ return ti;
+ }
+
+ public void revertState(String instanceId, String modelId) {
+ try {
+ CachedWorkflowProcessor cachedWP = this.processorQueue.get(instanceId);
+ if (cachedWP != null) {
try {
- List<WorkflowInstance> instances = null;
- synchronized(repo){
- instances = repo.getWorkflowInstances();
- }
-
- List<WorkflowProcessor> runnableProcessors = new Vector<WorkflowProcessor>();
- for (WorkflowInstance instance : instances) {
- if (!work)
- break;
- if (isRunnableInstance(instance)) {
- synchronized(repo){
- instance.setStatus(WorkflowStatus.STARTED);
- repo.updateWorkflowInstance(instance);
- }
-
- synchronized(runnableProcessors){
- WorkflowInstance inst = new WorkflowInstance();
- Workflow workflow = new Workflow();
- workflow.setId(instance.getId()+"-"+instance.getCurrentTaskId());
- WorkflowTask task = getTask(instance.getWorkflow().getTasks(), instance.getCurrentTaskId());
- workflow.setName(task.getTaskName());
- workflow.getTasks().add(task);
- inst.setId(UUID.randomUUID().toString());
- inst.setWorkflow(workflow);
- inst.setCurrentTaskStartDateTimeIsoStr(DateConvert.isoFormat(new Date()));
- inst.setPriority(instance.getPriority());
- inst.setSharedContext(instance.getSharedContext());
-
- SequentialProcessor processor =
- new SequentialProcessor(inst, repo, wmgrUrl, conditionWait);
- runnableProcessors.add(processor);
- }
+ cachedWP.uncache();
+ processorLock.lock(cachedWP.getInstanceId());
+ if (modelId != null)
+ WorkflowUtils.findProcessor(cachedWP.getWorkflowProcessor(), modelId).revertState();
+ else
+ cachedWP.getWorkflowProcessor().revertState();
+ WorkflowUtils.validateWorkflowProcessor(cachedWP.getWorkflowProcessor());
+ }catch (Exception e) {
+ throw e;
+ }finally {
+ processorLock.unlock(cachedWP.getInstanceId());
+ cachedWP.cache();
+ }
+ }
+ }catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to revert state for workflow [InstanceId = '" + instanceId + "', ModelId = '" + modelId + "'] : " + e.getMessage(), e);
+ }
+ }
+
+ public void setJobId(String instanceId, String modelId, String jobId) {
+ try {
+ CachedWorkflowProcessor cachedWP = this.processorQueue.get(instanceId);
+ if (cachedWP != null) {
+ try {
+ cachedWP.uncache();
+ processorLock.lock(cachedWP.getInstanceId());
+ WorkflowProcessor wp = (modelId == null) ? cachedWP.getWorkflowProcessor() : WorkflowUtils.findProcessor(cachedWP.getWorkflowProcessor(), modelId);
+ if (wp instanceof TaskProcessor)
+ ((TaskProcessor) wp).setJobId(jobId);
+ }catch (Exception e) {
+ throw e;
+ }finally {
+ processorLock.unlock(cachedWP.getInstanceId());
+ cachedWP.cache();
+ }
+ }
+ }catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to set state for workflow [InstanceId = '" + instanceId + "', ModelId = '" + modelId + "'] : " + e.getMessage(), e);
+ }
+ }
+
+ public void setState(String instanceId, String modelId, WorkflowState state) {
+ try {
+ CachedWorkflowProcessor cachedWP = this.processorQueue.get(instanceId);
+ if (cachedWP != null) {
+ try {
+ cachedWP.uncache();
+ processorLock.lock(cachedWP.getInstanceId());
+ WorkflowProcessor wp = (modelId == null) ? cachedWP.getWorkflowProcessor() : WorkflowUtils.findProcessor(cachedWP.getWorkflowProcessor(), modelId);
+ if (state instanceof RevertableWorkflowState)
+ ((RevertableWorkflowState) state).setPrevState(wp.getState());
+ wp.setState(state);
+ if (wp instanceof TaskProcessor) {
+ if (this.executingTasks.containsKey(instanceId + ":" + modelId)) {
+ if (!(state instanceof ExecutingState))
+ this.executingTasks.remove(instanceId + ":" + modelId);
+ else
+ this.executingTasks.put(instanceId + ":" + modelId, wp.getStub());
+ }else {
+ this.updateRunnableStub(wp);
}
-
- prioritizer.sort(runnableProcessors);
-
- //take a breather
- try {
- synchronized(this) {
- this.wait(1);
- }
- }catch (Exception e){}
}
}catch (Exception e) {
- e.printStackTrace();
+ throw e;
+ }finally {
+ processorLock.unlock(cachedWP.getInstanceId());
+ cachedWP.cache();
}
}
-
+ }catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to set state for workflow [InstanceId = '" + instanceId + "', ModelId = '" + modelId + "'] : " + e.getMessage(), e);
+ }
+ }
+
+ public void setPriority(String instanceId, String modelId, Priority priority) {
+ try {
+ if (this.executingTasks.containsKey(instanceId + ":" + modelId)) {
+ LOG.log(Level.WARNING, "Can't change the priority of an executing task [InstanceId = '" + instanceId + "', ModelId = '" + modelId + "'] : ");
+ return;
+ }
+ CachedWorkflowProcessor cachedWP = this.processorQueue.get(instanceId);
+ if (cachedWP != null) {
+ try {
+ cachedWP.uncache();
+ processorLock.lock(cachedWP.getInstanceId());
+ WorkflowProcessor wp = (modelId == null) ? cachedWP.getWorkflowProcessor() : WorkflowUtils.findProcessor(cachedWP.getWorkflowProcessor(), modelId);
+ wp.setPriorityRecur(priority);
+ if (wp instanceof TaskProcessor)
+ this.updateRunnableStub(wp);
+ }catch (Exception e) {
+ throw e;
+ }finally {
+ processorLock.unlock(cachedWP.getInstanceId());
+ cachedWP.cache();
+ }
+ }
+ }catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to set priority for workflow [InstanceId = '" + instanceId + "', ModelId = '" + modelId + "'] : " + e.getMessage(), e);
+ }
+ }
+
+ public void setMetadata(String instanceId, String modelId, Metadata metadata) {
+ try {
+ CachedWorkflowProcessor cachedWP = this.processorQueue.get(instanceId);
+ if (cachedWP != null) {
+ try {
+ cachedWP.uncache();
+ processorLock.lock(cachedWP.getInstanceId());
+ WorkflowProcessor wp = modelId == null ? cachedWP.getWorkflowProcessor() : WorkflowUtils.findProcessor(cachedWP.getWorkflowProcessor(), modelId);
+ wp.setDynamicMetadata(metadata);
+ }catch (Exception e) {
+ throw e;
+ }finally {
+ processorLock.unlock(cachedWP.getInstanceId());
+ cachedWP.cache();
+ }
+ }
+ }catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to set metadata for workflow [InstanceId = '" + instanceId + "', ModelId = '" + modelId + "'] : " + e.getMessage(), e);
+ }
+ }
+
+ public WorkflowProcessor getWorkflowProcessor(String instanceId) {
+ CachedWorkflowProcessor cachedWP = this.processorQueue.get(instanceId);
+ WorkflowProcessor returnProcessor = null;
+ if (cachedWP != null) {
try {
- synchronized(this) {
- this.wait(2000);
+ cachedWP.uncache();
+ processorLock.lock(instanceId);
+ returnProcessor = cachedWP.getWorkflowProcessor();
+ }catch (RuntimeException e) {
+ throw e;
+ }finally {
+ processorLock.unlock(instanceId);
+ cachedWP.cache();
+ }
+ }
+ return returnProcessor;
+ }
+
+ public boolean containsWorkflow(String instanceId) {
+ return this.processorQueue.containsKey(instanceId);
+ }
+
+ public void deleteWorkflowProcessor(String instanceId) {
+ CachedWorkflowProcessor cachedWP = this.processorQueue.remove(instanceId);
+ if (cachedWP != null) {
+ cachedWP.delete();
+ this.processorLock.delete(instanceId);
+ synchronized (this.runnableTasks) {
+ for (int i = 0; i < this.runnableTasks.size(); i++) {
+ WorkflowProcessor stub = this.runnableTasks.get(i);
+ if (stub.getInstanceId().equals(instanceId))
+ this.runnableTasks.remove(i--);
}
- }catch (Exception e){}
+ }
+ }
+ }
+
+ public RunnablesPage getExecutingPage(PageInfo pageInfo) {
+ List<WorkflowProcessor> executing = new Vector<WorkflowProcessor>(this.executingTasks.values());
+ Vector<WorkflowProcessor> pageWPs = new Vector<WorkflowProcessor>();
+ int startIndex = (pageInfo.getPageNum() - 1) * pageInfo.getPageSize();
+ for (int i = startIndex; i < startIndex + pageInfo.getPageSize() && i < executing.size(); i++)
+ pageWPs.add(executing.get(i));
+ return new RunnablesPage(this.getProcessedPageInfo(pageInfo, executing.size()), pageWPs);
+ }
+
+ public RunnablesPage getRunnablesPage(PageInfo pageInfo) {
+ List<WorkflowProcessor> runnables = new Vector<WorkflowProcessor>(this.runnableTasks);
+ Vector<WorkflowProcessor> pageWPs = new Vector<WorkflowProcessor>();
+ int startIndex = (pageInfo.getPageNum() - 1) * pageInfo.getPageSize();
+ for (int i = startIndex; i < startIndex + pageInfo.getPageSize() && i < runnables.size(); i++)
+ pageWPs.add(runnables.get(i));
+ return new RunnablesPage(this.getProcessedPageInfo(pageInfo, runnables.size()), pageWPs);
+ }
+
+ public QueuePage getPage(PageInfo pageInfo) {
+ return this.getPage(pageInfo, (Comparator<WorkflowProcessor>) null);
}
- private WorkflowTask getTask(List<WorkflowTask> tasks, String id){
- if(tasks != null && tasks.size() > 0){
- for(WorkflowTask task: tasks){
- if(task.getTaskId().equals(id)){
- return task;
- }
+ public QueuePage getPage(PageInfo pageInfo, PageFilter filter) {
+ Vector<CachedWorkflowProcessor> acceptedWPs = new Vector<CachedWorkflowProcessor>();
+ Vector<CachedWorkflowProcessor> cachedWPs = null;
+ synchronized(processorQueue) {
+ cachedWPs = new Vector<CachedWorkflowProcessor>(this.processorQueue.values());
+ }
+ if (filter != null)
+ for (CachedWorkflowProcessor cachedWP : cachedWPs)
+ if (filter.accept(cachedWP.getStub(), cachedWP.getCachedMetadata()))
+ acceptedWPs.add(cachedWP);
+ return new QueuePage(this.getProcessedPageInfo(pageInfo, acceptedWPs.size()), this.getPage(pageInfo, acceptedWPs), filter);
+ }
+
+ public QueuePage getPage(PageInfo pageInfo, Comparator<WorkflowProcessor> comparator) {
+ Vector<CachedWorkflowProcessor> sortedCachedWPs = null;
+ synchronized(this.processorQueue) {
+ sortedCachedWPs = new Vector<CachedWorkflowProcessor>(this.processorQueue.values());
+ }
+ if (comparator != null) {
+ final Comparator<WorkflowProcessor> comparatorFinal = comparator;
+ Collections.sort(sortedCachedWPs, new Comparator<CachedWorkflowProcessor>() {
+ public int compare(CachedWorkflowProcessor o1,
+ CachedWorkflowProcessor o2) {
+ return comparatorFinal.compare(o1.getStub(), o2.getStub());
}
+ });
+ }
+ return new QueuePage(this.getProcessedPageInfo(pageInfo, sortedCachedWPs.size()), this.getPage(pageInfo, sortedCachedWPs), comparator);
+ }
+
+ public QueuePage getPage(PageInfo pageInfo, PageFilter filter, final Comparator<WorkflowProcessor> comparator) {
+ Vector<CachedWorkflowProcessor> acceptedWPs = new Vector<CachedWorkflowProcessor>();
+ Vector<CachedWorkflowProcessor> cachedWPs = null;
+ synchronized(processorQueue) {
+ cachedWPs = new Vector<CachedWorkflowProcessor>(this.processorQueue.values());
}
-
- return null;
+ if (filter != null)
+ for (CachedWorkflowProcessor cachedWP : cachedWPs)
+ if (filter.accept(cachedWP.getStub(), cachedWP.getCachedMetadata()))
+ acceptedWPs.add(cachedWP);
+ if (comparator != null) {
+ Collections.sort(acceptedWPs, new Comparator<CachedWorkflowProcessor>() {
+ public int compare(CachedWorkflowProcessor o1,
+ CachedWorkflowProcessor o2) {
+ return comparator.compare(o1.getStub(), o2.getStub());
+ }
+ });
+ }
+ return new QueuePage(this.getProcessedPageInfo(pageInfo, acceptedWPs.size()), this.getPage(pageInfo, acceptedWPs), Arrays.asList(filter, comparator));
+ }
+
+ public QueuePage getPage(PageInfo pageInfo, WorkflowState state) {
+ List<CachedWorkflowProcessor> processorsOfGivenState = new Vector<CachedWorkflowProcessor>();
+ Vector<CachedWorkflowProcessor> processorQueueValues = null;
+ synchronized(this.processorQueue) {
+ processorQueueValues = new Vector<CachedWorkflowProcessor>(this.processorQueue.values());
+ }
+ for (CachedWorkflowProcessor cachedWP : processorQueueValues)
+ if (cachedWP.getStub().getState().equals(state))
+ processorsOfGivenState.add(cachedWP);
+ return new QueuePage(this.getProcessedPageInfo(pageInfo, processorsOfGivenState.size()), this.getPage(pageInfo, processorsOfGivenState), state);
+ }
+
+ public QueuePage getPage(PageInfo pageInfo, WorkflowState.Category category) {
+ List<CachedWorkflowProcessor> processorsOfGivenCategory = new Vector<CachedWorkflowProcessor>();
+ Vector<CachedWorkflowProcessor> processorQueueValues = null;
+ synchronized(this.processorQueue) {
+ processorQueueValues = new Vector<CachedWorkflowProcessor>(this.processorQueue.values());
+ }
+ for (CachedWorkflowProcessor cachedWP : processorQueueValues)
+ if (cachedWP.getStub().getState().getCategory().equals(category))
+ processorsOfGivenCategory.add(cachedWP);
+ return new QueuePage(this.getProcessedPageInfo(pageInfo, processorsOfGivenCategory.size()), this.getPage(pageInfo, processorsOfGivenCategory), category);
}
+ public QueuePage getPage(PageInfo pageInfo, String modelId) {
+ List<CachedWorkflowProcessor> processorsOfGivenModelId = new Vector<CachedWorkflowProcessor>();
+ Vector<CachedWorkflowProcessor> processorQueueValues = null;
+ synchronized(this.processorQueue) {
+ processorQueueValues = new Vector<CachedWorkflowProcessor>(this.processorQueue.values());
+ }
+ for (CachedWorkflowProcessor cachedWP : processorQueueValues)
+ if (cachedWP.getStub().getModelId().equals(modelId))
+ processorsOfGivenModelId.add(cachedWP);
+ return new QueuePage(this.getProcessedPageInfo(pageInfo, processorsOfGivenModelId.size()), this.getPage(pageInfo, processorsOfGivenModelId), modelId);
+ }
+
+ public QueuePage getPage(PageInfo pageInfo, Map<String, List<String>> keyValPairs) {
+ List<CachedWorkflowProcessor> queryResults = new Vector<CachedWorkflowProcessor>();
+ Vector<CachedWorkflowProcessor> processorQueueValues = null;
+ synchronized(this.processorQueue) {
+ processorQueueValues = new Vector<CachedWorkflowProcessor>(this.processorQueue.values());
+ }
+ for (CachedWorkflowProcessor cachedWP : processorQueueValues) {
+ Metadata cachedMetadata = cachedWP.getCachedMetadata();
+ if (cachedMetadata.getAllKeys().size() > 0) {
+ for (Entry<String, List<String>> entry : keyValPairs.entrySet()) {
+ String value = cachedMetadata.getMetadata(entry.getKey());
+ if (value != null && entry.getValue().contains(value))
+ queryResults.add(cachedWP);
+ }
+ }
+ }
+ return new QueuePage(this.getProcessedPageInfo(pageInfo, queryResults.size()), this.getPage(pageInfo, queryResults), keyValPairs);
+ }
+
+ protected ProcessedPageInfo getProcessedPageInfo(PageInfo pageInfo, int numOfHits) {
+ return new ProcessedPageInfo(pageInfo.getPageSize(), pageInfo.getPageNum(), numOfHits);
+ }
+
+ protected List<WorkflowProcessor> getPage(PageInfo pageInfo, List<CachedWorkflowProcessor> cachedWPs) {
+ Vector<WorkflowProcessor> pageWPs = new Vector<WorkflowProcessor>();
+ int startIndex = (pageInfo.getPageNum() - 1) * pageInfo.getPageSize();
+ for (int i = startIndex; i < startIndex + pageInfo.getPageSize() && i < cachedWPs.size(); i++) {
+ CachedWorkflowProcessor cachedWP = cachedWPs.get(i);
+ processorLock.lock(cachedWP.getInstanceId());
+ pageWPs.add(cachedWP.getStub());
+ processorLock.unlock(cachedWP.getInstanceId());
+ }
+ return pageWPs;
+ }
+
+ protected void updateRunnableStub(WorkflowProcessor wp) {
+ if (this.runnableTasks.remove(wp.getStub())) {
+ if (wp.getState() instanceof WaitingOnResourcesState) {
+ this.runnableTasks.add(wp.getStub());
+ synchronized (this.runnableTasks) {
+ this.priorityManager.sort(this.runnableTasks);
+ }
+ }
+ }
+ }
+
+ public int getNumOfLoadedProcessors() {
+ int loaded = 0;
+ Vector<CachedWorkflowProcessor> processorQueueValues = null;
+ synchronized(this.processorQueue) {
+ processorQueueValues = new Vector<CachedWorkflowProcessor>(this.processorQueue.values());
+ }
+ for (CachedWorkflowProcessor cachedWP : processorQueueValues)
+ if (cachedWP.WorkflowProcessor != null)
+ loaded++;
+ return loaded;
+ }
+
+ public int getNumOfProcessors() {
+ return this.processorQueue.size();
+ }
+
+
+
+ private class WorkflowProcessorLock {
+
+ private Map<String, ReadWriteLock> lockedProcessors;
+
+ public WorkflowProcessorLock() {
+ this.lockedProcessors = new HashMap<String, ReadWriteLock>();
+ }
+
+ public void lock(String instanceId) {
+ ReadWriteLock lock = null;
+ synchronized(this.lockedProcessors) {
+ lock = this.lockedProcessors.get(instanceId);
+ if (lock == null)
+ this.lockedProcessors.put(instanceId, lock = new ReentrantReadWriteLock());
+ }
+ lock.writeLock().lock();
+ }
+
+ public void unlock(String instanceId) {
+ ReadWriteLock lock = null;
+ synchronized(this.lockedProcessors) {
+ lock = this.lockedProcessors.get(instanceId);
+ }
+ lock.writeLock().unlock();
+ }
+
+ public void delete(String instanceId) {
+ synchronized(this.lockedProcessors) {
+ this.lockedProcessors.remove(instanceId);
+ }
+ }
+
+ }
+
+
private boolean isRunnableInstance(WorkflowInstance instance){
return !instance.getStatus().equals(WorkflowStatus.ERROR) &&
!instance.getStatus().equals(WorkflowStatus.FINISHED) &&
!instance.getStatus().equals(WorkflowStatus.METADATA_MISSING) &&
!instance.getStatus().equals(WorkflowStatus.PAUSED);
}
- }
+ }
-}
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/SynchronousLocalEngineRunner.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/SynchronousLocalEngineRunner.java?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/SynchronousLocalEngineRunner.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/SynchronousLocalEngineRunner.java Sat Apr 14 16:29:37 2012
@@ -54,6 +54,8 @@ public class SynchronousLocalEngineRunne
WorkflowTaskInstance inst = GenericWorkflowObjectFactory
.getTaskObjectFromClassName(workflowTask.getTaskInstanceClassName());
try {
+ LOG.log(Level.INFO, "Executing task: [" + workflowTask.getTaskName()
+ + "] locally");
inst.run(dynMetadata, workflowTask.getTaskConfig());
} catch (Exception e) {
LOG.log(Level.WARNING,
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecycle.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecycle.java?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecycle.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecycle.java Sat Apr 14 16:29:37 2012
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-
package org.apache.oodt.cas.workflow.lifecycle;
//OODT imports
@@ -26,163 +25,236 @@ import org.apache.oodt.cas.workflow.stru
//JDK imports
import java.util.Comparator;
import java.util.Iterator;
+import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
/**
- * @author mattmann
- * @version $Revision$
*
- * <p>
* Defines the lifecycle of a {@link Workflow}, identifying what
* {@link WorkflowStatus}es belong to a particular phase.
- * </p>.
+ *
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
*/
public class WorkflowLifecycle {
- public static final String DEFAULT_LIFECYCLE = "__default__";
-
- public static final String NO_WORKFLOW_ID = "__no__workflow__id";
+ public static final String DEFAULT_LIFECYCLE = "__default__";
- private SortedSet stages;
+ public static final String NO_WORKFLOW_ID = "__no__workflow__id";
- private String name;
+ private SortedSet stages;
- private String workflowId;
-
+ private String name;
- /**
- * Default Constructor.
- *
- */
- public WorkflowLifecycle() {
- this(null, null);
- }
-
- /**
- * Constructs a new WorkflowLifecycle with the given parameters.
- *
- * @param name
- * The name of the WorkflowLifecycle.
- * @param workflowId
- * The associated identifier for the {@link Workflow}s that this
- * WorkflowLifecycle is appropriate for.
- */
- public WorkflowLifecycle(String name, String workflowId) {
- this.name = name;
- this.workflowId = workflowId;
- this.stages = new TreeSet(new Comparator() {
-
- public int compare(Object o1, Object o2) {
- WorkflowLifecycleStage stage1 = (WorkflowLifecycleStage) o1;
- WorkflowLifecycleStage stage2 = (WorkflowLifecycleStage) o2;
-
- if (stage1.getOrder() < stage2.getOrder()) {
- return -1;
- } else if (stage1.getOrder() == stage2.getOrder()) {
- return 0;
- } else {
- return 1;
- }
- }
-
- });
-
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name
- * the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return the stages
- */
- public SortedSet getStages() {
- return stages;
- }
-
- /**
- * Adds a {@link WorkflowStage} to this WorkflowLifecycle.
- *
- * @param stage
- * The {@link WorkflowStage} to add to this WorkflowLifecycle.
- */
- public void addStage(WorkflowLifecycleStage stage) {
- if (!stages.contains(stage)) {
- stages.add(stage);
+ private String workflowId;
+
+ /**
+ * Default Constructor.
+ *
+ */
+ public WorkflowLifecycle() {
+ this(null, null);
+ }
+
+ /**
+ * Constructs a new WorkflowLifecycle with the given parameters.
+ *
+ * @param name
+ * The name of the WorkflowLifecycle.
+ * @param workflowId
+ * The associated identifier for the {@link Workflow}s that this
+ * WorkflowLifecycle is appropriate for.
+ */
+ public WorkflowLifecycle(String name, String workflowId) {
+ this.name = name;
+ this.workflowId = workflowId;
+ this.stages = new TreeSet(new Comparator() {
+
+ public int compare(Object o1, Object o2) {
+ WorkflowLifecycleStage stage1 = (WorkflowLifecycleStage) o1;
+ WorkflowLifecycleStage stage2 = (WorkflowLifecycleStage) o2;
+
+ if (stage1.getOrder() < stage2.getOrder()) {
+ return -1;
+ } else if (stage1.getOrder() == stage2.getOrder()) {
+ return 0;
+ } else {
+ return 1;
}
- }
-
- /**
- * Removes the given {@link WorkflowStage} from this WorkflowLifecycle.
- *
- * @param stage
- * The {@link WorkflowStage} to remove.
- * @return True on success, false on failure.
- */
- public boolean removeStage(WorkflowLifecycleStage stage) {
- return stages.remove(stage);
- }
+ }
- /**
- * Clears the {@link WorkflowStage}s in this WorkflowLifecycle.
- *
- */
- public void clearStages() {
- stages.clear();
- }
+ });
- /**
- * @return the workflowId
- */
- public String getWorkflowId() {
- return workflowId;
- }
+ }
- /**
- * @param workflowId
- * the workflowId to set
- */
- public void setWorkflowId(String workflowId) {
- this.workflowId = workflowId;
- }
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ * the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the stages
+ */
+ public SortedSet getStages() {
+ return stages;
+ }
+
+ /**
+ * Adds a {@link WorkflowStage} to this WorkflowLifecycle.
+ *
+ * @param stage
+ * The {@link WorkflowStage} to add to this WorkflowLifecycle.
+ */
+ public void addStage(WorkflowLifecycleStage stage) {
+ if (!stages.contains(stage)) {
+ stages.add(stage);
+ }
+ }
+
+ /**
+ * Removes the given {@link WorkflowStage} from this WorkflowLifecycle.
+ *
+ * @param stage
+ * The {@link WorkflowStage} to remove.
+ * @return True on success, false on failure.
+ */
+ public boolean removeStage(WorkflowLifecycleStage stage) {
+ return stages.remove(stage);
+ }
+
+ /**
+ * Clears the {@link WorkflowStage}s in this WorkflowLifecycle.
+ *
+ */
+ public void clearStages() {
+ stages.clear();
+ }
+
+ /**
+ * @return the workflowId
+ */
+ public String getWorkflowId() {
+ return workflowId;
+ }
+
+ /**
+ * @param workflowId
+ * the workflowId to set
+ */
+ public void setWorkflowId(String workflowId) {
+ this.workflowId = workflowId;
+ }
+
+ /**
+ * Gets the associated {@link WorkflowLifecycleStage} for a
+ * {@link WorkflowInstance} with a given status.
+ *
+ * @param status
+ * The status of the {@link WorkflowInstance} to get the
+ * {@link WorkflowLifecycleStage} for.
+ * @return The corresponding {@link WorkflowLifecycleStage} for the
+ * {@link WorkflowInstance} with the given status, or null if that
+ * status does not exist in any defined {@link WorkflowLifecycleStage}
+ * .
+ */
+ @Deprecated
+ public WorkflowLifecycleStage getStageForWorkflow(String status) {
+ if (this.stages != null && this.stages.size() > 0) {
+ for (Iterator i = this.stages.iterator(); i.hasNext();) {
+ WorkflowLifecycleStage stage = (WorkflowLifecycleStage) i.next();
+ if (stage.getStates().contains(status)) {
+ return stage;
+ }
+ }
- /**
- * Gets the associated {@link WorkflowLifecycleStage} for a
- * {@link WorkflowInstance} with a given status.
- *
- * @param status
- * The status of the {@link WorkflowInstance} to get the
- * {@link WorkflowLifecycleStage} for.
- * @return The corresponding {@link WorkflowLifecycleStage} for the
- * {@link WorkflowInstance} with the given status, or null if that
- * status does not exist in any defined
- * {@link WorkflowLifecycleStage}.
- */
- public WorkflowLifecycleStage getStageForWorkflow(String status) {
- if (this.stages != null && this.stages.size() > 0) {
- for (Iterator i = this.stages.iterator(); i.hasNext();) {
- WorkflowLifecycleStage stage = (WorkflowLifecycleStage) i
- .next();
- if (stage.getStates().contains(status)) {
- return stage;
- }
+ return null;
+ } else
+ return null;
+ }
+
+ /**
+ * Looks up an associated {@link WorkflowState} by scanning the
+ * {@link WorkflowLifecycleStage}s present in this lifecycle (aka, by scanning
+ * its "Categories", in Workflow2 terminology). Since no Category is provided,
+ * the first instance of a {@link WorkflowState} found in the given
+ * {@link WorkflowLifecycleStage} being scanned is returned, even if there are
+ * multiple instances of that state (e.g., others present in another
+ * category).
+ *
+ * If found, the {@link WorkflowState} is returned, otherwise null is
+ * returned.
+ *
+ * @param stateName
+ * The name of the {@link WorkflowState} to locate and return.
+ * @return The {@link WorkflowState} if found, otherwise null.
+ */
+ public WorkflowState getStateByName(String stateName) {
+ return this.getStateByNameAndCategory(stateName, null);
+ }
+
+ /**
+ * Gets a {@link WorkflowState} by its name and {@link WorkflowLifecycleStage}
+ * (or Category in Workflow2 terminology). If the state is found within that
+ * category, then it is returned, otherwise null is returned.
+ *
+ * @param stateName
+ * The name of the {@link WorkflowState} to locate and return.
+ * @param category
+ * The provided {@link WorkflowLifecycleStage} name to categorize the
+ * state by.
+ * @return The {@link WorkflowState} if found, otherwise null.
+ */
+ public WorkflowState getStateByNameAndCategory(String stateName,
+ String category) {
+ if (this.getStages() != null) {
+ for (WorkflowLifecycleStage stage : (SortedSet<WorkflowLifecycleStage>) this
+ .getStages()) {
+ if (category != null && !stage.getName().equals(category))
+ continue;
+ if (stage.getStates() != null) {
+ for (WorkflowState state : (List<WorkflowState>) stage.getStates()) {
+ if (state.getName().equals(stateName)) {
+ return state;
}
+ }
+ }
+ }
+ }
- return null;
- } else
- return null;
+ return null;
+ }
+
+ public WorkflowLifecycleStage getCategoryByName(String category){
+ if(this.getStages() != null){
+ for(WorkflowLifecycleStage stage: (SortedSet<WorkflowLifecycleStage>)this.getStages()){
+ if(stage.getName().equals(category)){
+ return stage;
+ }
+ }
}
+
+ return null;
+ }
+
+ public WorkflowState createState(String name, String category, String message){
+ WorkflowState state = new WorkflowState();
+ state.setName(name);
+ state.setCategory(getCategoryByName(category));
+ state.setMessage(message);
+ return state;
+ }
}
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecycleStage.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecycleStage.java?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecycleStage.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecycleStage.java Sat Apr 14 16:29:37 2012
@@ -36,14 +36,14 @@ public class WorkflowLifecycleStage {
private int order;
- private List states;
+ private List<WorkflowState> states;
/**
* Default Constructor.
*
*/
public WorkflowLifecycleStage() {
- states = new Vector();
+ states = new Vector<WorkflowState>();
}
/**
@@ -59,7 +59,7 @@ public class WorkflowLifecycleStage {
* The ordering of this State in a {@List} of States that make up
* a {@link WorkflowLifeCycle}.
*/
- public WorkflowLifecycleStage(String name, List states, int order) {
+ public WorkflowLifecycleStage(String name, List<WorkflowState> states, int order) {
this.name = name;
this.states = states;
this.order = order;
@@ -83,7 +83,7 @@ public class WorkflowLifecycleStage {
/**
* @return the states
*/
- public List getStates() {
+ public List<WorkflowState> getStates() {
return states;
}
@@ -91,7 +91,7 @@ public class WorkflowLifecycleStage {
* @param states
* the states to set
*/
- public void setStates(List states) {
+ public void setStates(List<WorkflowState> states) {
this.states = states;
}
@@ -119,4 +119,14 @@ public class WorkflowLifecycleStage {
return this.name.hashCode() + new Integer(this.order).hashCode();
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object stage) {
+ return this.name.equals(((WorkflowLifecycleStage)stage).getName());
+ }
+
+
+
}
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecyclesReader.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecyclesReader.java?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecyclesReader.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/lifecycle/WorkflowLifecyclesReader.java Sat Apr 14 16:29:37 2012
@@ -113,11 +113,45 @@ public final class WorkflowLifecyclesRea
WorkflowLifecycleStage stage = new WorkflowLifecycleStage();
stage.setName(STAGE_TAG_NAME_ATTR);
stage.setOrder(i+1);
- stage.setStates(XMLUtils.readMany(stageElem, STATUS_TAG_NAME));
+ stage.setStates(readStates(stageElem, stage));
lifecycle.addStage(stage);
}
}
}
+
+ private static List<WorkflowState> readStates(Element stageElem, WorkflowLifecycleStage category){
+ List<WorkflowState> states = new Vector<WorkflowState>();
+ NodeList statusNodeList = stageElem.getElementsByTagName(STATUS_TAG_NAME);
+ if(statusNodeList != null && statusNodeList.getLength() > 0){
+ for(int i=0; i < statusNodeList.getLength(); i++){
+ Element statusElem = (Element)statusNodeList.item(i);
+ // see if its name is specified via the name attribute, otherwise
+ // read it in back compat mode
+
+ if(statusElem.getAttribute("name") != null &&
+ !statusElem.getAttribute("name").equals("")){
+ String statusName = statusElem.getAttribute("name");
+ String description = XMLUtils.getElementText("description", statusElem);
+ WorkflowState state = new WorkflowState();
+ state.setCategory(category);
+ state.setName(statusName);
+ state.setDescription(description);
+ states.add(state);
+ }
+ else{
+ // back compat mode
+ String statusName = XMLUtils.getSimpleElementText(statusElem);
+ WorkflowState state = new WorkflowState();
+ state.setName(statusName);
+ state.setMessage(statusName);
+ state.setCategory(category);
+ states.add(state);
+ }
+ }
+ }
+
+ return states;
+ }
private static Document getDocumentRoot(String xmlFile) {
// open up the XML file
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Graph.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Graph.java?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Graph.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Graph.java Sat Apr 14 16:29:37 2012
@@ -373,6 +373,30 @@ public class Graph {
public List<String> getProcessorIds() {
return processorIds;
}
+
+ /**
+ *
+ * @return True is {@link #cond} isn't null, false otherwise.
+ */
+ public boolean isCondition(){
+ return this.cond != null;
+ }
+
+ /**
+ *
+ * @return True if {@link #workflow} isn't null, false othewise.
+ */
+ public boolean isWorkflow(){
+ return this.workflow != null;
+ }
+
+ /**
+ *
+ * @return True if {@link #task} isn't null, false otherwise.
+ */
+ public boolean isTask(){
+ return this.task != null;
+ }
private boolean checkValue(String value) {
return value != null && !value.equals("");
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/ParentChildWorkflow.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/ParentChildWorkflow.java?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/ParentChildWorkflow.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/ParentChildWorkflow.java Sat Apr 14 16:29:37 2012
@@ -33,6 +33,12 @@ public class ParentChildWorkflow extends
private Graph graph;
+ public ParentChildWorkflow(Workflow workflow) {
+ super(workflow.getName(), workflow.getId(), workflow.getTasks(), workflow
+ .getConditions());
+ this.graph = new Graph();
+ }
+
public ParentChildWorkflow(Graph graph) {
this.graph = graph;
}
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Workflow.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Workflow.java?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Workflow.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/Workflow.java Sat Apr 14 16:29:37 2012
@@ -33,6 +33,16 @@ import java.util.Vector;
* See <a href="http://www.gridbus.org/reports/GridWorkflowTaxonomy.pdf">Buyya
* et al.</a> for a great description in detail of what exactly a Workflow is.
*
+ * <br>
+ * Important note: As of Apache OODT 0.4, Workflows now support both pre- and
+ * post- conditions (as opposed to just pre-conditions, as was the behavior)
+ * before. The methods {@link #getConditions()} and {@link #setConditions(List)} are
+ * now deprecated in favor of their {@link #getPreConditions()} and {@link #setPreConditions(List)}
+ * and {@link #getPostConditions()} and {@link #setPostConditions(List)} counterparts.
+ * The existing condition only methods have been preserved for back compat, but will
+ * go away in later versions of the class and API. Also over the next few releases,
+ * we intend to change the inner APIs to use pre and post conditions.
+ *
*
* @author mattmann
* @version $Revision$
@@ -46,19 +56,22 @@ public class Workflow {
private List<WorkflowTask> tasks;
- private List<WorkflowCondition> conditions;
+ private List<WorkflowCondition> preConditions;
+
+ private List<WorkflowCondition> postConditions;
/**
* Default Constructor
*
*/
public Workflow() {
- this.tasks = new Vector<WorkflowTask>();
- this.conditions = new Vector<WorkflowCondition>();
+ this(null, null, new Vector<WorkflowTask>(), new Vector<WorkflowCondition>(),
+ new Vector<WorkflowCondition>());
}
/**
- * Constructs a new Workflow with the given parameters.
+ * Constructs a new Workflow with the given parameters. Deprecated. Use
+ * {@link #Workflow(String, String, List, List, List)} instead.
*
* @param name
* The name of this workflow.
@@ -72,12 +85,35 @@ public class Workflow {
* The {@link List} of {@link WorkflowCondition}s associated with
* this workflow.
*/
+ @Deprecated
public Workflow(String name, String id, List<WorkflowTask> tasks,
List<WorkflowCondition> conditions) {
+ this(name, id, tasks, conditions,
+ new Vector<WorkflowCondition>());
+ }
+
+ /**
+ *
+ * @param name
+ * The name of the Workflow.
+ * @param id
+ * The identifier of the Workflow.
+ * @param tasks
+ * The associated {@link List} of {@link WorkflowTask}s.
+ * @param preConditions
+ * The associated {@link List} of pre-{@link WorkflowCondition}s.
+ * @param postConditions
+ * The associated {@link List} of post{@link WorkflowCondition}s.
+ */
+ public Workflow(String name, String id, List<WorkflowTask> tasks,
+ List<WorkflowCondition> preConditions,
+ List<WorkflowCondition> postConditions) {
this.name = name;
this.id = id;
this.tasks = tasks;
- this.conditions = conditions;
+ this.preConditions = preConditions;
+ this.postConditions = postConditions;
+
}
/**
@@ -111,18 +147,29 @@ public class Workflow {
}
/**
- * @return the conditions
+ * Deprecated. Currently, this will return a list
+ * of all pre- and post- {@link WorkflowCondition}s.
+ *
+ * @return All pre-and-post conditions.
*/
+ @Deprecated
public List<WorkflowCondition> getConditions() {
- return conditions;
+ List<WorkflowCondition> allConds = new Vector<WorkflowCondition>();
+ allConds.addAll(preConditions);
+ allConds.addAll(this.postConditions);
+ return allConds;
}
/**
+ * Deprecated. Use {@link #setPreConditions(List)} or
+ * {@link #setPostConditions(List)} instead.
+ *
* @param conditions
* the conditions to set
*/
+ @Deprecated
public void setConditions(List<WorkflowCondition> conditions) {
- this.conditions = conditions;
+ this.preConditions = conditions;
}
/**
@@ -140,4 +187,32 @@ public class Workflow {
return tasks;
}
+ /**
+ * @return the preConditions
+ */
+ public List<WorkflowCondition> getPreConditions() {
+ return preConditions;
+ }
+
+ /**
+ * @param preConditions the preConditions to set
+ */
+ public void setPreConditions(List<WorkflowCondition> preConditions) {
+ this.preConditions = preConditions;
+ }
+
+ /**
+ * @return the postConditions
+ */
+ public List<WorkflowCondition> getPostConditions() {
+ return postConditions;
+ }
+
+ /**
+ * @param postConditions the postConditions to set
+ */
+ public void setPostConditions(List<WorkflowCondition> postConditions) {
+ this.postConditions = postConditions;
+ }
+
}
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowInstance.java Sat Apr 14 16:29:37 2012
@@ -17,11 +17,14 @@
package org.apache.oodt.cas.workflow.structs;
-//OODT imports
+//JDK imports
import java.text.ParseException;
import java.util.Date;
+//OODT imports
import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.lifecycle.WorkflowLifecycle;
+import org.apache.oodt.cas.workflow.lifecycle.WorkflowState;
import org.apache.oodt.commons.util.DateConvert;
/**
@@ -30,6 +33,24 @@ import org.apache.oodt.commons.util.Date
* status, and in general are data structures intended to be used as a means for
* monitoring the status of an executing {@link Workflow}.
*
+ * As of Apache OODT 0.4, the internal {@link Workflow} implementation uses
+ * {@link ParentChildWorkflow}, introduced as part of OODT-70, and the
+ * PackagedWorkflowRepository. {@link Workflow} instances given to the class will
+ * automatically convert to {@link ParentChildWorkflow} implementations internally,
+ * and the existing {@link #getWorkflow()} and {@link #setWorkflow(Workflow)} methods
+ * have been depcreated in favor of {@link #getParentChildWorkflow()} and
+ * {@link #setParentChildWorkflow(ParentChildWorkflow)} which will supersede
+ * those methods, and eventually turn into their concrete implementations.
+ *
+ * In addition, as of Apache OODT 0.4 the internal {@link #state} member variable
+ * now uses {@link WorkflowState} for representation. This requires the use of
+ * {@link WorkflowLifecycle} which has now moved from being simply a UI utility
+ * class for the Worklow Monitor web application to actually being fully integrated
+ * with the Workflow Manager. For backwards compatibility the {@link #setStatus(String)}
+ * and {@link #getStatus()} methods are still supported, but are deprecated. Developers
+ * using this class should move towards using {@link #setState(WorkflowState)} and
+ * {@link #getState()}.
+ *
* @author mattmann
* @author bfoster
* @version $Revision$
@@ -37,11 +58,11 @@ import org.apache.oodt.commons.util.Date
*/
public class WorkflowInstance {
- private Workflow workflow;
+ private ParentChildWorkflow workflow;
private String id;
- private String status;
+ private WorkflowState state;
private String currentTaskId;
@@ -56,6 +77,8 @@ public class WorkflowInstance {
private Metadata sharedContext;
private Priority priority;
+
+ private WorkflowLifecycle lifecycle;
/**
* Default Constructor.
@@ -63,15 +86,17 @@ public class WorkflowInstance {
*/
public WorkflowInstance() {
this(null, null, null, null, new Date(), null, null, null, new Metadata(),
- Priority.getDefault());
+ Priority.getDefault(), null);
}
- public WorkflowInstance(Workflow workflow, String id, String status,
+ public WorkflowInstance(Workflow workflow, String id, WorkflowState state,
String currentTaskId, Date startDate, Date endDate, Date taskStartDate,
- Date taskEndDate, Metadata sharedContext, Priority priority) {
- this.workflow = workflow;
+ Date taskEndDate, Metadata sharedContext, Priority priority,
+ WorkflowLifecycle lifecycle) {
+ this.workflow = workflow instanceof ParentChildWorkflow ? (ParentChildWorkflow) workflow
+ : new ParentChildWorkflow(workflow);
this.id = id;
- this.status = status;
+ this.state = state;
this.currentTaskId = currentTaskId;
this.startDate = startDate;
this.endDate = endDate;
@@ -79,6 +104,7 @@ public class WorkflowInstance {
this.taskEndDate = taskEndDate;
this.sharedContext = sharedContext;
this.priority = priority;
+ this.lifecycle = lifecycle;
}
/**
@@ -99,30 +125,73 @@ public class WorkflowInstance {
/**
* @return the status
*/
+ @Deprecated
public String getStatus() {
- return status;
+ return state.getName();
+ }
+
+ /**
+ * Sets the current {@link WorkflowState}
+ * to the provided status.
+ *
+ * @param status The provided status to set.
+ */
+ @Deprecated
+ public void setStatus(String status){
+ this.state = this.lifecycle.getStateByName(status);
+ }
+
+ /**
+ * @return the state
+ */
+ public WorkflowState getState() {
+ return state;
}
/**
- * @param status
- * the status to set
+ * @param state
+ * the state to set
*/
- public void setStatus(String status) {
- this.status = status;
+ public void setState(WorkflowState state) {
+ this.state = state;
}
/**
* @return the workflow
*/
+ @Deprecated
public Workflow getWorkflow() {
- return workflow;
+ return (Workflow) workflow;
}
/**
* @param workflow
* the workflow to set
*/
+ @Deprecated
public void setWorkflow(Workflow workflow) {
+ if (workflow instanceof ParentChildWorkflow) {
+ this.workflow = (ParentChildWorkflow) workflow;
+ } else {
+ this.workflow = new ParentChildWorkflow(workflow);
+ }
+ }
+
+ /**
+ *
+ * @return The workflow, with its parent/child relationships.
+ */
+ public ParentChildWorkflow getParentChildWorkflow() {
+ return this.workflow;
+ }
+
+ /**
+ * Sets the Parent Child workflow.
+ *
+ * @param workflow
+ * The workflow to set.
+ */
+ public void setParentChildWorkflow(ParentChildWorkflow workflow) {
this.workflow = workflow;
}
@@ -201,7 +270,8 @@ public class WorkflowInstance {
}
/**
- * @param startDate the startDate to set
+ * @param startDate
+ * the startDate to set
*/
public void setStartDate(Date startDate) {
this.startDate = startDate;
@@ -215,7 +285,8 @@ public class WorkflowInstance {
}
/**
- * @param endDate the endDate to set
+ * @param endDate
+ * the endDate to set
*/
public void setEndDate(Date endDate) {
this.endDate = endDate;
@@ -229,7 +300,8 @@ public class WorkflowInstance {
}
/**
- * @param taskStartDate the taskStartDate to set
+ * @param taskStartDate
+ * the taskStartDate to set
*/
public void setTaskStartDate(Date taskStartDate) {
this.taskStartDate = taskStartDate;
@@ -243,7 +315,8 @@ public class WorkflowInstance {
}
/**
- * @param taskEndDate the taskEndDate to set
+ * @param taskEndDate
+ * the taskEndDate to set
*/
public void setTaskEndDate(Date taskEndDate) {
this.taskEndDate = taskEndDate;
@@ -254,8 +327,7 @@ public class WorkflowInstance {
*/
@Deprecated
public String getEndDateTimeIsoStr() {
- return this.endDate != null ?
- DateConvert.isoFormat(this.endDate):null;
+ return this.endDate != null ? DateConvert.isoFormat(this.endDate) : null;
}
/**
@@ -277,8 +349,8 @@ public class WorkflowInstance {
*/
@Deprecated
public String getStartDateTimeIsoStr() {
- return this.startDate != null ?
- DateConvert.isoFormat(this.startDate):null;
+ return this.startDate != null ? DateConvert.isoFormat(this.startDate)
+ : null;
}
/**
@@ -300,8 +372,8 @@ public class WorkflowInstance {
*/
@Deprecated
public String getCurrentTaskEndDateTimeIsoStr() {
- return this.taskEndDate != null ?
- DateConvert.isoFormat(this.taskEndDate):null;
+ return this.taskEndDate != null ? DateConvert.isoFormat(this.taskEndDate)
+ : null;
}
/**
@@ -324,8 +396,8 @@ public class WorkflowInstance {
*/
@Deprecated
public String getCurrentTaskStartDateTimeIsoStr() {
- return this.taskStartDate != null ?
- DateConvert.isoFormat(this.taskStartDate):null;
+ return this.taskStartDate != null ? DateConvert
+ .isoFormat(this.taskStartDate) : null;
}
/**
@@ -343,4 +415,18 @@ public class WorkflowInstance {
}
}
+ /**
+ * @return the lifecycle
+ */
+ public WorkflowLifecycle getLifecycle() {
+ return lifecycle;
+ }
+
+ /**
+ * @param lifecycle the lifecycle to set
+ */
+ public void setLifecycle(WorkflowLifecycle lifecycle) {
+ this.lifecycle = lifecycle;
+ }
+
}
Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowTask.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowTask.java?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowTask.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowTask.java Sat Apr 14 16:29:37 2012
@@ -23,12 +23,11 @@ import java.util.List;
import java.util.Vector;
/**
- * @author mattmann
- * @version $Revision$
*
- * <p>
* A Workflow task, or job, or process.
- * </p>
+ *
+ * @author mattmann
+ * @version $Revision$
*
*/
public class WorkflowTask {
@@ -42,8 +41,11 @@ public class WorkflowTask {
/* the static configuration parameters for the task */
protected WorkflowTaskConfiguration taskConfig = null;
- /* the set of ordered conditions on this particular WorkflowTask */
- protected List conditions = null;
+ /* pre conditions for this task */
+ protected List<WorkflowCondition> preConditions = null;
+
+ /* post conditions for this task */
+ protected List<WorkflowCondition> postConditions = null;
/* the actual work performing portion of this WorkflowTask */
protected String taskInstanceClassName = null;
@@ -61,12 +63,20 @@ public class WorkflowTask {
*
*/
public WorkflowTask() {
- conditions = new Vector();
+ this.preConditions = new Vector<WorkflowCondition>();
+ this.postConditions = new Vector<WorkflowCondition>();
requiredMetFields = new Vector();
taskConfig = new WorkflowTaskConfiguration();
}
/**
+ *
+ * This constructor is now deprecated in Apache OODT 0.4, in favor of
+ * {@link #WorkflowTask(String, String, WorkflowTaskConfiguration, List, List, String, int)}
+ * that explicitly specifies pre- and post- {@link WorkflowCondition}s.
+ * As used, this method will set the pre-conditions via the passed in
+ * {@link List} of {@link WorkflowCondition}s only.
+ *
* @param taskId
* The unique ID for this WorkflowTask.
* @param taskName
@@ -81,16 +91,42 @@ public class WorkflowTask {
* The order in which this WorkflowTask is executed within a
* Workflow.
*/
+ @Deprecated
public WorkflowTask(String taskId, String taskName,
WorkflowTaskConfiguration taskConfig, List conditions,
String taskInstanceClassName, int order) {
this.taskId = taskId;
this.taskName = taskName;
this.taskConfig = taskConfig;
- this.conditions = conditions;
+ this.preConditions = conditions;
this.taskInstanceClassName = taskInstanceClassName;
this.order = order;
}
+
+ /**
+ * Constructs a new WorkflowTask.
+ *
+ * @param taskId The identifier for this task.
+ * @param taskName The name for this task.
+ * @param taskConfig The associated {@link WorkflowTaskConfiguration}.
+ * @param preConditions The {@link List} of pre-{@link WorkflowCondition}s.
+ * @param postConditions The {@link List} of post-{@link WorkflowCondition}s.
+ * @param taskInstanceClassName The implementing class name of this WorkflowTask.
+ * @param order The order in which this task should be run.
+ */
+ public WorkflowTask(String taskId, String taskName,
+ WorkflowTaskConfiguration taskConfig, List<WorkflowCondition>
+ preConditions, List<WorkflowCondition> postConditions,
+ String taskInstanceClassName, int order){
+ this.taskId = taskId;
+ this.taskName = taskName;
+ this.taskConfig = taskConfig;
+ this.preConditions = preConditions;
+ this.postConditions = postConditions;
+ this.taskInstanceClassName = taskInstanceClassName;
+ this.order = order;
+
+ }
/**
* @return Returns the taskConfig.
@@ -100,6 +136,34 @@ public class WorkflowTask {
}
/**
+ * @return the preConditions
+ */
+ public List<WorkflowCondition> getPreConditions() {
+ return preConditions;
+ }
+
+ /**
+ * @param preConditions the preConditions to set
+ */
+ public void setPreConditions(List<WorkflowCondition> preConditions) {
+ this.preConditions = preConditions;
+ }
+
+ /**
+ * @return the postConditions
+ */
+ public List<WorkflowCondition> getPostConditions() {
+ return postConditions;
+ }
+
+ /**
+ * @param postConditions the postConditions to set
+ */
+ public void setPostConditions(List<WorkflowCondition> postConditions) {
+ this.postConditions = postConditions;
+ }
+
+ /**
* @param taskConfig
* The taskConfig to set.
*/
@@ -151,26 +215,43 @@ public class WorkflowTask {
public void setTaskName(String taskName) {
this.taskName = taskName;
}
+
+
/**
+ * This method is deprecated in favor of using
+ * {@link #getPreConditions()} or {@link #getPostConditions()}. As called,
+ * will return a union of the Tasks's pre- and post- {@link WorkflowCondition}s.
*
* @return A {@link List} of {@link WorkflowCondition}s associated with
* this task.
*/
+ @Deprecated
public List getConditions() {
+ List conditions = new Vector();
+ conditions.addAll(this.preConditions);
+ conditions.addAll(this.postConditions);
return conditions;
}
/**
- * <p>
+ *
+ * This method is depcreated in favor of {@link #setPostConditions(List)} and
+ * {@link #setPreConditions(List)}, for explicitly setting the pre or post
+ * conditions of this WorkflowTask.
+ *
+ * To keep back compat, this method in its deprecated form will set the
+ * WorkflowTask pre-conditions, as was the case before.
+ *
* Sets the {@link List} of {@link WorkflowCondition}s associated with this
* task.
*
* @param conditions
* The condition {@link List}.
*/
+ @Deprecated
public void setConditions(List conditions) {
- this.conditions = conditions;
+ this.preConditions = conditions;
}
/**
Modified: oodt/trunk/workflow/src/main/resources/examples/wengine/wengine-lifecycle.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/resources/examples/wengine/wengine-lifecycle.xml?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/resources/examples/wengine/wengine-lifecycle.xml (original)
+++ oodt/trunk/workflow/src/main/resources/examples/wengine/wengine-lifecycle.xml Sat Apr 14 16:29:37 2012
@@ -18,40 +18,96 @@ the License.
<!-- FIXME: Change namespace URI? -->
<cas:workflowlifecycles xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas">
<default>
- <stage name="init">
- <status>NULL</status>
- <status>LOADED</status>
- <status>QUEUED</status>
- </stage>
- <stage name="precondition">
- <status>PRECONDITION EVAL</status>
- <status>RUN PRECONDITION</status>
- <status>RESULTS BAIL</status>
- <status>RESULTS BLOCKED</status>
- <status>RESULTS SUCCESS</status>
- <status>RESULTS FAILURE</status>
- <status>PRECONDITION SUCCESS</status>
+ <!-- stages in this sense map to bfoster's original "Category" classification
+ that is mentioned in the Workflow2 User's Guide
+
+ -->
+ <stage name="initial">
+ <!--
+ Statuses can optionally be specified
+ in the form:
+ <status>Name</status>
+
+ To preserve backwards compatibility. In this
+ case, the given description will simply be the
+ provided status name.
+
+ As of Apache OODT 0.4, statuses in this file can
+ also take the form:
+
+ <status name="Name">
+ <description>Description</description>
+ </status>
+ -->
+ <status name="Null">
+ <description>Uninitialized State</description>
+ </status>
+ <status name="Loaded">
+ <description>Loading Complete</description>
+ </status>
+ </stage>
+ <stage name="waiting">
+ <status name="Queued">
+ <description>Queued in WorkflowEngine</description>
+ </status>
+ <status name="Blocked">
+ <description>Task Bailed</description>
+ </status>
+ <status name="WaitingOnResources">
+ <description>Waiting for resource to execute</description>
+ </status>
+ </stage>
+ <stage name="holding">
+ <status name="Unknown">
+ <description>State is Unknown</description>
+ </status>
+ <status name="Paused">
+ <description>Has been manually paused</description>
+ </status>
+ </stage>
+ <stage name="transition">
+ <status name="PreConditionSuccess">
+ <description>All PreCondition Finished Successfully</description>
+ </status>
+ <status name="ExecutionComplete">
+ <description>Execution Completed Successfully</description>
+ </status>
</stage>
<stage name="running">
- <status>READY</status>
- <status>EXECUTING</status>
- <status>BLOCKED</status>
- <status>RESULTS SUCCESS</status>
- <status>RESULTS BAIL</status>
- </stage>
- <stage name="postcondition">
- <status>POSTCONDITION EVAL</status>
- <status>RUN POSTCONDITION</status>
- <status>RESULTS BAIL</status>
- <status>RESULTS BLOCKED</status>
- <status>RESULTS SUCCESS</status>
- <status>RESULTS FAILURE</status>
- <status>POSTCONDITION SUCCESS</status>
- </stage>
- <stage name="final">
- <status>SUCCESS</status>
- <status>OFF</status>
- <status>FAILURE</status>
+ <status name="PreConditionEval">
+ <description>Executing PreConditions</description>
+ </status>
+ <status name="Executing">
+ <description>Current being executed</description>
+ </status>
+ <status name="PostConditionEval">
+ <description>Executing PostConditions</description>
+ </status>
+ </stage>
+ <stage name="done">
+ <status name="Stopped">
+ <description>Force Killed</description>
+ </status>
+ <status name="Off">
+ <description>Turned OFF</description>
+ </status>
+ <status name="Failure">
+ <description>Execution Failed</description>
+ </status>
+ <status name="Success">
+ <description>Successfully Completed</description>
+ </status>
+ </stage>
+ <stage name="results">
+ <status name="ResultsSuccess">
+ <description>Notification of success</description>
+ </status>
+ <status name="ResultsFailure">
+ <description>Notification of failure</description>
+ </status>
+ <status name="ResultsBail">
+ <description>Notification to bail workflow</description>
+ </status>
</stage>
</default>
Modified: oodt/trunk/workflow/src/main/resources/examples/workflow-lifecycle.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/resources/examples/workflow-lifecycle.xml?rev=1326140&r1=1326139&r2=1326140&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/resources/examples/workflow-lifecycle.xml (original)
+++ oodt/trunk/workflow/src/main/resources/examples/workflow-lifecycle.xml Sat Apr 14 16:29:37 2012
@@ -17,6 +17,19 @@ the License.
-->
<!-- FIXME: Change namespace URI? -->
<cas:workflowlifecycles xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas">
+<!--
+ To preserve backwards compatibility. In this
+ case, the given description will simply be the
+ provided status name.
+
+ As of Apache OODT 0.4, statuses in this file can
+ also take the form:
+
+ <status name="Name">
+ <description>Description</description>
+ </status>
+
+ -->
<default>
<stage name="setup">
<status>QUEUED</status>