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.rev220808.CancelResourceReserveInput;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.CancelResourceReserveOutput;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestInput;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestInput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutput;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.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");
43 return RpcResultBuilder
45 this.pathComputationService.cancelResourceReserve(input).get())
47 } catch (InterruptedException | ExecutionException e) {
48 LOG.error("RPC cancelResourceReserve failed !", e);
49 return RpcResultBuilder.success((CancelResourceReserveOutput) null).buildFuture();
54 public ListenableFuture<RpcResult<PathComputationRequestOutput>>
55 pathComputationRequest(PathComputationRequestInput input) {
56 LOG.info("RPC path computation request received");
57 LOG.debug("input parameters are : input = {}", input);
59 return RpcResultBuilder
61 this.pathComputationService.pathComputationRequest(input).get())
63 } catch (InterruptedException | ExecutionException e) {
64 LOG.error("RPC path computation request failed !", e);
66 return RpcResultBuilder.success((PathComputationRequestOutput) null).buildFuture();
70 public ListenableFuture<RpcResult<PathComputationRerouteRequestOutput>> pathComputationRerouteRequest(
71 PathComputationRerouteRequestInput input) {
72 LOG.info("RPC path computation reroute request received");
73 LOG.debug("input parameters are : input = {}", input);
75 return RpcResultBuilder
77 this.pathComputationService.pathComputationRerouteRequest(input).get())
79 } catch (InterruptedException | ExecutionException e) {
80 LOG.error("RPC path computation request failed !", e);
81 return RpcResultBuilder.success((PathComputationRerouteRequestOutput) null).buildFuture();