Newcomers that register with TopologyManager should get all the existing edges 79/1579/1
authorGiovanni Meo <gmeo@cisco.com>
Tue, 1 Oct 2013 15:39:11 +0000 (17:39 +0200)
committerGiovanni Meo <gmeo@cisco.com>
Tue, 1 Oct 2013 15:46:43 +0000 (17:46 +0200)
- When an application wants to get topology updates by topology
manager, it may come after the topology manager has started to push
them around, in that case the app should retrieve the exisiting
topology. Some applications may not do that so topology manager can
still take care of this lazy one by pushing a snapshot of the existing
edges as soon as the listener is registered.

Change-Id: I919350b2ddfddfaa9186e09bd5167d7d810e3bcd
Signed-off-by: Giovanni Meo <gmeo@cisco.com>
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java

index b905a8982e83113e10b23261ab2d3045f1142c54..5a38ecd4a61db131623b1e56efef7849bbba2800 100644 (file)
@@ -20,6 +20,7 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ConcurrentHashMap;
@@ -115,6 +116,14 @@ public class TopologyManagerImpl implements
         if (this.topologyManagerAware != null) {
             log.debug("Adding ITopologyManagerAware: {}", s);
             this.topologyManagerAware.add(s);
+            // Reply all the known edges
+            if (this.edgesDB != null) {
+                List<TopoEdgeUpdate> existingEdges = new ArrayList<TopoEdgeUpdate>();
+                for (Entry<Edge, Set<Property>> entry : this.edgesDB.entrySet()) {
+                    existingEdges.add(new TopoEdgeUpdate(entry.getKey(), entry.getValue(), UpdateType.ADDED));
+                }
+                s.edgeUpdate(existingEdges);
+            }
         }
     }
 
@@ -129,6 +138,14 @@ public class TopologyManagerImpl implements
         if (this.topologyManagerClusterWideAware != null) {
             log.debug("Adding ITopologyManagerClusterWideAware: {}", s);
             this.topologyManagerClusterWideAware.add(s);
+            // Reply all the known edges
+            if (this.edgesDB != null) {
+                List<TopoEdgeUpdate> existingEdges = new ArrayList<TopoEdgeUpdate>();
+                for (Entry<Edge, Set<Property>> entry : this.edgesDB.entrySet()) {
+                    existingEdges.add(new TopoEdgeUpdate(entry.getKey(), entry.getValue(), UpdateType.ADDED));
+                }
+                s.edgeUpdate(existingEdges);
+            }
         }
     }