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/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
index 931ac72..a944ca6 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
@@ -16,6 +16,7 @@
package org.onosproject.net.intent;
import com.google.common.base.MoreObjects;
+import org.onlab.graph.Weight;
import org.onlab.util.Bandwidth;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.core.GroupId;
@@ -46,7 +47,7 @@
import org.onosproject.net.resource.ResourceService;
import org.onosproject.net.topology.DefaultTopologyEdge;
import org.onosproject.net.topology.DefaultTopologyVertex;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
import org.onosproject.net.topology.PathServiceAdapter;
import org.onosproject.net.topology.TopologyVertex;
import org.onosproject.store.Timestamp;
@@ -159,19 +160,19 @@
}
@Override
- public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
- final Set<Path> paths = getPaths(src, dst);
+ public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
+ Set<Path> paths = getPaths(src, dst);
for (Path path : paths) {
- final DeviceId srcDevice = path.src().elementId() instanceof DeviceId ? path.src().deviceId() : null;
- final DeviceId dstDevice = path.dst().elementId() instanceof DeviceId ? path.dst().deviceId() : null;
+ DeviceId srcDevice = path.src().elementId() instanceof DeviceId ? path.src().deviceId() : null;
+ DeviceId dstDevice = path.dst().elementId() instanceof DeviceId ? path.dst().deviceId() : null;
if (srcDevice != null && dstDevice != null) {
- final TopologyVertex srcVertex = new DefaultTopologyVertex(srcDevice);
- final TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
- final Link link = link(src.toString(), 1, dst.toString(), 1);
+ TopologyVertex srcVertex = new DefaultTopologyVertex(srcDevice);
+ TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
+ Link link = link(src.toString(), 1, dst.toString(), 1);
- final double weightValue = weight.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
- if (weightValue < 0) {
+ Weight weightValue = weigher.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
+ if (weightValue.isNegative()) {
return new HashSet<>();
}
}
@@ -220,7 +221,7 @@
}
@Override
- public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
+ public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
final Set<Path> paths = getPaths(src, dst);
for (Path path : paths) {
@@ -231,8 +232,8 @@
final TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
final Link link = link(src.toString(), 1, dst.toString(), 1);
- final double weightValue = weight.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
- if (weightValue < 0) {
+ final Weight weightValue = weigher.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
+ if (weightValue.isNegative()) {
return new HashSet<>();
}
}
diff --git a/core/api/src/test/java/org/onosproject/net/topology/PathServiceAdapter.java b/core/api/src/test/java/org/onosproject/net/topology/PathServiceAdapter.java
index eecb73e..f0494b1 100644
--- a/core/api/src/test/java/org/onosproject/net/topology/PathServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/net/topology/PathServiceAdapter.java
@@ -38,12 +38,25 @@
}
@Override
+ public Set<Path> getPaths(ElementId src, ElementId dst,
+ LinkWeigher weigher) {
+ return null;
+ }
+
+ @Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
return null;
}
@Override
- public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
+ public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
+ LinkWeight weight) {
+ return null;
+ }
+
+ @Override
+ public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
+ LinkWeigher weigher) {
return null;
}
@@ -59,4 +72,11 @@
Map<Link, Object> riskProfile) {
return null;
}
+
+ @Override
+ public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
+ LinkWeigher weigher,
+ Map<Link, Object> riskProfile) {
+ return null;
+ }
}
diff --git a/core/api/src/test/java/org/onosproject/net/topology/TopologyServiceAdapter.java b/core/api/src/test/java/org/onosproject/net/topology/TopologyServiceAdapter.java
index f86bb3b..79ec17c 100644
--- a/core/api/src/test/java/org/onosproject/net/topology/TopologyServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/net/topology/TopologyServiceAdapter.java
@@ -54,12 +54,14 @@
}
@Override
- public Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster) {
+ public Set<DeviceId> getClusterDevices(Topology topology,
+ TopologyCluster cluster) {
return null;
}
@Override
- public Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster) {
+ public Set<Link> getClusterLinks(Topology topology,
+ TopologyCluster cluster) {
return null;
}
@@ -69,17 +71,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 null;
}
@Override
- public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) {
+ public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
+ LinkWeigher weigher) {
+ return null;
+ }
+
+ @Override
+ public boolean isInfrastructure(Topology topology,
+ ConnectPoint connectPoint) {
return false;
}
@Override
- public boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint) {
+ public boolean isBroadcastPoint(Topology topology,
+ ConnectPoint connectPoint) {
return false;
}
@@ -92,18 +103,28 @@
}
@Override
- public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
+ public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+ DeviceId dst) {
return null;
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
- DeviceId dst, LinkWeight weight) {
+ DeviceId dst,
+ LinkWeight weight) {
return null;
}
@Override
- public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
+ public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+ DeviceId dst,
+ LinkWeigher weigher) {
+ return null;
+ }
+
+ @Override
+ public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+ DeviceId dst,
Map<Link, Object> riskProfile) {
return null;
}
@@ -115,4 +136,12 @@
return null;
}
+ @Override
+ public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+ DeviceId dst,
+ LinkWeigher weigher,
+ Map<Link, Object> riskProfile) {
+ return null;
+ }
+
}