Commit Graph

1315 Commits

Author SHA1 Message Date
ZHANG Dapeng f5f560ad36
all: TimeProvider to use nanos rather than millis
This is the same practice as #2833
2018-05-21 12:44:06 -07:00
zpencer faffb09f0a
core: remove io.grpc core dependency on census (#4461)
io.grpc (core) does not strictly require census. Move the usages and
and remove census from BUILD.bazel .
2018-05-18 14:56:45 -07:00
zpencer 850249f9ca
core: fix lints from import (#4472)
The import surfaced a few linter issues.
2018-05-17 16:21:30 -07:00
ZHANG Dapeng 4d94163bbd
core: Add ChannelTracer
This is a class similar to `CallTracer`, to be used for Channel Tracing.

The constructor arg `maxEvents` is a param supposed to be provided by `ManagedChannelBuilder`.
2018-05-16 10:56:41 -07:00
zpencer e806e387fe
core: put @ExperimentalApi on CallOptions.of() (#4466)
This marks the method as still experimental, to be clear to users that
they are using an experimental api.
2018-05-15 15:56:42 -07:00
ZHANG Dapeng 6a96656764
core: make channel stats' channel state consistent with subchannels
Moved `setState()` inside of `channelExecutor` runnable together with `setSubchannels`, otherwise the state may be inconsistent with subchannels, say channel state is the initial IDLE but subchannels is non-empty with active transports, or channel state is READY but subchannels is empty.
2018-05-15 15:48:57 -07:00
ZHANG Dapeng bf4a00c6de
context/core/netty: Add @CheckReturnValue to Context
By adding inner class annotations without introducing external dependencies.
2018-05-15 13:14:30 -07:00
ZHANG Dapeng 561583be14
core,services: Add ChannelTracing data object
Added `ChannelTrace` as an inner class of `Channelz`.

This is in preparation for the implementation of [Channel Tracing](https://github.com/grpc/proposal/blob/master/A3-channel-tracing.md)
2018-05-15 11:33:44 -07:00
zpencer 04a90bcad2
core: stabilize custom CallOptions API (#4457)
Deprecate `of()` in favor of `create()` and
`createWithDefault()`. Emphasize that the name string is only for
debug purposes.

Fixes #1869
2018-05-15 10:03:46 -07:00
zpencer 21b73bbdc1
core: partially stabilize Attributes API (#4458)
Deprecate static builder method, Keys.of(), add a notice of plans to
remove keys(), emphasize that the name is only a debug label.
The `@ExperimentalAPI` is left on the class because there are still
issues around hashCode/equals.
2018-05-14 11:30:06 -07:00
zpencer 902baa0cde
core: do not use internal accessors in BinaryLogProvider (#4454)
Now that this class is in `io.grpc` the accessor is not needed.
2018-05-09 12:21:05 -07:00
zpencer 247a76ed93
core,netty,okhttp: make toString more consistent for channelz (#4434)
Use MoreObjects.toStringHelper and use only the log id's long value,
because the class name is already present in the toStringHelper.
2018-05-07 11:38:16 -07:00
zpencer 6f29b60dcf
core, services: make BinaryLog an explicit object that is passed into channels/servers (#4431)
remove SPI, io.grpc.BinaryLog is a public API that is passed into builders and must be
explicitly closed.
2018-05-07 07:41:42 -07:00
Carl Mastrangelo 60a0b0c471
all: normalize copyright header 2018-05-03 14:55:21 -07:00
Eric Anderson 894c815832
core: Document Metadata ownership passes to the Call{,Listener}
This was already clearly documented in ServerCall.Listener and
ClientCall.
2018-05-03 07:08:27 -07:00
Grant Oakley 6bf8e0c084 core: add @CheckReturnValue to CallOptions 2018-05-02 15:56:52 -07:00
ZHANG Dapeng e19e8f7d40
core: populate effective deadline to ClientStream
Added `ClientStream.setDeadline(Deadline deadline)` method, which will set the timeout header.

Resolves #4412
2018-05-02 13:31:03 -07:00
ZHANG Dapeng d50c191aca
core/stub: fix lint warnings 2018-05-02 10:37:32 -07:00
Grant Oakley fcb48ff216 core,stub: Add toString() to ClientCallImpl and GrpcFuture 2018-05-01 16:49:56 -07:00
ZHANG Dapeng b58e0f4059
core: stickiness for RoundRobinLoadBalancer
Add weak stickiness support for Round Robin lb.
2018-04-30 16:46:35 -07:00
zpencer acfb3b9851
services,core: simplify CallId generation (#4365)
BinaryLog.java is the class that is responsible for intercepting
client and server calls. It now requires a CallId to be passed
in. The BinaryLogProviderImpl is responsible for generating a
CallId and passing it in.
2018-04-27 18:32:36 -07:00
zpencer 9ada30b25d
(low priority) core,netty,interop-testing: stabilize maxInboundMessageSize API (#4399)
On server side, `maxMessageSize` is deprecated for
`maxInboundMessageSize` to match the channel builder.

Update usages to use new setter.
2018-04-27 16:01:16 -07:00
zpencer 1a2d076aed
core,netty,okhttp,services,testing: expose security info to channelz (#4300)
Pull the TLS info from the SSLSession object for TLS, and AltsContext for ALTS.
2018-04-25 14:38:09 -07:00
zpencer 62e6e2de78
Start 1.13.0 development cycle (#4383) 2018-04-23 15:24:24 -07:00
Carl Mastrangelo c37ea15830
core: also expose parser on JsonParser 2018-04-20 13:25:21 -07:00
ZHANG Dapeng 74532acce0
core: use List instead of Set for drainedSubstreams
This improves latency performance (retry enabled) for NETTY transport by about 2us. For INPROCESS, NETTY_LOCAL, OKHTTP transports, the improvement seems much less than 2us.

```
before
Benchmark                                               (direct)  (transport)    Mode     Cnt         Score     Error  Units
TransportBenchmark.unaryCall1024                            true        NETTY  sample  260801     76566.536 ± 189.439  ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.00        true        NETTY  sample             60480.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.50        true        NETTY  sample             75264.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.90        true        NETTY  sample             85504.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.95        true        NETTY  sample             87424.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.99        true        NETTY  sample            100864.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.999       true        NETTY  sample            140800.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.9999      true        NETTY  sample            205547.469            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p1.00        true        NETTY  sample           3915776.000            ns/op 
TransportBenchmark.unaryCall1024                           false        NETTY  sample  208352     95865.619 ± 113.142  ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.00       false        NETTY  sample             72576.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.50       false        NETTY  sample             93568.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.90       false        NETTY  sample            105728.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.95       false        NETTY  sample            109568.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.99       false        NETTY  sample            124544.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.999      false        NETTY  sample            161792.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.9999     false        NETTY  sample            230520.448            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p1.00       false        NETTY  sample           3997696.000            ns/op
```

```
after
Benchmark                                               (direct)  (transport)    Mode     Cnt         Score     Error  Units
TransportBenchmark.unaryCall1024                            true        NETTY  sample  269471     74104.666 ± 182.514  ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.00        true        NETTY  sample             60992.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.50        true        NETTY  sample             70912.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.90        true        NETTY  sample             83584.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.95        true        NETTY  sample             85888.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.99        true        NETTY  sample            100224.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.999       true        NETTY  sample            142848.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.9999      true        NETTY  sample            489527.706            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p1.00        true        NETTY  sample           4300800.000            ns/op
TransportBenchmark.unaryCall1024                           false        NETTY  sample  216000     92468.337 ±  90.229  ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.00       false        NETTY  sample             68480.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.50       false        NETTY  sample             89472.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.90       false        NETTY  sample            103680.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.95       false        NETTY  sample            107008.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.99       false        NETTY  sample            120960.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.999      false        NETTY  sample            159232.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.9999     false        NETTY  sample            272076.493            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p1.00       false        NETTY  sample           2662400.000            ns/op
```
2018-04-20 11:22:32 -07:00
Eric Anderson ddf77f59cc core: Fix experimental API issue for channel state API
The earlier issue was for the feature itself, not the stabilization.
2018-04-19 17:38:20 -07:00
zpencer 934c2e2fd7
core: clarify binlog API (#4362)
The interceptors are a part of the implementation and not meant for
callers.

Both methods for wrapping clients / servers can be `final`.
2018-04-19 17:32:45 -07:00
zpencer ec95999124
core: remove unneeded binlog tests for ManagedChannelImpl ServerImpl (#4361)
Replace the tests with tests that just make sure binary log is
installed. Better tests exist today in BinaryLogProviderTest to make
sure the actual logic is correct.
2018-04-19 16:55:32 -07:00
ZHANG Dapeng e67a61fa08
core: refactor ManagedChannelImplTest with a configurable builder
In previous code of `ManagedChannelImplTest`, new tests will have to add more and more custom args in `createChannel(...)`, and each time when a custom arg is needed all other default args need be repeatedly provided in `createChannel(...)`. In most cases those args are just builder attributes. So this PR makes ManagedChannelImplTest easier to stub by providing a builder field, then new tests will just set necessary builder attributes before calling `createChannel()`.
2018-04-19 10:06:39 -07:00
ZHANG Dapeng f6a032d6b2
core: forward toString for forwarding classes
Forward `toString()` method for forwarding classes to improve debug information.

For example, `ForwardingManagedChannel.toString()` will return something like:

```
ForwardingManagedChannel{delegate=ManagedChannelImpl{logId=tag-13247, target=localhost:8080}}
```
2018-04-19 10:05:48 -07:00
Carl Mastrangelo f754bff906
core: make JsonParser public 2018-04-18 18:49:08 -07:00
zpencer 30400e0e58
core: add sockets to subchannel stat (#4345)
This is info not being reported at the moment and is missing from the
display.
2018-04-16 11:33:28 -07:00
zpencer c04278ea07
services: turn channelz null futures into Status.UNIMPLEMENTED (#4346)
Then channelz GUI will take this into account. This is particularly
useful for InProcessTransport, where I have decided we do not need
special support for in channelz. The server and channel stats are
already sufficient.
2018-04-16 09:54:35 -07:00
zpencer 791a29f63b
services: socket options were erroneously ignored if socket has no stats (#4336)
This fixes listen sockets. It is ok to have no data but report socket
options.
2018-04-13 14:59:35 -07:00
Carl Mastrangelo e4502aca5d
stub: add docs clarifying readiness 2018-04-13 14:12:54 -07:00
Carl Mastrangelo 03465a7f45
core: don't warn on absent service config
Fixes #4333
2018-04-13 11:13:57 -07:00
ZHANG Dapeng a6811d5bb1
all: add toString() to Server to improve debug info 2018-04-13 09:41:09 -07:00
ZHANG Dapeng 0eafb8e9ca
core: compare doubles with compare instead of ==
Always not compare equality for doubles with `==`.
2018-04-13 09:39:59 -07:00
Eric Anderson 0a598c053c core: Fix lint, style, "good ideas" violations 2018-04-12 17:26:54 -07:00
ZHANG Dapeng 6d7e19cbe5
core: replumb RetryPolicy
- replumbed `RetryPolicy` with `MethodInfo` without breaking the existing `RetryPolicyTest`.
- moved `ServiceConfigInterceptor.MethodInfo.RetryPolicy` out as a top level class so that `RetriableStream` does not import `ServiceConfigInterceptor`.
2018-04-12 11:41:04 -07:00
Kun Zhang 3f63cd0ad4
core: always call StreamTracer.streamClosed() when stream is officially closed. (#4331)
Previously StreamTracer.streamClosed() is called in
ServerStream.close(), but it is not exactly when the stream is
officially closed.  ServerStreamListener.closed() is guaranteed to be
called and it is the official end of the stream.
2018-04-12 09:05:48 -07:00
zpencer 137e759fda
core, netty: allow InputStream based certs (#4316)
Allow ServerBuilder to read certs from InputStream, not just from a
File.
2018-04-11 16:14:58 -07:00
zpencer 62cc2b1ae3
core,netty: add NettySocketSupport to populate TcpInfo (#4306)
NettySocketSupport is responsible for making the low level calls to
get and populate the TcpInfo structure.
2018-04-05 10:36:49 -07:00
Carl Mastrangelo 2df76cc710
core: apply service config 2018-04-04 17:45:12 -07:00
Carl Mastrangelo 9ed84258aa
core: don't reschedule idle timer if it is already active
Benchmark results (3 runs each)

non direct

```
Before:
50.0%ile Latency (in nanos):		157471
90.0%ile Latency (in nanos):		185927
95.0%ile Latency (in nanos):		195135
99.0%ile Latency (in nanos):		218815
99.9%ile Latency (in nanos):		1188735
100.0%ile Latency (in nanos):		18333695
QPS:                           6126
50.0%ile Latency (in nanos):		160407
90.0%ile Latency (in nanos):		188551
95.0%ile Latency (in nanos):		197487
99.0%ile Latency (in nanos):		219575
99.9%ile Latency (in nanos):		390239
100.0%ile Latency (in nanos):		18338815
QPS:                           6106
50.0%ile Latency (in nanos):		157831
90.0%ile Latency (in nanos):		186439
95.0%ile Latency (in nanos):		195815
99.0%ile Latency (in nanos):		216951
99.9%ile Latency (in nanos):		281167
100.0%ile Latency (in nanos):		5384447
QPS:                           6235

After:
50.0%ile Latency (in nanos):		152255
90.0%ile Latency (in nanos):		180551
95.0%ile Latency (in nanos):		188943
99.0%ile Latency (in nanos):		209623
99.9%ile Latency (in nanos):		1184831
100.0%ile Latency (in nanos):		4351999
QPS:                           6313
50.0%ile Latency (in nanos):		153663
90.0%ile Latency (in nanos):		181671
95.0%ile Latency (in nanos):		189991
99.0%ile Latency (in nanos):		210495
99.9%ile Latency (in nanos):		278895
100.0%ile Latency (in nanos):		18283519
QPS:                           6300
50.0%ile Latency (in nanos):		152767
90.0%ile Latency (in nanos):		180839
95.0%ile Latency (in nanos):		189791
99.0%ile Latency (in nanos):		211719
99.9%ile Latency (in nanos):		280927
100.0%ile Latency (in nanos):		12231167
QPS:                           6381
```

direct:

```
Before:
50.0%ile Latency (in nanos):		133943
90.0%ile Latency (in nanos):		153671
95.0%ile Latency (in nanos):		163655
99.0%ile Latency (in nanos):		188871
99.9%ile Latency (in nanos):		235791
100.0%ile Latency (in nanos):		7864575
QPS:                           7134
50.0%ile Latency (in nanos):		131623
90.0%ile Latency (in nanos):		151863
95.0%ile Latency (in nanos):		162095
99.0%ile Latency (in nanos):		187719
99.9%ile Latency (in nanos):		234983
100.0%ile Latency (in nanos):		17836031
QPS:                           7250
50.0%ile Latency (in nanos):		131223
90.0%ile Latency (in nanos):		150823
95.0%ile Latency (in nanos):		161311
99.0%ile Latency (in nanos):		187719
99.9%ile Latency (in nanos):		237471
100.0%ile Latency (in nanos):		4416255
QPS:                           7273

After:
50.0%ile Latency (in nanos):		122751
90.0%ile Latency (in nanos):		140967
95.0%ile Latency (in nanos):		148911
99.0%ile Latency (in nanos):		173215
99.9%ile Latency (in nanos):		214823
100.0%ile Latency (in nanos):		18509823
QPS:                           7774
50.0%ile Latency (in nanos):		124507
90.0%ile Latency (in nanos):		145855
95.0%ile Latency (in nanos):		156623
99.0%ile Latency (in nanos):		183111
99.9%ile Latency (in nanos):		235679
100.0%ile Latency (in nanos):		18289663
QPS:                           7625
50.0%ile Latency (in nanos):		124295
90.0%ile Latency (in nanos):		145071
95.0%ile Latency (in nanos):		156439
99.0%ile Latency (in nanos):		183919
99.9%ile Latency (in nanos):		232447
100.0%ile Latency (in nanos):		3712383
QPS:                           7632
```
2018-04-04 16:02:02 -07:00
Shohei Kamimori 8f01084bb3 core: add a `close` to InputBufferStream
Before:
`InputBufferStream.close()` does not close their buffer so the buffer will leak.

After:
Resolves #4198.
Override the `close` for closing their buffer.
2018-04-03 16:11:19 -07:00
zpencer b1d91b9f60
core,services: binary log should use real peer socket and call id (#4266)
The peer socket is read from TRANSPORT_ATTR_REMOTE_ADDR from the
stream attributes. We only log the peer on receive initial metadata.

The call id assumes census is available. The call ID read from the
context via SERVER_CALL_ID_CONTEXT_KEY on server side, and read from
CallOptions via CLIENT_CALL_ID_CALLOPTION_KEY on client side. The
value is copied from CONTEXT_SPAN_KEY which is set by census.

Pass around CallId with two longs, not a byte[].
2018-04-03 13:39:11 -07:00
zpencer 724e32fe57
core,netty,services: add server listen sockets to channelz proto service (#4220)
Server listen sockets differ from normal sockets in that they do not
have a remote address, do not have stats on calls started/failed/etc,
and do not have security info.
2018-04-03 10:05:47 -07:00
Shohei Kamimori 1d901a8de2 core: add tests for ReadableBuffers 2018-04-03 08:11:39 -07:00
zpencer 0067415811
core: document how to set up squid proxy for testing (#4285)
This makes it easier for a gRPC developer to validate the proxy code
using a real proxy.
2018-03-30 11:28:10 -07:00
zpencer 7c37f1d32b
core,netty,okhttp,services: expose socket options to channelz (#4228)
For okhttp, expose the standard options from the Socket object.

For netty, expose all the `io.netty.channel.ChannelOption`s of the
`channel.config()`.
2018-03-30 08:48:37 -07:00
Eric Anderson 4e82e62eaa
Fix compilation in Java 9 2018-03-28 17:13:39 -07:00
Shohei Kamimori 5af2515f3e core,README: add docs about grpc-java-api-checker (#4182) 2018-03-28 15:34:18 -07:00
ZHANG Dapeng db64c36af2
core: no retry on dropped PickResult
Address #3553 for normal retry. Not covering the unimplemented hedging case.
2018-03-26 14:57:12 -07:00
Eric Anderson 5f0ee3a725
Bump to Guava 20
Fixes #4176
2018-03-23 15:45:05 -07:00
Eric Anderson 7eab0d9468 netty: Add support for Conscrypt 2018-03-23 10:05:45 -07:00
zpencer 0955866d5a
core,services: implement binarylog Client and ServerInterceptor (#4174)
- To make unit tests easier, added the BinaryLogSinkWriter abstract
  class, which allows verifying high level arguments rather than low
  level protobufs.
- remove InputStream based marshaller (IDENTITY_MARSHALLER) in favor
  of byte[] because retries will need to call serialize multiple
  times. This is achieved with a special InputStream that lets us
  access the internal byte[] without copying.
- Change ByteBuffer based internal methods to use byte[]
- Update unit tests to reflect the above
2018-03-23 09:29:24 -07:00
Eric Gribkoff 5337728fa7
core,netty: client sends rst stream when server half-closes (#4222) 2018-03-22 12:38:42 -07:00
Carl Mastrangelo 7c69c3a867
core: disable jndi lookups 2018-03-21 12:55:54 -07:00
ZHANG Dapeng 900b39635d
core: Fix java lint found during weekly import 2018-03-20 17:45:26 -07:00
Kun Zhang 1e0875dff7
core: re-enable panic mode after all affected internal tests have been fixed. (#4245) 2018-03-20 13:06:41 -07:00
ZHANG Dapeng 6836b31fb3
core: catch and log Throwable for jndiResolver.resolve(host)
JndiResolver.resolve may throw Error that could cause rpc to hang. Catch and log Throwable and keep using jdkResolver's result to prevent it.
2018-03-20 13:02:52 -07:00
ZHANG Dapeng 95917b8f28
core: parse retry policy from service config 2018-03-19 15:15:59 -07:00
zpencer bb0c0e53c2
core: perform channelz obj removal before things that may throw (#4235)
This way we won't risk an exception making us fail to clean up.
For transportClosed only remove if we know this isn't a
duplicate call to close.
2018-03-18 12:18:09 -07:00
zpencer ca99f80999
core,services: track server sockets in channelz (#4226)
Rather than querying the ServerImpl for its sockets, we register them
into channelz as with all the other entities, for consistency.

Error conditions are checked with `assert` statements, so we throw in
tests.
2018-03-16 17:21:25 -07:00
Carl Mastrangelo 2ce1d370a0
core: re-add back in orphan wrapper 2018-03-16 14:51:38 -07:00
Carl Mastrangelo 7daefd75a1
core: make ManagedChannel honor Service config LB 2018-03-16 14:47:25 -07:00
ZHANG Dapeng 26fc6324c4
core: fix typo in ClientCall.java javadoc 2018-03-15 10:07:30 -07:00
Carl Mastrangelo 2761bbb851
core: handle long dns txt records properly, parse service config, add tests 2018-03-13 17:37:04 -07:00
ZHANG Dapeng 6b9e090d70
core: rm unnecessary InternalNameResolverProvider 2018-03-13 10:21:40 -07:00
Eric Anderson 11c8bcde1b Start 1.12.0 development cycle 2018-03-13 09:04:25 -07:00
ZHANG Dapeng 7852b34781
core: fix channel.getState(true) will not reconnect
resolves #4170
2018-03-12 14:13:52 -07:00
ZHANG Dapeng a83f67a706
core,netty,okhttp: Transparent retry
Changes:

- `ClientStreamListener.onClose(Status status, RpcProgress rpcProgress, Metadata trailers)` added.

- `AbstractClientStream.transportReportStatus(Status status, RpcProgress rpcProgress, boolean stopDelivery, Metadata trailers)` added

- `ClientCallImpl.ClientStreamListenerImpl` will ignore the arg `rpcProgress` (non retry)

- `RetriableStream.SubListener` will handle `rpcProgress` and decide if transparent retry.

- `NettyClientHandler` and `OkHttpClientTransport` will pass `RpcProgress.REFUSED` to client stream listener for later stream ids when received GOAWAY, or for stream received a RST_STREAM frame with REFUSED code.

- All other files are just a result of refactoring.
2018-03-12 14:12:46 -07:00
Eric Gribkoff c6fe4deb33
core: set delayedTransport picker to null in idle mode (#4207) 2018-03-12 12:21:39 -07:00
zpencer 402c1740fa
core,okhttp,netty,alts,testing: Plumb proxy resolved addr to transports (#4137)
ProxyDetector is now responsible for resolving the proxy's
`InetSocketAddress`, and `ProxyParameters` asserts that the address is
resolved. The results are plumbed through using a `PairSocketAddress`,
which is a special `SocketAddress`.

If a proxy should be used but the proxy can not be resolved, we the
`DnsNameResolver` will re-attempt the resolution later.

Remove the unit test testing for unresolved proxy addresses, since
it's no longer applicable.
2018-03-12 11:15:40 -07:00
zpencer f56ac76b35
core,services: add ChannelzService class (#4205)
This implements the methods to expose the stats as a gRPC
service. GetServerSockets is still unimplemented and will require a
follow up change.
2018-03-10 14:58:34 -08:00
zpencer 0678499965
core: express children of channels as WithLogId for channelz (#4201)
For channelz ref objects, we need the id as well as the name. By
returning a `WithLogId`, we can return the original object so that we
may call `toString` on it.
2018-03-09 15:49:15 -08:00
zpencer c3c8bc7ab6
core: keep root channels separate from subchannels in channelz (#4200)
It is a channelz requirement that subchannels and channels are
separate, and we can not retrieve a root channel by asking for a
subchannel and vice versa.
2018-03-09 14:44:41 -08:00
zpencer 921b668ad5
core,netty,okhttp,testing: separate local vs remote stream start times for channelz (#4194)
The channelz spec states that the two must be separate.
2018-03-08 16:57:12 -08:00
zpencer f0eb6d2102
core,netty,okhttp,testing: nest TransportStats inside SocketStats for channelz (#4190)
Transport ststistics should really be a child member of SocketStats.
While we're at it, let's add the local and remote SocketAddress to
SocketStats, with a test.
2018-03-08 14:56:04 -08:00
Eric Anderson c59ddc52a1 core: Internal is not necessary for LoadBalancers
With the advent of LoadBalancer2 (now just LoadBalancer) the need to use
internal APIs was removed; there's now first-class APIs exposed for
LoadBalancer use.

The old LoadBalancer API interacted with io.grpc.internal.ClientTransport
directly.
2018-03-08 13:31:31 -08:00
Eric Anderson 19cd32fb66 core: Remove redundancy in JSON parser 2018-03-08 09:20:34 -08:00
Carl Mastrangelo 8b9d179798
core: split JSON parsing into its own file 2018-03-07 17:57:48 -08:00
Eric Gribkoff eef9add54c
core: rename prepareToLoseNetwork() to enterIdle() (#4179) 2018-03-07 15:51:13 -08:00
Eric Gribkoff ae1fb9467c
core: use exponential backoff for name resolution (#4105) 2018-03-05 21:46:02 -08:00
Eric Anderson 26719bdc5c Partially revert "core: change serverimpl,servercallimpl's internalclose to cancel stream (#4038)"
This partially reverts commit 48ca4527c1.
It leaves the changes to ServerCallImpl and test.

This also partially reverts "Lint fixes" commit
3002a23a0f which removed unused variables
which are now necessary again.

This is reverted for the combined result of two issues:
* Some users are testing that they get UNKNOWN when the service throws.
  That's not unreasonable given the behavior was well-publicised when it
  changed in v1.5. We should probably keep the UNKNOWN in some common
  cases (like the service threw immediately, before sending anything).
* The client could see CANCELLED instead of INTERNAL as had been
  intended. It's unclear as to why (I didn't investigate heavily). This
  behavior is visible in MoreInProcessTest and was overlooked during
  review.
2018-03-02 13:35:06 -08:00
Eric Anderson f865b31f5f core: Disable ManagedChannelImpl orphan check
Some internal tests are broken and noticing the warning logs. They need
to be fixed before this is enabled.
2018-03-02 12:29:33 -08:00
Eric Anderson e392af1efd Partially revert "core: Tracking NameResolverProvider being experimental"
This partially reverts commit c07ad68cbd.

The PARAMS_DEFAULT_PORT in NameResorverProvider is the preferred name.
The hope is still to kill NameResolver.Factory.
2018-03-02 12:29:08 -08:00
Eric Gribkoff 3268082f01
core: prefer getHostString() to getHostName() in ProxyDetectorImpl (#4165) 2018-03-02 12:11:54 -08:00
ZHANG Dapeng c07ad68cbd
core: Tracking NameResolverProvider being experimental 2018-03-01 14:20:49 -08:00
zpencer fcc8ea5950
core: load binarylog class using serviceprovider util (#4161)
Use the common util rather than rolling our own here.
2018-03-01 10:15:15 -08:00
Eric Anderson 3002a23a0f Lint fixes 2018-02-28 10:20:08 -08:00
Carl Mastrangelo 7af2373a03
core,netty,okhttp,alts,inprocess: deprecate usePlaintext(boolean) 2018-02-28 08:53:14 -08:00
Eric Anderson 1b5aadf068 core: Disable panic mode
It is now discovering legitimate errors in some tests that need to be
resolved first. Follow progress at #3293.
2018-02-27 14:03:34 -08:00
zpencer 09d305c3fc
core: add server transports to channelz (#4149)
A previous PR added client transports, this PR adds server
transports.
2018-02-27 10:02:44 -08:00
zpencer 4dc1b50e1a
core: add ServerImpl to channelz (#4147)
This allows servers to be identified by ids.
2018-02-27 08:22:25 -08:00
ZHANG Dapeng 39decadaf6
core: allow application to provide all threads - inprocess channel 2018-02-26 17:12:04 -08:00
zpencer 00d1805f78
core: register client transports to channelz (#4146)
This makes client side transports visible to channelz when created,
and removed when terminated.
2018-02-26 16:41:09 -08:00
Eric Anderson ce84c2b227 core: Add missing @RunWith test annotation (#4142)
For ManagedChannelOrphanWrapperTest
2018-02-26 14:06:43 -08:00
zpencer b71b1084de
core: register channels, subchannels, oobchannels with channelz (#4035)
Channels, subchannels and oobchannels are added at creation and
removed at termination. Same goes for subchannels and
oobchannels. Everything is registered as a hard reference. This means
channels that are not properly cleaned up using `awaitTermination`
will remain visible in channelz.
2018-02-26 09:45:19 -08:00
ZHANG Dapeng 4bac7d7084
core: add InProcessServerBuilder.generateName() 2018-02-23 16:44:10 -08:00
ZHANG Dapeng e31851a0eb
core: remove runDunTasks with filter
In `FakeClock` we have `runDueTasks()` (without filter), `numPendingTasks(filter)`, and `getPendingTasks(filter)` which are useful. The `runDueTasks(filter)` method seems not a right way to test.
2018-02-22 12:46:24 -08:00
zpencer 9dc4ded597
core: move ManagedChannelImpl orphan check to wrapper class (#4093)
okhttp and netty libraries will retain hard references to
ManagedChannelImpl via its non static nested classes. Moving the
orphan check to a wrapper class solves this problem.

- Added ForwardingManagedChannel + test
2018-02-22 11:57:26 -08:00
Rama Chavali 48ca4527c1 core: change serverimpl,servercallimpl's internalclose to cancel stream (#4038)
The HTTP/2 error code will be INTERNAL_ERROR for all cancel statuses,
except for DEADLINE_EXCEEDED and CANCELLED, which are mapped to
CANCELLED.
2018-02-22 11:09:21 -08:00
zpencer 887217e57b
core,services: fix binarylog unit tests (#4109)
- The unsafe operation was reverted in code, so the test should not
  use it either
- The variable naming is tripping internal linters
2018-02-22 10:08:12 -08:00
Kun Zhang 46c1133a1e
core: add panic mode for ManagedChannelImpl (#4023)
Channel enters this mode whenever there is an uncaught throwable from
its ChannelExecutor, which is where most channel internal states are
mutated, such as load-balancing.

In panic mode, the channel will always report TRANSIENT_FAILURE as its
state, and will fail RPCs with an INTERNAL error code with the
uncaught throwable as the cause, which is helpful for investigating
bugs within gRPC and 3rd-party LoadBalancer implementations.

## Change to existing behavior
Previously if `LoadBalancer` throws in `handleResolvedAddressGroups()`, it would
be routed back to `LoadBalancer.handleNameResolutionError()`. Now it will make
the channel panic.

## Internal refactors
- Refactored out `shutdownNameResolverAndLoadBalancer()`, called from three code paths: `enterIdleMode()`, `delayedTransport.transportTerminated()`, and `panic()`.
- Refactored out `updateSubchannelPicker()`, called from both `updateBalancingState()` and `panic()`.
2018-02-22 09:27:08 -08:00
ZHANG Dapeng 38c84ed9ef
core: temporarily disable retry when stats or tracing is enabled
To avoid breakage, temporarily disable retry when stats or tracing is enabled.

This still agrees with the description of the javadoc of `ManagedChannelBuilder.enableRetry()`

```java
/**
   * Enables the retry mechanism provided by the gRPC library.
   *
   * <p>This method may not work as expected for the current release because retry is not fully
   * implemented yet.
   *
   * @return this
   * @since 1.11.0
   */
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/3982")
  public T enableRetry()
```
2018-02-21 15:04:36 -08:00
Eric Anderson b78c5cfcf2 core: Improve status descriptions in MessageDeframer
This removes the debug string added in 5a4794f2c because the issue was resolved
and the debug string is confusing for Netty, producing results like:
io.grpc.netty.NettyClientTransport$3: Frame size 216695976 exceeds maximum: 4194304

This makes it seem like it's a HTTP/2 frame problem and not a gRPC message
problem. Although it is clearer once you see the maximum is 4 MB, this already
bit me in #4086.

In general, we should talk about "messages" instead of "frames" when possible
as that's what is most comprehensible to the consumer of the description. I
also make sure to mention "gRPC" messages/frames because otherwise the message
is ambiguous.
2018-02-21 14:20:12 -08:00
zpencer 7d47ac0c12
core: Clarify ownership of InputStreams wrt Marshaller and Stream (#3419)
It is the responsibility of the caller to close the `InputStream`
returned by `Marshaller`.

`Stream` takes ownership of any `InputStream`s passed in.

`DelayedStream` and the streams of `InProcessTransport` already
handle ownership transfer, but `AbstractStream` needs to call
`close`.
2018-02-20 09:57:57 -08:00
zpencer 5f7b64a250
core,services: lock down visibility of BinaryLogSink (#4100)
- This class should not be a part of the public API
- Update ServiceProvidersTest to verify package private services can be
  loaded with the utility.
2018-02-20 09:54:40 -08:00
zpencer bde2ba2444
services: introduce BinaryLogSinkProvider (#3917)
The `BinaryLog` will write `GrpcLogEntry`s to the sink, which is
intended as a pluggable interface. It is the sink's
responsibility to send the binlog protos to disk, to a remote
logging service, etc.
2018-02-16 13:47:31 -08:00
ZHANG Dapeng df4048d98d
core: retry part 5 continued, throttle policy 2018-02-15 13:15:04 -08:00
Carl Mastrangelo 2f2881756f
core: remove lint warning 2018-02-14 13:10:55 -08:00
Eric Anderson 3480a08e70 core: ConnectivityStateManager is always enabled
There have been no callers of disable() since commit 1c7421be7.
2018-02-13 08:56:43 -08:00
zpencer 890da706bb
Revert "core: tests for forwarding {Server,Client}{Call, CallListener} (#4058)" (#4070)
This reverts commit 77397b9dd0.
2018-02-12 12:21:24 -08:00
Eric Gribkoff 6ee6eae5a0
core: add prepareToLoseNetwork() method to ManagedChannel 2018-02-09 11:05:09 -08:00
zpencer 77397b9dd0
core: tests for forwarding {Server,Client}{Call, CallListener} (#4058) 2018-02-09 10:56:39 -08:00
zpencer 5d5e8c6ad5
core: Install the ServerInterceptor from BinaryLogProvider (#3879) 2018-02-09 10:56:04 -08:00
zpencer 011c7629fd
core: split binlog tests into two in ManagedChannelImplTest (#4049) 2018-02-09 10:52:07 -08:00
zpencer 35f0d15291
core: add subchannel stats (#3967) 2018-02-09 10:50:11 -08:00
zpencer d2c7e33f3e
core: pull out reusable forwarding test, refactoring forwarding tests (#3480) 2018-02-08 16:31:23 -08:00
ZHANG Dapeng bc3e4e9a85
core: Remove incorrect `@GuardedBy` annotations
This change is being made in preparation for fixing a bug in the enforcement
of `@guardedby`.

Non-static inner classes can refer to locks declared by their enclosing
instances. Static member types (static classes, interfaces) cannot.
2018-02-08 14:29:59 -08:00
zpencer f8c7f963ef
core,netty,okhttp: use ServiceProviders for ManagedChannelProvider, ServerProvider (#4047) 2018-02-08 08:57:52 -08:00
ZHANG Dapeng c735bb3385
core: retry part 6, client options - maxAttempts 2018-02-07 18:00:56 -08:00
ZHANG Dapeng e33d39cf93
core: retry part 6, client options - disable retry 2018-02-07 18:00:36 -08:00
ZHANG Dapeng ad62cc2775
core: retry part 5 continued, logic on retry policy
Implement logic for making retry decision using RetryPolicy.
2018-02-07 18:00:04 -08:00
Eric Gribkoff de54a4cb49
core: remove @Internal annotation on @Internal and @ExperimentalApi 2018-02-07 14:40:25 -08:00
Ryan Michela 48fb9ff55f core: Add toString() for MethodDescriptor and ServiceDescriptor (#4013) 2018-02-07 10:30:54 -08:00
zpencer 71cc0e37a8
core: remove unused test resouce files from NameResolverProviderTest (#4048) 2018-02-06 17:37:42 -08:00
zpencer ca40d55e00
core: extract provider class out of ServiceProvidersTest (#4042) 2018-02-05 15:17:57 -08:00
Snow Pettersen 2c8bc71fb7 core: Resolve address of GRPC_PROXY_EXP hostname
Since this address is never resolved gRPC fails to connect with an
UnresolvedAddressException when the env variable is specified. This
should resolve the address before we attempt to proxy to it.
2018-02-01 15:08:42 -08:00
ZHANG Dapeng dc95465f6a
core: retry part 5, add RetryPolicy data object 2018-01-31 11:25:50 -08:00
zpencer 141a1d23ee
core: install the binary logging client interceptor (#3937) 2018-01-31 09:33:12 -08:00
Eric Gribkoff 2f05c23063
Start 1.11.0 development cycle 2018-01-30 15:13:55 -08:00
Eric Anderson d792a72ea1 Revert "core: make ManagedChannel honor Service config LB "
This reverts commit 98aa69af72.

The GSON dependency is noticable on Android for no benefit (currently).
Reverting until we figure out what we want to do.
2018-01-30 13:38:45 -08:00
Eric Anderson fbdc217b46 Revert "core: handle long dns txt records properly, parse service config, and add tests"
This reverts commit b01609572a.

The GSON dependency is noticable on Android for no benefit (currently).
Reverting until we figure out what we want to do.
2018-01-30 13:38:45 -08:00
zpencer 47019325db
core: PartialForwardingServerCall should forward getAuthority (#4009) 2018-01-29 14:02:21 -08:00
zpencer a85b0e1047
core: remove spy() usage in ServerImplTest (#4010) 2018-01-29 14:02:00 -08:00
Kun Zhang df65bef881
core: delete outboundMessage() and inboundMessage() on StreamTracer. (#4014)
They were deprecated in 1.7.0.
2018-01-29 13:42:14 -08:00
zpencer 0465bb5aeb
core,testing: deprecate passing ServerCall to StatsTraceContext (#3912)
Instead, pass a ServerCallInfo object containing the interesting bits
of info. This lets us modify the call handler for binary logging, but
still provide the original info to the StatsTraceContext API.
2018-01-26 16:51:45 -08:00
Bogdan Drutu af936919f3 Update opencensus to 0.11.0 and remove extra dependencies. 2018-01-26 13:04:26 -08:00
Shohei Kamimori 0c21032221 core: change retention policies to CLASS
`@Internal` and `@ExperimentalApi` annotations are not visible at compile time
of application (not grpc-java) because their retention policies are `SOURCE`.
So, change retention policies to `CLASS`.
2018-01-26 13:01:55 -08:00
zpencer 199a5203c5
core: move ChannelStats and TransportStats to io.grpc.internal.Channelz (#4008) 2018-01-25 23:24:49 -08:00
zpencer b109595ad3
core: move Instrumented, LogId, WithLogId to io.grpc.internal as public (#3995) 2018-01-25 17:19:00 -08:00
zpencer 2a93e6b92f
core: NameResolverProvider should use ServiceProviders util (#4005) 2018-01-25 17:18:42 -08:00
zpencer 2996207c20
core: generifiy ServiceProvider class (#3886)
Moving all the common code among different service provider
classes to one place.
2018-01-25 14:12:09 -08:00
zpencer 36670c1fcd
core: disable jndi in gae jdk7 (#4000) 2018-01-25 11:32:19 -08:00
ZHANG Dapeng cd3c9e245b
core: retry part 4, retry attempt header 2018-01-23 17:28:52 -08:00
ZHANG Dapeng 671834fd9e
core: retry part 3: use call executor and sceduled executor service
Use call executor and scheduled executor service to schedule and run `retry()`.

Backoff amount computation from retry policy and testcases during backoff will be added in future PRs.
2018-01-23 10:56:19 -08:00