Commit Graph

1051 Commits

Author SHA1 Message Date
Carl Mastrangelo 3fef40368d Make TestUtils able to read from input stream. This makes it easier to pass in an input stream from a resource 2015-12-07 17:28:25 -08:00
Carl Mastrangelo 529b14c07b Add compressor registry, and auto negotiate compression 2015-12-07 10:56:16 -08:00
Eric Anderson 96f9cefda4 Close active streams on channelInactive
We think this broke when the stream lifecycle listener was removed.
Observing the stream lifecycle would be the "proper" fix, but it had
notification ordering issues where streams would close before we were
notified of the event that caused the closure, which made it difficult
to provide useful error messages. The ordering of notifications was also
largely undefined.

The long term fix we look forward to is the HTTP/2 child channels, which
should have clearly defined ordering between error notification and
channel closure, and in the order that we need here.

Fixes #1251
2015-12-07 09:00:41 -08:00
Xudong Ma 8d0b5b0c4d Replace name in TODO to a known name, otherwise MOE will complain about it 2015-12-04 16:51:48 -08:00
Xudong Ma a7398dba38 Create a No-op stream in ClientCallImpl.start() if the Context has been cancelled. 2015-12-04 16:03:09 -08:00
Eric Anderson f83a6b8761 Don't leak streams when using DelayedStream
Locking is necessary to avoid race with setStream() since the
application may be calling cancel() in another thread, and we must not
call listener.close() multiple times.
2015-12-04 14:57:41 -08:00
Eric Anderson f6a29241e8 Call ClientStreamListener directly from current thread
ClientStreamListener is intended to be called directly from the
transport, so it is safe to hold locks during the call and run on the
network thread.
2015-12-04 14:51:56 -08:00
Eric Anderson 33db8adda4 Remove outdated and misleading JavaDoc
"onHeaders always is called" is from the initial gRPC design where
0-many context frames were sent before the first message. That is why it
was possible for "no headers were received". That has long-since not
been true, but in the various refactorings this language was
accidentally left. The language "Headers always precede messages" is
correct since headers are only guaranteed if messages were sent.
2015-12-04 14:47:54 -08:00
Xudong Ma 975c38e77c Keep our certs used for testing the same with their internal version 2015-12-04 13:45:48 -08:00
Xudong Ma c3e7541731 Add missing @RunWith, it is required internally 2015-12-03 17:22:36 -08:00
Eric Anderson a1ed98fbae Add missing generics 2015-12-03 14:36:08 -08:00
Eric Anderson 53cc86aafc Remove unused variable 2015-12-03 14:36:08 -08:00
Louis Ryan 7f2678a332 Switch from INTERNAL to CANCELLED for InterruptedException 2015-12-03 14:33:39 -08:00
Carl Mastrangelo e0ea1a10fc Move DelayedStream to its own file 2015-12-03 11:24:49 -08:00
Eric Anderson f8ff71d933 Shut down LB and NameResolver when shutting down Channel 2015-12-03 09:56:05 -08:00
Louis Ryan be6008666e Initial basic implementation of context binding for clients with some limited testing
Adds utility functions for working with Contexts and interceptors
Use 'name' as Context.Key.toString to make conversion to Metadata simpler
2015-12-02 15:33:58 -08:00
Xudong Ma 944edc4601 [Android-interop-test] Fail the instrumentation if any exception is thrown during the channel initialization. 2015-12-02 11:37:30 -08:00
Xudong Ma ee56c4940d Update Android interop test App to use ManagedChannelBuilder 2015-12-02 11:20:05 -08:00
Kun Zhang ad70a28d21 Move the pick-first logic from SimpleLoadBalancer to TransportSet.
TransportSet (as well as TransportManager) accepts a group of equivalent
addresses (EquivalentAddressGroup) instead of a single address.
TransportSet will move down the address list when reconnecting, and
applies back-off only after the entire list has been tried.

Main benefits:
- It will stop channel from trying to reconnect addresses that have been
  failed to connect to and moved away from. (#1212)
- It will make future implementation of Happy Eyeballs possible, inside
  TransportSet.

Tested: covered by TransportSetTest and
ManagedChannelImplTransportManagerTest.
2015-12-01 13:17:52 -08:00
Xudong Ma 88491c064f [okhttp] Use upper layer passed-in resolved address instead of resolving the hostname by itself. 2015-11-25 16:48:58 -08:00
Xudong Ma 097e3a8c65 coalesce pending flushes in OkHttpClientStream.start(). 2015-11-25 16:44:08 -08:00
Eric Anderson 036af15b66 Remove double-"brew update" as now unnecessary
The issue is closed and our latest runs on Travis are only needing to
run brew update once.
2015-11-25 14:21:06 -08:00
Eric Anderson 2db02b52be Reduce advertised Netty API
NettyServer wasn't usable as public, since its constructor was
package-private. So although this reduces our API, it shouldn't actually
impact anyone.

Fixes #1047
2015-11-25 14:12:10 -08:00
Eric Anderson 7ba9ca4861 Map IOException during connecting to UNAVAILABLE
This isn't expected to have much impact once the connection is
established because AbstractNettyHandler.exceptionCaught() wraps all
unknown exceptions with Http2Exception. Fixing that is future work.

Some cases we may now be unwrapping a StatusException, such as one
thrown by MessageDeframer. In general, that seems a Good Thing™, but it
is unclear exactly if it would be perceivable.

Fixes #1181
2015-11-25 09:43:38 -08:00
Carl Mastrangelo 1a32366242 Expose message compression on Server Call 2015-11-24 16:48:25 -08:00
Xudong Ma cda83191d9 Update the out of date Java doc for ClientTransport.newStream(), and update the caller. 2015-11-24 11:07:51 -08:00
nmittler 61a0d8238f Auto-refill connection window
Fixes #1175
2015-11-24 10:24:00 -08:00
Louis Ryan 73e2a235e7 Notify listeners before notifying child contexts of cancellation
Improve performance of isCancellable check
2015-11-23 13:42:46 -08:00
Kun Zhang ece7402dc8 Clarify specs for target strings, especially for IPv6.
See the javadocs of ManagedChannelBuilder.forTarget().

The most interesting case is passing an IPv6 address as target. It can
be either be passed as an authority, where brackets should not be
escaped ([::1]), or as a path of a full URI, where brackets must be
escaped (dns:///%5B::1%5D).

Previously, dns:///[::1], being an invalid URI (brackets not allowed in
path), would be converted to dns:////dns:///%5B::1%5D and passed to
DnsNameResolver. Though it would fail eventually, the error would be
very confusing to users. I changed the logic so that it would try with
dns:/// only if the target string doesn't look like an intended URI
target.

I have restricted the "URI target" to be absolute and hierarchical,
i.e., must start with scheme://. I couldn't find a way to better tell if
a string is intended to be a URI, but I am open to other options.

Refactored tests:

- Move the tests for getNameResolver() into a separate file
  ManagedChannelImplGetNameResolverTest, because those tests are not
  quite compatible with the facility provided by ManagedChannelImplTest.
- Create DnsNameResolverTest. Move DnsNameResolver out of the factory
  class to accommodate for the test.
2015-11-23 09:06:17 -08:00
Carl Mastrangelo 7de6c04d14 Move decompressor setting to the AbstractServerStream 2015-11-20 13:27:27 -08:00
buchgr 602473d786 Add directExecutor() to Channel and Server Builders. Fixes #368.
When using a direct executor we don't need to wrap calls in a
serializing executor and can thus also avoid the overhead that
comes with it.

Benchmarks show that throughput can be improved substantially.
On my MBP I get a 24% improvement in throughput with also
significantly better latency throughout all percentiles.

(running qps_client and qps_server with --address=localhost:1234 --directexecutor)

=== BEFORE ===
Channels:                       4
Outstanding RPCs per Channel:   10
Server Payload Size:            0
Client Payload Size:            0
50%ile Latency (in micros):     452
90%ile Latency (in micros):     600
95%ile Latency (in micros):     726
99%ile Latency (in micros):     1314
99.9%ile Latency (in micros):   5663
Maximum Latency (in micros):    136447
QPS:                            78498

=== AFTER ===
Channels:                       4
Outstanding RPCs per Channel:   10
Server Payload Size:            0
Client Payload Size:            0
50%ile Latency (in micros):     399
90%ile Latency (in micros):     429
95%ile Latency (in micros):     453
99%ile Latency (in micros):     650
99.9%ile Latency (in micros):   1265
Maximum Latency (in micros):    33855
QPS:                            97552
2015-11-19 20:50:02 +01:00
Jakob Buchgraber e8afcb47ff Fix build failure due to unused import. 2015-11-19 14:26:09 +01:00
nmittler ebed5a624a Upgrading to Netty 4.1.0.Beta8
A few things to note:

- ByteString has gone away in favor of AsciiString.

- Http2Headers now uses CharSequence for all methods, so there are a few places that we have to explicitly check for AsciiString to get the optimizations.

- We now have to specify a graceful shutdown timeout for our Netty handlers. Using 5 seconds.
2015-11-18 11:42:24 -08:00
Julien Boeuf 088def1985 Updating the server1 cert so that it can be used with Go.
The encoding of the issuer field in this cert is now a PRINTABLESTRING
as opposed to UTF8STRING in the previous server1.pem which was causing
the Go issue.

- https://github.com/grpc/grpc/pull/4096
- https://github.com/grpc/grpc-go/pull/442

Sorry I should have done this java PR and have it approved before
submitting the grpc-go and grpc PRs.
2015-11-17 21:43:45 -08:00
Carl Mastrangelo c3e179be60 Split out server call impl, add explicit tests and remove an impossible case 2015-11-17 11:16:29 -08:00
Eric Anderson 76eaae26b8 Enable LB and Naming for Netty.forAddress(String,int)
This swaps to the forTarget() codepath. The constructor is to make it
more convenient when extending the builder to disable checkAuthority.
2015-11-13 19:30:21 -08:00
Kun Zhang 01bf56bf8d Fix placeholder in the error message of Preconditions.
Only '%s' is allowed.
2015-11-13 14:58:35 -08:00
Louis Ryan c40d702068 Switch to use Executor instead of ExecutorService where we don't need it 2015-11-12 15:30:15 -08:00
Carl Mastrangelo b0c626c359 Update Load balancing URI parsing and add tests 2015-11-11 17:50:30 -08:00
Kun Zhang 5529b6489b Create BlankFutureProvider which is reused among LoadBalancers.
If a LoadBalancer is requested for a transport future before it can get
one from TransportManager, e.g., before name resolution is completed,
LoadBalancer will return a blank future created by BlankFutureProvider
and to be linked with real futures later.
2015-11-11 15:20:09 -08:00
Carl Mastrangelo 05b7d75029 Re add support for periods in metadata key names 2015-11-10 15:59:42 -08:00
Carl Mastrangelo 3b82484281 Minor cleanup of ClientCallImpl header normalization 2015-11-10 13:52:06 -08:00
Carl Mastrangelo dc375500d6 Update -bin header restrictions, and re introduce string interning. 2015-11-10 13:40:02 -08:00
Carl Mastrangelo 2ad35b8269 Add Header name character restrictions 2015-11-10 11:20:04 -08:00
Louis Ryan 49b513504c Remove notion of stack from thread-local binding, use simple swapping instead.
This allows for binding state to be reset to known-good states precisely which in turn
facilitates making it safe to have 'detach' not throw exceptions and instead log
a severe error that attach/detach calls were not correctly balanced.
2015-11-09 13:17:18 -08:00
Carl Mastrangelo d2046b637d Allow commas in Metadata values 2015-11-09 12:39:53 -08:00
Carl Mastrangelo e9c9d31704 Add even more coverage 2015-11-09 12:35:24 -08:00
Eric Anderson a5d9e34bd6 Add Executor wrapping to Context 2015-11-09 10:59:53 -08:00
Carl Mastrangelo a691752165 Add simple tests for OkHttpProtocolNegotiator coverage 2015-11-06 13:15:28 -08:00
Kun Zhang 38ba586e0c Migrating from Objects.ToStringHelper to MoreObjects.ToStringHelper.
The former is deprecated.
2015-11-04 10:04:12 -08:00