From 1af73d413afd1956b1922fd8b637bb6341a1e467 Mon Sep 17 00:00:00 2001 From: Satoshi Fujimoto Date: Thu, 29 Jun 2017 16:20:04 +0900 Subject: grpc: Update Java sample client for GoBGP v1.20 gRPC API Signed-off-by: Satoshi Fujimoto --- tools/grpc/java/src/gobgp/example/GobgpSampleClient.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'tools') diff --git a/tools/grpc/java/src/gobgp/example/GobgpSampleClient.java b/tools/grpc/java/src/gobgp/example/GobgpSampleClient.java index eb991f88..287b46b6 100644 --- a/tools/grpc/java/src/gobgp/example/GobgpSampleClient.java +++ b/tools/grpc/java/src/gobgp/example/GobgpSampleClient.java @@ -5,7 +5,7 @@ import gobgpapi.GobgpApiGrpc; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; -import java.util.Iterator; +import java.util.List; public class GobgpSampleClient { @@ -18,13 +18,12 @@ public class GobgpSampleClient { public void getNeighbors(){ - Gobgp.Arguments request = Gobgp.Arguments.newBuilder().build(); + Gobgp.GetNeighborRequest request = Gobgp.GetNeighborRequest.newBuilder().build(); - for(Iterator iterator = this.blockingStub.getNeighbors(request); iterator.hasNext(); ) { - Gobgp.Peer p = iterator.next(); - Gobgp.PeerConf conf = p.getConf(); - Gobgp.PeerState state = p.getInfo(); - Gobgp.Timers timer = p.getTimers(); + for(Gobgp.Peer peer: this.blockingStub.getNeighbor(request).getPeersList()) { + Gobgp.PeerConf conf = peer.getConf(); + Gobgp.PeerState state = peer.getInfo(); + Gobgp.Timers timer = peer.getTimers(); System.out.printf("BGP neighbor is %s, remote AS %d\n", conf.getNeighborAddress(), conf.getPeerAs()); System.out.printf("\tBGP version 4, remote router ID %s\n", conf.getId()); @@ -38,7 +37,7 @@ public class GobgpSampleClient { } public static void main(String args[]){ - new GobgpSampleClient(args[0], 8080).getNeighbors(); + new GobgpSampleClient(args[0], 50051).getNeighbors(); } } -- cgit v1.2.3