From ca99a05e70ce1585988ccee2f052b00e6ee06211 Mon Sep 17 00:00:00 2001 From: Alex Ehrnschwender Date: Wed, 10 Jun 2020 16:06:48 -0700 Subject: [PATCH] adds retrying example details in README, revert change to gradle wrapper properties --- examples/README.md | 30 +++++++++++++++++++ .../gradle/wrapper/gradle-wrapper.properties | 5 ++-- .../retrying/RetryingHelloWorldClient.java | 8 ++--- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/examples/README.md b/examples/README.md index 9f74895a45c..d3c69996715 100644 --- a/examples/README.md +++ b/examples/README.md @@ -87,6 +87,36 @@ before trying out the examples. +-
+ Retrying + + The [retrying example](src/main/java/io/grpc/examples/retrying) provides a HelloWorld GRPC client & + server which demos the effect of client retry policy configured on the [ManagedChannel]( + ../api/src/main/java/io/grpc/ManagedChannel.java) via [GRPC ServiceConfig]( + ../core/src/main/java/io/grpc/internal/ManagedChannelServiceConfig.java). Retry policy implementation & + configuration details are outlined in the [proposal](https://github.com/grpc/proposal/blob/master/A6-client-retries.md). + + This retrying example is very similar to the [hedging example](src/main/java/io/grpc/examples/hedging) in its setup. + The [RetryingHelloWorldServer](src/main/java/io/grpc/examples/retrying/RetryingHelloWorldServer.java) responds with + a status UNAVAILABLE error response to a specified percentage of requests to simulate server resource exhaustion and + general flakiness. The [RetryingHelloWorldClient](src/main/java/io/grpc/examples/retrying/RetryingHelloWorldClient.java) makes + a number of sequential requests to the server, several of which will be retried depending on the configured policy in + [retrying_service_config.json](src/main/resources/io/grpc/examples/retrying/retrying_service_config.json). Although + the requests are blocking unary calls for simplicity, these could easily be changed to future unary calls in order to + test the result of request concurrency with retry policy enabled. + + One can experiment with the [RetryingHelloWorldServer](src/main/java/io/grpc/examples/retrying/RetryingHelloWorldServer.java) + failure conditions to simulate server throttling, as well as alter policy values in the [retrying_service_config.json]( + src/main/resources/io/grpc/examples/retrying/retrying_service_config.json) to see their effects. To disable retrying + entirely, set environment variable `DISABLE_RETRYING_IN_RETRYING_EXAMPLE=true` before running the client. + Disabling the retry policy should produce many more failed GRPC calls as seen in the output log. + + See [the section below](#to-build-the-examples) for how to build and run the example. The + executables for the server and the client are `retrying-hello-world-server` and + `retrying-hello-world-client`. + +
+ ### To build the examples 1. **[Install gRPC Java library SNAPSHOT locally, including code generation plugin](../COMPILING.md) (Only need this step for non-released versions, e.g. master HEAD).** diff --git a/examples/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties index 21c56efbe47..7c4388a9216 100644 --- a/examples/gradle/wrapper/gradle-wrapper.properties +++ b/examples/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Tue Jun 02 23:49:09 PDT 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/examples/src/main/java/io/grpc/examples/retrying/RetryingHelloWorldClient.java b/examples/src/main/java/io/grpc/examples/retrying/RetryingHelloWorldClient.java index c03728664bf..d611b7a6f42 100644 --- a/examples/src/main/java/io/grpc/examples/retrying/RetryingHelloWorldClient.java +++ b/examples/src/main/java/io/grpc/examples/retrying/RetryingHelloWorldClient.java @@ -39,7 +39,7 @@ * A client that requests a greeting from the {@link RetryingHelloWorldServer} with a retrying policy. */ public class RetryingHelloWorldClient { - static final String ENV_DISABLE_RETRIES = "DISABLE_RETRIES_IN_RETRIES_EXAMPLE"; + static final String ENV_DISABLE_RETRYING = "DISABLE_RETRYING_IN_RETRYING_EXAMPLE"; private static final Logger logger = Logger.getLogger(RetryingHelloWorldClient.class.getName()); @@ -117,17 +117,17 @@ private void printSummary() { logger.log( Level.INFO, "Retrying enabled. To disable retries, run the client with environment variable {0}=true.", - ENV_DISABLE_RETRIES); + ENV_DISABLE_RETRYING); } else { logger.log( Level.INFO, "Retrying disabled. To enable retries, unset environment variable {0} and then run the client.", - ENV_DISABLE_RETRIES); + ENV_DISABLE_RETRYING); } } public static void main(String[] args) throws Exception { - boolean enableRetries = !Boolean.parseBoolean(System.getenv(ENV_DISABLE_RETRIES)); + boolean enableRetries = !Boolean.parseBoolean(System.getenv(ENV_DISABLE_RETRYING)); final RetryingHelloWorldClient client = new RetryingHelloWorldClient("localhost", 50051, enableRetries); ForkJoinPool executor = new ForkJoinPool();