Class AbstractNetconfSessionNegotiator<P extends org.opendaylight.netconf.api.NetconfSessionPreferences,​S extends AbstractNetconfSession<S,​L>,​L extends org.opendaylight.netconf.api.NetconfSessionListener<S>>

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, NetconfSessionNegotiator<S>

    public abstract class AbstractNetconfSessionNegotiator<P extends org.opendaylight.netconf.api.NetconfSessionPreferences,​S extends AbstractNetconfSession<S,​L>,​L extends org.opendaylight.netconf.api.NetconfSessionListener<S>>
    extends io.netty.channel.ChannelInboundHandlerAdapter
    implements NetconfSessionNegotiator<S>
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  AbstractNetconfSessionNegotiator.State
      Possible states for Finite State Machine.
      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractNetconfSessionNegotiator​(P sessionPreferences, io.netty.util.concurrent.Promise<S> promise, io.netty.channel.Channel channel, io.netty.util.Timer timer, L sessionListener, long connectionTimeoutMillis)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void channelActive​(io.netty.channel.ChannelHandlerContext ctx)  
      void channelRead​(io.netty.channel.ChannelHandlerContext ctx, Object msg)  
      void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)  
      protected abstract S getSession​(L sessionListener, io.netty.channel.Channel channel, org.opendaylight.netconf.api.messages.NetconfHelloMessage message)  
      protected S getSessionForHelloMessage​(org.opendaylight.netconf.api.messages.NetconfHelloMessage netconfMessage)  
      P getSessionPreferences()  
      protected abstract void handleMessage​(org.opendaylight.netconf.api.messages.NetconfHelloMessage msg)  
      protected boolean ifNegotiatedAlready()  
      protected void negotiationFailed​(Throwable cause)  
      protected void negotiationSuccessful​(S session)  
      protected void replaceHelloMessageInboundHandler​(S session)
      Remove special inbound handler for hello message.
      protected void sendMessage​(org.opendaylight.netconf.api.NetconfMessage msg)
      Send a message to peer and fail negotiation if it does not reach the peer.
      protected void startNegotiation()  
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from interface io.netty.channel.ChannelHandler

        handlerAdded, handlerRemoved
      • Methods inherited from interface io.netty.channel.ChannelInboundHandler

        channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
    • Field Detail

      • sessionPreferences

        protected final P extends org.opendaylight.netconf.api.NetconfSessionPreferences sessionPreferences
      • channel

        protected final io.netty.channel.Channel channel
    • Constructor Detail

      • AbstractNetconfSessionNegotiator

        protected AbstractNetconfSessionNegotiator​(P sessionPreferences,
                                                   io.netty.util.concurrent.Promise<S> promise,
                                                   io.netty.channel.Channel channel,
                                                   io.netty.util.Timer timer,
                                                   L sessionListener,
                                                   long connectionTimeoutMillis)
    • Method Detail

      • startNegotiation

        protected final void startNegotiation()
      • ifNegotiatedAlready

        protected final boolean ifNegotiatedAlready()
      • getSessionPreferences

        public P getSessionPreferences()
      • getSessionForHelloMessage

        protected final S getSessionForHelloMessage​(org.opendaylight.netconf.api.messages.NetconfHelloMessage netconfMessage)
                                             throws org.opendaylight.netconf.api.NetconfDocumentedException
        Throws:
        org.opendaylight.netconf.api.NetconfDocumentedException
      • replaceHelloMessageInboundHandler

        protected final void replaceHelloMessageInboundHandler​(S session)
        Remove special inbound handler for hello message. Insert regular netconf xml message (en|de)coders.

        Inbound hello message handler should be kept until negotiation is successful It caches any non-hello messages while negotiation is still in progress

      • getSession

        protected abstract S getSession​(L sessionListener,
                                        io.netty.channel.Channel channel,
                                        org.opendaylight.netconf.api.messages.NetconfHelloMessage message)
                                 throws org.opendaylight.netconf.api.NetconfDocumentedException
        Throws:
        org.opendaylight.netconf.api.NetconfDocumentedException
      • negotiationSuccessful

        protected final void negotiationSuccessful​(S session)
      • negotiationFailed

        protected void negotiationFailed​(Throwable cause)
      • sendMessage

        protected final void sendMessage​(org.opendaylight.netconf.api.NetconfMessage msg)
        Send a message to peer and fail negotiation if it does not reach the peer.
        Parameters:
        msg - Message which should be sent.
      • channelActive

        public final void channelActive​(io.netty.channel.ChannelHandlerContext ctx)
        Specified by:
        channelActive in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
      • channelRead

        public final void channelRead​(io.netty.channel.ChannelHandlerContext ctx,
                                      Object msg)
        Specified by:
        channelRead in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
      • exceptionCaught

        public void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                    Throwable cause)
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
      • handleMessage

        protected abstract void handleMessage​(org.opendaylight.netconf.api.messages.NetconfHelloMessage msg)
                                       throws Exception
        Throws:
        Exception