// Set up the connection to the server
NIOEventLoop eventLoop = new NIOEventLoop();
ProtoRpcChannel[] channels = ProtoRpcChannel.connectParallel(eventLoop,
new InetSocketAddress[] {new InetSocketAddress(host, port)});
// ProtoRpcChannel channel = new ProtoRpcChannel(eventLoop, new InetSocketAddress(host, port));
CounterService stub = CounterService.newStub(channels[0]);
ProtoRpcController rpc = new ProtoRpcController();
StoreResultCallback<Value> callback = new StoreResultCallback<Value>();
// Build the request
if (isGet) {
stub.get(rpc, GetRequest.getDefaultInstance(), callback);
rpc.block();
System.out.println("get = " + callback.getResult().getValue());
} else {
stub.add(rpc, Value.newBuilder().setValue(increment).build(), callback);
rpc.block();
System.out.println("counter + " + increment + " = " + callback.getResult().getValue());
}
}