X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fconnection%2Flistener%2FConnectionReadyListenerImpl.java;h=21769465227e0caa49a333ab525d0675a28c8cad;hb=c5f66e01bcc7908e234e502ad172202620f294a8;hp=0047deccac2984e737b886273ad611fa7e07fee3;hpb=52f1d136aff5568e9d9607e6a61e4ec128c962aa;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/ConnectionReadyListenerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/ConnectionReadyListenerImpl.java index 0047deccac..2176946522 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/ConnectionReadyListenerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/ConnectionReadyListenerImpl.java @@ -11,33 +11,35 @@ import java.util.concurrent.Future; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext; -import org.opendaylight.openflowplugin.openflow.md.core.HandshakeStepWrapper; +import org.opendaylight.openflowplugin.impl.connection.HandshakeStepWrapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * oneshot listener - once connection is ready, initiate handshake (if not already started by device) + * Oneshot listener - once connection is ready, initiate handshake (if not already started by device). */ public class ConnectionReadyListenerImpl implements ConnectionReadyListener { private static final Logger LOG = LoggerFactory.getLogger(ConnectionReadyListenerImpl.class); - private ConnectionContext connectionContext; - private HandshakeContext handshakeContext; + private final ConnectionContext connectionContext; + private final HandshakeContext handshakeContext; /** - * @param connectionContext - * @param handshakeContext + * Constructor. + * + * @param connectionContext - connection context + * @param handshakeContext - handshake context */ - public ConnectionReadyListenerImpl(ConnectionContext connectionContext, - HandshakeContext handshakeContext) { - this.connectionContext = connectionContext; - this.handshakeContext = handshakeContext; + public ConnectionReadyListenerImpl(ConnectionContext connectionContext, HandshakeContext handshakeContext) { + this.connectionContext = connectionContext; + this.handshakeContext = handshakeContext; } @Override + @SuppressWarnings("checkstyle:IllegalCatch") public void onConnectionReady() { - if(LOG.isDebugEnabled()) { + if (LOG.isDebugEnabled()) { LOG.debug("device is connected and ready-to-use (pipeline prepared): {}", connectionContext.getConnectionAdapter().getRemoteAddress()); } @@ -51,21 +53,15 @@ public class ConnectionReadyListenerImpl implements ConnectionReadyListener { final Future handshakeResult = handshakeContext.getHandshakePool().submit(handshakeStepWrapper); try { - // as we run not in netty thread, need to remain in sync lock until initial handshake step processed + // As we run not in netty thread, + // need to remain in sync lock until initial handshake step processed. handshakeResult.get(); } catch (Exception e) { - LOG.error("failed to process onConnectionReady event on device {}, reason {}", + LOG.error("failed to process onConnectionReady event on device {}", connectionContext.getConnectionAdapter().getRemoteAddress(), e); connectionContext.closeConnection(false); - try { - handshakeContext.close(); - } catch (Exception e1) { - LOG.error("failed to close handshake context for device {}, reason {}", - connectionContext.getConnectionAdapter().getRemoteAddress(), - e1 - ); - } + handshakeContext.close(); } } else { LOG.debug("already touched by hello message from device {} after second check",