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;
12 import java.util.concurrent.ExecutionException;
14 import org.opendaylight.transportpce.pce.service.PathComputationService;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.CancelResourceReserveInput;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.CancelResourceReserveOutput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestOutput;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.TransportpcePceService;
20 import org.opendaylight.yangtools.yang.common.RpcResult;
21 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * PceService implementation.
28 public class PceServiceRPCImpl implements TransportpcePceService {
30 private static final Logger LOG = LoggerFactory.getLogger(PceServiceRPCImpl.class);
32 private final PathComputationService pathComputationService;
34 public PceServiceRPCImpl(PathComputationService pathComputationService) {
35 this.pathComputationService = pathComputationService;
39 public ListenableFuture<RpcResult<CancelResourceReserveOutput>>
40 cancelResourceReserve(CancelResourceReserveInput input) {
41 LOG.info("RPC cancelResourceReserve request received");
42 CancelResourceReserveOutput output = null;
44 output = this.pathComputationService.cancelResourceReserve(input).get();
45 } catch (InterruptedException | ExecutionException e) {
46 LOG.error("RPC cancelResourceReserve failed !", e);
48 return RpcResultBuilder.success(output).buildFuture();
52 public ListenableFuture<RpcResult<PathComputationRequestOutput>>
53 pathComputationRequest(PathComputationRequestInput input) {
54 LOG.info("RPC path computation request received");
55 PathComputationRequestOutput output = null;
57 output = this.pathComputationService.pathComputationRequest(input).get();
58 } catch (InterruptedException | ExecutionException e) {
59 LOG.error("RPC path computation request failed !", e);
61 return RpcResultBuilder.success(output).buildFuture();