From c5be4a6ca20e6561855d7dba923c733cd196463f Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 23 Apr 2018 18:51:39 +0200 Subject: [PATCH] Adjust to RPC method signature update Input/Output structures are always present and we need to return ListenableFuture. Change-Id: Idf91f4321be2c339a7752c177bb000ffdd2e5021 Signed-off-by: Robert Varga --- .../protocol/bgp/rib/impl/BgpPeerRpc.java | 24 ++++++++++++------- .../protocol/bgp/rib/impl/BgpPeerRpcTest.java | 8 ++++--- .../pcep/topology/provider/TopologyRPCs.java | 7 ++++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BgpPeerRpc.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BgpPeerRpc.java index 56aa39307d..5db48bf2b2 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BgpPeerRpc.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BgpPeerRpc.java @@ -15,14 +15,17 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import io.netty.channel.ChannelFuture; import java.util.Set; -import java.util.concurrent.Future; import org.opendaylight.protocol.bgp.rib.spi.BGPSession; import org.opendaylight.protocol.bgp.rib.spi.PeerRPCs; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefreshBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.BgpPeerRpcService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.ResetSessionInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.ResetSessionOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.ResetSessionOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.RouteRefreshRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.RouteRefreshRequestOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.RouteRefreshRequestOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey; import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -47,28 +50,31 @@ public class BgpPeerRpc implements BgpPeerRpcService { } @Override - public Future> resetSession(final ResetSessionInput input) { + public ListenableFuture> resetSession(final ResetSessionInput input) { final ListenableFuture f = this.peerRPCs.releaseConnection(); - return Futures.transform(JdkFutureAdapters.listenInPoolThread(f), input1 -> { + return Futures.transform(f, input1 -> { if (f.isDone()) { - return RpcResultBuilder.success().build(); + return RpcResultBuilder.success(new ResetSessionOutputBuilder().build()).build(); } - return RpcResultBuilder.failed().withError(ErrorType.RPC, FAILURE_RESET_SESSION_MSG).build(); + return RpcResultBuilder.failed().withError(ErrorType.RPC, FAILURE_RESET_SESSION_MSG) + .build(); }, MoreExecutors.directExecutor()); } @Override - public Future> routeRefreshRequest(final RouteRefreshRequestInput input) { + public ListenableFuture> routeRefreshRequest( + final RouteRefreshRequestInput input) { final ChannelFuture f = sendRRMessage(input); if (f != null) { return Futures.transform(JdkFutureAdapters.listenInPoolThread(f), input1 -> { if (f.isSuccess()) { - return RpcResultBuilder.success().build(); + return RpcResultBuilder.success(new RouteRefreshRequestOutputBuilder().build()).build(); } - return RpcResultBuilder.failed().withError(ErrorType.RPC, FAILURE_MSG).build(); + return RpcResultBuilder.failed().withError(ErrorType.RPC, FAILURE_MSG) + .build(); }, MoreExecutors.directExecutor()); } - return RpcResultBuilder.failed().withError(ErrorType.RPC, FAILURE_MSG + + return RpcResultBuilder.failed().withError(ErrorType.RPC, FAILURE_MSG + " due to unsupported address families.").buildFuture(); } diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BgpPeerRpcTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BgpPeerRpcTest.java index d91db95a22..267ea7e9b9 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BgpPeerRpcTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BgpPeerRpcTest.java @@ -24,8 +24,10 @@ import org.opendaylight.protocol.bgp.rib.spi.PeerRPCs; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.PeerRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.ResetSessionInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.ResetSessionInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.ResetSessionOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.RouteRefreshRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.RouteRefreshRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.RouteRefreshRequestOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily; @@ -64,7 +66,7 @@ public final class BgpPeerRpcTest { .setAfi(Ipv4AddressFamily.class) .setSafi(SubsequentAddressFamily.class) .setPeerRef(this.peer).build(); - final Future> result = this.rpc.routeRefreshRequest(input); + final Future> result = this.rpc.routeRefreshRequest(input); assertTrue(result.get().getErrors().isEmpty()); } @@ -74,7 +76,7 @@ public final class BgpPeerRpcTest { .setAfi(Ipv6AddressFamily.class) .setSafi(SubsequentAddressFamily.class) .setPeerRef(this.peer).build(); - final Future> result = this.rpc.routeRefreshRequest(input); + final Future> result = this.rpc.routeRefreshRequest(input); assertEquals(1, result.get().getErrors().size()); assertEquals("Failed to send Route Refresh message due to unsupported address families.", result.get().getErrors().iterator().next().getMessage()); @@ -85,7 +87,7 @@ public final class BgpPeerRpcTest { Mockito.doReturn(Futures.immediateFuture(null)).when(this.peerRpcs).releaseConnection(); final ResetSessionInput input = new ResetSessionInputBuilder() .setPeerRef(this.peer).build(); - final Future> result = this.rpc.resetSession(input); + final Future> result = this.rpc.resetSession(input); assertTrue(result.get().getErrors().isEmpty()); } } diff --git a/pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/TopologyRPCs.java b/pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/TopologyRPCs.java index 90b71b18f3..cd27fd35cb 100644 --- a/pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/TopologyRPCs.java +++ b/pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/TopologyRPCs.java @@ -24,6 +24,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.RemoveLspOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.RemoveLspOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TearDownSessionInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TearDownSessionOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TearDownSessionOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TriggerSyncInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TriggerSyncOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TriggerSyncOutputBuilder; @@ -76,8 +78,9 @@ final class TopologyRPCs implements NetworkTopologyPcepService { } @Override - public ListenableFuture> tearDownSession(final TearDownSessionInput input) { + public ListenableFuture> tearDownSession(final TearDownSessionInput input) { return Futures.transform(this.manager.tearDownSession(input), - input1 -> SuccessfulRpcResult.create(null), MoreExecutors.directExecutor()); + input1 -> SuccessfulRpcResult.create(new TearDownSessionOutputBuilder().build()), + MoreExecutors.directExecutor()); } } -- 2.36.6