Commit Graph

210 Commits

Author SHA1 Message Date
pandaapo 1b94f48dc8
api: Fix CallOptions to be properly `@Immutable` (#9689)
Although CallOptions is annotated by @Immutable, its fields are not
final. So it's not truly immutable, namely not safe for unsynchronized
publication.

This commit adds final to all fields of CallOptions. Using internal
builder class to keep flexibility of constructing CallOptions.

Fixes #9658
2022-11-17 13:11:27 -08:00
RapperCL b8f142c1e7 reduce redundant judgment 2022-11-10 14:27:43 -08:00
yifeizhuang cff8bd8d87
doc: name resolver start() should not throw (#9589) 2022-10-05 16:22:30 -07:00
Kun Zhang 38b338228a
core: add getCallOptions() to CallCredentials.RequestInfo (#9538)
This is needed internally (b/134067789#comment20).
2022-09-13 08:55:05 -07:00
Larry Safran c27f2d5a57
[core,api,auth: Choose executor based on need for thread affinity (#9504)
* core,api,auth: Choose the callOptions executor when applying request metadata to credentials during newStream based upon whether AppEngineCredentials are being used as they require a specific thread to do the processing.

Add an interface to differentiate whether the specific thread is needed.

Fixes b/244209681
2022-09-02 21:55:38 -07:00
Terry Wilson 1f33fe6383
core: Assure that context cancellationCause is set (#9501)
core: Assure that context cancellationCause is set

Makes sure that whenever a context is in a cancelled state, we also have
a cancellationCause.
2022-08-31 10:43:22 -07:00
Terry Wilson 4b4cb0bd3b
api,core: Add LoadBalancer.acceptResolvedAddresses() (#9498)
Introduces a new acceptResolvedAddresses() method in LoadBalancer that
is to ultimately replace the existing handleResolvedAddresses(). The new
method allows the LoadBalancer implementation to reject the given
addresses by returning false from the method.

The long deprecated handleResolvedAddressGroups is also removed.
2022-08-31 08:36:50 -07:00
Terry Wilson 128688ae4d
Outlier detection load balancer (#9447)
New outlier detection load balancer.

Tracks all RPC results to the addresses it is configured with and periodically attempts
to detect outlier. It wraps a child load balancer from which it hides any addresses that
are deemed outliers.

As specified in gRFC A50: gRPC xDS Outlier Detection Support:
https://github.com/grpc/proposal/blob/master/A50-xds-outlier-detection.md
2022-08-18 08:46:30 -07:00
Larry Safran 778098b911
rls: fix RLS policy to not propagate status from control plane RPC to data plane RPC (#9413)
rls: Avoid library returning the status codes which the status spec document says that the library will never return when talking to RLS server.  Instead, always return UNAVAILABLE on errors.

* Provide context around error message from RLS server
2022-08-15 11:10:10 -07:00
Larry Safran 01d5bd47cb
Cleanup some of the warnings across the code base (#9445)
No logic changes, just cleans up warnings to make spotting real problems easier.

Remove "public" declarations on interfaces
Remove duplicate semicolons (Java lines ending in ";;")
Remove unneeded import
Change non-javadoc comment to not start with "/**"
Remove unneeded explicit type declarations from generics
Fix broken javadoc links
2022-08-15 11:06:31 -07:00
Eric Anderson 61f19d707a
Swap Animalsniffer to Java 8 and Android 19
Also added missing signatures. Swapping to version catalog will make
this process easier in the future.
2022-08-10 12:41:57 -07:00
Eric Anderson 2b50e405b1 core: Remove LB refreshNameResolver check
It's been 17 months since the check was introduced, which is plenty for
the migration. Leaving ignoreRefreshNameResolutionCheck() in-place to
let users delete their call sites. We'll remove the method after a few
releases.

Fixes #9409
2022-08-10 10:26:15 -07:00
Terry Wilson 7665d3850b
Revert "Add LoadBalancer.acceptResolvedAddresses() (#8742)" (#9414)
This reverts commit 70a29fbfe3.
2022-07-28 12:15:26 -07:00
Terry Wilson 70a29fbfe3
Add LoadBalancer.acceptResolvedAddresses() (#8742)
Introduces a new acceptResolvedAddresses() to the LoadBalancer.

This will now be the preferred way to handle addresses from the NameResolver. The existing handleResolvedAddresses() will eventually be deprecated.

The new method returns a boolean based on the LoadBalancers ability to use the provided addresses. If it does not accept them, false is returned. LoadBalancer implementations using the new method should no longer implement the canHandleEmptyAddressListFromNameResolution(), which will eventually be removed, along with handleResolvedAddresses().

Backward compatibility will be maintained so existing load balancers using handleResolvedAddresses() will continue to work.

Additionally the previously deprecated handleResolvedAddressGroups() method is removed.
2022-07-26 09:23:37 -07:00
yifeizhuang 027d36eee7
xds: xdsNameResolver match channel overrideAuthority in virtualHost matching (#9405) 2022-07-22 12:41:16 -07:00
Benjamin Peterson 50ebb5f864
api: Link to Status#asRuntimeException method in StatusRuntimeException javadocs. (#9373) 2022-07-14 21:04:25 +05:30
DNVindhya ef89bd3ac9
gcp-observability: Populate global interceptors from observability (#9309)
* Populate global interceptors from observability and added stackdriver exporters
2022-07-14 19:38:00 +05:30
Eric Anderson 0ff9f37b9e Use Gradle's task configuration avoidance APIs
This can avoid creating an additional 736 tasks (previously 502 out of
1591 were not created). That's not all that important as the build time
is essentially the same, but this lets us see the poor behavior of the
protobuf plugin in our own project and increase our understanding of how
to avoid task creation when developing the plugin. Of the tasks still
being created, protobuf is the highest contributor with 165 tasks,
followed by maven-publish with 76 and appengine with 53. The remaining
59 are from our own build, but indirectly caused by maven-publish.
2022-07-08 12:16:40 -07:00
Eric Anderson e96d04774b okhttp: Add server implementation 2022-07-01 12:38:01 -07:00
sanjaypujare c9a52eb83f
api,core: change ManagedChannel and Server Builders to use GlobalInterceptors (#9312)
* api,core: change ManagedChannel and Server Builders to use GlobalInterceptors
also added a getter in GlobalInterceptors to expose the set flag
2022-06-30 10:11:58 -07:00
Eric Anderson 69abec5a28
api: Explain security constraints of ATTR_AUTHORITY_OVERRIDE
Half of the text was copied from NameResolver.getServiceAuthority().
However, that method can't perform I/O (which would block) so more text
was appropriate here to mention the implications of having a remote
service provide the authority.

I noticed the text was lacking while discussing #9266.
2022-06-22 13:16:42 -07:00
Eric Anderson b06942d63b Use Gradle's version catalog
This moves our depedencies into a plain file that can be read and
updated by tooling. While the current tooling is not particularly better
than just using gradle-versions-plugin, it should put us on better
footing. gradle-versions-plugin is actually pretty nice, but will be
incompatible with Gradle 8, so we need to wait a bit to see what the
future holds.

Left libraries as an alias for libs to reduce the commit size and make
it easier to revert if we don't end up liking this approach.

We're using Gradle 7.3.3 where it was an incubating fetaure. But in
Gradle 7.4 is became stable.
2022-06-14 14:04:10 -07:00
Sergii Tkachenko 9cebe0aa2b
api: Add missing RunWith annotation to GlobalInterceptorsTest (#9258)
Internal build failed with 

```
grpc/api/src/test/java/io/grpc/GlobalInterceptorsTest.java:28: error: 
[JUnit4RunWithMissing] Test class may not be run because it is missing a @RunWith annotation
public class GlobalInterceptorsTest {
       ^
  Did you mean '@RunWith(JUnit4.class)' or 'public abstract class GlobalInterceptorsTest {'?
```
2022-06-10 10:30:42 -07:00
DNVindhya 395fae59f0
api: Add GlobalInterceptors API (#9235)
* added GlobalInterceptors API
2022-06-09 16:27:25 -07:00
Eric Anderson 01faeee877 api: Document illegal arguments for server connection management APIs
Most are not allowed to be zero. Grace period can be zero to immediately
close the connection when the age is hit. A zero permitKeepAliveTime()
simply doesn't enforce any limits on the client.

The choices here precisely matches the pre-existing Netty behavior, but
also seems to make sense in general.
2022-06-06 11:09:14 -07:00
Eric Anderson a2c0ae3295 api: Document Attributes.Key uses reference equality
The text here should be expanded once `keys()` is removed. But for now
this at least can make it clearer that the current behavior is on
purpose. The text here is the same as that in CallOptions.Key.

See https://github.com/grpc/grpc-java/issues/1764#issuecomment-1144935608
2022-06-06 11:08:51 -07:00
Eric Anderson a206cda1a8 Change Attributes.Key debug strings to reference the API of the key
Users appear to be doing `attributes.toString()` to find keys they are
interested in and then unable to find the name of the Key in our API.
They workaround the problem by scanning through `attributes.keys()`
looking for the key of interest. This is an abuse of the keys() API and
unnecessary user friction. They'd happily use the API if they just knew
where to find it.

I added internal to some strings to make it clear that you shouldn't go
looking to use it. There were many strings I didn't change. I focused on
keys most likely to be seen by users, which meant keys in grpc-api and
keys that are available via transport attributes.

See https://github.com/grpc/grpc-java/issues/1764#issuecomment-1139250061
2022-06-02 16:11:02 -07:00
Ovidiu Tirla a88f19fb4b
Expose SecurityLevel on server-side (#8943) 2022-05-16 17:26:10 -07:00
Eric Anderson b5e78d548d api: Ignore ClassCastExceptions for hard-coded providers
This was observed in the Bazel/Blaze build where io.grpc.util is a
separate target from the rest of core. During the build of a library
SecretRoundRobinLoadBalancerProvider was not on the classpath, and the
library was later included into a binary using grpc-core from Maven
Central which includes SecretRoundRobinLoadBalancerProvider.

```
java.util.ServiceConfigurationError: Provider io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider could not be instantiated java.lang.ClassCastException: class io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider cannot be cast to some.app.aaa.aab
```
2022-05-16 13:19:46 -07:00
Eric Anderson ba57a1d893 api: Add connection management APIs to ServerBuilder
These APIs were added to NettyServerBuilder for gRFC A8 and A9. They are
important enough that they shouldn't require using the perma-unstable
transport API to access. This change also allows using these methods
with grpc-netty-shaded.

Fixes #8991
2022-05-16 13:02:09 -07:00
sanjaypujare 41c027c11b
netty: implement UdsNameResolver and UdsNettyChannelProvider (#9113)
* netty: implement UdsNameResolver and UdsNettyChannelProvider
When the scheme is "unix:" we get the UdsNettyChannelProvider to
create a NettyChannelBuilder with DomainSocketAddress type and
other related params needed for UDS sockets
2022-05-02 16:41:50 -07:00
Sergii Tkachenko 7dc4fc929c
xds, api: minor cleanup to address linter suggestions (#9116) 2022-04-27 13:02:46 -07:00
sanjaypujare 538db03d56
api: add support for SocketAddress types in ManagedChannelProvider (#9076)
* api: add support for SocketAddress types in ManagedChannelProvider
also add support for SocketAddress types in NameResolverProvider
Use scheme in target URI to select a NameRseolverProvider and get
that provider's supported SocketAddress types.
implement selection in ManagedChannelRegistry of appropriate
ManagedChannelProvider based on NameResolver's SocketAddress types
2022-04-22 09:10:55 -07:00
Eric Anderson 40c929e39f android: Use InternalManagedChannelProvider instead of reflection
This fixes up cda0e9d to be compatible with Proguard without
configuration. Since the methods are now accessed directly there is no
need for manual -keep configuration.
2022-03-31 11:52:57 -07:00
yifeizhuang 7eeb411b1f
doc: add comment about callOptions executor behavior (#8913) 2022-02-11 15:07:09 -08:00
sanjaypujare a661515421
observability: revert previous visibility changes made in the provider APIs (#8889)
change visibility back to protected for certain methods of Providers
2022-02-04 08:38:46 -08:00
sanjaypujare bd156f98d6
observability: implement and integrate LoggingServerProvider into Observability (#8879) 2022-02-01 10:05:59 -08:00
sanjaypujare 881f747b7e
observability: implement Observability.grpcInit() and LoggingChannelProvider (#8872) 2022-01-31 10:37:54 -08:00
Penn (Dapeng) Zhang cf4cd65707 Revert "all: clean up code related to android api level less than 19"
This reverts commit 3ad4d9bfb7.
2022-01-18 10:14:50 -08:00
Penn (Dapeng) Zhang 3179bc3be0 Revert "use charset from StandardCharsets instead of 'Charset.forName' (#8779)"
This reverts commit a74a3ad834.
2022-01-18 10:14:50 -08:00
Eric Anderson 58a7ace6ac
Bump ErrorProne to 2.10.0
Previous versions of error prone were incompatible with Java 17 javac.

In grpc-api, errorprone is now api dependency because it is on a public
API.  I was happy to see that Gradle failed the build without the dep
change, although the error message wasn't super clear as to the cause.

It seems that previously -PerrorProne=false did nothing. I'm guessing
this is due to a behavior change of Gradle at some point. Swapping to
using the project does build without errorProne, although the build
fails with Javac complaining certain classes are unavailable. It's
unclear why. It doesn't seem to be caused by the error-prone plugin.
I've left it failing as a pre-existing issue.

ClientCalls/ServerCalls had Deprecated removed from some methods because
they were only deprecated in the internal class, not the API. And with
Deprecated, InlineMeSuggester complained.

I'm finding InlineMeSuggester to be overzealous, complaining about
package-private methods. In time we may figure out how to use it better,
or we may request changes to the checker in error-prone.
2022-01-12 12:06:27 -08:00
Jintao a74a3ad834
use charset from StandardCharsets instead of 'Charset.forName' (#8779)
Co-authored-by: Penn (Dapeng) Zhang <zdapeng@google.com>
2022-01-07 15:03:14 -08:00
Eric Anderson d44de5069d
Bump to Gradle 6.9 and update plugins
These changes make the build compatible with Gradle 7, except for
Android which requires plugin updates.

I removed animalsniffer from binder because it did nothing (as there
were no signatures) and it was failing after setting toolVersion. It
failed because animalsniffer is only compatible with java plugin. After
this change I put the withId(animalsniffer) loading inside the
withId(java) to avoid a plugin ordering failure. That made it safe again
for binder to load animalsniffer, but it is still best to remove the
plugin from binder as it is misleading.

I did not upgrade Android plugin versions as newer versions (even 3.6)
require dealing with androidx (#8421).
2022-01-07 09:54:50 -08:00
ZHANG Dapeng 3ad4d9bfb7
all: clean up code related to android api level less than 19 2022-01-07 08:13:32 -08:00
ZHANG Dapeng 042f9879d4
all: remove deprecated StreamInfo.transportAttrs (#8768)
APIs such as `StreamInfo.getTransportAttrs()` were [deprecated](860e97d12a (diff-aa4049f54d6d5d462700e9221344184a37d2068b3ba7d715abd417b1df5bf883R114)) since 1.41.0. Removing now.
2021-12-20 09:46:25 -08:00
Terry Wilson fc57cad4ec
Revert "Revert "core/auth: Remove CallCredentials2 (#8464)"" (#8572)
This reverts commit a91cc85dfd.
2021-10-05 10:34:44 -07:00
Eric Anderson 816a54a83b api: Add doc snippet to convert types for defaultServiceConfig()
Tested with Jackson's `new ObjectMapper().readValue(json, Map.class)`.

Fixes #8300
2021-09-27 14:14:35 -07:00
Eric Anderson 192688f1f2 netty: Requests with Connection header are malformed
Although this is part of HTTP/2 and should have already been handled
already, it was noticed as part of RBAC work to avoid matching
hop-by-hop headers. See gRFC A41.

Also add a warning if creating Metadata.Key for "Connection". Use this
to try to help diagnose a client if it happens to blindly copy headers
from HTTP/1, as PROTOCOL_ERROR is hard to debug.

This rolls-forward 6e89919 after it was reverted in 7669656, now that
the test proxy has been fixed.
2021-09-27 12:59:15 -07:00
Zhouyihai Ding e41df60bea
core: change the mapping from ChannelLogLevel to java.util.logging.Level
Instead of `ChannelLogLevel.{DEBUG,INFO}` mapping to the same java level, `ChannelLogLevel.{WARNING,ERROR}` will shame the same java level. This allows us to be able to independently control the visibility of `ChannelLogLevel.DEBUG` logs which are the most verbose.
2021-09-22 09:43:08 -07:00
ZHANG Dapeng 29d238afca
api,stub: clarify StreamObserver and Listener param type (#8544) 2021-09-21 10:38:41 -07:00