Commit Graph

927 Commits

Author SHA1 Message Date
Eric Anderson 0a8d761c19 core: Simplify ChannelImpl constructor; testable Builder
Add some example tests for easier fields in AbstractManagedChannelImplBuilder.

Many fields are no longer Nullable, in order to move logic from construction to
mutation, which eases testing and simplifies cross-class interactions.

The nameResolverFactory comment starting "Avoid loading the provider unless
necessary" was outdated and has not been a concern since #2071 which swapped to
a hard-coded list on Android.
2017-06-12 15:47:44 -07:00
Eric Gribkoff 49b9216e83 core: set server stream decompressor in transport thread 2017-06-12 12:00:21 -07:00
ZHANG Dapeng 1594ebbc12 core: scheduler.schedule() can be used normally
Since netty 4.1.11-final, netty/netty#6627 has been fixed.
2017-06-09 14:28:32 -07:00
Łukasz Strzałkowski 17af756df4 core: deprecate MethodDescriptor.create
Use MethodDescriptor.newBuilder instead
2017-06-09 13:53:39 -07:00
Carl Mastrangelo 6ef77e0609 core: hide access to Status code and message keys 2017-06-08 10:16:06 -07:00
Eric Anderson 72dd8f9a98 core: Mark NameResolverProvider experimental and clarify docs
We don't want people to be desensitized to the Internal annotation.
NameResolverProvider should have probably been ExperimentalApi from the
start, but it was copied from ManagedChannelProvider.

Theoretically, ManagedChannelProvider could be marked ExperimentalApi as
well, but there are no known use cases for doing so since making an
alternative ManagedChannel implementation is quite difficuilt and we
aren't aware of anybody interested in doing so. That isn't the case for
NameResolverProvider; NameResolverProvider is core to 'targets' being
useful.
2017-06-07 17:07:50 -07:00
Eric Anderson faa0ad79f7 Revert "core: move NameResolverProvider to internal"
This reverts commit 9c6ea274fe.

The class name is important for the service loaders.
2017-06-07 16:19:01 -07:00
Yang Song 4a0cf0b936 core: Bump up instrumentation_api to 0.4.3, use instrumentation-defined STATS_CONTEXT_KEY. (#3070) 2017-06-06 18:16:54 -07:00
Carl Mastrangelo 9c6ea274fe core: move NameResolverProvider to internal 2017-06-05 17:40:23 -07:00
Eric Anderson adc2de7533 netty: Clarify max header list size configuration 2017-06-05 14:55:16 -07:00
Eric Anderson acc1328853 core: Avoid DNS test when no networking available 2017-06-05 11:16:35 -07:00
zpencer c0fc6785c1 core: JumpToApplicationThreadServerStreamListener should not close context (#3055)
Calling CancellableContext#close() multiple times does not cause problems, but is unnecessary here. The return value of getListener() is a ServerStreamListenerImpl, which already calls CancellableContext#cancel() inside of the finally block of ServerStreamListener#closed().
2017-06-05 08:37:51 -07:00
Carl Mastrangelo 82fce837e4 core: don't return concrete type from AbstractServerImplBuilder 2017-06-01 14:38:05 -07:00
Carl Mastrangelo 166108a943 all: fix licence whitespace 2017-06-01 14:28:37 -07:00
Carl Mastrangelo 104350cf2e core: include how long deadline was in Status message 2017-05-31 15:04:10 -07:00
Carl Mastrangelo 3bfd630bff all: update to Apache 2 licence
Also, update the authors.
2017-05-31 13:29:01 -07:00
zpencer 8a1217d972 core: Server side cancellations should promptly inform server (#2963)
When a cancellation happens, the ServerCall and Context get notified. Rather than serializing on the normal work queue (which may be doing user computation), we should execute the notification immediately, thereby allowing the user computation to see the cancellation.
2017-05-30 13:05:54 -07:00
Carl Mastrangelo ee38b3754e core: remove 2 suffix from streams 2017-05-26 16:59:54 -07:00
William Thurston 6760bfec8a Log deadline narrowing events at FINE instead of INFO. 2017-05-26 15:28:34 -07:00
Eric Anderson cefcd39396 Fix incorrect assertEquals argument ordering
The expected value should be first.
2017-05-24 08:47:02 -07:00
Bogdan Drutu 530b714790 core/tracing: set always record events option for the RPC spans. (#2998) 2017-05-23 15:10:36 -07:00
Kun Zhang fae55a67a0 core: delete deprecated affinity API. (#3026)
Deprecated since 1.3.0
Resolves #1766
2017-05-19 15:04:40 -07:00
zpencer 347eb09d92 all: Minor updates to expand javadocs (#2991)
all: Minor updates to expand javadocs
2017-05-17 17:12:45 -07:00
Carl Mastrangelo 7be1720fce core: don't expose internal Metadata.headerCount 2017-05-15 18:33:10 -07:00
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
Carl Mastrangelo 7a73bf1068 core,benchmarks: use Atomics for StatsTraceContext
This removes a needless warning, and isn't much slower.  Also this
includes a benchmark for StatsTraceContext to measure the overhead
for creation.  It adds about 40ns per RPC.  Optimization will come
after structural changes are made to break the dependency on
Census.
2017-03-23 17:36:21 -07:00
ZHANG Dapeng 6789eac581 core,netty,okhttp: KeepAliveManager with Pinger
Modified KeepAliveManager to use a Pinger interface, which can send ping or shutdown transport for both server and client.
2017-03-23 13:34:19 -07:00
Kun Zhang c14c5dda63 core: delete deprecated pickSubchannel() (#2849)
The deprecation happens in 1.2.0. Now we can delete it for the next release.
2017-03-23 11:02:26 -07:00
Kun Zhang 3f35ea69df doc: performance implication of Metadata.containsKey() (#2851) 2017-03-23 11:01:37 -07:00
Kun Zhang 418d52d16d core: unify EquivalentAddressGroup and its immitators. (#2755)
Resolves #2716

- Add attributes to EquivalentAddressGroup
- Deprecate ResolvedServerInfoGroup by EquivalentAddressGroup
- Deprecate ResolvedServerInfo, because attributes for a single address
  with an address group is not found to be useful.
- The changes on the NameResolver and LoadBalancer interfaces are backward-compatible
  in the next release, with which implementors can switch to the new API smoothly.

As a related change, redefine the semantics of DnsNameResolver and
RoundRobinLoadBalancer:

- Before: DnsNameResolver returns all addresses in one address group.
  RoundRobinLoadBalancer ignores the grouping of addresses and
  round-robin on every single addresses.  It doesn't work well with the
  one-server-multiple-address setup, e.g., both IPv4 and IPv6 addresses
  are returned for a single serve, even if they are put in the same
  address group by the NameResolver.

- After: DnsNameResolver returns every address in its own
  EAG. RoundRobinLoadBalancer takes an EAG as a whole, and only
  round-robin on the list of EAGs. The new behavior is a better
  interpretation of the EAGs, and really allows the case where one
  server has more than one addresses (e.g., IPv4 and IPv6).

This change will affect users that use custom LoadBalancer with the
stock DnsNameResolver, and those who use custom NameResolver with the
stock RoundRobinLoadBalancer.

Users who use both the stock DnsNameResolver and RoundRobinLoadBalancer
or PickFirstBalancer will see no behavioral change. Because they will
still round-robin on individual addresses from DNS, or do pick-first on
all addresses from DNS (PickFirstBalancer flattens all addresses).

The result is a simpler API and reduction of boilderplates.
2017-03-22 18:29:31 -07:00
ZHANG Dapeng 3ffa5a9660 Okhttp: keepAlivedManager#onTransportShutdown moved from shutdown to stopIfNecessary and refactored
`keepAlivedManager#onTransportshutdown` should not be called in `transport.shutdown()` because it is possible that there are still open RPC streams, and maybe inactive, so keepalive is still needed.
2017-03-22 10:26:45 -07:00
Kun Zhang 8890888b12 core: delete defunct TransportManager. (#2846) 2017-03-22 10:21:59 -07:00
Kun Zhang c112a2c5d8 core: suggest against overriding Context in ClientInterceptor (#2838)
Reference: #2829
2017-03-22 09:35:10 -07:00
Carl Mastrangelo 82bdf53cd3 core: use nanos more consistently 2017-03-20 11:09:24 -07:00
ZHANG Dapeng 87c75b3ce7 core: annotate some keys with Immutable; Context.Key final 2017-03-16 17:50:23 -07:00
Eric Anderson 19afd8b48b core: Support keepalive even when transport is idle
Nothing is using this yet, but it will be used on both client and
server.
2017-03-15 17:15:19 -07:00
ZHANG Dapeng c44a4b24dd core: keepaliveManager not to use Ping.onSuccess; ragard onDataReceive as ping Ack
Preparing to support server side keepalive.
For the convience on server side, not to use Ping `onSuccess()` callback to cancle shutdownFuture any more, instead, regard `onDataReceived()` as ping Ack and cancel shutdownFuture in it.
2017-03-15 11:15:44 -07:00
Łukasz Strzałkowski 3390b6ae8d core: add missing @ThreadSafe annotation (#2823) 2017-03-15 08:12:31 -07:00
Łukasz Strzałkowski da93a64ec1 core: use withOptions instead of withAffinity (#2791)
Fixes #2738
Closes #1766
2017-03-14 12:47:10 -07:00
Kun Zhang 7c3f664e9b grpclb: set LB tokens to headers. (#2812)
The balancer service attaches a token string for each Server entry it
sends to the client.  The client has to set the token to the "lb-token"
header when assigning that Server entry to an RPC.

For convenience of testing, also implemented hashCode() and equals() for
PickResult.
2017-03-10 16:34:33 -08:00
ZHANG Dapeng 1662a719e2 core: fix '@link: can't find...' build noise
The build (jdk version jdk1.8.0_91) produces some noise

```
/usr/local/google/home/zdapeng/git/grpc-java/core/src/main/java/io/grpc/LoadBalancer.java:196: warning - Tag @link: can't find pickSubchannel(PickSubchannelArgs) in io.grpc.LoadBalancer.SubchannelPicker
/usr/local/google/home/zdapeng/git/grpc-java/core/src/main/java/io/grpc/LoadBalancer.java:388: warning - Tag @link: can't find pickSubchannel(
 PickSubchannelArgs) in io.grpc.LoadBalancer.SubchannelPicker
/usr/local/google/home/zdapeng/git/grpc-java/core/src/main/java/io/grpc/LoadBalancer.java:178: warning - Tag @link: can't find pickSubchannel(PickSubchannelArgs) in io.grpc.LoadBalancer.SubchannelPicker
3 warnings
:grpc-core:javadocJar
```

It seems nothing wrong with the javadoc and it could be a javac's bug, but here's a workaround.
2017-03-06 11:53:04 -08:00
ZHANG Dapeng 891581f14d all: fix errorprones
fix JavaStyle and ErrorProne warnings found in internal weekly import:

- Calls to ExpectedException#expect should always be followed by exactly one statement.
- Do not mock 'java.util.concurrent.Future'
2017-03-06 10:45:42 -08:00
Carl Mastrangelo ce243a9f21 core: make timeout marshalling less verbose
* core: make timeout marshalling less verbose
2017-03-06 09:21:21 -08:00
Jack Amadeo d21ee58341 Fix shared subchannel state in RoundRobin LB (#2777)
handleResolvedAddresses constructs subchannels for each address in
an EquivalentAddressGroup, sharing a reference to an immutable
Atrributes. However, as noted, this Attributes instance contains
a mutable AtomicReference, eventually causing subchannel state
changes to be improperly reflected in *all* subchannels of an
EquivalentAddressGroup.
2017-03-03 17:48:05 -08:00
Łukasz Strzałkowski 7bb60dc05c core: introduce PickSubchannelArgs (#2740)
This will allow adding new arguments passed to pickSubchannel
without significant API changes in core LB API in the future.

Closes #2737
2017-03-03 12:48:55 -08:00
ZHANG Dapeng 1fb353fa04 core: fix keepalivemanager bug on handling IDLE_AND_PING_SENT
There was a bug:
IDLE_AND_PING_SENT -> a new stream starts -> ping acked
would lead the keepalivemanager into IDLE state forever.
2017-03-03 12:18:02 -08:00
Łukasz Strzałkowski afb82b47fa doc: remove irrelevant java doc
The class and method references in it were removed recently
2017-03-02 22:02:48 -08:00
Łukasz Strzałkowski c5e5903598 core: add @nullable annotation
Subchannel can be nullable, add annotation for consitency
2017-03-02 21:39:42 -08:00
Carl Mastrangelo 5c37a8360c core: cache Accept-Encoding headers (#2766)
* core: cache Accept-Encoding headers

This avoids rebuilding the raw bytes for each RPC.  The decode path
is not yet optimized to avoid pulling to much into a single commit.
Decompressors may still use invalid names, but this is equivalent to
previous behavior, as cleaing happens later in the caching.

Also, internal accessors on DecompressorRegistry are now hidden.

Before:
Benchmark                                                    (extraEncodings)    Mode      Cnt        Score    Error  Units
DecompressorRegistryBenchmark.marshalOld                                    0  sample   928744      124.104 ± 11.159  ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.00                   0  sample                84.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.50                   0  sample                94.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.90                   0  sample               107.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.95                   0  sample               114.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.99                   0  sample               202.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.999                  0  sample              4944.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.9999                 0  sample             12178.008           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p1.00                   0  sample           2056192.000           ns/op
DecompressorRegistryBenchmark.marshalOld                                    1  sample  1345050      150.123 ±  6.952  ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.00                   1  sample               109.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.50                   1  sample               127.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.90                   1  sample               142.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.95                   1  sample               152.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.99                   1  sample               243.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.999                  1  sample              4640.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.9999                 1  sample             11472.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p1.00                   1  sample           2101248.000           ns/op
DecompressorRegistryBenchmark.marshalOld                                    2  sample  1130903      175.846 ±  1.392  ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.00                   2  sample               131.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.50                   2  sample               148.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.90                   2  sample               164.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.95                   2  sample               174.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.99                   2  sample               311.000           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.999                  2  sample              6048.768           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.9999                 2  sample             12349.107           ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p1.00                   2  sample            112000.000           ns/op

After:
Benchmark                                                    (extraEncodings)    Mode      Cnt        Score   Error  Units
DecompressorRegistryBenchmark.marshalOld                                    0  sample  1095005       67.555 ± 5.529  ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.00                   0  sample                42.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.50                   0  sample                52.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.90                   0  sample                69.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.95                   0  sample                84.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.99                   0  sample               133.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.999                  0  sample              3324.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.9999                 0  sample             11056.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p1.00                   0  sample           1820672.000          ns/op
DecompressorRegistryBenchmark.marshalOld                                    1  sample  1437034       78.089 ± 0.723  ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.00                   1  sample                60.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.50                   1  sample                69.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.90                   1  sample                79.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.95                   1  sample                83.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.99                   1  sample                96.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.999                  1  sample              2728.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.9999                 1  sample             11104.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p1.00                   1  sample            105344.000          ns/op
DecompressorRegistryBenchmark.marshalOld                                    2  sample  1203782       95.213 ± 0.864  ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.00                   2  sample                68.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.50                   2  sample                85.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.90                   2  sample                98.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.95                   2  sample               101.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.99                   2  sample               119.000          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.999                  2  sample              3209.736          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p0.9999                 2  sample             11257.947          ns/op
DecompressorRegistryBenchmark.marshalOld:marshalOld·p1.00                   2  sample             63168.000          ns/op
2017-03-01 15:30:28 -08:00
Eric Anderson 437fafab1b Address review comments 2017-02-28 09:23:04 -08:00
Eric Anderson 2eeb5e3e9e all: Downgrade to Guava 19
Guava 20 introduced some overloading optimizations for Preconditions
that require using Guava 20+ at runtime. Unfortunately, Guava 20 removes
some things that is causing incompatibilities with other libraries, like
Cassandra. While the incompatibility did trigger some of those libraries
to improve compatibility for newer Guavas, we'd like to give the
community more time to work through it. See #2688

At this commit, we appear to be compatible with Guava 18+. It's not
clear if we want to actually "support" 18, but it did compile. Guava 17
doesn't have at least MoreObjects, directExecutor, and firstNotNull.
Guava 21 compiles without warnings, so it should be compatible with
Guava 22 when it is released.

One test method will fail with the upcoming Guava 22, but this won't
impact applications. I made MoreThrowables to avoid using any
known-deprecated Guava methods in our JARs, to reduce pain for those
stuck with old versions of gRPC in the future (July 2018).

In the stand-alone Android apps I removed unnecessary explicit deps
instead of syncing the version used.
2017-02-28 09:23:04 -08:00