summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-06-29 16:20:04 +0900
committerSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-06-30 13:36:24 +0900
commit1af73d413afd1956b1922fd8b637bb6341a1e467 (patch)
tree86e4fcc5646971a63be0cfa2fcaaf9f7c268a934
parent609e3171dfc85b85dbaa7ca641600f3803a53692 (diff)
grpc: Update Java sample client for GoBGP v1.20 gRPC API
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
-rw-r--r--docs/sources/grpc-client.md16
-rw-r--r--tools/grpc/java/src/gobgp/example/GobgpSampleClient.java15
2 files changed, 16 insertions, 15 deletions
diff --git a/docs/sources/grpc-client.md b/docs/sources/grpc-client.md
index f0f841e8..bc91c3f0 100644
--- a/docs/sources/grpc-client.md
+++ b/docs/sources/grpc-client.md
@@ -232,13 +232,15 @@ $ CLASSPATH=./lib/protobuf-java-3.3.0.jar:./lib/guava-22.0.jar:./lib/grpc-okhttp
$ javac -classpath $CLASSPATH -d ./classes ./src/gobgpapi/*.java
$ javac -classpath $CLASSPATH -d ./classes ./src/gobgp/example/GobgpSampleClient.java
$ java -cp $CLASSPATH gobgp.example.GobgpSampleClient localhost
-Feb 08, 2016 2:39:29 PM io.grpc.internal.TransportSet$1 run
-INFO: Created transport io.grpc.okhttp.OkHttpClientTransport@ba4d54(localhost/127.0.0.1:8080) for localhost/127.0.0.1:8080
-Feb 08, 2016 2:39:29 PM io.grpc.internal.TransportSet$TransportListener transportReady
-INFO: Transport io.grpc.okhttp.OkHttpClientTransport@ba4d54(localhost/127.0.0.1:8080) for localhost/127.0.0.1:8080 is ready
-BGP neighbor is 10.0.255.1, remote AS 65001
- BGP version 4, remote router ID <nil>
- BGP state = BGP_FSM_ACTIVE, up for 0
+BGP neighbor is 10.0.0.2, remote AS 1
+ BGP version 4, remote router ID
+ BGP state = active, up for 0
+ BGP OutQ = 0, Flops = 0
+ Hold time is 0, keepalive interval is 0 seconds
+ Configured hold time is 90
+BGP neighbor is 10.0.0.3, remote AS 1
+ BGP version 4, remote router ID
+ BGP state = active, up for 0
BGP OutQ = 0, Flops = 0
Hold time is 0, keepalive interval is 0 seconds
Configured hold time is 90
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<Gobgp.Peer> 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();
}
}