* 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.eclipse.jdt.annotation.NonNull;
import org.opendaylight.netconf.client.NetconfClientSessionNegotiatorFactory;
-import org.opendaylight.yangtools.concepts.Builder;
-
-public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServer> {
+import org.opendaylight.netconf.nettyutil.handler.ssh.client.NetconfClientBuilder;
+import org.opendaylight.netconf.shaded.sshd.client.SshClient;
+public class NetconfCallHomeServerBuilder {
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;
private final CallHomeNetconfSubsystemListener subsystemListener;
private final StatusRecorder recorder;
- public NetconfCallHomeServerBuilder(CallHomeAuthorizationProvider authProvider,
- CallHomeNetconfSubsystemListener subsystemListener, StatusRecorder recorder) {
+ 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(), this.recorder);
+ public @NonNull NetconfCallHomeServer build() {
+ return new NetconfCallHomeServer(sshClient(), authProvider(),
+ new CallHomeSessionContext.Factory(nettyGroup(), negotiatorFactory(), subsystemListener()),
+ bindAddress(), recorder);
}
public SshClient getSshClient() {
return sshClient;
}
- public void setSshClient(SshClient sshClient) {
+ public void setSshClient(final SshClient sshClient) {
this.sshClient = sshClient;
}
return nettyGroup;
}
- public void setNettyGroup(EventLoopGroup nettyGroup) {
+ public void setNettyGroup(final EventLoopGroup nettyGroup) {
this.nettyGroup = nettyGroup;
}
return negotiationFactory;
}
- public void setNegotiationFactory(NetconfClientSessionNegotiatorFactory negotiationFactory) {
+ public void setNegotiationFactory(final NetconfClientSessionNegotiatorFactory negotiationFactory) {
this.negotiationFactory = negotiationFactory;
}
return bindAddress;
}
- public void setBindAddress(InetSocketAddress bindAddress) {
+ public void setBindAddress(final InetSocketAddress bindAddress) {
this.bindAddress = bindAddress;
}
return sshClient != null ? sshClient : defaultSshClient();
}
- private SshClient defaultSshClient() {
- return SshClient.setUpDefaultClient();
+ private static SshClient defaultSshClient() {
+ return new NetconfClientBuilder().build();
}
- 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);
}
}