X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fcommons%2Fprotocol-framework%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fframework%2FAbstractSessionNegotiator.java;h=a883eaf4ea1fa55980f3f897d4dcb45ca500c2bf;hp=9f9f811e889f85c20352db331187f008b812bd85;hb=6ca44d2095f0887508dd32f0174058a627eff4f9;hpb=9390dd5bea2420cdbb1e4f6c2029091811c4df5a diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java index 9f9f811e88..a883eaf4ea 100644 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java +++ b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java @@ -8,6 +8,7 @@ package org.opendaylight.protocol.framework; import io.netty.channel.Channel; +import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.util.concurrent.Promise; @@ -23,10 +24,11 @@ import com.google.common.base.Preconditions; * needing to provide only * * @param Protocol message type - * @param Protocol session type, has to extend ProtocolSession + * @param Protocol session type, has to extend {@code ProtocolSession} */ +@Deprecated public abstract class AbstractSessionNegotiator> extends ChannelInboundHandlerAdapter implements SessionNegotiator { - private final Logger logger = LoggerFactory.getLogger(AbstractSessionNegotiator.class); + private final Logger LOG = LoggerFactory.getLogger(AbstractSessionNegotiator.class); private final Promise promise; protected final Channel channel; @@ -39,42 +41,61 @@ public abstract class AbstractSessionNegotiator { + if (!f.isSuccess()) { + LOG.info("Failed to send message {}", msg, f.cause()); + negotiationFailed(f.cause()); + } else { + LOG.trace("Message {} sent to socket", msg); + } + }); + } + @Override public final void channelActive(final ChannelHandlerContext ctx) { - logger.debug("Starting session negotiation on channel {}", channel); + LOG.debug("Starting session negotiation on channel {}", channel); try { startNegotiation(); - } catch (Exception e) { - logger.warn("Unexpected negotiation failure", e); + } catch (final Exception e) { + LOG.warn("Unexpected negotiation failure", e); negotiationFailed(e); } } @Override + @SuppressWarnings("unchecked") public final void channelRead(final ChannelHandlerContext ctx, final Object msg) { - logger.debug("Negotiation read invoked on channel {}", channel); + LOG.debug("Negotiation read invoked on channel {}", channel); try { handleMessage((M)msg); - } catch (Exception e) { - logger.debug("Unexpected error while handling negotiation message {}", msg, e); + } catch (final Exception e) { + LOG.debug("Unexpected error while handling negotiation message {}", msg, e); negotiationFailed(e); } } @Override public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) { - logger.info("Unexpected error during negotiation", cause); + LOG.info("Unexpected error during negotiation", cause); negotiationFailed(cause); } }