Search in sources :

Example 6 with Edge

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;
}
Also used : LinkDescriptors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.link._case.LinkDescriptors) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 7 with Edge

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;
}
Also used : Edge(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge) ConnectedEdge(org.opendaylight.graph.ConnectedEdge)

Example 8 with Edge

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();
}
Also used : ConstrainedPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPathBuilder) ConnectedEdge(org.opendaylight.graph.ConnectedEdge)

Example 9 with Edge

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;
}
Also used : ConnectedEdge(org.opendaylight.graph.ConnectedEdge) PathDescriptionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.path.descriptions.PathDescriptionBuilder) PathDescription(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.path.descriptions.PathDescription) ArrayList(java.util.ArrayList)

Example 10 with Edge

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);
    }
}
Also used : Vertex(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex) ConnectedVertex(org.opendaylight.graph.ConnectedVertex) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Prefix(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix) Edge(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge) ConnectedEdge(org.opendaylight.graph.ConnectedEdge)

Aggregations

ConnectedEdge (org.opendaylight.graph.ConnectedEdge)6 Edge (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge)3 ConstrainedPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPathBuilder)3 ArrayList (java.util.ArrayList)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 Delay (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Delay)2 UnreservedBandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth)2 Prefix (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix)2 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)2 ConnectedVertex (org.opendaylight.graph.ConnectedVertex)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)1 SrAdjIds (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds)1 LinkDescriptors (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.link._case.LinkDescriptors)1 LinkAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes)1 IsisAdjFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.isis.adj.flags._case.IsisAdjFlags)1 OspfAdjFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.ospf.adj.flags._case.OspfAdjFlags)1 LocalLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase)1 Loss (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Loss)1