airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject airavata git commit: implemented getProcessType(pc) method in GFacWorker
Date Wed, 24 Jun 2015 16:58:12 GMT
Repository: airavata
Updated Branches:
  refs/heads/master adab9dda6 -> a393b735e


implemented getProcessType(pc) method in GFacWorker


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

Branch: refs/heads/master
Commit: a393b735e4a03bf3b663c31c7429a7ea19f2b708
Parents: adab9dd
Author: Shameera Rathanyaka <shameerainfo@gmail.com>
Authored: Wed Jun 24 12:58:07 2015 -0400
Committer: Shameera Rathanyaka <shameerainfo@gmail.com>
Committed: Wed Jun 24 12:58:07 2015 -0400

----------------------------------------------------------------------
 .../gfac/core/context/ProcessContext.java       |  6 +++
 .../apache/airavata/gfac/impl/GFacWorker.java   | 47 +++++++++++++++++++-
 2 files changed, 51 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/a393b735/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
index 3f8cf02..a3796d4 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
@@ -33,6 +33,7 @@ import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePrefer
 import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
 import org.apache.airavata.model.job.JobModel;
 import org.apache.airavata.model.process.ProcessModel;
+import org.apache.airavata.model.status.ProcessState;
 import org.apache.airavata.registry.cpi.AppCatalog;
 import org.apache.airavata.registry.cpi.ExperimentCatalog;
 import org.apache.curator.framework.CuratorFramework;
@@ -260,4 +261,9 @@ public class ProcessContext {
 	public void setComputeResourcePreference(ComputeResourcePreference computeResourcePreference)
{
 		this.computeResourcePreference = computeResourcePreference;
 	}
+
+	public ProcessState getProcessState() {
+		return processModel.getProcessStatus().getState();
+	}
+
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/a393b735/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacWorker.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacWorker.java
b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacWorker.java
index 63f0088..475e8a8 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacWorker.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacWorker.java
@@ -35,14 +35,29 @@ public class GFacWorker implements Runnable {
 	private String processId;
 	private String gatewayId;
 	private String tokenId;
+	private boolean isProcessContextPopulated = false;
 
 
+	/**
+	 * This will be called by monitoring service.
+	 * @param processContext
+	 * @throws GFacException
+	 */
     public   GFacWorker(ProcessContext processContext) throws GFacException {
         if (processContext == null) {
             throw new GFacException("Worker must initialize with valide processContext, Process
context is null");
         }
 	    this.processContext = processContext;
     }
+
+	/**
+	 * This constructor will be called when new or recovery request comes.
+	 * @param experimentId
+	 * @param processId
+	 * @param gatewayId
+	 * @param tokenId
+	 * @throws GFacException
+	 */
 	public GFacWorker(String experimentId, String processId, String gatewayId, String tokenId)
throws GFacException {
 		this.experimentId = experimentId;
 		this.processId = processId;
@@ -57,6 +72,7 @@ public class GFacWorker implements Runnable {
 		    ProcessType type = getProcessType(processContext);
 		    if (processContext == null) {
 			    processContext = engine.populateProcessContext(experimentId, processId, gatewayId,
tokenId);
+			    isProcessContextPopulated = true;
 		    }
 		    try {
 			    switch (type) {
@@ -100,7 +116,33 @@ public class GFacWorker implements Runnable {
 
 	private ProcessType getProcessType(ProcessContext processContext) {
 		// check the status and return correct type of process.
-		return ProcessType.NEW;
+		switch (processContext.getProcessState()) {
+			case CREATED:
+			case VALIDATED:
+				return ProcessType.NEW;
+			case PRE_PROCESSING:
+			case CONFIGURING_WORKSPACE:
+			case INPUT_DATA_STAGING:
+			case EXECUTING:
+				return ProcessType.RECOVER;
+			case MONITORING:
+				if (isProcessContextPopulated) {
+					return ProcessType.RECOVER; // hand over to monitor task
+				} else {
+					return ProcessType.OUTFLOW; // execute outflow
+				}
+			case OUTPUT_DATA_STAGING:
+			case POST_PROCESSING:
+				return ProcessType.RECOVER_OUTFLOW;
+			case COMPLETED:
+			case CANCELED:
+			case FAILED:
+				return ProcessType.COMPLETED;
+			//case CANCELLING: // TODO: handle this
+			default:
+				// this will never hit as we have handle all states in cases.
+				return ProcessType.NEW;
+		}
 	}
 
 
@@ -108,6 +150,7 @@ public class GFacWorker implements Runnable {
 		NEW,
 		RECOVER,
 		OUTFLOW,
-		RECOVER_OUTFLOW
+		RECOVER_OUTFLOW,
+		COMPLETED
 	}
 }


Mime
View raw message