airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [2/2] airavata git commit: Create new session if previous connection is closed
Date Fri, 18 Mar 2016 17:28:37 GMT
Create new session if previous connection is closed


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

Branch: refs/heads/master
Commit: c11667b716ebef85c2153cd3f3113f30d91d4b22
Parents: 49e962d
Author: Shameera Rathnayaka <shameerainfo@gmail.com>
Authored: Fri Mar 18 11:23:36 2016 -0400
Committer: Shameera Rathnayaka <shameerainfo@gmail.com>
Committed: Fri Mar 18 11:23:36 2016 -0400

----------------------------------------------------------------------
 .../src/main/java/org/apache/airavata/gfac/impl/Factory.java    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/c11667b7/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
index 7b01ffe..c04de11 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
@@ -422,7 +422,8 @@ public abstract class Factory {
 	public static Session getSSHSession(AuthenticationInfo authenticationInfo, ServerInfo serverInfo)
throws AiravataException {
 		SSHKeyAuthentication authentication = null;
 		String key = serverInfo.getUserName() + "_" + serverInfo.getHost() + "_" + serverInfo.getPort();
-		if (sessionMap.get(key) == null) {
+		Session session = sessionMap.get(key);
+		if (session == null || !session.isConnected()) {
 			try {
 				if (authenticationInfo instanceof SSHKeyAuthentication) {
 					authentication = (SSHKeyAuthentication) authenticationInfo;
@@ -432,7 +433,7 @@ public abstract class Factory {
 				JSch jSch = new JSch();
 				jSch.addIdentity(UUID.randomUUID().toString(), authentication.getPrivateKey(), authentication.getPublicKey(),
 						authentication.getPassphrase().getBytes());
-				Session session = jSch.getSession(serverInfo.getUserName(), serverInfo.getHost(),
+				session = jSch.getSession(serverInfo.getUserName(), serverInfo.getHost(),
 						serverInfo.getPort());
 				session.setUserInfo(new DefaultUserInfo(serverInfo.getUserName(), null, authentication.getPassphrase()));
 				if (authentication.getStrictHostKeyChecking().equals("yes")) {


Mime
View raw message