public void addEdge(Edge edge, Set<Property> properties, UpdateType updateType){ List<TopoEdgeUpdate > topoedgeupdateList = new ArrayList<TopoEdgeUpdate>(); topoedgeupdateList.add(new TopoEdgeUpdate(edge, properties, updateType)); this.pluginOutTopologyService.edgeUpdate(topoedgeupdateList); } }
@Override public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) { if (logger.isDebugEnabled()) { for (TopoEdgeUpdate topoEdgeUpdate : topoedgeupdateList) { Edge e = topoEdgeUpdate.getEdge(); Set<Property> p = topoEdgeUpdate.getProperty(); UpdateType type = topoEdgeUpdate.getUpdateType(); debugEdgeUpdate(e, type, p); } } }
private void edgeUpdateClusterWide(Edge e, UpdateType type, Set<Property> props, boolean isLocal) { TopoEdgeUpdate upd = new TopoEdgeUpdate(e, props, type); upd.setLocal(isLocal); notifyQ.add(upd); }
private String edgeListToString(List<TopoEdgeUpdate> topoedgeupdateList){ String str = ""; for(TopoEdgeUpdate edgeUpd : topoedgeupdateList){ str += edgeUpd.getEdge().toString() + "\t" + edgeUpd.getUpdateType() + "\n"; } return str; } }
boolean callListeners = false; for (int i = 0; i < topoedgeupdateList.size(); i++) { Edge e = topoedgeupdateList.get(i).getEdge(); Set<Property> p = topoedgeupdateList.get(i) .getProperty(); UpdateType type = topoedgeupdateList.get(i) .getUpdateType(); boolean isLocal = topoedgeupdateList.get(i) .isLocal(); if ((edgeUpdate(e, type, p, isLocal)) && (!callListeners)) { callListeners = true;
/** * Constructor for a topology element update. A TopologyElementUpdate is an * object that summarize what has happened on an Edge and if the update is * generated locally to this controller or no * * @param e * Edge being updated * @param p * Set of Properties attached to the edge * @param t * Type of update */ public TopoEdgeUpdate(Edge e, Set<Property> p, UpdateType t) { edge = e; props = p; type = t; setLocal(true); }
public void edgeUpdateToMdSal(List<TopoEdgeUpdate> topoedgeupdateList) { if (this.notifService == null) { logger.debug("ERROR: edgeUpdateToMdSal(): NotificationProviderService is null!"); return; } for(TopoEdgeUpdate edgeU : topoedgeupdateList){ Edge edge = edgeU.getEdge(); UpdateType type = edgeU.getUpdateType(); if(type == UpdateType.ADDED){ LinkDiscovered link = makeAddLink(edge); if(link == null) logger.debug("ERROR: edgeUpdateToMdSal(): call makeLink() given edge {}, error!"); else notifService.publish(link); } else if(type == UpdateType.REMOVED){ LinkRemoved link = makeRemoveLink(edge); if(link == null) logger.debug("ERROR: edgeUpdateToMdSal(): call makeLink() given edge {}, error!"); else notifService.publish(link); } else logger.debug("ERROR: edgeUpdateToMdSal(): given edge {} of type {}, not defined how to process, so ignore", edge, type); } }
private void doEdgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) { List<TopoEdgeUpdate> teuList = new ArrayList<TopoEdgeUpdate>(); for (TopoEdgeUpdate teu : topoedgeupdateList) { boolean isPending = (teu instanceof PendingEdgeUpdate); Edge e = teu.getEdge(); Set<Property> p = teu.getProperty(); UpdateType type = teu.getUpdateType(); TopoEdgeUpdate update = edgeUpdate(e, type, p, isPending); if (update != null) { teuList.add(update); } } if (!teuList.isEmpty()) { // Now update the listeners for (ITopologyManagerAware s : this.topologyManagerAware) { try { s.edgeUpdate(teuList); } catch (Exception exc) { log.error("Exception on edge update:", exc); } } } }
public static TopoEdgeUpdate toTopoEdgeUpdate(final Edge e,final UpdateType type,final TypeSafeDataReader reader) { return new TopoEdgeUpdate(e, toAdEdgeProperties(e, reader), type); }
private void notifyEdge(String container, List<TopoEdgeUpdate> etuList) { if (etuList == null) { return; } Edge edge; UpdateType type; List<TopoEdgeUpdate> etuNotifyList = new ArrayList<TopoEdgeUpdate>(); boolean notifyListeners = false, rv; for (TopoEdgeUpdate etu : etuList) { edge = etu.getEdge(); type = etu.getUpdateType(); // Update local cache rv = updateLocalEdgeMap(container, edge, type, etu.getProperty()); if (rv) { if (!notifyListeners) { notifyListeners = true; } etuNotifyList.add(etu); logger.debug( "notifyEdge(TopoEdgeUpdate): {} Edge {} in container {}", new Object[] { type.getName(), edge, container }); } } // Prepare to update TopologyService if (notifyListeners) { notifyQ.add(new NotifyEntry(container, etuNotifyList)); logger.debug("notifyEdge(TopoEdgeUpdate): add notifyQ"); } }
private void notifyEdge(String container, Edge edge, UpdateType type, Set<Property> props) { boolean notifyListeners; // Update local cache notifyListeners = updateLocalEdgeMap(container, edge, type, props); // Prepare to update TopologyService if (notifyListeners) { notifyQ.add(new NotifyEntry(container, new TopoEdgeUpdate(edge, props, type))); logger.trace("notifyEdge: {} Edge {} in container {}", new Object[] { type.getName(), edge, container });//lg.dbug-trc } }
private void notifyEdge(String container, List<TopoEdgeUpdate> etuList) { if (etuList == null) { return; } Edge edge; UpdateType type; List<TopoEdgeUpdate> etuNotifyList = new ArrayList<TopoEdgeUpdate>(); boolean notifyListeners = false, rv; for (TopoEdgeUpdate etu : etuList) { edge = etu.getEdge(); type = etu.getUpdateType(); // Update local cache rv = updateLocalEdgeMap(container, edge, type, etu.getProperty()); if (rv) { if (!notifyListeners) { notifyListeners = true; } etuNotifyList.add(etu); logger.debug( "notifyEdge(TopoEdgeUpdate): {} Edge {} in container {}", new Object[] { type.getName(), edge, container }); } } // Prepare to update TopologyService if (notifyListeners) { notifyQ.add(new NotifyEntry(container, etuNotifyList)); logger.debug("notifyEdge(TopoEdgeUpdate): add notifyQ"); } }
private void notifyEdge(String container, Edge edge, UpdateType type, Set<Property> props) { boolean notifyListeners; // Update local cache notifyListeners = updateLocalEdgeMap(container, edge, type, props); // Prepare to update TopologyService if (notifyListeners) { notifyQ.add(new NotifyEntry(container, new TopoEdgeUpdate(edge, props, type))); logger.debug("notifyEdge: {} Edge {} in container {}", new Object[] { type.getName(), edge, container }); } }
return; }else{ teuList.add(new TopoEdgeUpdate(edgeProps.getLeft(), null, UpdateType.REMOVED)); teuList.add(new TopoEdgeUpdate(edgeProps.getLeft(), null, UpdateType.REMOVED));
private void removeNodeConnector(String container, NodeConnector nodeConnector) { List<TopoEdgeUpdate> teuList = new ArrayList<TopoEdgeUpdate>(); Map<NodeConnector, Pair<Edge, Set<Property>>> edgePropsMap = edgeMap .get(container); if (edgePropsMap == null) { return; } // Remove edge in one direction Pair<Edge, Set<Property>> edgeProps = edgePropsMap.get(nodeConnector); if (edgeProps == null) { return; } teuList.add(new TopoEdgeUpdate(edgeProps.getLeft(), null, UpdateType.REMOVED)); // Remove edge in another direction edgeProps = edgePropsMap .get(edgeProps.getLeft().getHeadNodeConnector()); if (edgeProps == null) { return; } teuList.add(new TopoEdgeUpdate(edgeProps.getLeft(), null, UpdateType.REMOVED)); // Update in one shot notifyEdge(container, teuList); }
if (edgeProps != null) { i++; teuList.add(new TopoEdgeUpdate(edgeProps.getLeft(), edgeProps .getRight(), UpdateType.ADDED)); logger.trace("Add edge {}", edgeProps.getLeft());
/** * Function called by dependency manager after "init ()" is called and after * the services provided by the class are registered in the service registry * */ void start() { log.debug("Routing start() is called"); // build the routing database from the topology if it exists. Map<Edge, Set<Property>> edges = topologyManager.getEdges(); if (edges.isEmpty()) { return; } List<TopoEdgeUpdate> topoedgeupdateList = new ArrayList<TopoEdgeUpdate>(); log.debug("Creating routing database from the topology"); for (Iterator<Map.Entry<Edge, Set<Property>>> i = edges.entrySet() .iterator(); i.hasNext();) { Map.Entry<Edge, Set<Property>> entry = i.next(); Edge e = entry.getKey(); Set<Property> props = entry.getValue(); TopoEdgeUpdate topoedgeupdate = new TopoEdgeUpdate(e, props, UpdateType.ADDED); topoedgeupdateList.add(topoedgeupdate); } edgeUpdate(topoedgeupdateList); }
if (edgeProp != null) { i++; teuList.add(new TopoEdgeUpdate(edgeProp.getLeft(), edgeProp .getRight(), UpdateType.ADDED)); logger.trace("Add edge {}", edgeProp.getLeft());
private void addNodeConnector(String container, NodeConnector nodeConnector) { // Use the global edge map for the newly added port in a container Map<NodeConnector, Pair<Edge, Set<Property>>> globalEdgeMap = edgeMap.get(GlobalConstants.DEFAULT .toString()); if (globalEdgeMap == null) { return; } // Get the edge and update local cache in the container Edge edge1, edge2; edge1 = addEdge(container, nodeConnector, globalEdgeMap); if (edge1 == null) { return; } // Get the edge in reverse direction and update local cache in the container NodeConnector peerConnector = edge1.getHeadNodeConnector(); edge2 = addEdge(container, peerConnector, globalEdgeMap); // Send notification upwards in one shot List<TopoEdgeUpdate> teuList = new ArrayList<TopoEdgeUpdate>(); teuList.add(new TopoEdgeUpdate(edge1, null, UpdateType.ADDED)); logger.debug("Notify edge1: {} in container {}", edge1, container); if (edge2 != null) { teuList.add(new TopoEdgeUpdate(edge2, null, UpdateType.ADDED)); logger.debug("Notify edge2: {} in container {}", edge2, container); } notifyEdge(container, teuList); }
break; return new TopoEdgeUpdate(e, props, type);