Search in sources :

Example 1 with GetConstrainedPathOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.GetConstrainedPathOutputBuilder 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)

Aggregations

PathComputationAlgorithm (org.opendaylight.algo.PathComputationAlgorithm)1 ConnectedGraph (org.opendaylight.graph.ConnectedGraph)1 VertexKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey)1 ConstrainedPath (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPath)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