summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2018-12-24 23:20:35 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2018-12-24 23:20:35 +0900
commit48fa25d06c96262779253b0b051e8d1a34604764 (patch)
treefabaad0ea3022bc15c526e6757793ce62d2b67b3
parentbb1bbdd197a971917ae24946a4c4d2da539e5d55 (diff)
docs: delete outdated java/nodejs/ruby gRPC API examples
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
-rw-r--r--docs/sources/grpc-client.md186
-rw-r--r--tools/grpc/java/src/gobgp/example/GobgpSampleClient.java44
-rw-r--r--tools/grpc/nodejs/get_neighbors.js24
-rw-r--r--tools/grpc/ruby/get_neighbors.rb15
4 files changed, 0 insertions, 269 deletions
diff --git a/docs/sources/grpc-client.md b/docs/sources/grpc-client.md
index f3bccba1..76910253 100644
--- a/docs/sources/grpc-client.md
+++ b/docs/sources/grpc-client.md
@@ -9,10 +9,7 @@ Ruby, C++, Node.js, and Java. It assumes that you use Ubuntu 16.04 (64bit).
- [Prerequisite](#prerequisite)
- [Python](#python)
-- [Ruby](#ruby)
- [C++](#cpp)
-- [Node.js](#nodejs)
-- [Java](#java)
## Prerequisite
@@ -47,34 +44,6 @@ $ gobgp g r
*> 10.0.0.0/24 1.1.1.1 100 200 00:08:02 [{Origin: ?}]
```
-## Ruby
-
-### Generating Stub Code
-
-We need to generate stub code GoBGP at first.
-
-```bash
-$ cd $GOPATH/src/github.com/osrg/gobgp/tools/grpc/ruby
-$ GOBGP_API=$GOPATH/src/github.com/osrg/gobgp/api
-$ protoc -I $GOBGP_API --ruby_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_ruby_plugin` $GOBGP_API/gobgp.proto
-```
-
-### Get Neighbor
-
-['tools/grpc/ruby/get_neighbor.py'](https://github.com/osrg/gobgp/blob/master/tools/grpc/ruby/get_neighbor.rb)
-shows an example for getting neighbor's information.
-Let's run this script.
-
-```bash
-$ ruby -I . ./get_neighbors.rb 172.18.0.2
-BGP neighbor is 10.0.0.2, remote AS 65002
- BGP version 4, remote route 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
-```
-
## C++
### Generating Interface and Binary
@@ -103,158 +72,3 @@ $ gobgp g r
Network Next Hop AS_PATH Age Attrs
*> 10.0.0.0/24 1.1.1.1 00:13:26 [{Origin: i} {Communities: 0:100}]
```
-
-## Node.js
-
-### Example
-
-Copy protocol definition.
-
-```bash
-$ cd $GOPATH/src/github.com/osrg/gobgp/tools/grpc/nodejs
-$ ln -s $GOPATH/src/github.com/osrg/gobgp/api/gobgp.proto
-```
-
-['tools/grpc/nodejs/get_neighbor.js'](https://github.com/osrg/gobgp/blob/master/tools/grpc/nodejs/get_neighbors.js)
-shows an example to show neighbor information.
-Let's run this:
-
-```bash
-$ node get_neighbors.js
-BGP neighbor: 10.0.255.1 , remote AS: 65001
- BGP version 4, remote router ID: 10.0.255.1
- BGP state: BGP_FSM_ESTABLISHED , uptime: Wed Jul 20 2016 05:37:22 GMT+0900 (JST)
- BGP OutQ: 0 , Flops: 0
- Hold time: 90 , keepalive interval: 30 seconds
- Configured hold time: 90
-BGP neighbor: 10.0.255.2 , remote AS: 65002
- BGP version 4, remote router ID: <nil>
- BGP state: BGP_FSM_ACTIVE , uptime: undefined
- BGP OutQ: 0 , Flops: 0
- Hold time: undefined , keepalive interval: undefined seconds
- Configured hold time: 90
-```
-
-## Java
-
-At the time of this writing, versions of each plugins and tools are as
-following:
-
-- ProtocolBuffer: 3.3.0
-- grpc-java: 1.4.0
-- java: 1.8.0_131
-
-In proceeding with the following procedure, please substitute versions to the
-latest.
-
-### Install JDK
-
-We need to install JDK and we use Oracle JDK8 in this example.
-
-```bash
-$ sudo add-apt-repository ppa:webupd8team/java
-$ sudo apt-get update
-$ sudo apt-get install oracle-java8-installer
-$ java -version
-java version "1.8.0_131"
-Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
-Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
-$ echo "export JAVA_HOME=/usr/lib/jvm/java-8-oracle" >> ~/.bashrc
-$ source ~/.bashrc
-```
-
-### Create protobuf library for Java
-
-We assume you've cloned gRPC repository in your home directory.
-
-```bash
-$ sudo apt-get install maven
-$ cd ~/grpc/third_party/protobuf/java
-$ mvn package
-...
-[INFO]
-[INFO] --- maven-bundle-plugin:3.0.1:bundle (default-bundle) @ protobuf-java ---
-[INFO] ------------------------------------------------------------------------
-[INFO] BUILD SUCCESS
-[INFO] ------------------------------------------------------------------------
-[INFO] Total time: 1:57.106s
-[INFO] Finished at: Mon Feb 08 11:51:51 JST 2016
-[INFO] Final Memory: 31M/228M
-[INFO] ------------------------------------------------------------------------
-$ ls ./core/target/proto*
-./core/target/protobuf-java-3.3.0.jar
-```
-
-### Clone grpc-java and get plugins
-
-```bash
-$ cd ~/work
-$ git clone https://github.com/grpc/grpc-java.git
-$ cd ./grpc-java
-$ git checkout -b v1.4.0 v1.4.0
-$ cd ./all
-$ ../gradlew build
-$ ls ../compiler/build/binaries/java_pluginExecutable/
-protoc-gen-grpc-java
-```
-
-### Generate stub classes
-
-```bash
-$ cd $GOPATH/src/github.com/osrg/gobgp/tools/grpc
-$ mkdir -p java/src
-$ cd java
-$ GOBGP_API=$GOPATH/src/github.com/osrg/gobgp/api
-$ protoc --java_out=./src --proto_path="$GOBGP_API" $GOBGP_API/gobgp.proto
-$ protoc --plugin=protoc-gen-grpc-java=$HOME/work/grpc-java/compiler/build/exe/java_plugin/protoc-gen-grpc-java --grpc-java_out=./src --proto_path="$GOBGP_API" $GOBGP_API/gobgp.proto
-$ ls ./src/gobgpapi/
-Gobgp.java GobgpApiGrpc.java
-```
-
-### Build sample client
-
-['tools/grpc/java/src/gobgp/example/GobgpSampleClient.java'](https://github.com/osrg/gobgp/blob/master/tools/grpc/java/src/gobgp/example/GobgpSampleClient.java)
-is an example to show neighbor information.
-
-Let's build and run it. However we need to download and copy some dependencies
-beforehand.
-
-```bash
-$ cd $GOPATH/src/github.com/osrg/gobgp/tools/grpc/java
-$ mkdir lib
-$ cd lib
-$ wget http://central.maven.org/maven2/com/google/guava/guava/22.0/guava-22.0.jar
-$ wget http://central.maven.org/maven2/com/squareup/okhttp/okhttp/2.5.0/okhttp-2.7.5.jar
-$ wget http://central.maven.org/maven2/com/squareup/okio/okio/1.13.0/okio-1.13.0.jar
-$ wget http://central.maven.org/maven2/com/google/instrumentation/instrumentation-api/0.4.3/instrumentation-api-0.4.3.jar
-$ cp ~/grpc/third_party/protobuf/java/core/target/protobuf-java-3.3.0.jar ./
-$ cp ~/work/grpc-java/stub/build/libs/grpc-stub-1.4.0.jar ./
-$ cp ~/work/grpc-java/core/build/libs/grpc-core-1.4.0.jar ./
-$ cp ~/work/grpc-java/protobuf/build/libs/grpc-protobuf-1.4.0.jar ./
-$ cp ~/work/grpc-java/protobuf-lite/build/libs/grpc-protobuf-lite-1.4.0.jar ./
-$ cp ~/work/grpc-java/context/build/libs/grpc-context-1.4.0.jar ./
-$ cp ~/work/grpc-java/okhttp/build/libs/grpc-okhttp-1.4.0.jar ./
-```
-
-We are ready to build and run.
-
-```bash
-$ cd $GOPATH/src/github.com/osrg/gobgp/tools/grpc/java
-$ mkdir classes
-$ CLASSPATH=./lib/protobuf-java-3.3.0.jar:./lib/guava-22.0.jar:./lib/grpc-okhttp-1.4.0.jar:./lib/okio-1.13.0.jar:./lib/grpc-stub-1.4.0.jar:./lib/grpc-core-1.4.0.jar:./lib/grpc-protobuf-1.4.0.jar:./lib/okhttp-2.7.5.jar:./lib/instrumentation-api-0.4.3.jar:./lib/grpc-context-1.4.0.jar:./lib/grpc-protobuf-lite-1.4.0.jar:./classes/
-$ 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
-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
deleted file mode 100644
index 287b46b6..00000000
--- a/tools/grpc/java/src/gobgp/example/GobgpSampleClient.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package gobgp.example;
-
-import gobgpapi.Gobgp;
-import gobgpapi.GobgpApiGrpc;
-import io.grpc.ManagedChannel;
-import io.grpc.ManagedChannelBuilder;
-
-import java.util.List;
-
-public class GobgpSampleClient {
-
- private final GobgpApiGrpc.GobgpApiBlockingStub blockingStub;
-
- public GobgpSampleClient(String host, int port) {
- ManagedChannel channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext(true).build();
- this.blockingStub = GobgpApiGrpc.newBlockingStub(channel);
- }
-
- public void getNeighbors(){
-
- Gobgp.GetNeighborRequest request = Gobgp.GetNeighborRequest.newBuilder().build();
-
- 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());
- System.out.printf("\tBGP state = %s, up for %d\n", state.getBgpState(), timer.getState().getUptime());
- System.out.printf("\tBGP OutQ = %d, Flops = %d\n", state.getOutQ(), state.getFlops());
- System.out.printf("\tHold time is %d, keepalive interval is %d seconds\n",
- timer.getState().getHoldTime(), timer.getState().getKeepaliveInterval());
- System.out.printf("\tConfigured hold time is %d\n", timer.getConfig().getHoldTime());
-
- }
- }
-
- public static void main(String args[]){
- new GobgpSampleClient(args[0], 50051).getNeighbors();
- }
-
-}
-
diff --git a/tools/grpc/nodejs/get_neighbors.js b/tools/grpc/nodejs/get_neighbors.js
deleted file mode 100644
index 6cc6b082..00000000
--- a/tools/grpc/nodejs/get_neighbors.js
+++ /dev/null
@@ -1,24 +0,0 @@
-var grpc = require('grpc');
-var api = grpc.load('gobgp.proto').gobgpapi;
-var stub = new api.GobgpApi('localhost:50051', grpc.credentials.createInsecure());
-
-stub.getNeighbor({}, function(err, neighbor) {
- neighbor.peers.forEach(function(peer) {
- if(peer.info.bgp_state == 'BGP_FSM_ESTABLISHED') {
- var date = new Date(Number(peer.timers.state.uptime)*1000);
- var holdtime = peer.timers.state.negotiated_hold_time;
- var keepalive = peer.timers.state.keepalive_interval;
- }
-
- console.log('BGP neighbor:', peer.conf.neighbor_address,
- ', remote AS:', peer.conf.peer_as);
- console.log("\tBGP version 4, remote router ID:", peer.conf.id);
- console.log("\tBGP state:", peer.info.bgp_state,
- ', uptime:', date);
- console.log("\tBGP OutQ:", peer.info.out_q,
- ', Flops:', peer.info.flops);
- console.log("\tHold time:", holdtime,
- ', keepalive interval:', keepalive, 'seconds');
- console.log("\tConfigured hold time:", peer.timers.config.hold_time);
- });
-});
diff --git a/tools/grpc/ruby/get_neighbors.rb b/tools/grpc/ruby/get_neighbors.rb
deleted file mode 100644
index a451f67f..00000000
--- a/tools/grpc/ruby/get_neighbors.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'gobgp_pb'
-require 'gobgp_services_pb'
-
-host = ARGV[0]
-
-stub = Gobgpapi::GobgpApi::Stub.new("#{host}:50051", :this_channel_is_insecure)
-arg = Gobgpapi::GetNeighborRequest.new()
-stub.get_neighbor(arg).peers.each do |n|
- puts "BGP neighbor is #{n.conf.neighbor_address}, remote AS #{n.conf.peer_as}"
- puts "\tBGP version 4, remote route ID #{n.conf.id}"
- puts "\tBGP state = #{n.info.bgp_state}, up for #{n.timers.state.uptime}"
- puts "\tBGP OutQ = #{n.info.out_q}, Flops = #{n.info.flops}"
- puts "\tHold time is #{n.timers.state.hold_time}, keepalive interval is #{n.timers.state.keepalive_interval} seconds"
- puts "\tConfigured hold time is #{n.timers.config.hold_time}"
-end