Addressing a flow programming issues on controler fail-over scenario in a Clustered...
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / core / ComponentActivatorAbstractBase.java
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);