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.osgi.service.component.annotations.Activate;
23 import org.osgi.service.component.annotations.Component;
24 import org.osgi.service.component.annotations.Reference;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
29 * PceService implementation.
32 public class PceServiceRPCImpl implements TransportpcePceService {
34 private static final Logger LOG = LoggerFactory.getLogger(PceServiceRPCImpl.class);
36 private final PathComputationService pathComputationService;
39 public PceServiceRPCImpl(@Reference PathComputationService pathComputationService) {
40 this.pathComputationService = pathComputationService;
41 LOG.info("PceServiceRPCImpl instantiated");
45 public ListenableFuture<RpcResult<CancelResourceReserveOutput>>
46 cancelResourceReserve(CancelResourceReserveInput input) {
47 LOG.info("RPC cancelResourceReserve request received");
49 return RpcResultBuilder
51 this.pathComputationService.cancelResourceReserve(input).get())
53 } catch (InterruptedException | ExecutionException e) {
54 LOG.error("RPC cancelResourceReserve failed !", e);
55 return RpcResultBuilder.success((CancelResourceReserveOutput) null).buildFuture();
60 public ListenableFuture<RpcResult<PathComputationRequestOutput>>
61 pathComputationRequest(PathComputationRequestInput input) {
62 LOG.info("RPC path computation request received");
63 LOG.debug("input parameters are : input = {}", input);
65 return RpcResultBuilder
67 this.pathComputationService.pathComputationRequest(input).get())
69 } catch (InterruptedException | ExecutionException e) {
70 LOG.error("RPC path computation request failed !", e);
72 return RpcResultBuilder.success((PathComputationRequestOutput) null).buildFuture();
76 public ListenableFuture<RpcResult<PathComputationRerouteRequestOutput>> pathComputationRerouteRequest(
77 PathComputationRerouteRequestInput input) {
78 LOG.info("RPC path computation reroute request received");
79 LOG.debug("input parameters are : input = {}", input);
81 return RpcResultBuilder
83 this.pathComputationService.pathComputationRerouteRequest(input).get())
85 } catch (InterruptedException | ExecutionException e) {
86 LOG.error("RPC path computation request failed !", e);
87 return RpcResultBuilder.success((PathComputationRerouteRequestOutput) null).buildFuture();