-import io.netty.util.concurrent.Promise;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.api.NetconfSession;
-import org.opendaylight.controller.netconf.api.NetconfTerminationReason;
-import org.opendaylight.controller.netconf.util.AbstractSslChannelInitializer;
-import org.opendaylight.protocol.framework.AbstractDispatcher;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
-import org.opendaylight.protocol.framework.SessionListener;
-import org.opendaylight.protocol.framework.SessionListenerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-import java.io.Closeable;
-import java.net.InetSocketAddress;
-
-public class NetconfClientDispatcher extends AbstractDispatcher<NetconfClientSession, NetconfClientSessionListener> implements Closeable {
-
- private static final Logger logger = LoggerFactory.getLogger(NetconfClient.class);
-
- private final Optional<SSLContext> maybeContext;
- private final NetconfClientSessionNegotiatorFactory negotatorFactory;
- private final HashedWheelTimer timer;
-
- public NetconfClientDispatcher(final Optional<SSLContext> maybeContext, EventLoopGroup bossGroup, EventLoopGroup workerGroup) {
- super(bossGroup, workerGroup);
- this.maybeContext = Preconditions.checkNotNull(maybeContext);
- timer = new HashedWheelTimer();
- this.negotatorFactory = new NetconfClientSessionNegotiatorFactory(timer);
- }
-
- public Future<NetconfClientSession> createClient(InetSocketAddress address,
- final NetconfClientSessionListener sessionListener, ReconnectStrategy strat) {
-
- return super.createClient(address, strat, new PipelineInitializer<NetconfClientSession>() {
-
- @Override
- public void initializeChannel(final SocketChannel ch, final Promise<NetconfClientSession> promise) {
- initialize(ch, promise);
- }
-
- private void initialize(SocketChannel ch, Promise<NetconfClientSession> promise) {
- new ClientSslChannelInitializer(maybeContext, negotatorFactory, sessionListener).initialize(ch, promise);
- }
- });
- }
-
- private static class ClientSslChannelInitializer extends AbstractSslChannelInitializer {
-
- private final NetconfClientSessionNegotiatorFactory negotiatorFactory;
- private final NetconfClientSessionListener sessionListener;
-
- private ClientSslChannelInitializer(Optional<SSLContext> maybeContext,
- NetconfClientSessionNegotiatorFactory negotiatorFactory, NetconfClientSessionListener sessionListener) {
- super(maybeContext);
- this.negotiatorFactory = negotiatorFactory;
- this.sessionListener = sessionListener;
- }