Commit Graph

2084 Commits

Author SHA1 Message Date
Eric Gribkoff e36d229dc2 core,netty: remove grpc-payload-bin from GET requests 2017-04-21 10:22:05 -07:00
Eric Anderson 10dd34b0c0 grpclb: Flatten LB addresses to use pick-first
This has the limitation that all LB addresses must have the same
authority. Future work will try to remove that limitation.
2017-04-20 15:53:25 -07:00
Carl Mastrangelo b7833dab05 core: lookup TXT records when doing name resolution 2017-04-20 14:11:48 -07:00
ZHANG Dapeng e576c4cb4c netty: more coverage on server keepalive
cover the missed code path of `ping` and `onPingTimeout` in `NettyServerHandler`
2017-04-20 10:38:55 -07:00
Kun Zhang 7cf35510f7 core: pass ServerCall to ServerStreamTracer. (#2930)
This is needed for GRPCLB server-side load reporting, which needs to record
the authority and peer identity.
2017-04-20 09:30:46 -07:00
Kun Zhang a92b0488ed core: add ServerCall.getAuthority() (#2925)
Resolves #727
2017-04-18 15:10:51 -07:00
Eric Anderson 965fe5d6e4 all: Fix basic compatibility with Mockito 2.7.19
We aren't upgrading yet, because we don't want to begin using the new
Mockito APIs. But all the tests now pass with the newer version. There
are a lot of warnings that can't be fixed until we bump the mockito
version.
2017-04-18 12:14:53 -07:00
ZHANG Dapeng 4989736684 core: clamp keepAliveTime/Timeout in a way easier for test 2017-04-17 15:06:25 -07:00
ZHANG Dapeng 4a96e25955 netty: implement server max connection idle 2017-04-17 14:35:22 -07:00
Eric Anderson 393ebf7cdd netty,okhttp: handle ENHANCE_YOUR_CALM and too_many_pings
Any ENHANCE_YOUR_CALM is good reason to log, but too_many_pings also
triggers increase of the keepalive time for later connections.
2017-04-17 14:25:16 -07:00
Kun Zhang 6618f9739e core: add inboundHeaders() to ClientStreamTracer. (#2921)
Also renamed headersSent to outboundHeaders
2017-04-17 14:01:34 -07:00
Kun Zhang 25658cb406 core: delete the alias LoadBalancer2. (#2917)
Resolves #2656
2017-04-14 17:12:31 -07:00
Kun Zhang 41c5aab9bc core: record stats for GET requests (#2914)
Also define the expected call sites of StatsTraceContext.
2017-04-14 16:25:18 -07:00
Carl Mastrangelo 870ae40c8d benchmarks: disable flag printing 2017-04-14 11:17:47 -07:00
ZHANG Dapeng 75324e9918 netty: fix flaky max connection age tests using sleepAtLeast
resolves #2898
2017-04-14 09:42:42 -07:00
Eric Anderson b661ac7d73 core: Delete AbstractStream (replaced by AbstractStream2)
AbstractStream2 will be renamed in a later commit.
2017-04-13 16:26:56 -07:00
Xiao Hang 55e3b71888 Move okhttp to AbstractStream2 2017-04-13 14:49:48 -07:00
ZHANG Dapeng ffc64b70bb netty: move connection.addListner inside constructor of NettyServerHandler
For convenience of implementing max connection idle.
2017-04-13 14:34:18 -07:00
Carl Mastrangelo be61af42e9 core: use RESOURCE_EXHAUSTED for max message size failures 2017-04-13 08:35:48 -07:00
Łukasz Strzałkowski 4f96b0a483 compiler: move over to method descriptor builder 2017-04-12 08:56:46 -07:00
Carl Mastrangelo 17b90169d8 all: begin 1.4.x development cycle 2017-04-11 14:51:39 -07:00
Carl Mastrangelo ce349ae7ef core: make MethodDescriptor.Builder non experimental 2017-04-11 13:20:12 -07:00
Eric Anderson c8dff0d974 core: Fix unused variables
I did not fix the unused statsTraceCtx in
AbstractClientStream2.GetFramer. Instead, I opened
https://github.com/grpc/grpc-java/issues/2896
2017-04-11 09:33:47 -07:00
kpayson64 fd30b68d3c okhttp: Add OptionalMethod support for private classes (#2895) 2017-04-11 08:47:36 -07:00
ZHANG Dapeng f1de741a2a netty: ignore flaky max connection age tests
#2898
2017-04-10 16:06:07 -07:00
Eric Anderson b56a728502 all: Use "keepalive time" instead of "keepalive delay"
It should have always been 'time', to match the terminology of TCP
Keepalive.
2017-04-10 15:48:18 -07:00
Eric Anderson af4982b763 netty,okhttp: Allow keepalive without calls
Again, the server can enforce this, so clients shouldn't go wild with
their new-found freedom.
2017-04-10 15:48:18 -07:00
Eric Anderson 4227b0bb9b core: Reduce minimum client keepalive time to 10s
We previously limited at 1 minute because there was no server-side
enforcement. Now that there is server-side enforcement, it is safer to
allow clients to choose a lower value, since the service owner still has
to permit it.
2017-04-10 15:48:18 -07:00
Eric Anderson 0277b91762 okhttp,netty: Normalize client-side keepalive APIs
This improves the docs a bit and makes OkHttp look like Netty.
2017-04-10 15:48:18 -07:00
Kun Zhang 64938d3cb4 testing: remove negative asserts about stats. (#2894)
They were added in #2863. In TestServiceClient metricsExpected() returns
false because server-side stats is not available, but client-side stats
are there, thus these asserts would fail.

Resolves grpc/grpc/issues/10552
2017-04-10 14:23:26 -07:00
Eric Anderson 02deb9c1a1 core: Remove unused mocks which broke @DoNotMock 2017-04-10 14:19:38 -07:00
ZHANG Dapeng 81da785f75 netty: add jitter to max connection age 2017-04-10 13:38:47 -07:00
ZHANG Dapeng 83a06cc1a5 netty: implement server max connection age 2017-04-10 11:32:28 -07:00
Kun Zhang 44cca5507d core: remove incorrect reporting of CLIENT_SERVER_ELAPSED_TIME. (#2891)
Per spec this metric should be calculated on the server and sent back to
the client, for which the mechanism is not currently defined. As it's
not a required metric, we remove the incorrect implementation for now.

Internal ref: b/37208451
2017-04-10 11:25:25 -07:00
Kun Zhang 770b7e0f81 doc: document that channel state is not implemented. (#2890) 2017-04-10 11:21:55 -07:00
Eric Anderson cfc6634650 netty: Pass boolean to builder instead of permit/deny specialized naming
While we can use permit/deny in this one case, it isn't generalizable to
other cases. In order to avoid always questioning how to deal with
boolean config options, just pass the boolean in all cases.

This mirrors what is being done with the client-side's
keepAliveWithoutCalls.

These methods were very recently added, so there is a low risk of
breakage.
2017-04-10 10:34:03 -07:00
Kun Zhang c4e615cd28 core: allow SubchannelPicker to return a StreamTracer factory. (#2882)
This allows LoadBalancers to trace the activities, including the final
status of the stream that is created as a result of the pick.
2017-04-10 10:31:45 -07:00
Kun Zhang 903197b2aa core: StreamTracer (#2863)
Background
==========

LoadBalancer needs to track RPC measurements and status for
load-reporting.  We need to introduce a "Tracer" API for that.

Since such API is very close to the current
Census(instrumentation)-based stats reporting mechanism in terms of what
are recorded, we will migrate the Census-based stats reporting under the
new Tracer API.

Alternatives
============

We considered plumbing the LB-related information from the LoadBalancer
to the core, and recording those information along with the currently
recorded stats to Census. The LB-related information, such as LB_ID,
reason for dropping reqeusts etc, would be added to the Census
StatsContext as tags.

Since tags are held by StatsContext before eventually being recorded by
providing the measurements, and StatsContext is immutable, this would
require a way for LoadBalancer to override the StatsContext, which means
LoadBalancer API would has direct reference to the Census StatsContext.
This is undesirable because Census API is not stable yet.

Part of the LB-related information is whether the client has received
the initial headers from the server.  While such information can be
grabbed by implementing a ClientInterceptor, it must be recorded along
with other information such as LB_ID to be useful, and LB_ID is only
available in GrpclbLoadBalancer.

Bottom line, trying to use solely the Census StatsContext API to record
LB load information would require extra data plumbing channel between
ClientInterceptor, LoadBalancer and the gRPC core, as well as exposing
Census API on the gRPC API.  Even with those extensive changes, we are
yet to find a working solution. Therefore, we abandoned this idea and
propose this PR.

Summary of changes
==================

API summary
-----------
Introduce "StreamTracer" API, a callback interface for receiving stats
and tracing related updates concerning **a single stream**.
"ClientStreamTracer" and "ServerStreamTracer" add side-specific
events. A stream can have zero or more tracers and report to all of
them.

On the client-side, CallOptions now takes a list of
ClientStreamTracer.Factory. Opon creating a ClientStream, each of the
factory creates a ClientStreamTracer for the stream. This allows
ClientInterceptors to install its own tracer factories by overriding the
CallOptions.

Since StreamTracer only tracks the span of a stream, tracking of a
ClientCall needs to be done in a ClientInterceptor.  By installing its
own StreamTracer when a ClientCall is created, ClientInterceptor can
associate the updates for a Call with the updates for the Streams
created for that Call.  This is how we keep the existing Census
reporting mechanism in CensusStreamTracerModule.

On the server-side, ServerStreamTracer.Factory is added through the
ServerBuilder, and is used to create ServerStreamTracers for every
ServerStream.

The Tracer API supports propagation of stats/tracing information through
Context and metadata.  Both client-side and server-side tracer factories
have access to the headers object.  Client-side tracer relies on
interceptor to read the Context, while server-side tracer has
filterContext() method that can override the Context.

Implementation details
----------------------

Only real streams report stats.  Pseudo streams such as delayed stream,
failing stream don't report.  InProcess transport streams currently
don't report stats.

"StatsTraceContext" which used to receive updates from core and report
directly to Census (StatsContext), now delegates to the StreamTracers of
a stream.  On the client-side, the scope of a StatsTraceContext reduces
from ClientCall to a ClientStream to match the scope of StreamTracer.

The Census-specific logic that was in StatsTraceContext is moved into
CensusStreamTracerModule, which produces factories for StreamTracers
that report to Census.

Reporting with StatsTraceContext is moved out of the Channel/Call layer
into Transport/Stream layer, to match the scope change of
StatsTraceContext.

Bug fixed
----------------

The end of a server-side call was reported in ServerCallImpl's
ServerStreamListenerImpl.closed(), which was wrong.  Because closed()
receiving OK doesn't necessarily mean the RPC ended with OK.  Instead it
means the server has successfully sent the final status, which may be
non-OK, to the client.

Now the end report is done in both ServerStream.close(any Status) and
before calling ServerStreamListener.closed(non-OK).  Whichever happens
first is the reported status.

TODOs
=====

A follow-up change to the LoadBalancer API will add a
ClientStreamTracer.Factory to the PickResult to complete the API needed
by load-reporting.
2017-04-07 11:03:24 -07:00
Eric Anderson 4236027713 netty: Add config for server keepalive enforcement
Now that there is a config, the new defaults are now being enabled.
Previously there were no default limits. Now keepalives may not be more
frequent than every 5 minutes and only when there are outstanding RPCs.
2017-04-06 15:48:33 -07:00
Eric Anderson ebd2f2d2f7 android: Bump android build plugin version to 2.3.1
This cleans up some deprecation warnings from Gradle and cuts full build
time in half.
2017-04-06 15:36:47 -07:00
Eric Anderson 810b2d0b96 all: Update to gradle 3.4.1
Among build speed improvements and VS 2015 support, it also improves
quote handling in gradlew.
2017-04-06 15:36:47 -07:00
Eric Anderson 3818087aa4 netty: Handle channel creation failure
Something "very bad" has happened, but without grpc propagating the
cause from the Future it is very difficult to figure out what.

Fixes #2296
2017-04-06 11:11:49 -07:00
Kun Zhang 123bb315e9 grpclb: skip picker updates that have no effect (#2876)
Each time helper.updatePicker() is called, the Channel will re-process
all pending streams with the new picker.  If the old picker is
equivalent to the old one, it's wasteful.

This is also needed to make our internal integration test easier.
Because the load-balancer may send address list that is identical to the
previous one, just to update the TTL.  Without this change, new picker
replaces the old picker even if they carry the same list, which
effectively resets the round-robin pointer.  This causes a little
imbalance between test backends, resulting in test failure.
2017-04-05 09:43:05 -07:00
ZHANG Dapeng 1c1864be73 netty: refactor NettyChannelBuilder keepalive API (#2874)
To be in line with `NettyServerBuilder` APIs
- Deprecated `enableKeepAlive(boolean enable)` and
`enableKeepAlive(boolean enable, long keepAliveDelay, TimeUnit delayUnit, long keepAliveTimeout, 
TimeUnit timeoutUnit)`
which never worked in v1.2

- Added `keepAliveTime(long keepAliveTime, TimeUnit timeUnit)` and
`keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit)`
2017-04-04 18:19:41 -07:00
Eric Anderson 90788305a3 netty: Add server keepalive enforcement
Everything is currently permitted, but I've tested with other
configurations and all tests pass. I'll set the restrictive default at
the same time as adding a configuration API.
2017-04-04 16:47:42 -07:00
Eric Anderson f9eb545df0 netty: Fix client keepalive initialization (again)
d116cc9 fixed the NPE, but the initialization of the manager happened
_after_ newHandler() was called, so a null manager was passed to the
handler.

Fixes #2828
2017-03-31 17:21:33 -07:00
ZHANG Dapeng c4bbe66506 netty: expose server side keepalive API
expose server side keepalive API in NettyServerBuilder
2017-03-31 10:35:03 -07:00
Carl Mastrangelo 824e5df5cf benchmarks: use JMH 1.18 2017-03-30 14:52:22 -07:00
Eric Anderson 4096d4b668 core,netty: support GET verb in AbstractClientStream2 2017-03-30 14:18:14 -07:00
Eric Anderson d4c9d5f087 core: Wrap keepalive runnables with exception logging
executor.schedule() will "eat" any exceptions thrown by the Runnables,
because the Future is expected to be used to see them. However, we never
call get() on the Future, so we need to just the exceptions like we do
elsewhere in this case.
2017-03-30 14:10:53 -07:00