Bump upstream dependencies to Ca
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / impl / PathComputationRerouteRequestImpl.java
1 /*
2  * Copyright © 2024 Orange, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.transportpce.pce.impl;
9
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;
21
22
23 public class PathComputationRerouteRequestImpl implements PathComputationRerouteRequest {
24     private static final Logger LOG = LoggerFactory.getLogger(PathComputationRerouteRequestImpl.class);
25     private PathComputationService pathComputationService;
26
27     public PathComputationRerouteRequestImpl(final PathComputationService pathComputationService) {
28         this.pathComputationService = pathComputationService;
29     }
30
31     @Override
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);
36         try {
37             return RpcResultBuilder
38                     .success(this.pathComputationService.pathComputationRerouteRequest(input).get())
39                     .buildFuture();
40         } catch (InterruptedException | ExecutionException e) {
41             LOG.error("RPC path computation request failed !", e);
42         }
43         return RpcResultBuilder.<PathComputationRerouteRequestOutput>failed()
44                 .withError(ErrorType.RPC, "path-computation-reroute-request failed")
45                 .buildFuture();
46     }
47
48 }