Bump upstream dependencies to Ca
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / impl / CancelResourceReserveImpl.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.CancelResourceReserve;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveInput;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserveOutput;
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 CancelResourceReserveImpl implements CancelResourceReserve {
24     private static final Logger LOG = LoggerFactory.getLogger(CancelResourceReserveImpl.class);
25     private PathComputationService pathComputationService;
26
27     public CancelResourceReserveImpl(final PathComputationService pathComputationService) {
28         this.pathComputationService = pathComputationService;
29     }
30
31     @Override
32     public ListenableFuture<RpcResult<CancelResourceReserveOutput>> invoke(CancelResourceReserveInput input) {
33         LOG.info("RPC cancelResourceReserve request received");
34         try {
35             return RpcResultBuilder
36                     .success(this.pathComputationService.cancelResourceReserve(input).get())
37                     .buildFuture();
38         } catch (InterruptedException | ExecutionException e) {
39             LOG.error("RPC cancelResourceReserve failed !", e);
40         }
41         return RpcResultBuilder.<CancelResourceReserveOutput>failed()
42                 .withError(ErrorType.RPC, "cancel-resource-reserve failed")
43                 .buildFuture();
44     }
45
46 }