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.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;
23 public class CancelResourceReserveImpl implements CancelResourceReserve {
24 private static final Logger LOG = LoggerFactory.getLogger(CancelResourceReserveImpl.class);
25 private PathComputationService pathComputationService;
27 public CancelResourceReserveImpl(final PathComputationService pathComputationService) {
28 this.pathComputationService = pathComputationService;
32 public ListenableFuture<RpcResult<CancelResourceReserveOutput>> invoke(CancelResourceReserveInput input) {
33 LOG.info("RPC cancelResourceReserve request received");
35 return RpcResultBuilder
36 .success(this.pathComputationService.cancelResourceReserve(input).get())
38 } catch (InterruptedException | ExecutionException e) {
39 LOG.error("RPC cancelResourceReserve failed !", e);
41 return RpcResultBuilder.<CancelResourceReserveOutput>failed()
42 .withError(ErrorType.RPC, "cancel-resource-reserve failed")