Search in sources :

Example 6 with NetconfXMLToMessageDecoder

use of org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder in project netconf by opendaylight.

the class AbstractNetconfSessionNegotiator method replaceHelloMessageInboundHandler.

/**
 * Remove special inbound handler for hello message. Insert regular netconf xml message (en|de)coders.
 *
 * <p>
 * Inbound hello message handler should be kept until negotiation is successful
 * It caches any non-hello messages while negotiation is still in progress
 */
protected final void replaceHelloMessageInboundHandler(final S session) {
    ChannelHandler helloMessageHandler = replaceChannelHandler(channel, AbstractChannelInitializer.NETCONF_MESSAGE_DECODER, new NetconfXMLToMessageDecoder());
    checkState(helloMessageHandler instanceof NetconfXMLToHelloMessageDecoder, "Pipeline handlers misplaced on session: %s, pipeline: %s", session, channel.pipeline());
    Iterable<NetconfMessage> netconfMessagesFromNegotiation = ((NetconfXMLToHelloMessageDecoder) helloMessageHandler).getPostHelloNetconfMessages();
    // It means, we are now using the thread now
    for (NetconfMessage message : netconfMessagesFromNegotiation) {
        session.handleMessage(message);
    }
}
Also used : NetconfXMLToHelloMessageDecoder(org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) NetconfXMLToMessageDecoder(org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder) ChannelHandler(io.netty.channel.ChannelHandler)

Aggregations

NetconfXMLToMessageDecoder (org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder)6 NetconfMessageToXMLEncoder (org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder)5 Test (org.junit.Test)3 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)3 ByteBuf (io.netty.buffer.ByteBuf)2 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)2 ChannelHandler (io.netty.channel.ChannelHandler)1 NetconfChunkAggregator (org.opendaylight.netconf.nettyutil.handler.NetconfChunkAggregator)1 NetconfEOMAggregator (org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator)1 NetconfEXICodec (org.opendaylight.netconf.nettyutil.handler.NetconfEXICodec)1 NetconfXMLToHelloMessageDecoder (org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder)1