airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject svn commit: r1488321 - in /airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac: provider/impl/GramProvider.java utils/GramJobSubmissionListener.java
Date Fri, 31 May 2013 17:18:26 GMT
Author: samindaw
Date: Fri May 31 17:18:25 2013
New Revision: 1488321

URL: http://svn.apache.org/r1488321
Log:
saving gram data with the new API

Modified:
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GramJobSubmissionListener.java

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java?rev=1488321&r1=1488320&r2=1488321&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
Fri May 31 17:18:25 2013
@@ -20,6 +20,9 @@
 */
 package org.apache.airavata.gfac.provider.impl;
 
+import java.util.Calendar;
+import java.util.Map;
+
 import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
 import org.apache.airavata.gfac.Constants;
 import org.apache.airavata.gfac.GFacException;
@@ -32,7 +35,8 @@ import org.apache.airavata.gfac.provider
 import org.apache.airavata.gfac.provider.GFacProviderException;
 import org.apache.airavata.gfac.utils.GramJobSubmissionListener;
 import org.apache.airavata.gfac.utils.GramProviderUtils;
-import org.apache.airavata.registry.api.workflow.WorkflowNodeGramData;
+import org.apache.airavata.registry.api.workflow.ApplicationJob;
+import org.apache.airavata.registry.api.workflow.ApplicationJob.ApplicationJobStatus;
 import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
 import org.apache.airavata.schemas.gfac.GlobusHostType;
 import org.globus.gram.GramException;
@@ -42,8 +46,6 @@ import org.ietf.jgss.GSSException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Map;
-
 public class GramProvider implements GFacProvider {
     private static final Logger log = LoggerFactory.getLogger(GramJobSubmissionListener.class);
 
@@ -90,12 +92,27 @@ public class GramProvider implements GFa
            
             String experimentID = (String) jobExecutionContext.getProperty(Constants.PROP_TOPIC);
             String nodeID = (String)jobExecutionContext.getProperty(Constants.PROP_WORKFLOW_NODE_ID);
-            String hostName = jobExecutionContext.getApplicationContext().getHostDescription().getType().getHostName();
-            WorkflowNodeGramData workflowNodeGramData = new WorkflowNodeGramData(experimentID,
nodeID, job.getRSL(),hostName , job.getIDAsString());
+            
+            //WorkflowNodeGramData workflowNodeGramData = new WorkflowNodeGramData(experimentID,
nodeID, job.getRSL(),hostName , job.getIDAsString());;
+            
             try {
             	// for provider test
-            	if(jobExecutionContext.getGFacConfiguration().getAiravataAPI() != null)
-                jobExecutionContext.getGFacConfiguration().getAiravataAPI().getProvenanceManager().updateWorkflowNodeGramData(workflowNodeGramData);
+            	if(jobExecutionContext.getGFacConfiguration().getAiravataAPI() != null){
+            		ApplicationJob appJob = new ApplicationJob();
+                    appJob.setJobId(job.getIDAsString());
+                    appJob.setJobData(job.getRSL());
+                    appJob.setExperimentId(experimentID);
+                    appJob.setWorkflowExecutionId(experimentID);
+                    appJob.setNodeId(nodeID);
+                    appJob.setServiceDescriptionId(jobExecutionContext.getApplicationContext().getServiceDescription().getType().getName());
+                    appJob.setHostDescriptionId(jobExecutionContext.getApplicationContext().getHostDescription().getType().getHostName());
+                    appJob.setApplicationDescriptionId(jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType().getApplicationName().getStringValue());
+                    appJob.setSubmittedTime(Calendar.getInstance().getTime());
+                    appJob.setJobStatus(ApplicationJobStatus.SUBMITTED);
+                    appJob.setStatusUpdateTime(appJob.getSubmittedTime());
+                    jobExecutionContext.getGFacConfiguration().getAiravataAPI().getProvenanceManager().addApplicationJob(appJob);
+            	}
+                //jobExecutionContext.getGFacConfiguration().getAiravataAPI().getProvenanceManager().updateWorkflowNodeGramData(workflowNodeGramData);
             } catch (AiravataAPIInvocationException e) {
                 throw new GFacProviderException(e.getMessage(), e, jobExecutionContext);
             }

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GramJobSubmissionListener.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GramJobSubmissionListener.java?rev=1488321&r1=1488320&r2=1488321&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GramJobSubmissionListener.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GramJobSubmissionListener.java
Fri May 31 17:18:25 2013
@@ -20,10 +20,14 @@
 */
 package org.apache.airavata.gfac.utils;
 
+import java.util.Calendar;
+
+import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
 import org.apache.airavata.gfac.GFacException;
 import org.apache.airavata.gfac.context.JobExecutionContext;
 import org.apache.airavata.gfac.context.security.GSISecurityContext;
 import org.apache.airavata.gfac.notification.events.StatusChangeEvent;
+import org.apache.airavata.registry.api.workflow.ApplicationJob.ApplicationJobStatus;
 import org.globus.gram.GramException;
 import org.globus.gram.GramJob;
 import org.globus.gram.GramJobListener;
@@ -79,6 +83,13 @@ public class GramJobSubmissionListener i
                             break;
                         }
                     } else {
+                    	try {
+                			if (context.getGFacConfiguration().getAiravataAPI()!=null){
+                				context.getGFacConfiguration().getAiravataAPI().getProvenanceManager().updateApplicationJobStatusUpdateTime(job.getIDAsString(),
Calendar.getInstance().getTime());
+                			}
+                		} catch (AiravataAPIInvocationException e) {
+                			e.printStackTrace();
+                		}
                         log.info("job " + job.getIDAsString() + " have same status: "
                                 + GramJob.getStatusAsString(status));
                     }
@@ -91,11 +102,39 @@ public class GramJobSubmissionListener i
         }
     }
 
+    private ApplicationJobStatus getApplicationJobStatus(int gramStatus){
+    	switch(gramStatus){
+    	case GramJob.STATUS_ACTIVE:
+    		return ApplicationJobStatus.EXECUTING;
+    	case GramJob.STATUS_DONE:
+    		return ApplicationJobStatus.FINISHED;
+    	case GramJob.STATUS_FAILED:
+    		return ApplicationJobStatus.FAILED;
+    	case GramJob.STATUS_PENDING:
+    		return ApplicationJobStatus.PENDING;
+    	case GramJob.STATUS_STAGE_IN:
+    		return ApplicationJobStatus.INITIALIZE;
+    	case GramJob.STATUS_STAGE_OUT:
+    		return ApplicationJobStatus.FINALIZE;
+    	case GramJob.STATUS_SUSPENDED:
+    		return ApplicationJobStatus.PAUSED;
+    	default:
+    		return ApplicationJobStatus.UNKNOWN;
+    	}
+    }
+    
     private synchronized boolean isFinished() {
         return this.finished;
     }
 
     private synchronized boolean setStatus(int status, int error) {
+    	try {
+			if (context.getGFacConfiguration().getAiravataAPI()!=null){
+				context.getGFacConfiguration().getAiravataAPI().getProvenanceManager().updateApplicationJobStatus(job.getIDAsString(),
getApplicationJobStatus(status), Calendar.getInstance().getTime());
+			}
+		} catch (AiravataAPIInvocationException e) {
+			e.printStackTrace();
+		}
         this.status = status;
         this.error = error;
 



Mime
View raw message