Merge "BUG-3849: Unit test failure due to timing issues"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / connection / ConnectionManagerImpl.java
index 4f8de11aa4f952223345faab53ca790c9d145b0d..907afb6c0d88cd0b0b85204963e785b358c93631 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * <p/>
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -39,11 +39,12 @@ 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;
 
     @Override
     public void onSwitchConnected(final ConnectionAdapter connectionAdapter) {
+
         LOG.trace("preparing handshake: {}", connectionAdapter.getRemoteAddress());
 
         final int handshakeThreadLimit = 1; //TODO: move to constants/parametrize
@@ -59,6 +60,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(
@@ -69,7 +71,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);
         connectionAdapter.setSystemListener(systemListener);
 
         LOG.trace("connection ballet finished");
@@ -81,7 +83,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<Runnable>(HELLO_LIMIT), "OFHandshake-" + connectionIdentifier);
@@ -93,7 +95,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);
@@ -108,29 +110,23 @@ 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) {
+    public void setMessageHandler(final MessageHandler arg0) {
         // TODO Auto-generated method stub
 
     }