2 * Copyright © 2017 AT&T, 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.rev200128.CancelResourceReserveInput;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.CancelResourceReserveOutput;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInput;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestOutput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.TransportpcePceService;
18 import org.opendaylight.yangtools.yang.common.RpcResult;
19 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * PceService implementation.
26 public class PceServiceRPCImpl implements TransportpcePceService {
28 private static final Logger LOG = LoggerFactory.getLogger(PceServiceRPCImpl.class);
30 private final PathComputationService pathComputationService;
32 public PceServiceRPCImpl(PathComputationService pathComputationService) {
33 this.pathComputationService = pathComputationService;
37 public ListenableFuture<RpcResult<CancelResourceReserveOutput>>
38 cancelResourceReserve(CancelResourceReserveInput input) {
39 LOG.info("RPC cancelResourceReserve request received");
40 CancelResourceReserveOutput output = null;
42 output = this.pathComputationService.cancelResourceReserve(input).get();
43 } catch (InterruptedException | ExecutionException e) {
44 LOG.error("RPC cancelResourceReserve failed !", e);
46 return RpcResultBuilder.success(output).buildFuture();
50 public ListenableFuture<RpcResult<PathComputationRequestOutput>>
51 pathComputationRequest(PathComputationRequestInput input) {
52 LOG.info("RPC path computation request received");
53 PathComputationRequestOutput output = null;
55 output = this.pathComputationService.pathComputationRequest(input).get();
56 } catch (InterruptedException | ExecutionException e) {
57 LOG.error("RPC path computation request failed !", e);
59 return RpcResultBuilder.success(output).buildFuture();