Search in sources :

Example 1 with ConnectedVertex

use of org.opendaylight.graph.ConnectedVertex in project bgpcep by opendaylight.

the class ConnectedGraphImpl method addVertex.

@Override
public ConnectedVertex addVertex(final Vertex vertex) {
    checkArgument(vertex != null, "Provided Vertex is a null object");
    ConnectedVertexImpl cvertex = updateConnectedVertex(vertex.getVertexId().longValue());
    Vertex old = cvertex.getVertex();
    this.connectedGraphServer.addVertex(this.graph, vertex, old);
    cvertex.setVertex(vertex);
    return cvertex;
}
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)

Example 2 with ConnectedVertex

use of org.opendaylight.graph.ConnectedVertex in project bgpcep by opendaylight.

the class PathComputationImpl method getDestinationVertexKey.

private VertexKey getDestinationVertexKey(final EndpointsObj endPoints) {
    IpAddress address = null;
    if (endPoints.getAddressFamily() instanceof Ipv4Case) {
        address = new IpAddress(((Ipv4Case) endPoints.getAddressFamily()).getIpv4().getDestinationIpv4Address());
    }
    if (endPoints.getAddressFamily() instanceof Ipv6Case) {
        address = new IpAddress(((Ipv6Case) endPoints.getAddressFamily()).getIpv6().getDestinationIpv6Address());
    }
    if (address == null) {
        return null;
    }
    ConnectedVertex vertex = tedGraph.getConnectedVertex(address);
    LOG.debug("Compute path to Destination {}", vertex != null ? vertex : "Unknown");
    return vertex != null ? vertex.getVertex().key() : null;
}
Also used : Ipv6Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv6Case) ConnectedVertex(org.opendaylight.graph.ConnectedVertex) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Ipv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4Case)

Example 3 with ConnectedVertex

use of org.opendaylight.graph.ConnectedVertex in project bgpcep by opendaylight.

the class PathComputationImpl method getSourceVertexKey.

private VertexKey getSourceVertexKey(final EndpointsObj endPoints) {
    IpAddress address = null;
    if (endPoints.getAddressFamily() instanceof Ipv4Case) {
        address = new IpAddress(((Ipv4Case) endPoints.getAddressFamily()).getIpv4().getSourceIpv4Address());
    }
    if (endPoints.getAddressFamily() instanceof Ipv6Case) {
        address = new IpAddress(((Ipv6Case) endPoints.getAddressFamily()).getIpv6().getSourceIpv6Address());
    }
    if (address == null) {
        return null;
    }
    ConnectedVertex vertex = tedGraph.getConnectedVertex(address);
    LOG.debug("Compute path from Source {}", vertex != null ? vertex : "Unknown");
    return vertex != null ? vertex.getVertex().key() : null;
}
Also used : Ipv6Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv6Case) ConnectedVertex(org.opendaylight.graph.ConnectedVertex) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Ipv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4Case)

Example 4 with ConnectedVertex

use of org.opendaylight.graph.ConnectedVertex in project bgpcep by opendaylight.

the class AbstractPathComputation method initializePathComputation.

/**
 * Initialize the various parameters for Path Computation, in particular the
 * Source and Destination CspfPath.
 *
 * @param src
 *            Source Vertex Identifier in the Connected Graph
 * @param dst
 *            Destination Vertex Identifier in the Connected Graph
 *
 * @return Constrained Path Builder with status set to 'OnGoing' if
 *         initialization success, 'Failed' otherwise
 */
protected ConstrainedPathBuilder initializePathComputation(final VertexKey src, final VertexKey dst) {
    ConstrainedPathBuilder cpathBuilder = new ConstrainedPathBuilder().setStatus(ComputationStatus.InProgress);
    /* Check that source and destination vertexKey are not identical */
    if (src.equals(dst)) {
        LOG.warn("Source and Destination are equal: Abort!");
        cpathBuilder.setStatus(ComputationStatus.Failed);
        return cpathBuilder;
    }
    /*
         * Get the Connected Vertex from the Graph to initialize the source of
         * the Cspf Path
         */
    ConnectedVertex vertex = graph.getConnectedVertex(src.getVertexId().longValue());
    if (vertex == null) {
        LOG.warn("Found no source for Vertex Key {}", src);
        cpathBuilder.setStatus(ComputationStatus.Failed);
        return cpathBuilder;
    }
    LOG.debug("Create Path Source with Vertex {}", vertex);
    pathSource = new CspfPath(vertex).setCost(0).setDelay(0);
    cpathBuilder.setSource(vertex.getVertex().getVertexId());
    /*
         * Get the Connected Vertex from the Graph to initialize the destination
         * of the Cspf Path
         */
    vertex = graph.getConnectedVertex(dst.getVertexId().longValue());
    if (vertex == null) {
        LOG.warn("Found no destination for Vertex Key {}", src);
        cpathBuilder.setStatus(ComputationStatus.Failed);
        return cpathBuilder;
    }
    LOG.debug("Create Path Destination with Vertex {}", vertex);
    pathDestination = new CspfPath(vertex);
    cpathBuilder.setDestination(vertex.getVertex().getVertexId());
    /* Initialize the Priority Queue, HashMap */
    priorityQueue.clear();
    priorityQueue.add(pathSource);
    processedPath.clear();
    processedPath.put(pathSource.getVertexKey(), pathSource);
    processedPath.put(pathDestination.getVertexKey(), pathDestination);
    return cpathBuilder;
}
Also used : ConstrainedPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPathBuilder) ConnectedVertex(org.opendaylight.graph.ConnectedVertex)

Aggregations

ConnectedVertex (org.opendaylight.graph.ConnectedVertex)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 Ipv4Case (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4Case)2 Ipv6Case (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv6Case)2 Vertex (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex)1 ConstrainedPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPathBuilder)1