Repository: karaf Updated Branches: refs/heads/master e8bbe3bd7 -> d5d774f06
[KARAF-5118] Make SSHD server threads configurable Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/d5d774f0 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/d5d774f0 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/d5d774f0 Branch: refs/heads/master Commit: d5d774f06597e5661429025bf328336ccc46c77b Parents: e8bbe3b Author: Andrea Cosentino <[email protected]> Authored: Mon May 8 11:24:08 2017 +0200 Committer: Andrea Cosentino <[email protected]> Committed: Mon May 8 12:22:49 2017 +0200 ---------------------------------------------------------------------- .../karaf/instance/resources/etc/org.apache.karaf.shell.cfg | 5 +++++ .../src/main/java/org/apache/karaf/shell/ssh/Activator.java | 2 ++ .../java/org/apache/karaf/shell/ssh/SshServerAction.java | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/d5d774f0/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg ---------------------------------------------------------------------- diff --git a/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg b/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg index 3983df2..e91192d 100644 --- a/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg +++ b/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.shell.cfg @@ -34,6 +34,11 @@ sshHost = ${SUBST-SSH-HOST} sshIdleTimeout = 1800000 # +# The nio-workes defines the number of NIO worker threads to use +# +nio-workers = 2 + +# # sshRealm defines which JAAS domain to use for password authentication. # sshRealm = karaf http://git-wip-us.apache.org/repos/asf/karaf/blob/d5d774f0/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java ---------------------------------------------------------------------- diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java index 9c4ce12..1248112 100644 --- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java +++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java @@ -141,6 +141,7 @@ public class Activator extends BaseActivator implements ManagedService { int sshPort = getInt("sshPort", 8181); String sshHost = getString("sshHost", "0.0.0.0"); long sshIdleTimeout = getLong("sshIdleTimeout", 1800000); + int nioWorkers = getInt("nio-workers", 2); String sshRealm = getString("sshRealm", "karaf"); String hostKey = getString("hostKey", System.getProperty("karaf.etc") + "/host.key"); String hostKeyFormat = getString("hostKeyFormat", "simple"); @@ -194,6 +195,7 @@ public class Activator extends BaseActivator implements ManagedService { server.setAgentFactory(KarafAgentFactory.getInstance()); server.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE); server.getProperties().put(SshServer.IDLE_TIMEOUT, Long.toString(sshIdleTimeout)); + server.getProperties().put(SshServer.NIO_WORKERS, new Integer(nioWorkers).toString()); if (moduliUrl != null) { server.getProperties().put(SshServer.MODULI_URL, moduliUrl); } http://git-wip-us.apache.org/repos/asf/karaf/blob/d5d774f0/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java ---------------------------------------------------------------------- diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java index db32c1a..74ee25a 100644 --- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java +++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java @@ -41,6 +41,9 @@ public class SshServerAction implements Action @Option(name = "-i", aliases = { "--idle-timeout" }, description = "The session idle timeout in milliseconds", required = false, multiValued = false) private long idleTimeout = 1800000; + + @Option(name = "-n", aliases = { "--nio-workers" }, description = "The number of NIO worker threads to use", required = false, multiValued = false) + private int nioWorkers = 2; @Option(name = "-w", aliases = { "--welcome-banner" }, description = "The welcome banner to display when logging in", required = false, multiValued = false) private String welcomeBanner; @@ -61,6 +64,9 @@ public class SshServerAction implements Action // idle timeout server.getProperties().put(SshServer.IDLE_TIMEOUT, Long.toString(idleTimeout)); + // nio-workes + server.getProperties().put(SshServer.NIO_WORKERS, new Integer(nioWorkers).toString()); + // welcome banner if (welcomeBanner != null) { server.getProperties().put(SshServer.WELCOME_BANNER, welcomeBanner); @@ -69,7 +75,7 @@ public class SshServerAction implements Action // starting the SSHd server server.start(); - System.out.println("SSH server listening on port " + port + " (idle timeout " + idleTimeout + "ms)"); + System.out.println("SSH server listening on port " + port + " (idle timeout " + idleTimeout + "ms) " + " (nio worker Threads " + nioWorkers + ") "); if (!background) { synchronized (this) {
