Search in sources :

Example 1 with PathComputationAlgorithm

use of org.opendaylight.algo.PathComputationAlgorithm in project bgpcep by opendaylight.

the class PathComputationServer method getConstrainedPath.

@Override
public ListenableFuture<RpcResult<GetConstrainedPathOutput>> getConstrainedPath(final GetConstrainedPathInput input) {
    final GetConstrainedPathOutputBuilder output = new GetConstrainedPathOutputBuilder();
    LOG.info("Got Path Computation Service request");
    /* First, get graph */
    final ConnectedGraph cgraph = graphProvider.getConnectedGraph(input.getGraphName());
    if (cgraph == null) {
        output.setStatus(ComputationStatus.Failed);
        return RpcResultBuilder.<GetConstrainedPathOutput>failed().withError(RpcError.ErrorType.RPC, "Unknown Graph Name").buildFuture();
    }
    /* get a new Path Computation Algorithm according to Input choice */
    PathComputationAlgorithm algo = getPathComputationAlgorithm(cgraph, input.getAlgorithm());
    if (algo == null) {
        output.setStatus(ComputationStatus.Failed);
        return RpcResultBuilder.<GetConstrainedPathOutput>failed().withError(RpcError.ErrorType.RPC, "Unknown Path Computation Algorithm").buildFuture();
    }
    /*
         * Request Path Computation for given source, destination and
         * constraints
         */
    final VertexKey source = new VertexKey(input.getSource());
    final VertexKey destination = new VertexKey(input.getDestination());
    LOG.info("Call Path Computation {} algorithm for path from {} to {} with contraints {}", input.getAlgorithm().getName(), source, destination, input.getConstraints());
    final ConstrainedPath cpath = algo.computeP2pPath(source, destination, input.getConstraints());
    /* Send back the Computed Path */
    output.setPathDescription(cpath.getPathDescription()).setStatus(cpath.getStatus()).setComputedMetric(cpath.getMetric()).setComputedTeMetric(cpath.getTeMetric()).setComputedDelay(cpath.getDelay());
    return RpcResultBuilder.success(output.build()).buildFuture();
}
Also used : GetConstrainedPathOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.GetConstrainedPathOutput) ConnectedGraph(org.opendaylight.graph.ConnectedGraph) ConstrainedPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPath) GetConstrainedPathOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.GetConstrainedPathOutputBuilder) VertexKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey) PathComputationAlgorithm(org.opendaylight.algo.PathComputationAlgorithm)

Example 2 with PathComputationAlgorithm

use of org.opendaylight.algo.PathComputationAlgorithm in project bgpcep by opendaylight.

the class PathComputationImpl method computeEro.

@Override
public Ero computeEro(final EndpointsObj endpoints, final Bandwidth bandwidth, final ClassType classType, final List<Metrics> metrics, final boolean segmentRouting) {
    VertexKey source = getSourceVertexKey(endpoints);
    VertexKey destination = getDestinationVertexKey(endpoints);
    if (source == null) {
        return null;
    }
    if (destination == null) {
        return null;
    }
    /* Create new Constraints Object from the request */
    PathConstraints cts = getConstraints(endpoints, bandwidth, classType, metrics, segmentRouting);
    /* Determine Path Computation Algorithm according to parameters */
    AlgorithmType algoType;
    if (cts.getTeMetric() == null && cts.getDelay() == null && cts.getBandwidth() == null) {
        algoType = AlgorithmType.Spf;
    } else if (cts.getDelay() == null) {
        algoType = AlgorithmType.Cspf;
    } else {
        algoType = AlgorithmType.Samcra;
    }
    PathComputationAlgorithm algo = algoProvider.getPathComputationAlgorithm(tedGraph, algoType);
    if (algo == null) {
        return null;
    }
    /*
         * Request Path Computation for given source, destination and
         * constraints
         */
    final ConstrainedPath cpath = algo.computeP2pPath(source, destination, cts);
    LOG.info("Computed ERO: {}", cpath.getPathDescription());
    /* Check if we got a valid Path and return appropriate ERO */
    if (cpath.getStatus() == ComputationStatus.Completed) {
        return MessagesUtil.getEro(cpath.getPathDescription());
    } else {
        return null;
    }
}
Also used : AlgorithmType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.AlgorithmType) ConstrainedPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPath) VertexKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey) PathComputationAlgorithm(org.opendaylight.algo.PathComputationAlgorithm) PathConstraints(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.PathConstraints)

Example 3 with PathComputationAlgorithm

use of org.opendaylight.algo.PathComputationAlgorithm in project bgpcep by opendaylight.

the class PathComputationImpl method computePath.

@Override
public Message computePath(final Requests req) {
    LOG.info("Received Compute Path request");
    /* Check that Request Parameter Object is present */
    if (req == null || req.getRp() == null) {
        LOG.error("Missing Request Parameter Objects. Abort!");
        return MessagesUtil.createErrorMsg(PCEPErrors.RP_MISSING, Uint32.ZERO);
    }
    LOG.debug("Request for path computation {}", req);
    /*
         * Check that mandatory End Point Objects are present and Source /
         * Destination are know in the TED Graph
         */
    P2p input = req.getSegmentComputation().getP2p();
    if (input == null || input.getEndpointsObj() == null) {
        LOG.error("Missing End Point Objects. Abort!");
        Uint32 reqID = req.getRp().getRequestId().getValue();
        return MessagesUtil.createErrorMsg(PCEPErrors.END_POINTS_MISSING, reqID);
    }
    VertexKey source = getSourceVertexKey(input.getEndpointsObj());
    VertexKey destination = getDestinationVertexKey(input.getEndpointsObj());
    if (source == null) {
        return MessagesUtil.createNoPathMessage(req.getRp(), MessagesUtil.UNKNOWN_SOURCE);
    }
    if (destination == null) {
        return MessagesUtil.createNoPathMessage(req.getRp(), MessagesUtil.UNKNOWN_DESTINATION);
    }
    /* Create new Constraints Object from the request */
    PathConstraints cts = getConstraints(input, !PSTUtil.isDefaultPST(req.getRp().getTlvs().getPathSetupType()));
    /* Determine Path Computation Algorithm according to Input choice */
    AlgorithmType algoType;
    if (cts.getTeMetric() == null && cts.getDelay() == null) {
        algoType = AlgorithmType.Spf;
    } else if (cts.getDelay() == null) {
        algoType = AlgorithmType.Cspf;
    } else {
        algoType = AlgorithmType.Samcra;
    }
    PathComputationAlgorithm algo = algoProvider.getPathComputationAlgorithm(tedGraph, algoType);
    if (algo == null) {
        return MessagesUtil.createErrorMsg(PCEPErrors.RESOURCE_LIMIT_EXCEEDED, Uint32.ZERO);
    }
    /* Request Path Computation for given source, destination and constraints */
    LOG.debug("Call Path Computation {} algorithm for path from {} to {} with contraints {}", algoType, source, destination, cts);
    final ConstrainedPath cpath = algo.computeP2pPath(source, destination, cts);
    LOG.info("Computed path: {}", cpath.getPathDescription());
    /* Check if we got a valid Path and return appropriate message */
    if (cpath.getStatus() == ComputationStatus.Completed) {
        return MessagesUtil.createPcRepMessage(req.getRp(), req.getSegmentComputation().getP2p(), cpath);
    } else {
        return MessagesUtil.createNoPathMessage(req.getRp(), MessagesUtil.NO_PATH);
    }
}
Also used : AlgorithmType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.AlgorithmType) ConstrainedPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPath) VertexKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey) PathComputationAlgorithm(org.opendaylight.algo.PathComputationAlgorithm) PathConstraints(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.PathConstraints) Uint32(org.opendaylight.yangtools.yang.common.Uint32) P2p(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.P2p)

Aggregations

PathComputationAlgorithm (org.opendaylight.algo.PathComputationAlgorithm)3 VertexKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey)3 ConstrainedPath (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPath)3 AlgorithmType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.AlgorithmType)2 PathConstraints (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.PathConstraints)2 ConnectedGraph (org.opendaylight.graph.ConnectedGraph)1 GetConstrainedPathOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.GetConstrainedPathOutput)1 GetConstrainedPathOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.GetConstrainedPathOutputBuilder)1 P2p (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.P2p)1 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)1