airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject git commit: closing thrift client connections
Date Tue, 14 Oct 2014 14:57:34 GMT
Repository: airavata
Updated Branches:
  refs/heads/master e7be1f4e8 -> 6e1aa3ede


closing thrift client connections


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

Branch: refs/heads/master
Commit: 6e1aa3ede5e2f94f8711b53a203e15c81959fe3e
Parents: e7be1f4
Author: lahiru <lahiru@apache.org>
Authored: Tue Oct 14 10:57:26 2014 -0400
Committer: lahiru <lahiru@apache.org>
Committed: Tue Oct 14 10:57:26 2014 -0400

----------------------------------------------------------------------
 .../api/server/handler/AiravataServerHandler.java   | 12 ++++++++++--
 .../core/impl/GFACServiceJobSubmitter.java          | 16 +++++++++++-----
 2 files changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/6e1aa3ed/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index 9e257f7..fa52501 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -900,13 +900,21 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher
{
  	            throw exception;
  		}
 
-        if (getOrchestratorClient().validateExperiment(airavataExperimentId)) {
+        Client orchestratorClient = getOrchestratorClient();
+        try{
+        if (orchestratorClient.validateExperiment(airavataExperimentId)) {
             logger.infoId(airavataExperimentId, "Experiment validation succeed.");
             return true;
         } else {
             logger.infoId(airavataExperimentId, "Experiment validation failed.");
             return false;
+        }}catch (TException e){
+            throw e;
+        }finally {
+            orchestratorClient.getOutputProtocol().getTransport().close();
         }
+
+
     }
 
     /**
@@ -1233,7 +1241,7 @@ public class AiravataServerHandler implements Airavata.Iface, Watcher
{
             logger.errorId(experimentId, "Error while updating task status, hence updated
experiment status to " + status.toString(), e);
             throw new TException(e);
         }finally {
-            orchestratorClient.getInputProtocol().getTransport().close();
+            orchestratorClient.getOutputProtocol().getTransport().close();
         }
         return true;
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/6e1aa3ed/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACServiceJobSubmitter.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACServiceJobSubmitter.java
b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACServiceJobSubmitter.java
index a052d06..67c3f11 100644
--- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACServiceJobSubmitter.java
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACServiceJobSubmitter.java
@@ -75,6 +75,7 @@ public class GFACServiceJobSubmitter implements JobSubmitter, Watcher {
 
 	public boolean submit(String experimentID, String taskID, String tokenId) throws OrchestratorException
{
 		ZooKeeper zk = orchestratorContext.getZk();
+        GfacService.Client gfacClient = null;
 		try {
 			if (zk == null || !zk.getState().isConnected()) {
 				String zkhostPort = AiravataZKUtils.getZKhostPort();
@@ -96,12 +97,12 @@ public class GFACServiceJobSubmitter implements JobSubmitter, Watcher
{
 				String gfacNodeData = new String(zk.getData(gfacServer + File.separator + pickedChild,
false, null));
 				logger.info("GFAC instance node data: " + gfacNodeData);
 				String[] split = gfacNodeData.split(":");
-				GfacService.Client localhost = GFacClientFactory.createGFacClient(split[0], Integer.parseInt(split[1]));
+				gfacClient = GFacClientFactory.createGFacClient(split[0], Integer.parseInt(split[1]));
 				if (zk.exists(gfacServer + File.separator + pickedChild, false) != null) {
 					// before submitting the job we check again the state of the node
 					if (GFacUtils.createExperimentEntry(experimentID, taskID, zk, experimentNode, pickedChild,
tokenId)) {
 						// FIXME:: The GatewayID is temporarily read from properties file. It should instead
be inferred from the token.
-						return localhost.submitJob(experimentID, taskID, ServerSettings.getSetting(Constants.GATEWAY_NAME));
+						return gfacClient.submitJob(experimentID, taskID, ServerSettings.getSetting(Constants.GATEWAY_NAME));
 					}
 				}
 			}
@@ -117,12 +118,15 @@ public class GFACServiceJobSubmitter implements JobSubmitter, Watcher
{
 			e.printStackTrace();
 		} catch (Exception e) {
 			e.printStackTrace();
-		}
-		return false;
+		}finally {
+            gfacClient.getOutputProtocol().getTransport().close();
+        }
+        return false;
 	}
 
     public boolean terminate(String experimentID, String taskID) throws OrchestratorException
{
         ZooKeeper zk = orchestratorContext.getZk();
+        GfacService.Client localhost = null;
         try {
             if (zk == null || !zk.getState().isConnected()) {
                 String zkhostPort = AiravataZKUtils.getZKhostPort();
@@ -144,7 +148,7 @@ public class GFACServiceJobSubmitter implements JobSubmitter, Watcher
{
                 String gfacNodeData = new String(zk.getData(gfacServer + File.separator +
pickedChild, false, null));
                 logger.info("GFAC instance node data: " + gfacNodeData);
                 String[] split = gfacNodeData.split(":");
-                GfacService.Client localhost = GFacClientFactory.createGFacClient(split[0],
Integer.parseInt(split[1]));
+                localhost = GFacClientFactory.createGFacClient(split[0], Integer.parseInt(split[1]));
                 if (zk.exists(gfacServer + File.separator + pickedChild, false) != null)
{
                     // before submitting the job we check again the state of the node
                     if (GFacUtils.createExperimentEntry(experimentID, taskID, zk, experimentNode,
pickedChild, null)) {
@@ -164,6 +168,8 @@ public class GFACServiceJobSubmitter implements JobSubmitter, Watcher
{
             e.printStackTrace();
         } catch (Exception e) {
             e.printStackTrace();
+        }finally {
+
         }
         return false;
     }


Mime
View raw message