Skip to content

Commit 1ada412

Browse files
Merge branch 'grpc:master' into FixIssue-11194
2 parents 536311d + 2191557 commit 1ada412

File tree

8 files changed

+199
-106
lines changed

8 files changed

+199
-106
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ For a guided tour, take a look at the [quick start
4444
guide](https://grpc.io/docs/languages/java/quickstart) or the more explanatory [gRPC
4545
basics](https://grpc.io/docs/languages/java/basics).
4646

47-
The [examples](https://github.com/grpc/grpc-java/tree/v1.70.0/examples) and the
48-
[Android example](https://github.com/grpc/grpc-java/tree/v1.70.0/examples/android)
47+
The [examples](https://github.com/grpc/grpc-java/tree/v1.71.0/examples) and the
48+
[Android example](https://github.com/grpc/grpc-java/tree/v1.71.0/examples/android)
4949
are standalone projects that showcase the usage of gRPC.
5050

5151
Download
@@ -56,18 +56,18 @@ Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`:
5656
<dependency>
5757
<groupId>io.grpc</groupId>
5858
<artifactId>grpc-netty-shaded</artifactId>
59-
<version>1.70.0</version>
59+
<version>1.71.0</version>
6060
<scope>runtime</scope>
6161
</dependency>
6262
<dependency>
6363
<groupId>io.grpc</groupId>
6464
<artifactId>grpc-protobuf</artifactId>
65-
<version>1.70.0</version>
65+
<version>1.71.0</version>
6666
</dependency>
6767
<dependency>
6868
<groupId>io.grpc</groupId>
6969
<artifactId>grpc-stub</artifactId>
70-
<version>1.70.0</version>
70+
<version>1.71.0</version>
7171
</dependency>
7272
<dependency> <!-- necessary for Java 9+ -->
7373
<groupId>org.apache.tomcat</groupId>
@@ -79,18 +79,18 @@ Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`:
7979

8080
Or for Gradle with non-Android, add to your dependencies:
8181
```gradle
82-
runtimeOnly 'io.grpc:grpc-netty-shaded:1.70.0'
83-
implementation 'io.grpc:grpc-protobuf:1.70.0'
84-
implementation 'io.grpc:grpc-stub:1.70.0'
82+
runtimeOnly 'io.grpc:grpc-netty-shaded:1.71.0'
83+
implementation 'io.grpc:grpc-protobuf:1.71.0'
84+
implementation 'io.grpc:grpc-stub:1.71.0'
8585
compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+
8686
```
8787

8888
For Android client, use `grpc-okhttp` instead of `grpc-netty-shaded` and
8989
`grpc-protobuf-lite` instead of `grpc-protobuf`:
9090
```gradle
91-
implementation 'io.grpc:grpc-okhttp:1.70.0'
92-
implementation 'io.grpc:grpc-protobuf-lite:1.70.0'
93-
implementation 'io.grpc:grpc-stub:1.70.0'
91+
implementation 'io.grpc:grpc-okhttp:1.71.0'
92+
implementation 'io.grpc:grpc-protobuf-lite:1.71.0'
93+
implementation 'io.grpc:grpc-stub:1.71.0'
9494
compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+
9595
```
9696

@@ -99,7 +99,7 @@ For [Bazel](https://bazel.build), you can either
9999
(with the GAVs from above), or use `@io_grpc_grpc_java//api` et al (see below).
100100

101101
[the JARs]:
102-
https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.70.0
102+
https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.71.0
103103

104104
Development snapshots are available in [Sonatypes's snapshot
105105
repository](https://oss.sonatype.org/content/repositories/snapshots/).
@@ -131,7 +131,7 @@ For protobuf-based codegen integrated with the Maven build system, you can use
131131
<configuration>
132132
<protocArtifact>com.google.protobuf:protoc:3.25.5:exe:${os.detected.classifier}</protocArtifact>
133133
<pluginId>grpc-java</pluginId>
134-
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.70.0:exe:${os.detected.classifier}</pluginArtifact>
134+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.71.0:exe:${os.detected.classifier}</pluginArtifact>
135135
</configuration>
136136
<executions>
137137
<execution>
@@ -161,7 +161,7 @@ protobuf {
161161
}
162162
plugins {
163163
grpc {
164-
artifact = 'io.grpc:protoc-gen-grpc-java:1.70.0'
164+
artifact = 'io.grpc:protoc-gen-grpc-java:1.71.0'
165165
}
166166
}
167167
generateProtoTasks {
@@ -194,7 +194,7 @@ protobuf {
194194
}
195195
plugins {
196196
grpc {
197-
artifact = 'io.grpc:protoc-gen-grpc-java:1.70.0'
197+
artifact = 'io.grpc:protoc-gen-grpc-java:1.71.0'
198198
}
199199
}
200200
generateProtoTasks {

buildscripts/kokoro/psm-dualstack.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Location of the continuous shell script in repository.
44
build_file: "grpc-java/buildscripts/kokoro/psm-interop-test-java.sh"
5-
timeout_mins: 120
5+
timeout_mins: 240
66

77
action {
88
define_artifacts {

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ Example bugs not caught by mocked stub tests include:
153153

154154
For testing a gRPC client, create the client with a real stub
155155
using an
156-
[InProcessChannel](../core/src/main/java/io/grpc/inprocess/InProcessChannelBuilder.java),
156+
[InProcessChannel](../inprocess/src/main/java/io/grpc/inprocess/InProcessChannelBuilder.java),
157157
and test it against an
158-
[InProcessServer](../core/src/main/java/io/grpc/inprocess/InProcessServerBuilder.java)
158+
[InProcessServer](../inprocess/src/main/java/io/grpc/inprocess/InProcessServerBuilder.java)
159159
with a mock/fake service implementation.
160160

161161
For testing a gRPC server, create the server as an InProcessServer,

examples/example-dualstack/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The dualstack example uses a custom name resolver that provides both IPv4 and IPv6 localhost
44
endpoints for each of 3 server instances. The client will first use the default name resolver and
5-
load balancers which will only connect tot he first server. It will then use the
5+
load balancers which will only connect to the first server. It will then use the
66
custom name resolver with round robin to connect to each of the servers in turn. The 3 instances
77
of the server will bind respectively to: both IPv4 and IPv6, IPv4 only, and IPv6 only.
88

xds/src/main/java/io/grpc/xds/ClusterManagerLoadBalancer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ protected Map<Object, ResolvedAddresses> createChildAddressesMap(
8181

8282
ClusterManagerConfig config = (ClusterManagerConfig)
8383
resolvedAddresses.getLoadBalancingPolicyConfig();
84+
logger.log(
85+
XdsLogLevel.INFO,
86+
"Received cluster_manager lb config: child names={0}", config.childPolicies.keySet());
8487
Map<Object, ResolvedAddresses> childAddresses = new HashMap<>();
8588

8689
// Reactivate children with config; deactivate children without config
@@ -108,9 +111,6 @@ protected Map<Object, ResolvedAddresses> createChildAddressesMap(
108111
.build();
109112
childAddresses.put(childPolicy.getKey(), addresses);
110113
}
111-
logger.log(
112-
XdsLogLevel.INFO,
113-
"Received cluster_manager lb config: child names={0}", config.childPolicies.keySet());
114114
return childAddresses;
115115
}
116116

xds/src/main/java/io/grpc/xds/XdsNameResolver.java

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ final class XdsNameResolver extends NameResolver {
132132
// NamedFilterConfig.filterStateKey -> filter_instance.
133133
private final HashMap<String, Filter> activeFilters = new HashMap<>();
134134

135-
private volatile RoutingConfig routingConfig = RoutingConfig.EMPTY;
135+
private volatile RoutingConfig routingConfig;
136136
private Listener2 listener;
137137
private ObjectPool<XdsClient> xdsClientPool;
138138
private XdsClient xdsClient;
@@ -306,7 +306,7 @@ private void updateResolutionResult() {
306306

307307
if (logger.isLoggable(XdsLogLevel.INFO)) {
308308
logger.log(
309-
XdsLogLevel.INFO, "Generated service config:\n{0}", new Gson().toJson(rawServiceConfig));
309+
XdsLogLevel.INFO, "Generated service config: {0}", new Gson().toJson(rawServiceConfig));
310310
}
311311
ConfigOrError parsedServiceConfig = serviceConfigParser.parseServiceConfig(rawServiceConfig);
312312
Attributes attrs =
@@ -320,7 +320,7 @@ private void updateResolutionResult() {
320320
.setAttributes(attrs)
321321
.setServiceConfig(parsedServiceConfig)
322322
.build();
323-
listener.onResult(result);
323+
listener.onResult2(result);
324324
receivedConfig = true;
325325
}
326326

@@ -395,6 +395,9 @@ public Result selectConfig(PickSubchannelArgs args) {
395395
String path = "/" + args.getMethodDescriptor().getFullMethodName();
396396
do {
397397
routingCfg = routingConfig;
398+
if (routingCfg.errorStatus != null) {
399+
return Result.forError(routingCfg.errorStatus);
400+
}
398401
selectedRoute = null;
399402
for (RouteData route : routingCfg.routes) {
400403
if (RoutingUtils.matchRoute(route.routeMatch, path, headers, random)) {
@@ -626,19 +629,6 @@ private static String prefixedClusterSpecifierPluginName(String pluginName) {
626629
return "cluster_specifier_plugin:" + pluginName;
627630
}
628631

629-
private static final class FailingConfigSelector extends InternalConfigSelector {
630-
private final Result result;
631-
632-
public FailingConfigSelector(Status error) {
633-
this.result = Result.forError(error);
634-
}
635-
636-
@Override
637-
public Result selectConfig(PickSubchannelArgs args) {
638-
return result;
639-
}
640-
}
641-
642632
private class ResolveState implements ResourceWatcher<XdsListenerResource.LdsUpdate> {
643633
private final ConfigOrError emptyServiceConfig =
644634
serviceConfigParser.parseServiceConfig(Collections.<String, Object>emptyMap());
@@ -835,13 +825,13 @@ private void updateRoutes(List<VirtualHost> virtualHosts, long httpMaxStreamDura
835825
}
836826
}
837827
// Update service config to include newly added clusters.
838-
if (shouldUpdateResult) {
828+
if (shouldUpdateResult && routingConfig != null) {
839829
updateResolutionResult();
830+
shouldUpdateResult = false;
840831
}
841832
// Make newly added clusters selectable by config selector and deleted clusters no longer
842833
// selectable.
843834
routingConfig = new RoutingConfig(httpMaxStreamDurationNano, routesData.build());
844-
shouldUpdateResult = false;
845835
for (String cluster : deletedClusters) {
846836
int count = clusterRefs.get(cluster).refCount.decrementAndGet();
847837
if (count == 0) {
@@ -893,6 +883,9 @@ private ClientInterceptor createFilters(
893883
}
894884

895885
private void cleanUpRoutes(String error) {
886+
String errorWithNodeId =
887+
error + ", xDS node ID: " + xdsClient.getBootstrapInfo().node().getId();
888+
routingConfig = new RoutingConfig(Status.UNAVAILABLE.withDescription(errorWithNodeId));
896889
if (existingClusters != null) {
897890
for (String cluster : existingClusters) {
898891
int count = clusterRefs.get(cluster).refCount.decrementAndGet();
@@ -902,17 +895,12 @@ private void cleanUpRoutes(String error) {
902895
}
903896
existingClusters = null;
904897
}
905-
routingConfig = RoutingConfig.EMPTY;
898+
906899
// Without addresses the default LB (normally pick_first) should become TRANSIENT_FAILURE, and
907-
// the config selector handles the error message itself. Once the LB API allows providing
908-
// failure information for addresses yet still providing a service config, the config seector
909-
// could be avoided.
910-
String errorWithNodeId =
911-
error + ", xDS node ID: " + xdsClient.getBootstrapInfo().node().getId();
912-
listener.onResult(ResolutionResult.newBuilder()
900+
// the config selector handles the error message itself.
901+
listener.onResult2(ResolutionResult.newBuilder()
913902
.setAttributes(Attributes.newBuilder()
914-
.set(InternalConfigSelector.KEY,
915-
new FailingConfigSelector(Status.UNAVAILABLE.withDescription(errorWithNodeId)))
903+
.set(InternalConfigSelector.KEY, configSelector)
916904
.build())
917905
.setServiceConfig(emptyServiceConfig)
918906
.build());
@@ -983,12 +971,19 @@ public void onResourceDoesNotExist(final String resourceName) {
983971
private static class RoutingConfig {
984972
private final long fallbackTimeoutNano;
985973
final ImmutableList<RouteData> routes;
986-
987-
private static final RoutingConfig EMPTY = new RoutingConfig(0, ImmutableList.of());
974+
final Status errorStatus;
988975

989976
private RoutingConfig(long fallbackTimeoutNano, ImmutableList<RouteData> routes) {
990977
this.fallbackTimeoutNano = fallbackTimeoutNano;
991978
this.routes = checkNotNull(routes, "routes");
979+
this.errorStatus = null;
980+
}
981+
982+
private RoutingConfig(Status errorStatus) {
983+
this.fallbackTimeoutNano = 0;
984+
this.routes = null;
985+
this.errorStatus = checkNotNull(errorStatus, "errorStatus");
986+
checkArgument(!errorStatus.isOk(), "errorStatus should not be okay");
992987
}
993988
}
994989

0 commit comments

Comments
 (0)