Topology Manager to avoid redundant edge updates 75/5575/3
authorYevgeny Khodorkovsky <ykhodork@cisco.com>
Mon, 10 Mar 2014 06:07:35 +0000 (23:07 -0700)
committerYevgeny Khodorkovsky <ykhodork@cisco.com>
Tue, 11 Mar 2014 02:53:48 +0000 (19:53 -0700)
- Redundant edge updates (such as in the case of
  cluster switchover) should not be notified to apps/listeners, to avoid
  expensive tasks

Change-Id: I44845d99085771e1dfebd63d12685fd2c2d8260c
Signed-off-by: Yevgeny Khodorkovsky <ykhodork@cisco.com>
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java

index b29ce15f5621aa0c09b29bafdf080448b973b628..548bfb1f9fb26eb93ab4ca5bcd456d9bdc4082c3 100644 (file)
@@ -836,8 +836,10 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
             moveToReadyListHi(dst);
         }
 
+        //checking only OF map, since production edge discovery always overwrites any existing edge
+        UpdateType ut = edgeMap.containsKey(dst) ? UpdateType.CHANGED : UpdateType.ADDED;
         // notify
-        updateEdge(edge, UpdateType.ADDED, props);
+        updateEdge(edge, ut, props);
         logger.trace("Add edge {}", edge);
     }
 
@@ -936,6 +938,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
             return;
         }
 
+
         this.discoveryListener.notifyEdge(edge, type, props);
 
         NodeConnector src = edge.getTailNodeConnector(), dst = edge.getHeadNodeConnector();
index 0208cc7cdac4693a2ffafb42a06d54b0e11e6e71..f972ae6a6679b9b1d4cc55afe39a63b276d17ce0 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
  * The class represents an Edge, the Edge's Property Set and its UpdateType.
+ * If update is on new properties added to an existing edge, appropriate type is CHANGED.
  */
 public class TopoEdgeUpdate {
     private Edge edge;
index cc1a8b868d3d376c9eb4a66b5443707adbfbff31..ff1c026a344d74efa5aa1f1b57e05e60775cd1a4 100644 (file)
@@ -573,6 +573,13 @@ public class TopologyManagerImpl implements
         switch (type) {
         case ADDED:
 
+
+            if (this.edgesDB.containsKey(e)) {
+                // Avoid redundant updates (e.g. cluster switch-over) as notifications trigger expensive tasks
+                log.trace("Skipping redundant edge addition: {}", e);
+                return null;
+            }
+
             // Make sure the props are non-null or create a copy
             if (props == null) {
                 props = new HashSet<Property>();
@@ -580,19 +587,6 @@ public class TopologyManagerImpl implements
                 props = new HashSet<Property>(props);
             }
 
-            Set<Property> currentProps = this.edgesDB.get(e);
-            if (currentProps != null) {
-
-                if (currentProps.equals(props)) {
-                    // Avoid redundant updates as notifications trigger expensive tasks
-                    log.trace("Skipping redundant edge addition: {}", e);
-                    return null;
-                }
-
-                // In case of node switch-over to a different cluster controller,
-                // let's retain edge props (e.g. creation time)
-                props.addAll(currentProps);
-            }
 
             // Ensure that head node connector exists
             if (!headNodeConnectorExist(e)) {
@@ -654,10 +648,9 @@ public class TopologyManagerImpl implements
         case CHANGED:
             Set<Property> oldProps = this.edgesDB.get(e);
 
-            // When property changes lets make sure we can change it
+            // When property(s) changes lets make sure we can change it
             // all except the creation time stamp because that should
-            // be changed only when the edge is destroyed and created
-            // again
+            // be set only when the edge is created
             TimeStamp timeStamp = null;
             for (Property prop : oldProps) {
                 if (prop instanceof TimeStamp) {