airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject [6/8] changing package names of gfac implementations
Date Mon, 05 May 2014 14:44:30 GMT
http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/util/GramRSLGenerator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/util/GramRSLGenerator.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/util/GramRSLGenerator.java
new file mode 100644
index 0000000..f8a7502
--- /dev/null
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/util/GramRSLGenerator.java
@@ -0,0 +1,211 @@
+/*
+ *
+ * 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.
+ *
+*/
+package org.apache.airavata.gfac.gram.util;
+
+import org.apache.airavata.common.utils.StringUtil;
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.MappingFactory;
+import org.apache.airavata.gfac.Constants;
+import org.apache.airavata.gfac.ToolsException;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.provider.GFacProviderException;
+import org.apache.airavata.model.workspace.experiment.ComputationalResourceScheduling;
+import org.apache.airavata.model.workspace.experiment.TaskDetails;
+import org.apache.airavata.schemas.gfac.*;
+import org.globus.gram.GramAttributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+public class GramRSLGenerator {
+    protected static final Logger log = LoggerFactory.getLogger(GramRSLGenerator.class);
+
+    private enum JobType {
+        SERIAL, SINGLE, MPI, MULTIPLE, CONDOR
+    }
+
+    ;
+
+    public static GramAttributes  configureRemoteJob(JobExecutionContext context) throws ToolsException {
+        HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) context.getApplicationContext().getApplicationDeploymentDescription().getType();
+        GramAttributes jobAttr = new GramAttributes();
+        jobAttr.setExecutable(app.getExecutableLocation());
+        jobAttr.setDirectory(app.getStaticWorkingDirectory());
+        jobAttr.setStdout(app.getStandardOutput());
+        jobAttr.setStderr(app.getStandardError());
+        /*
+         * The env here contains the env of the host and the application. i.e the env specified in the host description
+         * and application description documents
+         */
+        NameValuePairType[] env = app.getApplicationEnvironmentArray();
+        if (env.length != 0) {
+            Map<String, String> nv = new HashMap<String, String>();
+            for (int i = 0; i < env.length; i++) {
+                String key = env[i].getName();
+                String value = env[i].getValue();
+                nv.put(key, value);
+            }
+
+            for (Map.Entry<String, String> entry : nv.entrySet()) {
+                jobAttr.addEnvVariable(entry.getKey(), entry.getValue());
+            }
+        }
+        jobAttr.addEnvVariable(Constants.INPUT_DATA_DIR_VAR_NAME, app.getInputDataDirectory());
+        jobAttr.addEnvVariable(Constants.OUTPUT_DATA_DIR_VAR_NAME, app.getOutputDataDirectory());
+
+    
+
+        if (app.getStandardInput() != null && !"".equals(app.getStandardInput())) {
+            jobAttr.setStdin(app.getStandardInput());
+        } else {
+            MessageContext input = context.getInMessageContext();;
+            Map<String,Object> inputs = input.getParameters();
+            Set<String> keys = inputs.keySet();
+            for (String paramName : keys ) {
+             	ActualParameter actualParameter = (ActualParameter) inputs.get(paramName);
+                if ("URIArray".equals(actualParameter.getType().getType().toString()) || "StringArray".equals(actualParameter.getType().getType().toString())
+                        || "FileArray".equals(actualParameter.getType().getType().toString())) {
+                    String[] values = null;
+                    if (actualParameter.getType() instanceof URIArrayType) {
+                        values = ((URIArrayType) actualParameter.getType()).getValueArray();
+                    } else if (actualParameter.getType() instanceof StringArrayType) {
+                        values = ((StringArrayType) actualParameter.getType()).getValueArray();
+                    } else if (actualParameter.getType() instanceof FileArrayType) {
+                        values = ((FileArrayType) actualParameter.getType()).getValueArray();
+                    }
+                    String value = StringUtil.createDelimiteredString(values, " ");
+                    jobAttr.addArgument(value);
+                } else {
+                    String paramValue = MappingFactory.toString(actualParameter);
+                    jobAttr.addArgument(paramValue);
+                }
+            }
+        }
+        // Using the workflowContext Header values if user provided them in the request and overwrite the default values in DD
+        //todo finish the scheduling based on workflow execution context
+        TaskDetails taskData = context.getTaskData();
+        if(taskData != null && taskData.isSetTaskScheduling()){
+        	 ComputationalResourceScheduling computionnalResource = taskData.getTaskScheduling();
+                try {
+                    int cpuCount = computionnalResource.getTotalCPUCount();
+                    if(cpuCount>0){
+                        app.setCpuCount(cpuCount);
+                    }
+                } catch (NullPointerException e) {
+                    log.debug("No Value sent in WorkflowContextHeader for CPU Count, value in the Deployment Descriptor will be used");
+                    new GFacProviderException("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used",e);
+                }
+                try {
+                    int nodeCount = computionnalResource.getNodeCount();
+                    if(nodeCount>0){
+                        app.setNodeCount(nodeCount);
+                    }
+                } catch (NullPointerException e) {
+                    log.debug("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used");
+                     new GFacProviderException("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used",e);
+                }
+                try {
+                    String queueName = computionnalResource.getQueueName();
+                    if (queueName != null) {
+                        if(app.getQueue() == null){
+                            QueueType queueType = app.addNewQueue();
+                            queueType.setQueueName(queueName);
+                        }else{
+                            app.getQueue().setQueueName(queueName);
+                        }
+                    }
+                } catch (NullPointerException e) {
+                    log.debug("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used");
+                     new GFacProviderException("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used",e);
+                }
+                try {
+                    int maxwallTime = computionnalResource.getWallTimeLimit();
+                    if(maxwallTime>0){
+                        app.setMaxWallTime(maxwallTime);
+                    }
+                } catch (NullPointerException e) {
+                    log.debug("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used");
+                     new GFacProviderException("No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will be used",e);
+                }
+        }
+        if (app.getNodeCount() > 0) {
+            jobAttr.set("hostCount", String.valueOf(app.getNodeCount()));
+            log.debug("Setting number of Nodes to " + app.getCpuCount());
+        }
+        if (app.getCpuCount() > 0) {
+            log.debug("Setting number of procs to " + app.getCpuCount());
+            jobAttr.setNumProcs(app.getCpuCount());
+        }
+        if (app.getMinMemory() > 0) {
+            log.debug("Setting minimum memory to " + app.getMinMemory());
+            jobAttr.setMinMemory(app.getMinMemory());
+        }
+        if (app.getMaxMemory() > 0) {
+            log.debug("Setting maximum memory to " + app.getMaxMemory());
+            jobAttr.setMaxMemory(app.getMaxMemory());
+        }
+        if (app.getProjectAccount() != null) {
+            if (app.getProjectAccount().getProjectAccountNumber() != null) {
+                log.debug("Setting project to " + app.getProjectAccount().getProjectAccountNumber());
+                jobAttr.setProject(app.getProjectAccount().getProjectAccountNumber());
+            }
+        }
+        if (app.getQueue() != null) {
+            if (app.getQueue().getQueueName() != null) {
+                log.debug("Setting job queue to " + app.getQueue().getQueueName());
+                jobAttr.setQueue(app.getQueue().getQueueName());
+            }
+        }
+        if (app.getMaxWallTime() > 0) {
+            log.debug("Setting max wall clock time to " + app.getMaxWallTime());
+
+            jobAttr.setMaxWallTime(app.getMaxWallTime());
+            jobAttr.set("proxy_timeout", "1");
+        } else {
+            jobAttr.setMaxWallTime(30);
+        }
+        String jobType = JobType.SINGLE.toString();
+        if (app.getJobType() != null) {
+            jobType = app.getJobType().toString();
+        }
+        if (jobType.equalsIgnoreCase(JobType.SINGLE.toString())) {
+            log.debug("Setting job type to single");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_SINGLE);
+        } if (jobType.equalsIgnoreCase(JobType.SERIAL.toString())) {
+            log.debug("Setting job type to single");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_SINGLE);
+        } else if (jobType.equalsIgnoreCase(JobType.MPI.toString())) {
+            log.debug("Setting job type to mpi");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_MPI);
+        } else if (jobType.equalsIgnoreCase(JobType.MULTIPLE.toString())) {
+            log.debug("Setting job type to multiple");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_MULTIPLE);
+        } else if (jobType.equalsIgnoreCase(JobType.CONDOR.toString())) {
+            jobAttr.setJobType(GramAttributes.JOBTYPE_CONDOR);
+        }
+
+        return jobAttr;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/util/GridFTPContactInfo.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/util/GridFTPContactInfo.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/util/GridFTPContactInfo.java
new file mode 100644
index 0000000..f331b0e
--- /dev/null
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/gram/util/GridFTPContactInfo.java
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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.
+ *
+*/
+package org.apache.airavata.gfac.gram.util;
+
+import org.apache.airavata.gfac.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GridFTPContactInfo {
+    protected final static Logger log = LoggerFactory.getLogger(GridFTPContactInfo.class);
+    public String hostName;
+    public int port;
+
+    public GridFTPContactInfo(String hostName, int port) {
+        if (port <= 0 || port == 80) {
+            log.debug(hostName + "port recived " + port + " setting it to " + Constants.DEFAULT_GSI_FTP_PORT);
+            port = Constants.DEFAULT_GSI_FTP_PORT;
+        }
+        this.hostName = hostName;
+        this.port = port;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof GridFTPContactInfo) {
+            return hostName.equals(((GridFTPContactInfo) obj).hostName) && port == ((GridFTPContactInfo) obj).port;
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        return hostName.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append(hostName).append(":").append(port);
+        return buf.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GramDirectorySetupHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GramDirectorySetupHandler.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GramDirectorySetupHandler.java
deleted file mode 100644
index 2a91afd..0000000
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GramDirectorySetupHandler.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-package org.apache.airavata.gfac.handler;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-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.external.GridFtp;
-import org.apache.airavata.gfac.util.GramProviderUtils;
-import org.apache.airavata.gfac.utils.GFacUtils;
-import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
-import org.apache.airavata.model.workspace.experiment.DataTransferDetails;
-import org.apache.airavata.model.workspace.experiment.ErrorCategory;
-import org.apache.airavata.model.workspace.experiment.TransferState;
-import org.apache.airavata.model.workspace.experiment.TransferStatus;
-import org.apache.airavata.registry.cpi.ChildDataType;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.GlobusHostType;
-import org.apache.airavata.schemas.gfac.HostDescriptionType;
-import org.apache.airavata.schemas.gfac.UnicoreHostType;
-import org.ietf.jgss.GSSCredential;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class  GramDirectorySetupHandler extends  AbstractHandler {
-    private static final Logger log = LoggerFactory.getLogger(GramDirectorySetupHandler.class);
-   
-    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
-        log.info("Invoking GramDirectorySetupHandler ...");
-        super.invoke(jobExecutionContext);
-        String[] gridFTPEndpointArray = null;
-
-        //TODO: why it is tightly coupled with gridftp
-//        GlobusHostType host = (GlobusHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType();
-
-        //TODO: make it more reusable
-        HostDescriptionType hostType = jobExecutionContext.getApplicationContext().getHostDescription().getType();
-
-
-
-        if(hostType instanceof GlobusHostType){
-        	gridFTPEndpointArray = ((GlobusHostType) hostType).getGridFTPEndPointArray();
-        }
-        else if (hostType instanceof UnicoreHostType){
-        	gridFTPEndpointArray = ((UnicoreHostType) hostType).getGridFTPEndPointArray();
-        }
-        
-
-
-        ApplicationDescription applicationDeploymentDescription = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription();
-        ApplicationDeploymentDescriptionType app = applicationDeploymentDescription.getType();
-        GridFtp ftp = new GridFtp();
-
-        try {
-
-            GSSCredential gssCred = ((GSISecurityContext)jobExecutionContext.
-                    getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getGssCredentials();
-
-            if (gridFTPEndpointArray == null || gridFTPEndpointArray.length == 0) {
-            	gridFTPEndpointArray = new String[]{hostType.getHostAddress()};
-            }
-            boolean success = false;
-            GFacHandlerException pe = null;// = new ProviderException("");
-            for (String endpoint : gridFTPEndpointArray) {
-                try {
-
-                    URI tmpdirURI = GramProviderUtils.createGsiftpURI(endpoint, app.getScratchWorkingDirectory());
-                    URI workingDirURI = GramProviderUtils.createGsiftpURI(endpoint, app.getStaticWorkingDirectory());
-                    URI inputURI = GramProviderUtils.createGsiftpURI(endpoint, app.getInputDataDirectory());
-                    URI outputURI = GramProviderUtils.createGsiftpURI(endpoint, app.getOutputDataDirectory());
-
-                    log.info("Host FTP = " + gridFTPEndpointArray[0]);
-                    log.info("temp directory = " + tmpdirURI);
-                    log.info("Working directory = " + workingDirURI);
-                    log.info("Input directory = " + inputURI);
-                    log.info("Output directory = " + outputURI);
-                    ftp.makeDir(tmpdirURI, gssCred);
-                    ftp.makeDir(workingDirURI, gssCred);
-                    ftp.makeDir(inputURI, gssCred);
-                    ftp.makeDir(outputURI, gssCred);
-                    success = true;
-                    DataTransferDetails detail = new DataTransferDetails();
-                    TransferStatus status = new TransferStatus();
-                    status.setTransferState(TransferState.DIRECTORY_SETUP);
-                    detail.setTransferStatus(status);
-                    detail.setTransferDescription("Working directory = " + workingDirURI);
-                    registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
-                                  
-                    break;
-                } catch (URISyntaxException e) {
-                    pe = new GFacHandlerException("URI is malformatted:" + e.getMessage(), e);
-
-                } catch (Exception e) {
-              	pe = new GFacHandlerException(e.getMessage(), e);
-                }
-            }
-            if (success == false) {
-            	GFacUtils.saveErrorDetails(jobExecutionContext, pe.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
-        		throw pe;
-            }
-        } catch (SecurityException e) {
-            throw new GFacHandlerException(e.getMessage(), e);
-        } catch (ApplicationSettingsException e1) {
-        	throw new GFacHandlerException(e1.getMessage(), e1);
-		} catch (GFacException e) {
-            throw new GFacHandlerException(e);
-        }
-    }
-
-    public void initProperties(Map<String, String> properties) throws GFacHandlerException {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPInputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPInputHandler.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPInputHandler.java
deleted file mode 100644
index ffbacdd..0000000
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPInputHandler.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-package org.apache.airavata.gfac.handler;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.StringUtil;
-import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.MappingFactory;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.ToolsException;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.gfac.external.GridFtp;
-import org.apache.airavata.gfac.util.GramProviderUtils;
-import org.apache.airavata.gfac.utils.GFacUtils;
-import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
-import org.apache.airavata.model.workspace.experiment.DataTransferDetails;
-import org.apache.airavata.model.workspace.experiment.ErrorCategory;
-import org.apache.airavata.model.workspace.experiment.TransferState;
-import org.apache.airavata.model.workspace.experiment.TransferStatus;
-import org.apache.airavata.registry.cpi.ChildDataType;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.GlobusHostType;
-import org.apache.airavata.schemas.gfac.HostDescriptionType;
-import org.apache.airavata.schemas.gfac.URIArrayType;
-import org.apache.airavata.schemas.gfac.URIParameterType;
-import org.apache.airavata.schemas.gfac.UnicoreHostType;
-import org.ietf.jgss.GSSCredential;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GridFTPInputHandler extends AbstractHandler {
-    private static final Logger log = LoggerFactory.getLogger(AppDescriptorCheckHandler.class);
- 
-    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
-        log.info("Invoking GridFTPInputHandler ...");
-        super.invoke(jobExecutionContext);
-        DataTransferDetails detail = new DataTransferDetails();
-        TransferStatus status = new TransferStatus();
-       
-        MessageContext inputNew = new MessageContext();
-        try {
-            MessageContext input = jobExecutionContext.getInMessageContext();
-            Set<String> parameters = input.getParameters().keySet();
-            for (String paramName : parameters) {
-                ActualParameter actualParameter = (ActualParameter) input.getParameters().get(paramName);
-                String paramValue = MappingFactory.toString(actualParameter);
-                //TODO: Review this with type
-                if ("URI".equals(actualParameter.getType().getType().toString())) {
-                    ((URIParameterType) actualParameter.getType()).setValue(stageInputFiles(jobExecutionContext, paramValue));
-                } else if ("URIArray".equals(actualParameter.getType().getType().toString())) {
-                    List<String> split = Arrays.asList(StringUtil.getElementsFromString(paramValue));
-                    List<String> newFiles = new ArrayList<String>();
-                    for (String paramValueEach : split) {
-                        String stageInputFiles = stageInputFiles(jobExecutionContext, paramValueEach);
-                        detail.setTransferDescription("Input Data Staged: " + stageInputFiles);
-                        status.setTransferState(TransferState.UPLOAD);
-                        detail.setTransferStatus(status);
-                        registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
-                   
-                        newFiles.add(stageInputFiles);
-                    }
-                    ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
-                }
-                inputNew.getParameters().put(paramName, actualParameter);
-               
-            }
-        } catch (Exception e) {
-        	 try {
-         	    status.setTransferState(TransferState.FAILED);
- 				detail.setTransferStatus(status);
- 				registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
- 				GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
- 			} catch (Exception e1) {
-  			    throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
-  		   }
-            log.error(e.getMessage());
-            throw new GFacHandlerException("Error while input File Staging", e, e.getLocalizedMessage());
-        }
-        jobExecutionContext.setInMessageContext(inputNew);
-    }
-
-    private static String stageInputFiles(JobExecutionContext jobExecutionContext, String paramValue) throws URISyntaxException, SecurityException, ToolsException, IOException,GFacException, ApplicationSettingsException {
-        URI gridftpURL = new URI(paramValue);
-
-        String[] gridFTPEndpointArray = null;
-
-        // not to download input files to the input dir if its http / gsiftp
-        // but if local then yes
-        boolean isInputNonLocal = true;
-
-        //TODO: why it is tightly coupled with gridftp
-//        GlobusHostType host = (GlobusHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType();
-
-        //TODO: make it more reusable
-        HostDescriptionType hostType = jobExecutionContext.getApplicationContext().getHostDescription().getType();
-
-        if(jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof GlobusHostType){
-        	gridFTPEndpointArray = ((GlobusHostType) hostType).getGridFTPEndPointArray();
-        }
-        else if (jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof UnicoreHostType){
-        	gridFTPEndpointArray = ((UnicoreHostType) hostType).getGridFTPEndPointArray();
-        	isInputNonLocal = false;
-        }
-        else {
-        	//TODO
-        }
-
-
-        ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
-        GridFtp ftp = new GridFtp();
-        URI destURI = null;
-        GSSCredential gssCred = ((GSISecurityContext)jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getGssCredentials();
-
-        for (String endpoint : gridFTPEndpointArray) {
-            URI inputURI = GramProviderUtils.createGsiftpURI(endpoint, app.getInputDataDirectory());
-            String fileName = new File(gridftpURL.getPath()).getName();
-            fileName = ftp.gridFTPFileExist(inputURI, fileName,gssCred);
-
-            String destLocalPath = inputURI.getPath() + File.separator + fileName;
-            //if user give a url just to refer an endpoint, not a web resource we are not doing any transfer
-            if (fileName != null && !"".equals(fileName)) {
-                destURI = GramProviderUtils.createGsiftpURI(endpoint, destLocalPath);
-                if (paramValue.startsWith("gsiftp")) {
-                	// no need to do if it is unicore, as unicore will download this on user's behalf to the job space dir
-                	if(isInputNonLocal) ftp.uploadFile(gridftpURL, destURI, gssCred);
-                	else return paramValue;
-                } else if (paramValue.startsWith("file")) {
-                    String localFile = paramValue.substring(paramValue.indexOf(":") + 1, paramValue.length());
-                    FileInputStream fis = null;
-                    try {
-                    	fis = new FileInputStream(localFile);
-                    	ftp.uploadFile(destURI, gssCred, fis);
-                    } catch (IOException e) {
-                        throw new GFacException("Unable to create file : " + localFile ,e);
-                    } finally {
-                        if (fis != null) {
-                            fis.close();
-                        }
-                    }
-                } else if (paramValue.startsWith("http")) {
-                	// no need to do if it is unicore
-                	if(isInputNonLocal) {
-                		InputStream is = null;
-                		try {
-                			is = gridftpURL.toURL().openStream();
-                			ftp.uploadFile(destURI, gssCred, (is));
-                		}finally {
-                			is.close();
-                		}
-                	} else {
-                		// don't return destUri
-                		return paramValue;
-                	}
-
-                } else {
-                    //todo throw exception telling unsupported protocol
-                    return paramValue;
-                }
-            } else {
-                // When the given input is not a web resource but a URI type input, then we don't do any transfer just keep the same value as it isin the input
-                return paramValue;
-            }
-        }
-        return destURI.getPath();
-    }
-
-    public void initProperties(Map<String, String> properties) throws GFacHandlerException {
-
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
deleted file mode 100644
index 33e549f..0000000
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-package org.apache.airavata.gfac.handler;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.StringUtil;
-import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.commons.gfac.type.MappingFactory;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.ToolsException;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.gfac.external.GridFtp;
-import org.apache.airavata.gfac.provider.GFacProviderException;
-import org.apache.airavata.gfac.util.GramProviderUtils;
-import org.apache.airavata.gfac.utils.GFacUtils;
-import org.apache.airavata.gfac.utils.OutputUtils;
-import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
-import org.apache.airavata.model.workspace.experiment.DataTransferDetails;
-import org.apache.airavata.model.workspace.experiment.ErrorCategory;
-import org.apache.airavata.model.workspace.experiment.TaskDetails;
-import org.apache.airavata.model.workspace.experiment.TransferState;
-import org.apache.airavata.model.workspace.experiment.TransferStatus;
-import org.apache.airavata.registry.cpi.ChildDataType;
-import org.apache.airavata.registry.cpi.Registry;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.GlobusHostType;
-import org.apache.airavata.schemas.gfac.HostDescriptionType;
-import org.apache.airavata.schemas.gfac.StringArrayType;
-import org.apache.airavata.schemas.gfac.URIArrayType;
-import org.apache.airavata.schemas.gfac.URIParameterType;
-import org.apache.airavata.schemas.gfac.UnicoreHostType;
-import org.ietf.jgss.GSSCredential;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class GridFTPOutputHandler extends AbstractHandler {
-    private static final Logger log = LoggerFactory.getLogger(GridFTPOutputHandler.class);
-    private Registry registry;
-
-
-    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
-       log.info("Invoking GridFTPOutputHandler ...");
-       super.invoke(jobExecutionContext);
-        
-       ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
-
- 	   HostDescriptionType hostType = jobExecutionContext.getApplicationContext().getHostDescription().getType();
- 	   String[] gridFTPEndpointArray = null;
- 	   String hostName = null;
- 
-       if(jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof GlobusHostType){
-        	gridFTPEndpointArray = ((GlobusHostType) hostType).getGridFTPEndPointArray();
-        	hostName = ((GlobusHostType) hostType).getHostName();
- 
-       }
-       else if (jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof UnicoreHostType){
-        	gridFTPEndpointArray = ((UnicoreHostType) hostType).getGridFTPEndPointArray();
-        	hostName = ((UnicoreHostType) hostType).getHostName();
-       }
-       else {
-        	//TODO
-       }
-
-       GridFtp ftp = new GridFtp();
-       File localStdErrFile = null;
-       Map<String, ActualParameter> stringMap = new HashMap<String, ActualParameter>();
-	   DataTransferDetails detail = new DataTransferDetails();
-	   TransferStatus status = new TransferStatus();
-
-       try {
-    	    GSSCredential gssCred = ((GSISecurityContext)jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getGssCredentials();
-    	    String[] hostgridFTP = gridFTPEndpointArray;
-            if (hostgridFTP == null || hostgridFTP.length == 0) {
-                hostgridFTP = new String[]{hostName};
-            }
-            for (String endpoint : gridFTPEndpointArray) {
-                try {
-                    /*
-                     *  Read Stdout and Stderror
-                     */
-					URI stdoutURI = GramProviderUtils.createGsiftpURI(endpoint, app.getStandardOutput());
-                    URI stderrURI = GramProviderUtils.createGsiftpURI(endpoint, app.getStandardError());
-                	status.setTransferState(TransferState.COMPLETE);
-					detail.setTransferStatus(status);
-					detail.setTransferDescription("STDOUT:" + stdoutURI.toString());
-                    registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
-                    status.setTransferState(TransferState.COMPLETE);
-					detail.setTransferStatus(status);
-					detail.setTransferDescription("STDERR:" + stderrURI.toString());
-                    registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
-                  
-                    log.info("STDOUT:" + stdoutURI.toString());
-                    log.info("STDERR:" + stderrURI.toString());
-
-                    File logDir = new File("./service_logs");
-                    if (!logDir.exists()) {
-                        logDir.mkdir();
-                    }
-
-                    String timeStampedServiceName = GFacUtils.createUniqueNameForService(jobExecutionContext
-                            .getServiceName());
-                    File localStdOutFile = File.createTempFile(timeStampedServiceName, "stdout");
-                    localStdErrFile = File.createTempFile(timeStampedServiceName, "stderr");
-
-
-                    String stdout = null;
-                    String stderr = null;
-
-                    // TODO: what if job is failed
-                    // and this handler is not able to find std* files?
-                    try {
-                     stdout = ftp.readRemoteFile(stdoutURI, gssCred, localStdOutFile);
-                     stderr = ftp.readRemoteFile(stderrURI, gssCred, localStdErrFile);
-                     //TODO: do we also need to set them as output parameters for another job
-                     ApplicationDescription application = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription();
-                     ApplicationDeploymentDescriptionType appDesc = application.getType();
-                     appDesc.setStandardOutput(stdout);
-                     appDesc.setStandardError(stderr);
-                     jobExecutionContext.getApplicationContext().setApplicationDeploymentDescription(application);
-                    }
-                    catch(ToolsException e) {
-                        log.error("Cannot download stdout/err files. One reason could be the job is not successfully finished:  "+e.getMessage());
-                    }
-
-
-                    Map<String, Object> output = jobExecutionContext.getOutMessageContext().getParameters();
-                    Set<String> keys = output.keySet();
-                    for (String paramName : keys) {
-                        ActualParameter actualParameter = (ActualParameter) output.get(paramName);
-                        if ("URIArray".equals(actualParameter.getType().getType().toString())) {
-                            URI outputURI = GramProviderUtils.createGsiftpURI(endpoint, app.getOutputDataDirectory());
-                            List<String> outputList = ftp.listDir(outputURI, gssCred);
-                            String[] valueList = outputList.toArray(new String[outputList.size()]);
-                            ((URIArrayType) actualParameter.getType()).setValueArray(valueList);
-                            // why to instantiate new instance?
-//                            stringMap = new HashMap<String, ActualParameter>();
-                            stringMap.put(paramName, actualParameter);
-                        }else if ("StringArray".equals(actualParameter.getType().getType().toString())) {
-                            String[] valueList = OutputUtils.parseStdoutArray(stdout, paramName);
-                            ((StringArrayType) actualParameter.getType()).setValueArray(valueList);
-//                            stringMap = new HashMap<String, ActualParameter>();
-                            stringMap.put(paramName, actualParameter);
-                        } else if ("URI".equals(actualParameter.getType().getType().toString())) {
-                        	  URI outputURI = GramProviderUtils.createGsiftpURI(endpoint, app.getOutputDataDirectory());
-                              List<String> outputList = ftp.listDir(outputURI, gssCred);
-							if (outputList.size() == 0 || outputList.get(0).isEmpty()) {
-								stringMap = OutputUtils.fillOutputFromStdout(output, stdout, stderr);
-							} else {
-								String valueList = outputList.get(0);
-								((URIParameterType) actualParameter.getType()).setValue(valueList);
-								stringMap = new HashMap<String, ActualParameter>();
-								stringMap.put(paramName, actualParameter);
-							}
-                        }
-                        else {
-                            // This is to handle exception during the output parsing.
-                            stringMap = OutputUtils.fillOutputFromStdout(output, stdout, stderr);
-                        }
-                        status.setTransferState(TransferState.DOWNLOAD);
-    					detail.setTransferStatus(status);
-    					detail.setTransferDescription("Output: " + stringMap.get(paramName).toString());
-                        registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
-                      
-                    }
-                    if (stringMap == null || stringMap.isEmpty()) {
-                        throw new GFacHandlerException("Empty Output returned from the Application, Double check the application" +
-                                "and ApplicationDescriptor output Parameter Names");
-                    }
-                    // If users has given an output Data path to download the output files this will download the file on machine where GFac is installed
-                    TaskDetails taskData =  jobExecutionContext.getTaskData();
-                    if(taskData != null && taskData.getAdvancedOutputDataHandling() != null){
-                    	String outputDataDirectory = taskData.getAdvancedOutputDataHandling().getOutputDataDir();
-                            if(outputDataDirectory != null && !"".equals(outputDataDirectory)){
-                                stageOutputFiles(jobExecutionContext,outputDataDirectory);
-                            }
-                    }
-                } catch (ToolsException e) {
-                    log.error(e.getMessage());
-                    throw new GFacHandlerException(e.getMessage() + "\n StdError Data: \n" +readLastLinesofStdOut(localStdErrFile.getPath(), 20),e);
-                } catch (URISyntaxException e) {
-                    log.error(e.getMessage());
-                    throw new GFacHandlerException("URI is malformatted:" + e.getMessage(), e, readLastLinesofStdOut(localStdErrFile.getPath(), 20));
-                }
-            }
-        } catch (Exception e) {
-        	 try {
-        	    status.setTransferState(TransferState.FAILED);
-				detail.setTransferStatus(status);
-				registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
-				GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
-	 		} catch (Exception e1) {
- 			    throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
- 		   }
-        	log.error(e.getMessage());
-            throw new GFacHandlerException(e.getMessage(), e, readLastLinesofStdOut(localStdErrFile.getPath(), 20));
-        }
-
-    }
-
-    private static String readLastLinesofStdOut(String path, int count) {
-        StringBuffer buffer = new StringBuffer();
-        FileInputStream in = null;
-        try {
-            in = new FileInputStream(path);
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
-        BufferedReader br = new BufferedReader(new InputStreamReader(in));
-        List<String> strLine = new ArrayList<String>();
-        String tmp = null;
-        int numberofLines = 0;
-        try {
-            while ((tmp = br.readLine()) != null) {
-                strLine.add(tmp);
-                numberofLines++;
-            }
-        } catch (IOException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
-        if (numberofLines > count) {
-            for (int i = numberofLines - count; i < numberofLines; i++) {
-                buffer.append(strLine.get(i));
-                buffer.append("\n");
-            }
-        } else {
-            for (int i = 0; i < numberofLines; i++) {
-                buffer.append(strLine.get(i));
-                buffer.append("\n");
-            }
-        }
-        try {
-            in.close();
-        } catch (IOException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
-        return buffer.toString();
-    }
-
-    private static void stageOutputFiles(JobExecutionContext jobExecutionContext, String outputFileStagingPath) throws GFacProviderException,GFacException, ApplicationSettingsException {
-
-
-    	   HostDescriptionType hostType = jobExecutionContext.getApplicationContext().getHostDescription().getType();
-    	   String[] gridFTPEndpointArray = null;
-
-           if(jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof GlobusHostType){
-           	gridFTPEndpointArray = ((GlobusHostType) hostType).getGridFTPEndPointArray();
-           }
-           else if (jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof UnicoreHostType){
-           	gridFTPEndpointArray = ((UnicoreHostType) hostType).getGridFTPEndPointArray();
-           }
-           else {
-           	//TODO
-           }
-
-
-        MessageContext outputNew = new MessageContext();
-        MessageContext output = jobExecutionContext.getOutMessageContext();
-        Map<String, Object> parameters = output.getParameters();
-        for (String paramName : parameters.keySet()) {
-            ActualParameter actualParameter = (ActualParameter) parameters
-                    .get(paramName);
-
-            GridFtp ftp = new GridFtp();
-            GSSCredential gssCred = ((GSISecurityContext)jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getGssCredentials();
-            try {
-                if ("URI".equals(actualParameter.getType().getType().toString())) {
-                    for (String endpoint : gridFTPEndpointArray) {
-                        ((URIParameterType) actualParameter.getType()).setValue(doStaging(outputFileStagingPath,
-                                MappingFactory.toString(actualParameter), ftp, gssCred, endpoint));
-                    }
-                } else if ("URIArray".equals(actualParameter.getType().getType().toString())) {
-                    List<String> split = Arrays.asList(StringUtil.getElementsFromString(MappingFactory.toString(actualParameter)));
-                    List<String> newFiles = new ArrayList<String>();
-                    for (String endpoint : gridFTPEndpointArray) {
-                        for (String paramValueEach : split) {
-                            newFiles.add(doStaging(outputFileStagingPath, paramValueEach, ftp, gssCred, endpoint));
-                        }
-                        ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
-                    }
-
-                }
-            } catch (URISyntaxException e) {
-                log.error(e.getMessage());
-                throw new GFacProviderException(e.getMessage(), e);
-            } catch (ToolsException e) {
-                log.error(e.getMessage());
-                throw new GFacProviderException(e.getMessage(), e);
-            }
-            outputNew.getParameters().put(paramName, actualParameter);
-        }
-        jobExecutionContext.setOutMessageContext(outputNew);
-    }
-
-    private static String doStaging(String outputFileStagingPath, String paramValue, GridFtp ftp, GSSCredential gssCred, String endpoint) throws URISyntaxException, ToolsException {
-        URI srcURI = GramProviderUtils.createGsiftpURI(endpoint, paramValue);
-        String fileName = new File(srcURI.getPath()).getName();
-        File outputpath = new File(outputFileStagingPath);
-        if(!outputpath.exists()){
-        	outputpath.mkdirs();
-        }
-        File outputFile = new File(outputpath.getAbsolutePath() + File.separator + fileName);
-        ftp.readRemoteFile(srcURI,
-                gssCred, outputFile);
-        return outputFileStagingPath + File.separator + fileName;
-    }
-
-    public void initProperties(Map<String, String> properties) throws GFacHandlerException {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/persistence/DBJobPersistenceManager.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/persistence/DBJobPersistenceManager.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/persistence/DBJobPersistenceManager.java
deleted file mode 100644
index 3086b95..0000000
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/persistence/DBJobPersistenceManager.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- *
- * 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.
- *
- */
-
-package org.apache.airavata.gfac.persistence;
-
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.log4j.Logger;
-import org.globus.gram.internal.GRAMConstants;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * User: AmilaJ (amilaj@apache.org)
- * Date: 6/18/13
- * Time: 4:16 PM
- * Database based job persistence manager. Current default implementation.
- */
-
-public class DBJobPersistenceManager implements JobPersistenceManager {
-
-    private DBUtil dbUtil;
-
-    private static final Logger log = Logger.getLogger(DBJobPersistenceManager.class);
-
-
-    public DBJobPersistenceManager(DBUtil db) {
-        this.dbUtil = db;
-    }
-
-    public synchronized void updateJobStatus(JobData jobData) throws GFacException {
-
-        if (jobData.getState() == GRAMConstants.STATUS_UNSUBMITTED) {
-            insertJob(jobData);
-        } else {
-
-            String sql = "update gram_job set status = ? where job_id = ?";
-
-            Connection connection = null;
-            PreparedStatement stmt = null;
-
-            try {
-                connection = getConnection();
-                stmt = connection.prepareStatement(sql);
-                stmt.setInt(1, jobData.getState());
-                stmt.setString(2, jobData.getJobId());
-
-                stmt.executeUpdate();
-                connection.commit();
-
-            } catch (SQLException e) {
-                throw new GFacException(e);
-            } finally {
-                try {
-                    if (stmt != null) {
-                        stmt.close();
-                    }
-
-                    if (connection != null) {
-                        connection.close();
-                    }
-
-                } catch (SQLException e) {
-                    log.error("Error closing streams", e);
-                }
-            }
-        }
-    }
-
-    private void insertJob(JobData jobData) throws GFacException {
-
-        String sql = "insert into gram_job values (?, ?)";
-
-        PreparedStatement stmt = null;
-        Connection connection = null;
-
-        try {
-            connection = getConnection();
-            stmt = connection.prepareStatement(sql);
-            stmt.setString(1, jobData.getJobId());
-            stmt.setInt(2, jobData.getState());
-
-            stmt.executeUpdate();
-        } catch (SQLException e) {
-            throw new GFacException(e);
-        } finally {
-            try {
-                if (stmt != null) {
-                    stmt.close();
-                }
-
-                if (connection != null) {
-                    connection.close();
-                }
-
-            } catch (SQLException e) {
-                log.error("Error closing streams", e);
-            }
-        }
-
-    }
-
-    public List<JobData> getRunningJobs() throws GFacException {
-
-        String sql = "select * from gram_job where status not in (?, ?, ?)";
-
-        int[] statuses = new int[3];
-        statuses[0] = GRAMConstants.STATUS_UNSUBMITTED;
-        statuses[1] = GRAMConstants.STATUS_DONE;
-        statuses[2] = GRAMConstants.STATUS_FAILED;
-
-        return getJobs(sql, statuses);
-    }
-
-    public List<JobData> getFailedJobs() throws GFacException {
-
-        String sql = "select * from gram_job where status in (?)";
-
-        int[] statuses = new int[1];
-        statuses[0] = GRAMConstants.STATUS_FAILED;
-
-        return getJobs(sql, statuses);
-    }
-
-    public List<JobData> getUnSubmittedJobs() throws GFacException {
-
-        String sql = "select * from gram_job where status in (?)";
-
-        int[] statuses = new int[1];
-        statuses[0] = GRAMConstants.STATUS_UNSUBMITTED;
-
-        return getJobs(sql, statuses);
-    }
-
-    public List<JobData> getSuccessfullyCompletedJobs() throws GFacException {
-
-        String sql = "select * from gram_job where status in (?)";
-
-        int[] statuses = new int[1];
-        statuses[0] = GRAMConstants.STATUS_DONE;
-
-        return getJobs(sql, statuses);
-
-    }
-
-
-    protected List<JobData> getJobs(String sql, int[] statuses) throws GFacException {
-
-        List<JobData> jobs = new ArrayList<JobData>();
-
-        PreparedStatement preparedStatement = null;
-        Connection connection = null;
-
-        try {
-            connection = getConnection();
-            preparedStatement = connection.prepareStatement(sql);
-
-            int index = 1;
-            for (int status : statuses) {
-                preparedStatement.setInt(index, status);
-                ++index;
-            }
-
-            ResultSet resultSet = preparedStatement.executeQuery();
-
-            while (resultSet.next()) {
-
-                String jobId = resultSet.getString("job_id");
-                int state = resultSet.getInt("status");
-
-                jobs.add(new JobData(jobId, state));
-            }
-
-        } catch (SQLException e) {
-            throw new GFacException(e);
-        } finally {
-            try {
-                if (preparedStatement != null) {
-                    preparedStatement.close();
-                }
-
-                if (connection != null) {
-                    connection.close();
-                }
-
-            } catch (SQLException e) {
-                log.error("Error closing connection", e);
-            }
-        }
-
-        return jobs;
-    }
-
-    private synchronized Connection getConnection() throws SQLException {
-        Connection connection = dbUtil.getConnection();
-        connection.setAutoCommit(true);
-
-        return connection;
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
deleted file mode 100644
index 2ba4b4b..0000000
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-package org.apache.airavata.gfac.provider.impl;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.JobSubmissionFault;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
-import org.apache.airavata.gfac.notification.events.JobIDEvent;
-import org.apache.airavata.gfac.notification.events.StartExecutionEvent;
-import org.apache.airavata.gfac.provider.AbstractProvider;
-import org.apache.airavata.gfac.provider.GFacProviderException;
-import org.apache.airavata.gfac.util.GramProviderUtils;
-import org.apache.airavata.gfac.utils.GFacUtils;
-import org.apache.airavata.gfac.util.GramJobSubmissionListener;
-import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
-import org.apache.airavata.model.workspace.experiment.ErrorCategory;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.GlobusHostType;
-import org.globus.gram.GramException;
-import org.globus.gram.GramJob;
-import org.globus.gram.WaitingForCommitException;
-import org.globus.gram.internal.GRAMConstants;
-import org.globus.gram.internal.GRAMProtocolErrorConstants;
-import org.ietf.jgss.GSSCredential;
-import org.ietf.jgss.GSSException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GramProvider extends AbstractProvider {
-    private static final Logger log = LoggerFactory.getLogger(GramJobSubmissionListener.class);
-
-    private GramJob job;
-    private GramJobSubmissionListener listener;
-    private boolean twoPhase = true;
-
-    /**
-     * If normal job submission fail due to an authorisation failure or script failure we
-     * will re-attempt to submit the job. In-order to avoid any recursive loop during a continuous
-     * failure we track whether failure paths are tried or not. Following booleans keeps track whether
-     * we already tried a failure path or not.
-     */
-    /**
-     * To track job submissions during a authorisation failure while requesting job.
-     */
-    private boolean renewCredentialsAttempt = false;
-    /**
-     * To track job submission during a script error situation.
-     */
-    private boolean reSubmissionInProgress = false;
-    /**
-     * To track authorisation failures during status monitoring.
-     */
-    private boolean authorisationFailedAttempt = false;
-
-    private static final Map<String, GramJob> currentlyExecutingJobCache
-            = new ConcurrentHashMap<String, GramJob>();
-
-    private static Properties resources;
-
-    static {
-        try {
-
-            String propFileName = "errors.properties";
-            resources = new Properties();
-            InputStream inputStream = GramProvider.class.getClassLoader()
-                    .getResourceAsStream(propFileName);
-
-            if (inputStream == null) {
-                throw new FileNotFoundException("property file '" + propFileName
-                        + "' not found in the classpath");
-            }
-
-            resources.load(inputStream);
-
-        } catch (FileNotFoundException mre) {
-            log.error("errors.properties not found", mre);
-        } catch (IOException e) {
-            log.error("Error reading errors.properties file", e);
-        }
-    }
-
-
-    // This method prepare the environment before the application invocation.
-    public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
-
-        try {
-        	super.initialize(jobExecutionContext);
-            String strTwoPhase = ServerSettings.getSetting("TwoPhase");
-            if (strTwoPhase != null) {
-                twoPhase = Boolean.parseBoolean(strTwoPhase);
-                log.info("Two phase commit is set to " + twoPhase);
-            }
-        } catch (ApplicationSettingsException e) {
-            log.warn("Error reading TwoPhase property from configurations.", e);
-        }
-
-        job = GramProviderUtils.setupEnvironment(jobExecutionContext, twoPhase);
-        listener = new GramJobSubmissionListener(job, jobExecutionContext);
-        job.addListener(listener);
-    }
-
-    public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException{
-        jobExecutionContext.getNotifier().publish(new StartExecutionEvent());
-        GlobusHostType host = (GlobusHostType) jobExecutionContext.getApplicationContext().
-                getHostDescription().getType();
-        ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().
-                getApplicationDeploymentDescription().getType();
-
-        StringBuilder stringBuilder = new StringBuilder();
-        try {
-
-            GSSCredential gssCred = ((GSISecurityContext)jobExecutionContext.
-                    getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getGssCredentials();
-            job.setCredentials(gssCred);
-            // We do not support multiple gatekeepers in XBaya GUI, so we simply pick the 0th element in the array
-            String gateKeeper = host.getGlobusGateKeeperEndPointArray(0);
-            log.info("Request to contact:" + gateKeeper);
-
-            stringBuilder.append("Finished launching job, Host = ").append(host.getHostAddress()).append(" RSL = ")
-                    .append(job.getRSL()).append(" working directory = ").append(app.getStaticWorkingDirectory())
-                    .append(" temp directory = ").append(app.getScratchWorkingDirectory())
-                    .append(" Globus GateKeeper Endpoint = ").append(gateKeeper);
-
-            log.info(stringBuilder.toString());
-
-            submitJobs(gateKeeper, jobExecutionContext, host);
-
-        } catch (ApplicationSettingsException e) {
-        	throw new GFacException(e.getMessage(), e);
-		} finally {
-            if (job != null) {
-                try {
-                	 /*
-                     * Remove listener
-                     */
-                    job.removeListener(listener);
-                } catch (Exception e) {
-                	 log.error(e.getMessage());
-                }
-            }
-        }
-    }
-
-    private void submitJobs(String gateKeeper,
-                            JobExecutionContext jobExecutionContext,
-                            GlobusHostType globusHostType) throws GFacException, GFacProviderException {
-    	boolean applicationSaved=false;
-    	String taskID = jobExecutionContext.getTaskData().getTaskID();
-			
-    	if (twoPhase) {
-            try {
-                /*
-                * The first boolean is to force communication through SSLv3
-                * The second boolean is to specify the job is a batch job - use true for interactive and false for
-                 * batch.
-                * The third boolean is to specify to use the full proxy and not delegate a limited proxy.
-                */
-                job.request(true, gateKeeper, false, false);
-
-                // Single boolean to track all authentication failures, therefore we need to re-initialize
-                // this here
-                renewCredentialsAttempt = false;
-
-            } catch (WaitingForCommitException e) {
-            	String jobID = job.getIDAsString();
-				
-            	details.setJobID(jobID);
-            	details.setJobDescription(job.getRSL());
-                jobExecutionContext.setJobDetails(details);
-                GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.UN_SUBMITTED);
-                
-                applicationSaved=true;
-                String jobStatusMessage = "Un-submitted JobID= " + jobID;
-                log.info(jobStatusMessage);
-                jobExecutionContext.getNotifier().publish(new JobIDEvent(jobStatusMessage));
-
-                log.info("Two phase commit: sending COMMIT_REQUEST signal; Job id - " + jobID);
-
-                try {
-                    job.signal(GramJob.SIGNAL_COMMIT_REQUEST);
-
-                } catch (GramException gramException) {
-                    throw new GFacException("Error while sending commit request. Job Id - "
-                            + job.getIDAsString(), gramException);
-                } catch (GSSException gssException) {
-
-                    // User credentials are invalid
-                    log.error("Error while submitting commit request - Credentials provided are invalid. Job Id - "
-                            + job.getIDAsString(), e);
-                    log.info("Attempting to renew credentials and re-submit commit signal...");
-                	GFacUtils.saveErrorDetails(jobExecutionContext, gssException.getLocalizedMessage(), CorrectiveAction.RETRY_SUBMISSION, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
-                    renewCredentials(jobExecutionContext);
-
-                    try {
-                        job.signal(GramJob.SIGNAL_COMMIT_REQUEST);
-                    } catch (GramException e1) {
-                     	GFacUtils.saveErrorDetails(jobExecutionContext, gssException.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
-                    	throw new GFacException("Error while sending commit request. Job Id - "
-                                + job.getIDAsString(), e1);
-                    } catch (GSSException e1) {
-                     	GFacUtils.saveErrorDetails(jobExecutionContext, gssException.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
-                        throw new GFacException("Error while sending commit request. Job Id - "
-                                + job.getIDAsString() + ". Credentials provided invalid", e1);
-                    }
-                }
-                GFacUtils.updateJobStatus(jobExecutionContext, details, JobState.SUBMITTED);
-                jobStatusMessage = "Submitted JobID= " + job.getIDAsString();
-                log.info(jobStatusMessage);
-                jobExecutionContext.getNotifier().publish(new JobIDEvent(jobStatusMessage));
-
-            } catch (GSSException e) {
-                // Renew credentials and re-submit
-             	GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.RETRY_SUBMISSION, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
-                
-                reSubmitJob(gateKeeper, jobExecutionContext, globusHostType, e);
-
-            } catch (GramException e) {
-             	GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
-                
-            	throw new GFacException("An error occurred while submitting a job, job id = " + job.getIDAsString(), e);
-            }
-        } else {
-
-            /*
-            * The first boolean is to force communication through SSLv3
-            * The second boolean is to specify the job is a batch job - use true for interactive and false for
-             * batch.
-            * The third boolean is to specify to use the full proxy and not delegate a limited proxy.
-            */
-            try {
-
-                job.request(true, gateKeeper, false, false);
-                renewCredentialsAttempt = false;
-
-            } catch (GramException e) {
-            	GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
-                throw new GFacException("An error occurred while submitting a job, job id = " + job.getIDAsString(), e);
-            } catch (GSSException e) {
-            	GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.RETRY_SUBMISSION, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
-                // Renew credentials and re-submit
-                reSubmitJob(gateKeeper, jobExecutionContext, globusHostType, e);
-            }
-
-            String jobStatusMessage = "Un-submitted JobID= " + job.getIDAsString();
-            log.info(jobStatusMessage);
-            jobExecutionContext.getNotifier().publish(new JobIDEvent(jobStatusMessage));
-
-        }
-
-        currentlyExecutingJobCache.put(job.getIDAsString(), job);
-        /*
-        * Wait until job is done
-        */
-        listener.waitFor();
-
-        checkJobStatus(jobExecutionContext, globusHostType, gateKeeper);
-
-    }
-
-    private void renewCredentials(JobExecutionContext jobExecutionContext) throws GFacException {
-
-        renewCredentials(this.job, jobExecutionContext);
-    }
-
-    private void renewCredentials(GramJob gramJob, JobExecutionContext jobExecutionContext) throws GFacException {
-
-        try {
-        	GSSCredential gssCred = ((GSISecurityContext)jobExecutionContext.
-                    getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).renewCredentials();
-            gramJob.renew(gssCred);
-        } catch (GramException e1) {
-            throw new GFacException("Unable to renew credentials. Job Id - "
-                    + gramJob.getIDAsString(), e1);
-        } catch (GSSException e1) {
-            throw new GFacException("Unable to renew credentials. Job Id - "
-                    + gramJob.getIDAsString(), e1);
-        } catch (ApplicationSettingsException e) {
-        	throw new GFacException(e.getLocalizedMessage(), e);
-		}
-    }
-
-    private void reSubmitJob(String gateKeeper,
-                             JobExecutionContext jobExecutionContext,
-                             GlobusHostType globusHostType, Exception e) throws GFacException, GFacProviderException {
-
-        if (!renewCredentialsAttempt) {
-
-            renewCredentialsAttempt = true;
-
-            // User credentials are invalid
-            log.error("Error while submitting job - Credentials provided are invalid. Job Id - "
-                    + job.getIDAsString(), e);
-            log.info("Attempting to renew credentials and re-submit jobs...");
-
-            // Remove existing listener and register a new listener
-            job.removeListener(listener);
-            listener = new GramJobSubmissionListener(job, jobExecutionContext);
-
-            job.addListener(listener);
-
-            renewCredentials(jobExecutionContext);
-
-            submitJobs(gateKeeper, jobExecutionContext, globusHostType);
-
-        } else {
-            throw new GFacException("Error while submitting job - Credentials provided are invalid. Job Id - "
-                    + job.getIDAsString(), e);
-        }
-
-    }
-
-    private void reSubmitJob(String gateKeeper,
-                             JobExecutionContext jobExecutionContext,
-                             GlobusHostType globusHostType) throws GFacException, GFacProviderException {
-
-        // User credentials are invalid
-        log.info("Attempting to renew credentials and re-submit jobs...");
-
-        // Remove existing listener and register a new listener
-        job.removeListener(listener);
-        listener = new GramJobSubmissionListener(job, jobExecutionContext);
-
-        job.addListener(listener);
-
-        renewCredentials(jobExecutionContext);
-
-        submitJobs(gateKeeper, jobExecutionContext, globusHostType);
-
-    }
-
-	
-	
-    public void dispose(JobExecutionContext jobExecutionContext) throws GFacProviderException {
-    }
-
-    public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException {
-        cancelSingleJob(jobId, jobExecutionContext);
-    }
-
-
-    private void cancelSingleJob(String jobId, JobExecutionContext context) throws GFacException {
-        // First check whether job id is in the cache
-        if (currentlyExecutingJobCache.containsKey(jobId)) {
-
-            synchronized (this) {
-                GramJob gramJob = currentlyExecutingJobCache.get(jobId);
-
-                // Even though we check using containsKey, at this point job could be null
-                if (gramJob != null && (gramJob.getStatus() != GRAMConstants.STATUS_DONE ||
-                        gramJob.getStatus() != GRAMConstants.STATUS_FAILED)) {
-                    cancelJob(gramJob, context);
-                }
-            }
-
-        } else {
-
-            try {
-				GSSCredential gssCred = ((GSISecurityContext)context.
-				        getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getGssCredentials();
-
-				GramJob gramJob = new GramJob(null);
-				try {
-				    gramJob.setID(jobId);
-				} catch (MalformedURLException e) {
-				    throw new GFacException("Invalid job id - " + jobId, e);
-				}
-				gramJob.setCredentials(gssCred);
-
-				synchronized (this) {
-				    if (gramJob.getStatus() != GRAMConstants.STATUS_DONE ||
-				            gramJob.getStatus() != GRAMConstants.STATUS_FAILED) {
-				        cancelJob(gramJob, context);
-				    }
-				}
-			} catch (ApplicationSettingsException e) {
-				throw new GFacException(e);
-			}
-        }
-    }
-
-    private void cancelJob(GramJob gramJob, JobExecutionContext context) throws GFacException{
-
-        try {
-            gramJob.cancel();
-        } catch (GramException e) {
-            throw new GFacException("Error cancelling job, id - " + gramJob.getIDAsString(), e);
-        } catch (GSSException e) {
-
-            log.warn("Credentials invalid to cancel job. Attempting to renew credentials and re-try. " +
-                    "Job id - " + gramJob.getIDAsString());
-            renewCredentials(gramJob, context);
-
-            try {
-                gramJob.cancel();
-                gramJob.signal(GramJob.SIGNAL_COMMIT_END);
-            } catch (GramException e1) {
-                throw new GFacException("Error cancelling job, id - " + gramJob.getIDAsString(), e1);
-            } catch (GSSException e1) {
-                throw new GFacException("Error cancelling job, invalid credentials. Job id - "
-                        + gramJob.getIDAsString(), e);
-            }
-        }
-
-    }
-
-    public void initProperties(Map<String, String> properties) throws GFacException {
-
-    }
-
-    private void checkJobStatus(JobExecutionContext jobExecutionContext, GlobusHostType host, String gateKeeper)
-            throws GFacProviderException {
-        int jobStatus = listener.getCurrentStatus();
-
-        if (jobStatus == GramJob.STATUS_FAILED) {
-            
-            String errorMsg = "Job " + job.getIDAsString() + " on host " + host.getHostAddress() + " Job Exit Code = "
-                    + listener.getError() + " Error Description = " + getGramErrorString(listener.getError());
-
-            if (listener.getError() == GRAMProtocolErrorConstants.INVALID_SCRIPT_REPLY) {
-
-                // re-submitting without renewing
-                // TODO verify why we re-submit jobs when we get a invalid script reply
-                if (!reSubmissionInProgress) {
-                    reSubmissionInProgress = true;
-
-                    log.info("Invalid script reply received. Re-submitting job, id - " + job.getIDAsString());
-                    try {
-                        reSubmitJob(gateKeeper, jobExecutionContext, host);
-                    } catch (GFacException e) {
-                        throw new GFacProviderException
-                                ("Error during re-submission. Original job submission data - " + errorMsg,  e);
-                    }
-                    return;
-                }
-
-            } else if (listener.getError() == GRAMProtocolErrorConstants.ERROR_AUTHORIZATION) {
-
-                // re-submit with renewed credentials
-                if (!authorisationFailedAttempt) {
-                    authorisationFailedAttempt = true;
-                    log.info("Authorisation error contacting provider. Re-submitting job with renewed credentials.");
-
-                    try {
-                        renewCredentials(jobExecutionContext);
-                        reSubmitJob(gateKeeper, jobExecutionContext, host);
-                    } catch (GFacException e) {
-                        throw new GFacProviderException
-                                ("Error during re-submission. Original job submission data - " + errorMsg,  e);
-                    }
-
-                    return;
-                }
-
-            } else if (listener.getError() == GRAMProtocolErrorConstants.USER_CANCELLED) {
-
-                log.info("User successfully cancelled job id " + job.getIDAsString());
-                return;
-            }
-
-
-
-            log.error(errorMsg);
-
-            synchronized (this) {
-                currentlyExecutingJobCache.remove(job.getIDAsString());
-            }
-
-            throw new JobSubmissionFault(new Exception(errorMsg), host.getHostAddress(), gateKeeper,
-                            job.getRSL(), jobExecutionContext, getGramErrorString(listener.getError()),
-                    listener.getError());
-
-        } else if (jobStatus == GramJob.STATUS_DONE) {
-            log.info("Job " + job.getIDAsString() + " on host " + host.getHostAddress() + " is successfully executed.");
-
-            synchronized (this) {
-                currentlyExecutingJobCache.remove(job.getIDAsString());
-            }
-        }
-    }
-
-    public String getGramErrorString(int errorCode) {
-
-        if (resources != null) {
-            try {
-                return resources.getProperty(String.valueOf(errorCode));
-            } catch (MissingResourceException mre) {
-                log.warn("Error reading globus error descriptions.", mre);
-                return "Error code: " + errorCode;
-            }
-        } else {
-            return "Error code: " + errorCode;
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9bb8c2be/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/util/GramJobSubmissionListener.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/util/GramJobSubmissionListener.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/util/GramJobSubmissionListener.java
deleted file mode 100644
index a77864d..0000000
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/util/GramJobSubmissionListener.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-package org.apache.airavata.gfac.util;
-
-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.gfac.utils.GFacUtils;
-import org.globus.gram.GramJob;
-import org.globus.gram.GramJobListener;
-import org.ietf.jgss.GSSCredential;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GramJobSubmissionListener implements GramJobListener{
-    private final Logger log = LoggerFactory.getLogger(GramJobSubmissionListener.class);
-
-    public static final int NO_ERROR = -42;
-    public static final int INITIAL_STATUS = -43;
-
-    private volatile boolean jobDone = false;
-    private volatile int error = NO_ERROR;
-    private int currentStatus = INITIAL_STATUS;
-
-    private JobExecutionContext context;
-    private GramJob job;
-
-    public GramJobSubmissionListener(GramJob job, JobExecutionContext context) {
-        this.job = job;
-        this.context = context;
-    }
-
-    /**
-     * This method is used to block the process until the currentStatus of the job is DONE or FAILED
-     */
-    public void waitFor()  {
-        while (!isJobDone()) {
-            synchronized (this) {
-                try {
-                    wait();
-                } catch (InterruptedException e) {}
-            }
-        }
-    }
-
-
-    
-    private synchronized boolean isJobDone() {
-        return this.jobDone;
-    }
-
-    private void setStatus(int status, int error) {
-		try {
-			GFacUtils.updateJobStatus(context, context.getJobDetails(), GramProviderUtils.getApplicationJobStatus(status));
-		} catch (GFacException e) {
-			log.error("Error persisting status" + e.getLocalizedMessage(), e);
-		}
-        this.currentStatus = status;
-        this.error = error;
-
-        switch (this.currentStatus) {
-        case GramJob.STATUS_FAILED:
-            log.info("Job Error Code: " + error);
-            this.jobDone = true;
-            notifyAll();
-        case GramJob.STATUS_DONE:
-            this.jobDone = true;
-            notifyAll();
-        }
-
-    }
-
-    public synchronized void statusChanged(GramJob job) {
-
-        int jobStatus = job.getStatus();
-        String jobStatusMessage = "Status of job " + job.getIDAsString() + "is " + job.getStatusAsString();
-        /*
-         * Notify currentStatus change
-         */
-        this.context.getNotifier().publish(new StatusChangeEvent(jobStatusMessage));
-
-        /*
-         * Set new currentStatus if it is jobDone, notify all wait object
-         */
-        if (currentStatus != jobStatus) {
-            currentStatus = jobStatus;
-
-            setStatus(job.getStatus(), job.getError());
-
-            // Test to see whether we need to renew credentials
-            renewCredentials(job);
-        }
-    }
-
-    private void renewCredentials(GramJob job) {
-
-        try {
-
-            int proxyExpTime = job.getCredentials().getRemainingLifetime();
-            if (proxyExpTime < GSISecurityContext.CREDENTIAL_RENEWING_THRESH_HOLD) {
-                log.info("Job proxy expired. Trying to renew proxy");
-                GSSCredential gssCred = ((GSISecurityContext)context.
-                        getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).renewCredentials();
-                job.renew(gssCred);
-                log.info("MyProxy credentials are renewed .");
-            }
-
-        } catch (Exception e) {
-            log.error("An error occurred while trying to renew credentials. Job id " + job.getIDAsString());
-        }
-
-
-    }
-
-    public synchronized int getError() {
-        return error;
-    }
-
-    public synchronized int getCurrentStatus() {
-        return currentStatus;
-    }
-}


Mime
View raw message