X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fconnection%2FConnectionManagerImpl.java;h=544e7124ba44bb6627efc050820b2803a5715545;hb=f2085daac2c4f2f9077be43baddfefc28257677f;hp=4ff951a456e4aed35c7b8f9e089aa473e8bed9ef;hpb=f74dab9e40cc10fd0a3d6e77c1fece2e16db489c;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java index 4ff951a456..544e7124ba 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java @@ -5,21 +5,18 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowplugin.impl.connection; -import org.opendaylight.openflowplugin.openflow.md.core.ErrorHandlerSimpleImpl; +package org.opendaylight.openflowplugin.impl.connection; import java.net.InetAddress; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.TimeUnit; - import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionManager; import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext; import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler; -import org.opendaylight.openflowplugin.api.openflow.device.handlers.MessageHandler; import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor; import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeListener; import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeManager; @@ -27,6 +24,7 @@ import org.opendaylight.openflowplugin.impl.connection.listener.ConnectionReadyL import org.opendaylight.openflowplugin.impl.connection.listener.HandshakeListenerImpl; import org.opendaylight.openflowplugin.impl.connection.listener.OpenflowProtocolListenerInitialImpl; import org.opendaylight.openflowplugin.impl.connection.listener.SystemNotificationsListenerImpl; +import org.opendaylight.openflowplugin.openflow.md.core.ErrorHandlerSimpleImpl; import org.opendaylight.openflowplugin.openflow.md.core.HandshakeManagerImpl; import org.opendaylight.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; @@ -41,14 +39,21 @@ public class ConnectionManagerImpl implements ConnectionManager { private static final Logger LOG = LoggerFactory.getLogger(ConnectionManagerImpl.class); private static final int HELLO_LIMIT = 20; - private boolean bitmapNegotiationEnabled = true; + private final boolean bitmapNegotiationEnabled = true; private DeviceConnectedHandler deviceConnectedHandler; + private final long echoReplyTimeout; + + public ConnectionManagerImpl(long echoReplyTimeout) { + this.echoReplyTimeout = echoReplyTimeout; + } + @Override public void onSwitchConnected(final ConnectionAdapter connectionAdapter) { - LOG.trace("preparing handshake"); - final int handshakeThreadLimit = 1; //TODO: move to constants/parametrize + LOG.trace("preparing handshake: {}", connectionAdapter.getRemoteAddress()); + + final int handshakeThreadLimit = 1; final ThreadPoolLoggingExecutor handshakePool = createHandshakePool( connectionAdapter.getRemoteAddress().toString(), handshakeThreadLimit); @@ -60,6 +65,8 @@ public class ConnectionManagerImpl implements ConnectionManager { LOG.trace("prepare handshake context"); HandshakeContext handshakeContext = new HandshakeContextImpl(handshakePool, handshakeManager); + handshakeListener.setHandshakeContext(handshakeContext); + connectionContext.setHandshakeContext(handshakeContext); LOG.trace("prepare connection listeners"); final ConnectionReadyListener connectionReadyListener = new ConnectionReadyListenerImpl( @@ -70,10 +77,10 @@ public class ConnectionManagerImpl implements ConnectionManager { new OpenflowProtocolListenerInitialImpl(connectionContext, handshakeContext); connectionAdapter.setMessageListener(ofMessageListener); - final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl(connectionContext); + final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl(connectionContext, echoReplyTimeout); connectionAdapter.setSystemListener(systemListener); - LOG.trace("connection balet finished"); + LOG.trace("connection ballet finished"); } /** @@ -82,7 +89,7 @@ public class ConnectionManagerImpl implements ConnectionManager { * @return */ private static ThreadPoolLoggingExecutor createHandshakePool( - final String connectionIdentifier, int handshakeThreadLimit) { + final String connectionIdentifier, final int handshakeThreadLimit) { return new ThreadPoolLoggingExecutor(handshakeThreadLimit, handshakeThreadLimit, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(HELLO_LIMIT), "OFHandshake-" + connectionIdentifier); @@ -94,7 +101,7 @@ public class ConnectionManagerImpl implements ConnectionManager { * @return */ private HandshakeManager createHandshakeManager(final ConnectionAdapter connectionAdapter, - HandshakeListener handshakeListener) { + final HandshakeListener handshakeListener) { HandshakeManagerImpl handshakeManager = new HandshakeManagerImpl(connectionAdapter, ConnectionConductor.versionOrder.get(0), ConnectionConductor.versionOrder); @@ -109,30 +116,18 @@ public class ConnectionManagerImpl implements ConnectionManager { * @return parameter dedicated to hello message content */ public boolean isBitmapNegotiationEnabled() { - return bitmapNegotiationEnabled ; + return bitmapNegotiationEnabled; } - /** - * @param bitmapNegotiationEnabled the bitmapNegotiationEnabled to set - */ - public void setBitmapNegotiationEnabled(boolean bitmapNegotiationEnabled) { - this.bitmapNegotiationEnabled = bitmapNegotiationEnabled; - } @Override - public boolean accept(InetAddress switchAddress) { + public boolean accept(final InetAddress switchAddress) { // TODO add connection accept logic based on address return true; } @Override - public void setDeviceConnectedHandler(DeviceConnectedHandler deviceConnectedHandler) { + public void setDeviceConnectedHandler(final DeviceConnectedHandler deviceConnectedHandler) { this.deviceConnectedHandler = deviceConnectedHandler; } - - @Override - public void setMessageHandler(MessageHandler arg0) { - // TODO Auto-generated method stub - - } }