Set call-home SSH port to 4334
[netconf.git] / netconf / callhome-protocol / src / main / java / org / opendaylight / netconf / callhome / protocol / NetconfCallHomeServerBuilder.java
index f9252466ba8b3b95fb25ac59341b4a47dfed8333..19d0c933a9841a55eb6120cc4554fa17582dbd60 100644 (file)
@@ -5,25 +5,23 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netconf.callhome.protocol;
 
-import com.google.common.base.Optional;
+import io.netty.channel.DefaultEventLoopGroup;
 import io.netty.channel.EventLoopGroup;
-import io.netty.channel.local.LocalEventLoopGroup;
 import io.netty.util.HashedWheelTimer;
 import java.net.InetSocketAddress;
+import java.util.Optional;
 import java.util.concurrent.TimeUnit;
-import org.apache.sshd.SshClient;
-import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.callhome.protocol.CallHomeSessionContext.Factory;
 import org.opendaylight.netconf.client.NetconfClientSessionNegotiatorFactory;
+import org.opendaylight.netconf.shaded.sshd.client.SshClient;
 import org.opendaylight.yangtools.concepts.Builder;
 
 public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServer> {
 
     private static final long DEFAULT_SESSION_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
-    private static final int DEFAULT_CALL_HOME_PORT = 6666;
+    private static final int DEFAULT_CALL_HOME_PORT = 4334;
 
     private SshClient sshClient;
     private EventLoopGroup nettyGroup;
@@ -32,25 +30,27 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
 
     private final CallHomeAuthorizationProvider authProvider;
     private final CallHomeNetconfSubsystemListener subsystemListener;
+    private final StatusRecorder recorder;
 
-    public NetconfCallHomeServerBuilder(CallHomeAuthorizationProvider authProvider,
-            CallHomeNetconfSubsystemListener subsystemListener) {
+    public NetconfCallHomeServerBuilder(final CallHomeAuthorizationProvider authProvider,
+            final CallHomeNetconfSubsystemListener subsystemListener, final StatusRecorder recorder) {
         this.authProvider = authProvider;
         this.subsystemListener = subsystemListener;
+        this.recorder = recorder;
     }
 
     @Override
     public NetconfCallHomeServer build() {
         Factory factory =
                 new CallHomeSessionContext.Factory(nettyGroup(), negotiatorFactory(), subsystemListener());
-        return new NetconfCallHomeServer(sshClient(), authProvider(), factory, bindAddress());
+        return new NetconfCallHomeServer(sshClient(), authProvider(), factory, bindAddress(), this.recorder);
     }
 
     public SshClient getSshClient() {
         return sshClient;
     }
 
-    public void setSshClient(SshClient sshClient) {
+    public void setSshClient(final SshClient sshClient) {
         this.sshClient = sshClient;
     }
 
@@ -58,7 +58,7 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         return nettyGroup;
     }
 
-    public void setNettyGroup(EventLoopGroup nettyGroup) {
+    public void setNettyGroup(final EventLoopGroup nettyGroup) {
         this.nettyGroup = nettyGroup;
     }
 
@@ -66,7 +66,7 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         return negotiationFactory;
     }
 
-    public void setNegotiationFactory(NetconfClientSessionNegotiatorFactory negotiationFactory) {
+    public void setNegotiationFactory(final NetconfClientSessionNegotiatorFactory negotiationFactory) {
         this.negotiationFactory = negotiationFactory;
     }
 
@@ -74,7 +74,7 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         return bindAddress;
     }
 
-    public void setBindAddress(InetSocketAddress bindAddress) {
+    public void setBindAddress(final InetSocketAddress bindAddress) {
         this.bindAddress = bindAddress;
     }
 
@@ -82,7 +82,6 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         return authProvider;
     }
 
-
     private InetSocketAddress bindAddress() {
         return bindAddress != null ? bindAddress : defaultBindAddress();
     }
@@ -107,21 +106,20 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         return sshClient != null ? sshClient : defaultSshClient();
     }
 
-    private SshClient defaultSshClient() {
+    private static SshClient defaultSshClient() {
         return SshClient.setUpDefaultClient();
     }
 
-    private NetconfClientSessionNegotiatorFactory defaultNegotiationFactory() {
+    private static NetconfClientSessionNegotiatorFactory defaultNegotiationFactory() {
         return new NetconfClientSessionNegotiatorFactory(new HashedWheelTimer(),
-                Optional.<NetconfHelloMessageAdditionalHeader>absent(), DEFAULT_SESSION_TIMEOUT_MILLIS);
+                                                         Optional.empty(), DEFAULT_SESSION_TIMEOUT_MILLIS);
     }
 
-    private EventLoopGroup defaultNettyGroup() {
-        return new LocalEventLoopGroup();
+    private static EventLoopGroup defaultNettyGroup() {
+        return new DefaultEventLoopGroup();
     }
 
-    private InetSocketAddress defaultBindAddress() {
+    private static InetSocketAddress defaultBindAddress() {
         return new InetSocketAddress(DEFAULT_CALL_HOME_PORT);
     }
-
 }