Commit Graph

1426 Commits

Author SHA1 Message Date
Eric Anderson b7ed883aec core: Avoid loading ManagedChannelProvider from NameResolverProvider
Not all users are triggering the loading of ManagedChannelProvider, so
avoid the unnecessary loading. Also, since class initialization is
involved, exception handling tends to get strange and hard to diagnose
issues.
2016-06-20 15:32:45 -07:00
Eric Anderson ef178304cb Revert "Eliminate MethodDescriptor from startCall and interceptCall for servers"
This reverts commit 3df1446deb.

The commit was adding to the difficulty of integration for testing. By
itself it isn't bad, so this is a temporary revert until the many other
commits are absorbed and then it will be reapplied.

This does have a manual edit for ClientCallsTest.
2016-06-20 15:18:18 -07:00
Kun Zhang 11a314e31a Delete the old ClientCall.cancel().
It's deprecated since 0.14.0.
2016-06-17 09:54:02 -07:00
Kun Zhang def237d960 auth: MoreCallCredentials.from(Credentials).
It converts Google Auth Library Credentials to CallCredentials, and
supersedes ClientAuthInterceptor, which is now deprecated.

Also swaps out the ClientAuthInterceptor implementation.

Caveat: This in fact changes ClientAuthInterceptor's behavior. Before
this change, if multiple ClientAuthInterceptors were attached, their
effects would be additive. After this change, only the last executed one
would take effect, and it would also overwrite the CallCredentials set
in CallOptions. We don't think it's an issue, since other languages also
only allow one call credentials to be attached to an RPC.
2016-06-16 16:07:54 -07:00
Jakob Buchgraber 63d8274661 core: don't create a new context for each client call. Fixes #1926
Also, undo the hack that makes sure AsyncClient's stack doesn't overflow as it's no longer needed.
2016-06-16 16:02:17 +02:00
Eric Anderson 26fb347f40 stub: Disable flaky test in ClientCallsTest (#1938)
The test has found a legitimate flake caused by a race in DelayedStream
related to onReady. Disable it until the fix arrives to prevent CI
failure noise.
2016-06-15 21:30:26 -07:00
Eric Anderson 93c34ef008 stub: Improve ClientCall test to fail more obviously
If the timoutout expires, the test will almost certainly fail now due to
responses not matching expected responses, but it isn't as obvious why
the test fails. Swapping to ArrayList prints the entire list when they
don't match, which also makes it easier to diagnose.

This is, in part, to help diagnose #1932
2016-06-15 17:03:20 -07:00
ZHANG Dapeng 95791b7507 okhttp: fix NPE when using CLEARTEXT connectionSpec
Resolves #1815

The only legitimate way to create plaintext connection with okhttp is by calling
OkHttpChannelBuilder#usePlaintex

Throw IllegalArgumentException when calling
OkHttpChannelBuilder#connectionSpec or Utils.convertSpec directly with CLEARTEXT a connectionSped argument.
2016-06-15 16:14:50 -07:00
Kun Zhang 38b950f4f9 core: add transportInUse() to transport listener.
A transport is "in use" iff number of streams > 0. In following changes
the channel will use this information when deciding whether it should
transit to the IDLE mode (#1276).
2016-06-15 13:40:44 -07:00
Jakob Buchgraber 33cd6bee0e core: Overwrite values for existing custom call options.
When a custom calloption is overwritten we keep its old value around.
This patch actually overwrites the old value.
2016-06-15 10:29:05 +02:00
Kun Zhang e7c735abea Make ServerCallHandler non-experimental. 2016-06-14 13:54:29 -07:00
Eric Anderson a62e976229 docs: Don't suggest using grpc-all
Using grpc-all pulls in more dependencies than necessary, as virtually
no user needs both OkHttp and Netty or both Protobuf and Protobuf Nano.
When the separate deps are listed, users are much more likely to remove
unnecessary deps.

Fixes #1597
2016-06-14 10:58:38 -07:00
Eric Anderson a2076f4ec8 core: Enable per-message compression bit by default
This does not enable compression by default, but if the application
chooses to enable compression for a Call, messages will be compressed
without also needing to enable per-message compression.

Disabling per-message compression is intended as a security feature and
should be relatively rarely used, but it was the default. Thus we
required clients to use more advanced interfaces unnecessarily.

To keep client and server behavior consistent, the server also has
per-message compression enabled by default. However, to prevent
compressing on the wire by default, servers no longer enable compression
for the response by default.
2016-06-14 10:51:32 -07:00
Carl Mastrangelo 7c2f7913dc benchmarks: add a header encoding benchmark
Initial numbers so we have some reference:

Benchmark                              (headerCount)    Mode     Cnt     Score    Error  Units
HeadersBenchmark.convertClientHeaders              1  sample  108722   111.912 ±  1.751  ns/op
HeadersBenchmark.convertClientHeaders              5  sample  165053   268.991 ±  1.776  ns/op
HeadersBenchmark.convertClientHeaders             10  sample  188272   441.860 ±  2.531  ns/op
HeadersBenchmark.convertClientHeaders             20  sample  190869   841.065 ± 31.847  ns/op
HeadersBenchmark.convertServerHeaders              1  sample  126578   110.958 ±  1.604  ns/op
HeadersBenchmark.convertServerHeaders              5  sample  179316   241.991 ±  2.006  ns/op
HeadersBenchmark.convertServerHeaders             10  sample  103436   406.329 ±  3.114  ns/op
HeadersBenchmark.convertServerHeaders             20  sample   99179   809.501 ±  4.320  ns/op
HeadersBenchmark.encodeClientHeaders               1  sample  134333   625.415 ± 48.461  ns/op
HeadersBenchmark.encodeClientHeaders               5  sample  167081   971.640 ± 42.102  ns/op
HeadersBenchmark.encodeClientHeaders              10  sample  112809  1418.281 ± 61.045  ns/op
HeadersBenchmark.encodeClientHeaders              20  sample  137593  2286.269 ±  6.715  ns/op
2016-06-14 10:41:31 -07:00
Louis Ryan b681a07f6c Introduce ClientResponseObsever to capture call initiation and to allow
for capture of the CallStreamObserver
2016-06-14 10:18:48 -07:00
Eric Anderson 26bace63e5 core: Improve fail fast status messages
Don't wrap the Status when a fail-fast RPC is already queued when the
transport fails, since that Status is directly responsible for the
failing of the RPC. For future fail-fast RPCs, use the saved status as a
cause to make debugging easier.

This came out of #1330, where the unnecessary nesting of the status
codes just added noise.
2016-06-14 09:55:18 -07:00
Eric Anderson 56a2938830 core: Add NameResolverProvider
This allows moving DnsNameResolver out of io.grpc and removes another
reference of io.grpc.internal from io.grpc. It allows allows
NameResolvers to be pluggable just by being in the class path (as is
already done for ManagedChannels and Servers).
2016-06-14 09:49:52 -07:00
Carl Mastrangelo df346e3a86 examples: make JSON code more obviously advanced 2016-06-14 09:23:28 -07:00
Louis Ryan 3df1446deb Eliminate MethodDescriptor from startCall and interceptCall for servers
Make the MethodDescriptor a property of ServerCall
Move ServerMethodDefinition into ServerServiceDefinition
2016-06-13 14:39:58 -07:00
Eric Anderson 0b55c81548 core: Move ACCEPT_ENCODING_JOINER to DecompressorRegistry
This removes a reference of io.grpc.internal from io.grpc. It also
optimizes server call handling for outbound grpc-accept-encoding header,
as had already been done for client call.
2016-06-13 13:42:58 -07:00
Jakob Buchgraber 4b127f2231 core: Fix CallOptions 'wait for ready' and toString()
- CallOptions 'wait for ready' was not passed between with*() calls and therefore
it was not possible to enable it via a stub.

- Properly format custom call options in toString() output.
2016-06-13 21:04:25 +02:00
Jakob Buchgraber 7da48ae13e core: log exceptions thrown by Runnable's executed via schedule(..). Fixes #1237 2016-06-13 18:39:26 +02:00
ZHANG Dapeng 9d4a43fb79 core: fail fast implementation
resolves #1759
2016-06-11 09:30:16 -07:00
Kun Zhang 432cec7973 core: CallCredentials
Introduce CallCredentials as a first-class option to allow applications
to set per-call credentials into headers for outgoing RPCs. This will
supersede ClientAuthInterceptor. It has access to more
information (e.g., transport attributes, MethodDescriptor) and allow
results to be returned asynchronously, e.g., from a blocking I/O, which
was problemantic with ClientAuthInterceptor.
2016-06-09 17:46:15 -07:00
Doug Clark 121549697f docs: update documentation for client TLS in SECURITY.md 2016-06-09 08:41:47 -07:00
William Thurston a05ab57561 core: emit lists of lists from NameResolver 2016-06-09 08:30:55 -07:00
Eric Anderson 03d9450968 netty: Use uber boringssl jar 2016-06-08 10:26:49 -07:00
Eric Anderson 3f5a154a2d netty: Bump Netty dependency to 4.1.1.Final
Bumping tcnative was not required to be done at the same time as Netty.
But the new tcnative should now work correctly on Windows and be smaller
on Linux.
2016-06-08 10:25:46 -07:00
Eric Anderson 7c722e440e codegen: Specify URL for ExperimentalApi
Fixes #1378. These are the last ExperimentalApis that didn't have their
own separate tracking issue.
2016-06-07 15:00:29 -07:00
Kun Zhang 05ce5455da core: A missed-out test for #1896 2016-06-07 11:57:25 -07:00
ZHANG Dapeng b88ea27b53 core/internal: add 3-arg newStream method to ClientTransport interface (#1898)
adding 
ClientStream newStream(MethodDescriptor<?, ?> method, Metadata headers, CallOptions callOptions);
to ClientTransport interface

Created this PR first because both fail fast implementation and another change will be using this interface change
2016-06-06 19:43:15 -07:00
Jakob Buchgraber 53cd333531 core: add test for complete() without close() exception in AbstractServerStream. Fixes #615 2016-06-03 07:27:57 +02:00
Carl Mastrangelo 0021e063f2 benchmarks: reset context in AsyncClient to avoid chaining.
Fixes #1878
2016-06-02 21:41:43 -07:00
Eric Anderson c6fd94ca85 Implement shutdownNow
Fixes #448
2016-06-02 17:39:59 -07:00
Kun Zhang 631a9d5fac Fix URI construction.
This fixes two issues.

1) Use the URI constructor with multiple arguments to construct the placeholder
URI for direct address, so that special characters can be correctly
escaped. This resolves #1883.

It requires the second fix.

2) Stop URI from mistreating paths as authorities.

There is a bug in URI constructors that take multiple arguments.  They simply
concatenate escaped components and try to parse the resulting string.

For example, URI("dns", null, "//127.0.0.1", null), which is what we do
internally when the application passes "/127.0.0.1" as the target, is supposed
to create a [scheme="dns", path="//127.0.0.1"].  Instead, it internally composes
"dns://127.0.0.1", which is parsed into [scheme="dns", authority="127.0.0.1"].

To avoid this issue, we pass empty string instead of null as the authority to
the URI constructor. The constructor would make "dns:////127.0.0.1" internally
which can be parsed correctly.
2016-06-02 17:10:44 -07:00
Jakob Buchgraber d25b65bb53 testing: add tests for Netty bug where a channel would break after a RST_STREAM frame. Fixes #1682 2016-06-02 18:34:07 +02:00
Jakob Buchgraber c6c74799f4 netty: add toString() to GrpcHttp2Headers 2016-06-02 18:18:55 +02:00
elandau 90323ad5d4 core: add custom CallOptions 2016-06-02 09:14:48 -07:00
Carl Mastrangelo 2ed39c92eb core: cache decompressor registry encodings, and make it copy on write 2016-06-02 09:10:42 -07:00
Kun Zhang 90506405c9 Differentiate transport to LB services and to servers.
TransportManager has a new method, createOobTransportProvider(), which
accepts an EquivalentAddressGroup and the authority string. This
addresses two requirements:

1. Per GRPCLB protocol, connections to the remote load-balancer may use a
different authority than the channel's (#1137).

2. For idle state determination, Channel needs to exclude the transport to
the LB service when looking at live RPCs and (#1276).
2016-06-01 18:23:09 -07:00
Carl Mastrangelo 676bf4854f core: fix nags from linter 2016-06-01 13:58:07 -07:00
Carl Mastrangelo 02eb24b3bd core,netty,okhttp: move user agent removal closer to where it is set 2016-06-01 12:55:21 -07:00
Jakob Buchgraber 028d0844dd core: add test for deframer closed exception. fixes #1795 2016-06-01 20:44:29 +02:00
Carl Mastrangelo 134451f62c benchmarks: use nextUp for nextDelay calculation in OpenLoopClient 2016-05-31 14:05:48 -07:00
Kun Zhang c08d74fec4 TransportSet shutdown() also shuts down the pending transport.
Previously TransportSet.shutdown() only shuts down the active transport,
which means a transport will not be shutdown if it's not ready yet. This
issue was introduced by #1494 that postponed the assignment of the
active transport till transport ready.
2016-05-29 15:45:03 -07:00
Carl Mastrangelo 9f37951680 benchmarks: honor transport in AsyncClient 2016-05-27 11:55:18 -07:00
ZHANG Dapeng 361936401f core/internal: fix regex pattern 2016-05-26 14:02:15 -07:00
Eric Anderson 7052d8b5e9 core: Promote Deadline API to stable
Fixes #1706
2016-05-26 13:33:48 -07:00
Carl Mastrangelo fa22259e3a netty: use custom Http2Headers class for encoding Metadata
Before:
Benchmark                              (headerCount)    Mode     Cnt     Score    Error  Units
HeadersBenchmark.convertClientHeaders             10  sample  127008   631.214 ±  3.543  ns/op
HeadersBenchmark.convertClientHeaders             20  sample  142036  1125.874 ± 21.114  ns/op
HeadersBenchmark.convertClientHeaders             50  sample  117570  2678.635 ± 47.764  ns/op
HeadersBenchmark.convertClientHeaders            100  sample  115919  5427.720 ± 67.956  ns/op
HeadersBenchmark.convertServerHeaders             10  sample  133903   610.970 ±  3.094  ns/op
HeadersBenchmark.convertServerHeaders             20  sample  138155  1154.304 ±  4.595  ns/op
HeadersBenchmark.convertServerHeaders             50  sample  120078  2658.175 ± 38.679  ns/op
HeadersBenchmark.convertServerHeaders            100  sample  120509  5212.341 ± 49.062  ns/op

After:
Benchmark                              (headerCount)    Mode     Cnt     Score    Error  Units
HeadersBenchmark.convertClientHeaders             10  sample  102473   407.383 ±  2.693  ns/op
HeadersBenchmark.convertClientHeaders             20  sample  103205   791.241 ± 38.054  ns/op
HeadersBenchmark.convertClientHeaders             50  sample  173817  1840.311 ±  5.718  ns/op
HeadersBenchmark.convertClientHeaders            100  sample  169984  3690.753 ± 44.308  ns/op
HeadersBenchmark.convertServerHeaders             10  sample  103615   401.661 ±  2.922  ns/op
HeadersBenchmark.convertServerHeaders             20  sample   99060   823.453 ±  5.553  ns/op
HeadersBenchmark.convertServerHeaders             50  sample  171824  1846.788 ± 29.840  ns/op
HeadersBenchmark.convertServerHeaders            100  sample  171622  3670.354 ±  7.127  ns/op
2016-05-25 17:23:51 -07:00
Eric Anderson 149ce204e2 netty: Bump netty dep to 4.1.0.Final
Is such a thing even possible? Yes it is.

Note that HTTP/2 in Netty still is not stable, so we remain
version-pinned.
2016-05-25 16:58:51 -07:00