Search in sources :

Example 6 with Vertex

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex in project bgpcep by opendaylight.

the class LinkstateGraphBuilder method getVertexId.

/**
 * Get Vertex in the Graph by the OSPF Router ID or IS-IS-System ID.
 *
 * @param routerID  The Router Identifier entry
 *
 * @return Vertex in the Connected Graph that corresponds to this Router ID. Vertex is created if not found.
 */
private static Uint64 getVertexId(final CRouterIdentifier routerID) {
    Uint64 rid = Uint64.ZERO;
    if (routerID instanceof IsisNodeCase) {
        final byte[] isoId = ((IsisNodeCase) routerID).getIsisNode().getIsoSystemId().getValue();
        final byte[] convert = { 0, 0, isoId[0], isoId[1], isoId[2], isoId[3], isoId[4], isoId[5] };
        rid = Uint64.fromLongBits(ByteBuffer.wrap(convert).getLong());
    }
    if (routerID instanceof OspfNodeCase) {
        rid = ((OspfNodeCase) routerID).getOspfNode().getOspfRouterId().toUint64();
    }
    LOG.debug("Get Vertex Identifier {}", rid);
    return rid;
}
Also used : IsisNodeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.IsisNodeCase) OspfNodeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.OspfNodeCase) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 7 with Vertex

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex 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 8 with Vertex

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex 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 9 with Vertex

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex 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 10 with Vertex

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex 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)5 ConnectedEdge (org.opendaylight.graph.ConnectedEdge)4 ConstrainedPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPathBuilder)4 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)3 Prefix (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix)3 Vertex (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex)3 SidCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCase)2 Edge (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge)2 PrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.PrefixBuilder)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 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 LinkStateAttribute (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.LinkStateAttribute)1 PrefixAttributesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.PrefixAttributesCase)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 NodeAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributes)1 PrefixAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes)1