From 2bf3159833c38942e8770a49eb00d1601c669055 Mon Sep 17 00:00:00 2001 From: Pramila Singh Date: Fri, 19 Jul 2013 13:01:44 -0700 Subject: [PATCH] InventoryShim to check node presence, before notifying in container Signed-off-by: Pramila Singh --- .../internal/InventoryServiceShim.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java index 837426eda4..f0b8735f83 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java @@ -255,10 +255,10 @@ public class InventoryServiceShim implements IContainerListener, } @Override - public void nodeConnectorUpdated(String containerName, NodeConnector p, UpdateType t) { - logger.debug("nodeConnectorUpdated: {} type {} for container {}", new Object[] { p, t, containerName }); - Node node = p.getNode(); - Set ncContainers = this.nodeConnectorContainerMap.get(p); + public void nodeConnectorUpdated(String containerName, NodeConnector nc, UpdateType t) { + logger.debug("nodeConnectorUpdated: {} type {} for container {}", new Object[] { nc, t, containerName }); + Node node = nc.getNode(); + Set ncContainers = this.nodeConnectorContainerMap.get(nc); Set nodeContainers = this.nodeContainerMap.get(node); if (ncContainers == null) { ncContainers = new CopyOnWriteArraySet(); @@ -271,7 +271,7 @@ public class InventoryServiceShim implements IContainerListener, switch (t) { case ADDED: if (ncContainers.add(containerName)) { - this.nodeConnectorContainerMap.put(p, ncContainers); + this.nodeConnectorContainerMap.put(nc, ncContainers); } if (nodeContainers.add(containerName)) { this.nodeContainerMap.put(node, nodeContainers); @@ -283,14 +283,14 @@ public class InventoryServiceShim implements IContainerListener, if (ncContainers.isEmpty()) { // Do cleanup to reduce memory footprint if no // elements to be tracked - this.nodeConnectorContainerMap.remove(p); + this.nodeConnectorContainerMap.remove(nc); } else { - this.nodeConnectorContainerMap.put(p, ncContainers); + this.nodeConnectorContainerMap.put(nc, ncContainers); } } boolean nodeContainerUpdate = true; - for (NodeConnector nc : nodeConnectorContainerMap.keySet()) { - if ((nc.getNode().equals(node)) && (nodeConnectorContainerMap.get(nc).contains(containerName))) { + for (NodeConnector ncContainer : nodeConnectorContainerMap.keySet()) { + if ((ncContainer.getNode().equals(node)) && (nodeConnectorContainerMap.get(ncContainer).contains(containerName))) { nodeContainerUpdate = false; break; } @@ -309,12 +309,15 @@ public class InventoryServiceShim implements IContainerListener, break; } - Set ncProp = nodeConnectorProps.get(p); + Set nodeProp = nodeProps.get(node); + if (nodeProp == null) { + return; + } + Set ncProp = nodeConnectorProps.get(nc); // notify InventoryService - notifyInventoryShimInternalListener(containerName, p, t, ncProp); + notifyInventoryShimInternalListener(containerName, nc, t, ncProp); if (notifyNodeUpdate) { - Set nodeProp = nodeProps.get(node); notifyInventoryShimInternalListener(containerName, node, t, nodeProp); } } -- 2.36.6