import org.opendaylight.controller.topologymanager.ITopologyManager;
import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
import org.opendaylight.controller.topologymanager.ITopologyManagerClusterWideAware;
+import org.opendaylight.controller.topologymanager.ITopologyManagerShell;
import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
public class TopologyManagerImpl implements
ICacheUpdateAware<Object, Object>,
ITopologyManager,
+ ITopologyManagerShell,
IConfigurationContainerAware,
IListenTopoUpdates,
IObjectReader,
}
@Override
- public void updateHostLink(NodeConnector port, Host h, UpdateType t, Set<Property> props) {
+ public synchronized void updateHostLink(NodeConnector port, Host h, UpdateType t, Set<Property> props) {
// Clone the property set in case non null else just
// create an empty one. Caches allocated via infinispan
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>();
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)) {
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) {
}
}
}
+
+ public List<String> printUserLink() {
+ List<String> result = new ArrayList<String>();
+ for (String name : this.userLinksDB.keySet()) {
+ TopologyUserLinkConfig linkConfig = userLinksDB.get(name);
+ result.add("Name : " + name);
+ result.add(linkConfig.toString());
+ result.add("Edge " + getLinkTuple(linkConfig));
+ result.add("Reverse Edge " + getReverseLinkTuple(linkConfig));
+ }
+ return result;
+ }
+
+ public List<String> addUserLink(String name, String ncStr1, String ncStr2) {
+ List<String> result = new ArrayList<String>();
+ if ((name == null)) {
+ result.add("Please enter a valid Name");
+ return result;
+ }
+
+ if (ncStr1 == null) {
+ result.add("Please enter two node connector strings");
+ return result;
+ }
+ if (ncStr2 == null) {
+ result.add("Please enter second node connector string");
+ return result;
+ }
+
+ NodeConnector nc1 = NodeConnector.fromString(ncStr1);
+ if (nc1 == null) {
+ result.add("Invalid input node connector 1 string: " + ncStr1);
+ return result;
+ }
+ NodeConnector nc2 = NodeConnector.fromString(ncStr2);
+ if (nc2 == null) {
+ result.add("Invalid input node connector 2 string: " + ncStr2);
+ return result;
+ }
+
+ TopologyUserLinkConfig config = new TopologyUserLinkConfig(name, ncStr1, ncStr2);
+ result.add(this.addUserLink(config).toString());
+ return result;
+ }
+
+ public List<String> deleteUserLinkShell(String name) {
+ List<String> result = new ArrayList<String>();
+ if ((name == null)) {
+ result.add("Please enter a valid Name");
+ return result;
+ }
+ this.deleteUserLink(name);
+ return result;
+ }
+
+ public List<String> printNodeEdges() {
+ List<String> result = new ArrayList<String>();
+ Map<Node, Set<Edge>> nodeEdges = getNodeEdges();
+ if (nodeEdges == null) {
+ return result;
+ }
+ Set<Node> nodeSet = nodeEdges.keySet();
+ if (nodeSet == null) {
+ return result;
+ }
+ result.add(" Node Edge");
+ for (Node node : nodeSet) {
+ Set<Edge> edgeSet = nodeEdges.get(node);
+ if (edgeSet == null) {
+ continue;
+ }
+ for (Edge edge : edgeSet) {
+ result.add(node + " " + edge);
+ }
+ }
+ return result;
+ }
+
}