Commit Graph

853 Commits

Author SHA1 Message Date
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
Lukasz Strzalkowski 2131dfe6f4 doc: there's no type param anymore 2017-02-27 10:25:00 -08:00
Lukasz Strzalkowski f995c6c9d4 doc: fix @link to cancel in java doc 2017-02-27 09:48:34 -08:00
Lukasz Strzalkowski efe261ea43 core: remove SingleTransportChannel, not used 2017-02-27 08:35:51 -08:00
Kun Zhang a9bd94781c core: promote LBv2 classes. 2017-02-24 16:48:44 -08:00
Kun Zhang a6b1d8981a core: delete the old channel impl and LoadBalancer. 2017-02-24 16:48:44 -08:00
Eric Anderson 675080b208 all: Enable ErrorProne during compilation
ErrorProne provides static analysis for common issues, including
misused variables GuardedBy locks.

This increases build time by 60% for parallel builds and 30% for
non-parallel, so I've provided a way to disable the check. It is on by
default though and will be run in our CI environments.
2017-02-24 14:53:23 -08:00
Łukasz Strzałkowski 70b482afad core: clean up code deprecated in 1.1 (#2678) 2017-02-21 14:20:26 -08:00
Łukasz Strzałkowski 63a77658fb Fix link to class in java doc (#2739)
doc: fix link to class in java doc
2017-02-21 09:48:25 -08:00
Kun Zhang 6ff5f2149b core: report error count metrics. (#2734) 2017-02-17 14:07:37 -08:00
Eric Anderson 72923dca87 all: prepare for ErrorProne's FutureReturnValueIgnored
Futures almost universally should be handled in some way when being
returned, either to receive the value or to cancel scheduled tasks to
prevent leaks.

Netty is a bit of a special case though, since it constantly returns
futures that you ignore (even adding a listener returns the "this"
future). So we want to suppress the warning for code using Netty instead
of trying to fix it. When we enable ErrorProne in the build, we should
start passing -Xep:FutureReturnValueIgnored:OFF in the compilerArgs.
2017-02-16 07:22:56 -08:00
Ryan Michela 4029b3f0c2 Implement missing authority API for HandlerRegistry 2017-02-10 17:19:20 -08:00
ZHANG Dapeng 9c78b466b6 core: DelayedStream getAttributes to throw IllegalStateExeption if not passThrough 2017-02-10 11:13:10 -08:00
Eric Anderson 7e1fd4f370 core: Tweak getAttributes() JavaDoc
It now provides more guarantees and should be more obvious when it is
safe to use.
2017-02-08 12:49:00 -08:00
Kun Zhang 9a81cad952 core: switch to LBv2 as the default. (#2707) 2017-02-07 17:45:28 -08:00
Kun Zhang 45642096c3 core: un-abstract the LBv2 setter in ManagedChannelBuilder. (#2697)
The LBv2 setter was added in #2658 as an abstract method, which breaks
anyone who implements ManagedChannelBuilder.  Here we add a default
implementation that throws.
2017-02-06 13:26:47 -08:00
Kun Zhang 7ab5e0e810 core: record server_elapsed_time on client (#2673)
It is defined as the time between the client sends out the headers, and the RPC finishes.
2017-02-03 13:29:06 -08:00
Carl Mastrangelo 237a65ebfc core: make ServiceDescriptor use the Builder pattern 2017-01-30 15:22:40 -08:00
Carl Mastrangelo cbe0ecd5e2 all: fix linter found on import 2017-01-27 15:47:53 -08:00
Carl Mastrangelo 566d0e9400 testing: change names of noopMarshaller to void marshaller
This is needed because in interceptor tests, often the types cannot
be changed.  The void methods stay for users who are writing tests
where they actually don't care about types.  The noop methods
require types to be specified.  This is for users who don't care
about the implementation.  These represent different levels of
commitment.

This eases the transition of code Mocking MethodDescriptor, which
breaks in this release.
2017-01-27 14:41:38 -08:00
Kun Zhang 9983a7b9e4 docs: security requirement of NameResolver.getServiceAuthority() (#2665)
In response to #2662
2017-01-27 09:27:47 -08:00
Eric Anderson 65e4d9f47a all: avoid DNS with GRPC_PROXY_EXP
In some environments DNS is not available and is performed by the
CONNECT proxy. Nothing "special" should need to be done for these
environments, but the previous support took shortcuts which knowingly
would not support such environments.

This change should fix both OkHttp and Netty. Netty's
Bootstrap.connect() resolved the name immediately whereas using
ChannelPipeline.connect() waits until the address reaches the end of the
pipeline. Netty uses NetUtil.toSocketAddressString() to get the name of
the address, which uses InetSocketAddress.getHostString() when
available.

OkHttp is still using InetSocketAddress.getHostName() which may issue
reverse DNS lookups. However, if the reverse DNS lookup fails, it should
convert the IP to a textual string like getHostString(). So as long as
the reverse DNS maps to the same machine as the IP, there should only be
performance concerns, not correctness issues. Since the DnsNameResolver
is creating unresolved addresses, the reverse DNS lookups shouldn't
occur in the common case.
2017-01-27 09:27:07 -08:00
Kun Zhang 0e6cf9971b core: open up LBv2 APIs for early adopters. 2017-01-26 16:27:31 -08:00
Carl Mastrangelo 89bc2cd3b2 all: update to latest import ordering 2017-01-26 13:43:06 -08:00
Kun Zhang 0428556ce4 core: allow LBv2 impls to be stripped out by ProGuard. (#2654)
This should address the concern of increased method count as mentioned
in #2650.
2017-01-25 15:06:39 -08:00
Kun Zhang f088b81fc8 core: stop "testing" from depending on "core"'s test. (#2652)
Because "core"'s test source already depends on "testing", e.g.,
`core/src/test/java/io/grpc/internal/ServerCallImplTest.java` uses
`testing/src/main/java/io/grpc/internal/testing/StatsTestUtils.java`,
which forms a circular dependency.

This change moves the StatsContext setter accessors from "core"'s test
source to "testing".

Resolves #2651
2017-01-25 07:57:12 -08:00
dapengzhang0 7d85e73b23 ForwardingClientCall.getAttributes should call delegate 2017-01-24 09:11:23 -08:00
Carl Mastrangelo 40bc50212b core: remove with* methods from MethodDescriptor 2017-01-23 15:41:40 -08:00
Lukasz Strzalkowski b33d3cb170 core: rename getAttr() and use standard getAttributes() 2017-01-23 15:06:00 -08:00
Łukasz Strzałkowski 8882abaa09 core: rename attributes() -> getAttributes()
Make it consistent with its counterpart, ClientStream#getAttributes()
2017-01-23 15:04:51 -08:00
Carl Mastrangelo efbcd1f1b9 core: change method descriptor to be builder based 2017-01-23 12:29:35 -08:00
Eric Anderson e9fa8c99ce core: Only use scheduled executor for timer tasks
This removes an abuse of scheduled executor in ManagedChannelImpl. The executor
was used to avoid deadlocking. Now we run the work on the same thread, but
delay it until locks have been released.

There is no need to fix ManagedChannelImpl2. Due to its different
threading model it didn't have need to abuse the scheduledExecutor.

Fixes #2444
2017-01-23 11:24:25 -08:00
Carl Mastrangelo a4e481b3f9 core: make ServiceDescriptor check input values
Fixes: #2357
2017-01-20 17:22:14 -08:00
Kun Zhang 737cd16a38 core: make StatsContextFactory setters protected (#2634)
These are only used in internal tests.  In production,
StatsContextFactory is loaded by the "Instrumentation" library and must
be one per process, thus we won't allow setting it on a per-channel or
per-server basis.
2017-01-20 17:20:44 -08:00
ZHANG Dapeng 018e2d5307 all: make some api non-experimental for 1.1 2017-01-20 16:34:56 -08:00
Eric Anderson 2bd74c5a92 core: cancel RPC when exception in server onReady
Fixes #2305
2017-01-20 10:47:11 -08:00
Carl Mastrangelo d5eb248737 all: bump to netty 4.1.7 2017-01-19 15:24:26 -08:00
Lukasz Strzalkowski 060eb45623 Rename attributes() to getAttributes() to make it consistent 2017-01-19 12:53:54 -08:00
Eric Anderson 1e99b299e1 all: ErrorProne fixes and avoid @Beta in Guava 2017-01-19 12:16:05 -08:00
Kun Zhang 5a4794f2c8 core: add debug information in MessageDeframer. (#2622)
So that MessageDeframer would include the class name of the enclosing
stream when emitting errors.  This should give us more information about #2157
2017-01-18 17:23:29 -08:00
Kun Zhang fa8f1150cb docs: fix deprecation reference in ClientAuthInterceptor. (#2621) 2017-01-18 16:25:57 -08:00
Łukasz Strzałkowski 6494a17c5b RoundRobinLoadBalancer minor cleanups (#2611)
* Remove else, make it easier to read

* Ready subchanns list will be at max the same as the input list

* Make status private, add pkg-private getter for tests

* Remove empty field, cache size, simplify logic

Make list unmodifiable. Document index with GuardedBy (see #nextSubchannel())
2017-01-18 14:40:30 -08:00
ZHANG Dapeng d87a6587a4 core,netty: add getAttributes to ClientStream and ClientCall (#2526)
add `getAttributes()` to `ClientStream` and `ClientCall` to be able to share clientTransport
information such as socket TOS with higher lever API's, once the RPC picks up an active transport that is ready to use.
2017-01-17 20:33:37 -08:00
Kun Zhang 527d243ec0 core: more logs in ManagedChannelImpl. (#2606)
They have already been added to ManagedChannelImpl2.

Resolves #2299
2017-01-17 09:36:02 -08:00
Eric Gribkoff d59973c925 core,services: separately index mutable and immutable services
Updates the proto reflection service to process immutable services once and
mutable services as-needed.
2017-01-13 17:46:56 -08:00
Kun Zhang c436d93f07 core: ServerImpl returns shared resources at termination (#2605)
Previously it does it at shutdown, which was wrong because executor may
still be used before the server is terminated.

Resolves #2034

Uses ObjectPool to make this change testable.  Cleans up test and makes
it mostly single-threaded, except for two deadlock tests that have to be
multi-threaded.
2017-01-13 09:00:32 -08:00
Carl Mastrangelo ec7f00a272 core,testing: make MethodDescriptor final and add Test helper 2017-01-11 17:30:14 -08:00
Carl Mastrangelo ce3a94bacc core: promote experimental methods in MethodDescriptor 2017-01-11 17:07:53 -08:00
Carl Mastrangelo b5b9ba5604 core: fix bug with Metadata merging 2017-01-11 13:23:46 -08:00
Carl Mastrangelo 8493498a54 core: remove thisT() from API 2017-01-11 12:46:47 -08:00
Carl Mastrangelo 813cb090af core: make getResponseMarshaller experimental in MethodDescriptor 2017-01-11 11:22:01 -08:00
Carl Mastrangelo 85bb0a100d core: make Contexts, ResolvedServerInfoGroup, and ServerInterceptors final 2017-01-11 10:47:17 -08:00
Carl Mastrangelo 8e463ce1a8 core,stub: remove deprecated deadline methods 2017-01-10 15:54:38 -08:00
Kun Zhang d17a7b5bd4 core: abstract channel builder to accept LoadBalancer2 (#2583)
If a LoadBalancer2 is passed in, the builder will create ManagedChannelImpl2 instead of ManagedChannelImpl. This allows us to test the LBv2 classes on a large scale.
2017-01-10 15:30:12 -08:00
Kun Zhang 7cb0497767 core: ManagedChannelImpl2. (#2530)
1. Adapt to LoadBalancer2 interface.  Channel holds on to a single
   DelayedClientTransport2.

2. Lock-free: every channel state mutation, including Subchannel
   mutations, calling into LoadBalancer, idleness and shutdown, is made
   from channelExecutor.

3. Idleness grace period is no longer needed.
2017-01-09 14:44:10 -08:00
Carl Mastrangelo 8d49df28ee all: add max message size to client calls 2017-01-05 17:23:34 -08:00
Carl Mastrangelo 6ed3cbb143 core: fix API breakage in ServerBuilder 2017-01-05 17:22:47 -08:00
Kun Zhang cce8eac56d core: upgrade census (now named instrumentation) to 0.3.0 (#2565)
In upstream, Census is renamed to "Instrumentation". `com.google.census` is renamed to `com.google.instrumentation.stats`.

In gRPC, "census" in every name is replaced by "stats".
2017-01-05 10:48:13 -08:00
Kun Zhang 322eb8c5c5 grpclb: re-implement GrpclbLoadBalancer in v2 API. (#2557)
Besides API changes, this implementation is also up-to-date with the
latest design:

1. Delegate to round-robin and pick-first policies if requested by
the naming system.

2. OOB channels to LoadBalancer always use the LB authority provided by
the naming system.

3. Never send application RPCs to balancer addresses, even if the
address returns UNIMPLEMENTED error.
2016-12-29 15:00:04 -08:00
Kun Zhang 4693492fda style: fix styles and error-prones (#2560)
"Because of spurious wakeups, wait() must always be called in a loop".
Got rid of wait().

"If you return or throw from a finally, then values returned or thrown from the try-catch block will be ignored. Consider using try-with-resources instead."
Ignored the exception thrown from finally.
2016-12-29 11:20:49 -08:00
Łukasz Strzałkowski 661413c2df core: Port PickFirst & RoundRobin LBs to v2 API (#2479) 2016-12-21 10:03:25 -08:00
Kun Zhang a6ecece6f5 doc: more guidelines for LoadBalancer2 implementations. (#2501) 2016-12-16 15:18:59 -08:00
Carl Mastrangelo ce9d152dff all: update to guava 20 2016-12-16 15:15:17 -08:00
Kun Zhang f8f569e078 core: InternalSubchannel uses ChannelExecutor. (#2503) 2016-12-16 14:17:38 -08:00
Kun Zhang 1ba66d38d9 doc: update javadocs in DelayedClientTransport2. (#2522)
Resolves #2521
2016-12-15 13:07:19 -08:00
Carl Mastrangelo f394a93ddb core: add full stack trace in Status.toString
* core: add full stack trace in Status.toString
2016-12-15 08:54:56 -08:00
Kun Zhang 946046abaf core: two changes on DelayedClientTransport2. (#2505)
1. Use ChannelExecutor to run callbacks.  Now callbacks are no longer
run under the delayed transport lock.

2. Use explicit picker version instead of relying on identity equality
to detect new pickers.  Rationale: if reprocess() is called again with
the same picker, all pending streams will be reprocessed by this picker
again, thus there is no reason to leave out the racing new stream.
2016-12-15 08:47:33 -08:00
Anuraag Agrawal 221fadcbdd Implement setListener in AbstractServerStream and remove from subclasses. 2016-12-14 12:29:10 -08:00
Carl Mastrangelo 1f2802a11f core: make forTarget(String) non-experimental 2016-12-14 10:15:12 -08:00
Kun Zhang 178b5260c2 core: handle a race in DelayedClientTransport(2). (#2486)
* Fork DelayedClientTransport into DelayedClientTransport2, and fix a race
on it.  Consider the following sequence:

1. Channel is created. Picker is initially null

2. Channel has a new RPC. Because picker is null, the delayed transport
is picked, but newStream() is not called yet.

3. LoadBalancer updates a new picker to Channel. Channel runs
reprocess() but does nothing because no pending stream is there.

4. newStream() called on the delayed transport.

In previous implementation, newStream() on step 4 will not see the
picker. It will only use the next picker.

After this change, delayed transport would save the latest picker and
use it on newStream(), which is the desired behavior.

Also deleted all the code that will not be used after the LB refactor.


* Also fixed a bug: newStream() should always return a failing stream if it's shutdown. Previously it's not doing so if picker is not null.
2016-12-12 09:24:13 -08:00
Kun Zhang fd33a72174 core: thread-less ChannelExecutor. (#2493)
Dedicated for mutating states of ManagedChannelImpl, InternalSubchannel and LoadBalancer.
2016-12-08 18:38:29 -08:00
Kenji Kaneda 21bca9a475 core: Add @Nullable to Metadata#get 2016-12-08 10:25:21 -08:00
Eric Anderson e999f8da62 core: Fix ErrorProne failure for ForOverride
Methods overriding a ForOverride method should not be public.
2016-12-08 10:08:12 -08:00
Carl Mastrangelo cb1ba5bf39 core: remove extra allocation in MessageFramer
OutputStreamAdapter is a private class, and is only ever called by two
places: ByteStreams.copy, which never calls the single byte method, and
DrainTo, which potentially can.  There are two classes that implement
DrainTo, which is primarily ProtoInputStream.  It calls
MessageLite.writeTo(OutputStream) or back again to ByteStreams.copy.

MessageLite.writeTo in turn wraps the OutputStream in a
CodedOutputStream.OutputStreamEncoder, which then never calls the single
byte version.  Thus, all know implementations never call the single
byte override.

Additionally, it is well known that the single byte write is slow, and
is expected to be wrapped in a BufferedOutputStream if there are many
small writes.
2016-12-05 13:11:06 -08:00
Kenji Kaneda 1d5fd1fa35 core: Fix typos in GrpcUtil
- s/IMPLEMENTATION_VERION/IMPLEMENTATION_VERSION
- s/ACCEPT_ENCODING_SPLITER/ACCEPT_ENCODING_SPLITTER
2016-12-05 11:42:16 -08:00