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 2011/08/10 08:23:17 UTC

svn commit: r1156041 - in /oodt/trunk: ./ workflow/src/main/java/org/apache/oodt/cas/workflow/engine/ workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/ workflow/src/main/java/org/apache/oodt/cas/workflow/repository/ workflow/src/main/java/o...

Author: mattmann
Date: Wed Aug 10 06:23:15 2011
New Revision: 1156041

URL: http://svn.apache.org/viewvc?rev=1156041&view=rev
Log:
- fix for OODT-207: WorkflowConditions should have a timeout 

Added:
    oodt/trunk/workflow/src/main/resources/examples/timeout.workflow.xml   (with props)
Modified:
    oodt/trunk/CHANGES.txt
    oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/WorkflowProcessor.java
    oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepository.java
    oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java
    oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/XMLWorkflowRepository.java
    oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowCondition.java
    oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/DbStructFactory.java
    oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlRpcStructFactory.java
    oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlStructFactory.java
    oodt/trunk/workflow/src/main/resources/examples/conditions.xml
    oodt/trunk/workflow/src/main/resources/examples/events.xml
    oodt/trunk/workflow/src/main/resources/examples/tasks.xml
    oodt/trunk/workflow/src/main/resources/examples/wengine/GranuleMaps.xml
    oodt/trunk/workflow/src/main/resources/examples/wengine/hello-goodbye.xml
    oodt/trunk/workflow/src/main/resources/workflow.sql
    oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/repository/TestPackagedWorkflowRepository.java
    oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/repository/TestWorkflowRepository.java
    oodt/trunk/workflow/src/testdata/workflow.sql

Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Wed Aug 10 06:23:15 2011
@@ -4,6 +4,8 @@ Apache OODT Change Log
 Release 0.4: Current Development
 --------------------------------------------
 
+* OODT-207 WorkflowConditions should have a timeout (mattmann)
+
 * OODT-308 WEditor save feature is not implemented (bfoster via mattmann)
 
 * OODT-296 Workflow Editor GUI (mattmann, bfoster, ahart)

Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/WorkflowProcessor.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/WorkflowProcessor.java?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/WorkflowProcessor.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/WorkflowProcessor.java Wed Aug 10 06:23:15 2011
@@ -21,6 +21,8 @@ package org.apache.oodt.cas.workflow.eng
 import java.net.InetAddress;
 import java.net.URL;
 import java.net.UnknownHostException;
+import java.util.Calendar;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -39,6 +41,8 @@ import org.apache.oodt.cas.workflow.stru
 import org.apache.oodt.cas.workflow.structs.WorkflowTaskInstance;
 import org.apache.oodt.cas.workflow.structs.exceptions.InstanceRepositoryException;
 import org.apache.oodt.cas.workflow.util.GenericWorkflowObjectFactory;
+import org.apache.oodt.commons.date.DateUtils;
+import org.apache.oodt.commons.util.DateConvert;
 
 /**
  * An abstract base class representing the methodology for processing a
@@ -75,6 +79,8 @@ public abstract class WorkflowProcessor 
   protected String currentJobId = null;
 
   protected boolean paused = false;
+  
+  protected Map<String, String> COND_TIMEOUTS = new HashMap<String, String>();
 
   public WorkflowProcessor(WorkflowInstance workflowInstance,
       WorkflowInstanceRepository instRep, URL wParentUrl, long conditionWait) {
@@ -250,6 +256,9 @@ public abstract class WorkflowProcessor 
       String taskId) {
     for (WorkflowCondition c : conditionList) {
       WorkflowConditionInstance cInst = null;
+      if(!COND_TIMEOUTS.containsKey(c.getConditionId())){
+          COND_TIMEOUTS.put(c.getConditionId(), generateISO8601());
+      }
 
       // see if we've already cached this condition instance
       if (CONDITION_CACHE.get(taskId) != null) {
@@ -282,7 +291,8 @@ public abstract class WorkflowProcessor 
       }
 
       // actually perform the evaluation
-      if (!cInst.evaluate(this.workflowInstance.getSharedContext(),
+      if (!timedOut(c) && 
+          !cInst.evaluate(this.workflowInstance.getSharedContext(),
           c.getCondConfig())) {
         return false;
       }
@@ -290,6 +300,41 @@ public abstract class WorkflowProcessor 
 
     return true;
   }
+  
+  protected boolean timedOut(WorkflowCondition condition) {
+    if (condition.getTimeoutSeconds() == -1)
+      return false;
+    String isoStartDateTimeStr = COND_TIMEOUTS.get(condition.getConditionId());
+    Date isoStartDateTime = null;
+    try {
+      isoStartDateTime = DateConvert.isoParse(isoStartDateTimeStr);
+    } catch (Exception e) {
+      e.printStackTrace();
+      LOG.log(Level.WARNING, "Unable to parse start date time for condition: ["
+          + condition.getConditionId() + "]: start date time: ["
+          + isoStartDateTimeStr + "]: Reason: " + e.getMessage());
+      return false;
+    }
+    Date now = new Date();
+    long numSecondsElapsed = (now.getTime() - isoStartDateTime.getTime()) / (1000);
+    if (numSecondsElapsed >= condition.getTimeoutSeconds()) {
+      LOG.log(
+          Level.INFO,
+          "Condition: [" + condition.getConditionName()
+              + "]: exceeded timeout threshold of: ["
+              + condition.getTimeoutSeconds() + "] seconds: elapsed time: ["
+              + numSecondsElapsed + "]");
+      return true;
+    } else{
+      LOG.log(
+          Level.FINEST,
+          "Condition: [" + condition.getConditionName()
+              + "]: has not exceeded timeout threshold of: ["
+              + condition.getTimeoutSeconds() + "] seconds: elapsed time: ["
+              + numSecondsElapsed + "]");      
+      return false;
+    }
+  }
 
   protected String getTaskNameById(String taskId) {
     for (WorkflowTask task : (List<WorkflowTask>) (List<?>) this.workflowInstance
@@ -313,5 +358,9 @@ public abstract class WorkflowProcessor 
     }
     return null;
   }
+  
+  private String generateISO8601(){
+    return DateConvert.isoFormat(new Date());
+  }
 
 }

Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepository.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepository.java?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepository.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/instrepo/LuceneWorkflowInstanceRepository.java Wed Aug 10 06:23:15 2011
@@ -585,25 +585,24 @@ public class LuceneWorkflowInstanceRepos
         }
     }
 
-    private void addConditionsToDoc(String taskId, List conditionList,
-            Document doc) {
-        if (conditionList != null && conditionList.size() > 0) {
-            for (Iterator i = conditionList.iterator(); i.hasNext();) {
-                WorkflowCondition cond = (WorkflowCondition) i.next();
-                doc.add(new Field(taskId + "_condition_name", cond
-                        .getConditionName(), Field.Store.YES, Field.Index.NO));
-                doc.add(new Field(taskId + "_condition_id", cond
-                        .getConditionId(), Field.Store.YES,
-                        Field.Index.UN_TOKENIZED));
-                doc.add(new Field(taskId + "_condition_class", cond
-                        .getConditionInstanceClassName(), Field.Store.YES,
-                        Field.Index.NO));
-                doc.add(new Field(taskId + "_condition_order", String
-                        .valueOf(cond.getOrder()), Field.Store.YES,
-                        Field.Index.NO));
-            }
-        }
+  private void addConditionsToDoc(String taskId, List conditionList,
+      Document doc) {
+    if (conditionList != null && conditionList.size() > 0) {
+      for (Iterator i = conditionList.iterator(); i.hasNext();) {
+        WorkflowCondition cond = (WorkflowCondition) i.next();
+        doc.add(new Field(taskId + "_condition_name", cond.getConditionName(),
+            Field.Store.YES, Field.Index.NO));
+        doc.add(new Field(taskId + "_condition_id", cond.getConditionId(),
+            Field.Store.YES, Field.Index.UN_TOKENIZED));
+        doc.add(new Field(taskId + "_condition_class", cond
+            .getConditionInstanceClassName(), Field.Store.YES, Field.Index.NO));
+        doc.add(new Field(taskId + "_condition_order", String.valueOf(cond
+            .getOrder()), Field.Store.YES, Field.Index.NO));
+        doc.add(new Field(taskId + "_condition_timeout", String.valueOf(cond
+            .getTimeoutSeconds()), Field.Store.YES, Field.Index.NO));
+      }
     }
+  }
 
     private WorkflowInstance toWorkflowInstance(Document doc) {
         WorkflowInstance inst = new WorkflowInstance();
@@ -712,6 +711,7 @@ public class LuceneWorkflowInstanceRepos
         String[] condClasses = doc.getValues(taskId + "_condition_class");
         String[] condOrders = doc.getValues(taskId + "_condition_order");
         String[] condIds = doc.getValues(taskId + "_condition_id");
+        String[] condTimeouts = doc.getValues(taskId+"_condition_timeout");
 
         if (condNames == null) {
             return condList;
@@ -719,7 +719,8 @@ public class LuceneWorkflowInstanceRepos
 
         if (condNames.length != condClasses.length
                 || condNames.length != condOrders.length
-                || condNames.length != condIds.length) {
+                || condNames.length != condIds.length 
+                || condNames.length != condTimeouts.length) {
             LOG.log(Level.WARNING,
                     "Condition arrays are not of same size when "
                             + "rebuilding from given Document");
@@ -732,6 +733,7 @@ public class LuceneWorkflowInstanceRepos
             cond.setConditionInstanceClassName(condClasses[i]);
             cond.setConditionName(condNames[i]);
             cond.setOrder(Integer.parseInt(condOrders[i]));
+            cond.setTimeoutSeconds(Long.parseLong(condTimeouts[i]));
         }
 
         return condList;

Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/PackagedWorkflowRepository.java Wed Aug 10 06:23:15 2011
@@ -496,6 +496,7 @@ public class PackagedWorkflowRepository 
         cond.setConditionId(graph.getModelId());
         cond.setConditionName(graph.getModelName());
         cond.setConditionInstanceClassName(graph.getClazz());
+        cond.setTimeoutSeconds(graph.getTimeout());
         cond.setCondConfig(convertToConditionConfiguration(staticMetadata));
 
         if (cond.getConditionName() == null
@@ -564,7 +565,9 @@ public class PackagedWorkflowRepository 
   }
 
   private ParentChildWorkflow getDynamicWorkflow(WorkflowTask task) {
-    ParentChildWorkflow workflow = new ParentChildWorkflow(new Graph());
+    Graph graph = new Graph();
+    graph.setExecutionType("sequential");
+    ParentChildWorkflow workflow = new ParentChildWorkflow(graph);
     workflow.setId("parallel-" + UUID.randomUUID().toString());
     workflow.setName("Parallel Single Task " + task.getTaskName());
     workflow.getTasks().add(task);
@@ -644,6 +647,8 @@ public class PackagedWorkflowRepository 
     private List<String> excused;
 
     private String clazz;
+    
+    private long timeout;
 
     private Graph parent;
 
@@ -660,6 +665,9 @@ public class PackagedWorkflowRepository 
       this.alias = graphElem.getAttribute("alias");
       this.minReqSuccessfulSubProcessors = graphElem.getAttribute("min");
       this.executionType = graphElem.getAttribute("execution");
+      this.timeout = Long.valueOf(graphElem.getAttribute("timeout") != null 
+          && !graphElem.getAttribute("timeout").equals("") ? 
+              graphElem.getAttribute("timeout"):"-1");
 
       NamedNodeMap attrMap = graphElem.getAttributes();
       for (int i = 0; i < attrMap.getLength(); i++) {
@@ -705,6 +713,7 @@ public class PackagedWorkflowRepository 
       this.clazz = null;
       this.children = new Vector<Graph>();
       this.parent = null;
+      this.timeout = -1;
     }
 
     /**
@@ -907,6 +916,20 @@ public class PackagedWorkflowRepository 
       return this.modelId;
     }
 
+    /**
+     * @return the timeout
+     */
+    public long getTimeout() {
+      return timeout;
+    }
+
+    /**
+     * @param timeout the timeout to set
+     */
+    public void setTimeout(long timeout) {
+      this.timeout = timeout;
+    }
+
   }
 
   private class ParentChildWorkflow extends Workflow {
@@ -924,7 +947,7 @@ public class PackagedWorkflowRepository 
       buf.append(",name=");
       buf.append(this.getName());
       buf.append(",parent=");
-      buf.append(this.graph.parent.modelId);
+      buf.append(this.graph.parent != null ? this.graph.parent.modelId:null);
       buf.append(",children=");
       buf.append(this.graph.children);
       buf.append(",executionType=");
@@ -949,6 +972,8 @@ public class PackagedWorkflowRepository 
           buf.append(cond.getConditionId());
           buf.append(",instanceClass=");
           buf.append(cond.getConditionInstanceClassName());
+          buf.append(",timeout=");
+          buf.append(cond.getTimeoutSeconds());
           buf.append(",config=");
           buf.append(cond.getCondConfig().getProperties());
           buf.append("]");

Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/XMLWorkflowRepository.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/XMLWorkflowRepository.java?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/XMLWorkflowRepository.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/repository/XMLWorkflowRepository.java Wed Aug 10 06:23:15 2011
@@ -319,7 +319,8 @@ public class XMLWorkflowRepository imple
                         System.out.println("Condition: ["
                                 + condition.getClass().getName() + ", id="
                                 + condition.getConditionId() + ", name="
-                                + condition.getConditionName() + ", order="
+                                + condition.getConditionName() + ", timeout="
+                                + condition.getTimeoutSeconds()+ ", order="
                                 + condition.getOrder() + "]");
                         
                         System.out.println("Configuration: ");

Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowCondition.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowCondition.java?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowCondition.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/WorkflowCondition.java Wed Aug 10 06:23:15 2011
@@ -43,6 +43,8 @@ public class WorkflowCondition {
 
   /* the static configuration parameters for the condition */
   protected WorkflowConditionConfiguration condConfig;
+  
+  private long timeoutSeconds;
 
   /**
    * <p>
@@ -76,6 +78,7 @@ public class WorkflowCondition {
     this.conditionId = conditionId;
     this.conditionInstanceClassName = instanceClass;
     this.order = order;
+    this.timeoutSeconds = -1;
     this.condConfig = new WorkflowConditionConfiguration();
   }
 
@@ -163,4 +166,18 @@ public class WorkflowCondition {
     this.order = order;
   }
 
+  /**
+   * @return the timeoutSeconds
+   */
+  public long getTimeoutSeconds() {
+    return timeoutSeconds;
+  }
+
+  /**
+   * @param timeoutSeconds the timeoutSeconds to set
+   */
+  public void setTimeoutSeconds(long timeoutSeconds) {
+    this.timeoutSeconds = timeoutSeconds;
+  }
+
 }

Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/DbStructFactory.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/DbStructFactory.java?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/DbStructFactory.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/DbStructFactory.java Wed Aug 10 06:23:15 2011
@@ -107,6 +107,7 @@ public final class DbStructFactory {
             condition.setConditionId(String.valueOf(rs
                     .getInt("workflow_condition_id")));
             condition.setConditionName(rs.getString("workflow_condition_name"));
+            condition.setTimeoutSeconds(rs.getLong("workflow_condition_timeout"));
             if (setOrder) {
                 condition.setOrder(rs.getInt("condition_order"));
             }

Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlRpcStructFactory.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlRpcStructFactory.java?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlRpcStructFactory.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlRpcStructFactory.java Wed Aug 10 06:23:15 2011
@@ -367,6 +367,7 @@ public final class XmlRpcStructFactory {
         condition.put("id", c.getConditionId());
         condition.put("name", c.getConditionName());
         condition.put("order", String.valueOf(c.getOrder()));
+        condition.put("timeout", String.valueOf(c.getTimeoutSeconds()));
         condition.put("configuration", getXmlRpcWorkflowConditionConfig(c.getCondConfig()));
         return condition;
 
@@ -481,6 +482,7 @@ public final class XmlRpcStructFactory {
         condition.setConditionName((String) cond.get("name"));
         condition.setOrder(Integer.valueOf((String) cond.get("order"))
                 .intValue());
+        condition.setTimeoutSeconds(Long.valueOf((String)cond.get("timeout")));
         condition.setCondConfig(getWorkflowConditionConfigurationFromXmlRpc((Hashtable)cond.get("configuration")));
         return condition;
     }

Modified: oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlStructFactory.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlStructFactory.java?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlStructFactory.java (original)
+++ oodt/trunk/workflow/src/main/java/org/apache/oodt/cas/workflow/util/XmlStructFactory.java Wed Aug 10 06:23:15 2011
@@ -161,6 +161,7 @@ public final class XmlStructFactory {
                         workflowCondition.setConditionName(condition
                                 .getConditionName());
                         workflowCondition.setOrder(i + 1);
+                        workflowCondition.setTimeoutSeconds(condition.getTimeoutSeconds());
                         workflowCondition.setCondConfig(condition.getTaskConfig());
                         conditionList.add(workflowCondition);
                     }
@@ -203,7 +204,10 @@ public final class XmlStructFactory {
         condition.setConditionInstanceClassName(conditionClassName);
         condition.setConditionId(conditionElement.getAttribute("id"));
         condition.setConditionName(conditionElement.getAttribute("name"));
-        
+        condition.setTimeoutSeconds(Long.valueOf(conditionElement.getAttribute("timeout") != null && 
+            !conditionElement.getAttribute("timeout").equals("")
+            ? conditionElement.getAttribute("timeout"):"-1"));
+
         // load its configuration
         Element configElement = getFirstElement("configuration", conditionElement);
         if (configElement != null) {

Modified: oodt/trunk/workflow/src/main/resources/examples/conditions.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/resources/examples/conditions.xml?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/resources/examples/conditions.xml (original)
+++ oodt/trunk/workflow/src/main/resources/examples/conditions.xml Wed Aug 10 06:23:15 2011
@@ -23,4 +23,5 @@
             <property name="reqMetKeys" value="Met1,Met2,Met3"/>
         </configuration>
     </condition>
+    <condition id="urn:oodt:TimeoutCondition" name="Timeout Condition" class="org.apache.oodt.cas.workflow.examples.FalseCondition" timeout="30"/>
 </cas:conditions>

Modified: oodt/trunk/workflow/src/main/resources/examples/events.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/resources/examples/events.xml?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/resources/examples/events.xml (original)
+++ oodt/trunk/workflow/src/main/resources/examples/events.xml Wed Aug 10 06:23:15 2011
@@ -40,6 +40,9 @@
 	<event name="metError">
 		<workflow id="urn:oodt:testMetErrorWorkflow" />
 	</event>
+	<event name="timeout">
+	    <workflow id="urn:oodt:timeoutWorkflow"/>
+	</event>
     <event name="GenericFileIngest">
        <workflow id="urn:oodt:mailWorkflow"/>
     </event>

Modified: oodt/trunk/workflow/src/main/resources/examples/tasks.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/resources/examples/tasks.xml?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/resources/examples/tasks.xml (original)
+++ oodt/trunk/workflow/src/main/resources/examples/tasks.xml Wed Aug 10 06:23:15 2011
@@ -113,4 +113,14 @@
 			<property name="mail.from" value="oodt@jpl.nasa.gov"/>
 		</configuration>
 	</task>	
+	<task id="urn:oodt:TestTimeoutTask" name="Test Timeout"
+		class="org.apache.oodt.cas.workflow.examples.LongTask">
+		<conditions>
+		   <condition id="urn:oodt:TimeoutCondition"/>
+		</conditions>
+		<configuration />
+		<requiredMetFields>
+			<metfield name="numSeconds" />
+		</requiredMetFields>
+	</task>	
 </cas:tasks>

Added: oodt/trunk/workflow/src/main/resources/examples/timeout.workflow.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/resources/examples/timeout.workflow.xml?rev=1156041&view=auto
==============================================================================
--- oodt/trunk/workflow/src/main/resources/examples/timeout.workflow.xml (added)
+++ oodt/trunk/workflow/src/main/resources/examples/timeout.workflow.xml Wed Aug 10 06:23:15 2011
@@ -0,0 +1,21 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<cas:workflow xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas" name="Timeout Workflow" id="urn:oodt:timeoutWorkflow">
+ <tasks>
+   <task id="urn:oodt:TestTimeoutTask"/>
+ </tasks>
+</cas:workflow>

Propchange: oodt/trunk/workflow/src/main/resources/examples/timeout.workflow.xml
------------------------------------------------------------------------------
    svn:executable = *

Modified: oodt/trunk/workflow/src/main/resources/examples/wengine/GranuleMaps.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/resources/examples/wengine/GranuleMaps.xml?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/resources/examples/wengine/GranuleMaps.xml (original)
+++ oodt/trunk/workflow/src/main/resources/examples/wengine/GranuleMaps.xml Wed Aug 10 06:23:15 2011
@@ -89,7 +89,7 @@
 
 
 	<!-- CONDITIONS -->
-	<condition id="urn:npp:MOA_IASI_L1C_Daily" name="MOA_IASI_L1C_Daily" class="org.apache.oodt.cas.pge.condition.PGETaskWorkflowCondition">
+	<condition id="urn:npp:MOA_IASI_L1C_Daily" name="MOA_IASI_L1C_Daily" class="org.apache.oodt.cas.pge.condition.PGETaskWorkflowCondition" timeout="30">
 		<configuration>
 			<!-- query properties -->
 			<property name="PGETask/Condition/ProductTypeNames" value="MOA_IASI_L1C"/>

Modified: oodt/trunk/workflow/src/main/resources/examples/wengine/hello-goodbye.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/resources/examples/wengine/hello-goodbye.xml?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/resources/examples/wengine/hello-goodbye.xml (original)
+++ oodt/trunk/workflow/src/main/resources/examples/wengine/hello-goodbye.xml Wed Aug 10 06:23:15 2011
@@ -137,6 +137,8 @@
 			<property name="reqMetKeys" value="Met1,Met2,Met3" />
 		</configuration>
 	</condition>
+	<condition id="urn:oodt:TimeoutCondition" name="Timeout Condition" 
+	    class="org.apache.oodt.cas.workflow.examples.FalseCondition" timeout="30"/>
 
 
 

Modified: oodt/trunk/workflow/src/main/resources/workflow.sql
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/main/resources/workflow.sql?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/main/resources/workflow.sql (original)
+++ oodt/trunk/workflow/src/main/resources/workflow.sql Wed Aug 10 06:23:15 2011
@@ -62,7 +62,8 @@ workflow_met_val varchar(1000) NOT NULL)
 CREATE TABLE workflow_conditions
 (workflow_condition_id int NOT NULL PRIMARY KEY,
 workflow_condition_name varchar(255) NOT NULL,
-workflow_condition_class varchar(255) NOT NULL);
+workflow_condition_class varchar(255) NOT NULL,
+workflow_condition_timeout int);
 
 CREATE TABLE workflow_condition_map
 (workflow_task_id int NOT NULL, 

Modified: oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/repository/TestPackagedWorkflowRepository.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/repository/TestPackagedWorkflowRepository.java?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/repository/TestPackagedWorkflowRepository.java (original)
+++ oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/repository/TestPackagedWorkflowRepository.java Wed Aug 10 06:23:15 2011
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.oodt.cas.workflow.structs.Workflow;
+import org.apache.oodt.cas.workflow.structs.WorkflowCondition;
 
 //Junit imports
 import junit.framework.TestCase;
@@ -94,6 +95,23 @@ public class TestPackagedWorkflowReposit
     assertTrue(foundThree);
     assertTrue(foundFour);
   }
+  
+  /**
+   * @since OODT-207
+   */
+  public void testGetConditionTimeout(){
+    WorkflowCondition cond = null;
+    try{
+      cond = this.repo.getWorkflowConditionById("urn:npp:MOA_IASI_L1C_Daily");
+    }
+    catch(Exception e){
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+    
+    assertNotNull(cond);
+    assertEquals(30L, cond.getTimeoutSeconds());
+  }
 
   /*
    * (non-Javadoc)

Modified: oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/repository/TestWorkflowRepository.java
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/repository/TestWorkflowRepository.java?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/repository/TestWorkflowRepository.java (original)
+++ oodt/trunk/workflow/src/test/org/apache/oodt/cas/workflow/repository/TestWorkflowRepository.java Wed Aug 10 06:23:15 2011
@@ -99,7 +99,7 @@ public class TestWorkflowRepository exte
         }
 
         assertNotNull(workflows);
-        assertEquals(8, workflows.size());
+        assertEquals(9, workflows.size());
     }
 
     public void testGetWorkflowsForEvent() {
@@ -192,6 +192,22 @@ public class TestWorkflowRepository exte
 
         validateTaskCondition(conditions);
     }
+    
+    /**
+     * @since OODT-207
+     */
+    public void testGetConditionTimeout(){
+      WorkflowCondition cond = null;
+      try{
+        cond = workflowRepository.getWorkflowConditionById("urn:oodt:TimeoutCondition");
+      }
+      catch(Exception e){
+        e.printStackTrace();
+        fail(e.getMessage());
+      }
+      
+      assertEquals(30L, cond.getTimeoutSeconds());
+    }
 
     public void testGetConfigurationByTaskId() {
         WorkflowTaskConfiguration config = null;
@@ -328,6 +344,7 @@ public class TestWorkflowRepository exte
         assertEquals("urn:oodt:TrueCondition", c.getConditionId());
         assertEquals("True Condition", c.getConditionName());
         assertEquals(1, c.getOrder());
+        assertEquals(-1L, c.getTimeoutSeconds());
     }
 
     private void validateTaskConfiguration(WorkflowTaskConfiguration config) {

Modified: oodt/trunk/workflow/src/testdata/workflow.sql
URL: http://svn.apache.org/viewvc/oodt/trunk/workflow/src/testdata/workflow.sql?rev=1156041&r1=1156040&r2=1156041&view=diff
==============================================================================
--- oodt/trunk/workflow/src/testdata/workflow.sql (original)
+++ oodt/trunk/workflow/src/testdata/workflow.sql Wed Aug 10 06:23:15 2011
@@ -46,7 +46,8 @@ workflow_met_val varchar(1000) NOT NULL)
 CREATE TABLE workflow_conditions
 (workflow_condition_id int NOT NULL PRIMARY KEY,
 workflow_condition_name varchar(255) NOT NULL,
-workflow_condition_class varchar(255) NOT NULL);
+workflow_condition_class varchar(255) NOT NULL,
+workflow_condition_timeout int NOT NULL);
 
 CREATE TABLE workflow_condition_map
 (workflow_task_id int NOT NULL, 
@@ -63,7 +64,7 @@ CREATE TABLE workflow_condition_configur
 property_name varchar(1000) NOT NULL,
 property_value varchar(1000) NOT NULL);
 
-INSERT INTO workflow_conditions VALUES ('1', 'CheckCond', 'org.apache.oodt.cas.workflow.examples.CheckForMetadataKeys');
+INSERT INTO workflow_conditions VALUES ('1', 'CheckCond', 'org.apache.oodt.cas.workflow.examples.CheckForMetadataKeys', 30);
 INSERT INTO workflow_condition_configuration VALUES ('1', 'reqMetKeys', 'Met1,Met2,Met3');
-INSERT INTO workflow_conditions VALUES ('2', 'FalseCond', 'org.apache.oodt.cas.workflow.examples.FalseCondition');
-INSERT INTO workflow_conditions VALUES ('3', 'TrueCond', 'org.apache.oodt.cas.workflow.examples.TrueCondition');
+INSERT INTO workflow_conditions VALUES ('2', 'FalseCond', 'org.apache.oodt.cas.workflow.examples.FalseCondition', 10);
+INSERT INTO workflow_conditions VALUES ('3', 'TrueCond', 'org.apache.oodt.cas.workflow.examples.TrueCondition', 30);