Removing the Container Aware dependency from Clustering Services. 26/1326/1
authorMadhu Venugopal <vmadhu@cisco.com>
Sun, 22 Sep 2013 08:38:11 +0000 (01:38 -0700)
committerMadhu Venugopal <vmadhu@cisco.com>
Sun, 22 Sep 2013 08:38:11 +0000 (01:38 -0700)
Clustering Services implementation is ContainerAware to handle the case of Container deletion.
More appropriate way to handle it is to have an explicit API in global cluster manager to expose
a functionality to clean all the caches assocaited with a Container. This API can be used by
the Container Manager to clean up the caches.

Change-Id: I9758a01da13ffa7d951307a116df34a7fe9c19f6
Signed-off-by: Madhu Venugopal <vmadhu@cisco.com>
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/IClusterGlobalServices.java
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/Activator.java
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterGlobalManager.java
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManagerCommon.java
opendaylight/clustering/stub/src/main/java/org/opendaylight/controller/clustering/stub/internal/ClusterGlobalManager.java
opendaylight/containermanager/implementation/src/main/java/org/opendaylight/controller/containermanager/internal/ContainerManager.java
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java

index 17df387..f42d966 100644 (file)
@@ -10,7 +10,6 @@
 package org.opendaylight.controller.clustering.services_implementation.internal;
 
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
-import org.opendaylight.controller.sal.core.IContainerAware;
 
 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
@@ -128,7 +127,7 @@ public class Activator extends ComponentActivatorAbstractBase {
     public void configureGlobalInstance(Component c, Object imp) {
         if (imp.equals(ClusterManager.class)) {
             // export the service for Apps and Plugins
-            c.setInterface(new String[] { IClusterServices.class.getName(), IContainerAware.class.getName() }, null);
+            c.setInterface(new String[] { IClusterServices.class.getName() }, null);
         }
 
         if (imp.equals(ClusterGlobalManager.class)) {
index ce33ac8..34ddb7a 100644 (file)
@@ -41,4 +41,13 @@ public class ClusterGlobalManager
         }
         super.unsetCacheUpdateAware(props, s);
     }
+
+    @Override
+    public void removeContainerCaches(String containerName) {
+        logger.debug("Removing caches for container {}", containerName);
+        for (String cacheName : clusterService.getCacheList(containerName)) {
+            clusterService.destroyCache(containerName, cacheName);
+        }
+    }
+
 }
index ca13fbc..4a67e76 100644 (file)
@@ -55,11 +55,10 @@ import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.clustering.services.IGetUpdates;
 import org.opendaylight.controller.clustering.services.IListenRoleChange;
 import org.opendaylight.controller.clustering.services.ListenRoleChangeAddException;
-import org.opendaylight.controller.sal.core.IContainerAware;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ClusterManager implements IClusterServices, IContainerAware {
+public class ClusterManager implements IClusterServices {
     protected static final Logger logger = LoggerFactory
             .getLogger(ClusterManager.class);
     private DefaultCacheManager cm;
@@ -371,6 +370,7 @@ public class ClusterManager implements IClusterServices, IContainerAware {
             return null;
         }
         for (String cacheName : manager.getCacheNames()) {
+            if (!manager.isRunning(cacheName)) continue;
             if (cacheName.startsWith("{" + containerName + "}_")) {
                 String[] res = cacheName.split("[{}]");
                 if (res.length >= 4 && res[1].equals(containerName)
@@ -676,21 +676,4 @@ public class ClusterManager implements IClusterServices, IContainerAware {
             }
         }
     }
-
-    private void removeContainerCaches(String containerName) {
-        logger.info("Destroying caches for container {}", containerName);
-        for (String cacheName : this.getCacheList(containerName)) {
-            this.destroyCache(containerName, cacheName);
-        }
-    }
-
-    @Override
-    public void containerCreate(String arg0) {
-        // no op
-    }
-
-    @Override
-    public void containerDestroy(String container) {
-        removeContainerCaches(container);
-    }
 }
index 90299e5..61681bc 100644 (file)
@@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
 
 public abstract class ClusterManagerCommon implements IClusterServicesCommon {
     protected String containerName = null;
-    private IClusterServices clusterService = null;
+    protected IClusterServices clusterService = null;
     protected static final Logger logger = LoggerFactory
             .getLogger(ClusterManagerCommon.class);
     private ConcurrentMap<String, GetUpdatesContainer> cacheUpdateAware =
index 004d1b9..8f905a9 100644 (file)
@@ -918,10 +918,10 @@ public class TopologyManagerImpl implements
                     // Lets sleep for sometime to allow aggregation of event
                     Thread.sleep(100);
                 } catch (InterruptedException e1) {
-                    log.warn("TopologyNotify interrupted {}", e1.getMessage());
                     if (shuttingDown) {
                         return;
                     }
+                    log.warn("TopologyNotify interrupted {}", e1.getMessage());
                 } catch (Exception e2) {
                     log.error("", e2);
                 }