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();
}
Aggregations