From 84f6086336d271f5710ce07ca0f9c77b0f11b4e9 Mon Sep 17 00:00:00 2001 From: yifeizhuang Date: Tue, 19 Jul 2022 23:10:12 +0000 Subject: [PATCH 01/11] Bump version to 1.48.1-SNAPSHOT --- build.gradle | 2 +- .../src/test/golden/TestDeprecatedService.java.txt | 2 +- compiler/src/test/golden/TestService.java.txt | 2 +- .../src/testLite/golden/TestDeprecatedService.java.txt | 2 +- compiler/src/testLite/golden/TestService.java.txt | 2 +- core/src/main/java/io/grpc/internal/GrpcUtil.java | 2 +- examples/android/clientcache/app/build.gradle | 10 +++++----- examples/android/helloworld/app/build.gradle | 8 ++++---- examples/android/routeguide/app/build.gradle | 8 ++++---- examples/android/strictmode/app/build.gradle | 8 ++++---- examples/build.gradle | 2 +- examples/example-alts/build.gradle | 2 +- examples/example-gauth/build.gradle | 2 +- examples/example-gauth/pom.xml | 4 ++-- examples/example-hostname/build.gradle | 2 +- examples/example-hostname/pom.xml | 4 ++-- examples/example-jwt-auth/build.gradle | 2 +- examples/example-jwt-auth/pom.xml | 4 ++-- examples/example-orca/build.gradle | 2 +- examples/example-tls/build.gradle | 2 +- examples/example-tls/pom.xml | 4 ++-- examples/example-xds/build.gradle | 2 +- examples/pom.xml | 4 ++-- 23 files changed, 41 insertions(+), 41 deletions(-) diff --git a/build.gradle b/build.gradle index 56ecf47054b..78de14c8f3f 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ subprojects { apply plugin: "net.ltgt.errorprone" group = "io.grpc" - version = "1.48.0" // CURRENT_GRPC_VERSION + version = "1.48.1-SNAPSHOT" // CURRENT_GRPC_VERSION repositories { maven { // The google mirror is less flaky than mavenCentral() diff --git a/compiler/src/test/golden/TestDeprecatedService.java.txt b/compiler/src/test/golden/TestDeprecatedService.java.txt index ca09ce90b98..f5aa03f3e99 100644 --- a/compiler/src/test/golden/TestDeprecatedService.java.txt +++ b/compiler/src/test/golden/TestDeprecatedService.java.txt @@ -8,7 +8,7 @@ import static io.grpc.MethodDescriptor.generateFullMethodName; * */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.48.0)", + value = "by gRPC proto compiler (version 1.48.1-SNAPSHOT)", comments = "Source: grpc/testing/compiler/test.proto") @io.grpc.stub.annotations.GrpcGenerated @java.lang.Deprecated diff --git a/compiler/src/test/golden/TestService.java.txt b/compiler/src/test/golden/TestService.java.txt index f37cd348359..9aadaf37e45 100644 --- a/compiler/src/test/golden/TestService.java.txt +++ b/compiler/src/test/golden/TestService.java.txt @@ -8,7 +8,7 @@ import static io.grpc.MethodDescriptor.generateFullMethodName; * */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.48.0)", + value = "by gRPC proto compiler (version 1.48.1-SNAPSHOT)", comments = "Source: grpc/testing/compiler/test.proto") @io.grpc.stub.annotations.GrpcGenerated public final class TestServiceGrpc { diff --git a/compiler/src/testLite/golden/TestDeprecatedService.java.txt b/compiler/src/testLite/golden/TestDeprecatedService.java.txt index 25bfe6cad1e..5bd3d39e576 100644 --- a/compiler/src/testLite/golden/TestDeprecatedService.java.txt +++ b/compiler/src/testLite/golden/TestDeprecatedService.java.txt @@ -8,7 +8,7 @@ import static io.grpc.MethodDescriptor.generateFullMethodName; * */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.48.0)", + value = "by gRPC proto compiler (version 1.48.1-SNAPSHOT)", comments = "Source: grpc/testing/compiler/test.proto") @io.grpc.stub.annotations.GrpcGenerated @java.lang.Deprecated diff --git a/compiler/src/testLite/golden/TestService.java.txt b/compiler/src/testLite/golden/TestService.java.txt index e592d66cb3f..ed21ce9a7d5 100644 --- a/compiler/src/testLite/golden/TestService.java.txt +++ b/compiler/src/testLite/golden/TestService.java.txt @@ -8,7 +8,7 @@ import static io.grpc.MethodDescriptor.generateFullMethodName; * */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.48.0)", + value = "by gRPC proto compiler (version 1.48.1-SNAPSHOT)", comments = "Source: grpc/testing/compiler/test.proto") @io.grpc.stub.annotations.GrpcGenerated public final class TestServiceGrpc { diff --git a/core/src/main/java/io/grpc/internal/GrpcUtil.java b/core/src/main/java/io/grpc/internal/GrpcUtil.java index a6a4e3b873b..7c2cec2d5fb 100644 --- a/core/src/main/java/io/grpc/internal/GrpcUtil.java +++ b/core/src/main/java/io/grpc/internal/GrpcUtil.java @@ -203,7 +203,7 @@ public byte[] parseAsciiString(byte[] serialized) { public static final Splitter ACCEPT_ENCODING_SPLITTER = Splitter.on(',').trimResults(); - private static final String IMPLEMENTATION_VERSION = "1.48.0"; // CURRENT_GRPC_VERSION + private static final String IMPLEMENTATION_VERSION = "1.48.1-SNAPSHOT"; // CURRENT_GRPC_VERSION /** * The default timeout in nanos for a keepalive ping request. diff --git a/examples/android/clientcache/app/build.gradle b/examples/android/clientcache/app/build.gradle index ac99730d3fb..ba8a1a8742a 100644 --- a/examples/android/clientcache/app/build.gradle +++ b/examples/android/clientcache/app/build.gradle @@ -34,7 +34,7 @@ android { protobuf { protoc { artifact = 'com.google.protobuf:protoc:3.21.1' } plugins { - grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.0' // CURRENT_GRPC_VERSION + grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION } } generateProtoTasks { @@ -54,12 +54,12 @@ dependencies { implementation 'com.android.support:appcompat-v7:27.0.2' // You need to build grpc-java to obtain these libraries below. - implementation 'io.grpc:grpc-okhttp:1.48.0' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-protobuf-lite:1.48.0' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-stub:1.48.0' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-okhttp:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-protobuf-lite:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-stub:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'org.apache.tomcat:annotations-api:6.0.53' testImplementation 'junit:junit:4.12' testImplementation 'com.google.truth:truth:1.0.1' - testImplementation 'io.grpc:grpc-testing:1.48.0' // CURRENT_GRPC_VERSION + testImplementation 'io.grpc:grpc-testing:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION } diff --git a/examples/android/helloworld/app/build.gradle b/examples/android/helloworld/app/build.gradle index cd333babda4..5777cbbcee2 100644 --- a/examples/android/helloworld/app/build.gradle +++ b/examples/android/helloworld/app/build.gradle @@ -32,7 +32,7 @@ android { protobuf { protoc { artifact = 'com.google.protobuf:protoc:3.21.1' } plugins { - grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.0' // CURRENT_GRPC_VERSION + grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION } } generateProtoTasks { @@ -52,8 +52,8 @@ dependencies { implementation 'com.android.support:appcompat-v7:27.0.2' // You need to build grpc-java to obtain these libraries below. - implementation 'io.grpc:grpc-okhttp:1.48.0' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-protobuf-lite:1.48.0' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-stub:1.48.0' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-okhttp:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-protobuf-lite:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-stub:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'org.apache.tomcat:annotations-api:6.0.53' } diff --git a/examples/android/routeguide/app/build.gradle b/examples/android/routeguide/app/build.gradle index 24683b4f927..763a8e6fdfd 100644 --- a/examples/android/routeguide/app/build.gradle +++ b/examples/android/routeguide/app/build.gradle @@ -32,7 +32,7 @@ android { protobuf { protoc { artifact = 'com.google.protobuf:protoc:3.21.1' } plugins { - grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.0' // CURRENT_GRPC_VERSION + grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION } } generateProtoTasks { @@ -52,8 +52,8 @@ dependencies { implementation 'com.android.support:appcompat-v7:27.0.2' // You need to build grpc-java to obtain these libraries below. - implementation 'io.grpc:grpc-okhttp:1.48.0' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-protobuf-lite:1.48.0' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-stub:1.48.0' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-okhttp:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-protobuf-lite:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-stub:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'org.apache.tomcat:annotations-api:6.0.53' } diff --git a/examples/android/strictmode/app/build.gradle b/examples/android/strictmode/app/build.gradle index f7c137bca36..348610c244c 100644 --- a/examples/android/strictmode/app/build.gradle +++ b/examples/android/strictmode/app/build.gradle @@ -33,7 +33,7 @@ android { protobuf { protoc { artifact = 'com.google.protobuf:protoc:3.21.1' } plugins { - grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.0' // CURRENT_GRPC_VERSION + grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION } } generateProtoTasks { @@ -53,8 +53,8 @@ dependencies { implementation 'com.android.support:appcompat-v7:28.0.0' // You need to build grpc-java to obtain these libraries below. - implementation 'io.grpc:grpc-okhttp:1.48.0' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-protobuf-lite:1.48.0' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-stub:1.48.0' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-okhttp:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-protobuf-lite:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-stub:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'org.apache.tomcat:annotations-api:6.0.53' } diff --git a/examples/build.gradle b/examples/build.gradle index ea8434913bd..6c891754bdb 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -22,7 +22,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.0' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION def protobufVersion = '3.21.1' def protocVersion = protobufVersion diff --git a/examples/example-alts/build.gradle b/examples/example-alts/build.gradle index 260ca0753e2..40eb86c410e 100644 --- a/examples/example-alts/build.gradle +++ b/examples/example-alts/build.gradle @@ -23,7 +23,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.0' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION def protocVersion = '3.21.1' dependencies { diff --git a/examples/example-gauth/build.gradle b/examples/example-gauth/build.gradle index be89ca911a9..e44b9f0c574 100644 --- a/examples/example-gauth/build.gradle +++ b/examples/example-gauth/build.gradle @@ -23,7 +23,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.0' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION def protobufVersion = '3.21.1' def protocVersion = protobufVersion diff --git a/examples/example-gauth/pom.xml b/examples/example-gauth/pom.xml index f27f2db4519..e4b63a24437 100644 --- a/examples/example-gauth/pom.xml +++ b/examples/example-gauth/pom.xml @@ -6,13 +6,13 @@ jar - 1.48.0 + 1.48.1-SNAPSHOT example-gauth https://github.com/grpc/grpc-java UTF-8 - 1.48.0 + 1.48.1-SNAPSHOT 3.21.1 1.7 diff --git a/examples/example-hostname/build.gradle b/examples/example-hostname/build.gradle index ebde5f3a302..def41ed94a3 100644 --- a/examples/example-hostname/build.gradle +++ b/examples/example-hostname/build.gradle @@ -21,7 +21,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.0' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION def protobufVersion = '3.21.1' dependencies { diff --git a/examples/example-hostname/pom.xml b/examples/example-hostname/pom.xml index aa84d26958d..aa3954ee4c8 100644 --- a/examples/example-hostname/pom.xml +++ b/examples/example-hostname/pom.xml @@ -6,13 +6,13 @@ jar - 1.48.0 + 1.48.1-SNAPSHOT example-hostname https://github.com/grpc/grpc-java UTF-8 - 1.48.0 + 1.48.1-SNAPSHOT 3.21.1 1.7 diff --git a/examples/example-jwt-auth/build.gradle b/examples/example-jwt-auth/build.gradle index c4b09b92eca..3e87053cd4f 100644 --- a/examples/example-jwt-auth/build.gradle +++ b/examples/example-jwt-auth/build.gradle @@ -22,7 +22,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.0' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION def protobufVersion = '3.21.1' def protocVersion = protobufVersion diff --git a/examples/example-jwt-auth/pom.xml b/examples/example-jwt-auth/pom.xml index c985e047032..02092bbe2f0 100644 --- a/examples/example-jwt-auth/pom.xml +++ b/examples/example-jwt-auth/pom.xml @@ -7,13 +7,13 @@ jar - 1.48.0 + 1.48.1-SNAPSHOT example-jwt-auth https://github.com/grpc/grpc-java UTF-8 - 1.48.0 + 1.48.1-SNAPSHOT 3.21.1 3.21.1 diff --git a/examples/example-orca/build.gradle b/examples/example-orca/build.gradle index be8efa0d919..c70d4806db5 100644 --- a/examples/example-orca/build.gradle +++ b/examples/example-orca/build.gradle @@ -17,7 +17,7 @@ repositories { sourceCompatibility = 1.8 targetCompatibility = 1.8 -def grpcVersion = '1.48.0' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION def protocVersion = '3.21.1' dependencies { diff --git a/examples/example-tls/build.gradle b/examples/example-tls/build.gradle index 4196bb68974..c6cb2a99e4c 100644 --- a/examples/example-tls/build.gradle +++ b/examples/example-tls/build.gradle @@ -23,7 +23,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.0' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION def protocVersion = '3.21.1' dependencies { diff --git a/examples/example-tls/pom.xml b/examples/example-tls/pom.xml index 1812e2d2c12..2939c576790 100644 --- a/examples/example-tls/pom.xml +++ b/examples/example-tls/pom.xml @@ -6,13 +6,13 @@ jar - 1.48.0 + 1.48.1-SNAPSHOT example-tls https://github.com/grpc/grpc-java UTF-8 - 1.48.0 + 1.48.1-SNAPSHOT 3.21.1 2.0.53.Final diff --git a/examples/example-xds/build.gradle b/examples/example-xds/build.gradle index 542d5ffdc03..a0806a29604 100644 --- a/examples/example-xds/build.gradle +++ b/examples/example-xds/build.gradle @@ -22,7 +22,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.0' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION def nettyTcNativeVersion = '2.0.31.Final' def protocVersion = '3.21.1' diff --git a/examples/pom.xml b/examples/pom.xml index b1bf1f5843a..22bc0dc12f4 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,13 +6,13 @@ jar - 1.48.0 + 1.48.1-SNAPSHOT examples https://github.com/grpc/grpc-java UTF-8 - 1.48.0 + 1.48.1-SNAPSHOT 3.21.1 3.21.1 From 61a3a2fb99eb351ac692431fd39530c041c0d5ce Mon Sep 17 00:00:00 2001 From: Larry Safran <107004254+larry-safran@users.noreply.github.com> Date: Thu, 21 Jul 2022 11:38:14 -0700 Subject: [PATCH 02/11] core: Disable retry by default for in-process transport's channel (#9368) Backport of PR #9361 See issue #8712 --- .../java/io/grpc/inprocess/InProcessChannelBuilder.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/io/grpc/inprocess/InProcessChannelBuilder.java b/core/src/main/java/io/grpc/inprocess/InProcessChannelBuilder.java index df396ae2f66..35998a535e2 100644 --- a/core/src/main/java/io/grpc/inprocess/InProcessChannelBuilder.java +++ b/core/src/main/java/io/grpc/inprocess/InProcessChannelBuilder.java @@ -114,6 +114,10 @@ public ClientTransportFactory buildClientTransportFactory() { managedChannelImplBuilder.setStatsRecordStartedRpcs(false); managedChannelImplBuilder.setStatsRecordFinishedRpcs(false); managedChannelImplBuilder.setStatsRecordRetryMetrics(false); + + // By default, In-process transport should not be retriable as that leaks memory. Since + // there is no wire, bytes aren't calculated so buffer limit isn't respected + managedChannelImplBuilder.disableRetry(); } @Internal @@ -123,7 +127,7 @@ protected ManagedChannelBuilder delegate() { } @Override - public final InProcessChannelBuilder maxInboundMessageSize(int max) { + public InProcessChannelBuilder maxInboundMessageSize(int max) { // TODO(carl-mastrangelo): maybe throw an exception since this not enforced? return super.maxInboundMessageSize(max); } From 289a442e2dfcb60a617c90c225ac7dafc08545bd Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Fri, 15 Jul 2022 15:25:27 -0700 Subject: [PATCH 03/11] core: Workaround retry causing memory leak Data is getting orphaned sitting in MessageFramer. This hack thus always flushes data out of the framer so no data can remain sitting there. See #9340 --- .../io/grpc/internal/RetriableStream.java | 4 + .../io/grpc/internal/RetriableStreamTest.java | 77 ++++++++++++++++--- 2 files changed, 69 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/io/grpc/internal/RetriableStream.java b/core/src/main/java/io/grpc/internal/RetriableStream.java index 55c17c50ba2..cb94195cce1 100644 --- a/core/src/main/java/io/grpc/internal/RetriableStream.java +++ b/core/src/main/java/io/grpc/internal/RetriableStream.java @@ -550,6 +550,10 @@ class SendMessageEntry implements BufferEntry { @Override public void runWith(Substream substream) { substream.stream.writeMessage(method.streamRequest(message)); + // TODO(ejona): Workaround Netty memory leak. Message writes always need to be followed by + // flushes (or half close), but retry appears to have a code path that the flushes may + // not happen. The code needs to be fixed and this removed. See #9340. + substream.stream.flush(); } } diff --git a/core/src/test/java/io/grpc/internal/RetriableStreamTest.java b/core/src/test/java/io/grpc/internal/RetriableStreamTest.java index 3f8b25ce1c4..f20e772e92b 100644 --- a/core/src/test/java/io/grpc/internal/RetriableStreamTest.java +++ b/core/src/test/java/io/grpc/internal/RetriableStreamTest.java @@ -268,10 +268,14 @@ public Void answer(InvocationOnMock in) { retriableStream.sendMessage("msg3"); retriableStream.request(456); - inOrder.verify(mockStream1, times(2)).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).flush(); // Memory leak workaround + inOrder.verify(mockStream1).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).flush(); // Memory leak workaround inOrder.verify(mockStream1).request(345); inOrder.verify(mockStream1, times(2)).flush(); inOrder.verify(mockStream1).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).flush(); // Memory leak workaround inOrder.verify(mockStream1).request(456); inOrder.verifyNoMoreInteractions(); @@ -304,12 +308,19 @@ public Void answer(InvocationOnMock in) { ArgumentCaptor sublistenerCaptor2 = ArgumentCaptor.forClass(ClientStreamListener.class); inOrder.verify(mockStream2).start(sublistenerCaptor2.capture()); - inOrder.verify(mockStream2, times(2)).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround + inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround inOrder.verify(mockStream2).request(345); inOrder.verify(mockStream2, times(2)).flush(); inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround inOrder.verify(mockStream2).request(456); - inOrder.verify(mockStream2, times(2)).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround + inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround inOrder.verify(mockStream2).isReady(); inOrder.verifyNoMoreInteractions(); @@ -319,7 +330,10 @@ public Void answer(InvocationOnMock in) { // mockStream1 is closed so it is not in the drainedSubstreams verifyNoMoreInteractions(mockStream1); - inOrder.verify(mockStream2, times(2)).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround + inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround // retry2 doReturn(mockStream3).when(retriableStreamRecorder).newSubstream(2); @@ -353,12 +367,19 @@ public Void answer(InvocationOnMock in) { ArgumentCaptor sublistenerCaptor3 = ArgumentCaptor.forClass(ClientStreamListener.class); inOrder.verify(mockStream3).start(sublistenerCaptor3.capture()); - inOrder.verify(mockStream3, times(2)).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround + inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround inOrder.verify(mockStream3).request(345); inOrder.verify(mockStream3, times(2)).flush(); inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround inOrder.verify(mockStream3).request(456); - inOrder.verify(mockStream3, times(7)).writeMessage(any(InputStream.class)); + for (int i = 0; i < 7; i++) { + inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround + } inOrder.verify(mockStream3).isReady(); inOrder.verifyNoMoreInteractions(); @@ -1958,10 +1979,14 @@ public Void answer(InvocationOnMock in) { hedgingStream.sendMessage("msg3"); hedgingStream.request(456); - inOrder.verify(mockStream1, times(2)).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).flush(); // Memory leak workaround + inOrder.verify(mockStream1).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).flush(); // Memory leak workaround inOrder.verify(mockStream1).request(345); inOrder.verify(mockStream1, times(2)).flush(); inOrder.verify(mockStream1).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).flush(); // Memory leak workaround inOrder.verify(mockStream1).request(456); inOrder.verifyNoMoreInteractions(); @@ -1984,10 +2009,14 @@ public Void answer(InvocationOnMock in) { ArgumentCaptor sublistenerCaptor2 = ArgumentCaptor.forClass(ClientStreamListener.class); inOrder.verify(mockStream2).start(sublistenerCaptor2.capture()); - inOrder.verify(mockStream2, times(2)).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround + inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround inOrder.verify(mockStream2).request(345); inOrder.verify(mockStream2, times(2)).flush(); inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround inOrder.verify(mockStream2).request(456); inOrder.verify(mockStream1).isReady(); inOrder.verify(mockStream2).isReady(); @@ -1998,9 +2027,13 @@ public Void answer(InvocationOnMock in) { hedgingStream.sendMessage("msg2 after hedge2 starts"); inOrder.verify(mockStream1).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).flush(); // Memory leak workaround inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround inOrder.verify(mockStream1).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).flush(); // Memory leak workaround inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround inOrder.verifyNoMoreInteractions(); @@ -2022,12 +2055,19 @@ public Void answer(InvocationOnMock in) { ArgumentCaptor sublistenerCaptor3 = ArgumentCaptor.forClass(ClientStreamListener.class); inOrder.verify(mockStream3).start(sublistenerCaptor3.capture()); - inOrder.verify(mockStream3, times(2)).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround + inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround inOrder.verify(mockStream3).request(345); inOrder.verify(mockStream3, times(2)).flush(); inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround inOrder.verify(mockStream3).request(456); - inOrder.verify(mockStream3, times(2)).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround + inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround inOrder.verify(mockStream1).isReady(); inOrder.verify(mockStream2).isReady(); inOrder.verify(mockStream3).isReady(); @@ -2036,8 +2076,11 @@ public Void answer(InvocationOnMock in) { // send one more message hedgingStream.sendMessage("msg1 after hedge3 starts"); inOrder.verify(mockStream1).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).flush(); // Memory leak workaround inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround // hedge3 receives nonFatalStatus sublistenerCaptor3.getValue().closed( @@ -2047,7 +2090,9 @@ public Void answer(InvocationOnMock in) { // send one more message hedgingStream.sendMessage("msg1 after hedge3 fails"); inOrder.verify(mockStream1).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream1).flush(); // Memory leak workaround inOrder.verify(mockStream2).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream2).flush(); // Memory leak workaround // the hedge mockStream4 starts fakeClock.forwardTime(HEDGING_DELAY_IN_SECONDS, TimeUnit.SECONDS); @@ -2067,12 +2112,19 @@ public Void answer(InvocationOnMock in) { ArgumentCaptor sublistenerCaptor4 = ArgumentCaptor.forClass(ClientStreamListener.class); inOrder.verify(mockStream4).start(sublistenerCaptor4.capture()); - inOrder.verify(mockStream4, times(2)).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream4).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream4).flush(); // Memory leak workaround + inOrder.verify(mockStream4).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream4).flush(); // Memory leak workaround inOrder.verify(mockStream4).request(345); inOrder.verify(mockStream4, times(2)).flush(); inOrder.verify(mockStream4).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream4).flush(); // Memory leak workaround inOrder.verify(mockStream4).request(456); - inOrder.verify(mockStream4, times(4)).writeMessage(any(InputStream.class)); + for (int i = 0; i < 4; i++) { + inOrder.verify(mockStream4).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream4).flush(); // Memory leak workaround + } inOrder.verify(mockStream1).isReady(); inOrder.verify(mockStream2).isReady(); inOrder.verify(mockStream4).isReady(); @@ -2190,6 +2242,7 @@ public void hedging_maxAttempts() { hedgingStream.sendMessage("msg1 after commit"); inOrder.verify(mockStream3).writeMessage(any(InputStream.class)); + inOrder.verify(mockStream3).flush(); // Memory leak workaround inOrder.verifyNoMoreInteractions(); Metadata heders = new Metadata(); From 25183ed10086e023931f418eef6934315e2744e3 Mon Sep 17 00:00:00 2001 From: yifeizhuang Date: Fri, 15 Jul 2022 09:41:50 -0700 Subject: [PATCH 04/11] xds: do not expose orca proto in ORCA api (#9366) The fix avoids shaded dependency of orca protos --- ...tomBackendMetricsLoadBalancerProvider.java | 21 ++++---- .../io/grpc/services/CallMetricRecorder.java | 3 +- .../services/InternalCallMetricRecorder.java | 8 +++ .../java/io/grpc/xds/orca/OrcaOobUtil.java | 9 ++-- .../io/grpc/xds/orca/OrcaPerRequestUtil.java | 17 +++++-- .../io/grpc/xds/orca/OrcaOobUtilTest.java | 29 +++++++---- .../grpc/xds/orca/OrcaPerRequestUtilTest.java | 49 +++++++++++++++---- 7 files changed, 100 insertions(+), 36 deletions(-) diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/CustomBackendMetricsLoadBalancerProvider.java b/interop-testing/src/main/java/io/grpc/testing/integration/CustomBackendMetricsLoadBalancerProvider.java index 372403ed47f..7c88c7b1d73 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/CustomBackendMetricsLoadBalancerProvider.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/CustomBackendMetricsLoadBalancerProvider.java @@ -19,11 +19,11 @@ import static io.grpc.testing.integration.AbstractInteropTest.ORCA_OOB_REPORT_KEY; import static io.grpc.testing.integration.AbstractInteropTest.ORCA_RPC_REPORT_KEY; -import com.github.xds.data.orca.v3.OrcaLoadReport; import io.grpc.ConnectivityState; import io.grpc.LoadBalancer; import io.grpc.LoadBalancerProvider; import io.grpc.LoadBalancerRegistry; +import io.grpc.services.CallMetricRecorder; import io.grpc.testing.integration.Messages.TestOrcaReport; import io.grpc.util.ForwardingLoadBalancer; import io.grpc.util.ForwardingLoadBalancerHelper; @@ -87,8 +87,8 @@ public Subchannel createSubchannel(CreateSubchannelArgs args) { Subchannel subchannel = super.createSubchannel(args); OrcaOobUtil.setListener(subchannel, new OrcaOobUtil.OrcaOobReportListener() { @Override - public void onLoadReport(OrcaLoadReport orcaLoadReport) { - latestOobReport = fromOrcaLoadReport(orcaLoadReport); + public void onLoadReport(CallMetricRecorder.CallMetricReport orcaLoadReport) { + latestOobReport = fromCallMetricReport(orcaLoadReport); } }, OrcaOobUtil.OrcaReportingConfig.newBuilder() @@ -133,22 +133,23 @@ public PickResult pickSubchannel(PickSubchannelArgs args) { OrcaPerRequestUtil.getInstance().newOrcaClientStreamTracerFactory( new OrcaPerRequestUtil.OrcaPerRequestReportListener() { @Override - public void onLoadReport(OrcaLoadReport orcaLoadReport) { + public void onLoadReport(CallMetricRecorder.CallMetricReport callMetricReport) { AtomicReference reportRef = args.getCallOptions().getOption(ORCA_RPC_REPORT_KEY); - reportRef.set(fromOrcaLoadReport(orcaLoadReport)); + reportRef.set(fromCallMetricReport(callMetricReport)); } })); } } } - private static TestOrcaReport fromOrcaLoadReport(OrcaLoadReport orcaLoadReport) { + private static TestOrcaReport fromCallMetricReport( + CallMetricRecorder.CallMetricReport callMetricReport) { return TestOrcaReport.newBuilder() - .setCpuUtilization(orcaLoadReport.getCpuUtilization()) - .setMemoryUtilization(orcaLoadReport.getMemUtilization()) - .putAllRequestCost(orcaLoadReport.getRequestCostMap()) - .putAllUtilization(orcaLoadReport.getUtilizationMap()) + .setCpuUtilization(callMetricReport.getCpuUtilization()) + .setMemoryUtilization(callMetricReport.getMemoryUtilization()) + .putAllRequestCost(callMetricReport.getRequestCostMetrics()) + .putAllUtilization(callMetricReport.getUtilizationMetrics()) .build(); } } diff --git a/services/src/main/java/io/grpc/services/CallMetricRecorder.java b/services/src/main/java/io/grpc/services/CallMetricRecorder.java index da4283eba81..e87512e3002 100644 --- a/services/src/main/java/io/grpc/services/CallMetricRecorder.java +++ b/services/src/main/java/io/grpc/services/CallMetricRecorder.java @@ -53,7 +53,8 @@ public static final class CallMetricReport { private Map utilizationMetrics; /** - * Create a report for all backend metrics. + * A gRPC object of orca load report. LB policies listening at per-rpc or oob orca load reports + * will be notified of the metrics data in this data format. */ CallMetricReport(double cpuUtilization, double memoryUtilization, Map requestCostMetrics, diff --git a/services/src/main/java/io/grpc/services/InternalCallMetricRecorder.java b/services/src/main/java/io/grpc/services/InternalCallMetricRecorder.java index 5c6c79e71f2..01f6cc6417c 100644 --- a/services/src/main/java/io/grpc/services/InternalCallMetricRecorder.java +++ b/services/src/main/java/io/grpc/services/InternalCallMetricRecorder.java @@ -44,4 +44,12 @@ public static Map finalizeAndDump(CallMetricRecorder recorder) { public static CallMetricRecorder.CallMetricReport finalizeAndDump2(CallMetricRecorder recorder) { return recorder.finalizeAndDump2(); } + + public static CallMetricRecorder.CallMetricReport createMetricReport( + double cpuUtilization, double memoryUtilization, + Map requestCostMetrics, + Map utilizationMetrics) { + return new CallMetricRecorder.CallMetricReport(cpuUtilization, memoryUtilization, + requestCostMetrics, utilizationMetrics); + } } diff --git a/xds/src/main/java/io/grpc/xds/orca/OrcaOobUtil.java b/xds/src/main/java/io/grpc/xds/orca/OrcaOobUtil.java index 0e88c02cd15..2e6a2891569 100644 --- a/xds/src/main/java/io/grpc/xds/orca/OrcaOobUtil.java +++ b/xds/src/main/java/io/grpc/xds/orca/OrcaOobUtil.java @@ -51,6 +51,7 @@ import io.grpc.internal.BackoffPolicy; import io.grpc.internal.ExponentialBackoffPolicy; import io.grpc.internal.GrpcUtil; +import io.grpc.services.CallMetricRecorder; import io.grpc.util.ForwardingLoadBalancerHelper; import io.grpc.util.ForwardingSubchannel; import java.util.HashMap; @@ -168,9 +169,9 @@ public interface OrcaOobReportListener { *

Note this callback will be invoked from the {@link SynchronizationContext} of the * delegated helper, implementations should not block. * - * @param report load report in the format of ORCA protocol. + * @param report load report in the format of grpc {@link CallMetricRecorder.CallMetricReport}. */ - void onLoadReport(OrcaLoadReport report); + void onLoadReport(CallMetricRecorder.CallMetricReport report); } static final Attributes.Key ORCA_REPORTING_STATE_KEY = @@ -450,8 +451,10 @@ void handleResponse(OrcaLoadReport response) { callHasResponded = true; backoffPolicy = null; subchannelLogger.log(ChannelLogLevel.DEBUG, "Received an ORCA report: {0}", response); + CallMetricRecorder.CallMetricReport metricReport = + OrcaPerRequestUtil.fromOrcaLoadReport(response); for (OrcaOobReportListener listener : configs.keySet()) { - listener.onLoadReport(response); + listener.onLoadReport(metricReport); } call.request(1); } diff --git a/xds/src/main/java/io/grpc/xds/orca/OrcaPerRequestUtil.java b/xds/src/main/java/io/grpc/xds/orca/OrcaPerRequestUtil.java index 52f9f9f5f1b..4006e989545 100644 --- a/xds/src/main/java/io/grpc/xds/orca/OrcaPerRequestUtil.java +++ b/xds/src/main/java/io/grpc/xds/orca/OrcaPerRequestUtil.java @@ -28,6 +28,8 @@ import io.grpc.Metadata; import io.grpc.internal.ForwardingClientStreamTracer; import io.grpc.protobuf.ProtoUtils; +import io.grpc.services.CallMetricRecorder; +import io.grpc.services.InternalCallMetricRecorder; import java.util.ArrayList; import java.util.List; @@ -175,14 +177,14 @@ public abstract ClientStreamTracer.Factory newOrcaClientStreamTracerFactory( public interface OrcaPerRequestReportListener { /** - * Invoked when an per-request ORCA report is received. + * Invoked when a per-request ORCA report is received. * *

Note this callback will be invoked from the network thread as the RPC finishes, * implementations should not block. * - * @param report load report in the format of ORCA format. + * @param report load report in the format of grpc {@link CallMetricRecorder.CallMetricReport}. */ - void onLoadReport(OrcaLoadReport report); + void onLoadReport(CallMetricRecorder.CallMetricReport report); } /** @@ -250,6 +252,12 @@ public void inboundTrailers(Metadata trailers) { } } + static CallMetricRecorder.CallMetricReport fromOrcaLoadReport(OrcaLoadReport loadReport) { + return InternalCallMetricRecorder.createMetricReport(loadReport.getCpuUtilization(), + loadReport.getMemUtilization(), loadReport.getRequestCostMap(), + loadReport.getUtilizationMap()); + } + /** * A container class to hold registered {@link OrcaPerRequestReportListener}s and invoke all of * them when an {@link OrcaLoadReport} is received. @@ -263,8 +271,9 @@ void addListener(OrcaPerRequestReportListener listener) { } void onReport(OrcaLoadReport report) { + CallMetricRecorder.CallMetricReport metricReport = fromOrcaLoadReport(report); for (OrcaPerRequestReportListener listener : listeners) { - listener.onLoadReport(report); + listener.onLoadReport(metricReport); } } } diff --git a/xds/src/test/java/io/grpc/xds/orca/OrcaOobUtilTest.java b/xds/src/test/java/io/grpc/xds/orca/OrcaOobUtilTest.java index 770cb783b56..5a981123ae0 100644 --- a/xds/src/test/java/io/grpc/xds/orca/OrcaOobUtilTest.java +++ b/xds/src/test/java/io/grpc/xds/orca/OrcaOobUtilTest.java @@ -25,6 +25,7 @@ import static io.grpc.ConnectivityState.SHUTDOWN; import static org.junit.Assert.fail; import static org.mockito.AdditionalAnswers.delegatesTo; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.inOrder; @@ -61,6 +62,7 @@ import io.grpc.inprocess.InProcessServerBuilder; import io.grpc.internal.BackoffPolicy; import io.grpc.internal.FakeClock; +import io.grpc.services.CallMetricRecorder; import io.grpc.stub.StreamObserver; import io.grpc.testing.GrpcCleanupRule; import io.grpc.util.ForwardingLoadBalancerHelper; @@ -285,7 +287,9 @@ public void singlePolicyTypicalWorkflow() { OrcaLoadReport report = OrcaLoadReport.getDefaultInstance(); serverCall.responseObserver.onNext(report); assertLog(subchannel.logs, "DEBUG: Received an ORCA report: " + report); - verify(mockOrcaListener0, times(i + 1)).onLoadReport(eq(report)); + verify(mockOrcaListener0, times(i + 1)).onLoadReport( + argThat(new OrcaPerRequestUtilTest.MetricsReportMatcher( + OrcaPerRequestUtil.fromOrcaLoadReport(report)))); } for (int i = 0; i < NUM_SUBCHANNELS; i++) { @@ -369,7 +373,9 @@ public void twoLevelPoliciesTypicalWorkflow() { OrcaLoadReport report = OrcaLoadReport.getDefaultInstance(); serverCall.responseObserver.onNext(report); assertLog(subchannel.logs, "DEBUG: Received an ORCA report: " + report); - verify(mockOrcaListener1, times(i + 1)).onLoadReport(eq(report)); + verify(mockOrcaListener1, times(i + 1)).onLoadReport( + argThat(new OrcaPerRequestUtilTest.MetricsReportMatcher( + OrcaPerRequestUtil.fromOrcaLoadReport(report)))); } for (int i = 0; i < NUM_SUBCHANNELS; i++) { @@ -425,8 +431,9 @@ public void orcReportingDisabledWhenServiceNotImplemented() { OrcaLoadReport report = OrcaLoadReport.getDefaultInstance(); serverCall.responseObserver.onNext(report); assertLog(subchannel.logs, "DEBUG: Received an ORCA report: " + report); - verify(mockOrcaListener0).onLoadReport(eq(report)); - + verify(mockOrcaListener0).onLoadReport( + argThat(new OrcaPerRequestUtilTest.MetricsReportMatcher( + OrcaPerRequestUtil.fromOrcaLoadReport(report)))); verifyNoInteractions(backoffPolicyProvider); } @@ -471,8 +478,9 @@ public void orcaReportingStreamClosedAndRetried() { OrcaLoadReport report = OrcaLoadReport.getDefaultInstance(); orcaServiceImp.calls.peek().responseObserver.onNext(report); assertLog(subchannel.logs, "DEBUG: Received an ORCA report: " + report); - inOrder.verify(mockOrcaListener0).onLoadReport(eq(report)); - + inOrder.verify(mockOrcaListener0).onLoadReport( + argThat(new OrcaPerRequestUtilTest.MetricsReportMatcher( + OrcaPerRequestUtil.fromOrcaLoadReport(report)))); // Server closes the ORCA reporting RPC after a response, will restart immediately. orcaServiceImp.calls.poll().responseObserver.onCompleted(); assertThat(subchannel.logs).containsExactly( @@ -659,9 +667,11 @@ public void policiesReceiveSameReportIndependently() { orcaServiceImps[0].calls.peek().responseObserver.onNext(report); assertLog(subchannels[0].logs, "DEBUG: Received an ORCA report: " + report); // Only parent helper's listener receives the report. - ArgumentCaptor parentReportCaptor = ArgumentCaptor.forClass(null); + ArgumentCaptor parentReportCaptor = + ArgumentCaptor.forClass(null); verify(mockOrcaListener1).onLoadReport(parentReportCaptor.capture()); - assertThat(parentReportCaptor.getValue()).isEqualTo(report); + assertThat(OrcaPerRequestUtilTest.reportEqual(parentReportCaptor.getValue(), + OrcaPerRequestUtil.fromOrcaLoadReport(report))).isTrue(); verifyNoMoreInteractions(mockOrcaListener2); // Now child helper also wants to receive reports. @@ -669,7 +679,8 @@ public void policiesReceiveSameReportIndependently() { orcaServiceImps[0].calls.peek().responseObserver.onNext(report); assertLog(subchannels[0].logs, "DEBUG: Received an ORCA report: " + report); // Both helper receives the same report instance. - ArgumentCaptor childReportCaptor = ArgumentCaptor.forClass(null); + ArgumentCaptor childReportCaptor = + ArgumentCaptor.forClass(null); verify(mockOrcaListener1, times(2)) .onLoadReport(parentReportCaptor.capture()); verify(mockOrcaListener2) diff --git a/xds/src/test/java/io/grpc/xds/orca/OrcaPerRequestUtilTest.java b/xds/src/test/java/io/grpc/xds/orca/OrcaPerRequestUtilTest.java index 76fbdd3e027..2b3de09b573 100644 --- a/xds/src/test/java/io/grpc/xds/orca/OrcaPerRequestUtilTest.java +++ b/xds/src/test/java/io/grpc/xds/orca/OrcaPerRequestUtilTest.java @@ -19,7 +19,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.AdditionalAnswers.delegatesTo; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -28,8 +28,10 @@ import static org.mockito.Mockito.when; import com.github.xds.data.orca.v3.OrcaLoadReport; +import com.google.common.base.Objects; import io.grpc.ClientStreamTracer; import io.grpc.Metadata; +import io.grpc.services.CallMetricRecorder; import io.grpc.xds.orca.OrcaPerRequestUtil.OrcaPerRequestReportListener; import io.grpc.xds.orca.OrcaPerRequestUtil.OrcaReportingTracerFactory; import org.junit.Before; @@ -37,6 +39,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatcher; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -96,9 +99,33 @@ public void singlePolicyTypicalWorkflow() { OrcaReportingTracerFactory.ORCA_ENDPOINT_LOAD_METRICS_KEY, OrcaLoadReport.getDefaultInstance()); tracer.inboundTrailers(trailer); - ArgumentCaptor reportCaptor = ArgumentCaptor.forClass(null); + ArgumentCaptor reportCaptor = + ArgumentCaptor.forClass(null); verify(orcaListener1).onLoadReport(reportCaptor.capture()); - assertThat(reportCaptor.getValue()).isEqualTo(OrcaLoadReport.getDefaultInstance()); + assertThat(reportEqual(reportCaptor.getValue(), + OrcaPerRequestUtil.fromOrcaLoadReport(OrcaLoadReport.getDefaultInstance()))).isTrue(); + } + + static final class MetricsReportMatcher implements + ArgumentMatcher { + private CallMetricRecorder.CallMetricReport original; + + public MetricsReportMatcher(CallMetricRecorder.CallMetricReport report) { + this.original = report; + } + + @Override + public boolean matches(CallMetricRecorder.CallMetricReport argument) { + return reportEqual(original, argument); + } + } + + static boolean reportEqual(CallMetricRecorder.CallMetricReport a, + CallMetricRecorder.CallMetricReport b) { + return a.getCpuUtilization() == b.getCpuUtilization() + && a.getMemoryUtilization() == b.getMemoryUtilization() + && Objects.equal(a.getRequestCostMetrics(), b.getRequestCostMetrics()) + && Objects.equal(a.getUtilizationMetrics(), b.getUtilizationMetrics()); } /** @@ -136,11 +163,14 @@ public void twoLevelPoliciesTypicalWorkflow() { OrcaReportingTracerFactory.ORCA_ENDPOINT_LOAD_METRICS_KEY, OrcaLoadReport.getDefaultInstance()); childTracer.inboundTrailers(trailer); - ArgumentCaptor parentReportCap = ArgumentCaptor.forClass(null); - ArgumentCaptor childReportCap = ArgumentCaptor.forClass(null); + ArgumentCaptor parentReportCap = + ArgumentCaptor.forClass(null); + ArgumentCaptor childReportCap = + ArgumentCaptor.forClass(null); verify(orcaListener1).onLoadReport(parentReportCap.capture()); verify(orcaListener2).onLoadReport(childReportCap.capture()); - assertThat(parentReportCap.getValue()).isEqualTo(OrcaLoadReport.getDefaultInstance()); + assertThat(reportEqual(parentReportCap.getValue(), + OrcaPerRequestUtil.fromOrcaLoadReport(OrcaLoadReport.getDefaultInstance()))).isTrue(); assertThat(childReportCap.getValue()).isSameInstanceAs(parentReportCap.getValue()); } @@ -159,11 +189,12 @@ public void onlyParentPolicyReceivesReportsIfCreatesOwnTracer() { ClientStreamTracer parentTracer = parentFactory.newClientStreamTracer(STREAM_INFO, new Metadata()); Metadata trailer = new Metadata(); + OrcaLoadReport report = OrcaLoadReport.getDefaultInstance(); trailer.put( - OrcaReportingTracerFactory.ORCA_ENDPOINT_LOAD_METRICS_KEY, - OrcaLoadReport.getDefaultInstance()); + OrcaReportingTracerFactory.ORCA_ENDPOINT_LOAD_METRICS_KEY, report); parentTracer.inboundTrailers(trailer); - verify(orcaListener1).onLoadReport(eq(OrcaLoadReport.getDefaultInstance())); + verify(orcaListener1).onLoadReport( + argThat(new MetricsReportMatcher(OrcaPerRequestUtil.fromOrcaLoadReport(report)))); verifyNoInteractions(childFactory); verifyNoInteractions(orcaListener2); } From 014c022b084e50a18370824e4d71dc464ca91d56 Mon Sep 17 00:00:00 2001 From: yifeizhuang Date: Mon, 18 Jul 2022 13:23:55 -0700 Subject: [PATCH 05/11] service: make the orca MetricReport a top level experimental class (#9382) --- ...tomBackendMetricsLoadBalancerProvider.java | 9 ++- services/BUILD.bazel | 1 + .../io/grpc/services/CallMetricRecorder.java | 42 +------------ .../services/InternalCallMetricRecorder.java | 10 ++-- .../grpc/services/InternalMetricRecorder.java | 2 +- .../java/io/grpc/services/MetricRecorder.java | 4 +- .../java/io/grpc/services/MetricReport.java | 59 +++++++++++++++++++ .../grpc/services/CallMetricRecorderTest.java | 4 +- .../OrcaMetricReportingServerInterceptor.java | 4 +- .../java/io/grpc/xds/orca/OrcaOobUtil.java | 9 ++- .../io/grpc/xds/orca/OrcaPerRequestUtil.java | 10 ++-- .../io/grpc/xds/orca/OrcaServiceImpl.java | 4 +- .../io/grpc/xds/orca/OrcaOobUtilTest.java | 6 +- .../grpc/xds/orca/OrcaPerRequestUtilTest.java | 21 ++++--- 14 files changed, 101 insertions(+), 84 deletions(-) create mode 100644 services/src/main/java/io/grpc/services/MetricReport.java diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/CustomBackendMetricsLoadBalancerProvider.java b/interop-testing/src/main/java/io/grpc/testing/integration/CustomBackendMetricsLoadBalancerProvider.java index 7c88c7b1d73..1864afd3c42 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/CustomBackendMetricsLoadBalancerProvider.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/CustomBackendMetricsLoadBalancerProvider.java @@ -23,7 +23,7 @@ import io.grpc.LoadBalancer; import io.grpc.LoadBalancerProvider; import io.grpc.LoadBalancerRegistry; -import io.grpc.services.CallMetricRecorder; +import io.grpc.services.MetricReport; import io.grpc.testing.integration.Messages.TestOrcaReport; import io.grpc.util.ForwardingLoadBalancer; import io.grpc.util.ForwardingLoadBalancerHelper; @@ -87,7 +87,7 @@ public Subchannel createSubchannel(CreateSubchannelArgs args) { Subchannel subchannel = super.createSubchannel(args); OrcaOobUtil.setListener(subchannel, new OrcaOobUtil.OrcaOobReportListener() { @Override - public void onLoadReport(CallMetricRecorder.CallMetricReport orcaLoadReport) { + public void onLoadReport(MetricReport orcaLoadReport) { latestOobReport = fromCallMetricReport(orcaLoadReport); } }, @@ -133,7 +133,7 @@ public PickResult pickSubchannel(PickSubchannelArgs args) { OrcaPerRequestUtil.getInstance().newOrcaClientStreamTracerFactory( new OrcaPerRequestUtil.OrcaPerRequestReportListener() { @Override - public void onLoadReport(CallMetricRecorder.CallMetricReport callMetricReport) { + public void onLoadReport(MetricReport callMetricReport) { AtomicReference reportRef = args.getCallOptions().getOption(ORCA_RPC_REPORT_KEY); reportRef.set(fromCallMetricReport(callMetricReport)); @@ -143,8 +143,7 @@ public void onLoadReport(CallMetricRecorder.CallMetricReport callMetricReport) { } } - private static TestOrcaReport fromCallMetricReport( - CallMetricRecorder.CallMetricReport callMetricReport) { + private static TestOrcaReport fromCallMetricReport(MetricReport callMetricReport) { return TestOrcaReport.newBuilder() .setCpuUtilization(callMetricReport.getCpuUtilization()) .setMemoryUtilization(callMetricReport.getMemoryUtilization()) diff --git a/services/BUILD.bazel b/services/BUILD.bazel index 6e85d31d952..78a953d0882 100644 --- a/services/BUILD.bazel +++ b/services/BUILD.bazel @@ -37,6 +37,7 @@ java_library( srcs = [ "src/main/java/io/grpc/services/CallMetricRecorder.java", "src/main/java/io/grpc/services/MetricRecorder.java", + "src/main/java/io/grpc/services/MetricReport.java", ], deps = [ "//api", diff --git a/services/src/main/java/io/grpc/services/CallMetricRecorder.java b/services/src/main/java/io/grpc/services/CallMetricRecorder.java index e87512e3002..2feb5e28e6f 100644 --- a/services/src/main/java/io/grpc/services/CallMetricRecorder.java +++ b/services/src/main/java/io/grpc/services/CallMetricRecorder.java @@ -16,8 +16,6 @@ package io.grpc.services; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.annotations.VisibleForTesting; import io.grpc.Context; import io.grpc.ExperimentalApi; @@ -46,42 +44,6 @@ public final class CallMetricRecorder { private double memoryUtilizationMetric = 0; private volatile boolean disabled; - public static final class CallMetricReport { - private double cpuUtilization; - private double memoryUtilization; - private Map requestCostMetrics; - private Map utilizationMetrics; - - /** - * A gRPC object of orca load report. LB policies listening at per-rpc or oob orca load reports - * will be notified of the metrics data in this data format. - */ - CallMetricReport(double cpuUtilization, double memoryUtilization, - Map requestCostMetrics, - Map utilizationMetrics) { - this.cpuUtilization = cpuUtilization; - this.memoryUtilization = memoryUtilization; - this.requestCostMetrics = checkNotNull(requestCostMetrics, "requestCostMetrics"); - this.utilizationMetrics = checkNotNull(utilizationMetrics, "utilizationMetrics"); - } - - public double getCpuUtilization() { - return cpuUtilization; - } - - public double getMemoryUtilization() { - return memoryUtilization; - } - - public Map getRequestCostMetrics() { - return requestCostMetrics; - } - - public Map getUtilizationMetrics() { - return utilizationMetrics; - } - } - /** * Returns the call metric recorder attached to the current {@link Context}. If there is none, * returns a no-op recorder. @@ -201,13 +163,13 @@ Map finalizeAndDump() { * * @return a per-request ORCA reports containing all saved metrics. */ - CallMetricReport finalizeAndDump2() { + MetricReport finalizeAndDump2() { Map savedRequestCostMetrics = finalizeAndDump(); Map savedUtilizationMetrics = utilizationMetrics.get(); if (savedUtilizationMetrics == null) { savedUtilizationMetrics = Collections.emptyMap(); } - return new CallMetricReport(cpuUtilizationMetric, + return new MetricReport(cpuUtilizationMetric, memoryUtilizationMetric, Collections.unmodifiableMap(savedRequestCostMetrics), Collections.unmodifiableMap(savedUtilizationMetrics) ); diff --git a/services/src/main/java/io/grpc/services/InternalCallMetricRecorder.java b/services/src/main/java/io/grpc/services/InternalCallMetricRecorder.java index 01f6cc6417c..97e5e5a0aa6 100644 --- a/services/src/main/java/io/grpc/services/InternalCallMetricRecorder.java +++ b/services/src/main/java/io/grpc/services/InternalCallMetricRecorder.java @@ -41,15 +41,13 @@ public static Map finalizeAndDump(CallMetricRecorder recorder) { return recorder.finalizeAndDump(); } - public static CallMetricRecorder.CallMetricReport finalizeAndDump2(CallMetricRecorder recorder) { + public static MetricReport finalizeAndDump2(CallMetricRecorder recorder) { return recorder.finalizeAndDump2(); } - public static CallMetricRecorder.CallMetricReport createMetricReport( - double cpuUtilization, double memoryUtilization, - Map requestCostMetrics, - Map utilizationMetrics) { - return new CallMetricRecorder.CallMetricReport(cpuUtilization, memoryUtilization, + public static MetricReport createMetricReport(double cpuUtilization, double memoryUtilization, + Map requestCostMetrics, Map utilizationMetrics) { + return new MetricReport(cpuUtilization, memoryUtilization, requestCostMetrics, utilizationMetrics); } } diff --git a/services/src/main/java/io/grpc/services/InternalMetricRecorder.java b/services/src/main/java/io/grpc/services/InternalMetricRecorder.java index 4519bf661c3..cd36c425ac8 100644 --- a/services/src/main/java/io/grpc/services/InternalMetricRecorder.java +++ b/services/src/main/java/io/grpc/services/InternalMetricRecorder.java @@ -29,7 +29,7 @@ public final class InternalMetricRecorder { private InternalMetricRecorder() { } - public static CallMetricRecorder.CallMetricReport getMetricReport(MetricRecorder recorder) { + public static MetricReport getMetricReport(MetricRecorder recorder) { return recorder.getMetricReport(); } } diff --git a/services/src/main/java/io/grpc/services/MetricRecorder.java b/services/src/main/java/io/grpc/services/MetricRecorder.java index 31c10083732..a576386e98b 100644 --- a/services/src/main/java/io/grpc/services/MetricRecorder.java +++ b/services/src/main/java/io/grpc/services/MetricRecorder.java @@ -86,8 +86,8 @@ public void clearMemoryUtilizationMetric() { memoryUtilization = 0; } - CallMetricRecorder.CallMetricReport getMetricReport() { - return new CallMetricRecorder.CallMetricReport(cpuUtilization, memoryUtilization, + MetricReport getMetricReport() { + return new MetricReport(cpuUtilization, memoryUtilization, Collections.emptyMap(), Collections.unmodifiableMap(metricsData)); } } diff --git a/services/src/main/java/io/grpc/services/MetricReport.java b/services/src/main/java/io/grpc/services/MetricReport.java new file mode 100644 index 00000000000..3b4ccf3e5f8 --- /dev/null +++ b/services/src/main/java/io/grpc/services/MetricReport.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.services; + +import static com.google.common.base.Preconditions.checkNotNull; + +import io.grpc.ExperimentalApi; +import java.util.Map; + +/** + * A gRPC object of orca load report. LB policies listening at per-rpc or oob orca load reports + * will be notified of the metrics data in this data format. + */ +@ExperimentalApi("https://github.com/grpc/grpc-java/issues/9381") +public final class MetricReport { + private double cpuUtilization; + private double memoryUtilization; + private Map requestCostMetrics; + private Map utilizationMetrics; + + MetricReport(double cpuUtilization, double memoryUtilization, + Map requestCostMetrics, + Map utilizationMetrics) { + this.cpuUtilization = cpuUtilization; + this.memoryUtilization = memoryUtilization; + this.requestCostMetrics = checkNotNull(requestCostMetrics, "requestCostMetrics"); + this.utilizationMetrics = checkNotNull(utilizationMetrics, "utilizationMetrics"); + } + + public double getCpuUtilization() { + return cpuUtilization; + } + + public double getMemoryUtilization() { + return memoryUtilization; + } + + public Map getRequestCostMetrics() { + return requestCostMetrics; + } + + public Map getUtilizationMetrics() { + return utilizationMetrics; + } +} diff --git a/services/src/test/java/io/grpc/services/CallMetricRecorderTest.java b/services/src/test/java/io/grpc/services/CallMetricRecorderTest.java index e6649d42887..93745d53ed7 100644 --- a/services/src/test/java/io/grpc/services/CallMetricRecorderTest.java +++ b/services/src/test/java/io/grpc/services/CallMetricRecorderTest.java @@ -47,7 +47,7 @@ public void dumpDumpsAllSavedMetricValues() { recorder.recordCpuUtilizationMetric(0.1928); recorder.recordMemoryUtilizationMetric(47.4); - CallMetricRecorder.CallMetricReport dump = recorder.finalizeAndDump2(); + MetricReport dump = recorder.finalizeAndDump2(); Truth.assertThat(dump.getUtilizationMetrics()) .containsExactly("util1", 154353.423, "util2", 0.1367, "util3", 1437.34); Truth.assertThat(dump.getRequestCostMetrics()) @@ -76,7 +76,7 @@ public void lastValueWinForMetricsWithSameName() { recorder.recordMemoryUtilizationMetric(9384.0); recorder.recordUtilizationMetric("util1", 84323.3); - CallMetricRecorder.CallMetricReport dump = recorder.finalizeAndDump2(); + MetricReport dump = recorder.finalizeAndDump2(); Truth.assertThat(dump.getRequestCostMetrics()) .containsExactly("cost1", 4654.67, "cost2", 75.83); Truth.assertThat(dump.getMemoryUtilization()).isEqualTo(9384.0); diff --git a/xds/src/main/java/io/grpc/xds/orca/OrcaMetricReportingServerInterceptor.java b/xds/src/main/java/io/grpc/xds/orca/OrcaMetricReportingServerInterceptor.java index db624df7435..729277072c2 100644 --- a/xds/src/main/java/io/grpc/xds/orca/OrcaMetricReportingServerInterceptor.java +++ b/xds/src/main/java/io/grpc/xds/orca/OrcaMetricReportingServerInterceptor.java @@ -31,6 +31,7 @@ import io.grpc.protobuf.ProtoUtils; import io.grpc.services.CallMetricRecorder; import io.grpc.services.InternalCallMetricRecorder; +import io.grpc.services.MetricReport; /** * A {@link ServerInterceptor} that intercepts a {@link ServerCall} by running server-side RPC @@ -89,8 +90,7 @@ public void close(Status status, Metadata trailers) { next); } - private static OrcaLoadReport fromInternalReport( - CallMetricRecorder.CallMetricReport internalReport) { + private static OrcaLoadReport fromInternalReport(MetricReport internalReport) { return OrcaLoadReport.newBuilder() .setCpuUtilization(internalReport.getCpuUtilization()) .setMemUtilization(internalReport.getMemoryUtilization()) diff --git a/xds/src/main/java/io/grpc/xds/orca/OrcaOobUtil.java b/xds/src/main/java/io/grpc/xds/orca/OrcaOobUtil.java index 2e6a2891569..016c4ba0eb5 100644 --- a/xds/src/main/java/io/grpc/xds/orca/OrcaOobUtil.java +++ b/xds/src/main/java/io/grpc/xds/orca/OrcaOobUtil.java @@ -51,7 +51,7 @@ import io.grpc.internal.BackoffPolicy; import io.grpc.internal.ExponentialBackoffPolicy; import io.grpc.internal.GrpcUtil; -import io.grpc.services.CallMetricRecorder; +import io.grpc.services.MetricReport; import io.grpc.util.ForwardingLoadBalancerHelper; import io.grpc.util.ForwardingSubchannel; import java.util.HashMap; @@ -169,9 +169,9 @@ public interface OrcaOobReportListener { *

Note this callback will be invoked from the {@link SynchronizationContext} of the * delegated helper, implementations should not block. * - * @param report load report in the format of grpc {@link CallMetricRecorder.CallMetricReport}. + * @param report load report in the format of grpc {@link MetricReport}. */ - void onLoadReport(CallMetricRecorder.CallMetricReport report); + void onLoadReport(MetricReport report); } static final Attributes.Key ORCA_REPORTING_STATE_KEY = @@ -451,8 +451,7 @@ void handleResponse(OrcaLoadReport response) { callHasResponded = true; backoffPolicy = null; subchannelLogger.log(ChannelLogLevel.DEBUG, "Received an ORCA report: {0}", response); - CallMetricRecorder.CallMetricReport metricReport = - OrcaPerRequestUtil.fromOrcaLoadReport(response); + MetricReport metricReport = OrcaPerRequestUtil.fromOrcaLoadReport(response); for (OrcaOobReportListener listener : configs.keySet()) { listener.onLoadReport(metricReport); } diff --git a/xds/src/main/java/io/grpc/xds/orca/OrcaPerRequestUtil.java b/xds/src/main/java/io/grpc/xds/orca/OrcaPerRequestUtil.java index 4006e989545..0c2c7395b47 100644 --- a/xds/src/main/java/io/grpc/xds/orca/OrcaPerRequestUtil.java +++ b/xds/src/main/java/io/grpc/xds/orca/OrcaPerRequestUtil.java @@ -28,8 +28,8 @@ import io.grpc.Metadata; import io.grpc.internal.ForwardingClientStreamTracer; import io.grpc.protobuf.ProtoUtils; -import io.grpc.services.CallMetricRecorder; import io.grpc.services.InternalCallMetricRecorder; +import io.grpc.services.MetricReport; import java.util.ArrayList; import java.util.List; @@ -182,9 +182,9 @@ public interface OrcaPerRequestReportListener { *

Note this callback will be invoked from the network thread as the RPC finishes, * implementations should not block. * - * @param report load report in the format of grpc {@link CallMetricRecorder.CallMetricReport}. + * @param report load report in the format of grpc {@link MetricReport}. */ - void onLoadReport(CallMetricRecorder.CallMetricReport report); + void onLoadReport(MetricReport report); } /** @@ -252,7 +252,7 @@ public void inboundTrailers(Metadata trailers) { } } - static CallMetricRecorder.CallMetricReport fromOrcaLoadReport(OrcaLoadReport loadReport) { + static MetricReport fromOrcaLoadReport(OrcaLoadReport loadReport) { return InternalCallMetricRecorder.createMetricReport(loadReport.getCpuUtilization(), loadReport.getMemUtilization(), loadReport.getRequestCostMap(), loadReport.getUtilizationMap()); @@ -271,7 +271,7 @@ void addListener(OrcaPerRequestReportListener listener) { } void onReport(OrcaLoadReport report) { - CallMetricRecorder.CallMetricReport metricReport = fromOrcaLoadReport(report); + MetricReport metricReport = fromOrcaLoadReport(report); for (OrcaPerRequestReportListener listener : listeners) { listener.onLoadReport(metricReport); } diff --git a/xds/src/main/java/io/grpc/xds/orca/OrcaServiceImpl.java b/xds/src/main/java/io/grpc/xds/orca/OrcaServiceImpl.java index 6046fbd1441..1ea64f70bf2 100644 --- a/xds/src/main/java/io/grpc/xds/orca/OrcaServiceImpl.java +++ b/xds/src/main/java/io/grpc/xds/orca/OrcaServiceImpl.java @@ -26,9 +26,9 @@ import io.grpc.BindableService; import io.grpc.ServerServiceDefinition; import io.grpc.SynchronizationContext; -import io.grpc.services.CallMetricRecorder; import io.grpc.services.InternalMetricRecorder; import io.grpc.services.MetricRecorder; +import io.grpc.services.MetricReport; import io.grpc.stub.ServerCallStreamObserver; import io.grpc.stub.StreamObserver; import java.util.concurrent.ScheduledExecutorService; @@ -146,7 +146,7 @@ public void run() { } private OrcaLoadReport generateMetricsReport() { - CallMetricRecorder.CallMetricReport internalReport = + MetricReport internalReport = InternalMetricRecorder.getMetricReport(metricRecorder); return OrcaLoadReport.newBuilder().setCpuUtilization(internalReport.getCpuUtilization()) .setMemUtilization(internalReport.getMemoryUtilization()) diff --git a/xds/src/test/java/io/grpc/xds/orca/OrcaOobUtilTest.java b/xds/src/test/java/io/grpc/xds/orca/OrcaOobUtilTest.java index 5a981123ae0..4ae70bfba4a 100644 --- a/xds/src/test/java/io/grpc/xds/orca/OrcaOobUtilTest.java +++ b/xds/src/test/java/io/grpc/xds/orca/OrcaOobUtilTest.java @@ -62,7 +62,7 @@ import io.grpc.inprocess.InProcessServerBuilder; import io.grpc.internal.BackoffPolicy; import io.grpc.internal.FakeClock; -import io.grpc.services.CallMetricRecorder; +import io.grpc.services.MetricReport; import io.grpc.stub.StreamObserver; import io.grpc.testing.GrpcCleanupRule; import io.grpc.util.ForwardingLoadBalancerHelper; @@ -667,7 +667,7 @@ public void policiesReceiveSameReportIndependently() { orcaServiceImps[0].calls.peek().responseObserver.onNext(report); assertLog(subchannels[0].logs, "DEBUG: Received an ORCA report: " + report); // Only parent helper's listener receives the report. - ArgumentCaptor parentReportCaptor = + ArgumentCaptor parentReportCaptor = ArgumentCaptor.forClass(null); verify(mockOrcaListener1).onLoadReport(parentReportCaptor.capture()); assertThat(OrcaPerRequestUtilTest.reportEqual(parentReportCaptor.getValue(), @@ -679,7 +679,7 @@ public void policiesReceiveSameReportIndependently() { orcaServiceImps[0].calls.peek().responseObserver.onNext(report); assertLog(subchannels[0].logs, "DEBUG: Received an ORCA report: " + report); // Both helper receives the same report instance. - ArgumentCaptor childReportCaptor = + ArgumentCaptor childReportCaptor = ArgumentCaptor.forClass(null); verify(mockOrcaListener1, times(2)) .onLoadReport(parentReportCaptor.capture()); diff --git a/xds/src/test/java/io/grpc/xds/orca/OrcaPerRequestUtilTest.java b/xds/src/test/java/io/grpc/xds/orca/OrcaPerRequestUtilTest.java index 2b3de09b573..5f91b0fdcb1 100644 --- a/xds/src/test/java/io/grpc/xds/orca/OrcaPerRequestUtilTest.java +++ b/xds/src/test/java/io/grpc/xds/orca/OrcaPerRequestUtilTest.java @@ -31,7 +31,7 @@ import com.google.common.base.Objects; import io.grpc.ClientStreamTracer; import io.grpc.Metadata; -import io.grpc.services.CallMetricRecorder; +import io.grpc.services.MetricReport; import io.grpc.xds.orca.OrcaPerRequestUtil.OrcaPerRequestReportListener; import io.grpc.xds.orca.OrcaPerRequestUtil.OrcaReportingTracerFactory; import org.junit.Before; @@ -99,29 +99,28 @@ public void singlePolicyTypicalWorkflow() { OrcaReportingTracerFactory.ORCA_ENDPOINT_LOAD_METRICS_KEY, OrcaLoadReport.getDefaultInstance()); tracer.inboundTrailers(trailer); - ArgumentCaptor reportCaptor = + ArgumentCaptor reportCaptor = ArgumentCaptor.forClass(null); verify(orcaListener1).onLoadReport(reportCaptor.capture()); assertThat(reportEqual(reportCaptor.getValue(), OrcaPerRequestUtil.fromOrcaLoadReport(OrcaLoadReport.getDefaultInstance()))).isTrue(); } - static final class MetricsReportMatcher implements - ArgumentMatcher { - private CallMetricRecorder.CallMetricReport original; + static final class MetricsReportMatcher implements ArgumentMatcher { + private MetricReport original; - public MetricsReportMatcher(CallMetricRecorder.CallMetricReport report) { + public MetricsReportMatcher(MetricReport report) { this.original = report; } @Override - public boolean matches(CallMetricRecorder.CallMetricReport argument) { + public boolean matches(MetricReport argument) { return reportEqual(original, argument); } } - static boolean reportEqual(CallMetricRecorder.CallMetricReport a, - CallMetricRecorder.CallMetricReport b) { + static boolean reportEqual(MetricReport a, + MetricReport b) { return a.getCpuUtilization() == b.getCpuUtilization() && a.getMemoryUtilization() == b.getMemoryUtilization() && Objects.equal(a.getRequestCostMetrics(), b.getRequestCostMetrics()) @@ -163,9 +162,9 @@ public void twoLevelPoliciesTypicalWorkflow() { OrcaReportingTracerFactory.ORCA_ENDPOINT_LOAD_METRICS_KEY, OrcaLoadReport.getDefaultInstance()); childTracer.inboundTrailers(trailer); - ArgumentCaptor parentReportCap = + ArgumentCaptor parentReportCap = ArgumentCaptor.forClass(null); - ArgumentCaptor childReportCap = + ArgumentCaptor childReportCap = ArgumentCaptor.forClass(null); verify(orcaListener1).onLoadReport(parentReportCap.capture()); verify(orcaListener2).onLoadReport(childReportCap.capture()); From 0c287af2c05329ccac64995cab0c3cbe8036423a Mon Sep 17 00:00:00 2001 From: yifeizhuang Date: Fri, 22 Jul 2022 07:40:49 -0700 Subject: [PATCH 06/11] example: fix orca example to use new ORCA API (#9403) --- buildscripts/kokoro/unix.sh | 3 ++ ...tomBackendMetricsLoadBalancerProvider.java | 6 +-- .../orca/CustomBackendMetricsServer.java | 43 ++++++++++--------- .../java/io/grpc/services/MetricReport.java | 11 +++++ 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/buildscripts/kokoro/unix.sh b/buildscripts/kokoro/unix.sh index a0c256ac3dd..cfa20e0f36a 100755 --- a/buildscripts/kokoro/unix.sh +++ b/buildscripts/kokoro/unix.sh @@ -83,6 +83,9 @@ if [[ -z "${SKIP_TESTS:-}" ]]; then ../gradlew build $GRADLE_FLAGS popd # TODO(zpencer): also build the GAE examples + pushd examples/example-orca + ../gradlew build $GRADLE_FLAGS + popd fi LOCAL_MVN_TEMP=$(mktemp -d) diff --git a/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsLoadBalancerProvider.java b/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsLoadBalancerProvider.java index a63f86081ae..3a5e4f97a89 100644 --- a/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsLoadBalancerProvider.java +++ b/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsLoadBalancerProvider.java @@ -20,11 +20,11 @@ import io.grpc.LoadBalancer; import io.grpc.LoadBalancerProvider; import io.grpc.LoadBalancerRegistry; +import io.grpc.services.MetricReport; import io.grpc.util.ForwardingLoadBalancer; import io.grpc.util.ForwardingLoadBalancerHelper; import io.grpc.xds.orca.OrcaOobUtil; import io.grpc.xds.orca.OrcaPerRequestUtil; -import io.grpc.xds.shaded.com.github.xds.data.orca.v3.OrcaLoadReport; import java.util.concurrent.TimeUnit; /** @@ -87,7 +87,7 @@ public LoadBalancer.Subchannel createSubchannel(LoadBalancer.CreateSubchannelArg // otherwise it is treated as server minimum report interval. OrcaOobUtil.setListener(subchannel, new OrcaOobUtil.OrcaOobReportListener() { @Override - public void onLoadReport(OrcaLoadReport orcaLoadReport) { + public void onLoadReport(MetricReport orcaLoadReport) { System.out.println("Example load balancer received OOB metrics report:\n" + orcaLoadReport); } @@ -129,7 +129,7 @@ public LoadBalancer.PickResult pickSubchannel(LoadBalancer.PickSubchannelArgs ar OrcaPerRequestUtil.getInstance().newOrcaClientStreamTracerFactory( new OrcaPerRequestUtil.OrcaPerRequestReportListener() { @Override - public void onLoadReport(OrcaLoadReport orcaLoadReport) { + public void onLoadReport(MetricReport orcaLoadReport) { System.out.println("Example load balancer received per-rpc metrics report:\n" + orcaLoadReport); } diff --git a/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsServer.java b/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsServer.java index 5216bed27ac..da76b3b5b2c 100644 --- a/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsServer.java +++ b/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsServer.java @@ -16,6 +16,7 @@ package io.grpc.examples.orca; +import com.google.common.collect.ImmutableMap; import io.grpc.BindableService; import io.grpc.examples.helloworld.GreeterGrpc; import io.grpc.examples.helloworld.HelloReply; @@ -23,12 +24,13 @@ import io.grpc.Server; import io.grpc.ServerBuilder; import io.grpc.services.CallMetricRecorder; +import io.grpc.services.InternalCallMetricRecorder; import io.grpc.services.MetricRecorder; import io.grpc.stub.StreamObserver; import io.grpc.xds.orca.OrcaMetricReportingServerInterceptor; import io.grpc.xds.orca.OrcaServiceImpl; -import io.grpc.xds.shaded.com.github.xds.data.orca.v3.OrcaLoadReport; import java.io.IOException; +import java.util.Map; import java.util.Random; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -108,29 +110,30 @@ class GreeterImpl extends GreeterGrpc.GreeterImplBase { @Override public void sayHello(HelloRequest req, StreamObserver responseObserver) { HelloReply reply = HelloReply.newBuilder().setMessage("Hello " + req.getName()).build(); - OrcaLoadReport randomPerRpcMetrics = OrcaLoadReport.newBuilder() - .setCpuUtilization(random.nextDouble()) - .setMemUtilization(random.nextDouble()) - .putUtilization("util", random.nextDouble()) - .putRequestCost("cost", random.nextDouble()) - .build(); + double cpuUtilization = random.nextDouble(); + double memoryUtilization = random.nextDouble(); + Map utilization = ImmutableMap.of("util", random.nextDouble()); + Map requestCost = ImmutableMap.of("cost", random.nextDouble()); // Sets per-query backend metrics to a random test report. CallMetricRecorder.getCurrent() - .recordMemoryUtilizationMetric(randomPerRpcMetrics.getMemUtilization()) - .recordCallMetric("cost", randomPerRpcMetrics.getRequestCostOrDefault("cost", 0.0)) - .recordUtilizationMetric("util", randomPerRpcMetrics.getUtilizationOrDefault("util", 0.0)); - System.out.println("Hello World Server updates RPC metrics data:\n" + randomPerRpcMetrics); + .recordCpuUtilizationMetric(cpuUtilization) + .recordMemoryUtilizationMetric(memoryUtilization) + .recordCallMetric("cost", requestCost.get("cost")) + .recordUtilizationMetric("util", utilization.get("util")); + System.out.println(String.format("Hello World Server updates RPC metrics data:\n" + + "cpu: %s, memory: %s, request cost: %s, utilization: %s\n", + cpuUtilization, memoryUtilization, requestCost, utilization)); - OrcaLoadReport randomOobMetrics = OrcaLoadReport.newBuilder() - .setCpuUtilization(random.nextDouble()) - .setMemUtilization(random.nextDouble()) - .putUtilization("util", random.nextDouble()) - .build(); + cpuUtilization = random.nextDouble(); + memoryUtilization = random.nextDouble(); + utilization = ImmutableMap.of("util", random.nextDouble()); // Sets OOB backend metrics to a random test report. - metricRecorder.setCpuUtilizationMetric(randomOobMetrics.getCpuUtilization()); - metricRecorder.setMemoryUtilizationMetric(randomOobMetrics.getMemUtilization()); - metricRecorder.setAllUtilizationMetrics(randomOobMetrics.getUtilizationMap()); - System.out.println("Hello World Server updates OOB metrics data:\n" + randomOobMetrics); + metricRecorder.setCpuUtilizationMetric(cpuUtilization); + metricRecorder.setMemoryUtilizationMetric(memoryUtilization); + metricRecorder.setAllUtilizationMetrics(utilization); + System.out.println(String.format("Hello World Server updates OOB metrics data:\n" + + "cpu: %s, memory: %s, utilization: %s\n", + cpuUtilization, memoryUtilization, utilization)); responseObserver.onNext(reply); responseObserver.onCompleted(); } diff --git a/services/src/main/java/io/grpc/services/MetricReport.java b/services/src/main/java/io/grpc/services/MetricReport.java index 3b4ccf3e5f8..56ab150f8af 100644 --- a/services/src/main/java/io/grpc/services/MetricReport.java +++ b/services/src/main/java/io/grpc/services/MetricReport.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.MoreObjects; import io.grpc.ExperimentalApi; import java.util.Map; @@ -56,4 +57,14 @@ public Map getRequestCostMetrics() { public Map getUtilizationMetrics() { return utilizationMetrics; } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("cpuUtilization", cpuUtilization) + .add("memoryUtilization", memoryUtilization) + .add("requestCost", requestCostMetrics) + .add("utilization", utilizationMetrics) + .toString(); + } } From c7f0965f9e514d6cbe586ddda518af9d0a7d2c14 Mon Sep 17 00:00:00 2001 From: yifeizhuang Date: Mon, 25 Jul 2022 13:10:29 -0700 Subject: [PATCH 07/11] service: CalMetricRecorder.recordCallMetric is deprecated, use CalMetricRecorder.recordRequestCostMetric (#9410) --- .../testing/integration/TestServiceImpl.java | 2 +- .../io/grpc/services/CallMetricRecorder.java | 18 ++++++++++++++++++ .../grpc/services/CallMetricRecorderTest.java | 16 ++++++++-------- ...caMetricReportingServerInterceptorTest.java | 2 +- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceImpl.java b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceImpl.java index 0b18494fc01..a2c93d4ef8c 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceImpl.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceImpl.java @@ -141,7 +141,7 @@ private static void echoCallMetricsFromPayload(TestOrcaReport report) { recorder.recordUtilizationMetric(entry.getKey(), entry.getValue()); } for (Map.Entry entry : report.getRequestCostMap().entrySet()) { - recorder.recordCallMetric(entry.getKey(), entry.getValue()); + recorder.recordRequestCostMetric(entry.getKey(), entry.getValue()); } } diff --git a/services/src/main/java/io/grpc/services/CallMetricRecorder.java b/services/src/main/java/io/grpc/services/CallMetricRecorder.java index 2feb5e28e6f..d93f93606f9 100644 --- a/services/src/main/java/io/grpc/services/CallMetricRecorder.java +++ b/services/src/main/java/io/grpc/services/CallMetricRecorder.java @@ -17,6 +17,7 @@ package io.grpc.services; import com.google.common.annotations.VisibleForTesting; +import com.google.errorprone.annotations.InlineMe; import io.grpc.Context; import io.grpc.ExperimentalApi; import java.util.Collections; @@ -92,8 +93,25 @@ public CallMetricRecorder recordUtilizationMetric(String name, double value) { * * @return this recorder object * @since 1.47.0 + * @deprecated use {@link #recordRequestCostMetric} instead. + * This method will be removed in the future. */ + @Deprecated + @InlineMe(replacement = "this.recordRequestCostMetric(name, value)") public CallMetricRecorder recordCallMetric(String name, double value) { + return recordRequestCostMetric(name, value); + } + + /** + * Records a call metric measurement for request cost. + * If RPC has already finished, this method is no-op. + * + *

A latter record will overwrite its former name-sakes. + * + * @return this recorder object + * @since 1.48.1 + */ + public CallMetricRecorder recordRequestCostMetric(String name, double value) { if (disabled) { return this; } diff --git a/services/src/test/java/io/grpc/services/CallMetricRecorderTest.java b/services/src/test/java/io/grpc/services/CallMetricRecorderTest.java index 93745d53ed7..9811d1da92e 100644 --- a/services/src/test/java/io/grpc/services/CallMetricRecorderTest.java +++ b/services/src/test/java/io/grpc/services/CallMetricRecorderTest.java @@ -41,9 +41,9 @@ public void dumpDumpsAllSavedMetricValues() { recorder.recordUtilizationMetric("util1", 154353.423); recorder.recordUtilizationMetric("util2", 0.1367); recorder.recordUtilizationMetric("util3", 1437.34); - recorder.recordCallMetric("cost1", 37465.12); - recorder.recordCallMetric("cost2", 10293.0); - recorder.recordCallMetric("cost3", 1.0); + recorder.recordRequestCostMetric("cost1", 37465.12); + recorder.recordRequestCostMetric("cost2", 10293.0); + recorder.recordRequestCostMetric("cost3", 1.0); recorder.recordCpuUtilizationMetric(0.1928); recorder.recordMemoryUtilizationMetric(47.4); @@ -65,11 +65,11 @@ public void noMetricsRecordedAfterSnapshot() { @Test public void lastValueWinForMetricsWithSameName() { - recorder.recordCallMetric("cost1", 3412.5435); - recorder.recordCallMetric("cost2", 6441.341); - recorder.recordCallMetric("cost1", 6441.341); - recorder.recordCallMetric("cost1", 4654.67); - recorder.recordCallMetric("cost2", 75.83); + recorder.recordRequestCostMetric("cost1", 3412.5435); + recorder.recordRequestCostMetric("cost2", 6441.341); + recorder.recordRequestCostMetric("cost1", 6441.341); + recorder.recordRequestCostMetric("cost1", 4654.67); + recorder.recordRequestCostMetric("cost2", 75.83); recorder.recordMemoryUtilizationMetric(1.3); recorder.recordMemoryUtilizationMetric(3.1); recorder.recordUtilizationMetric("util1", 28374.21); diff --git a/xds/src/test/java/io/grpc/xds/orca/OrcaMetricReportingServerInterceptorTest.java b/xds/src/test/java/io/grpc/xds/orca/OrcaMetricReportingServerInterceptorTest.java index e0305b2e886..7ec7ef7b5e3 100644 --- a/xds/src/test/java/io/grpc/xds/orca/OrcaMetricReportingServerInterceptorTest.java +++ b/xds/src/test/java/io/grpc/xds/orca/OrcaMetricReportingServerInterceptorTest.java @@ -90,7 +90,7 @@ public void unaryRpc( entry.getValue()); } for (Map.Entry entry : applicationCostMetrics.entrySet()) { - CallMetricRecorder.getCurrent().recordCallMetric(entry.getKey(), + CallMetricRecorder.getCurrent().recordRequestCostMetric(entry.getKey(), entry.getValue()); } CallMetricRecorder.getCurrent().recordCpuUtilizationMetric(cpuUtilizationMetrics); From 80dc06714b9511ed8a8a542ff1d3a6926d2aee0c Mon Sep 17 00:00:00 2001 From: yifeizhuang Date: Mon, 25 Jul 2022 16:28:58 -0700 Subject: [PATCH 08/11] example-orca: fix lost streamTracerFactor (#9411) --- ...tomBackendMetricsLoadBalancerProvider.java | 28 ++++++++++++------- services/BUILD.bazel | 1 + 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsLoadBalancerProvider.java b/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsLoadBalancerProvider.java index 3a5e4f97a89..c42fb7cdc10 100644 --- a/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsLoadBalancerProvider.java +++ b/examples/example-orca/src/main/java/io/grpc/examples/orca/CustomBackendMetricsLoadBalancerProvider.java @@ -124,16 +124,24 @@ public LoadBalancer.PickResult pickSubchannel(LoadBalancer.PickSubchannelArgs ar return result; } // Installs ORCA per-query metrics reporting listener. - return LoadBalancer.PickResult.withSubchannel( - result.getSubchannel(), - OrcaPerRequestUtil.getInstance().newOrcaClientStreamTracerFactory( - new OrcaPerRequestUtil.OrcaPerRequestReportListener() { - @Override - public void onLoadReport(MetricReport orcaLoadReport) { - System.out.println("Example load balancer received per-rpc metrics report:\n" - + orcaLoadReport); - } - })); + final OrcaPerRequestUtil.OrcaPerRequestReportListener orcaListener = + new OrcaPerRequestUtil.OrcaPerRequestReportListener() { + @Override + public void onLoadReport(MetricReport orcaLoadReport) { + System.out.println("Example load balancer received per-rpc metrics report:\n" + + orcaLoadReport); + } + }; + if (result.getStreamTracerFactory() == null) { + return LoadBalancer.PickResult.withSubchannel( + result.getSubchannel(), + OrcaPerRequestUtil.getInstance().newOrcaClientStreamTracerFactory(orcaListener)); + } else { + return LoadBalancer.PickResult.withSubchannel( + result.getSubchannel(), + OrcaPerRequestUtil.getInstance().newOrcaClientStreamTracerFactory( + result.getStreamTracerFactory(), orcaListener)); + } } } } diff --git a/services/BUILD.bazel b/services/BUILD.bazel index 78a953d0882..2854b666ba1 100644 --- a/services/BUILD.bazel +++ b/services/BUILD.bazel @@ -43,6 +43,7 @@ java_library( "//api", "//context", "@com_google_code_findbugs_jsr305//jar", + "@com_google_errorprone_error_prone_annotations//jar", "@com_google_guava_guava//jar", ], ) From d56f8fbe1d2822bc4f91515dd471ad49493fc385 Mon Sep 17 00:00:00 2001 From: yifeizhuang Date: Mon, 11 Jul 2022 17:33:57 -0700 Subject: [PATCH 09/11] core: server stream should not deliver halfClose() when call is immediately cancelled(#9362) Fix a bug where the server stream delivers halfClose() to the call during cancellation. It happens when call has a short deadline. Server sees `INTERNAL, desc: Half-closed without a request` due to the bug. --- .../grpc/internal/AbstractServerStream.java | 4 +- .../internal/AbstractServerStreamTest.java | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/io/grpc/internal/AbstractServerStream.java b/core/src/main/java/io/grpc/internal/AbstractServerStream.java index 3513ec9346f..0079d95555e 100644 --- a/core/src/main/java/io/grpc/internal/AbstractServerStream.java +++ b/core/src/main/java/io/grpc/internal/AbstractServerStream.java @@ -217,8 +217,8 @@ public final void onStreamAllocated() { @Override public void deframerClosed(boolean hasPartialMessage) { deframerClosed = true; - if (endOfStream) { - if (!immediateCloseRequested && hasPartialMessage) { + if (endOfStream && !immediateCloseRequested) { + if (hasPartialMessage) { // We've received the entire stream and have data available but we don't have // enough to read the next frame ... this is bad. deframeFailed( diff --git a/core/src/test/java/io/grpc/internal/AbstractServerStreamTest.java b/core/src/test/java/io/grpc/internal/AbstractServerStreamTest.java index 65fc89be231..9f6c4922aa5 100644 --- a/core/src/test/java/io/grpc/internal/AbstractServerStreamTest.java +++ b/core/src/test/java/io/grpc/internal/AbstractServerStreamTest.java @@ -28,11 +28,13 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import com.google.common.util.concurrent.SettableFuture; import io.grpc.InternalStatus; import io.grpc.Metadata; import io.grpc.Status; +import io.grpc.StatusRuntimeException; import io.grpc.internal.AbstractServerStream.TransportState; import io.grpc.internal.MessageFramerTest.ByteWritableBuffer; import java.io.ByteArrayInputStream; @@ -108,6 +110,43 @@ public void messagesAvailable(MessageProducer producer) { assertNull("no message expected", streamListenerMessageQueue.poll()); } + @Test + public void noHalfCloseListenerOnCancellation() throws Exception { + final Queue streamListenerMessageQueue = new LinkedList<>(); + final SettableFuture closedFuture = SettableFuture.create(); + + stream.transportState().setListener(new ServerStreamListenerBase() { + @Override + public void messagesAvailable(StreamListener.MessageProducer producer) { + InputStream message; + while ((message = producer.next()) != null) { + streamListenerMessageQueue.add(message); + } + } + + @Override + public void halfClosed() { + if (streamListenerMessageQueue.isEmpty()) { + throw new StatusRuntimeException(Status.INTERNAL.withDescription( + "Half close without request")); + } + } + + @Override + public void closed(Status status) { + closedFuture.set(status); + } + }); + + ReadableBuffer buffer = mock(ReadableBuffer.class); + when(buffer.readableBytes()).thenReturn(1); + stream.transportState().inboundDataReceived(buffer, true); + Status cancel = Status.CANCELLED.withDescription("DEADLINE EXCEEDED"); + stream.transportState().transportReportStatus(cancel); + assertEquals(cancel, closedFuture.get(TIMEOUT_MS, TimeUnit.MILLISECONDS)); + verify(buffer).close(); + } + @Test public void queuedBytesInDeframerShouldNotBlockComplete() throws Exception { final SettableFuture closedFuture = SettableFuture.create(); From dd7449353054d585b3a22fa02104a5ad0be06acd Mon Sep 17 00:00:00 2001 From: yifeizhuang Date: Mon, 1 Aug 2022 20:36:10 +0000 Subject: [PATCH 10/11] Update README etc to reference 1.48.1 --- README.md | 30 ++++++++++++------------ cronet/README.md | 2 +- documentation/android-channel-builder.md | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 75d7db605dc..c780a9db26c 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ For a guided tour, take a look at the [quick start guide](https://grpc.io/docs/languages/java/quickstart) or the more explanatory [gRPC basics](https://grpc.io/docs/languages/java/basics). -The [examples](https://github.com/grpc/grpc-java/tree/v1.48.0/examples) and the -[Android example](https://github.com/grpc/grpc-java/tree/v1.48.0/examples/android) +The [examples](https://github.com/grpc/grpc-java/tree/v1.48.1/examples) and the +[Android example](https://github.com/grpc/grpc-java/tree/v1.48.1/examples/android) are standalone projects that showcase the usage of gRPC. Download @@ -43,18 +43,18 @@ Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`: io.grpc grpc-netty-shaded - 1.48.0 + 1.48.1 runtime io.grpc grpc-protobuf - 1.48.0 + 1.48.1 io.grpc grpc-stub - 1.48.0 + 1.48.1 org.apache.tomcat @@ -66,23 +66,23 @@ Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`: Or for Gradle with non-Android, add to your dependencies: ```gradle -runtimeOnly 'io.grpc:grpc-netty-shaded:1.48.0' -implementation 'io.grpc:grpc-protobuf:1.48.0' -implementation 'io.grpc:grpc-stub:1.48.0' +runtimeOnly 'io.grpc:grpc-netty-shaded:1.48.1' +implementation 'io.grpc:grpc-protobuf:1.48.1' +implementation 'io.grpc:grpc-stub:1.48.1' compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+ ``` For Android client, use `grpc-okhttp` instead of `grpc-netty-shaded` and `grpc-protobuf-lite` instead of `grpc-protobuf`: ```gradle -implementation 'io.grpc:grpc-okhttp:1.48.0' -implementation 'io.grpc:grpc-protobuf-lite:1.48.0' -implementation 'io.grpc:grpc-stub:1.48.0' +implementation 'io.grpc:grpc-okhttp:1.48.1' +implementation 'io.grpc:grpc-protobuf-lite:1.48.1' +implementation 'io.grpc:grpc-stub:1.48.1' compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+ ``` [the JARs]: -https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.48.0 +https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.48.1 Development snapshots are available in [Sonatypes's snapshot repository](https://oss.sonatype.org/content/repositories/snapshots/). @@ -114,7 +114,7 @@ For protobuf-based codegen integrated with the Maven build system, you can use com.google.protobuf:protoc:3.21.1:exe:${os.detected.classifier} grpc-java - io.grpc:protoc-gen-grpc-java:1.48.0:exe:${os.detected.classifier} + io.grpc:protoc-gen-grpc-java:1.48.1:exe:${os.detected.classifier} @@ -144,7 +144,7 @@ protobuf { } plugins { grpc { - artifact = 'io.grpc:protoc-gen-grpc-java:1.48.0' + artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1' } } generateProtoTasks { @@ -177,7 +177,7 @@ protobuf { } plugins { grpc { - artifact = 'io.grpc:protoc-gen-grpc-java:1.48.0' + artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1' } } generateProtoTasks { diff --git a/cronet/README.md b/cronet/README.md index f378574ba5c..0878c251cab 100644 --- a/cronet/README.md +++ b/cronet/README.md @@ -26,7 +26,7 @@ In your app module's `build.gradle` file, include a dependency on both `grpc-cro Google Play Services Client Library for Cronet ``` -implementation 'io.grpc:grpc-cronet:1.48.0' +implementation 'io.grpc:grpc-cronet:1.48.1' implementation 'com.google.android.gms:play-services-cronet:16.0.0' ``` diff --git a/documentation/android-channel-builder.md b/documentation/android-channel-builder.md index fcf13c66d58..c32db5f4d76 100644 --- a/documentation/android-channel-builder.md +++ b/documentation/android-channel-builder.md @@ -36,8 +36,8 @@ In your `build.gradle` file, include a dependency on both `grpc-android` and `grpc-okhttp`: ``` -implementation 'io.grpc:grpc-android:1.48.0' -implementation 'io.grpc:grpc-okhttp:1.48.0' +implementation 'io.grpc:grpc-android:1.48.1' +implementation 'io.grpc:grpc-okhttp:1.48.1' ``` You also need permission to access the device's network state in your From 6e2e18bb728793df32b2ba195a954ad380e546de Mon Sep 17 00:00:00 2001 From: yifeizhuang Date: Mon, 1 Aug 2022 20:36:36 +0000 Subject: [PATCH 11/11] Bump version to 1.48.1 --- build.gradle | 2 +- .../src/test/golden/TestDeprecatedService.java.txt | 2 +- compiler/src/test/golden/TestService.java.txt | 2 +- .../src/testLite/golden/TestDeprecatedService.java.txt | 2 +- compiler/src/testLite/golden/TestService.java.txt | 2 +- core/src/main/java/io/grpc/internal/GrpcUtil.java | 2 +- examples/android/clientcache/app/build.gradle | 10 +++++----- examples/android/helloworld/app/build.gradle | 8 ++++---- examples/android/routeguide/app/build.gradle | 8 ++++---- examples/android/strictmode/app/build.gradle | 8 ++++---- examples/build.gradle | 2 +- examples/example-alts/build.gradle | 2 +- examples/example-gauth/build.gradle | 2 +- examples/example-gauth/pom.xml | 4 ++-- examples/example-hostname/build.gradle | 2 +- examples/example-hostname/pom.xml | 4 ++-- examples/example-jwt-auth/build.gradle | 2 +- examples/example-jwt-auth/pom.xml | 4 ++-- examples/example-orca/build.gradle | 2 +- examples/example-tls/build.gradle | 2 +- examples/example-tls/pom.xml | 4 ++-- examples/example-xds/build.gradle | 2 +- examples/pom.xml | 4 ++-- 23 files changed, 41 insertions(+), 41 deletions(-) diff --git a/build.gradle b/build.gradle index 78de14c8f3f..2bb85a5a08b 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ subprojects { apply plugin: "net.ltgt.errorprone" group = "io.grpc" - version = "1.48.1-SNAPSHOT" // CURRENT_GRPC_VERSION + version = "1.48.1" // CURRENT_GRPC_VERSION repositories { maven { // The google mirror is less flaky than mavenCentral() diff --git a/compiler/src/test/golden/TestDeprecatedService.java.txt b/compiler/src/test/golden/TestDeprecatedService.java.txt index f5aa03f3e99..b2296d091c4 100644 --- a/compiler/src/test/golden/TestDeprecatedService.java.txt +++ b/compiler/src/test/golden/TestDeprecatedService.java.txt @@ -8,7 +8,7 @@ import static io.grpc.MethodDescriptor.generateFullMethodName; * */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.48.1-SNAPSHOT)", + value = "by gRPC proto compiler (version 1.48.1)", comments = "Source: grpc/testing/compiler/test.proto") @io.grpc.stub.annotations.GrpcGenerated @java.lang.Deprecated diff --git a/compiler/src/test/golden/TestService.java.txt b/compiler/src/test/golden/TestService.java.txt index 9aadaf37e45..24bea515ff8 100644 --- a/compiler/src/test/golden/TestService.java.txt +++ b/compiler/src/test/golden/TestService.java.txt @@ -8,7 +8,7 @@ import static io.grpc.MethodDescriptor.generateFullMethodName; * */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.48.1-SNAPSHOT)", + value = "by gRPC proto compiler (version 1.48.1)", comments = "Source: grpc/testing/compiler/test.proto") @io.grpc.stub.annotations.GrpcGenerated public final class TestServiceGrpc { diff --git a/compiler/src/testLite/golden/TestDeprecatedService.java.txt b/compiler/src/testLite/golden/TestDeprecatedService.java.txt index 5bd3d39e576..a7995110d7a 100644 --- a/compiler/src/testLite/golden/TestDeprecatedService.java.txt +++ b/compiler/src/testLite/golden/TestDeprecatedService.java.txt @@ -8,7 +8,7 @@ import static io.grpc.MethodDescriptor.generateFullMethodName; * */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.48.1-SNAPSHOT)", + value = "by gRPC proto compiler (version 1.48.1)", comments = "Source: grpc/testing/compiler/test.proto") @io.grpc.stub.annotations.GrpcGenerated @java.lang.Deprecated diff --git a/compiler/src/testLite/golden/TestService.java.txt b/compiler/src/testLite/golden/TestService.java.txt index ed21ce9a7d5..f60f3775d5b 100644 --- a/compiler/src/testLite/golden/TestService.java.txt +++ b/compiler/src/testLite/golden/TestService.java.txt @@ -8,7 +8,7 @@ import static io.grpc.MethodDescriptor.generateFullMethodName; * */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.48.1-SNAPSHOT)", + value = "by gRPC proto compiler (version 1.48.1)", comments = "Source: grpc/testing/compiler/test.proto") @io.grpc.stub.annotations.GrpcGenerated public final class TestServiceGrpc { diff --git a/core/src/main/java/io/grpc/internal/GrpcUtil.java b/core/src/main/java/io/grpc/internal/GrpcUtil.java index 7c2cec2d5fb..b8eaaa05970 100644 --- a/core/src/main/java/io/grpc/internal/GrpcUtil.java +++ b/core/src/main/java/io/grpc/internal/GrpcUtil.java @@ -203,7 +203,7 @@ public byte[] parseAsciiString(byte[] serialized) { public static final Splitter ACCEPT_ENCODING_SPLITTER = Splitter.on(',').trimResults(); - private static final String IMPLEMENTATION_VERSION = "1.48.1-SNAPSHOT"; // CURRENT_GRPC_VERSION + private static final String IMPLEMENTATION_VERSION = "1.48.1"; // CURRENT_GRPC_VERSION /** * The default timeout in nanos for a keepalive ping request. diff --git a/examples/android/clientcache/app/build.gradle b/examples/android/clientcache/app/build.gradle index ba8a1a8742a..508ebebc892 100644 --- a/examples/android/clientcache/app/build.gradle +++ b/examples/android/clientcache/app/build.gradle @@ -34,7 +34,7 @@ android { protobuf { protoc { artifact = 'com.google.protobuf:protoc:3.21.1' } plugins { - grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1' // CURRENT_GRPC_VERSION } } generateProtoTasks { @@ -54,12 +54,12 @@ dependencies { implementation 'com.android.support:appcompat-v7:27.0.2' // You need to build grpc-java to obtain these libraries below. - implementation 'io.grpc:grpc-okhttp:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-protobuf-lite:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-stub:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-okhttp:1.48.1' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-protobuf-lite:1.48.1' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-stub:1.48.1' // CURRENT_GRPC_VERSION implementation 'org.apache.tomcat:annotations-api:6.0.53' testImplementation 'junit:junit:4.12' testImplementation 'com.google.truth:truth:1.0.1' - testImplementation 'io.grpc:grpc-testing:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + testImplementation 'io.grpc:grpc-testing:1.48.1' // CURRENT_GRPC_VERSION } diff --git a/examples/android/helloworld/app/build.gradle b/examples/android/helloworld/app/build.gradle index 5777cbbcee2..fc498f3e04a 100644 --- a/examples/android/helloworld/app/build.gradle +++ b/examples/android/helloworld/app/build.gradle @@ -32,7 +32,7 @@ android { protobuf { protoc { artifact = 'com.google.protobuf:protoc:3.21.1' } plugins { - grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1' // CURRENT_GRPC_VERSION } } generateProtoTasks { @@ -52,8 +52,8 @@ dependencies { implementation 'com.android.support:appcompat-v7:27.0.2' // You need to build grpc-java to obtain these libraries below. - implementation 'io.grpc:grpc-okhttp:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-protobuf-lite:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-stub:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-okhttp:1.48.1' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-protobuf-lite:1.48.1' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-stub:1.48.1' // CURRENT_GRPC_VERSION implementation 'org.apache.tomcat:annotations-api:6.0.53' } diff --git a/examples/android/routeguide/app/build.gradle b/examples/android/routeguide/app/build.gradle index 763a8e6fdfd..a583cdc0f81 100644 --- a/examples/android/routeguide/app/build.gradle +++ b/examples/android/routeguide/app/build.gradle @@ -32,7 +32,7 @@ android { protobuf { protoc { artifact = 'com.google.protobuf:protoc:3.21.1' } plugins { - grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1' // CURRENT_GRPC_VERSION } } generateProtoTasks { @@ -52,8 +52,8 @@ dependencies { implementation 'com.android.support:appcompat-v7:27.0.2' // You need to build grpc-java to obtain these libraries below. - implementation 'io.grpc:grpc-okhttp:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-protobuf-lite:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-stub:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-okhttp:1.48.1' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-protobuf-lite:1.48.1' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-stub:1.48.1' // CURRENT_GRPC_VERSION implementation 'org.apache.tomcat:annotations-api:6.0.53' } diff --git a/examples/android/strictmode/app/build.gradle b/examples/android/strictmode/app/build.gradle index 348610c244c..c6e608e7251 100644 --- a/examples/android/strictmode/app/build.gradle +++ b/examples/android/strictmode/app/build.gradle @@ -33,7 +33,7 @@ android { protobuf { protoc { artifact = 'com.google.protobuf:protoc:3.21.1' } plugins { - grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.48.1' // CURRENT_GRPC_VERSION } } generateProtoTasks { @@ -53,8 +53,8 @@ dependencies { implementation 'com.android.support:appcompat-v7:28.0.0' // You need to build grpc-java to obtain these libraries below. - implementation 'io.grpc:grpc-okhttp:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-protobuf-lite:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-stub:1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-okhttp:1.48.1' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-protobuf-lite:1.48.1' // CURRENT_GRPC_VERSION + implementation 'io.grpc:grpc-stub:1.48.1' // CURRENT_GRPC_VERSION implementation 'org.apache.tomcat:annotations-api:6.0.53' } diff --git a/examples/build.gradle b/examples/build.gradle index 6c891754bdb..7d9a24dacb3 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -22,7 +22,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1' // CURRENT_GRPC_VERSION def protobufVersion = '3.21.1' def protocVersion = protobufVersion diff --git a/examples/example-alts/build.gradle b/examples/example-alts/build.gradle index 40eb86c410e..b586a75c428 100644 --- a/examples/example-alts/build.gradle +++ b/examples/example-alts/build.gradle @@ -23,7 +23,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1' // CURRENT_GRPC_VERSION def protocVersion = '3.21.1' dependencies { diff --git a/examples/example-gauth/build.gradle b/examples/example-gauth/build.gradle index e44b9f0c574..43afeb4b87f 100644 --- a/examples/example-gauth/build.gradle +++ b/examples/example-gauth/build.gradle @@ -23,7 +23,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1' // CURRENT_GRPC_VERSION def protobufVersion = '3.21.1' def protocVersion = protobufVersion diff --git a/examples/example-gauth/pom.xml b/examples/example-gauth/pom.xml index e4b63a24437..23a5c2e9e38 100644 --- a/examples/example-gauth/pom.xml +++ b/examples/example-gauth/pom.xml @@ -6,13 +6,13 @@ jar - 1.48.1-SNAPSHOT + 1.48.1 example-gauth https://github.com/grpc/grpc-java UTF-8 - 1.48.1-SNAPSHOT + 1.48.1 3.21.1 1.7 diff --git a/examples/example-hostname/build.gradle b/examples/example-hostname/build.gradle index def41ed94a3..20afdda45a3 100644 --- a/examples/example-hostname/build.gradle +++ b/examples/example-hostname/build.gradle @@ -21,7 +21,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1' // CURRENT_GRPC_VERSION def protobufVersion = '3.21.1' dependencies { diff --git a/examples/example-hostname/pom.xml b/examples/example-hostname/pom.xml index aa3954ee4c8..dc50c9837c8 100644 --- a/examples/example-hostname/pom.xml +++ b/examples/example-hostname/pom.xml @@ -6,13 +6,13 @@ jar - 1.48.1-SNAPSHOT + 1.48.1 example-hostname https://github.com/grpc/grpc-java UTF-8 - 1.48.1-SNAPSHOT + 1.48.1 3.21.1 1.7 diff --git a/examples/example-jwt-auth/build.gradle b/examples/example-jwt-auth/build.gradle index 3e87053cd4f..867c77ae1a6 100644 --- a/examples/example-jwt-auth/build.gradle +++ b/examples/example-jwt-auth/build.gradle @@ -22,7 +22,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1' // CURRENT_GRPC_VERSION def protobufVersion = '3.21.1' def protocVersion = protobufVersion diff --git a/examples/example-jwt-auth/pom.xml b/examples/example-jwt-auth/pom.xml index 02092bbe2f0..0bc95caac44 100644 --- a/examples/example-jwt-auth/pom.xml +++ b/examples/example-jwt-auth/pom.xml @@ -7,13 +7,13 @@ jar - 1.48.1-SNAPSHOT + 1.48.1 example-jwt-auth https://github.com/grpc/grpc-java UTF-8 - 1.48.1-SNAPSHOT + 1.48.1 3.21.1 3.21.1 diff --git a/examples/example-orca/build.gradle b/examples/example-orca/build.gradle index c70d4806db5..d13fe2218eb 100644 --- a/examples/example-orca/build.gradle +++ b/examples/example-orca/build.gradle @@ -17,7 +17,7 @@ repositories { sourceCompatibility = 1.8 targetCompatibility = 1.8 -def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1' // CURRENT_GRPC_VERSION def protocVersion = '3.21.1' dependencies { diff --git a/examples/example-tls/build.gradle b/examples/example-tls/build.gradle index c6cb2a99e4c..71a7cf28579 100644 --- a/examples/example-tls/build.gradle +++ b/examples/example-tls/build.gradle @@ -23,7 +23,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1' // CURRENT_GRPC_VERSION def protocVersion = '3.21.1' dependencies { diff --git a/examples/example-tls/pom.xml b/examples/example-tls/pom.xml index 2939c576790..993b9e60d72 100644 --- a/examples/example-tls/pom.xml +++ b/examples/example-tls/pom.xml @@ -6,13 +6,13 @@ jar - 1.48.1-SNAPSHOT + 1.48.1 example-tls https://github.com/grpc/grpc-java UTF-8 - 1.48.1-SNAPSHOT + 1.48.1 3.21.1 2.0.53.Final diff --git a/examples/example-xds/build.gradle b/examples/example-xds/build.gradle index a0806a29604..c7f4b945bdb 100644 --- a/examples/example-xds/build.gradle +++ b/examples/example-xds/build.gradle @@ -22,7 +22,7 @@ targetCompatibility = 1.8 // Feel free to delete the comment at the next line. It is just for safely // updating the version in our release process. -def grpcVersion = '1.48.1-SNAPSHOT' // CURRENT_GRPC_VERSION +def grpcVersion = '1.48.1' // CURRENT_GRPC_VERSION def nettyTcNativeVersion = '2.0.31.Final' def protocVersion = '3.21.1' diff --git a/examples/pom.xml b/examples/pom.xml index 22bc0dc12f4..879f9b11b21 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,13 +6,13 @@ jar - 1.48.1-SNAPSHOT + 1.48.1 examples https://github.com/grpc/grpc-java UTF-8 - 1.48.1-SNAPSHOT + 1.48.1 3.21.1 3.21.1