airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dimuthu...@apache.org
Subject [airavata] branch staging updated: Logging improvements
Date Tue, 10 Jul 2018 18:42:19 GMT
This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch staging
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/staging by this push:
     new 321b79e  Logging improvements
321b79e is described below

commit 321b79e88b528ec5a399f8a8e55147bce74225ab
Author: dimuthu <dimuthu.upeksha2@gmail.com>
AuthorDate: Tue Jul 10 14:42:10 2018 -0400

    Logging improvements
---
 .../airavata/helix/adaptor/PoolingSSHJClient.java   | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/modules/airavata-helix/agent-impl/sshj-agent/src/main/java/org/apache/airavata/helix/adaptor/PoolingSSHJClient.java
b/modules/airavata-helix/agent-impl/sshj-agent/src/main/java/org/apache/airavata/helix/adaptor/PoolingSSHJClient.java
index 13a1c67..c207ef4 100644
--- a/modules/airavata-helix/agent-impl/sshj-agent/src/main/java/org/apache/airavata/helix/adaptor/PoolingSSHJClient.java
+++ b/modules/airavata-helix/agent-impl/sshj-agent/src/main/java/org/apache/airavata/helix/adaptor/PoolingSSHJClient.java
@@ -86,7 +86,7 @@ public class PoolingSSHJClient extends SSHClient {
         try {
             if (clientInfoMap.isEmpty()) {
                 SSHClient newClient = createNewSSHClient();
-                SSHClientInfo info = new SSHClientInfo(1, System.currentTimeMillis());
+                SSHClientInfo info = new SSHClientInfo(1, System.currentTimeMillis(), 0);
                 clientInfoMap.put(newClient, info);
 
                 /* if this is the very first connection that is created to the compute host,
fetch the MaxSessions
@@ -126,19 +126,20 @@ public class PoolingSSHJClient extends SSHClient {
                     Map.Entry<SSHClient, SSHClientInfo> minEntry = minEntryOp.get();
                     // use the connection with least amount of sessions created.
 
-                    logger.debug("Session count for selected connection {}. Threshold {}",
minEntry.getValue().getSessionCount(), maxSessionsForConnection);
+                    logger.debug("Session count for selected connection {} is {}. Threshold
{}",
+                            minEntry.getValue().getClientId(), minEntry.getValue().getSessionCount(),
maxSessionsForConnection);
                     if (minEntry.getValue().getSessionCount() >= maxSessionsForConnection)
{
                         // if it exceeds the maximum session count, create a new connection
                         logger.debug("Connection with least amount of sessions exceeds the
threshold. So creating a new connection. " +
                                 "Current connection count " + clientInfoMap.size());
                         SSHClient newClient = createNewSSHClient();
-                        SSHClientInfo info = new SSHClientInfo(1, System.currentTimeMillis());
+                        SSHClientInfo info = new SSHClientInfo(1, System.currentTimeMillis(),
clientInfoMap.size());
                         clientInfoMap.put(newClient, info);
                         return newClient;
 
                     } else {
                         // otherwise reuse the same connetion
-                        logger.debug("Reusing the same connection as it doesn't exceed the
threshold");
+                        logger.debug("Reusing the same connection {} as it doesn't exceed
the threshold", minEntry.getValue().getClientId());
                         minEntry.getValue().setSessionCount(minEntry.getValue().getSessionCount()
+ 1);
                         minEntry.getValue().setLastAccessedTime(System.currentTimeMillis());
                         return minEntry.getKey();
@@ -261,10 +262,12 @@ public class PoolingSSHJClient extends SSHClient {
 
         private int sessionCount;
         private long lastAccessedTime;
+        private int clientId;
 
-        public SSHClientInfo(int sessionCount, long lastAccessedTime) {
+        public SSHClientInfo(int sessionCount, long lastAccessedTime, int clientId) {
             this.sessionCount = sessionCount;
             this.lastAccessedTime = lastAccessedTime;
+            this.clientId = clientId;
         }
 
         public int getSessionCount() {
@@ -284,6 +287,14 @@ public class PoolingSSHJClient extends SSHClient {
             this.lastAccessedTime = lastAccessedTime;
             return this;
         }
+
+        public int getClientId() {
+            return clientId;
+        }
+
+        public void setClientId(int clientId) {
+            this.clientId = clientId;
+        }
     }
 
     public HostKeyVerifier getHostKeyVerifier() {


Mime
View raw message