use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method getEdgeId.
/**
* Determine the Source Edge Key from the link descriptor.
* There is several case: IPv4, IPv6 address or Unnumbered Interface.
*
* @param linkCase The Link part of the Linkstate route
*
* @return Unique key
*/
private static Uint64 getEdgeId(final LinkCase linkCase) {
Uint64 key = Uint64.ZERO;
final LinkDescriptors linkDescriptors = linkCase.getLinkDescriptors();
if (linkDescriptors.getIpv4InterfaceAddress() != null) {
key = ipv4ToKey(linkDescriptors.getIpv4InterfaceAddress());
}
if (linkDescriptors.getIpv6InterfaceAddress() != null) {
key = ipv6ToKey(linkDescriptors.getIpv6InterfaceAddress());
}
if (linkDescriptors.getLinkLocalIdentifier() != null) {
key = linkDescriptors.getLinkLocalIdentifier().toUint64();
}
return key;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge in project bgpcep by opendaylight.
the class ConnectedGraphImpl method addEdge.
@Override
public ConnectedEdge addEdge(final Edge edge) {
checkArgument(edge != null, "Provided Edge is a null object");
ConnectedEdgeImpl cedge = updateConnectedEdge(edge.getEdgeId().longValue());
Edge old = cedge.getEdge();
if (old == null) {
ConnectedVertexImpl source = null;
ConnectedVertexImpl destination = null;
if (edge.getLocalVertexId() != null) {
source = updateConnectedVertex(edge.getLocalVertexId().longValue());
}
if (edge.getRemoteVertexId() != null) {
destination = updateConnectedVertex(edge.getRemoteVertexId().longValue());
}
connectVertices(source, destination, cedge);
}
this.connectedGraphServer.addEdge(this.graph, edge, old);
cedge.setEdge(edge);
return cedge;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge in project bgpcep by opendaylight.
the class ShortestPathFirst method computeP2pPath.
@Override
public ConstrainedPath computeP2pPath(final VertexKey src, final VertexKey dst, final PathConstraints cts) {
ConstrainedPathBuilder cpathBuilder;
List<ConnectedEdge> edges;
CspfPath currentPath;
int currentCost = Integer.MAX_VALUE;
LOG.info("Start SPF Path Computation from {} to {} with constraints {}", src, dst, cts);
/* Initialize algorithm */
this.constraints = cts;
cpathBuilder = initializePathComputation(src, dst);
if (cpathBuilder.getStatus() == ComputationStatus.Failed) {
LOG.warn("Initial configurations are not met. Abort!");
return cpathBuilder.build();
}
visitedVertices.clear();
while (priorityQueue.size() != 0) {
currentPath = priorityQueue.poll();
visitedVertices.put(currentPath.getVertexKey(), currentPath);
LOG.debug("Process path to Vertex {} from Priority Queue", currentPath.getVertex());
edges = currentPath.getVertex().getOutputConnectedEdges();
for (ConnectedEdge edge : edges) {
/* Check that Edge point to a valid Vertex and is suitable for the Constraint Address Family */
if (pruneEdge(edge, currentPath)) {
LOG.trace(" Prune Edge {}", edge);
continue;
}
if (relax(edge, currentPath) && pathDestination.getCost() < currentCost) {
currentCost = pathDestination.getCost();
cpathBuilder.setPathDescription(getPathDescription(pathDestination.getPath())).setMetric(Uint32.valueOf(pathDestination.getCost())).setStatus(ComputationStatus.Active);
LOG.debug(" Found a valid path up to destination {}", cpathBuilder.getPathDescription());
}
}
}
/* The priority queue is empty => all the possible (vertex, path) elements have been explored
* The "ConstrainedPathBuilder" object contains the optimal path if it exists
* Otherwise an empty path with status failed is returned
*/
if (cpathBuilder.getStatus() == ComputationStatus.InProgress || cpathBuilder.getPathDescription().size() == 0) {
cpathBuilder.setStatus(ComputationStatus.Failed);
} else {
cpathBuilder.setStatus(ComputationStatus.Completed);
}
return cpathBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge in project bgpcep by opendaylight.
the class AbstractPathComputation method getPathDescription.
/**
* Convert List of Connected Edges into a Path Description as a List of
* IPv4, IPv6 or MPLS Label depending of the requested Address Family.
*
* @param edges
* List of Connected Edges
*
* @return Path Description
*/
protected List<PathDescription> getPathDescription(final List<ConnectedEdge> edges) {
ArrayList<PathDescription> list = new ArrayList<>();
for (ConnectedEdge edge : edges) {
PathDescription pathDesc = null;
switch(constraints.getAddressFamily()) {
case Ipv4:
pathDesc = new PathDescriptionBuilder().setIpv4(edge.getEdge().getEdgeAttributes().getRemoteAddress().getIpv4Address()).build();
break;
case Ipv6:
pathDesc = new PathDescriptionBuilder().setIpv6(edge.getEdge().getEdgeAttributes().getRemoteAddress().getIpv6Address()).build();
break;
case SrIpv4:
pathDesc = new PathDescriptionBuilder().setLocalIpv4(edge.getEdge().getEdgeAttributes().getLocalAddress().getIpv4Address()).setRemoteIpv4(edge.getEdge().getEdgeAttributes().getRemoteAddress().getIpv4Address()).setSid(edge.getEdge().getEdgeAttributes().getAdjSid()).build();
break;
case SrIpv6:
pathDesc = new PathDescriptionBuilder().setLocalIpv6(edge.getEdge().getEdgeAttributes().getLocalAddress().getIpv6Address()).setRemoteIpv6(edge.getEdge().getEdgeAttributes().getRemoteAddress().getIpv6Address()).setSid(edge.getEdge().getEdgeAttributes().getAdjSid()).build();
break;
default:
break;
}
list.add(pathDesc);
}
return list;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge in project bgpcep by opendaylight.
the class ConnectedGraphImpl method createConnectedGraph.
/**
* Transform the associated Graph in a Connected Graph. This method will automatically create associated Connected
* Vertices, from the Graph Vertices, Connected Edges, from the Graph Edges and Prefix from the Graph Prefix.
*/
private void createConnectedGraph() {
if (this.graph == null) {
return;
}
/* Add all vertices */
for (Vertex vertex : this.graph.nonnullVertex().values()) {
ConnectedVertexImpl cvertex = new ConnectedVertexImpl(vertex);
vertices.put(cvertex.getKey(), cvertex);
}
/* Add all edges */
for (Edge edge : this.graph.nonnullEdge().values()) {
ConnectedEdgeImpl cedge = new ConnectedEdgeImpl(edge);
edges.put(cedge.getKey(), cedge);
}
/* Add all prefixes */
for (Prefix prefix : this.graph.nonnullPrefix().values()) {
ConnectedVertexImpl cvertex = vertices.get(prefix.getVertexId().longValue());
if (cvertex != null) {
cvertex.addPrefix(prefix);
}
prefixes.putIfAbsent(prefix.getPrefix(), prefix);
}
}
Aggregations