Merge "Correction classes names in loggers."
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / connection / ConnectionManagerImpl.java
index 7f16e813b80fcde8cb4cb119e586fa1a7d67c252..544e7124ba44bb6627efc050820b2803a5715545 100644 (file)
@@ -5,6 +5,7 @@
  * 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 java.net.InetAddress;
@@ -16,7 +17,6 @@ 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;
@@ -39,15 +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: {}", connectionAdapter.getRemoteAddress());
 
-        final int handshakeThreadLimit = 1; //TODO: move to constants/parametrize
+        final int handshakeThreadLimit = 1;
         final ThreadPoolLoggingExecutor handshakePool = createHandshakePool(
                 connectionAdapter.getRemoteAddress().toString(), handshakeThreadLimit);
 
@@ -60,6 +66,7 @@ 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,7 +77,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
                 new OpenflowProtocolListenerInitialImpl(connectionContext, handshakeContext);
         connectionAdapter.setMessageListener(ofMessageListener);
 
-        final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl(connectionContext, handshakeContext);
+        final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl(connectionContext, echoReplyTimeout);
         connectionAdapter.setSystemListener(systemListener);
 
         LOG.trace("connection ballet finished");
@@ -94,7 +101,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
      * @return
      */
     private HandshakeManager createHandshakeManager(final ConnectionAdapter connectionAdapter,
-            final HandshakeListener handshakeListener) {
+                                                    final HandshakeListener handshakeListener) {
         HandshakeManagerImpl handshakeManager = new HandshakeManagerImpl(connectionAdapter,
                 ConnectionConductor.versionOrder.get(0),
                 ConnectionConductor.versionOrder);
@@ -109,7 +116,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
      * @return parameter dedicated to hello message content
      */
     public boolean isBitmapNegotiationEnabled() {
-        return bitmapNegotiationEnabled ;
+        return bitmapNegotiationEnabled;
     }
 
 
@@ -123,10 +130,4 @@ public class ConnectionManagerImpl implements ConnectionManager {
     public void setDeviceConnectedHandler(final DeviceConnectedHandler deviceConnectedHandler) {
         this.deviceConnectedHandler = deviceConnectedHandler;
     }
-
-    @Override
-    public void setMessageHandler(final MessageHandler arg0) {
-        // TODO Auto-generated method stub
-
-    }
 }