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=6450e6d647087359314de308a9a52ce740ee40ed;hb=f18f86a82f6fc46426e6f198bdf7625a17063878;hp=9901b7162cbcb2fa6eabad5f6d44dbcc3873fc87;hpb=6aefd793fa213511f779521c7dde1f293359f9da;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 9901b7162c..6450e6d647 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 @@ -9,8 +9,7 @@ package org.opendaylight.openflowplugin.impl.connection; import java.net.InetAddress; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.ThreadPoolExecutor; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; @@ -26,7 +25,6 @@ import org.opendaylight.openflowplugin.impl.connection.listener.OpenflowProtocol 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; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; import org.slf4j.Logger; @@ -41,16 +39,16 @@ public class ConnectionManagerImpl implements ConnectionManager { private static final int HELLO_LIMIT = 20; private final boolean bitmapNegotiationEnabled = true; private DeviceConnectedHandler deviceConnectedHandler; + private final long echoReplyTimeout; + private final ThreadPoolExecutor threadPool; + + public ConnectionManagerImpl(long echoReplyTimeout, final ThreadPoolExecutor threadPool) { + this.echoReplyTimeout = echoReplyTimeout; + this.threadPool = threadPool; + } @Override public void onSwitchConnected(final ConnectionAdapter connectionAdapter) { - - LOG.trace("preparing handshake: {}", connectionAdapter.getRemoteAddress()); - - final int handshakeThreadLimit = 1; - final ThreadPoolLoggingExecutor handshakePool = createHandshakePool( - connectionAdapter.getRemoteAddress().toString(), handshakeThreadLimit); - LOG.trace("prepare connection context"); final ConnectionContext connectionContext = new ConnectionContextImpl(connectionAdapter); @@ -58,7 +56,7 @@ public class ConnectionManagerImpl implements ConnectionManager { final HandshakeManager handshakeManager = createHandshakeManager(connectionAdapter, handshakeListener); LOG.trace("prepare handshake context"); - HandshakeContext handshakeContext = new HandshakeContextImpl(handshakePool, handshakeManager); + HandshakeContext handshakeContext = new HandshakeContextImpl(threadPool, handshakeManager); handshakeListener.setHandshakeContext(handshakeContext); connectionContext.setHandshakeContext(handshakeContext); @@ -71,24 +69,12 @@ 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, threadPool); connectionAdapter.setSystemListener(systemListener); LOG.trace("connection ballet finished"); } - /** - * @param connectionIdentifier - * @param handshakeThreadLimit - * @return - */ - private static ThreadPoolLoggingExecutor createHandshakePool( - final String connectionIdentifier, final int handshakeThreadLimit) { - return new ThreadPoolLoggingExecutor(handshakeThreadLimit, - handshakeThreadLimit, 0L, TimeUnit.MILLISECONDS, - new ArrayBlockingQueue(HELLO_LIMIT), "OFHandshake-" + connectionIdentifier); - } - /** * @param connectionAdapter * @param handshakeListener @@ -113,7 +99,6 @@ public class ConnectionManagerImpl implements ConnectionManager { return bitmapNegotiationEnabled; } - @Override public boolean accept(final InetAddress switchAddress) { // TODO add connection accept logic based on address