Commit Graph

1602 Commits

Author SHA1 Message Date
ZHANG Dapeng 3a13aa5665 compiler: make Stub final class 2016-07-22 09:49:32 -07:00
Eric Anderson 4b5511e4c0 compiler: Add FALLTHROUGH_INTENDED to appropriate cases
The macro can become [[clang::fallthrough]] or similar on supporting
compilers.
2016-07-22 08:36:05 -07:00
ZHANG Dapeng e109125c62 compiler: add build option to enable deprecated generated code
partially resolving #1469

The added option for java_plugin `enable_deprecated` is `true` by default in `java_plugin.cpp`, so the generated code for `TestService.java` (`compiler/build.gradle` not setting this option) has all deprecated interfaces and static bindService method.

`./build.gradle` and `examples/build.gradle` set this option explicitly to `false`, so all the other generated classes do not have deprecated code.

Will set `enable_deprecated` to `false` by default in future PR when we are ready.
2016-07-21 16:35:18 -07:00
Eric Anderson e23d7ec08a netty: Add test for AbstractHttp2Headers
This increases line coverage by 1.3%.
2016-07-20 16:54:35 -07:00
Eric Anderson 2cd884ea80 core: Reduce DeadlineTest flake
To my knowledge, there has been just a single DeadlineTest flake since
the code was fixed to avoid issues with I/O due to class loading:

io.grpc.DeadlineTest > defaultTickerIsSystemTicker[0] FAILED
    java.lang.AssertionError: <-21431071 ns from now> and <0 ns from now> should have been within <20000000ns> of each other

But we don't really need fine-grained verification during the test
though; if the code is not using nanoTime, then it is almost certainly
not going to have even a day of accuracy (except on a fresh VM). So
checking for a second of accuracy vs 20ms shouldn't really be an issue.
2016-07-20 09:53:00 -07:00
Eric Anderson 4289aaf79c core: Hard-code a list of providers for Android
Class.getResource() is expensive on Android, which is used by
ServiceLoader. So we hard-code a list for Android instead.

Fixes #2037
2016-07-20 09:49:59 -07:00
Louis Ryan deeb976b5f Revise security provider selection for androind to choose from the
installed providers in order of their likely capability
2016-07-19 13:30:22 -07:00
Carl Mastrangelo fa86c8eb74 benchmarks: daemonize threads to reduce the number of stacktraces 2016-07-19 11:32:00 -07:00
Carl Mastrangelo 297af4425e netty: always flush at least once, even if there were no writes 2016-07-19 11:18:54 -07:00
Eric Anderson 083ea8e6aa core: Add missing assert in CallOptionsTest 2016-07-19 11:12:28 -07:00
nmittler 780b2696c1 Ensure that trailers are not lost when making blocking calls.
Fixes #2036
2016-07-18 15:47:57 -07:00
Louis Ryan c1ef8061d1 Fix selection of security Provider to conscruct SSLContext
Cleanup redundant API un TestUtils
Fix TlsTest to be ignored on JKD7 correctly
2016-07-18 14:25:27 -07:00
Eric Anderson 0099657b5e android-interop: Remove usage of deprecated generated interface 2016-07-18 10:41:14 -07:00
Jakob Buchgraber 0ad59483e4 netty: update to 4.1.3.Final 2016-07-18 19:21:26 +02:00
Carl Mastrangelo 953599543e netty: reduce contention in WriteQueue
WriteQueue uses LinkedBlockingQueue, which has stronger synchronization
semantics than we need.  It also requires that we batch reads from it
in order to get reasonable performance.  After profiling the delay
between writing to LBQ and reading from it, there was a ~10us delay.

This change switches to using ConcurrentLinkedQueue as the underlying
queue, and removes the batching (reads).  Using CLQ with batching is
slightly slower.

Benchmarks show favorable numbers for both latency and throughput.
Each of the following results were run serveral times:

Before:
Benchmark                         (direct)  (transport)    Mode     Cnt       Score     Error  Units
TransportBenchmark.unaryCall1024      true        NETTY  sample  321575  124185.027 ± 406.112  ns/op
TransportBenchmark.unaryCall1024     false        NETTY  sample  237400  168232.991 ± 548.043  ns/op

After:
Benchmark                         (direct)  (transport)    Mode     Cnt       Score     Error  Units
TransportBenchmark.unaryCall1024      true        NETTY  sample  354773  112552.339 ± 362.471  ns/op
TransportBenchmark.unaryCall1024     false        NETTY  sample  263297  151660.490 ± 507.463  ns/op

Qps with 10 outstanding RPCs per channel:

Before:
Channels:                       4
Outstanding RPCs per Channel:   10
Server Payload Size:            0
Client Payload Size:            0
50%ile Latency (in micros):     396
90%ile Latency (in micros):     680
95%ile Latency (in micros):     838
99%ile Latency (in micros):     1476
99.9%ile Latency (in micros):   5231
Maximum Latency (in micros):    43327
QPS:                            85761

After:
Channels:                       4
Outstanding RPCs per Channel:   10
Server Payload Size:            0
Client Payload Size:            0
50%ile Latency (in micros):     384
90%ile Latency (in micros):     612
95%ile Latency (in micros):     725
99%ile Latency (in micros):     1080
99.9%ile Latency (in micros):   3107
Maximum Latency (in micros):    30447
QPS:                            93353

The results are even better when under heavy load.  Qps with 100
outstanding RPCs per channel:

Before:
Channels:                       4
Outstanding RPCs per Channel:   100
Server Payload Size:            0
Client Payload Size:            0
50%ile Latency (in micros):     2735
90%ile Latency (in micros):     5051
95%ile Latency (in micros):     6219
99%ile Latency (in micros):     9271
99.9%ile Latency (in micros):   13759
Maximum Latency (in micros):    44831
QPS:                            125775

After:
Channels:                       4
Outstanding RPCs per Channel:   100
Server Payload Size:            0
Client Payload Size:            0
50%ile Latency (in micros):     2697
90%ile Latency (in micros):     4639
95%ile Latency (in micros):     5539
99%ile Latency (in micros):     7931
99.9%ile Latency (in micros):   12335
Maximum Latency (in micros):    61823
QPS:                            131904
2016-07-18 09:50:47 -07:00
Eric Anderson 8f3173617c docs: Avoid using bindService()
bindService() is generally not necessary and the static version is
deprecated.
2016-07-16 17:45:22 -07:00
Eric Anderson 2e4138aa5c core: Fix doc to refer to ImplBase 2016-07-14 16:06:58 -07:00
Eric Anderson e34f2cf3e0 interop: Add constant for necessary max message size
The max message size isn't necessary for the standard cross-language
interop tests, but only our own veryLarge tests.
2016-07-14 09:47:23 -07:00
Louis Ryan f52b4e52cd Make the OkHTTP transport AppEngine friendly. AppEngine may support
conscrypt at some point which would allow ALPN to function
Clarify the SSLContext.getDefault is not used when constructing the
default SSLSocketFactory.
2016-07-13 18:27:43 -07:00
Eric Anderson d2cc576320 core: Fix ErrorProne errors 2016-07-13 14:14:15 -07:00
Jakob Buchgraber edf2c62fd5 netty: update to 4.1.2.Final and tcnative Fork18 2016-07-12 08:06:19 +02:00
Eric Anderson e9643bb5d7 Start 1.1.0 development cycle 2016-07-11 16:57:58 -07:00
Eric Anderson 0a98ff083b interop: Bump maxMessageSize for Android testing
This was missed in 16b096b5
2016-07-11 15:14:54 -07:00
Eric Anderson bfcb04c196 core: Allow avoiding Provider loading, for Android 2016-07-11 10:02:23 -07:00
Eric Anderson d7bf67e01f examples: Provide Maven and Gradle build files
The examples are no longer part of the normal build, although they are
built with Travis. The examples now include their own copy of the gradle
wrapper to ease usage from IDEs which can now properly detect the
correct version of gradle to use.

The build files were generated using "gradle init" and "mvn
archetype:generate" and then modified following our README.

Fixes #1414
2016-07-11 09:20:25 -07:00
Eric Anderson 3c03eb79ec travis,jenkins: Fail build if javac emits warnings 2016-07-10 12:01:07 -07:00
Eric Anderson 7fb43d2a1e core: Add generics to raw types in KeepAliveManagerTest
Swapping to doReturn is necessary since passing a <?> to thenReturn()
does not match the <?> of OngoingStubbing (without a cast).
2016-07-10 11:57:07 -07:00
Eric Anderson 0e47be1287 core: Save accept encoding since Metadata is not thread-safe
Metadata has been passed to the application. The application may be
modifying Metadata concurrently, so we must not access Metadata after
that point.

Fixes #1947
2016-07-10 11:28:04 -07:00
Jakob Buchgraber 0d6a9de54c netty: deduplicate javadoc accidentially introduced in e80b136495 2016-07-10 09:51:16 +02:00
Jakob Buchgraber 7504b79f00 netty: add logging to find cause of ClosedChannelException.
- See #1330 for details.
- Also, Netty 4.1.2.Final comes with additional information where
a (usually statically cached) ClosedChannelException was triggered [1]

[1] https://github.com/netty/netty@e845670#diff-8c9a7d1d9b0fdb6c5aef2794d05a9f88
2016-07-09 14:50:39 +02:00
Xiao Hang d9001ca448 Keepalive support
Creates a KeepAliveManager which should be used by each transport. It does keepalive pings and shuts down the transport if does not receive an response in time.
It prevents the connection being shut down for long lived streams. It could also detect broken socket in certain platforms.
2016-07-08 17:18:47 -07:00
Kun Zhang a86c5bf327 docs: Fix an issue link on ExperimentalApi. 2016-07-08 12:03:17 -07:00
Kun Zhang 527fd67cc8 core: Channel Idleness
Resolves #1276

Idle mode is where the channel does not keep live connections, and does
not have running NameResolver and LoadBalancer.

TransportSet aggregates the in-use state of transports, including the
delayed transport and real transports. Channel aggregates the in-use
state of TransportSets and delayed tranports.

Channel starts in idle mode. It exits idle mode if one of the following
occurs:
 1. A new Call requests for a transport.
 2. The channel's in-use state turns to true.
 3. Someone calls exitIdleMode().

Channel enters the idle mode if its in-use state has been false for the
configured timeout (disabled by default). It shuts down all
TransportSets, NameResolver and LoadBalancer. Interim transports and OOB
transports are LoadBalancer's responsibility.

There is a race that could cause annoyance if IDLE_TIMEOUT was too
small (e.g., 0). A TransportSet's delayed transport is holding streams,
which keeps its in-use state in true. When a real transport is ready,
all streams are transferred to the real transport, immediately after
which the delayed transport's in-use state turns to false, while the
real transport's in-use state may have not turned to true, because some
transport (e.g. netty) may have a brief delay between newStream() being
called and the stream being created internally. This could cause the
channel's aggregated in-use state be in false for a brief time, if which
is longer than IDLE_TIMEOUT, could make channel go to idle mode. Even
though the channel would go back to non-idle again, idle mode would
shutdown all transports and NameResolver and LoadBalancer which leads to
spurious error in the application.

We minimize the chance of such race by setting the minimum timeout to 1
second.

Related chanes:
- ManagedChannelImplTest now switched to use fake executors.
- Turn a few anonymous runnables into named classes. This is more useful for debugging.
2016-07-08 11:36:16 -07:00
Jakob Buchgraber e80b136495 Fix wrong use of checkNotNull in WriteQueue.
* Fix wrong use of checkNotNull in WriteQueue.

The issue was found and reported by @blakearnold. Thank you!
2016-07-08 16:00:34 +02:00
Eric Anderson 7b26a3249c docs: Add gradle build to steps in RELEASING 2016-07-07 16:11:36 -07:00
Eric Anderson 554287a0cd docs: Add missing files to sed in RELEASING 2016-07-07 16:11:36 -07:00
Eric Anderson 16b096b571 Reduce default max message size to 4 MiB
Fixes #1676
2016-07-07 13:34:53 -07:00
Jakob Buchgraber 2d7347fbfc netty: undo commit 6a55e29 as netty's DefaultThreadFactory has been fixed 2016-07-02 13:23:41 +02:00
Jakob Buchgraber 1257f96a00 netty: reduce allocations in write queue.
- Merge all the command objects with QueuedCommand so to save one object allocation per write.
- Add unit tests
2016-07-02 12:17:54 +02:00
Carl Mastrangelo 9bbaa8f46b interop tests: fix race in Compression tests where MetadataEntry.getParsed was being concurrently called.
Metadata is internally not thread safe, so putting it in a volatile is not enough.
2016-07-01 16:42:05 -07:00
Carl Mastrangelo 8d9283116c core: add @GaurdedBy annotations for mutable state of ServerImpl
Commit 5487ea8f54 unintentionally fixed a race condition in

shutdownNow, but the race was detected when being used inside Google.  This could have
been avoided by the enforceable documentation of GaurdedBy annotations.  These make it
clear what locks should be held, promote documentation for newly added server state,
and can be automatically checked by static analysis.
2016-07-01 16:11:20 -07:00
Carl Mastrangelo 2292cbfca0 netty: prevent race between transportCreated and transportShutdown 2016-07-01 15:57:47 -07:00
Eric Anderson 46379da1a6 Start 1.0.0 development cycle 2016-07-01 11:46:33 -07:00
Eric Anderson 75f27ba625 examples: Avoid deprecated generated class 2016-07-01 11:21:48 -07:00
Eric Anderson 32fd329e1c core: Rename withCredentials to withCallCredentials on CallOptions
It was withCallCredentials on the stub to avoid confusion with channel
credentials (which don't exist in Java at this time, but do in other
languages), and having the method names be different doesn't add value.
2016-07-01 11:18:38 -07:00
nmittler 8f78b4d88e Fixing error-prone warnings. 2016-07-01 10:03:41 -07:00
Jakob Buchgraber 3eafa5aeec benchmarks: fix typo in README 2016-07-01 16:20:47 +02:00
Eric Anderson 31651f369f auth: Promote OAuth2 service accounts to JWT
JWT needs less configuration and zero round-trips to initialize.

Fixes #785
2016-06-30 15:41:39 -07:00
Jakob Buchgraber c5733742ce netty: fix incorrect usage of AsciString.
An AsciiString object may only use a subsection of its backing byte array. We need to test for this and return a copy of the subsection if necessary.
Big thanks to @normanmaurer for uncovering this issue: https://github.com/netty/netty/issues/5472
2016-06-30 16:28:45 +02:00
ZHANG Dapeng f149e4c175 compiler: deprecate interfaces and add ImplBase in codegen
first step to address issue #1469:

- leave and deprecate interfaces in codegen
- introduce `ServiceImplBase`,
- `AbstractService` is deprecated and extends `ServiceImplBase`
- static `bindService()` is deprecated
2016-06-29 21:17:03 -07:00