Commit Graph

497 Commits

Author SHA1 Message Date
Xiaoshuang LU cdb1f54794 netty: make server sockets be configurable 2017-11-22 16:00:33 -08:00
Eric Anderson 9bdb8f005a netty: Include more stace trace information for ClosedChannelExceptions
There's been another sighting, but it's very hard to narrow down what is
triggering it.
2017-11-17 13:18:52 -08:00
zpencer 2f155606b8
core,netty: add ID to NettyServer (#3745)
These are already WithLogId:
 ManagedChannelImpl, InternalSubchannel, ServerTransport
2017-11-15 11:49:13 -08:00
ramaraochavali df357cb8d3 netty: Netty server poorly handles unknown content type 2017-11-15 11:32:50 -08:00
ZHANG Dapeng 66f9ef5d69
netty: fix server keepalive unexpected ping ack
Resolves #3684
2017-11-14 11:09:31 -08:00
Kun Zhang de06a9471a
core: add internal accessors to control stats recording of RPC upstarts. (#3736) 2017-11-14 11:00:20 -08:00
zpencer 47bee4feee
core,netty: plumb fake clock into transport tracer tests (#3724) 2017-11-13 15:58:29 -08:00
zpencer d0a84ae5b8
core,netty: wire TransportTracer to netty client (#3705) 2017-11-10 15:55:21 -08:00
Eric Anderson b026ea544c netty: Avoid clearing SSLParameters
Since Netty may have set some parameters already, we should modify the
existing SSLParameters instead of starting from scratch.

This may fix ALPN with JDK9, but full support for ALPN with JDK9 is
still later work and we're not supporting it yet.

Fixes #3532
2017-11-10 13:08:58 -08:00
ramaraochavali 17e1ad9bb2 core: Add useTransportSecurity to ManagedChannelBuilder
This allows the consumer of a builder to swap back from plaintext.
2017-11-10 10:57:05 -08:00
Eric Anderson 93e89ba704 netty: Move server transportReady after client preface receipt
This mirrors the behavior of client-side.
2017-11-10 10:42:29 -08:00
zpencer 9ae5f116b5
netty: TransportTracer test for local window update (#3710) 2017-11-09 17:13:04 -08:00
zpencer af4cd2ebfd
netty: bump correct value of outbound msg counter (#3667)
No need for SendFrameGrpcCommand to know about the message count.
2017-11-09 11:32:19 -08:00
Eric Anderson bbb98feb75 Fix broken method names in tests that include leading '/'
The method name passed to MethodDescriptor does not include the leading
'/'. If it does, on the wire it will actually cause two slashes. This
has been this way for a _long_ time, but in tests that ignore the method
name or use the same MethodDescriptor no client and server the extra /
"works fine." But it's misleading, so let's remove it.
2017-11-08 15:24:50 -08:00
zpencer f2968f518f
core,netty: correctly count streams that ended due to client cancel (#3683)
Only bump the counter from AbstractServerStream.TransportState, and hole punch
from AbstractServerStream to TransportState when the application calls close.
2017-11-08 13:18:12 -08:00
zpencer a3c44fa7ca
core,netty,okhttp: add TransportTracer param to ClientStream and Http2ClientStreamTransportState (#3668)
This diff does not actually change any behaviors yet, that will come
in the next diff along with unit tests for those new behaviors. This
diff's goal is only to change the method signatures so future diffs
are cleaner.
2017-11-07 16:08:55 -08:00
zpencer a2e9a7f6dd
core,ntety,okhttp: Add getTransportStats method to ClientTransport (#3662)
This merely adds the method but does not do anything yet.
2017-11-06 13:24:20 -08:00
zpencer 9fac15d4f8
core,netty,okhttp: move transport tracer outbound counters to transport thread (#3661)
Counters are bumped when a message is completely written. If a
part of a message is still buffered and not yet flushed, we will
not increment the stats.
2017-11-06 12:46:17 -08:00
zpencer 2162cd07d5
netty,core: add a TransportTracer class (#3454) 2017-11-02 15:44:21 -07:00
Ray Tsang 80a8c8f3d7 netty: Updated ALPN error message and added troubleshooting procedures 2017-11-01 13:01:43 -07:00
Carl Mastrangelo 8f88cb82f2
netty: include rst stream message in Status 2017-10-31 10:49:25 -07:00
zpencer 5856a932c3
netty: separate connection log (#3591)
Move netty connection log info to a separate logger:
  io.grpc.netty.NettyServerTransport.connections

Users can redirect or disable this log using the usual way:
  -Djava.util.logging.config.file="logging.properties"
2017-10-27 13:15:49 -07:00
zpencer 7df9ae9753 core,netty,okhttp: detect proxy via ProxySelector (#3021)
This lets us specify the proxy using `-Dhttps.proxyHost=host -Dhttps.proxyPort=port`
along with auth info like username and password.
2017-10-17 19:26:11 -07:00
Kun Zhang 8edead0851 core: make in-process transport support StreamTracer
This is needed for both completeness and stats/tracing contexts propagation.

Stats recording with Census is intentionally disabled (#2284), while the rest of the Census-related logic work the same as on the other transports.
2017-10-09 10:14:36 -07:00
Carl Mastrangelo 5e36a8deb5 all: upgrade to JUnit 4.12 2017-10-05 11:24:15 -07:00
Eric Anderson e92b72588d Promote keepalive to ManagedChannelBuilder; stabilize
Fixes #3493
2017-09-27 11:59:04 -07:00
Carl Mastrangelo 80334d5b2f netty: update to 4.1.16 2017-09-25 18:18:17 -07:00
Eric Gribkoff 5ac9ad0c1f core: client supports inbound gzipped streams (#3403) 2017-09-25 09:01:53 -07:00
Kun Zhang 8ee9fb5183 core: add internal API to disable stats and/or tracing. (#3464) 2017-09-15 10:00:12 -07:00
Carl Mastrangelo abea73c0af core: add finalizer checks for ManagedChannels (#3452)
* core: add finalizer checks for ManagedChannels

Cleaning up channels is something users should do.  To promote this
behavior, add a log message to indicate that the channel has not
been properly cleaned.

This change users WeakReferences to avoid keeping the channel
alive and retaining too much memory.  Only the id and the target
are kept.  Additionally, the lost references are only checked at
JVM shutdown and on new channel creation.  This is done to avoid
Object finalizers.

The test added checks to see that the message is logged.  Since
java does not allow forcing of a GC cycle, this code is best
effort, giving up after about a second.  A custom log filter is
added to hook the log messages and check to see if the correct
one is present.  Handlers are not used because they are
hierarchical, and would be annoying to restore their state after
the test.

The other tests in the file contribute a lot of bad channels.  This
is reasonable, because they aren't real channels.  However, it does
mean that less than half of them are being cleaned up properly.
After trying to fix a few, it is too hard to do.  It would only
serve to massively complicate the tests.

Instead, this code just keeps track of how many it wasn't able to
clean up, and ignores them for the test.  They are still logged,
because really they should be closed.
2017-09-14 21:19:22 -07:00
zpencer 2b1363d586 core,netty,okhttp,protobuf-lite: avoid @Beta guava classes (#3463) 2017-09-14 19:39:06 -07:00
zpencer bda67784c0 core,netty,okhttp: strip outbound headers with reserved names (#3098)
These will be stripped:
CONTENT_TYPE, TE, USER_AGENT
2017-09-14 15:26:36 -07:00
Eric Anderson 2d711687f9 Revert "netty: hide ProtocolNegotiator, and expose initial ChannelHandler"
This reverts commit 332c46ff1a.

We need the protocol negotiator exposed for alternative
handshake/security mechanisms.
2017-09-14 12:15:04 -07:00
Carl Mastrangelo 332c46ff1a netty: hide ProtocolNegotiator, and expose initial ChannelHandler
* netty: hide ProtocolNegotiator, and expose initial ChannelHandler

This change does two things: it hides the ProtocolNegotiator from
NSB, and exposes an internal "init channel" on NSB and NCB.  The
reason for the change is that PN is not a powerful enough
abstraction for internal Google use (and for some other outside
users with highly specific uses).

The new API exposes adding a ChannelHandler to the pipeline upon
registration of the channel.

To accomplish this, NettyClientTransport is modified to use
ChannelInitializer.  There is a comment explaining why it cannot
be used, but after looking at the the original discussion, I
believe the reasons for doing so are no longer applicable.

Specifically, at the time that CI was removed, there was no
WriteQueue class.  The WQ class buffers all writes and executes
them on the EventLoop.  Prior to WQ it was not the case that all
writes happened on the loop, so it could race.  If the write was
not on the loop, it would be put on the loops execution queue,
but with the CI handler as the target.  Since CI removed itself
upon registration, the write wouldn get fired on the wrong
handler.

With the additional of WQ, this is no longer a problem.  All
writes go through WQ, and only execute on the loop, so pipeline
changes are no longer racy.

...That is, except for the initial noop write.  This does still
experience the race.  If the channel is failed during
registration or connect, the lifecycle manager will fail for
differing, racy reasons.

====

To make things more uniform across NCT and NST, I have put them
both back to using CI.  I have added listeners to each of the
bootstrap futures.  I have also moved the initial write to the
CI, so that it always goes through the the buffering negotiation
handler.

Lastly, racy shutdown errors will be logged so that if multiple
callbacks try to shutdown, it will be obvious where they came
from and in which order they happened.

I am not sure how to test the raciness of this code, but I *think*
it is deterministic.  From my reading, Promises are resolved
before channel events so the first future to complete should be the
winner.  Since listeners are always added from the same thread,
and resolved by the loop, I think this forces determinism.

One last note: the negotiator has a scheme that is hard coded
after the transport has started.  This makes it impossible to
change schemes after the channel is started.  Thats okay, but it
should be a use case we knowingly prevent.  Others may want to
do something more bold than we do.
2017-09-12 19:56:25 -07:00
Eric Gribkoff ec600feb87 okhttp: set GET method in headers (#3316) 2017-09-11 13:58:33 -07:00
zpencer e6fc6f33a5 netty: NOOP_MESSAGE must be staged before connect() (#3411)
Addresses flakey test
Fixes #3408
2017-08-28 17:48:14 -07:00
Eric Anderson 6164b7b2ee Move jmh benchmarks to their respective modules
The benchmarks should be close to the code they're benchmarking, like
we do with tests.

This includes a bugfix to SerializingExecutorBenchmark to let it run.

The io.grpc.benchmarks.netty benchmarks in benchmarks/ depend on
ByteBufOutputMarshaller from benchmarks's main, so they were not moved.
2017-08-28 13:37:39 -07:00
Eric Anderson 97c625fa79 netty: Update to Netty 4.1.15
We'll need to figure out what we want to do about the deprecated API.
We'll probably just drop the verification check, but need to look into
it a bit.
2017-08-28 10:23:13 -07:00
Carl Mastrangelo c024f17429 netty,okhttp: include more detail about ALPN missing
Additionally: include info on why android classes are missing
2017-08-24 16:00:36 -07:00
zpencer 68e8dc240c netty: graceful shutdowns should for streams to close (#3386)
Previously we have a hard timeout of 5s, which isn't very graceful.
2017-08-24 10:16:12 -07:00
John Hume 7d0229a1f5 Also fix bazel name of io.netty:netty-transport 2017-08-23 15:48:08 -07:00
ZHANG Dapeng fe1583c9b4 netty: fix transport spuriously in notInUse state
Previously, if two streams are added (but not active yet), then the transport is changed into inUse; after that, if one of them gets active and then closed and removed, then the transport will be changed into and staying at notInUse, although the other stream could later be active.
2017-08-23 13:38:05 -07:00
Eric Anderson 6ca91c4356 netty: Handle shutdown and failures during negotiator
NettyClientTransport needs to call close() on the Channel directly
instead of sending a message, since the message would typically be
delayed until negotiation completes.

The closeFuture() closes too early to be helpful, which is very
unfortunate. Using it squelches the negotiator's error handling. We now
rely on the handlers to report shutdown without any back-up. The
handlers error handling has matured, so maybe this is okay.
2017-08-18 14:38:48 -07:00
Kun Zhang 41410345e6 core: pass status to ManagedClientTransport.shutdown() (#3351)
This aligns with shutdownNow(), which is already accepting a status.
The status will be propagated to application when RPCs failed because
of transport shutdown, which will become useful information for debug.
2017-08-16 10:23:07 -07:00
ZHANG Dapeng 577bbefd1a netty: fix keepalive test flakiness
In `NettyHandlerTestBase` class, extended Netty's `EmbeddedChannel` by overriding`eventLoop()` to return an `eventLoop` that uses `FakeClock.getScheduledExecutorService() to schedule tasks.

Resolves #3326
2017-08-15 10:49:01 -07:00
ZHANG Dapeng 34f31fe3c6 netty: Not to ignore tests for window overriding
As noted after `@Ignore`
> Re-enable once https://github.com/grpc/grpc-java/issues/1175 is fixed

#1175 has been closed for a long time, should re-enable the tests.
2017-08-14 12:58:17 -07:00
ZHANG Dapeng c71e2919de all: fix typo of overridden
s/overriden/overridden/g
2017-08-11 16:53:53 -07:00
Eric Gribkoff 9b74f8e756 core,netty,okhttp: add option to deframe in app thread 2017-08-11 16:52:45 -07:00
Eric Gribkoff 16575d01a3 core,netty,okhttp,testing: switch to StreamListener.messagesAvailable 2017-08-11 16:52:45 -07:00
Paul Gross 72b9ee22b8 all: Fix mismatch in naming Bazel Maven jars
This commit aligns the naming of the Bazel Maven jars with the names
used by Bazel's migration-tooling project:

https://github.com/bazelbuild/migration-tooling

Unfortunately, we can't fix @com_google_protobuf_java because it's
required by Bazel itself.

Fixes #3328
2017-08-11 16:39:43 -07:00