Commit Graph

343 Commits

Author SHA1 Message Date
Chengyuan Zhang 25122f9e83
api: clean up duplicated method in InternalServerInterceptors (#8261) 2021-06-15 15:11:56 -07:00
Eric Anderson 5642e01243
Replace failOnVersionConflict() with custom requireUpperBoundDeps
failOnVersionConflict has never been good for us. It is equivalent to
Maven dependencyConvergence which we discourage our users to use because
it is too tempermental and _creates_ version skew issues over time.
However, we had no real alternative for determining if our deps would be
misinterpeted by Maven.

failOnVersionConflict has been a constant drain and makes it really hard
to do seemingly-trivial upgrades. As evidenced by protobuf/build.gradle
in this change, it also caused _us_ to introduce a version downgrade.

This introduces our own custom requireUpperBoundDeps implementation so
that we can get back to simple dependency upgrades _and_ increase our
confidence in a consistent dependency tree.
2021-06-11 14:01:18 -07:00
Chengyuan Zhang e5d0e9d9a8
api, core: support zero copy into protobuf (#8102)
Enables a codepath for zero-copy protobuf deserialization. Two new InputStream extension interfaces are added:

- HasByteBuffer: allows access to the underlying buffers containing inbound bytes directly without copying
- Detachable: allows customer marshaller to keep the buffers around until the application code is done with using the protobuf messages

Applications can implement a custom marshaller that takes over the ownership of ByteBuffers and wrap them into ByteStrings with protobuf's UnsafeByteOperations support. Then a RopeByteString, which is a in-place composite of ByteStrings can be created. This enables using the zero-copy codepath (requires immutable ByteBuffer indication) of CodedInputStream for deserialization.
2021-05-14 14:45:03 -07:00
Eric Anderson e08b9db208
Use @DoNotCall for static methods in Builders that throw
Since static methods are pseudo-inherited by Builder implementations but
are trivially accidentally used, we re-define static methods in each
builder to make them behave more like the caller would expect. However,
not all the methods actually work; some just throw because the caller
was certainly not getting what they would expect.

Annotating with `@DoNotCall` can expose the problems at compile time
instead of runtime. While `@Deprecated` would also be an option, it is a
bit harder to figure out the ramifications and whether we want to go
that route.

This change was suggested by a lint tool for XdsServerBuilder and it
seems appropriate so I applied it to the other similar cases I could
find.
2021-05-12 10:12:52 -07:00
Eric Anderson 16eb5a47ec Stabilize ChannelCredentials
Some of the experimental API annotations were changed to other issues or
became `@Internal` to match their related APIs.

Fixes #7479
2021-05-03 16:22:43 -07:00
Eric Anderson d42f3b8fcb Stabilize ServerCredentials
Some of the experimental API annotations were changed to other issues or
became @Internal to match their related APIs.

Fixes #7621
2021-05-03 16:10:24 -07:00
Chengyuan Zhang 9614738a7d
core, grpclb, xds: let leaf LB policies explicitly refresh name resolution when subchannel connection is broken (#8048)
Currently each subchannel implicitly refreshes the name resolution when its state changes to IDLE or TRANSIENT_FAILURE. That is, this feature is built into subchannel's internal implementation. Although it eliminates the burden of having LB implementations refreshing the resolver when connections to backends are broken, this is gives LB policies no chance to disable or override this refresh (e.g., in some complex load balancing hierarchy like xDS, LB policies may embed a resolver inside for resolving backends so the refreshing resolution operation should be hooked to the resolver embedded in the LB policy instead of the one in Channel).

In order to make this transition smoothly, we add a check to SubchannelImpl that checks if the LoadBalancer has explicitly called Helper.refreshNameResolution for broken subchannels created by it. If not, it logs a warning and do the refresh.

A temporary LoadBalancer.Helper API ignoreRefreshNameResolution() is added to avoid false-positive warnings for xDS that intentionally does not want a refresh. Once the migration is done, this should be deleted.
2021-04-16 10:49:06 -07:00
yifeizhuang 6a9c9901e4
grpclb: support multiple authorities in lb backends for all SRV records (#7951) 2021-03-11 13:29:41 -08:00
Chengyuan Zhang b5c0a4a97a Make addServices() a final method on ServerBuilder and delete from its forwarders. 2021-03-05 10:03:22 -08:00
Chengyuan Zhang 37b94b3074
api: delete deprecated NameResolver APIs (#7936)
Deletes deprecated (~2 years) NameResolver APIs that uses NameResolver.Helper/Attributes for passing information from Channel to resolver.
2021-03-04 13:08:18 -08:00
Chengyuan Zhang a598b973a3
api: add ServerBuilder.addServices() API (#7926) 2021-02-28 23:36:27 -08:00
Eric Anderson d937ec5baf api: Add mTLS and Trust/KeyManager Credentials API 2021-02-19 09:30:24 -08:00
Serhii Zabelnykov 9ba419adc0
api: add nullable annotation to trailersFromThrowable (#7856) 2021-02-08 23:39:38 -08:00
Sergii Tkachenko 461b10a907 services: add support for channelz.GetServer() 2021-02-01 19:33:16 -05:00
ZHANG Dapeng 92e7fd370b
core: user is responsible to override authority for resolvingOobChannelBuilder
ManagedChannelImpl should not override authority for createResolvingOobChannel(target, creds), because ManagedChannelImpl does not know what target and creds are.
2021-01-29 09:50:59 -08:00
ZHANG Dapeng 9437783838
core: enhance ManagedChannelBuilder.overrideAuthority()
Enhance `ManagedChannelBuilder.overrideAuthority()` to make it impossible to use a different authority to a backend by wrapping ClientTransportFactory.newClientTransport() and setting ClientTransportOptions’ authority. To avoid confusing the LB policy, it would need to keep the original addresses to return during `Subchannel.getAddresses()`

The class `OverrideAuthorityNameResolverFactory` is deleted and its logic is moved into `ManagedChannelImpl`.
2021-01-29 09:29:06 -08:00
Nick Hill 2072df9be6
Random acts of garbage reduction
I noticed some opportunities to reduce allocations on hot paths
2021-01-21 10:45:31 -08:00
Eric Anderson 03d04f1944 api: Reword retry javadoc to make clear service config is source of configuration
Multiple users have tried things like
`mcb.enableRetry().maxRetryAttempts(3)` and been confused when no
retries were performed. Providing a reference to the gRFC and
`defaultServiceConfig()` should greatly increase the clarity of how to
use the method.
2021-01-13 11:36:08 -08:00
Chengyuan Zhang b66d182bb9
api: delete LoadBalancer.Helper APIs that had been deprecated for a long time (#7793) 2021-01-11 15:25:35 -08:00
ZHANG Dapeng ccef406f89
api: fix LoadBalancer javadoc 2021-01-05 13:12:06 -08:00
Eric Anderson b3899087d0 api: Improve code clarity by using Arrays.copyOf()
As noticed by a linter
2020-12-23 13:08:01 -08:00
ZHANG Dapeng 90d61178a3
all: ChannelCredentials.withoutBearerTokens() and LoadBalancer.Helper API change (#7748)
API change (See go/grpc-rls-callcreds-to-server):

- Add `ChannelCredentials.withoutBearerTokens()`
- Add `createResolvingOobChannelBuilder(String, ChannelCredentials)`, `getChannelCredentials()` and `getUnsafeChannelCredentials()` for `LoadBalancer.Helper`

This PR does not include the implementation of `createResolvingOobChannelBuilder(String, ChannelCredentials)`.
2020-12-22 22:48:39 -08:00
ZHANG Dapeng af29777686
all: migrate to interceptor-based config selector
This is migration following #7610
2020-12-04 11:11:57 -08:00
ZHANG Dapeng ac2327deb7
api,core: interceptor-based config selector (#7610)
Interceptor-based config selector will be needed for fault injection.

Add `interceptor` field to `InternalConfigSelector.Result`. Keep `callOptions` and `committedCallback` fields for the moment, because it needs a refactoring to migrate the existing xds config selector implementation to the new API.
2020-11-30 09:16:22 -08:00
wanyingd1996 2bf5ef54da
api: Added documentation for Call onClose hanging problem 2020-11-19 12:45:16 -08:00
Sergii Tkachenko 79d2e0c326 core: fix typos in Forwarding* classes 2020-11-18 15:36:56 -05:00
Eric Anderson 980956d503 api: Expose ForwardingServerBuilder for XdsServerBuilder
This reduces ABI issues caused by returning the more precise
XdsServerBuilder in the API. See
https://github.com/grpc/grpc-java/issues/7552.
2020-11-18 11:31:24 -08:00
Eric Anderson 60319dad2d api: Add ServerCredentials 2020-11-13 11:13:33 -08:00
ST-DDT 566f16ea0b
api: Clarify expectations regarding ServerCall#close (#7580) 2020-11-02 11:13:36 -08:00
Sergii Tkachenko d314c68126
Fix builders ABI backward compatibility broken in v1.33.0
* fix channel builders ABI backward compatibility broken in v1.33.0
* fix server builders ABI backward compatibility broken in v1.33.0
* makes ForwardingServerBuilder package-private
2020-10-29 12:06:37 -04:00
ST-DDT b7355052c4
Add implementation note regarding server interceptors and thread locals 2020-10-13 13:11:16 -07:00
Chengyuan Zhang 7dbf6a2c1c
xds: clarify required and optional fields in config selector result (#7496) 2020-10-09 01:04:34 -07:00
Eric Anderson c8a94d1059 api: Add ChannelCredentials 2020-10-07 13:58:37 -05:00
Eric Anderson 4c1bab9ed5 Prepare for JUnit 4.13
It deprecates ExpectedException and Assert.assertThat(T, org.hamcrest.Matcher).
Without Java 8 we don't want to migrate away from ExpectedException at
this time. We tend to prefer Truth over Hamcrest, so I swapped the one
instance of Assert.assertThat() to use Truth. With this change we get a
warning-less build with JUnit 4.13. We don't yet upgrade because we
still need to support JUnit 4.12 for some use-cases, but will be able to
upgrade to 4.13 soon when they upgrade.
2020-09-28 17:07:50 -05:00
Chengyuan Zhang bf7a42dbd1
api, core: delete io.grpc.LoadBalancer.loadBalancingConfig attribute (#7440) 2020-09-18 12:54:48 -07:00
ZHANG Dapeng ee5b5929d5
api,netty: Fix TruthIncompatibleType 2020-09-15 11:22:44 -07:00
Philipp Kern 07012421ad
core: add accessor for bare method name in MethodDescriptor (#7339)
Added getBareMethodName and extractBareMethodName for accessing the unqualified method name.
2020-09-03 14:27:18 -07:00
Sergii Tkachenko 07b812b1f5 api, core: create ForwardingServerBuilder and ServerImplBuilder 2020-09-03 16:26:04 -04:00
Sergii Tkachenko 522e70d1d7 api: remove incomplete sentence in javadoc 2020-09-03 11:02:47 -04:00
Sergii Tkachenko 5cfbe1061a api: Fix a small typo in ForwardingChannelBuilderTest 2020-08-27 15:00:13 -04:00
Eric Anderson 03f83bbac2 api: Fix NameResolver.ConfigOrError javadoc
It appears getAttributes() javadoc was accidentally copied when
ConfigOrError was moved in commit 0244418d2. This restores the
documentation from before the move.
2020-08-24 10:24:23 -07:00
wanyingd1996 6eced95a54
api: removed deprecated method blockingExecutor (#7242) 2020-08-12 15:29:30 -07:00
Eric Anderson 020fb36753 Fix lint warnings 2020-08-07 14:49:50 -05:00
Eric Anderson e92b2275f9 Update to Error Prone 2.4
Most of the changes should be semi-clear why they were made. However, BadImport
may not be as obvious: https://errorprone.info/bugpattern/BadImport . That
impacted classes named Type, Entry, and Factory. Also
PublicContructorForAbstractClass:
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass

The JdkObsolete issue is already resolved but is not yet in a release.
2020-08-06 10:56:16 -05:00
Eric Anderson 80d62bfce2 Upgrade to Mockito 3.3.3
verifyZeroInteractions has the same behavior as verifyNoMoreInteractions. It
was deprecated in Mockito 3.0.1 and replaced with verifyNoInteractions, which
does not change behavior depending on previous verify() calls. All instances
were replaced with verifyNoInteractions, except those in
ApplicationThreadDeframerTest which were replaced with verifyNoMoreInteractions
since there is a verify() call in `@Before`.
2020-08-06 10:49:23 -05:00
Chengyuan Zhang 1ed24feecd
xds: include a status for the result of ConfigSelector (#7260) 2020-07-30 15:21:38 -07:00
ZHANG Dapeng 9f56b8cea2
api: change ConfigSelector.Result to use callback instead of interceptor
We found that the interceptor approach for `ConfigSelector` would be adding a layer of indirection for no gain: The API Result selectConfig(LoadBalancer.PickSubchannelArgs args) consumes headers among other inputs, because route matching might need to match the headers; and the API produces ClientInterceptor among other outputs. But the headers is not available until clientCall.start(listner, headers), whereas the interceptor need be applied to the call before clientCall.start(). So the input is not available until the output is applied. That means we will need to delay calling the downstream newCall() (which will either be RealChannel or the interceptor) until start() is called.

So we want to change to the other approach similar to what c-core is taking: Have `Result(Object config, CallOptions, Runnable committedCallback)`, where CallOption is the selector modified CallOption, and committedCallback is used to monitor the call lifecycle.
2020-07-17 13:33:44 -07:00
ZHANG Dapeng d342b111f9
api: add InternalConfigSelector abstract class 2020-07-16 13:52:03 -07:00
Eric Anderson 2dab629a0a api: Deprecate ManagedChannelBuilder.nameResolverFactory
It has been our intention for years to remove nameResolverFactory. We should
make it clear to users to avoid new code depending on it and so they can tell
us why they need it so we can provide replacements.
2020-06-30 14:34:35 -05:00
Eric Anderson debc3cdc79 api: Add documentation for Provider SPI discovery 2020-06-30 14:34:35 -05:00
Jihun Cho f5258dca17
api,core: add LoadBalancer.Helper#createResolvingOobChannelBuilder api (#7136) 2020-06-17 12:36:14 -07:00
Elliotte Rusty Harold 417d7700dd
deps: Update guava to 29.0 (#7079) 2020-06-03 13:48:02 -07:00
Eric Anderson 146857952c api: Remove ref to deleted InternalNotifyOnServerBuild 2020-06-02 07:28:44 -07:00
Kun Zhang 96a32ed768
core/doc: clarify when ClientCall.cancel() can be called.
The original javadoc may be misunderstood as "one must call
halfClose() before calling cancel()".
2020-05-07 18:41:22 -07:00
ZHANG Dapeng 0044f8ce56
all: migrate gradle build to java-library plugin
- Use gradle configuration `api` for dependencies that are part of grpc public api signatures.
- Replace deprecated gradle configurations `compile`, `testCompile`, `runtime` and `testRuntime`.
- With minimal change in dependencies: If we need dep X and Y to compile our code, and if X transitively depends on Y, then our build would still pass even if we only include X as `compile`/`implementation` dependency for our project. Ideally we should include both X and Y explicitly as `implementation` dependency for our project, but in this PR we don't add the missing Y if it is previously missing.
2020-05-04 16:44:30 -07:00
ZHANG Dapeng ce9d217920
all: introduce gradle util functions to manage guava dependency
Define util function to exclude guava's transitive dependencies jsr305 and animal-sniffer-annotations, and always manually add them as runtimeOnly dependency. error_prone_annotations is an exception: It is also excluded but manually added not as runtimeOnly. It must always compile with guava, otherwise users will see warning spams if guava is in the compile classpath but error_prone_annotations is not.
2020-05-01 22:59:28 -07:00
Chengyuan Zhang a423900491
api, core, services: make ProtoReflectionService interceptor compatible (#6967)
Eliminate the hack of InternalNotifyOnBuild mechanism for letting ProtoReflectionService get access to the Sever instance, which makes ProtoReflectionService incompatible with server interceptors. This change put the Server instance into the Context and let the ProtoReflectionService RPC obtain it in its RPC Context. Also enhanced ProtoReflectionService so that one service instance can be used across multiple servers.
2020-05-01 10:39:38 -07:00
Eric Anderson 4674b27736 api,stub: Improve waitForReady documentation 2020-04-30 16:03:52 -07:00
Kun Zhang 54cac75d47
core: refine LoadBalancer javadoc (#6950)
Update renamed components and references to deprecated APIs.
2020-04-20 15:51:36 -07:00
Jihun Cho 68297d6d7c
core: implement Helper#createResolvingOobChannel (#6923) 2020-04-17 16:07:38 -07:00
ST-DDT c89bf49b6a
api: Fix javadoc reference to deprecated method (#6894) 2020-04-02 16:43:28 -07:00
Chris Nokleberg e081f414a7
core: copy the SchemaDescriptor when rebuilding descriptor (#6851)
useMarshalledMessages works by duplicating a ServerServiceDefinition while replacing just the marshallers. It currently does not copy over the SchemaDescriptors, which breaks at least the ProtoReflectionService.
2020-03-30 14:07:24 -07:00
Chris Nokleberg a4275b63f4
core: preserve KnownLength when wrapping InputStream (#6852)
useInputStreamMessages ensures that the InputStream supports marking by wrapping the stream in a BufferedInputStream if markSupported() returns false. This change uses a new subclass of BufferedInputStream that also implements KnownLength, when the original stream also implements KnownLength.
2020-03-30 10:09:15 -07:00
Eric Anderson 47d545ad70 api: Fix MethodType documentation overspecification
The server does not _have_ to wait until half close in CLIENT_STREAMING, and
commonly wouldn't in error cases. {client,server}SendsOneMessage were way
over-specifying the behavior and included unnecessary and incorrect words like
"immediately." Those methods shouldn't be the defining the behavior in that
much precision anyway; that would be the job of the individual enum values, if
anything.
2020-03-09 12:16:01 -07:00
Chengyuan Zhang 6a7e47b8a5
core, grpclb: change policy selection strategy for Grpclb policy (take two: move logic of querying SRV into Grpclb's own resolver) (#6723)
Eliminated the code path of resolving Grpclb balancer addresses in grpc-core and moved it into GrpclbNameResolver, which is a subclass of DnsNameResolver. Main changes:

- Slightly changed ResourceResolver and its JNDI implementation. ResourceResolver#resolveSrv(String) returns a list of SrvRecord so that it only parse SRV records and does nothing more. It's gRPC's name resolver's logic to use information parsed from SRV records.

- Created a GrpclbNameResolver class that extends DnsNameResolver. Logic of using information from SRV records to set balancer addresses as ResolutionResult attributes is implemented in GrpclbNameResolver only.

- Refactored DnsNameResolver, mainly the resolveAll(...) method. Logics for resolving backend addresses and service config are modularized into resolveAddresses() and resolveServiceConfig() methods respectively. They are shared implementation for subclasses (i.e., GrpclbNameResolver).
2020-03-02 01:03:25 -08:00
Jihun Cho 2162ad0436
service: HealthCheckingLoadBalancerFactory using its own attribute (#6704) 2020-02-28 17:11:20 -08:00
ZHANG Dapeng 5677a0b723
api,netty: fix MethodDescriptor and InternalKnownTransport for netty-shaded
Resolves #6765
2020-02-27 12:53:11 -08:00
Chengyuan Zhang 3955e4e184
api: fix Javadoc warnings. (#6763) 2020-02-26 11:51:01 -08:00
Eric Anderson dd8165b2a7 api: Add ExperimentalApi to Metadata.BinaryStreamMarshaller
This was missed in d1078591 and the API has not yet been released.
2019-12-27 13:33:46 -08:00
Jihun Cho 90969b3471
core: make service config error handling optional implementation (#6564) 2019-12-26 15:07:20 -08:00
ST-DDT 2afe13487c api: Fix javadoc for ManagedChannelBuilder#forTarget(String)
The dns scheme is only the default scheme with grpc-java. Other
libraries could add more NameResolvers and thus change the default. For
compatibility reasons, the schema should therefore be specified
explicitly.
2019-12-16 15:51:53 -08:00
Dounan Shi 9e02cf089e Gracefully shutdown example servers (#6512) 2019-12-13 16:19:45 -08:00
markb74 d107859145 Support for lazily serialized values in Metadata.
First add a new a Metadata.BinaryStreamMarshaller interface which
serializes to/from instances of InputStream, and a corresponding
Key.of() factory method.

Values set with this type of key will be kept unserialized internally,
alongside a reference to the Marshaller. A new method
InternalMetadata.serializePartial(), returns values which are either
byte[] or InputStream, and allows transport-specific handling of
lazily-serialized values.

For the regular serialize() method, stream-marshalled values will be
converted to byte[] via an InputStreams.
2019-12-12 15:34:30 -08:00
Tomo Suzuki 80699f8be9 all: bump Animal-sniffer-annotation to 1.18 (#6488) 2019-12-05 13:15:59 -08:00
Chengyuan Zhang eb21c646b2
api, core: make scheduled executor service accessible for NameResolver.Args (#6455)
Added new API on NameResolver.Args to access ScheduledExecutorService, which is wrapped transport executor.
2019-11-21 16:14:13 -08:00
ZHANG Dapeng 2d454d478c
Revert "Revert "all: remove deprecated usePlaintext(boolean)""
This reverts commit 316a739e67.
2019-11-18 16:53:52 -08:00
Chengyuan Zhang 86bfefdaf2
api, core: make channel logger accessible through NameResolver.Args (#6430) 2019-11-18 16:33:39 -08:00
Chengyuan Zhang 94eb93bd3a
api: enforce NameResolver.Args creation with builder (#6437) 2019-11-18 15:31:44 -08:00
Eric Anderson 4dba65bad4 api: Rename blockingExecutor to offloadExecutor
The API review for #6279 came up with a more meaningful name that
better explains the intent. A setter for the old name was left in
ManagedChannelBuilder to ease migration to the new name by current
users.
2019-11-04 13:16:08 -08:00
sanjaypujare 7dbf12fe2a
api,stub : fix 2 typos (CallCredentials2 to CallCredentials and javadoc comment in AbstractStub) (#6343) 2019-10-28 10:03:49 -07:00
Carl Mastrangelo 4503a233f4 api: stabilize safe and idempotent methods in MethodDescriptor 2019-10-22 10:59:11 -07:00
Jihun Cho ae11b9facc
api,core,stub: fix lint errors (#6305) 2019-10-18 17:30:00 -07:00
Jihun Cho eef47b26b8
core,grpclb: DnsNameResolver will use srv record by default if grpclb (#6298) 2019-10-18 13:00:47 -07:00
Eric Anderson 40f401d0e7 api: Clarify setting safe/idempotent may change other value 2019-10-17 10:01:34 -07:00
Eric Anderson 9eca2dcc4f api: Add ExperimentalApi annotations for blockingExecutor
These should have been present when initially added in #6238, but we forgot.
2019-10-16 13:58:55 -07:00
Eric Anderson 3ce5df3f78 api: Safe implies idempotent 2019-10-16 13:29:38 -07:00
Eric Anderson fa45a71ec9 api: Allow streaming methods to be safe 2019-10-16 10:08:42 -07:00
Grant Oakley adcfb3e623 api,core: Adds an Executor field to NameResolver.Args.
Adds an Executor to NameResolver.Args, which is optionally set on ManagedChannelBuilder. This allows NameResolver implementations to avoid creating their own thread pools if the application already manages its own pools.

Addresses #3703.
2019-10-14 08:46:26 -07:00
ZHANG Dapeng 316a739e67
Revert "all: remove deprecated usePlaintext(boolean)"
This reverts commit 296857b4e7.
2019-10-10 15:56:47 -07:00
ZHANG Dapeng 296857b4e7
all: remove deprecated usePlaintext(boolean) 2019-10-08 09:27:39 -07:00
ZHANG Dapeng 90b3c88fe2
api: avoid infinite loop in handleResolvedAddresses
If a `LoadBalancer` implementation does not override `handleResolvedAddressGroups()`, or overrides `handleResolvedAddressGroups()` but calls `super.handleResolvedAddressGroups()` at the beginning or the end, it will be trapped in an infinite loop.
2019-10-03 15:58:18 -07:00
Jihun Cho e9ac1b4a76
all: update modules to wait until other module's sourceSet is available (#6232) 2019-10-02 15:05:44 -07:00
ZHANG Dapeng 19b09160c9
all: stabilize ManagedChannelBuilder.usePlaintext() 2019-09-18 15:16:31 -07:00
Eric Anderson 2b945774b6 Apply animalsniffer plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 4215b80b81 Apply java plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 5b838e5284 Apply maven-publish plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 55ac6f08af Apply JMH plugin explicitly when needed 2019-09-13 09:42:17 -07:00
edr 132e8bc8dd core: Add Attributes.Key for authority in EquivalentAddressGroup (#6126)
This enables NameResolvers to dynamically provide authority for each
Subchannel

Fixes #4469
2019-09-11 20:35:18 -07:00
Kun Zhang f9509694b9
context: allow creating Deadline with custom Ticker. (#6031)
This makes Deadline more test-friendly. Next step is to allow
ServerBuilder to take a custom Ticker and use it for creating
incoming Deadlines. With both changes in, application logic will be
able to verify the Deadlines they set.
2019-07-31 11:26:51 -07:00
ZHANG Dapeng 4114433674
doc: Add hint to users who want an experimental API to be stabilized 2019-07-26 09:22:53 -07:00
Mike Kobit 6615f2fc9d Add `@Nullable` to getter for trailers on `StatusRuntimeException` since the constructors allows it to be null 2019-07-09 15:56:42 -07:00
ZHANG Dapeng ea08150551
doc: Update javadoc that hedging is supported 2019-06-20 14:46:44 -07:00
Carl Mastrangelo 74e945ceb4
core,netty: block server shutdown until the socket is unbound 2019-06-19 17:23:08 -07:00
Kun Zhang c92c9e71bb
core: SubchannelStateListener continues to receive updates after LoadBalancer is shutdown. (#5883)
No more methods on the `LoadBalancer` will be called after
`LoadBalancer#shutdown()` is called.  This includes
`LoadBalancer#handleSubchannelState()` too.  `SubchannelStateListener`
inherited this restriction.  However, this special case makes
`onSubchannelState(SHUTDOWN)` an unreliable way of being notified
about `Subchannel` SHUTDOWN, and may confuse/complicate a
wrapping `LoadBalancer` that expects the full notification (e.g., #5875).

The javadoc isn't clear whether this restriction applies.  I think
it's more useful to make it no apply.
2019-06-14 14:43:54 -07:00
ZHANG Dapeng b69b15fddb
javadoc: exclude internal APIs
Fixes #5858 in master
2019-06-10 13:36:21 -07:00
Carl Mastrangelo 7657523b28
all: update to error prone 2.3.3 2019-06-05 15:28:43 -07:00
Manuel Kollus e526891a2b api,protobuf-lite: solve code style issues 2019-05-31 12:49:30 -07:00
Eric Anderson 3c931b40b0 api: Mention similarity of synccontext to a dedicated thread
This is the conceptual model we use. Document it to help aid others'
understanding and make it easier to understand when it is appropriate to
use.
2019-05-30 10:52:22 -07:00
Kun Zhang af2c16d301
api: deprecate Helper.updateSubchannelAddresses() and add equivalent on Subchannel (#5802)
Resolves #5676
2019-05-30 09:16:38 -07:00
Eric Anderson bc2e1764f6 api,stub: Clarify isReady()/onReady() interaction semantics 2019-05-29 17:28:45 -07:00
Tim van der Lippe ad0893737e Migrate org.mockito.Matchers#any* to org.mockito.ArgumentMatchers
The former is deprecated and replaced by the latter in Mockito 2.
However, there is a functional difference: ArgumentMatchers will reject
`null` and check the type if the matcher specified a type (e.g.
`any(Class)` or `anyInt()`). `any()` will remain to accept anything.
2019-05-29 16:53:01 -07:00
Chengyuan Zhang d86d3dd363
all: fix lint and revert redundant lint fixes in #5570 (#5787)
* Revert "all: fix lint (#5770)"

This reverts commit 00d4cc29ad.

* all: fix lint and revert redundant lint fix in #5570
2019-05-24 01:02:12 -07:00
Carl Mastrangelo cdeafcf6e0
core: add discard method for Attributes 2019-05-23 10:34:04 -07:00
Chengyuan Zhang 00d4cc29ad
all: fix lint (#5770)
* fixed lint warnings

* remove unused arg for subchannel
2019-05-23 01:05:22 -07:00
Kun Zhang f8fffeff12
api: add Subchannel.getInternalSubchannel(). (#5773)
Previously PickResult's Subchannel must be the actual implementation
returned from the Channel's Helper, and Channel would cast it to the
implementation class in order to use it.  This will be broken if
Subchannel is wrapped in the case of hierarchical LoadBalancers.

getInternalSubchannel() is the guaranteed path for the Channel to get
the InternalSubchannel implementation.  It is friendly for wrapping.

Background: #5676
2019-05-22 13:52:28 -07:00
Eric Anderson b6720c9fe6 api: Don't yet deprecate NameResolver.Listener
We think NameResolver.Listener2 may still change, so don't yet encourage
people to migrate.

Fixes #5764
2019-05-21 17:49:08 -07:00
Eric Anderson 15a453d9ef api: Fix doc for default value of idleTimeout()
It appears the docs were not updated when this was changed in d74091f5, which
was first released in v1.1.
2019-05-21 13:48:57 -07:00
Kun Zhang a2595d9e7d
api/core/grpclb: add warning about calling Subchannel.requestConnection() outside of sync-context (#5757)
The pick_first policies in core and grpclb previously would call
Subchannel.requestConnection() from data-path.  They now will schedule
that call in the sync-context to avoid the warning.  They will only
call it for the first pick of each picker, to prevent storming the
sync-context.
2019-05-20 11:39:02 -07:00
Kun Zhang 7934594dfe
api: pass Subchannel state updates to SubchannelStateListener rather than LoadBalancer (take 2) (#5722)
This is a revised version of #5503 (62b03fd), which was rolled back in f8d0868. The newer version passes SubchannelStateListener to Subchannel.start() instead of SubchannelCreationArgs, which allows us to remove the Subchannel argument from the listener, which works as a solution for #5676.

LoadBalancers that call the old createSubchannel() will get start() implicitly called with a listener that passes updates to the deprecated LoadBalancer.handleSubchannelState(). Those who call the new createSubchannel() will have to call start() explicitly.

GRPCLB code is still using the old API, because it's a pain to migrate the SubchannelPool to the new API.  Since CachedSubchannelHelper is on the way, it's easier to switch to it when it's ready. Keeping
GRPCLB with the old API would also confirm the backward compatibility.
2019-05-17 16:37:41 -07:00
Kun Zhang ae14c8d061
api: temporarily remove the warning about sync-context in requestConnection(). (#5738) (#5752)
Contrary to #5736, we will still keep the sync-context requirement of
requestConnection(), because it prevents API fragmentation.
PickFirstLoadBalancer is the only known violator.  We will fix it on
master, but we don't want to make that change on 1.21.x because the
release is soon.  We simply remove the warning in this release so that
users won't be annoyed.

This supersedes #5736
2019-05-16 13:07:10 -07:00
Kun Zhang cec9ee368d
api: move SubchannelPicker.requestConnection() to LoadBalancer. (#5751)
We will require Subchannel.requestConnection() to be called from
sync-context (#5722), but SubchannelPicker.requestConnection() is
currently calling it with the assumption of thread-safety.  Actually
SubchannelPicker.requestConnection() is called already from
sync-context by ChannelImpl, it makes more sense to move this method
to LoadBalancer where all other methods are sync-context'ed, rather than
making SubchannelPicker.requestConnection() sync-context'ed and fragmenting
the SubchannelPicker API because pickSubchannel() is thread-safe.

C++ also has the requestConnection() equivalent on their LoadBalancer
interface.
2019-05-16 09:50:23 -07:00
Kun Zhang 0c17c4c995
api: make LoadBalancer.Helper and Subchannel further non-thread-safe. (#5718)
I see more cases of wrapping Helper and Subchannel during the work of
XdsLoadBalancer, we will require that all methods that involve mutable
state to be called from the Synchronization Context.  We will start
logging warnings first, and make them throw in a future release.

Helper.createSubchannel() is already doing so.  This change adds
warnings to the other eligible methods.

https://github.com/grpc/grpc-java/issues/5015
2019-05-09 18:13:46 -07:00
Kun Zhang 175a423c10
api: add getters for NameResolver.Args and NameResolverRegistry in LoadBalancer.Helper (#5685)
Hierarchical LoadBalancers such as xDS will need this to create NameResolvers to resolve locality target names.
2019-05-09 15:55:18 -07:00
Eric Anderson 980dd9671d api: Rename NameResolver.Observer to Listener2
This follows the sort of changes we've done in the past, where the '2'
implies "version 2." We can end up reclaiming the original name if we
wish in the future.

The main reason for this change is to avoid changing to Observer since
the rest of io.grpc consistently uses Listener.
2019-05-08 20:00:35 -07:00
Kun Zhang f8d0868e1d
Revert "core: pass Subchannel state updates to SubchannelStateListener rather than LoadBalancer (#5503)" (#5684)
This reverts commit 62b03fd7e6.

Effectively reverts its follow-up commits:
dc218b6d4d
405d8c3865
44840fe813
2019-05-08 09:01:45 -07:00
Eric Anderson 257bb546fd api: Discourage using ClientInterceptor for credentials 2019-05-06 17:03:44 -07:00
ZHANG Dapeng 72553433b3
api: fix LoadBalancer javadoc links 2019-05-06 11:17:35 -07:00
Kun Zhang 63f636b4b6
api: NameResolver.Args deprecates NameResolver.Helper. (#5664)
Having two Helpers (the other being LoadBalancer.Helper) is proven to
be confusing, and the one in NameResolver is fundamentally different
from the one from LoadBalancer, as the latter mutates the states while
the former doesn't. Renaming it to Args make it less awkward to
expose it to LoadBalancer, which is needed for creating NameResolvers
for per-locality routing in the XdsLoadBalancer.
2019-05-03 16:45:38 -07:00
Kun Zhang 973885457f
core: change ClientStreamTracer.StreamInfo to a final class with a builder (#5648)
As we are now endorsing the wrapping of ClientStreamTracers by
providing ForwardingClientStreamTracer, there is a need for altering
StreamInfo, especially CallOptions before it's passed onto the
delegate.  A Builder class and a toBuilder() provides a robust way
to copy the rest of the fields.

This is a breaking change for anybody who creates StreamInfo, which is
unlikely in non-test code, because StreamInfo was added as late as
1.20.0.
2019-04-30 09:10:56 -07:00
Chengyuan Zhang 44840fe813
api: fix bugs of missing to copy customOptions when converting to a new builder, also trash hashCode/equals (#5647)
* api: fix bugs of missing out customOptions in CreateSubchannelArgs toBuider, hashCode, equals

* trash equals/hashCode for CreateSubchannelArgs as they are problematic
2019-04-29 18:40:11 -07:00
Chengyuan Zhang 405d8c3865
api: patch CreateSubchannelArgs toString() with customOptions (#5646) 2019-04-29 14:54:59 -07:00
Chengyuan Zhang dc218b6d4d
api: augment CreateSubchannelArgs with custom options (#5640)
* api: augment CreateSubchannelArgs with custom options

* added unit tests

* added ExperimentalApi anntation with tracking issue
2019-04-26 13:59:37 -07:00
Kun Zhang d530641097
core: annotate experimental API's inner classes. (#5643)
Annotations on outer class don't show on the javadoc of inner classes.
2019-04-26 11:28:48 -07:00
Carl Mastrangelo 53a3f12666
api: expose if waitForReady has been set on CallOptions 2019-04-25 10:56:40 -07:00
Carl Mastrangelo ce6358e57f
core: add getService to MethodDescriptor 2019-04-24 17:45:41 -07:00
Eric Anderson 187fe9e146 Lint fixes 2019-04-23 14:51:34 -07:00
Carl Mastrangelo 04e07034f3
all: update to truth 0.44 2019-04-23 10:50:49 -07:00
Eric Anderson f4d48fec62
core: Add NameResolverRegistry
NameResolverRegistry takes on all the logic previously in
NameResolverProvider. But it also allows manual registration of
NameResolvers, which is useful when the providers have complex
construction or need objects injected into them.

This also avoids a circular dependency during class loading since
previously loading any Provider searched for all Providers via
ClassLoader since ClassLoader handling was static within the parent
class.

Fixes #5562
2019-04-22 10:22:46 -07:00
Jean de Klerk b363f80764 docs: add note about retrying UNAVAILABLE 2019-04-19 14:29:13 -07:00
Eric Anderson 7c0e14318e api: Stabilize MethodDescriptor.Marshaller
Fixes #1777
2019-04-19 10:32:42 -07:00
Kun Zhang 39e66fa22b
core: delete ManagedChannelBuilder.loadBalancerFactory() and all deprecated factories (#5480)
This has been deprecated since 1.18.0
2019-04-17 14:46:19 -07:00
Carl Mastrangelo a395eec4a3
core: update LB and NR API names
Updates #1770
2019-04-17 12:45:29 -07:00
Eric Anderson 80c3c992a6 core: Move io.grpc to grpc-api
io.grpc has fewer dependencies than io.grpc.internal. Moving it to a
separate artifact lets users use the API without bringing in the deps.
If the library has an optional dependency on grpc, that can be quite
convenient.

We now version-pin both grpc-api and grpc-core, since both contain
internal APIs.

I had to change a few tests in grpc-api to avoid FakeClock. Moving
FakeClock to grpc-api was difficult because it uses
io.grpc.internal.TimeProvider, which can't be moved since it is a
production class. Having grpc-api's tests depend on grpc-core's test
classes would be weird and cause a circular dependincy. Having
grpc-api's tests depend on grpc-core is likely possible, but weird and
fairly unnecessary at this point. So instead I rewrote the tests to
avoid FakeClock.

Fixes #1447
2019-04-16 21:45:40 -07:00