Commit Graph

1365 Commits

Author SHA1 Message Date
Carl Mastrangelo e0b1149902 Removed unsused variables 2015-12-16 10:20:10 -08:00
Carl Mastrangelo f5d09ff0b2 Disallow compressing zero length messages. 2015-12-16 10:03:17 -08:00
Carl Mastrangelo e967be8d3f More each coverage 2015-12-15 17:12:16 -08:00
Carl Mastrangelo c1800943ff Bump test coverage 2015-12-15 14:19:25 -08:00
Carl Mastrangelo 829735bb25 Fix gaurded by 2015-12-15 12:35:09 -08:00
Carl Mastrangelo b9cacc1553 update tests 2015-12-14 16:09:28 -08:00
Carl Mastrangelo 7ac44928be Fix bug where server wouldn't declare the negotiated compression 2015-12-14 15:48:01 -08:00
Xudong Ma d238d86a3c Some changes to Android interop test App:
1. Call runTest() for test "all", this is required by some internal code.
2. Turn off proguard for debug App.
3. Catch Throwable when we run the test, so that some errors like OutOfMemoryError would fail the test.
4. Compare message size for veryLargeResponse test, otherwise comparing two message would create two more large byte arrarys.
2015-12-14 13:11:59 -08:00
Kun Zhang 7ce50f76c7 Revert to lazy-connection.
`TransportSet` won't connect/reconnect until a transport is requested
through `obtainActiveTransport()`.
Lazy connection is safer, and more desirable in mobile environments.
It's also what C core is doing.

To warm up connections, `LoadBalancer` can call
`TransportManager.getTransport()`, even periodically if it wants to
maintain live connections.
2015-12-11 10:40:19 -08:00
Eric Anderson 7450bf6a17 Swap to "old" link for OpenSSL download with Travis
The previous download link only worked for the most recent version. The
new form only works for old versions. That will encourage us not to use
the latest version, but for tests that's probably not a big deal.

We haven't noticed the breakage sooner because the build results are
cached.
2015-12-10 16:33:06 -08:00
Xudong Ma d41a0fa38e Use getClassLoader() instead of Thread.currentThread().getContextClassLoader() for android.
See #1272 for more details.
2015-12-10 15:06:47 -08:00
Kun Zhang 16247153f6 Move default scheme decision from ManagedChannelImpl to NameResolver.Factory.
This makes it possible to use a default scheme other than "dns" by
installing a custom NameResolver.Factory to the channel builder.
2015-12-10 14:40:46 -08:00
Carl Mastrangelo 4b18f49330 Move ServerCall unary check and add tests 2015-12-10 13:01:48 -08:00
Carl Mastrangelo 82a79d8f93 Expose compression on ClientCall and Server Call 2015-12-08 10:49:27 -08:00
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