Remove deprecated LinkWeight interface
Change-Id: I4d3edab133d115ba189f317202d2dfba9b100918
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
index 3ad3c0e..3612273 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
@@ -24,6 +24,8 @@
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.Annotations;
import org.onosproject.net.ChannelSpacing;
@@ -51,8 +53,7 @@
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceService;
import org.onosproject.net.resource.Resources;
-import org.onosproject.net.topology.AdapterLinkWeigher;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyEdge;
import org.onosproject.net.topology.TopologyService;
@@ -337,34 +338,44 @@
// Route in WDM topology
Topology topology = topologyService.currentTopology();
//TODO: refactor with LinkWeigher class Implementation
- LinkWeight weight = new LinkWeight() {
+ LinkWeigher weight = new LinkWeigher() {
@Override
- public double weight(TopologyEdge edge) {
+ public Weight getInitialWeight() {
+ return ScalarWeight.toWeight(0.0);
+ }
+
+ @Override
+ public Weight getNonViableWeight() {
+ return ScalarWeight.NON_VIABLE_WEIGHT;
+ }
+
+ @Override
+ public Weight weight(TopologyEdge edge) {
// Disregard inactive or non-optical links
if (edge.link().state() == Link.State.INACTIVE) {
- return -1;
+ return ScalarWeight.toWeight(-1);
}
if (edge.link().type() != Link.Type.OPTICAL) {
- return -1;
+ return ScalarWeight.toWeight(-1);
}
// Adhere to static port mappings
DeviceId srcDeviceId = edge.link().src().deviceId();
if (srcDeviceId.equals(intent.getSrc().deviceId())) {
ConnectPoint srcStaticPort = staticPort(intent.getSrc());
if (srcStaticPort != null) {
- return srcStaticPort.equals(edge.link().src()) ? 1 : -1;
+ return ScalarWeight.toWeight(srcStaticPort.equals(edge.link().src()) ? 1 : -1);
}
}
DeviceId dstDeviceId = edge.link().dst().deviceId();
if (dstDeviceId.equals(intent.getDst().deviceId())) {
ConnectPoint dstStaticPort = staticPort(intent.getDst());
if (dstStaticPort != null) {
- return dstStaticPort.equals(edge.link().dst()) ? 1 : -1;
+ return ScalarWeight.toWeight(dstStaticPort.equals(edge.link().dst()) ? 1 : -1);
}
}
- return 1;
+ return ScalarWeight.toWeight(1);
}
};
@@ -393,7 +404,7 @@
Stream<Path> paths = topologyService.getKShortestPaths(topology,
start.deviceId(),
end.deviceId(),
- AdapterLinkWeigher.adapt(weight))
+ weight)
.filter(p -> p.links().get(0).src().port().equals(start.port()) &&
p.links().get(p.links().size() - 1).dst().port().equals(end.port()));
if (log.isDebugEnabled()) {
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
index 4b386bd..e45bfb1 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
@@ -21,6 +21,8 @@
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.net.ConnectPoint;
@@ -54,8 +56,9 @@
import org.onosproject.net.resource.ResourceService;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.Resources;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
import org.onosproject.net.topology.Topology;
+import org.onosproject.net.topology.TopologyEdge;
import org.onosproject.net.topology.TopologyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -256,25 +259,41 @@
// Route in OTU topology
Topology topology = topologyService.currentTopology();
- LinkWeight weight = edge -> {
- // Disregard inactive or non-optical links
- if (edge.link().state() == Link.State.INACTIVE) {
- return -1;
+
+ class Weigher implements LinkWeigher {
+ @Override
+ public Weight weight(TopologyEdge edge) {
+ if (edge.link().state() == Link.State.INACTIVE) {
+ return ScalarWeight.toWeight(-1);
+ }
+ if (edge.link().type() != Link.Type.OPTICAL) {
+ return ScalarWeight.toWeight(-1);
+ }
+ // Find path with available TributarySlots resources
+ if (!isAvailableTributarySlots(intent, edge.link())) {
+ return ScalarWeight.toWeight(-1);
+ }
+ return ScalarWeight.toWeight(1);
}
- if (edge.link().type() != Link.Type.OPTICAL) {
- return -1;
+
+ @Override
+ public Weight getInitialWeight() {
+ return null;
}
- // Find path with available TributarySlots resources
- if (!isAvailableTributarySlots(intent, edge.link())) {
- return -1;
+
+ @Override
+ public Weight getNonViableWeight() {
+ return null;
}
- return 1;
- };
+ }
+
+
+ LinkWeigher weigher = new Weigher();
ConnectPoint start = intent.getSrc();
ConnectPoint end = intent.getDst();
- return topologyService.getPaths(topology, start.deviceId(), end.deviceId(), weight);
+ return topologyService.getPaths(topology, start.deviceId(), end.deviceId(), weigher);
}
private boolean isAvailableTributarySlots(OpticalOduIntent intent, Link link) {
diff --git a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java
index 46c408f..2c39274 100644
--- a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java
+++ b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java
@@ -66,7 +66,7 @@
import org.onosproject.net.optical.impl.DefaultOtuPort;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.resource.MockResourceService;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyServiceAdapter;
@@ -173,13 +173,13 @@
Set<Path> paths = Sets.newHashSet(path);
@Override
- public Topology currentTopology() {
- return null;
+ public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeigher weight) {
+ return paths;
}
@Override
- public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
- return paths;
+ public Topology currentTopology() {
+ return null;
}
}
diff --git a/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java
index 7da14a9..b1f9d44 100644
--- a/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java
+++ b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java
@@ -28,7 +28,7 @@
import org.onosproject.net.Path;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.topology.GeoDistanceLinkWeight;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
import org.onosproject.net.topology.PathService;
import org.onosproject.net.topology.TopologyEvent;
import org.onosproject.net.topology.TopologyListener;
@@ -78,7 +78,7 @@
private Set<Link> allPathLinks;
private boolean listenersRemoved;
- private LinkWeight linkData;
+ private LinkWeigher linkData;
private int highlightDelay;
private enum Mode {
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
index 3ecdd5b..e7ef935 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
@@ -18,6 +18,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
import org.onosproject.net.DisjointPath;
import java.util.ArrayList;
import java.util.Collection;
@@ -68,6 +69,7 @@
import org.onosproject.net.link.LinkEvent;
import org.onosproject.net.MastershipRole;
import org.onosproject.bandwidthmgr.api.BandwidthMgmtService;
+import org.onosproject.net.topology.LinkWeigher;
import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
import org.onosproject.pce.pceservice.constraint.CapabilityConstraint.CapabilityType;
import org.onosproject.pce.pceservice.constraint.CostConstraint;
@@ -75,7 +77,6 @@
import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint;
import org.onosproject.net.resource.Resource;
import org.onosproject.net.resource.ResourceAllocation;
-import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.PathService;
import org.onosproject.net.topology.TopologyEdge;
import org.onosproject.net.topology.TopologyEvent;
@@ -225,7 +226,7 @@
* @param constraints path constraints
* @return edge-weight function
*/
- private LinkWeight weight(List<Constraint> constraints) {
+ private LinkWeigher weight(List<Constraint> constraints) {
return new TeConstraintBasedLinkWeight(constraints);
}
@@ -957,7 +958,7 @@
return value;
}
- protected class TeConstraintBasedLinkWeight implements LinkWeight {
+ protected class TeConstraintBasedLinkWeight implements LinkWeigher {
private final List<Constraint> constraints;
@@ -976,10 +977,20 @@
}
@Override
- public double weight(TopologyEdge edge) {
+ public Weight getInitialWeight() {
+ return ScalarWeight.toWeight(0.0);
+ }
+
+ @Override
+ public Weight getNonViableWeight() {
+ return ScalarWeight.toWeight(0.0);
+ }
+
+ @Override
+ public Weight weight(TopologyEdge edge) {
if (!constraints.iterator().hasNext()) {
//Takes default cost/hopcount as 1 if no constraints specified
- return 1.0;
+ return ScalarWeight.toWeight(1.0);
}
Iterator<Constraint> it = constraints.iterator();
@@ -1003,7 +1014,7 @@
cost = constraint.cost(edge.link(), null);
}
}
- return cost;
+ return ScalarWeight.toWeight(cost);
}
}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
index bdd593c..fd13454 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
@@ -29,6 +29,8 @@
import org.onlab.graph.DijkstraGraphSearch;
import org.onlab.graph.Graph;
import org.onlab.graph.GraphPathSearch;
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
import org.onlab.packet.ChassisId;
import org.onlab.util.Bandwidth;
import org.onosproject.net.AnnotationKeys;
@@ -53,7 +55,7 @@
import org.onosproject.net.provider.ProviderId;
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.TopologyEdge;
import org.onosproject.net.topology.TopologyVertex;
import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
@@ -82,7 +84,6 @@
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.Link.State.ACTIVE;
import static org.onosproject.net.Link.Type.DIRECT;
-import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.COST;
import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.TE_COST;
@@ -168,7 +169,7 @@
* @param constraints path constraints
* @return edge-weight function
*/
- private LinkWeight weight(List<Constraint> constraints) {
+ private LinkWeigher weight(List<Constraint> constraints) {
return new MockTeConstraintBasedLinkWeight(constraints);
}
@@ -180,7 +181,7 @@
new DefaultTopologyEdge(D3, D4, link4)));
GraphPathSearch.Result<TopologyVertex, TopologyEdge> result =
- graphSearch().search(graph, D1, D4, adapt(weight(constraints)), ALL_PATHS);
+ graphSearch().search(graph, D1, D4, weight(constraints), ALL_PATHS);
ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
builder.add(networkPath(path));
@@ -211,7 +212,7 @@
}
}
- private class MockTeConstraintBasedLinkWeight implements LinkWeight {
+ private class MockTeConstraintBasedLinkWeight implements LinkWeigher {
private final List<Constraint> constraints;
@@ -230,10 +231,20 @@
}
@Override
- public double weight(TopologyEdge edge) {
+ public Weight getInitialWeight() {
+ return ScalarWeight.toWeight(0.0);
+ }
+
+ @Override
+ public Weight getNonViableWeight() {
+ return ScalarWeight.NON_VIABLE_WEIGHT;
+ }
+
+ @Override
+ public Weight weight(TopologyEdge edge) {
if (!constraints.iterator().hasNext()) {
//Takes default cost/hopcount as 1 if no constraints specified
- return 1.0;
+ return ScalarWeight.toWeight(1.0);
}
Iterator<Constraint> it = constraints.iterator();
@@ -259,7 +270,7 @@
cost = constraint.cost(edge.link(), null);
}
}
- return cost;
+ return ScalarWeight.toWeight(cost);
}
}
@@ -1274,7 +1285,7 @@
new DefaultTopologyEdge(D4, D5, link5)));
GraphPathSearch.Result<TopologyVertex, TopologyEdge> result =
- graphSearch().search(graph, D1, D5, adapt(weight(constraints)), ALL_PATHS);
+ graphSearch().search(graph, D1, D5, weight(constraints), ALL_PATHS);
ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
builder.add(networkPath(path));
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
index 432ffb6..9cf7069 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
@@ -56,7 +56,7 @@
import org.onosproject.net.provider.ProviderId;
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.Topology;
import org.onosproject.net.topology.TopologyEdge;
@@ -92,7 +92,6 @@
import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
import static org.onosproject.net.MastershipRole.MASTER;
-import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING;
@@ -1476,7 +1475,7 @@
}
@Override
- public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
+ public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeigher weight) {
DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
Set<TopologyVertex> vertices = graph.getVertexes();
@@ -1486,7 +1485,7 @@
}
GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = PathComputationTest.graphSearch()
- .search(graph, srcV, dstV, adapt(weight), ALL_PATHS);
+ .search(graph, srcV, dstV, weight, ALL_PATHS);
ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
builder.add(PathComputationTest.networkPath(path));
@@ -1521,7 +1520,7 @@
private class MockPathService extends PathServiceAdapter {
Set<Path> computedPaths;
@Override
- public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
+ public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weight) {
// If either edge is null, bail with no paths.
if (src == null || dst == null) {
return ImmutableSet.of();
diff --git a/core/api/src/main/java/org/onosproject/net/topology/AbstractPathService.java b/core/api/src/main/java/org/onosproject/net/topology/AbstractPathService.java
index 7c831e7..cf9a531 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/AbstractPathService.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/AbstractPathService.java
@@ -42,7 +42,6 @@
import java.util.stream.Stream;
import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
/**
* Helper class for path service.
@@ -60,18 +59,13 @@
private static final PortNumber P0 = PortNumber.portNumber(0);
protected static final LinkWeigher DEFAULT_WEIGHER =
- adapt(new HopCountLinkWeight());
+ new HopCountLinkWeigher();
protected TopologyService topologyService;
protected HostService hostService;
@Override
- public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
- return getPaths(src, dst, adapt(weight));
- }
-
- @Override
public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
checkNotNull(src, ELEMENT_ID_NULL);
checkNotNull(dst, ELEMENT_ID_NULL);
@@ -140,11 +134,6 @@
}
@Override
- public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
- return getDisjointPaths(src, dst, adapt(weight));
- }
-
- @Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
checkNotNull(src, ELEMENT_ID_NULL);
checkNotNull(dst, ELEMENT_ID_NULL);
@@ -179,12 +168,6 @@
}
@Override
- public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
- Map<Link, Object> riskProfile) {
- return getDisjointPaths(src, dst, adapt(weight), riskProfile);
- }
-
- @Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
LinkWeigher weigher, Map<Link, Object> riskProfile) {
checkNotNull(src, ELEMENT_ID_NULL);
diff --git a/core/api/src/main/java/org/onosproject/net/topology/AdapterLinkWeigher.java b/core/api/src/main/java/org/onosproject/net/topology/AdapterLinkWeigher.java
deleted file mode 100644
index 70260e3..0000000
--- a/core/api/src/main/java/org/onosproject/net/topology/AdapterLinkWeigher.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.net.topology;
-
-import org.onlab.graph.DefaultEdgeWeigher;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.graph.Weight;
-
-/**
- * Wrapper which transforms double-based link weigher to {@link Weight}-based
- * link weigher.
- */
-public final class AdapterLinkWeigher
- extends DefaultEdgeWeigher<TopologyVertex, TopologyEdge>
- implements LinkWeigher {
-
- private final LinkWeight doubleWeigher;
-
- private AdapterLinkWeigher(LinkWeight doubleWeigher) {
- this.doubleWeigher = doubleWeigher;
- }
-
- @Override
- public Weight weight(TopologyEdge edge) {
- return new ScalarWeight(doubleWeigher.weight(edge));
- }
-
- /**
- * Transforms double-based link weigher to {@link Weight}-based weigher.
- *
- * @param lw double-based weigher
- * @return {@link Weight}-based weigher
- */
- public static LinkWeigher adapt(LinkWeight lw) {
- return lw == null ? null : new AdapterLinkWeigher(lw);
- }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/topology/GeoDistanceLinkWeight.java b/core/api/src/main/java/org/onosproject/net/topology/GeoDistanceLinkWeight.java
index f30fc80..9d22b84 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/GeoDistanceLinkWeight.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/GeoDistanceLinkWeight.java
@@ -16,6 +16,8 @@
package org.onosproject.net.topology;
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
import org.onlab.util.GeoLocation;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.Annotations;
@@ -29,7 +31,7 @@
* Link weight for measuring link cost using the geo distance between link
* vertices as determined by the element longitude/latitude annotation.
*/
-public class GeoDistanceLinkWeight implements LinkWeight {
+public class GeoDistanceLinkWeight implements LinkWeigher {
private static final double MAX_KM = 40_075 / 2.0;
@@ -45,10 +47,20 @@
}
@Override
- public double weight(TopologyEdge edge) {
+ public Weight getInitialWeight() {
+ return ScalarWeight.toWeight(0.0);
+ }
+
+ @Override
+ public Weight getNonViableWeight() {
+ return ScalarWeight.NON_VIABLE_WEIGHT;
+ }
+
+ @Override
+ public Weight weight(TopologyEdge edge) {
GeoLocation src = getLocation(edge.link().src().deviceId());
GeoLocation dst = getLocation(edge.link().dst().deviceId());
- return src != null && dst != null ? src.kilometersTo(dst) : MAX_KM;
+ return ScalarWeight.toWeight(src != null && dst != null ? src.kilometersTo(dst) : MAX_KM);
}
private GeoLocation getLocation(DeviceId deviceId) {
diff --git a/core/api/src/main/java/org/onosproject/net/topology/HopCountLinkWeight.java b/core/api/src/main/java/org/onosproject/net/topology/HopCountLinkWeight.java
deleted file mode 100644
index 885cd67..0000000
--- a/core/api/src/main/java/org/onosproject/net/topology/HopCountLinkWeight.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.topology;
-
-import static org.onosproject.net.Link.State.ACTIVE;
-import static org.onosproject.net.Link.Type.INDIRECT;
-
-/**
- * Link weight for measuring link cost as hop count with indirect links
- * being as expensive as traversing the entire graph to assume the worst.
- */
-public class HopCountLinkWeight implements LinkWeight {
- private final int indirectLinkCost;
-
- /**
- * Creates a new hop-count weight.
- */
- public HopCountLinkWeight() {
- this.indirectLinkCost = Short.MAX_VALUE;
- }
-
- /**
- * Creates a new hop-count weight with the specified cost of indirect links.
- *
- * @param indirectLinkCost indirect link cost
- */
- public HopCountLinkWeight(int indirectLinkCost) {
- this.indirectLinkCost = indirectLinkCost;
- }
-
- @Override
- public double weight(TopologyEdge edge) {
- // To force preference to use direct paths first, make indirect
- // links as expensive as the linear vertex traversal.
- return edge.link().state() ==
- ACTIVE ? (edge.link().type() ==
- INDIRECT ? indirectLinkCost : 1) : -1;
- }
-}
-
diff --git a/core/api/src/main/java/org/onosproject/net/topology/LinkWeight.java b/core/api/src/main/java/org/onosproject/net/topology/LinkWeight.java
deleted file mode 100644
index 944c843..0000000
--- a/core/api/src/main/java/org/onosproject/net/topology/LinkWeight.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2014-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.topology;
-
-/**
- * Entity capable of determining cost or weight of a specified topology
- * graph edge.
- * @deprecated in Junco (1.9.0), use {@link LinkWeigher} instead
- */
-@Deprecated
-public interface LinkWeight {
-
- /**
- * Returns the weight of the given edge.
- *
- * @param edge edge to be weighed
- * @return edge weight
- */
- double weight(TopologyEdge edge);
-}
diff --git a/core/api/src/main/java/org/onosproject/net/topology/MetricLinkWeight.java b/core/api/src/main/java/org/onosproject/net/topology/MetricLinkWeight.java
index e24ea4a..e87f660 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/MetricLinkWeight.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/MetricLinkWeight.java
@@ -16,20 +16,32 @@
package org.onosproject.net.topology;
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
import org.onosproject.net.AnnotationKeys;
/**
* Link weight for measuring link cost using the link metric annotation.
*/
-public class MetricLinkWeight implements LinkWeight {
+public class MetricLinkWeight implements LinkWeigher {
@Override
- public double weight(TopologyEdge edge) {
+ public Weight getInitialWeight() {
+ return ScalarWeight.toWeight(0.0);
+ }
+
+ @Override
+ public Weight getNonViableWeight() {
+ return ScalarWeight.NON_VIABLE_WEIGHT;
+ }
+
+ @Override
+ public Weight weight(TopologyEdge edge) {
String v = edge.link().annotations().value(AnnotationKeys.METRIC);
try {
- return v != null ? Double.parseDouble(v) : 1;
+ return ScalarWeight.toWeight(v != null ? Double.parseDouble(v) : 1);
} catch (NumberFormatException e) {
- return 1;
+ return ScalarWeight.toWeight(1.0);
}
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/topology/PathAdminService.java b/core/api/src/main/java/org/onosproject/net/topology/PathAdminService.java
index fed0651..fb67c91 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/PathAdminService.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/PathAdminService.java
@@ -28,18 +28,6 @@
* If null is specified, the builtin default hop-count link-weight will be
* used.
*
- * @param linkWeight default link-weight function
- *
- * @deprecated in Junco (1.9.0), use setDefaultLinkWeigher() instead
- */
- @Deprecated
- void setDefaultLinkWeight(LinkWeight linkWeight);
-
- /**
- * Sets the specified link-weight function to be used as a default.
- * If null is specified, the builtin default hop-count link-weight will be
- * used.
- *
* @param linkWeigher link-weight function to be used as default
*/
void setDefaultLinkWeigher(LinkWeigher linkWeigher);
diff --git a/core/api/src/main/java/org/onosproject/net/topology/PathService.java b/core/api/src/main/java/org/onosproject/net/topology/PathService.java
index ae2de8b..73f0149 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/PathService.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/PathService.java
@@ -48,21 +48,6 @@
* destination network elements. The path is computed using the supplied
* edge-weight function.
*
- * @param src source element
- * @param dst destination element
- * @param weight edge-weight entity
- * @return set of all shortest paths between the two element
- *
- * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
- */
- @Deprecated
- Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight);
-
- /**
- * Returns the set of all shortest paths between the specified source and
- * destination network elements. The path is computed using the supplied
- * edge-weight function.
- *
* @param src source element
* @param dst destination element
* @param weigher edge-weight entity
@@ -113,22 +98,6 @@
* specified source and destination elements. The path is computed using
* the supplied edge-weight function.
*
- * @param src source device
- * @param dst destination device
- * @param weight edge-weight entity
- * @return set of all shortest paths between the two devices
- *
- * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
- */
- @Deprecated
- Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
- LinkWeight weight);
-
- /**
- * Returns the set of all disjoint shortest path pairs between the
- * specified source and destination elements. The path is computed using
- * the supplied edge-weight function.
- *
* @param src source device
* @param dst destination device
* @param weigher edge-weight entity
@@ -159,25 +128,6 @@
*
* @param src source device
* @param dst destination device
- * @param weight edge-weight entity
- * @param riskProfile map of edges to risk profiles
- * @return set of all shortest paths between the two devices
- *
- * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
- */
- @Deprecated
- Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
- LinkWeight weight,
- Map<Link, Object> riskProfile);
-
- /**
- * Returns the set of all disjoint shortest path pairs between the
- * specified source and destination elements and taking into consideration
- * the provided risk profile. The path is computed using the supplied
- * edge-weight function.
- *
- * @param src source device
- * @param dst destination device
* @param weigher edge-weight entity
* @param riskProfile map of edges to risk profiles
* @return set of all shortest paths between the two devices
diff --git a/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java b/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java
index 6d95a97..ee70ed7 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java
@@ -111,22 +111,6 @@
* @param topology topology descriptor
* @param src source device
* @param dst destination device
- * @param weight edge-weight entity
- * @return set of all shortest paths between the two devices
- *
- * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
- */
- @Deprecated
- Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
- LinkWeight weight);
-
- /**
- * Returns the set of all shortest paths, computed using the supplied
- * edge-weight entity, between the specified source and destination devices.
- *
- * @param topology topology descriptor
- * @param src source device
- * @param dst destination device
* @param weigher edge-weight entity
* @return set of all shortest paths between the two devices
*/
@@ -204,22 +188,6 @@
* @param topology topology descriptor
* @param src source device
* @param dst destination device
- * @param weight edge-weight entity
- * @return set of all shortest paths between the two devices
- *
- * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
- */
- @Deprecated
- Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
- LinkWeight weight);
-
- /**
- * Returns the set of all disjoint shortest path pairs, computed using the supplied
- * edge-weight entity, between the specified source and destination devices.
- *
- * @param topology topology descriptor
- * @param src source device
- * @param dst destination device
* @param weigher edge-weight entity
* @return set of all shortest paths between the two devices
*/
@@ -246,23 +214,6 @@
* @param topology topology descriptor
* @param src source device
* @param dst destination device
- * @param weight edge-weight entity
- * @param riskProfile map of edges to risk profiles
- * @return set of all shortest paths between the two devices
- *
- * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
- */
- @Deprecated
- Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
- LinkWeight weight, Map<Link, Object> riskProfile);
-
- /**
- * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
- * between the specified source and destination devices.
- *
- * @param topology topology descriptor
- * @param src source device
- * @param dst destination device
* @param weigher edge-weight entity
* @param riskProfile map of edges to risk profiles
* @return set of all shortest paths between the two devices
diff --git a/core/api/src/main/java/org/onosproject/net/topology/TopologyStore.java b/core/api/src/main/java/org/onosproject/net/topology/TopologyStore.java
index 99838c6..17957e1 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/TopologyStore.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/TopologyStore.java
@@ -109,21 +109,6 @@
* @param topology topology descriptor
* @param src source device
* @param dst destination device
- * @param weight link weight function
- * @return set of shortest paths
- *
- * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
- */
- @Deprecated
- Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
- LinkWeight weight);
-
- /**
- * Computes and returns the set of shortest paths between src and dest.
- *
- * @param topology topology descriptor
- * @param src source device
- * @param dst destination device
* @param weigher link weight function
* @return set of shortest paths
*/
@@ -176,22 +161,6 @@
* @param topology topology descriptor
* @param src source device
* @param dst destination device
- * @param weight link weight function
- * @return set of shortest paths
- *
- * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
- */
- @Deprecated
- Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
- LinkWeight weight);
-
- /**
- * Computes and returns the set of disjoint shortest path pairs
- * between src and dst.
- *
- * @param topology topology descriptor
- * @param src source device
- * @param dst destination device
* @param weigher link weight function
* @return set of shortest paths
*/
@@ -216,24 +185,6 @@
* @param topology topology descriptor
* @param src source device
* @param dst destination device
- * @param weight link weight function
- * @param riskProfile map of edges to objects. Edges that map to the same object will
- * be treated as if they were in the same risk group.
- * @return set of shortest paths
- *
- * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
- */
- @Deprecated
- Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
- LinkWeight weight, Map<Link, Object> riskProfile);
-
- /**
- * Computes and returns the set of SRLG disjoint shortest path pairs between source
- * and dst, given a mapping of edges to SRLG risk groups.
- *
- * @param topology topology descriptor
- * @param src source device
- * @param dst destination device
* @param weigher link weight function
* @param riskProfile map of edges to objects. Edges that map to the same object will
* be treated as if they were in the same risk group.
diff --git a/core/api/src/test/java/org/onosproject/net/topology/LinkWeigherAdapter.java b/core/api/src/test/java/org/onosproject/net/topology/LinkWeigherAdapter.java
new file mode 100644
index 0000000..bf3f934
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/topology/LinkWeigherAdapter.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.topology;
+
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
+
+public class LinkWeigherAdapter implements LinkWeigher {
+ final double weight;
+
+ public LinkWeigherAdapter(Double weight) {
+ this.weight = weight;
+ }
+ @Override
+ public Weight weight(TopologyEdge edge) {
+ return ScalarWeight.toWeight(weight);
+ }
+
+ @Override
+ public Weight getInitialWeight() {
+ return ScalarWeight.toWeight(0.0);
+ }
+
+ @Override
+ public Weight getNonViableWeight() {
+ return ScalarWeight.toWeight(0.0);
+ }
+}
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 1e18030..86a9405 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
@@ -33,11 +33,6 @@
}
@Override
- public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
- return null;
- }
-
- @Override
public Set<Path> getPaths(ElementId src, ElementId dst,
LinkWeigher weigher) {
return null;
@@ -50,12 +45,6 @@
@Override
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;
}
@@ -68,13 +57,6 @@
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
- LinkWeight weight,
- 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 a3266fb..b75dbb0 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
@@ -72,12 +72,6 @@
@Override
public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
- LinkWeight weight) {
- return null;
- }
-
- @Override
- public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
LinkWeigher weigher) {
return null;
}
@@ -111,13 +105,6 @@
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
DeviceId dst,
- LinkWeight weight) {
- return null;
- }
-
- @Override
- public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
- DeviceId dst,
LinkWeigher weigher) {
return null;
}
@@ -131,13 +118,6 @@
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
- DeviceId dst, LinkWeight weight,
- Map<Link, Object> riskProfile) {
- return null;
- }
-
- @Override
- public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
DeviceId dst,
LinkWeigher weigher,
Map<Link, Object> riskProfile) {
diff --git a/core/common/src/main/java/org/onosproject/common/DefaultTopology.java b/core/common/src/main/java/org/onosproject/common/DefaultTopology.java
index 4b266a8..ecbb573 100644
--- a/core/common/src/main/java/org/onosproject/common/DefaultTopology.java
+++ b/core/common/src/main/java/org/onosproject/common/DefaultTopology.java
@@ -49,7 +49,7 @@
import org.onosproject.net.topology.DefaultTopologyCluster;
import org.onosproject.net.topology.DefaultTopologyVertex;
import org.onosproject.net.topology.GraphDescription;
-import org.onosproject.net.topology.HopCountLinkWeight;
+import org.onosproject.net.topology.HopCountLinkWeigher;
import org.onosproject.net.topology.LinkWeigher;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyCluster;
@@ -73,7 +73,6 @@
import static org.onosproject.core.CoreService.CORE_PROVIDER_ID;
import static org.onosproject.net.Link.State.INACTIVE;
import static org.onosproject.net.Link.Type.INDIRECT;
-import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
/**
* Default implementation of the topology descriptor. This carries the backing
@@ -160,7 +159,7 @@
this.clusterIndexes = Suppliers.memoize(this::buildIndexes);
- this.hopCountWeigher = adapt(new HopCountLinkWeight(graph.getVertexes().size()));
+ this.hopCountWeigher = new HopCountLinkWeigher(graph.getVertexes().size());
this.broadcastSets = Suppliers.memoize(this::buildBroadcastSets);
this.infrastructurePoints = Suppliers.memoize(this::findInfrastructurePoints);
this.computeCost = Math.max(0, System.nanoTime() - time);
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleTopologyStore.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleTopologyStore.java
index 8030869..cb34df1 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleTopologyStore.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleTopologyStore.java
@@ -30,7 +30,6 @@
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;
import org.onosproject.net.topology.TopologyEvent;
@@ -44,7 +43,6 @@
import java.util.Map;
import java.util.Set;
-import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -112,12 +110,6 @@
}
@Override
- 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) {
return defaultTopology(topology).getPaths(src, dst, weigher);
@@ -129,12 +121,6 @@
}
@Override
- public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
- LinkWeight weight) {
- return getDisjointPaths(topology, src, dst, adapt(weight));
- }
-
- @Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
DeviceId dst, LinkWeigher weigher) {
return defaultTopology(topology).getDisjointPaths(src, dst, weigher);
@@ -147,12 +133,6 @@
}
@Override
- 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,
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 ec73c3b..cc9cc53 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
@@ -27,7 +27,6 @@
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;
import org.onosproject.net.topology.AbstractPathService;
@@ -80,12 +79,6 @@
}
@Override
- public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
- checkPermission(TOPOLOGY_READ);
- 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);
@@ -105,12 +98,6 @@
}
@Override
- public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
- checkPermission(TOPOLOGY_READ);
- return super.getDisjointPaths(src, dst, weight);
- }
-
- @Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
checkPermission(TOPOLOGY_READ);
return super.getDisjointPaths(src, dst, weigher);
@@ -124,13 +111,6 @@
}
@Override
- public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
- Map<Link, Object> riskProfile) {
- checkPermission(TOPOLOGY_READ);
- 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);
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 522c23c..0d15645 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
@@ -21,18 +21,17 @@
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
-import org.onosproject.net.DisjointPath;
-import org.onosproject.net.provider.AbstractListenerProviderRegistry;
import org.onosproject.event.Event;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
+import org.onosproject.net.DisjointPath;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
+import org.onosproject.net.provider.AbstractListenerProviderRegistry;
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;
import org.onosproject.net.topology.TopologyEvent;
@@ -47,15 +46,14 @@
import org.slf4j.Logger;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
-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.onosproject.security.AppPermission.Type.TOPOLOGY_READ;
import static org.slf4j.LoggerFactory.getLogger;
-import static org.onosproject.security.AppPermission.Type.*;
/**
@@ -158,12 +156,6 @@
@Override
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);
@@ -214,13 +206,6 @@
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
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);
@@ -243,13 +228,6 @@
@Override
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) {
diff --git a/core/net/src/test/java/org/onosproject/net/topology/impl/TopologyManagerTest.java b/core/net/src/test/java/org/onosproject/net/topology/impl/TopologyManagerTest.java
index b350144..3516058 100644
--- a/core/net/src/test/java/org/onosproject/net/topology/impl/TopologyManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/topology/impl/TopologyManagerTest.java
@@ -28,7 +28,8 @@
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.topology.DefaultGraphDescription;
import org.onosproject.net.topology.GraphDescription;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
+import org.onosproject.net.topology.LinkWeigherAdapter;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyCluster;
import org.onosproject.net.topology.TopologyEvent;
@@ -174,7 +175,7 @@
public void onDemandPath() {
submitTopologyGraph();
Topology topology = service.currentTopology();
- LinkWeight weight = edge -> 3.3;
+ LinkWeigher weight = new LinkWeigherAdapter(3.3);
Set<Path> paths = service.getPaths(topology, did("a"), did("c"), weight);
assertEquals("wrong path count", 2, paths.size());
diff --git a/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java b/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java
index c59d30d..b6e6d04 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java
@@ -41,7 +41,6 @@
import org.onosproject.net.topology.GeoDistanceLinkWeight;
import org.onosproject.net.topology.GraphDescription;
import org.onosproject.net.topology.LinkWeigher;
-import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.MetricLinkWeight;
import org.onosproject.net.topology.PathAdminService;
import org.onosproject.net.topology.Topology;
@@ -74,7 +73,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.isNullOrEmpty;
-import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
import static org.onosproject.net.topology.TopologyEvent.Type.TOPOLOGY_CHANGED;
import static org.slf4j.LoggerFactory.getLogger;
@@ -165,11 +163,11 @@
if (newLinkWeightFunction != null &&
!Objects.equals(newLinkWeightFunction, linkWeightFunction)) {
linkWeightFunction = newLinkWeightFunction;
- LinkWeight weight = linkWeightFunction.equals(LINK_METRIC) ?
+ LinkWeigher weight = linkWeightFunction.equals(LINK_METRIC) ?
new MetricLinkWeight() :
linkWeightFunction.equals(GEO_DISTANCE) ?
new GeoDistanceLinkWeight(deviceService) : null;
- setDefaultLinkWeight(weight);
+ setDefaultLinkWeigher(weight);
}
log.info(FORMAT, linkWeightFunction);
}
@@ -215,11 +213,6 @@
return defaultTopology(topology).getPaths(src, dst);
}
- @Override
- 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,
@@ -249,12 +242,6 @@
}
@Override
- public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
- LinkWeight weight) {
- return getDisjointPaths(topology, src, dst, adapt(weight));
- }
-
- @Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
DeviceId dst, LinkWeigher weigher) {
return defaultTopology(topology).getDisjointPaths(src, dst, weigher);
@@ -267,12 +254,6 @@
}
@Override
- 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) {
@@ -352,11 +333,6 @@
}
@Override
- public void setDefaultLinkWeight(LinkWeight linkWeight) {
- DefaultTopology.setDefaultLinkWeigher(adapt(linkWeight));
- }
-
- @Override
public void setDefaultLinkWeigher(LinkWeigher linkWeigher) {
DefaultTopology.setDefaultLinkWeigher(linkWeigher);
}
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManager.java
index a9ee2ab..f21493f 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManager.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManager.java
@@ -29,7 +29,6 @@
import org.onosproject.net.topology.ClusterId;
import org.onosproject.net.topology.DefaultGraphDescription;
import org.onosproject.net.topology.LinkWeigher;
-import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyCluster;
import org.onosproject.net.topology.TopologyEvent;
@@ -44,7 +43,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.incubator.net.virtual.DefaultVirtualLink.PID;
-import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
/**
* Topology service implementation built on the virtual network service.
@@ -139,12 +137,6 @@
@Override
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) {
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
@@ -162,12 +154,6 @@
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
- DeviceId dst, LinkWeight weight) {
- return getDisjointPaths(topology, src, dst, adapt(weight));
- }
-
- @Override
- public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
DeviceId dst,
LinkWeigher weigher) {
checkNotNull(src, DEVICE_ID_NULL);
@@ -187,13 +173,6 @@
@Override
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) {
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathManagerTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathManagerTest.java
index adfca6d..cf49106 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathManagerTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathManagerTest.java
@@ -37,7 +37,8 @@
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.TestDeviceParams;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
+import org.onosproject.net.topology.LinkWeigherAdapter;
import org.onosproject.net.topology.PathService;
import org.onosproject.store.service.TestStorageService;
@@ -161,7 +162,7 @@
Set<Path> paths = pathService.getPaths(DID1, DID3);
validatePaths(paths, 1, 1, DID1, DID3, 1.0);
- LinkWeight linkWeight = edge -> 2.0;
+ LinkWeigher linkWeight = new LinkWeigherAdapter(2.0);
paths = pathService.getPaths(DID1, DID3, linkWeight);
validatePaths(paths, 1, 1, DID1, DID3, 2.0);
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java
index 6218a15..ed51f94 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java
@@ -42,7 +42,7 @@
import org.onosproject.net.PortNumber;
import org.onosproject.net.TestDeviceParams;
import org.onosproject.net.topology.LinkWeigher;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigherAdapter;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyCluster;
import org.onosproject.net.topology.TopologyService;
@@ -414,7 +414,7 @@
assertEquals("The paths size did not match.", 1, paths.size());
// test the getPaths() by weight method.
- LinkWeight weight = edge -> 1.0;
+ LinkWeigher weight = new LinkWeigherAdapter(1.0);
Set<Path> paths1 = topologyService.getPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), weight);
assertNotNull("The paths should not be null.", paths1);
assertEquals("The paths size did not match.", 1, paths1.size());
@@ -472,7 +472,7 @@
// test the getDisjointPaths() method using a null weight.
Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(),
- dstVirtualDevice.id(), (LinkWeight) null);
+ dstVirtualDevice.id(), (LinkWeigher) null);
}
/**
@@ -513,7 +513,7 @@
assertEquals("The paths size did not match.", 1, paths.size());
// test the getDisjointPaths() method using a weight.
- LinkWeight weight = edge -> 1.0;
+ LinkWeigher weight = new LinkWeigherAdapter(1.0);
Set<DisjointPath> paths1 = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(),
dstVirtualDevice.id(), weight);
assertNotNull("The paths should not be null.", paths1);
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/provider/DefaultVirtualFlowRuleProviderTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/provider/DefaultVirtualFlowRuleProviderTest.java
index 72698ae..c157a54 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/provider/DefaultVirtualFlowRuleProviderTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/provider/DefaultVirtualFlowRuleProviderTest.java
@@ -62,7 +62,6 @@
import org.onosproject.net.flow.instructions.L2ModificationInstruction;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.topology.LinkWeigher;
-import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyServiceAdapter;
@@ -343,14 +342,6 @@
}
@Override
- public Set<Path> getPaths(Topology topology, DeviceId src,
- DeviceId dst, LinkWeight weight) {
- DefaultPath path = new DefaultPath(PID, ImmutableList.of(LINK1),
- oneHundred, ANNOTATIONS);
- return ImmutableSet.of(path);
- }
-
- @Override
public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
LinkWeigher weigher) {
DefaultPath path = new DefaultPath(PID, ImmutableList.of(LINK1),