Vector cost proposed to TST on 2016-07-13
First part implemented: weight interface introduced and integrated, default weight implementation added.
Change-Id: Ia46f1b44139069aa171a3c13faf168351bd7cc56
diff --git a/core/net/src/main/java/org/onosproject/net/topology/impl/PathManager.java b/core/net/src/main/java/org/onosproject/net/topology/impl/PathManager.java
index 5c41ff4..ec650da 100644
--- a/core/net/src/main/java/org/onosproject/net/topology/impl/PathManager.java
+++ b/core/net/src/main/java/org/onosproject/net/topology/impl/PathManager.java
@@ -26,6 +26,7 @@
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.host.HostService;
+import org.onosproject.net.topology.LinkWeigher;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.PathService;
import org.onosproject.net.topology.TopologyService;
@@ -74,7 +75,7 @@
public Set<Path> getPaths(ElementId src, ElementId dst) {
checkPermission(TOPOLOGY_READ);
- return getPaths(src, dst, null);
+ return getPaths(src, dst, (LinkWeigher) null);
}
@Override
@@ -83,11 +84,17 @@
return super.getPaths(src, dst, weight);
}
+ @Override
+ public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
+ checkPermission(TOPOLOGY_READ);
+ return super.getPaths(src, dst, weigher);
+ }
+
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
checkPermission(TOPOLOGY_READ);
- return getDisjointPaths(src, dst, (LinkWeight) null);
+ return getDisjointPaths(src, dst, (LinkWeigher) null);
}
@Override
@@ -97,10 +104,16 @@
}
@Override
+ public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
+ checkPermission(TOPOLOGY_READ);
+ return super.getDisjointPaths(src, dst, weigher);
+ }
+
+ @Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
Map<Link, Object> riskProfile) {
checkPermission(TOPOLOGY_READ);
- return getDisjointPaths(src, dst, null, riskProfile);
+ return getDisjointPaths(src, dst, (LinkWeigher) null, riskProfile);
}
@Override
@@ -110,4 +123,11 @@
return super.getDisjointPaths(src, dst, weight, riskProfile);
}
+ @Override
+ public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeigher weigher,
+ Map<Link, Object> riskProfile) {
+ checkPermission(TOPOLOGY_READ);
+ return super.getDisjointPaths(src, dst, weigher, riskProfile);
+ }
+
}
diff --git a/core/net/src/main/java/org/onosproject/net/topology/impl/TopologyManager.java b/core/net/src/main/java/org/onosproject/net/topology/impl/TopologyManager.java
index 4203a8e..ecf7e25 100644
--- a/core/net/src/main/java/org/onosproject/net/topology/impl/TopologyManager.java
+++ b/core/net/src/main/java/org/onosproject/net/topology/impl/TopologyManager.java
@@ -31,6 +31,7 @@
import org.onosproject.net.provider.AbstractProviderService;
import org.onosproject.net.topology.ClusterId;
import org.onosproject.net.topology.GraphDescription;
+import org.onosproject.net.topology.LinkWeigher;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyCluster;
@@ -50,6 +51,7 @@
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
import static org.onosproject.security.AppGuard.checkPermission;
import static org.slf4j.LoggerFactory.getLogger;
import static org.onosproject.security.AppPermission.Type.*;
@@ -154,18 +156,26 @@
}
@Override
- public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
+ public Set<Path> getPaths(Topology topology, DeviceId src,
+ DeviceId dst, LinkWeight weight) {
+ return getPaths(topology, src, dst, adapt(weight));
+ }
+
+ @Override
+ public Set<Path> getPaths(Topology topology, DeviceId src,
+ DeviceId dst, LinkWeigher weigher) {
checkPermission(TOPOLOGY_READ);
checkNotNull(topology, TOPOLOGY_NULL);
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
- checkNotNull(weight, "Link weight cannot be null");
- return store.getPaths(topology, src, dst, weight);
+ checkNotNull(weigher, "Link weight cannot be null");
+ return store.getPaths(topology, src, dst, weigher);
}
@Override
- public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
+ public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+ DeviceId dst) {
checkPermission(TOPOLOGY_READ);
checkNotNull(topology, TOPOLOGY_NULL);
checkNotNull(src, DEVICE_ID_NULL);
@@ -175,17 +185,26 @@
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
- DeviceId dst, LinkWeight weight) {
+ DeviceId dst,
+ LinkWeight weight) {
+ return getDisjointPaths(topology, src, dst, adapt(weight));
+ }
+
+ @Override
+ public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+ DeviceId dst,
+ LinkWeigher weigher) {
checkPermission(TOPOLOGY_READ);
checkNotNull(topology, TOPOLOGY_NULL);
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
- checkNotNull(weight, LINK_WEIGHT_NULL);
- return store.getDisjointPaths(topology, src, dst, weight);
+ checkNotNull(weigher, LINK_WEIGHT_NULL);
+ return store.getDisjointPaths(topology, src, dst, weigher);
}
@Override
- public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
+ public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+ DeviceId dst,
Map<Link, Object> riskProfile) {
checkPermission(TOPOLOGY_READ);
checkNotNull(topology, TOPOLOGY_NULL);
@@ -198,12 +217,20 @@
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
DeviceId dst, LinkWeight weight,
Map<Link, Object> riskProfile) {
+ return getDisjointPaths(topology, src, dst, adapt(weight), riskProfile);
+ }
+
+ @Override
+ public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+ DeviceId dst,
+ LinkWeigher weigher,
+ Map<Link, Object> riskProfile) {
checkPermission(TOPOLOGY_READ);
checkNotNull(topology, TOPOLOGY_NULL);
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
- checkNotNull(weight, LINK_WEIGHT_NULL);
- return store.getDisjointPaths(topology, src, dst, weight, riskProfile);
+ checkNotNull(weigher, LINK_WEIGHT_NULL);
+ return store.getDisjointPaths(topology, src, dst, weigher, riskProfile);
}
@Override