2 * Copyright (c) 2013 Cisco Systems, 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.bgpcep.pcep.topology.provider;
10 import java.util.concurrent.Future;
12 import org.opendaylight.bgpcep.programming.spi.SuccessfulRpcResult;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspInput;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspOutput;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspOutputBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalOutput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalOutputBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.NetworkTopologyPcepService;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.OperationResult;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspInput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspOutput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspOutputBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspInput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspOutput;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspOutputBuilder;
27 import org.opendaylight.yangtools.yang.common.RpcResult;
29 import com.google.common.base.Function;
30 import com.google.common.base.Preconditions;
31 import com.google.common.util.concurrent.Futures;
33 final class TopologyRPCs implements NetworkTopologyPcepService {
34 private final ServerSessionManager manager;
36 TopologyRPCs(final ServerSessionManager manager) {
37 this.manager = Preconditions.checkNotNull(manager);
41 public Future<RpcResult<AddLspOutput>> addLsp(final AddLspInput input) {
42 return Futures.transform(manager.addLsp(input), new Function<OperationResult, RpcResult<AddLspOutput>>() {
44 public RpcResult<AddLspOutput> apply(final OperationResult input) {
45 return SuccessfulRpcResult.create(new AddLspOutputBuilder(input).build());
51 public Future<RpcResult<RemoveLspOutput>> removeLsp(final RemoveLspInput input) {
52 return Futures.transform(manager.removeLsp(input), new Function<OperationResult, RpcResult<RemoveLspOutput>>() {
54 public RpcResult<RemoveLspOutput> apply(final OperationResult input) {
55 return SuccessfulRpcResult.create(new RemoveLspOutputBuilder(input).build());
61 public Future<RpcResult<UpdateLspOutput>> updateLsp(final UpdateLspInput input) {
62 return Futures.transform(manager.updateLsp(input), new Function<OperationResult, RpcResult<UpdateLspOutput>>() {
64 public RpcResult<UpdateLspOutput> apply(final OperationResult input) {
65 return SuccessfulRpcResult.create(new UpdateLspOutputBuilder(input).build());
71 public Future<RpcResult<EnsureLspOperationalOutput>> ensureLspOperational(final EnsureLspOperationalInput input) {
72 return Futures.transform(manager.ensureLspOperational(input), new Function<OperationResult, RpcResult<EnsureLspOperationalOutput>>() {
74 public RpcResult<EnsureLspOperationalOutput> apply(final OperationResult input) {
75 return SuccessfulRpcResult.create(new EnsureLspOperationalOutputBuilder(input).build());