Populate the Node Cache at the controller start/restart. 02/29202/3
authorAnil Vishnoi <vishnoianil@gmail.com>
Sat, 31 Oct 2015 00:21:08 +0000 (05:51 +0530)
committerAnil Vishnoi <vishnoianil@gmail.com>
Fri, 6 Nov 2015 18:38:59 +0000 (00:08 +0530)
This cache can be removed fully, but if we do that, we need
to make read call to the data store, where we will have to
read the whole topology tree, that can put some load on the
md-sal data store, and it might not be negligible in case of
clustered data store.

Change-Id: Ieeb5ae5ba01839b34aefe7d3916c6bdd0fb14808
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NodeCacheManagerImpl.java

index 0f7cd698930dac213d07e4f8accb34de445578e4..7e21101e004a9e3cff4cab2f7adeacd8f6240e48 100644 (file)
@@ -164,6 +164,19 @@ public class NodeCacheManagerImpl extends AbstractHandler implements NodeCacheMa
         return nodes;
     }
 
+    private void populateNodeCache() {
+        LOG.debug("populateNodeCache : Populating the node cache");
+        List<Node> nodes = southbound.readOvsdbTopologyNodes();
+        for(Node ovsdbNode : nodes) {
+            this.nodeCache.put(ovsdbNode.getNodeId(), ovsdbNode);
+        }
+        nodes = southbound.readOvsdbTopologyBridgeNodes();
+        for(Node bridgeNode : nodes) {
+            this.nodeCache.put(bridgeNode.getNodeId(), bridgeNode);
+        }
+        LOG.debug("populateNodeCache : Node cache population is done. Total nodes : {}",this.nodeCache.size());
+    }
+
     @Override
     public void setDependencies(ServiceReference serviceReference) {
         southbound =
@@ -171,6 +184,7 @@ public class NodeCacheManagerImpl extends AbstractHandler implements NodeCacheMa
         eventDispatcher =
                 (EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this);
         eventDispatcher.eventHandlerAdded(serviceReference, this);
+        populateNodeCache();
     }
 
     @Override