Commit Graph

859 Commits

Author SHA1 Message Date
Eric Anderson cf0e161bd6 Remove unused variables
The removal of the poll()s is a behavior change, but the tests weren't
needing to call it.
2017-05-15 15:39:49 -07:00
Eric Anderson eb6acfe186 Javadoc improvements, especially to Context 2017-05-15 10:12:44 -07:00
Carl Mastrangelo 870dd50eb2 core: clarify more origin docs for Channel 2017-05-11 17:39:30 -07:00
Carl Mastrangelo 90559c7f0a core: add Since java doc annotations to Server, and clarify return types 2017-05-11 10:10:01 -07:00
ZHANG Dapeng bb978bac31 doc: initiate some package javadoc
Initated package javadoc for 
* `io.grpc.stub`, 
* `io.grpc.auth`, 
* `io.grpc.util`, 
* `io.grpc.protobuf`, 
* `io.grpc.protobuf.lite`,
* `io.grpc.protobuf.nano`
2017-05-10 11:29:07 -07:00
Eric Anderson f4173c34ad core,grpclb: Update addresses in OobChannel
This allows avoiding re-creating connections unnecessarily. For
NameResolvers that support notifications this avoids stampeding herds
when possible, since all clients may receive the notification at
approximately the same time.
2017-05-09 12:35:00 -07:00
Eric Anderson 30b61dbf4d core: Update addresses in Subchannel
This allows avoiding re-creating connections unnecessarily. For
NameResolvers that support notifications this avoids stampeding herds
when possible, since all clients may receive the notification at
approximately the same time.
2017-05-09 12:35:00 -07:00
Carl Mastrangelo 1f7c9d5716 core: document ServerBuilder return values and method history
Also, remove an erroneously added ExperimentalApi annotation.  The
method was non experimental as of the 1.0.0 release.
2017-05-05 10:34:10 -07:00
ZHANG Dapeng 5891c963e2 doc: fix broken links 2017-05-05 09:03:48 -07:00
Muxi Yan f674776a6c Add/Fix some docs (#2970)
* Add/Fix some docs

* Address comments

* Address comments

* Address comments

* Add remarks

* Build fixes

* Revision

* More revision
2017-05-04 10:57:49 -07:00
ZHANG Dapeng 7d048af68e javadoc: fix broken links in javadoc 2017-05-02 16:21:43 -07:00
zpencer a317912a14 Channel.authority() should return the value of overrideAuthority (#2956)
AbstractManagedChannelImplBuilder accepts an overrideAuthority parameter, but this value is not hooked up to the name resolver object. Ultimately, Channel.authority consults with the NameResolver, so the overrideAuthority should be hooked into the NameResolverFactory, while all other functionality should be preserved.

Also, add unit tests for all the variants of OkHttpChannelBuilder and NettyChannelBuilder constructors, namely to test the slightly different NettyChannelBuilder(SocketAddress) code path.

Fixes #2682
2017-04-27 14:17:38 -07:00
Kun Zhang 0d6b4184d1 Implement GRPCLB client-side load reporting (#2941)
Also updated load_balancing.proto to the latest version.
2017-04-27 11:28:28 -07:00
Kun Zhang be74e97b5d core: stop using static flags for Census control. (#2947)
Static mutable flags are evil.  Turned them to options on channel
builder.  Also restore the local stats recording by default, because
these flags were added with the concern of wire-compatibility, but not
local feature.
2017-04-26 10:50:55 -07:00
Kun Zhang 49bde5494b core: integrate instrumentation-java (Census) tracing (#2938)
Main implementation is in CensusTracingModule.

Also a few fix-ups in the stats implementation CensusStatsModule:

- Change header key name from grpc-census-bin to grpc-tags-bin
- Server does not fail on header parse errors. Uses the default instead.

Protect Census-based stats and tracing with static flags: `GrpcUtil.enableCensusStats` and `GrpcUtil.enableCensusTracing`. They keep those features disabled by default until they, especially their wire formats, are stabilized.
2017-04-25 13:53:29 -07:00
Fred Wulff ba1c4bf4ac core: Add support for the AppEngine development sandbox 2017-04-24 11:15:58 -07:00
Eric Gribkoff e36d229dc2 core,netty: remove grpc-payload-bin from GET requests 2017-04-21 10:22:05 -07:00
Carl Mastrangelo b7833dab05 core: lookup TXT records when doing name resolution 2017-04-20 14:11:48 -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
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
Carl Mastrangelo be61af42e9 core: use RESOURCE_EXHAUSTED for max message size failures 2017-04-13 08:35:48 -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
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 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
Eric Anderson 02deb9c1a1 core: Remove unused mocks which broke @DoNotMock 2017-04-10 14:19:38 -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
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 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
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
ZHANG Dapeng c4bbe66506 netty: expose server side keepalive API
expose server side keepalive API in NettyServerBuilder
2017-03-31 10:35:03 -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
Eric Anderson 0bcf921e20 core: Remove internal comment referencing compression frames
Compression frames existed in a very early iteration of the gRPC
protocol. It was killed long ago.
2017-03-30 14:10:29 -07:00
Eric Anderson 0d498fbb95 core: Fix User-Agent Javadoc in ManagedChannelBuilder
The behavior of how the application's User-Agent is used changed in
2247ad2. But the Javadoc was not updated.
2017-03-30 13:34:26 -07:00
Carl Mastrangelo a4d698f7c1 core: make SerializingExecutor lockless (#2858)
This is an alternative implementation of #2192
2017-03-29 17:57:42 -07:00
Kenji Kaneda c131d2dd14 core: Do not call startDeadlineTimer when is deadlineCancellationExecutor is null
We got a NullPointerException from ClientCallImpl#startDeadlineTimer
when a new Call is created after a Netty channel is terminated. Here
is a stacktrace:

INTERNAL: java.lang.NullPointerException
at io.grpc.internal.ClientCallImpl.startDeadlineTimer(ClientCallImpl.java:320)
at io.grpc.internal.ClientCallImpl.start(ClientCallImpl.java:253)

The following code snippet reproduces the bug:

```
ManagedChannel channel = NettyChannelBuilder.forAddress(host, port)
    .usePlaintext(true)
    .build();
channel.shutdown();

Thread.sleep(1000);

GreeterGrpc.GreeterBlockingStub stub =
GreeterGrpc.newBlockingStub(channel)
    .withDeadlineAfter(10, TimeUnit.SECONDS);
stub.sayHello(HelloRequest.newBuilder().setName("world").build());
```

The issue was that ClientCallImpl is created from RealChannel#newCall
*after* ManagedChannelImpl#maybeTerminateChannel is called and
scheduledExecutor is set to null. In such a scenario,
deadlineCancellationExecutor is set to null.

I think there are several ways to fix this, but one way would be to
just avoid calling startDeadlineTimer() when
deadlineCancellationExecutor is null. DelayedClientTransport will
create a FailingClientStream with Status.UNAVAILABLE and we will get

```
Exception in thread "main" io.grpc.StatusRuntimeException:
UNAVAILABLE: Channel has shutdown (reported by delayed transport)
```
2017-03-28 16:31:29 -07:00
Carl Mastrangelo 6765596bb9 core: add @since annotations to MethodDescriptor 2017-03-24 16:05:57 -07:00