2 * Copyright © 2024 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.pce.impl;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.concurrent.ExecutionException;
12 import org.opendaylight.transportpce.pce.service.PathComputationService;
13 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequest;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestInput;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestOutput;
16 import org.opendaylight.yangtools.yang.common.ErrorType;
17 import org.opendaylight.yangtools.yang.common.RpcResult;
18 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 public class PathComputationRerouteRequestImpl implements PathComputationRerouteRequest {
24 private static final Logger LOG = LoggerFactory.getLogger(PathComputationRerouteRequestImpl.class);
25 private PathComputationService pathComputationService;
27 public PathComputationRerouteRequestImpl(final PathComputationService pathComputationService) {
28 this.pathComputationService = pathComputationService;
32 public ListenableFuture<RpcResult<PathComputationRerouteRequestOutput>> invoke(
33 PathComputationRerouteRequestInput input) {
34 LOG.info("RPC path computation reroute request received");
35 LOG.debug("input parameters are : input = {}", input);
37 return RpcResultBuilder
38 .success(this.pathComputationService.pathComputationRerouteRequest(input).get())
40 } catch (InterruptedException | ExecutionException e) {
41 LOG.error("RPC path computation request failed !", e);
43 return RpcResultBuilder.<PathComputationRerouteRequestOutput>failed()
44 .withError(ErrorType.RPC, "path-computation-reroute-request failed")