karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject karaf git commit: KARAF-4246 - Add support of idle timeout to the client
Date Wed, 06 Jan 2016 08:19:13 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x 9f08eb9e9 -> 48c791585


KARAF-4246 - Add support of idle timeout to the client


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

Branch: refs/heads/karaf-3.0.x
Commit: 48c791585b21122977b041b812ce7be4823953cb
Parents: 9f08eb9
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Wed Jan 6 09:18:49 2016 +0100
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Wed Jan 6 09:18:49 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/karaf/client/ClientConfig.java | 17 ++++++++++++++++-
 .../main/java/org/apache/karaf/client/Main.java    |  2 ++
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/48c79158/client/src/main/java/org/apache/karaf/client/ClientConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/karaf/client/ClientConfig.java b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
index 576c6f6..fc11435 100644
--- a/client/src/main/java/org/apache/karaf/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
@@ -38,6 +38,7 @@ public class ClientConfig {
     private int level;
     private int retryAttempts;
     private int retryDelay;
+    private long idleTimeout;
     private boolean batch;
     private String file = null;
     private String keyFile = null;
@@ -64,6 +65,7 @@ public class ClientConfig {
         level = Integer.parseInt(shellCfg.getProperty("logLevel", "1"));
         retryAttempts = 0;
         retryDelay = 2;
+        idleTimeout = Long.parseLong(shellCfg.getProperty("sshIdleTimeout", "1800000"));
         batch = false;
         file = null;
         user = null;
@@ -139,6 +141,13 @@ public class ClientConfig {
                     } else {
                         keyFile = args[i];
                     }
+                } else if (args[i].equals("-t")) {
+                    if (args.length <= ++i) {
+                        System.err.println("miss the idle timeout");
+                        System.exit(1);
+                    } else {
+                        idleTimeout = Long.parseLong(args[i]);
+                    }
                 } else if (args[i].equals("--help")) {
                     showHelp();
                 } else {
@@ -187,7 +196,8 @@ public class ClientConfig {
         System.out.println("  -d [delay]    intra-retry delay (defaults to 2 seconds)");
         System.out.println("  -b            batch mode, specify multiple commands via standard
input");
         System.out.println("  -f [file]     read commands from the specified file");
-        System.out.println("  -k [keyFile]    specify the private keyFile location when using
key login, need have BouncyCastle registered as security provider using this flag");
+        System.out.println("  -k [keyFile]  specify the private keyFile location when using
key login, need have BouncyCastle registered as security provider using this flag");
+        System.out.println("  -t [timeout]  specify the idle timeout");
         System.out.println("  [commands]    commands to run");
         System.out.println("If no commands are specified, the client will be put in an interactive
mode");
         System.exit(0);
@@ -293,4 +303,9 @@ public class ClientConfig {
     public String getKeyFile() {
         return keyFile;
     }
+
+    public long getIdleTimeout() {
+        return idleTimeout;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/48c79158/client/src/main/java/org/apache/karaf/client/Main.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/karaf/client/Main.java b/client/src/main/java/org/apache/karaf/client/Main.java
index f5b2cb3..50071af 100644
--- a/client/src/main/java/org/apache/karaf/client/Main.java
+++ b/client/src/main/java/org/apache/karaf/client/Main.java
@@ -42,6 +42,7 @@ import org.apache.sshd.client.future.ConnectFuture;
 import org.apache.sshd.client.kex.ECDHP256;
 import org.apache.sshd.client.kex.ECDHP384;
 import org.apache.sshd.client.kex.ECDHP521;
+import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.KeyExchange;
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.RuntimeSshException;
@@ -97,6 +98,7 @@ public class Main {
 
             client = (SshClient)clientBuilder.build();
             setupAgent(config.getUser(), config.getKeyFile(), client);
+            client.getProperties().put(FactoryManager.IDLE_TIMEOUT, String.valueOf(config.getIdleTimeout()));
             final Console console = System.console();
             if (console != null) {
                 client.setUserInteraction(new UserInteraction() {


Mime
View raw message