Teach netconf-client abount maximum incoming chunk size
[netconf.git] / netconf / netconf-client / src / main / java / org / opendaylight / netconf / client / conf / NetconfClientConfigurationBuilder.java
index 8047d60f1cca6cdc9101b9a782d117349992e137..09002ab1e430c675c3d17174d0b6aed3e518e979 100644 (file)
@@ -7,11 +7,19 @@
  */
 package org.opendaylight.netconf.client.conf;
 
+import static com.google.common.base.Preconditions.checkArgument;
+
 import java.net.InetSocketAddress;
+import java.util.List;
+import org.checkerframework.checker.index.qual.NonNegative;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
+import org.opendaylight.netconf.client.SslHandlerFactory;
+import org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator;
+import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
+import org.opendaylight.netconf.nettyutil.handler.ssh.client.NetconfSshClient;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 
 public class NetconfClientConfigurationBuilder {
 
@@ -26,6 +34,11 @@ public class NetconfClientConfigurationBuilder {
     private ReconnectStrategy reconnectStrategy;
     private AuthenticationHandler authHandler;
     private NetconfClientConfiguration.NetconfClientProtocol clientProtocol = DEFAULT_CLIENT_PROTOCOL;
+    private SslHandlerFactory sslHandlerFactory;
+    private NetconfSshClient sshClient;
+    private List<Uri> odlHelloCapabilities;
+    private @NonNegative int maximumIncomingChunkSize =
+        AbstractNetconfSessionNegotiator.DEFAULT_MAXIMUM_INCOMING_CHUNK_SIZE;
 
     protected NetconfClientConfigurationBuilder() {
     }
@@ -34,43 +47,76 @@ public class NetconfClientConfigurationBuilder {
         return new NetconfClientConfigurationBuilder();
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withAddress(final InetSocketAddress address) {
         this.address = address;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withConnectionTimeoutMillis(final long connectionTimeoutMillis) {
         this.connectionTimeoutMillis = connectionTimeoutMillis;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withProtocol(
             final NetconfClientConfiguration.NetconfClientProtocol clientProtocol) {
         this.clientProtocol = clientProtocol;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withAdditionalHeader(
             final NetconfHelloMessageAdditionalHeader additionalHeader) {
         this.additionalHeader = additionalHeader;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withSessionListener(final NetconfClientSessionListener sessionListener) {
         this.sessionListener = sessionListener;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withReconnectStrategy(final ReconnectStrategy reconnectStrategy) {
         this.reconnectStrategy = reconnectStrategy;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
     public NetconfClientConfigurationBuilder withAuthHandler(final AuthenticationHandler authHandler) {
         this.authHandler = authHandler;
         return this;
     }
 
+    @SuppressWarnings("checkstyle:hiddenField")
+    public NetconfClientConfigurationBuilder withSslHandlerFactory(final SslHandlerFactory sslHandlerFactory) {
+        this.sslHandlerFactory = sslHandlerFactory;
+        return this;
+    }
+
+    @SuppressWarnings("checkstyle:hiddenField")
+    public NetconfClientConfigurationBuilder withSshClient(final NetconfSshClient sshClient) {
+        this.sshClient = sshClient;
+        return this;
+    }
+
+    @SuppressWarnings("checkstyle:hiddenField")
+    public NetconfClientConfigurationBuilder withOdlHelloCapabilities(final List<Uri> odlHelloCapabilities) {
+        this.odlHelloCapabilities = odlHelloCapabilities;
+        return this;
+    }
+
+    @SuppressWarnings("checkstyle:hiddenField")
+    public NetconfClientConfigurationBuilder withMaximumIncomingChunkSize(
+            final @NonNegative int maximumIncomingChunkSize) {
+        checkArgument(maximumIncomingChunkSize > 0);
+        this.maximumIncomingChunkSize  = maximumIncomingChunkSize;
+        return this;
+    }
+
     final InetSocketAddress getAddress() {
         return address;
     }
@@ -99,8 +145,25 @@ public class NetconfClientConfigurationBuilder {
         return clientProtocol;
     }
 
+    final SslHandlerFactory getSslHandlerFactory() {
+        return sslHandlerFactory;
+    }
+
+    public NetconfSshClient getSshClient() {
+        return sshClient;
+    }
+
+    final List<Uri> getOdlHelloCapabilities() {
+        return odlHelloCapabilities;
+    }
+
+    final @NonNegative int getMaximumIncomingChunkSize() {
+        return maximumIncomingChunkSize;
+    }
+
     public NetconfClientConfiguration build() {
         return new NetconfClientConfiguration(clientProtocol, address, connectionTimeoutMillis, additionalHeader,
-                sessionListener, reconnectStrategy, authHandler);
+                sessionListener, reconnectStrategy, authHandler, sslHandlerFactory, sshClient, odlHelloCapabilities,
+                maximumIncomingChunkSize);
     }
 }