Complete the change s/Greetings/Greeter
This commit is contained in:
parent
2604848108
commit
a16a4d551f
|
|
@ -369,7 +369,7 @@ We'll look at using a client to access the server in the next section.
|
|||
Client-side gRPC is pretty simple. In this step, we'll use the generated code
|
||||
to write a simple client that can access the `Greeter` server we created
|
||||
in the [previous section](#server). You can see the complete client code in
|
||||
[GreetingClient.java](java/src/main/java/ex/grpc/GreetingsClient.java).
|
||||
[GreeterClient.java](java/src/main/java/ex/grpc/GreeterClient.java).
|
||||
|
||||
Again, we're not going to go into much detail about how to implement a client
|
||||
- we'll leave that for the tutorial.
|
||||
|
|
@ -462,13 +462,13 @@ We've added simple shell scripts to simplifying running the examples. Now
|
|||
that they are built, you can run the server with:
|
||||
|
||||
```sh
|
||||
$ ./run_greetings_server.sh
|
||||
$ ./run_greeter_server.sh
|
||||
```
|
||||
|
||||
and in another terminal window confirm that it receives a message.
|
||||
|
||||
```sh
|
||||
$ ./run_greetings_client.sh
|
||||
$ ./run_greeter_client.sh
|
||||
```
|
||||
|
||||
### Adding another client
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash -e
|
||||
TARGET='Greetings Client'
|
||||
TARGET_CLASS='ex.grpc.GreetingsClient'
|
||||
TARGET='Greeter Client'
|
||||
TARGET_CLASS='ex.grpc.GreeterClient'
|
||||
TARGET_ARGS="$@"
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash -e
|
||||
TARGET='Greetings Server'
|
||||
TARGET_CLASS='ex.grpc.GreetingsServer'
|
||||
TARGET='Greeter Server'
|
||||
TARGET_CLASS='ex.grpc.GreeterServer'
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
mvn -q -nsu -am package -Dcheckstyle.skip=true -DskipTests
|
||||
|
|
@ -9,13 +9,13 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class GreetingsClient {
|
||||
public class GreeterClient {
|
||||
private final Logger logger = Logger.getLogger(
|
||||
GreetingsClient.class.getName());
|
||||
GreeterClient.class.getName());
|
||||
private final ChannelImpl channel;
|
||||
private final GreeterGrpc.GreeterBlockingStub blockingStub;
|
||||
|
||||
public GreetingsClient(String host, int port) {
|
||||
public GreeterClient(String host, int port) {
|
||||
channel = NettyChannelBuilder.forAddress(host, port)
|
||||
.negotiationType(NegotiationType.PLAINTEXT)
|
||||
.build();
|
||||
|
|
@ -40,7 +40,7 @@ public class GreetingsClient {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
GreetingsClient client = new GreetingsClient("localhost", 50051);
|
||||
GreeterClient client = new GreeterClient("localhost", 50051);
|
||||
try {
|
||||
/* Access a service running on the local machine on port 50051 */
|
||||
String user = "world";
|
||||
|
|
@ -7,9 +7,9 @@ import com.google.net.stubby.transport.netty.NettyServerBuilder;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Server that manages startup/shutdown of a {@code Greetings} server.
|
||||
* Server that manages startup/shutdown of a {@code Greeter} server.
|
||||
*/
|
||||
public class GreetingsServer {
|
||||
public class GreeterServer {
|
||||
/* The port on which the server should run */
|
||||
private int port = 50051;
|
||||
private ServerImpl server;
|
||||
|
|
@ -33,7 +33,7 @@ public class GreetingsServer {
|
|||
* Main launches the server from the command line.
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
final GreetingsServer server = new GreetingsServer();
|
||||
final GreeterServer server = new GreeterServer();
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
Loading…
Reference in New Issue