Bug 5596 Initial commit failed
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / connection / listener / HandshakeListenerImpl.java
index 8bbe07bfaf92aef2bdcb67aabcfcb90606a5bb79..d1de6f8a20305ada3620e476394c9e08e186990d 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
 import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionStatus;
 import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeListener;
@@ -65,15 +66,16 @@ public class HandshakeListenerImpl implements HandshakeListener {
         return new FutureCallback<RpcResult<BarrierOutput>>() {
             @Override
             public void onSuccess(@Nullable final RpcResult<BarrierOutput> result) {
-                LOG.debug("succeeded by getting sweep barrier after posthandshake for device {}", connectionContext.getNodeId());
+                LOG.debug("succeeded by getting sweep barrier after post-handshake for device {}", connectionContext.getNodeId().getValue());
                 try {
-                    if (!deviceConnectedHandler.deviceConnected(connectionContext)) {
-                        connectionContext.closeConnection(true);
+                    ConnectionStatus connectionStatusResult = deviceConnectedHandler.deviceConnected(connectionContext);
+                    if (ConnectionStatus.CLOSING.equals(connectionStatusResult)) {
+                        connectionContext.closeConnection(false);
                     }
                     SessionStatistics.countEvent(connectionContext.getNodeId().toString(),
                             SessionStatistics.ConnectionStatus.CONNECTION_CREATED);
                 } catch (final Exception e) {
-                    LOG.error("ConnectionContext initial processing failed: {}", e.getMessage());
+                    LOG.error("ConnectionContext initial processing failed: ", e);
                     SessionStatistics.countEvent(connectionContext.getNodeId().toString(),
                             SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_OFP);
                     connectionContext.closeConnection(true);
@@ -82,7 +84,7 @@ public class HandshakeListenerImpl implements HandshakeListener {
 
             @Override
             public void onFailure(final Throwable t) {
-                LOG.error("failed to get sweep barrier after posthandshake for device {}", connectionContext.getNodeId());
+                LOG.error("failed to get sweep barrier after post-handshake for device {}", connectionContext.getNodeId());
                 connectionContext.closeConnection(false);
             }
         };