Class AbstractNetconfSessionNegotiator<P extends org.opendaylight.netconf.api.NetconfSessionPreferences,S extends AbstractNetconfSession<S,L>,L extends org.opendaylight.netconf.api.NetconfSessionListener<S>>
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator<P,S,L>
-
- 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 classAbstractNetconfSessionNegotiator.StatePossible states for Finite State Machine.
-
Field Summary
Fields Modifier and Type Field Description protected io.netty.channel.Channelchannelstatic StringNAME_OF_EXCEPTION_HANDLERprotected PsessionPreferences
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractNetconfSessionNegotiator(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 voidchannelActive(io.netty.channel.ChannelHandlerContext ctx)voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)protected abstract SgetSession(L sessionListener, io.netty.channel.Channel channel, org.opendaylight.netconf.api.messages.NetconfHelloMessage message)protected SgetSessionForHelloMessage(org.opendaylight.netconf.api.messages.NetconfHelloMessage netconfMessage)PgetSessionPreferences()protected abstract voidhandleMessage(org.opendaylight.netconf.api.messages.NetconfHelloMessage msg)protected booleanifNegotiatedAlready()protected voidnegotiationFailed(Throwable cause)protected voidnegotiationSuccessful(S session)protected voidreplaceHelloMessageInboundHandler(S session)Remove special inbound handler for hello message.protected voidsendMessage(org.opendaylight.netconf.api.NetconfMessage msg)Send a message to peer and fail negotiation if it does not reach the peer.protected voidstartNegotiation()-
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
-
-
-
-
Field Detail
-
NAME_OF_EXCEPTION_HANDLER
public static final String NAME_OF_EXCEPTION_HANDLER
- See Also:
- Constant Field Values
-
sessionPreferences
protected final P extends org.opendaylight.netconf.api.NetconfSessionPreferences sessionPreferences
-
channel
protected final io.netty.channel.Channel channel
-
-
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:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter
-
channelRead
public final void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter
-
-