Merge "Bug 6085 - Modifying config flow does not work if first flow creation failed"
authorAbhijit Kumbhare <abhijit.kumbhare@ericsson.com>
Thu, 23 Jun 2016 15:30:55 +0000 (15:30 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 23 Jun 2016 15:30:55 +0000 (15:30 +0000)
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatRpcMsgManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/HandshakeContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/SessionManagerOFImpl.java

index 08bdf848532150bbb961b4887fab6a46dab6cd2f..e4b032e370b5875e5852e1d4f4d484e9ed325f62 100644 (file)
@@ -89,7 +89,7 @@ public class FlowNodeConnectorInventoryTranslatorImpl extends AbstractNodeConnec
     @Override
     public void remove(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector del, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
         if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE_CONNECTOR)){
-            LOG.warn("Node Connector removed");
+            LOG.info("Node Connector removed");
             String sNodeConnectorIdentifier = nodeConnIdent
                     .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue();
             long nDpId = getDpIdFromPortName(sNodeConnectorIdentifier);
@@ -102,7 +102,7 @@ public class FlowNodeConnectorInventoryTranslatorImpl extends AbstractNodeConnec
     @Override
     public void update(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector original, FlowCapableNodeConnector update, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
         if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE_CONNECTOR)){
-            LOG.warn("Node Connector updated");
+            LOG.info("Node Connector updated");
             //donot need to do anything as we are not considering updates here
         }
     }
@@ -110,7 +110,7 @@ public class FlowNodeConnectorInventoryTranslatorImpl extends AbstractNodeConnec
     @Override
     public void add(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector add, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
         if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE_CONNECTOR)){
-            LOG.warn("Node Connector added");
+            LOG.info("Node Connector added");
             String sNodeConnectorIdentifier = nodeConnIdent
                     .firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue();
             long nDpId = getDpIdFromPortName(sNodeConnectorIdentifier);
index 6c43cd4912f64f43aed34ad0af79cf54839f288a..e372ff557dfbc88b11c8da1e802cead2b75b5ec5 100644 (file)
@@ -175,7 +175,9 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
     public void remove(InstanceIdentifier<FlowCapableNode> identifier, FlowCapableNode del,
                        InstanceIdentifier<FlowCapableNode> nodeIdent) {
         if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
-            LOG.warn("Node removed: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Node removed: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
+            }
 
             if ( ! nodeIdent.isWildcarded()) {
                 flowNodeDisconnected(nodeIdent);
@@ -187,7 +189,9 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
     public void add(InstanceIdentifier<FlowCapableNode> identifier, FlowCapableNode add,
                     InstanceIdentifier<FlowCapableNode> nodeIdent) {
         if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
-            LOG.warn("Node added: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Node added: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
+            }
 
             if ( ! nodeIdent.isWildcarded()) {
                 flowNodeConnected(nodeIdent);
index 1717f3af4d0ca9a26472600ef6c474a788191629..43074a70bf82f626c4abbf2a6665ac7edb11adc3 100644 (file)
@@ -188,6 +188,10 @@ public class StatRpcMsgManagerImpl implements StatRpcMsgManager {
                     String[] multipartRequestName = result.getResult().getClass().getSimpleName().split("(?=\\p{Upper})");
                     LOG.warn("Node [{}] does not support statistics request type : {}",
                             nodeKey.getId(),Joiner.on(" ").join(Arrays.copyOfRange(multipartRequestName, 2, multipartRequestName.length-2)));
+                    if (resultTransId != null) {
+                        resultTransId.setException(
+                            new UnsupportedOperationException());
+                    }
                 } else {
                     if (resultTransId != null) {
                         resultTransId.set(id);
@@ -202,8 +206,10 @@ public class StatRpcMsgManagerImpl implements StatRpcMsgManager {
             @Override
             public void onFailure(final Throwable t) {
                 LOG.warn("Response Registration for Statistics RPC call fail!", t);
+                if (resultTransId != null) {
+                    resultTransId.setException(t);
+                }
             }
-
         }
 
         Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),new FutureCallbackImpl());
index e7142642b85c6010eaac4735bbb8de3e379c771f..1efadcc18b3a70c5a1c432201b5b4da13f129b14 100644 (file)
@@ -8,19 +8,13 @@
 package org.opendaylight.openflowplugin.impl.connection;
 
 import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext;
 import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  *
  */
 public class HandshakeContextImpl implements HandshakeContext {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HandshakeContextImpl.class);
-
     private ThreadPoolExecutor handshakePool;
     private HandshakeManager handshakeManager;
 
@@ -44,23 +38,6 @@ public class HandshakeContextImpl implements HandshakeContext {
     }
 
     @Override
-    public void close() throws Exception {
-        shutdownPoolPolitely();
-    }
-
-    private void shutdownPoolPolitely() {
-        LOG.debug("terminating handshake pool");
-        handshakePool.shutdown();
-        try {
-            handshakePool.awaitTermination(1, TimeUnit.SECONDS);
-        } catch (InterruptedException e) {
-            LOG.error("Error while awaiting termination on pool. Will use shutdownNow method.");
-        } finally {
-            handshakePool.purge();
-            if (! handshakePool.isTerminated()) {
-                handshakePool.shutdownNow();
-            }
-            LOG.debug("pool is terminated: {}", handshakePool.isTerminated());
-        }
+    public void close() {
     }
 }
index bcf4259fc9632f3fcdb507737f14fc0255bc380d..f85f29d06f5d6f717090a55095385e0b37b78673 100644 (file)
@@ -281,11 +281,14 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
 
     @Override
     public void processFlowRemovedMessage(final FlowRemoved flowRemoved) {
+        //1. translate to general flow (table, priority, match, cookie)
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved flowRemovedNotification =
+                flowRemovedTranslator.translate(flowRemoved, deviceInfo, null);
+        // Trigger off a notification
+        notificationPublishService.offerNotification(flowRemovedNotification);
+
         final ItemLifecycleListener itemLifecycleListener = flowLifeCycleKeeper.getItemLifecycleListener();
         if (itemLifecycleListener != null) {
-            //1. translate to general flow (table, priority, match, cookie)
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved flowRemovedNotification =
-                    flowRemovedTranslator.translate(flowRemoved, deviceInfo, null);
             //2. create registry key
             final FlowRegistryKey flowRegKey = FlowRegistryKeyFactory.create(flowRemovedNotification);
             //3. lookup flowId
@@ -299,8 +302,6 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
                         .child(Flow.class, new FlowKey(flowDescriptor.getFlowId()));
                 // b) notify listener
                 itemLifecycleListener.onRemoved(flowPath);
-                // c) trigger off a notification
-                notificationPublishService.offerNotification(flowRemovedNotification);
             } else {
                 LOG.debug("flow id not found: nodeId={} tableId={}, priority={}",
                         getDeviceInfo().getNodeId(), flowRegKey.getTableId(), flowRemovedNotification.getPriority());
index 1a5f53857a5b3e3fd93dbb334c06621b9dcab36d..67cc3efce7e2abb1867c77a02ca0dd48e38ce6b2 100644 (file)
@@ -99,13 +99,18 @@ public class SessionManagerOFImpl implements ConjunctSessionManager {
             LOG.info("context for invalidation not found");
         } else {
             synchronized (context) {
-                for (Entry<SwitchConnectionDistinguisher, ConnectionConductor> auxEntry : context.getAuxiliaryConductors()) {
-                    invalidateAuxiliary(sessionKey, auxEntry.getKey());
+                if (context.isValid()) {
+                    for (Entry<SwitchConnectionDistinguisher, ConnectionConductor> auxEntry : context.getAuxiliaryConductors()) {
+                        invalidateAuxiliary(sessionKey, auxEntry.getKey());
+                    }
+                    context.getPrimaryConductor().disconnect();
+                    context.setValid(false);
+                    removeSessionContext(context);
+                    // TODO:: notify listeners
+                } else {
+                    LOG.warn("Ignore invalid session context: {}",
+                             Arrays.toString(sessionKey.getId()));
                 }
-                context.getPrimaryConductor().disconnect();
-                context.setValid(false);
-                removeSessionContext(context);
-                // TODO:: notify listeners
             }
         }
     }
@@ -115,13 +120,19 @@ public class SessionManagerOFImpl implements ConjunctSessionManager {
             LOG.info("context for invalidation not found");
         } else {
             synchronized (sessionContext) {
-                for (Entry<SwitchConnectionDistinguisher, ConnectionConductor> auxEntry : sessionContext
-                        .getAuxiliaryConductors()) {
-                    invalidateAuxiliary(sessionContext, auxEntry.getKey(), true);
+                if (sessionContext.isValid()) {
+                    for (Entry<SwitchConnectionDistinguisher, ConnectionConductor> auxEntry : sessionContext
+                             .getAuxiliaryConductors()) {
+                        invalidateAuxiliary(sessionContext, auxEntry.getKey(), true);
+                    }
+                    sessionContext.setValid(false);
+                    removeSessionContext(sessionContext);
+                    // TODO:: notify listeners
+                } else {
+                    LOG.warn("Ignore invalid dead session context: {}",
+                             Arrays.toString(
+                                 sessionContext.getSessionKey().getId()));
                 }
-                sessionContext.setValid(false);
-                removeSessionContext(sessionContext);
-                // TODO:: notify listeners
             }
         }
     }
@@ -130,8 +141,13 @@ public class SessionManagerOFImpl implements ConjunctSessionManager {
         if (LOG.isDebugEnabled()) {
             LOG.debug("removing session: {}", Arrays.toString(sessionContext.getSessionKey().getId()));
         }
-        sessionLot.remove(sessionContext.getSessionKey(), sessionContext);
-        sessionNotifier.onSessionRemoved(sessionContext);
+        if (sessionLot.remove(sessionContext.getSessionKey(), sessionContext)) {
+            sessionNotifier.onSessionRemoved(sessionContext);
+        } else {
+            // This should never happen.
+            LOG.warn("Ignore session context that was already removed: {}",
+                     Arrays.toString(sessionContext.getSessionKey().getId()));
+        }
     }
 
     @Override