From: Robert Varga Date: Tue, 18 Oct 2022 15:15:14 +0000 (+0200) Subject: Improve default client parameters X-Git-Tag: v4.0.3~34 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=d9cf4638bbf31af7380656a326fc7c51007ce13c;p=netconf.git Improve default client parameters Properties can be directly set, use that instead of mucking with strings and maps. Change-Id: I90dbef2431dff8206532445998177b7cb903928c Signed-off-by: Robert Varga --- diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java index 98f049369b..b659187b87 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.net.SocketAddress; +import java.time.Duration; import java.util.concurrent.TimeUnit; import org.checkerframework.checker.lock.qual.GuardedBy; import org.checkerframework.checker.lock.qual.Holding; @@ -55,12 +56,13 @@ public final class AsyncSshHandler extends ChannelOutboundHandlerAdapter { public static final NetconfSshClient DEFAULT_CLIENT; static { - final NetconfSshClient c = new NetconfClientBuilder().build(); + final var c = new NetconfClientBuilder().build(); // Disable default timeouts from mina sshd - c.getProperties().put(CoreModuleProperties.AUTH_TIMEOUT.getName(), "0"); - c.getProperties().put(CoreModuleProperties.IDLE_TIMEOUT.getName(), "0"); - c.getProperties().put(CoreModuleProperties.NIO2_READ_TIMEOUT.getName(), "0"); - c.getProperties().put(CoreModuleProperties.TCP_NODELAY.getName(), true); + final var zero = Duration.ofMillis(0); + CoreModuleProperties.AUTH_TIMEOUT.set(c, zero); + CoreModuleProperties.IDLE_TIMEOUT.set(c, zero); + CoreModuleProperties.NIO2_READ_TIMEOUT.set(c, zero); + CoreModuleProperties.TCP_NODELAY.set(c, true); // TODO make configurable, or somehow reuse netty threadpool c.setNioWorkers(SSH_DEFAULT_NIO_WORKERS);