本文整理汇总了Java中org.onosproject.net.DisjointPath类的典型用法代码示例。如果您正苦于以下问题:Java DisjointPath类的具体用法?Java DisjointPath怎么用?Java DisjointPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DisjointPath类属于org.onosproject.net包,在下文中一共展示了DisjointPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDisjointPaths
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
/**
* Computes on-demand the set of shortest disjoint path pairs between source and
* destination devices.
*
* @param src source device
* @param dst destination device
* @param weight link weight function
* @return set of disjoint shortest path pairs
*/
public Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst, LinkWeight weight) {
DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
Set<TopologyVertex> vertices = graph.getVertexes();
if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
// src or dst not part of the current graph
return ImmutableSet.of();
}
GraphPathSearch.Result<TopologyVertex, TopologyEdge> result =
SUURBALLE.search(graph, srcV, dstV, weight, ALL_PATHS);
ImmutableSet.Builder<DisjointPath> builder = ImmutableSet.builder();
for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
builder.add(networkDisjointPath((org.onlab.graph.DisjointPathPair<TopologyVertex, TopologyEdge>) path));
}
return builder.build();
}
示例2: disjointPaths
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
/**
* Computes on-demand the set of shortest disjoint risk groups path pairs between source and
* destination devices.
*
* @param src source device
* @param dst destination device
* @param weight edge weight object
* @param riskProfile map representing risk groups for each edge
* @return set of shortest disjoint paths
*/
private Set<DisjointPath> disjointPaths(DeviceId src, DeviceId dst, LinkWeight weight,
Map<TopologyEdge, Object> riskProfile) {
DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
Set<TopologyVertex> vertices = graph.getVertexes();
if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
// src or dst not part of the current graph
return ImmutableSet.of();
}
SrlgGraphSearch<TopologyVertex, TopologyEdge> srlg = new SrlgGraphSearch<>(riskProfile);
GraphPathSearch.Result<TopologyVertex, TopologyEdge> result =
srlg.search(graph, srcV, dstV, weight, ALL_PATHS);
ImmutableSet.Builder<DisjointPath> builder = ImmutableSet.builder();
for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
builder.add(networkDisjointPath((org.onlab.graph.DisjointPathPair<TopologyVertex, TopologyEdge>) path));
}
return builder.build();
}
示例3: testGetDisjointPaths
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
/**
* Test getDisjointPaths() methods.
*/
@Test
public void testGetDisjointPaths() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
// test the getDisjointPaths() method.
Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(),
dstVirtualDevice.id());
assertNotNull("The paths should not be null.", paths);
assertEquals("The paths size did not match.", 1, paths.size());
// test the getDisjointPaths() method using a weight.
LinkWeight weight = edge -> 1.0;
Set<DisjointPath> paths1 = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(),
dstVirtualDevice.id(), weight);
assertNotNull("The paths should not be null.", paths1);
assertEquals("The paths size did not match.", 1, paths1.size());
}
示例4: json
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
/**
* Produces a JSON array containing the specified paths.
*
* @param context context to use for looking up codecs
* @param paths collection of paths
* @return JSON array
*/
public static JsonNode json(AbstractShellCommand context,
Iterable<? extends Path> paths) {
ObjectMapper mapper = context.mapper();
ArrayNode result = mapper.createArrayNode();
for (Path path : paths) {
result.add(LinksListCommand.json(context, path)
.put("cost", path.cost())
.set("links", LinksListCommand.json(context, path.links())));
if (path instanceof DisjointPath) {
// [ (primay), (backup), ...]
DisjointPath backup = (DisjointPath) path;
result.add(LinksListCommand.json(context, backup.backup())
.put("cost", backup.cost())
.set("links", LinksListCommand.json(context, backup.links())));
}
}
return result;
}
示例5: edgeToEdgePathD
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
private DisjointPath edgeToEdgePathD(EdgeLink srcLink, EdgeLink dstLink, DisjointPath path,
LinkWeigher weigher) {
Path primary = null;
Path backup = null;
if (path != null) {
primary = path.primary();
backup = path.backup();
}
if (backup == null) {
return new DefaultDisjointPath(PID,
(DefaultPath) edgeToEdgePath(srcLink, dstLink, primary, weigher));
}
return new DefaultDisjointPath(PID,
(DefaultPath) edgeToEdgePath(srcLink, dstLink, primary, weigher),
(DefaultPath) edgeToEdgePath(srcLink, dstLink, backup, weigher));
}
示例6: getDisjointPaths
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
/**
* Computes on-demand the set of shortest disjoint path pairs between
* source and destination devices.
*
* @param src source device
* @param dst destination device
* @param weigher link weight function
* @return set of disjoint shortest path pairs
*/
public Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst,
LinkWeigher weigher) {
DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
Set<TopologyVertex> vertices = graph.getVertexes();
if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
// src or dst not part of the current graph
return ImmutableSet.of();
}
GraphPathSearch.Result<TopologyVertex, TopologyEdge> result =
SUURBALLE.search(graph, srcV, dstV, weigher, ALL_PATHS);
ImmutableSet.Builder<DisjointPath> builder = ImmutableSet.builder();
for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
DisjointPath disjointPath =
networkDisjointPath((DisjointPathPair<TopologyVertex, TopologyEdge>) path);
if (disjointPath.backup() != null) {
builder.add(disjointPath);
}
}
return builder.build();
}
示例7: buildDisjointPaths
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
private ImmutableSet.Builder<Link> buildDisjointPaths(ImmutableSet.Builder<Link> pathBuilder) {
paths.forEach(path -> {
DisjointPath dp = (DisjointPath) path;
pathBuilder.addAll(dp.primary().links());
pathBuilder.addAll(dp.backup().links());
});
return pathBuilder;
}
示例8: hilightAndSendPaths
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
private void hilightAndSendPaths() {
PathLinkMap linkMap = new PathLinkMap();
allPathLinks.forEach(linkMap::add);
Set<Link> selectedPathLinks;
// Prepare two working sets; one containing selected path links and
// the other containing all paths links.
if (currentMode.equals(Mode.DISJOINT)) {
DisjointPath dp = (DisjointPath) paths.get(pathIndex);
selectedPathLinks = paths.isEmpty() ?
ImmutableSet.of() : Sets.newHashSet(dp.primary().links());
selectedPathLinks.addAll(dp.backup().links());
} else {
selectedPathLinks = paths.isEmpty() ?
ImmutableSet.of() : ImmutableSet.copyOf(paths.get(pathIndex).links());
}
Highlights highlights = new Highlights();
if (highlightDelay > 0) {
highlights.delay(highlightDelay);
}
for (PathLink plink : linkMap.biLinks()) {
plink.computeHilight(selectedPathLinks, allPathLinks);
highlights.add(plink.highlight(null));
}
if (src != null) {
highlights = addBadge(highlights, srcType, src.toString(), SRC);
}
if (dst != null) {
highlights = addBadge(highlights, dstType, dst.toString(), DST);
}
sendMessage(TopoJson.highlightsMessage(highlights));
}
示例9: getDisjointPaths
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
checkPermission(TOPOLOGY_READ);
checkNotNull(topology, TOPOLOGY_NULL);
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
return store.getDisjointPaths(topology, src, dst);
}
示例10: getDisjointPaths
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
checkPermission(TOPOLOGY_READ);
checkNotNull(src, ELEMENT_ID_NULL);
checkNotNull(dst, ELEMENT_ID_NULL);
// Get the source and destination edge locations
EdgeLink srcEdge = getEdgeLink(src, true);
EdgeLink dstEdge = getEdgeLink(dst, false);
// If either edge is null, bail with no paths.
if (srcEdge == null || dstEdge == null) {
return ImmutableSet.of();
}
DeviceId srcDevice = srcEdge != NOT_HOST ? srcEdge.dst().deviceId() : (DeviceId) src;
DeviceId dstDevice = dstEdge != NOT_HOST ? dstEdge.src().deviceId() : (DeviceId) dst;
// If the source and destination are on the same edge device, there
// is just one path, so build it and return it.
if (srcDevice.equals(dstDevice)) {
return edgeToEdgePathsDisjoint(srcEdge, dstEdge);
}
// Otherwise get all paths between the source and destination edge
// devices.
Topology topology = topologyService.currentTopology();
Set<DisjointPath> paths = weight == null ?
topologyService.getDisjointPaths(topology, srcDevice, dstDevice) :
topologyService.getDisjointPaths(topology, srcDevice, dstDevice, weight);
return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths);
}
示例11: edgeToEdgePathsDisjoint
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
private Set<DisjointPath> edgeToEdgePathsDisjoint(EdgeLink srcLink, EdgeLink dstLink, Set<DisjointPath> paths) {
Set<DisjointPath> endToEndPaths = Sets.newHashSetWithExpectedSize(paths.size());
for (DisjointPath path : paths) {
endToEndPaths.add(edgeToEdgePathD(srcLink, dstLink, path));
}
return endToEndPaths;
}
示例12: edgeToEdgePathD
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
private DisjointPath edgeToEdgePathD(EdgeLink srcLink, EdgeLink dstLink, DisjointPath path) {
Path primary = null;
Path backup = null;
if (path != null) {
primary = path.primary();
backup = path.backup();
}
return new DefaultDisjointPath(PID, (DefaultPath) edgeToEdgePath(srcLink, dstLink, primary),
(DefaultPath) edgeToEdgePath(srcLink, dstLink, backup));
}
示例13: getDisjointPaths
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
DeviceId dst) {
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
return defaultTopology(topology).getDisjointPaths(src, dst);
}
示例14: testGetPathsOnNonEmptyVnet
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
/**
* Tests getPaths(), getDisjointPaths()
* on a non-empty virtual network.
*/
@Test
public void testGetPathsOnNonEmptyVnet() {
VirtualNetwork vnet = setupVnet();
PathService pathService = manager.get(vnet.id(), PathService.class);
// src and dest are in vnet and are connected by a virtual link
Set<Path> paths = pathService.getPaths(DID1, DID3);
validatePaths(paths, 1, 1, DID1, DID3, 1.0);
LinkWeight linkWeight = edge -> 2.0;
paths = pathService.getPaths(DID1, DID3, linkWeight);
validatePaths(paths, 1, 1, DID1, DID3, 2.0);
Set<DisjointPath> disjointPaths = pathService.getDisjointPaths(DID1, DID3);
validatePaths(disjointPaths, 1, 1, DID1, DID3, 1.0);
disjointPaths = pathService.getDisjointPaths(DID1, DID3, linkWeight);
validatePaths(disjointPaths, 1, 1, DID1, DID3, 2.0);
// src and dest are in vnet but are not connected
paths = pathService.getPaths(DID4, DID3);
assertEquals("incorrect path count", 0, paths.size());
disjointPaths = pathService.getDisjointPaths(DID4, DID3);
assertEquals("incorrect path count", 0, disjointPaths.size());
// src is in vnet, but dest is not in vnet.
DeviceId nonExistentDeviceId = DeviceId.deviceId("nonExistentDevice");
paths = pathService.getPaths(DID2, nonExistentDeviceId);
assertEquals("incorrect path count", 0, paths.size());
disjointPaths = pathService.getDisjointPaths(DID2, nonExistentDeviceId);
assertEquals("incorrect path count", 0, disjointPaths.size());
}
示例15: testGetPathsOnEmptyVnet
import org.onosproject.net.DisjointPath; //导入依赖的package包/类
/**
* Tests getPaths(), getDisjointPaths()
* on an empty virtual network.
*/
@Test
public void testGetPathsOnEmptyVnet() {
VirtualNetwork vnet = setupEmptyVnet();
PathService pathService = manager.get(vnet.id(), PathService.class);
Set<Path> paths = pathService.getPaths(DID1, DID3);
assertEquals("incorrect path count", 0, paths.size());
Set<DisjointPath> disjointPaths = pathService.getDisjointPaths(DID1, DID3);
assertEquals("incorrect path count", 0, disjointPaths.size());
}