Commit Graph

375 Commits

Author SHA1 Message Date
Eric Anderson ae68718881 netty: remove unused code in a test 2017-02-13 16:56:10 -08:00
Łukasz Strzałkowski 26913bb82e netty: include SETTINGS_MAX_HEADER_LIST_SIZE in SETTINGS
Closes #2350
2017-02-13 07:37:54 -08:00
Ryan Michela 4029b3f0c2 Implement missing authority API for HandlerRegistry 2017-02-10 17:19:20 -08:00
Eric Anderson cc000be12d netty: Fix CheckReturnValue failure in test 2017-02-09 17:16:19 -08:00
Eric Anderson 42aa64c647 all: swap to newer animalsniffer plugin
The new plugin uses a newer version of animalsniffer, allows overriding
the animalsniffer version used, and has up-to-date handling. The
up-to-date handling cuts fully incremental parallel build times in half,
from 5.5s to 2.7s.

The previous plugin was supposed to be verifying tests. However, either
it wasn't verifying them or its verification was broken.
2017-02-07 12:49:01 -08:00
Carl Mastrangelo dfe61e4ed3 netty: fix race in server channel startup and shutdown 2017-02-06 15:44:03 -08:00
Carl Mastrangelo 1928dc7779 netty: add return value errorprone annotations 2017-02-06 14:53:29 -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
ZHANG Dapeng b1aee9fcc0 netty: call transportReady in handleProtocolNegotiationCompleted
implements the comments mentioned in #2619
2017-02-01 14:55:55 -08:00
Carl Mastrangelo fdeade4ee2 netty: work around netty bug when RPCs may be reset early
For netty/netty#6296
2017-01-30 16:09:19 -08:00
Carl Mastrangelo 0c0ce37bbd all: upgrade to netty 4.1.8 and tcnative Fork26 2017-01-30 12:40:46 -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
Eric Anderson 23f5a6ff2a Add support for http forward proxy with CONNECT
This is a squash and modification of master commits that also includes:
netty,okhttp: Fix CONNECT and its error handling

This commit has been modified to reduce its size to substantially reduce
risk of it breaking Netty error handling. But that also means proxy
error handling just provides a useless "there was an error" sort of
message.

There is no Java API to enable the proxy support. Instead, you must set
the GRPC_PROXY_EXP environment variable which should be set to a
host:port string. The environment variable is temporary; it will not
exist in future releases. It exists to provide support without needing
explicit code to enable the future, while at the same time not risking
enabling it for existing users.
2017-01-27 09:27:07 -08:00
Łukasz Strzałkowski aa0391a427 core: pass down addr to which client is connected
This addresses #2613
2017-01-26 15:11:39 -08:00
Carl Mastrangelo 89bc2cd3b2 all: update to latest import ordering 2017-01-26 13:43:06 -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
Carl Mastrangelo d5eb248737 all: bump to netty 4.1.7 2017-01-19 15:24:26 -08:00
Eric Anderson 1e99b299e1 all: ErrorProne fixes and avoid @Beta in Guava 2017-01-19 12:16:05 -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
htuch 7fbee39c3a Introduce a grpc-exp ALPN protocol identifier
This patch introduces an additional ALPN protocol, grpc-exp, intended to
take preference to h2 and indicate to the server that the connection
contains only gRPC traffic. This allows servers and intermediate boxes
to distinguish gRPC from other HTTP/2 traffic.

The choice of grpc-exp as a protocol identifier indicates that this
scheme is currently experimental and should not be relied upon. The
protocol is not in the IANA TLS registry.

This is the grpc-java equivalent of
8cdf17a620.

Due to the opacity of ALPN and TLS negotiation at application level, the
tests are only there to validate that the lists we're feeding into the
negotiation process have the desired ordering properties:

  * If grpc-exp is present, h2 is as well.

  * grpc-exp is preferenced over h2.
2017-01-09 10:40:56 -08:00
ZHANG Dapeng bff6506f92 netty: no add_dep io.netty.handler.ssl.SslContext (#2529)
Not to expose dependency of `io.netty.handler.ssl.SslContext` when implementing `TransportCreationParamsFilter`

Change the `TransportCreationParamsFilter` API
````
ProtocolNegotiator getProtocolNegotiator(NegotiationType negotiationType, SslContext sslContext);
````
into
````
ProtocolNegotiator getProtocolNegotiator();
````
2016-12-16 16:20:31 -08:00
Carl Mastrangelo cb6cf1ae2f netty: refactor how internal netty channel works 2016-12-16 10:36:12 -08:00
ZHANG Dapeng e36eb10728 codehealth: errorprone, unused 2016-12-15 13:13:26 -08:00
Anuraag Agrawal 221fadcbdd Implement setListener in AbstractServerStream and remove from subclasses. 2016-12-14 12:29:10 -08:00
Carl Mastrangelo 677f05d7fb netty: move internal channel builder code to a special accessor 2016-12-13 11:17:00 -08:00
Łukasz Strzałkowski bd9e041b74 netty: Add support for keepalive 2016-12-12 09:02:24 -08:00
Lukasz Strzalkowski 483f3d55e9 Remove deadcode 2016-12-05 14:17:13 -08:00
Carl Mastrangelo 209a32fd1a core,netty: add a log id to the server and server transports 2016-12-05 09:47:35 -08:00
Carl Mastrangelo e9779d7c00 all: use a proper log id which can reference channels, subchannels, and transports 2016-12-02 15:35:11 -08:00
Carl Mastrangelo 5269a1b969 netty: call the client ssl negotiation handler
* netty: call the client ssl negotiation handler
2016-11-30 08:47:20 -08:00
ZHANG Dapeng e70f7b421c all: cleanup - errorprone, unused 2016-11-16 19:15:16 -08:00
ZHANG Dapeng 0d694c80ee core,netty: quick patch for setListener regression
resolves grpc/grpc#8715
now that setListener is called prior to
`JumpToApplicationThreadServerStreamListener` being completely ready to
use. We should not call `AbstractStream2#onStreamAllocated()` inside
`setListener()` anymore, but call it after `ServerImpl#streamCreated()`
is completed.
2016-11-11 19:39:16 -08:00
ZHANG Dapeng 0e27eef168 core: fix bug when stream listener not set before stream closed
Resolves #1936

Two bugs fixed:
- NPE in `ServerImpl#streamCreated()` when stream listener not set before
  stream closed
- It is possible that `internalCancel()` is called during
  `InProcessClientStream#start()` due to early server `onComplete()` or server `onError()`,
  in this case no need to enlist `streams`, otherwise the channel can not be shutdown by `shutdown()`.
2016-11-09 15:21:11 -08:00
ZHANG Dapeng e40668499c netty: add channel options in NettyChannelBuilder
Add `withOption(ChannelOption<T> option, T value)` method to
`NettyChannelBuilder`. This allows user to set a custom TOS.
2016-11-09 13:32:05 -08:00
Eric Anderson 78107a69c0 core: Do not rely on HTTP 200
We only want to use the HTTP code for errors, when the response is not
grpc. grpc status codes may be mapped to HTTP codes in the future, and
we don't want to break when that happens. We also don't want to ever
accidentally use Status.OK without receiving it from the server, even
for HTTP 200.
2016-11-01 17:35:15 -07:00
Carl Mastrangelo fdd062c465 core: make max message size part of the public API 2016-10-27 14:11:44 -07:00
Carl Mastrangelo 2417660687 netty: fix static data race on handler settings 2016-10-26 13:52:10 -07:00
Carl Mastrangelo 8702185e8c netty: use memory efficient slice in Buffer 2016-10-20 13:29:36 -07:00
Jakob Buchgraber 6fa63a6371 netty: Upgrade to 4.1.6 and tcnative Fork23. Fixes #2224 (#2349) 2016-10-20 00:24:58 +02:00
Jakob Buchgraber 10f4c90f4e core: Call onSentBytes only if future is successfull. (#2339)
For example, if opening a stream failed after a DATA frame had already been queued.
2016-10-17 19:23:19 +02:00
Jakob Buchgraber 1e1c71d74c netty: Add toString() to GrpcHttp2InboundHeaders. Fixes #2341. (#2342)
Binary header values are printed in their base64 encoded form.

The GrpcHttpOutboundHeaders, as mentioned in the issue, don't seem to be affected by this regression. The toString() method seems fine.
2016-10-14 18:57:08 +02:00
Jakob Buchgraber 96069958f6 netty: Remove RequestMessagesCommand (#2333)
It's not needed. Can do the same by scheduling a task on the eventloop.
2016-10-14 01:23:19 +02:00
Jakob Buchgraber 14cc0dbe2b netty: Special case Http2ChannelClosedException. Fixes #2279 (#2334) 2016-10-14 00:14:55 +02:00
Eric Anderson e7ce41dd94 all: Style, unused, and errorprone fixes 2016-10-12 16:57:01 -07:00
Kun Zhang 132f7a9a33 core: Census integration for stats (#2262)
Highlights
==========

StatsTraceContext
-----------------

The bridge between gRPC library and Census. It keeps track of the total
payload sizes and the elapsed time of a Call. The rest of the gRPC code
doesn't invoke Census directly.

Context propagation
-------------------

StatsTraceContext carries CensusContext (and the upcoming TraceContext)
and is attached to the gRPC Context.

1. StatsTraceContext is created by ManagedChannelImpl, by calling
createClientContext(), which inherits the current CensusContext if available.

2. ManagedChannelImpl passes StatsTraceContext to ClientCallImpl, then
to the stream, then to the framer and deframer explicitly.

3. ClientCallImpl propagates the CensusContext to the headers.

1. ServerImpl creates a StatsTraceContext by implementing a new callback
method StatsTraceContext methodDetermined(MethodDescriptor, Metadata) on
ServerTransportListener.

2. NettyServerHandler calls methodDetermined() before creating the
stream, and passes the StatsTraceContext to the stream.

3. When ServerImpl creates the gRPC Context for the new ServerCall, it
calls the new method statsTraceContext() on ServerStream and puts the
StatsTraceContext in the Context.

Metrics recording
-----------------

1. Client-side start time: when ClientCallImpl is created

2. Server-side start time: when methodDetermined() is called

3. Server-side end time: in ServerStreamListener.closed(), but before
calling onComplete() or onCancel() on ServerCall.Listener.

4. Client-side end time: in ClientStreamListener.closed(), but before
calling onClonse() on ClientCall.Listener

Message sizes are recorded in MessageFramer and MessageDeframer. Both
the uncompressed and wire (possibly compressed) payload sizes are
counted.

TODOs
=====

The CensusContext created from headers on the server side should be
attached to the gRPC Context for the call.  It's not done at this moment
because Census lacks the proper API to do it. It only affects tracing
and resource accounting, but doesn't affect stats functionality
2016-10-06 17:15:24 -07:00
dapengzhang0 4e5765a93f all: fix minor JavaStyle errors found in code sync 2016-10-05 09:28:16 -07:00
Eric Anderson cad7124c27 core,netty: split stream state on client-side; AbstractStream2
OkHttp will need to be migrated in a future commit.
2016-10-03 11:10:38 -07:00
Jakob Buchgraber 7aa0e1a901 netty: server support extension content types (#2306)
Removed a (left over?) content type check that checks for equality with "application/grpc".
The content type is verified using checkContentType(..).
2016-09-30 10:05:21 +02:00