oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattm...@apache.org
Subject [54/88] [abbrv] oodt git commit: OODT-212: Begin to implement Rollback of Workflows per sherylj. Review https://reviews.apache.org/r/4790/.
Date Mon, 17 Jul 2017 23:06:09 GMT
OODT-212: Begin to implement Rollback of Workflows per sherylj. Review https://reviews.apache.org/r/4790/.


Project: http://git-wip-us.apache.org/repos/asf/oodt/repo
Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/d24ec749
Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/d24ec749
Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/d24ec749

Branch: refs/heads/feature/zookeeper-config
Commit: d24ec749118ed0aeb5846f3e6e60c467443db1a4
Parents: ad29238
Author: Chris Mattmann <mattmann@apache.org>
Authored: Sun Jul 16 11:08:26 2017 -0700
Committer: Chris Mattmann <mattmann@apache.org>
Committed: Sun Jul 16 11:08:26 2017 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +
 .../RollbackableWorkflowTaskInstance.java       | 75 ++++++++++++++++++++
 2 files changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oodt/blob/d24ec749/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ccdeadf..2a614e5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,6 +3,8 @@ Apache OODT Change Log
 
 Release 1.1 - Current Development
 
+* OODT-212 Rollback capability for Workflows (sherylj via mattmann)
+
 * OODT-836, OODT-837 Remove Non-Essential Components (mattmann, mdstarch, magicaltrout)
 
 * OODT-213 Reading/Writing API for XML-based Workflow Task policy (mattmann)

http://git-wip-us.apache.org/repos/asf/oodt/blob/d24ec749/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/RollbackableWorkflowTaskInstance.java
----------------------------------------------------------------------
diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/RollbackableWorkflowTaskInstance.java
b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/RollbackableWorkflowTaskInstance.java
new file mode 100644
index 0000000..3759570
--- /dev/null
+++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/structs/RollbackableWorkflowTaskInstance.java
@@ -0,0 +1,75 @@
+package org.apache.oodt.cas.workflow.structs;
+
+//JDK imports
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.metadata.CoreMetKeys;
+import org.apache.oodt.cas.workflow.structs.exceptions.WorkflowTaskInstanceException;
+import org.apache.oodt.cas.workflow.system.XmlRpcWorkflowManagerClient;
+
+public abstract class RollbackableWorkflowTaskInstance implements
+    WorkflowTaskInstance {
+  
+  protected XmlRpcWorkflowManagerClient wmc; 
+  protected String workflowInstId;
+  
+  public void run(Metadata metadata, WorkflowTaskConfiguration config)
+      throws WorkflowTaskInstanceException {
+    
+    workflowInstId = getWorkflowInstanceId(metadata);
+    wmc = createWorkflowMangerClient(metadata);
+    
+    
+    //clean generated metadata 
+    clearAllMetadata(metadata);
+    
+    //Determine next workflow state
+    updateState(metadata);
+    
+    //clean up task instance from instance rep?
+    clearInstRep();
+
+  }
+  
+  protected String getWorkflowInstanceId(Metadata metadata) {
+    
+	String instId = metadata.getMetadata(CoreMetKeys.WORKFLOW_INST_ID);  
+    return instId;
+    
+  }
+  
+  protected XmlRpcWorkflowManagerClient createWorkflowMangerClient(Metadata metadata) {
+    URL url;
+    try {
+      url = new URL(metadata.getMetadata(CoreMetKeys.WORKFLOW_MANAGER_URL));
+      wmc = new XmlRpcWorkflowManagerClient(url);
+     
+    } catch (MalformedURLException e) {
+      e.printStackTrace();
+    }
+    return wmc;
+  }
+
+  protected void clearAllMetadata(Metadata metadata) {
+  
+    List<String> keys =  metadata.getAllKeys();
+    
+    //remove metadata for each key
+    for(String key: keys) {
+      metadata.removeMetadata(key);
+    }  
+    try {
+      wmc.updateMetadataForWorkflow(workflowInstId, metadata);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+  
+  public abstract void updateState(Metadata metadata);
+  
+  public abstract void clearInstRep();
+}


Mime
View raw message