Commit Graph

369 Commits

Author SHA1 Message Date
Tim van der Lippe d35fbd7eee all: Update to Mockito 2
This is the public port of cl/238445847

Fixes #5319
2019-03-19 14:17:52 -07:00
Carl Mastrangelo 801cc5c189
core,netty,okhttp: propagate the subchannel logger to the transport 2019-03-04 15:16:53 -08:00
Kun Zhang 59a336c3ae
core: add internal transport attribute ATTR_CLIENT_EAG_ATTRS (#5420)
This is needed for GRPCLB pick_first support, which needs to attach
tokens to headers, and the tokens are per server. In pick_first, all
addresses are in a single Subchannel, thus the LoadBalancer needs to
know which backend is used for a new stream.
2019-03-04 12:38:26 -08:00
Eric Anderson a818c81a71 testing: Move AbstractTransportTest to core to avoid Truth dep
Fixes #5301
2019-02-28 21:33:19 -07:00
Kun Zhang 83b92cfc9f
core: pass transport attributes to ClientStreamTracer.Factory.newClientStreamTracer() (#5380)
This will be a new override.  The old override is now deprecated.

In order to pass new information without adding new overrides, I shoved most information
into an object called StreamInfo.  The Metadata is left out to draw attention because
it's mutable.

Motivation: this is needed for correctly supporting pick_first in GRPCLB.  GRPCLB needs to
add a token to the headers, and the token varies among servers.  With round_robin, GRPCLB
create a Subchannel for each server, thus can attach the token when the Subchannel is picked.
To implement pick_first, all server addresses will be put in a single Subchannel, we will
need to add the header in newClientStreamTracer(), by looking up the server address from
the transport attributes and deciding which token to add.
2019-02-21 11:13:51 -08:00
Eric Gribkoff 6c32eaf9d4
okhttp: add socketFactory method to channel builder (#5378) 2019-02-20 19:17:20 -08:00
Kun Zhang e875a8c6a3
core: introduce NameResolver.Helper and deprecate the params on newNameResolver() (#5345)
Context: [#4159 (comment)](https://github.com/grpc/grpc-java/issues/4159#issuecomment-415827641)

`Attributes` is appropriate for plumbing optional objects, especially useful for a long plumbing path where components in the middle may not care or see all objects in the container. It's not the case for the `params` on `newNewResolver()`. Both the default port and the proxy detector are guaranteed to be there and the plumbing path is very short. In this case, a first-class object is more appropriate and easier to use.

The `Helper` will also have `getSynchronizationContext()` (#2649) and a method to parse and validate service config. We we also considering merging `Listener` into the `Helper`, to make `NameResolver` match the `LoadBalancer` API.
2019-02-12 10:14:59 -08:00
Kun Zhang 138e958c4a
core: ProxiedSocketAddress on public API (#5344)
Combine the public `ProxyParameters` and the internal `ProxySocketAddress` as `HttpConnectProxiedSocketAddress`. The more specific name signifies the type of the proxy we currently support, and makes room for other proxy types (e.g., SOCKS) in the future. The combination simplifies NameResolver implementation.

Introduce `ProxiedSocketAddress` as the base class that is returned by `ProxyDetector`, mainly for clarification and documentation. Added documentation about proxy in general on `ProxyDetector`.
2019-02-11 09:56:59 -08:00
Carl Mastrangelo f6ec07d87d
core,netty: expose listening on multiple ports 2019-02-06 15:49:59 -08:00
Carl Mastrangelo 3a39b81cf5
all: remove java6 type args 2019-02-04 10:03:50 -08:00
Eric Anderson 723851627e okhttp: Remove DEFAULT_CONNECTION_SPEC from builder
This will reduce the method count, as okhttp's copy of ConnectionSpec will no
longer be retained when ProGuarded. It was deprecated in 25f357699, 10 months
ago.
2019-02-01 09:36:37 -08:00
Carl Mastrangelo ed0a9f3f1d
netty: support listening on multiple ports 2019-01-29 10:13:40 -08:00
Carl Mastrangelo f6689a1f86
all: fix lint errors 2019-01-25 16:09:59 -08:00
Eric Gribkoff 1d97b50315
core: do not lose status when RST_STREAM with NO_ERROR received (#5264) 2019-01-24 08:50:09 -08:00
Ignacio del Valle Alles 3a38e59bae core: Allow specifying a ProxyDetector per ManagedChannel 2019-01-23 16:57:40 -08:00
Jihun Cho 0e32152229 okhttp: throws correct exception in AsyncSink when write/flush happened before
connected. This change will suppress NPE logs when the transport encountered
any error during connection phrase.
2019-01-22 17:03:58 -08:00
Eric Anderson e74576b85b Remove old BetaApi failure suppressions
We've been on newer versions of Guava for a while now; these no longer
do anything.

Reworded the comment for Stopwatch.createUnstarted(), because it is not
safe (it doesn't matter if the method isn't marked Beta; you have to use
Ticker), except for the fact it is only used in our tests.
2019-01-08 16:07:40 -08:00
ZHANG Dapeng df21e40285
all: fix lint 2019-01-02 15:28:44 -08:00
ZHANG Dapeng 56e980cb29
okhttp: fix MockitoAnyIncorrectPrimitiveType error in test 2019-01-02 11:41:41 -08:00
Jihun Cho 6bf0936f8e
okhttp: move async mechanism from FrameWriter to sink (AsyncSink) (#4916)
Optimize OkHttp transport's memory use by getting rid of queuing writes in
AsyncFrameWriter. If any write is pending due to connection issue or by flow
control, AsyncFrameWriter can use at least 8K per each task (task includes
buffer) even if the actual payload is very small. To merge pending writes,
Async mechanism is moved from AsyncFrameWriter to AsyncSink (AsyncSink 
is used by okio's FrameWriter). AsyncSink is still relying on okio's buffer to
decide merging writes or not.

Resolves #4860
2018-12-28 17:20:03 -08:00
Carl Mastrangelo 1bf8476cd7
core: standardize logid format and add details for channelz 2018-12-17 17:22:11 -08:00
Rodrigo Queiro 8481943866 Add missing j2objc dependency to Bazel build
This avoids a warning when building artifacts that depend on Guava.

Fixes #5046.
2018-11-13 13:39:35 -08:00
Eric Gribkoff cab5966415
okhttp: error in frame handler closes with INTERNAL (#5049) 2018-11-09 08:48:13 -08:00
Carl Mastrangelo e7e88a9af8
core: narrow SharedResourceHolder types, and make the scheduler unconfigurable 2018-11-07 13:12:21 -08:00
Jihun Cho 80c973cbd5
okhttp: Optimize memory usage by mergeing buffers (#5023)
okhttp: Optimize memory usage by mergeing buffers

OkHttp transport's memory useage by merging Buffers for each pending data.
- OutboundFlowController, OkHttpClientStream

NOTE: Buffer by default allocate 4k memory.
2018-11-06 11:01:20 -08:00
ZHANG Dapeng 85b244bb41
core,netty,testing: Support dup headers joined with commas
Following the [spec](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md) on duplicate header names:

**Custom-Metadata** header order is not guaranteed to be preserved except for values with duplicate header names. Duplicate header names may have their values joined with "," as the delimiter and be considered semantically equivalent. Implementations must split Binary-Headers on "," before decoding the Base64-encoded values.
2018-11-01 16:17:05 -07:00
Thomas Broyer 183e1f6735 all: update Error Prone to 2.3.2
This will allow enabling Error Prone on JDK 10+ (after
updating the net.ltgt.errorprone plugin), and is also a
prerequisite to that plugin update.

Also remove net.ltgt.apt plugin, as Gradle has native
support for annotationProcessor.
2018-10-19 13:08:36 -07:00
Eric Anderson b7c3d276c9 core: Add maxInboundMetadataSize to builders
This is a rename of the pre-existing Netty builder method, so aliases
were added to the Netty builders.

Fixes #4050. This API was a minor rename to the pre-existing Netty API,
so has already undergone API review and thus is not ExperimentalApi.
2018-10-18 14:34:03 -07:00
Eric Anderson eaafb997e2 okhttp: Add maxInboundMetadataSize
Fixes #4567
2018-10-18 14:34:03 -07:00
Eric Anderson 0fbc1153bd testing: Add transport tests for maxInboundMetadataSize 2018-10-18 14:34:03 -07:00
creamsoup 7675ce2d47
okhttp: make flow control window size configurable (#4959)
Make flow control window size in OkHttp configurable.
2018-10-17 17:33:23 -07:00
Kun Zhang c528df8ae8
core: add internal Subchannel.asChannel() (#4950)
Returns a Channel that allows a LoadBalancer to make auxiliary RPCs on already-established application connections. We need this to implement client-side health-checking (#4932)

See comments on the API for its semantics.

Notable changes:

- Transports are modified to use InUseStateAggregator so that they can exclude RPCs made on Subchannel.asChannel() when reporting in-use state for idle mode.
- OobChannel shares the same Executor as Subchannel.asChannel(). Because the latter is not a ManagedChannel and doesn't have life-cycle, thus can't determine when to return the Executor to a pool, the Executor is now returned only when ManagedChannelImpl is terminated.
2018-10-15 15:39:21 -07:00
Kun Zhang 861f9147ed
core: add CallCredentials2 and deprecate CallCredentials' old interface (#4902)
This is the first step of smoothly changing the CallCredentials API.

Security level and authority are parameters required to be passed to
applyRequestMetadata(). This change wraps them, along with
MethodDescriptor and the transport attributes to RequestInfo, which is
more clear to the implementers.

ATTR_SECURITY_LEVEL is moved to the internal GrpcAttributes and
annotated as TransportAttr, because transports are required to set it,
but no user is actually reading them from
{Client,Server}Call.getAttributes().

ATTR_AUTHORITY is removed, because no transport is overriding it.

All involved interfaces are changed to abstract classes, as this will
make further API changes smoother.

The CallCredentials name is stabilized, thus we first introduce
CallCredentials2, ask CallCredentials implementations to migrate to
it, while GRPC accepting both at the same time, then replace
CallCredentials with CallCredentials2.
2018-10-10 21:45:56 -07:00
Grant Oakley 4ce9c0492d okhttp: Add SslGuard to list of allowed security providers. See internal issue b/116007005 for more details. 2018-10-10 11:39:10 -07:00
creamsoup c0a3c4ab75
okhttp: make AsyncFrameWriter log quietly when socket is already closed. also, default log level down to INFO(closed) which is same as NettyServerTransport. (#4927) 2018-10-09 17:11:56 -07:00
Carl Mastrangelo 0b7043d31a
okhttp: remove internal mockito dep 2018-10-05 11:25:14 -07:00
Kun Zhang fbfc3a40d0
core: add Grpc.TRANSPORT_ATTR_LOCAL_ADDR (#4906)
Resolves #4135
2018-10-03 16:43:37 -07:00
Carl Mastrangelo 5e4d9a591e
okhttp: include better ALPN error message and fine log some exceptions 2018-09-24 18:36:07 -07:00
Carl Mastrangelo b0f423295b
all: use Java7 brackets 2018-09-14 13:52:29 -07:00
Eric Anderson 98630f1870 netty,okhttp: Enable TransportTest.flowControlPushBack
It appears to be stable now. Ran for 1000s of times. I do see some
general flakiness in TransportTest, but it applies to the tests in
general and isn't specific to this one test. It is:

```
org.mockito.exceptions.verification.WantedButNotInvoked:
Wanted but not invoked:
listener.transportReady();
-> at io.grpc.internal.testing.AbstractTransportTest.startTransport(AbstractTransportTest.java:1815)
Actually, there were zero interactions with this mock.
```

This flake is not seen often because it occurs less frequently when
running all the tests (~.1% vs 1%). One of the early tests must warm
something up to make it less likely.
2018-09-10 17:45:20 -07:00
creamsoup 554210da2a
okhttp: settings acks back after apply settings before sending any data (#4825)
okhttp: setting acks back after apply settings before sending any data as a result of the change.
Resolves #4809 also, make #4816 the not flaky.
2018-09-06 15:52:02 -07:00
zpencer 2fca42feb9
all: prepend internal classes with Internal (#4826)
This is a safer way to hide the classes, because they will not appear
in public targets for some build configurations.
2018-09-05 18:48:42 -07:00
zpencer 4d366ce978
all: move Channelz to io.grpc as InternalChannelz (#4797)
This is an API used to coordinate across packages and must live in
`io.grpc`.

Prepending `Internal` makes it easier to detect and hide this class
from public visibility when using certain build tools.

fixes #4796
2018-09-04 16:52:01 -07:00
Eric Gribkoff d3cdfd0883
okhttp: use java 7, avoid compiler varargs warning (#4806) 2018-08-28 11:53:15 -07:00
Eric Anderson 7b126b00a0 all: Swap to Java 7 source and bytecode
Core and OkHttp are left with Java 6 for the moment. Once we resolve
their issues they could be bumped as well.

Updates #3961
2018-08-27 15:29:03 -07:00
creamsoup 30a4bfb2f0
Implement flush coalescing in OkHttp. (#4763)
okhttp: Implement flush coalescing.
2018-08-17 11:08:16 -07:00
Eric Gribkoff 79b24709b9
all: update animalsniffer to Java 7 and add Android 14 (#4727) 2018-08-09 09:09:21 -07:00
Eric Anderson 9d6241eedc Propagate EquivalentAddressGroup attributes to transports
Most of the changes are changing the signature of newClientTransport.
Since this is annoying, I choose to introduce a ClientTransportOptions
object to avoid the churn in the future.

With ClientTransportOptions in place, there's only a few lines necessary
of plumbing for the Attributes: add the field to ClientTransportOptions
and populate it in InternalSubchannel. There are no consumers of the
field in this commit.
2018-07-09 13:00:17 -07:00
ZHANG Dapeng b244988572
netty,okhttp: make rpc followed by racy GOAWAY transparent-retry-able
A new RPC starts with the following steps:

1. Pick a READY transport
2. the READY transport calls `transport.newStream()`
3. the new stream calls `stream.start()`
4. `stream.start()` invokes or enqueus `writeHeaders()` (or for GET request, noop)

A racy GOAWAY could happen between 3 and 4, and by the retry spec, the RPC should be transparent-retry-able in this case. For Netty and OkHttp transport implementation, before step 4, (even if step 1, 2, and 3 excluding 4 are made atomic,) the http2-stream for the RPC is not created, so the current transparent retry logic does not apply and need fix.

Of course, if step 1, 2, and 3 including 4 are made atomic, and not with GET, there will be no such problem.
2018-06-28 12:52:17 -07:00
ZHANG Dapeng 5ce10f0146
all: add gradle format checker
This PR adds an automatic gradle format checker and reformats all the *.gradle files. After this, new changes to *.gradle files will fail to build if not in good format, just like checkStyle failure.
2018-06-11 18:35:18 -07:00