2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.protocol_plugin.openflow.internal;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.HashMap;
14 import java.util.HashSet;
15 import java.util.List;
18 import java.util.Timer;
19 import java.util.TimerTask;
20 import java.util.concurrent.BlockingQueue;
21 import java.util.concurrent.ConcurrentHashMap;
22 import java.util.concurrent.ConcurrentMap;
23 import java.util.concurrent.CopyOnWriteArrayList;
24 import java.util.concurrent.LinkedBlockingQueue;
26 import org.apache.commons.lang3.tuple.ImmutablePair;
27 import org.apache.commons.lang3.tuple.Pair;
28 import org.eclipse.osgi.framework.console.CommandInterpreter;
29 import org.eclipse.osgi.framework.console.CommandProvider;
30 import org.opendaylight.controller.protocol_plugin.openflow.IDiscoveryListener;
31 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener;
32 import org.opendaylight.controller.protocol_plugin.openflow.IOFStatisticsManager;
33 import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProvider;
34 import org.opendaylight.controller.protocol_plugin.openflow.ITopologyServiceShimListener;
35 import org.opendaylight.controller.sal.core.Bandwidth;
36 import org.opendaylight.controller.sal.core.Config;
37 import org.opendaylight.controller.sal.core.ContainerFlow;
38 import org.opendaylight.controller.sal.core.Edge;
39 import org.opendaylight.controller.sal.core.IContainerAware;
40 import org.opendaylight.controller.sal.core.IContainerListener;
41 import org.opendaylight.controller.sal.core.Node;
42 import org.opendaylight.controller.sal.core.NodeConnector;
43 import org.opendaylight.controller.sal.core.Property;
44 import org.opendaylight.controller.sal.core.State;
45 import org.opendaylight.controller.sal.core.UpdateType;
46 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
47 import org.opendaylight.controller.sal.utils.GlobalConstants;
48 import org.osgi.framework.BundleContext;
49 import org.osgi.framework.FrameworkUtil;
50 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory;
54 * The class describes a shim layer that relays the topology events from
55 * OpenFlow core to various listeners. The notifications are filtered based on
56 * container configurations.
58 public class TopologyServiceShim implements IDiscoveryListener,
59 IContainerListener, CommandProvider, IRefreshInternalProvider,
60 IInventoryShimExternalListener, IContainerAware {
61 protected static final Logger logger = LoggerFactory
62 .getLogger(TopologyServiceShim.class);
63 private ConcurrentMap<String, ITopologyServiceShimListener> topologyServiceShimListeners = new ConcurrentHashMap<String, ITopologyServiceShimListener>();
64 private ConcurrentMap<NodeConnector, List<String>> containerMap = new ConcurrentHashMap<NodeConnector, List<String>>();
65 private ConcurrentMap<String, ConcurrentMap<NodeConnector, Pair<Edge, Set<Property>>>> edgeMap = new ConcurrentHashMap<String, ConcurrentMap<NodeConnector, Pair<Edge, Set<Property>>>>();
67 private BlockingQueue<NotifyEntry> notifyQ;
68 private Thread notifyThread;
69 private BlockingQueue<String> bulkNotifyQ;
70 private Thread ofPluginTopoBulkUpdate;
71 private volatile Boolean shuttingDown = false;
72 private IOFStatisticsManager statsMgr;
73 private Timer pollTimer;
74 private TimerTask txRatePoller;
75 private Thread bwUtilNotifyThread;
76 private BlockingQueue<UtilizationUpdate> bwUtilNotifyQ;
77 private List<NodeConnector> connectorsOverUtilized;
78 private float bwThresholdFactor = (float) 0.8; // Threshold = 80% of link
83 List<TopoEdgeUpdate> teuList;
85 public NotifyEntry(String container, TopoEdgeUpdate teu) {
86 this.container = container;
87 this.teuList = new ArrayList<TopoEdgeUpdate>();
89 this.teuList.add(teu);
93 public NotifyEntry(String container, List<TopoEdgeUpdate> teuList) {
94 this.container = container;
95 this.teuList = new ArrayList<TopoEdgeUpdate>();
96 if (teuList != null) {
97 this.teuList.addAll(teuList);
102 class TopologyNotify implements Runnable {
103 private final BlockingQueue<NotifyEntry> notifyQ;
104 private NotifyEntry entry;
105 private Map<String, List<TopoEdgeUpdate>> teuMap = new HashMap<String, List<TopoEdgeUpdate>>();
106 private List<TopoEdgeUpdate> teuList;
107 private boolean notifyListeners;
109 TopologyNotify(BlockingQueue<NotifyEntry> notifyQ) {
110 this.notifyQ = notifyQ;
118 notifyListeners = false;
119 while (!notifyQ.isEmpty()) {
120 entry = notifyQ.take();
121 teuList = teuMap.get(entry.container);
122 if (teuList == null) {
123 teuList = new ArrayList<TopoEdgeUpdate>();
125 // group all the updates together
126 teuList.addAll(entry.teuList);
127 teuMap.put(entry.container, teuList);
128 notifyListeners = true;
131 if (notifyListeners) {
132 for (String container : teuMap.keySet()) {
133 // notify the listener
134 topologyServiceShimListeners.get(container)
135 .edgeUpdate(teuMap.get(container));
140 } catch (InterruptedException e1) {
141 logger.warn("TopologyNotify interrupted {}",
146 } catch (Exception e2) {
147 logger.error("", e2);
153 class UtilizationUpdate {
154 NodeConnector connector;
157 UtilizationUpdate(NodeConnector connector, UpdateType type) {
158 this.connector = connector;
163 class BwUtilizationNotify implements Runnable {
164 private final BlockingQueue<UtilizationUpdate> notifyQ;
166 BwUtilizationNotify(BlockingQueue<UtilizationUpdate> notifyQ) {
167 this.notifyQ = notifyQ;
174 UtilizationUpdate update = notifyQ.take();
175 NodeConnector connector = update.connector;
176 Set<String> containerList = edgeMap.keySet();
177 for (String container : containerList) {
178 Map<NodeConnector, Pair<Edge, Set<Property>>> edgePropsMap = edgeMap
180 Edge edge = edgePropsMap.get(connector).getLeft();
181 if (edge.getTailNodeConnector().equals(connector)) {
182 ITopologyServiceShimListener topologServiceShimListener = topologyServiceShimListeners
184 if (update.type == UpdateType.ADDED) {
185 topologServiceShimListener
186 .edgeOverUtilized(edge);
188 topologServiceShimListener
189 .edgeUtilBackToNormal(edge);
193 } catch (InterruptedException e1) {
195 "Edge Bandwidth Utilization Notify Thread interrupted {}",
200 } catch (Exception e2) {
201 logger.error("", e2);
208 * Function called by the dependency manager when all the required
209 * dependencies are satisfied
213 logger.trace("Init called");
214 connectorsOverUtilized = new ArrayList<NodeConnector>();
215 notifyQ = new LinkedBlockingQueue<NotifyEntry>();
216 notifyThread = new Thread(new TopologyNotify(notifyQ));
217 bwUtilNotifyQ = new LinkedBlockingQueue<UtilizationUpdate>();
218 bwUtilNotifyThread = new Thread(new BwUtilizationNotify(bwUtilNotifyQ));
219 bulkNotifyQ = new LinkedBlockingQueue<String>();
220 ofPluginTopoBulkUpdate = new Thread(new Runnable() {
225 String containerName = bulkNotifyQ.take();
226 logger.debug("Bulk Notify container:{}", containerName);
227 TopologyBulkUpdate(containerName);
228 } catch (InterruptedException e) {
229 logger.warn("Topology Bulk update thread interrupted");
236 }, "Topology Bulk Update");
238 // Initialize node connector tx bit rate poller timer
239 pollTimer = new Timer();
240 txRatePoller = new TimerTask() {
247 registerWithOSGIConsole();
251 * Continuously polls the transmit bit rate for all the node connectors from
252 * statistics manager and trigger the warning notification upward when the
253 * transmit rate is above a threshold which is a percentage of the edge
256 protected void pollTxBitRates() {
257 Map<NodeConnector, Pair<Edge, Set<Property>>> globalContainerEdges = edgeMap
258 .get(GlobalConstants.DEFAULT.toString());
259 if (globalContainerEdges == null) {
263 for (NodeConnector connector : globalContainerEdges.keySet()) {
264 // Skip if node connector belongs to production switch
265 if (connector.getType().equals(
266 NodeConnector.NodeConnectorIDType.PRODUCTION)) {
270 // Get edge for which this node connector is head
271 Pair<Edge, Set<Property>> props = this.edgeMap.get(
272 GlobalConstants.DEFAULT.toString()).get(connector);
273 // On switch mgr restart the props get reset
277 Set<Property> propSet = props.getRight();
278 if (propSet == null) {
283 for (Property prop : propSet) {
284 if (prop instanceof Bandwidth) {
285 bw = ((Bandwidth) prop).getValue();
290 // Skip if agent did not provide a bandwidth info for the edge
295 // Compare bandwidth usage
296 Long switchId = (Long) connector.getNode().getID();
297 Short port = (Short) connector.getID();
298 float rate = statsMgr.getTransmitRate(switchId, port);
299 if (rate > bwThresholdFactor * bw) {
300 if (!connectorsOverUtilized.contains(connector)) {
301 connectorsOverUtilized.add(connector);
302 this.bwUtilNotifyQ.add(new UtilizationUpdate(connector,
306 if (connectorsOverUtilized.contains(connector)) {
307 connectorsOverUtilized.remove(connector);
308 this.bwUtilNotifyQ.add(new UtilizationUpdate(connector,
309 UpdateType.REMOVED));
317 * Function called by the dependency manager when at least one dependency
318 * become unsatisfied or when the component is shutting down because for
319 * example bundle is being stopped.
323 logger.trace("DESTROY called!");
329 * Function called by dependency manager after "init ()" is called and after
330 * the services provided by the class are registered in the service registry
334 logger.trace("START called!");
335 notifyThread.start();
336 bwUtilNotifyThread.start();
337 ofPluginTopoBulkUpdate.start();
338 pollTimer.scheduleAtFixedRate(txRatePoller, 10000, 5000);
342 * Function called by the dependency manager before the services exported by
343 * the component are unregistered, this will be followed by a "destroy ()"
348 logger.trace("STOP called!");
350 notifyThread.interrupt();
353 void setTopologyServiceShimListener(Map<?, ?> props,
354 ITopologyServiceShimListener s) {
356 logger.error("Didn't receive the service properties");
359 String containerName = (String) props.get("containerName");
360 if (containerName == null) {
361 logger.error("containerName not supplied");
364 if ((this.topologyServiceShimListeners != null)
365 && !this.topologyServiceShimListeners
366 .containsKey(containerName)) {
367 this.topologyServiceShimListeners.put(containerName, s);
368 logger.trace("Added topologyServiceShimListener for container: {}",
373 void unsetTopologyServiceShimListener(Map<?, ?> props,
374 ITopologyServiceShimListener s) {
376 logger.error("Didn't receive the service properties");
379 String containerName = (String) props.get("containerName");
380 if (containerName == null) {
381 logger.error("containerName not supplied");
384 if ((this.topologyServiceShimListeners != null)
385 && this.topologyServiceShimListeners.containsKey(containerName)
386 && this.topologyServiceShimListeners.get(containerName).equals(
388 this.topologyServiceShimListeners.remove(containerName);
390 "Removed topologyServiceShimListener for container: {}",
395 void setStatisticsManager(IOFStatisticsManager s) {
399 void unsetStatisticsManager(IOFStatisticsManager s) {
400 if (this.statsMgr == s) {
401 this.statsMgr = null;
405 private void updateContainerMap(List<String> containers, NodeConnector p) {
406 if (containers.isEmpty()) {
407 // Do cleanup to reduce memory footprint if no
408 // elements to be tracked
409 this.containerMap.remove(p);
411 this.containerMap.put(p, containers);
416 * From a given edge map, retrieve the edge sourced by the port and update
417 * the local cache in the container
421 * @param nodeConnector
425 * @return the found edge
427 private Edge addEdge(String container, NodeConnector nodeConnector,
428 Map<NodeConnector, Pair<Edge, Set<Property>>> edges) {
429 logger.debug("Search edge sourced by port {} in container {}", nodeConnector, container);
431 // Retrieve the associated edge
432 Pair<Edge, Set<Property>> edgeProps = edges.get(nodeConnector);
433 if (edgeProps == null) {
434 logger.debug("edgePros is null for port {} in container {}", nodeConnector, container);
438 Edge edge = edgeProps.getLeft();
440 logger.debug("edge is null for port {} in container {}", nodeConnector, container);
444 // Make sure the peer port is in the same container
445 NodeConnector peerConnector = edge.getHeadNodeConnector();
446 List<String> containers = this.containerMap.get(peerConnector);
447 if ((containers == null) || !containers.contains(container)) {
448 logger.debug("peer port {} of edge {} is not part of the container {}", new Object[] { peerConnector, edge,
453 // Update the local cache
454 updateLocalEdgeMap(container, edge, UpdateType.ADDED, edgeProps.getRight());
455 logger.debug("Added edge {} to local cache in container {}", edge, container);
460 private void addNodeConnector(String container,
461 NodeConnector nodeConnector) {
462 // Use the global edge map for the newly added port in a container
463 Map<NodeConnector, Pair<Edge, Set<Property>>> globalEdgeMap = edgeMap.get(GlobalConstants.DEFAULT
465 if (globalEdgeMap == null) {
469 // Get the edge and update local cache in the container
471 edge1 = addEdge(container, nodeConnector, globalEdgeMap);
476 // Get the edge in reverse direction and update local cache in the container
477 NodeConnector peerConnector = edge1.getHeadNodeConnector();
478 edge2 = addEdge(container, peerConnector, globalEdgeMap);
480 // Send notification upwards in one shot
481 List<TopoEdgeUpdate> teuList = new ArrayList<TopoEdgeUpdate>();
482 teuList.add(new TopoEdgeUpdate(edge1, null, UpdateType.ADDED));
483 logger.debug("Notify edge1: {} in container {}", edge1, container);
485 teuList.add(new TopoEdgeUpdate(edge2, null, UpdateType.ADDED));
486 logger.debug("Notify edge2: {} in container {}", edge2, container);
488 notifyEdge(container, teuList);
491 private void removeNodeConnector(String container,
492 NodeConnector nodeConnector) {
493 List<TopoEdgeUpdate> teuList = new ArrayList<TopoEdgeUpdate>();
494 Map<NodeConnector, Pair<Edge, Set<Property>>> edgePropsMap = edgeMap
496 if (edgePropsMap == null) {
500 // Remove edge in one direction
501 Pair<Edge, Set<Property>> edgeProps = edgePropsMap.get(nodeConnector);
502 if (edgeProps == null) {
505 teuList.add(new TopoEdgeUpdate(edgeProps.getLeft(), null,
506 UpdateType.REMOVED));
508 // Remove edge in another direction
509 edgeProps = edgePropsMap
510 .get(edgeProps.getLeft().getHeadNodeConnector());
511 if (edgeProps == null) {
514 teuList.add(new TopoEdgeUpdate(edgeProps.getLeft(), null,
515 UpdateType.REMOVED));
517 // Update in one shot
518 notifyEdge(container, teuList);
522 * Update local cache and return true if it needs to notify upper layer
523 * Topology listeners.
526 * The network container
532 * The edge properties
533 * @return true if it needs to notify upper layer Topology listeners
535 private boolean updateLocalEdgeMap(String container, Edge edge,
536 UpdateType type, Set<Property> props) {
537 ConcurrentMap<NodeConnector, Pair<Edge, Set<Property>>> edgePropsMap = edgeMap
539 NodeConnector src = edge.getTailNodeConnector();
540 Pair<Edge, Set<Property>> edgeProps = new ImmutablePair<Edge, Set<Property>>(
547 if (edgePropsMap == null) {
548 edgePropsMap = new ConcurrentHashMap<NodeConnector, Pair<Edge, Set<Property>>>();
551 if (edgePropsMap.containsKey(src)
552 && edgePropsMap.get(src).equals(edgeProps)) {
553 // Entry already exists. No update.
560 edgePropsMap.put(src, edgeProps);
561 edgeMap.put(container, edgePropsMap);
565 if ((edgePropsMap != null) && edgePropsMap.containsKey(src)) {
566 edgePropsMap.remove(src);
567 if (edgePropsMap.isEmpty()) {
568 edgeMap.remove(container);
570 edgeMap.put(container, edgePropsMap);
577 "notifyLocalEdgeMap: invalid {} for Edge {} in container {}",
578 new Object[] { type.getName(), edge, container });
583 "notifyLocalEdgeMap: {} for Edge {} in container {}",
584 new Object[] { type.getName(), edge, container });
590 private void notifyEdge(String container, Edge edge, UpdateType type,
591 Set<Property> props) {
592 boolean notifyListeners;
594 // Update local cache
595 notifyListeners = updateLocalEdgeMap(container, edge, type, props);
597 // Prepare to update TopologyService
598 if (notifyListeners) {
599 notifyQ.add(new NotifyEntry(container, new TopoEdgeUpdate(edge, props,
601 logger.debug("notifyEdge: {} Edge {} in container {}",
602 new Object[] { type.getName(), edge, container });
606 private void notifyEdge(String container, List<TopoEdgeUpdate> etuList) {
607 if (etuList == null) {
613 List<TopoEdgeUpdate> etuNotifyList = new ArrayList<TopoEdgeUpdate>();
614 boolean notifyListeners = false, rv;
616 for (TopoEdgeUpdate etu : etuList) {
617 edge = etu.getEdge();
618 type = etu.getUpdateType();
620 // Update local cache
621 rv = updateLocalEdgeMap(container, edge, type, etu.getProperty());
623 if (!notifyListeners) {
624 notifyListeners = true;
626 etuNotifyList.add(etu);
628 "notifyEdge(TopoEdgeUpdate): {} Edge {} in container {}",
629 new Object[] { type.getName(), edge, container });
633 // Prepare to update TopologyService
634 if (notifyListeners) {
635 notifyQ.add(new NotifyEntry(container, etuNotifyList));
636 logger.debug("notifyEdge(TopoEdgeUpdate): add notifyQ");
641 public void notifyEdge(Edge edge, UpdateType type, Set<Property> props) {
642 if ((edge == null) || (type == null)) {
646 // Notify default container
647 notifyEdge(GlobalConstants.DEFAULT.toString(), edge, type, props);
649 // Notify the corresponding containers
650 List<String> containers = getEdgeContainers(edge);
651 if (containers != null) {
652 for (String container : containers) {
653 notifyEdge(container, edge, type, props);
659 * Return a list of containers the edge associated with
661 private List<String> getEdgeContainers(Edge edge) {
662 NodeConnector src = edge.getTailNodeConnector(), dst = edge
663 .getHeadNodeConnector();
665 if (!src.getType().equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) {
666 /* Find the common containers for both ends */
667 List<String> srcContainers = this.containerMap.get(src), dstContainers = this.containerMap
668 .get(dst), cmnContainers = null;
669 if ((srcContainers != null) && (dstContainers != null)) {
670 cmnContainers = new ArrayList<String>(srcContainers);
671 cmnContainers.retainAll(dstContainers);
673 return cmnContainers;
676 * If the neighbor is part of a monitored production network, get
677 * the containers that the edge port belongs to
679 return this.containerMap.get(dst);
684 public void tagUpdated(String containerName, Node n, short oldTag,
685 short newTag, UpdateType t) {
689 public void containerFlowUpdated(String containerName,
690 ContainerFlow previousFlow, ContainerFlow currentFlow, UpdateType t) {
694 public void nodeConnectorUpdated(String containerName, NodeConnector p,
696 if (this.containerMap == null) {
697 logger.error("containerMap is NULL");
700 List<String> containers = this.containerMap.get(p);
701 if (containers == null) {
702 containers = new CopyOnWriteArrayList<String>();
706 if (!containers.contains(containerName)) {
707 containers.add(containerName);
708 updateContainerMap(containers, p);
709 addNodeConnector(containerName, p);
713 if (containers.contains(containerName)) {
714 containers.remove(containerName);
715 updateContainerMap(containers, p);
716 removeNodeConnector(containerName, p);
725 public void containerModeUpdated(UpdateType t) {
729 private void registerWithOSGIConsole() {
730 BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass())
732 bundleContext.registerService(CommandProvider.class.getName(), this,
737 public String getHelp() {
738 StringBuffer help = new StringBuffer();
739 help.append("---Topology Service Shim---\n");
740 help.append("\t pem [container] - Print edgeMap entries");
741 help.append(" for a given container\n");
742 return help.toString();
745 public void _pem(CommandInterpreter ci) {
746 String container = ci.nextArgument();
747 if (container == null) {
748 container = GlobalConstants.DEFAULT.toString();
751 ci.println("Container: " + container);
752 ci.println(" Edge Bandwidth");
754 Map<NodeConnector, Pair<Edge, Set<Property>>> edgePropsMap = edgeMap
756 if (edgePropsMap == null) {
760 for (Pair<Edge, Set<Property>> edgeProps : edgePropsMap.values()) {
761 if (edgeProps == null) {
766 Set<Property> props = edgeProps.getRight();
768 for (Property prop : props) {
769 if (prop.getName().equals(Bandwidth.BandwidthPropName)) {
770 bw = ((Bandwidth) prop).getValue();
775 ci.println(edgeProps.getLeft() + " " + bw);
777 ci.println("Total number of Edges: " + count);
780 public void _bwfactor(CommandInterpreter ci) {
781 String factorString = ci.nextArgument();
782 if (factorString == null) {
783 ci.println("Bw threshold: " + this.bwThresholdFactor);
784 ci.println("Insert a non null bw threshold");
787 bwThresholdFactor = Float.parseFloat(factorString);
788 ci.println("New Bw threshold: " + this.bwThresholdFactor);
792 * This method will trigger topology updates to be sent toward SAL. SAL then
793 * pushes the updates to ALL the applications that have registered as
794 * listeners for this service. SAL has no way of knowing which application
795 * requested for the refresh.
797 * As an example of this case, is stopping and starting the Topology
798 * Manager. When the topology Manager is stopped, and restarted, it will no
799 * longer have the latest topology. Hence, a request is sent here.
801 * @param containerName
805 public void requestRefresh(String containerName) {
806 // wake up a bulk update thread and exit
807 // the thread will execute the bulkUpdate()
808 bulkNotifyQ.add(containerName);
812 * Retrieve the edges for a given container
814 * @param containerName
816 * @return the edges and their properties
818 private Collection<Pair<Edge, Set<Property>>> getEdgeProps(String containerName) {
819 Map<NodeConnector, Pair<Edge, Set<Property>>> edgePropMap = null;
820 edgePropMap = edgeMap.get(containerName);
821 if (edgePropMap == null) {
824 return edgePropMap.values();
828 * Reading the current topology database, the method will replay all the
829 * edge updates for the ITopologyServiceShimListener instance in the given
830 * container, which will in turn publish them toward SAL.
832 * @param containerName
835 private void TopologyBulkUpdate(String containerName) {
836 Collection<Pair<Edge, Set<Property>>> edgeProps = null;
838 logger.debug("Try bulk update for container:{}", containerName);
839 edgeProps = getEdgeProps(containerName);
840 if (edgeProps == null) {
841 logger.debug("No edges known for container:{}", containerName);
844 ITopologyServiceShimListener topologServiceShimListener = topologyServiceShimListeners
846 if (topologServiceShimListener == null) {
847 logger.debug("No topology service shim listener for container:{}",
852 List<TopoEdgeUpdate> teuList = new ArrayList<TopoEdgeUpdate>();
853 for (Pair<Edge, Set<Property>> edgeProp : edgeProps) {
854 if (edgeProp != null) {
856 teuList.add(new TopoEdgeUpdate(edgeProp.getLeft(), edgeProp
857 .getRight(), UpdateType.ADDED));
858 logger.trace("Add edge {}", edgeProp.getLeft());
862 topologServiceShimListener.edgeUpdate(teuList);
864 logger.debug("Sent {} updates", i);
868 public void updateNode(Node node, UpdateType type, Set<Property> props) {
872 public void updateNodeConnector(NodeConnector nodeConnector,
873 UpdateType type, Set<Property> props) {
874 List<String> containers = new ArrayList<String>();
875 List<String> conList = this.containerMap.get(nodeConnector);
877 containers.add(GlobalConstants.DEFAULT.toString());
878 if (conList != null) {
879 containers.addAll(conList);
890 boolean rmEdge = false;
891 for (Property prop : props) {
892 if (((prop instanceof Config) && (((Config) prop).getValue() != Config.ADMIN_UP))
893 || ((prop instanceof State) && (((State) prop)
894 .getValue() != State.EDGE_UP))) {
896 * If port admin down or link down, remove the edges
897 * associated with the port
905 for (String cName : containers) {
906 removeNodeConnector(cName, nodeConnector);
911 for (String cName : containers) {
912 removeNodeConnector(cName, nodeConnector);
921 public void containerCreate(String containerName) {
926 public void containerDestroy(String containerName) {
927 Set<NodeConnector> removeNodeConnectorSet = new HashSet<NodeConnector>();
928 for (Map.Entry<NodeConnector, List<String>> entry : containerMap.entrySet()) {
929 List<String> ncContainers = entry.getValue();
930 if (ncContainers.contains(containerName)) {
931 NodeConnector nodeConnector = entry.getKey();
932 removeNodeConnectorSet.add(nodeConnector);
935 for (NodeConnector nodeConnector : removeNodeConnectorSet) {
936 List<String> ncContainers = containerMap.get(nodeConnector);
937 ncContainers.remove(containerName);
938 if (ncContainers.isEmpty()) {
939 containerMap.remove(nodeConnector);
942 edgeMap.remove(containerName);