Bug 3608 - Floating IP notifications fixed. 40/22840/1
authorKeith Burns (alagalah) <alagalah@gmail.com>
Wed, 17 Jun 2015 23:25:27 +0000 (16:25 -0700)
committerKeith Burns <alagalah@gmail.com>
Wed, 17 Jun 2015 23:27:28 +0000 (23:27 +0000)
- Also fixed nasty Map NPE for unregister/register EP.
- Overuse of Maps are the devil's hand-maiden.

Change-Id: I144a528c54df036217fedffc0a3c6deccc31867b
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/EndpointListener.java
renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/EndpointManager.java

index e086c5f6bb01b0324252a54939377f2e6ec3478b..9309dce803e99bac7fe446ddd53a72ccfd623df1 100644 (file)
@@ -14,7 +14,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 
 /**
  * A listener to events related to endpoints being added, removed or updated.
- * @author readams
  */
 public interface EndpointListener {
     /**
@@ -23,7 +22,7 @@ public interface EndpointListener {
      * @param epKey the key for the affected endpoint
      */
     public void endpointUpdated(EpKey epKey);
-    
+
     /**
      * An endpoint attached to a particular node have been added, removed,
      * or updated
@@ -31,9 +30,9 @@ public interface EndpointListener {
      * @param epKey the key for the affected endpoint
      */
     public void nodeEndpointUpdated(NodeId nodeId, EpKey epKey);
-    
+
     /**
-     * An endpoint for an endpoint group have been added, removed, 
+     * An endpoint for an endpoint group have been added, removed,
      * or updated.
      * @param egKey the key for the affected endpoint group
      * @param epKey the key for the affected endpoint
index c22df8dda2d682e78d7fed9ba52aa6db08bb10aa..6d6acfa6319f633336cb61081ceed4c1247a83c2 100644 (file)
@@ -472,27 +472,31 @@ public class EndpointManager implements AutoCloseable, DataChangeListener {
                         && getLocationType(newL3Ep).equals(LocationType.External)) {
                     if (newL3Ep.getNetworkContainment() != null) {
                         arpTasker.addMacForL3EpAndCreateEp(newL3Ep);
-                        return;
                     } else {
                         LOG.error("Cannot generate MacAddress for L3Endpoint {}. NetworkContainment is null.", newL3Ep);
                         return;
                     }
                 }
+                if (newL3Ep.getL2Context() != null && newL3Ep.getMacAddress() != null) {
+                    notifyEndpointUpdated(new EpKey(newL3Ep.getL2Context(), newL3Ep.getMacAddress()));
+                }
+                return;
             } else {
                 LOG.error("{} is not a valid L3 Endpoint", newL3Ep);
                 return;
             }
-            return;
         }
 
         if (oldL3Ep != null && newL3Ep == null) {
             // deleted L3Endpoint
+            notifyEndpointUpdated(new EpKey(oldL3Ep.getL2Context(), oldL3Ep.getMacAddress()));
             return;
         }
 
         if (oldL3Ep != null && newL3Ep != null) {
             LOG.trace("Updating L3 Endpoint {}");
             // updated Endpoint
+            notifyEndpointUpdated(new EpKey(newL3Ep.getL2Context(), newL3Ep.getMacAddress()));
             return;
         }
         if (newL3Ep.getAugmentation(OfOverlayL3Context.class) == null) {
@@ -632,7 +636,7 @@ public class EndpointManager implements AutoCloseable, DataChangeListener {
             // Get map of EPGs and their Endpoints for Node
             ConcurrentMap<EgKey, Set<EpKey>> map = endpointsByGroupByNode.get(oldLoc);
             // For each EPG in the removed endpoint...
-            for (EndpointGroupId oldEpgId : newEpgIds) {
+            for (EndpointGroupId oldEpgId : oldEpgIds) {
                 EgKey oldEgKey = new EgKey(oldEp.getTenant(), oldEpgId);
                 // Get list of endpoints for EPG
                 Set<EpKey> eps = map.get(oldEgKey);