Merge "Addressing a flow programming issues on controler fail-over scenario in a...
authorGiovanni Meo <gmeo@cisco.com>
Thu, 9 Jan 2014 19:15:36 +0000 (19:15 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 9 Jan 2014 19:15:36 +0000 (19:15 +0000)
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/ComponentActivatorAbstractBase.java
opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java

index 3d6a0292ef67225079b11759a3560bdfddf85377..2b3347f312469b00ca6748f5d19884626ce1daf3 100644 (file)
@@ -2639,6 +2639,13 @@ public class ForwardingRulesManager implements
         }
     }
 
+    /**
+     * Function called by the dependency manager before Container is Stopped and Destroyed.
+     */
+    public void containerStop() {
+        uninstallAllFlowEntries(false);
+    }
+
     /**
      * Function called by the dependency manager before the services exported by
      * the component are unregistered, this will be followed by a "destroy ()"
@@ -2646,7 +2653,6 @@ public class ForwardingRulesManager implements
      */
     void stop() {
         stopping = true;
-        uninstallAllFlowEntries(false);
         // Shutdown executor
         this.executor.shutdownNow();
         // Now walk all the workMonitor and wake up the one sleeping because
index 969aa630a1519f712e24af8ef0e0cd0025022635..0cd1612808b4a67e8c0eb38c0dec013e4090dee3 100644 (file)
@@ -45,8 +45,8 @@ abstract public class ComponentActivatorAbstractBase implements
     Logger logger = LoggerFactory
             .getLogger(ComponentActivatorAbstractBase.class);
     private DependencyManager dm;
-    private ConcurrentMap<ImmutablePair<String, Object>, Component> dbInstances = (ConcurrentMap<ImmutablePair<String, Object>, Component>) new ConcurrentHashMap<ImmutablePair<String, Object>, Component>();
-    private ConcurrentMap<Object, Component> dbGlobalInstances = (ConcurrentMap<Object, Component>) new ConcurrentHashMap<Object, Component>();
+    private ConcurrentMap<ImmutablePair<String, Object>, Component> dbInstances = new ConcurrentHashMap<ImmutablePair<String, Object>, Component>();
+    private ConcurrentMap<Object, Component> dbGlobalInstances = new ConcurrentHashMap<Object, Component>();
 
     /**
      * Method that should be overriden by the derived class for customization
@@ -253,6 +253,11 @@ abstract public class ComponentActivatorAbstractBase implements
                             containerName, imps[i]);
                     Component c = this.dbInstances.get(key);
                     if (c != null) {
+                        if (c.getService() != null) {
+                            c.invokeCallbackMethod(new Object[] { c.getService() }, "containerStop",
+                                                   new Class[][] {{ Component.class}, {} },
+                                                   new Object[][] { {c}, {} });
+                        }
                         // Now remove the component from dependency manager,
                         // which will implicitely stop it first
                         this.dm.remove(c);
index a34cbb5db80f8f7232bf8dac7c2c41e7aba42c01..7a3625a229ef5ae04f76de4a6eabe28feef657b7 100644 (file)
@@ -800,8 +800,7 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
         log.debug("Host Facing Port in a container came up, install the rules for all hosts from this port !");
         Set<HostNodeConnector> allHosts = this.hostTracker.getAllHosts();
         for (HostNodeConnector host : allHosts) {
-            if (node.equals(host.getnodeconnectorNode())
-                    && swPort.equals(host.getnodeConnector())) {
+            if (node.equals(host.getnodeconnectorNode())) {
                 /*
                  * This host resides behind the same switch and port for which a port up
                  * message is received. Ideally this should not happen, but if it does,