Commit Graph

2221 Commits

Author SHA1 Message Date
Carl Mastrangelo 80334d5b2f netty: update to 4.1.16 2017-09-25 18:18:17 -07:00
Eric Gribkoff a8db154702 testing: reduce mocks in AbstractTransportTest to eliminate flakes 2017-09-25 17:58:05 -07:00
Kun Zhang a6653bb135 core/compiler: register Span names for code-generated methods (take 2)
This is a more favorable approach than #3467. Doing the registration
in MethodDescriptor should allow us to deregister in case the
generated stub and its MethodDescriptors are garbage-collected
routinely, e.g., if they are loaded by a separate ClassLoader.
2017-09-25 15:38:48 -07:00
Eric Gribkoff 5ac9ad0c1f core: client supports inbound gzipped streams (#3403) 2017-09-25 09:01:53 -07:00
Eric Gribkoff a34ea3592c core: add gzip inflater for compressed streams (#3395) 2017-09-22 09:09:37 -07:00
ZHANG Dapeng 20c910f809 core: nonnull pendingStreams in DelayedClientTransport
Make `pendingStreams` in `DelayedClientTransport` non-null.
2017-09-22 09:04:58 -07:00
Brendan Linn 131a0ff39a java_grpc_library.bzl: fix path-manipulation bug.
_path_ignoring_repository munges bazel filesystem paths into proto
import paths, in order to pass to protoc -I. Currently, the function
assumes that the include's path begins with the bazel workspace root,
which can therefore be sheared off the front of the path.

This assumption is incorrect. For an include living in an external
repository (say, `@com_google_protobuf//:timestamp_proto`),
the filesystem path is something like
`bazel-out/darwin_x86_64-fastbuild/genfiles/external/com_google_protobuf/google/protobuf/timestamp.proto`.
(See also:
http://docs.bazel.build/versions/master/skylark/lib/Label.html#workspace_root.)
This commit changes _path_ignoring_repository to handle this case correctly.
2017-09-21 13:23:17 -07:00
Eric Anderson 5bf4f5b7a6 context: Use .class literal instead of Class.forName
Found via ErrorProne
2017-09-20 09:43:50 -07:00
Eric Anderson bd28b92850 Avoid catching AssertionError in tests
Found via ErrorProne
2017-09-20 09:43:50 -07:00
pieterjanpintens 6bb1755357 core: allow to fallback to ServiceLoader.load withouth classloader to
make GRCP more OSGi friendly.
2017-09-20 08:42:16 -07:00
Kun Zhang 0ba4ab8b85 core: remove reference to Guava collect
It was added by mistake in commit 2b1363d586
2017-09-19 16:26:29 -07:00
Kun Zhang 7e534ed704 core: record individual messages with sizes to Census/tracing (#3461)
Two methods, outboundMessageSent() and inboundMessageRead() are added to StreamTracer in order to associate individual messages with sizes. Both types of sizes are optional, as allowed by Census tracing.

Both methods accept a sequence number as the type ID as required by Census. The original outboundMesage() and inboundMessage() are also replaced by overrides that take the sequence number, to better match the new methods. The deprecation of the old overrides are tracked by #3460
2017-09-19 09:22:11 -07:00
Eric Anderson a3ff9cd784 all: Keep artifacts dependencyConvergence-clean
Maven Enforcer's dependencyConvergence is commonly used in Spring
projects, as it is inherited by all starter projects[1]. While I find
that option to be crazy and harmful (and would instead support
requireUpperBoundDeps), it does bother people.

1. https://github.com/spring-projects/spring-boot/blob/v1.5.6.RELEASE/spring-boot-starters/pom.xml#L94
2017-09-18 16:20:18 -07:00
Kun Zhang a9941a8bcf okhttp/test: add missing annotation. (#3476) 2017-09-18 15:35:18 -07:00
Carl Mastrangelo 2924e30e45 android-interop-testing: use Java Style enums
This makes it easier to convert over to Proto lite, which will be
replacing nano in the near future.

This CL is a port originally from @arielbackenroth
2017-09-15 11:49:31 -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 bb203657cb okhttp: update caller of Headers.createRequestHeaders (#3465) 2017-09-14 17:19:36 -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
zpencer 86dec11f7b context: log severe warning if ancestry chain too long (#3459)
If a context has an unreasonable number of ancestors, then
chances are this is an application error. Log the stack trace to
notify the user and aid in debugging.
2017-09-14 11:39:19 -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
Kun Zhang df92533524 grpclb: fallback to backend addresses (#3439)
The GRPCLB client will use the backend addresses from resolver if it has not received any server list from any balancer after a certain timeout (10s).
2017-09-12 12:25:08 -07:00
Eric Gribkoff ec600feb87 okhttp: set GET method in headers (#3316) 2017-09-11 13:58:33 -07:00
Lukasz Strzalkowski 731bbefb17 core, compiler, protobuf: introduce MethodDescriptor#setSchemaDescriptor 2017-09-11 09:57:03 -07:00
ZHANG Dapeng 65530bb71b core: ClientCallImpl start should not be called after cancel
Added checkState for this condition.
2017-09-11 09:45:07 -07:00
zpencer b8b5f5e046 protobuf-nano: do not use preexisting IoUtils internal class #3450
This reverts commit 671783f

The dependency on core caused some problems with
Proguard. There are android builds that should include
protobuf-* but expect the rest of gRPC to be bundled with the
runtime environment. In that case, when Proguard inspects the
output, it will find a reference to IoUtil but fail to find the
class itself. It makes the builds easier to just avoid this
dependency.
2017-09-08 16:33:27 -07:00
Carl Mastrangelo 53f56a32f1 inprocess,core: add ManagedChannelBuilder and ServerBuilder factory hiders
* inprocess,core: add ManagedChannelBuilder and ServerBuilder factory hiders

Because the factory for Channels and Servers resides on the builder
itself, it is easy for subclasses to accidentally inherit the
factory.  This causes confusion, because calling a static method on
a specific class may result in a different class.

This change adds hiding static factories to each builder, and a test
to enforce that each subclass hides the factory.  The test lives in
the interop tests, because it has a classpath dependency on all the
existing transports.

Minor note: the test scans the classpath using a Beta Guava API.
The test can be disabled if the API goes away.
2017-09-06 15:21:17 -07:00
Kun Zhang ddd31d6799 core/census: set method name tag to the server handler's context (#3436) 2017-09-06 10:04:50 -07:00
zpencer 671783f912 protobuf-nano: use existing class IoUtils for toByteArray (#3437)
protobuf-nano: use existing class IoUtils and force protobuf-nano
to use exact version of internal
2017-09-06 07:30:58 -07:00
zpencer 78831690f6 protobuf-nano: avoid using @Beta API com.google.common.io.ByteStreams (#3433) 2017-09-05 09:08:52 -07:00
Carl Mastrangelo aaebf6e967 core: name more anonymous classes in ServerImpl
This makes it much easier to read stack traces since the name of the
event is in the frame.
2017-09-01 15:32:07 -07:00
zpencer b579528c89 Update README to reference 1.6.1 (#3428) 2017-08-31 15:24:33 -07:00
Carl Mastrangelo 4c721b7490 core: save alloc in SerializingExecutor 2017-08-30 12:52:25 -07:00
Carl Mastrangelo f61acf5eb9 core: remove unused buffer methods 2017-08-29 19:05:06 -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 Gribkoff 812e65a5ca context: add RunWith annotation 2017-08-28 12:11:02 -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
Eric Anderson 3620931eae context: Use polymorphism instead of canBeCancelled field 2017-08-28 09:41:56 -07:00
Eric Anderson 21cd244734 context: Remove superfluous cascadesCancellation field 2017-08-28 09:41:56 -07:00
Eric Anderson 32cd4a0660 compiler: Produce unified output on diff failure
This includes the file names and context, which is soo much nicer.
2017-08-25 16:41:39 -07:00
Carl Mastrangelo 24ff2748b7 all: update to proto 3.4.0 2017-08-25 11:25:36 -07:00
Carl Mastrangelo a53d030b5c core: fix lint warnings 2017-08-25 11:23:03 -07:00
Kun Zhang 485431880f grpclb: remove expiration_interval. (#3398) 2017-08-25 10:49:46 -07:00
Eric Gribkoff cfc9433ee3 core: advance past empty buffer in CompositeReadableBuffer (#3392) 2017-08-24 21:35:25 -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
Eric Anderson 521c55e9bd Avoid request threads on AppEngine Java 8
While the code had correctly determined full threads were available, the
call to MoreExecutors returned a request thread factory, which has
limitations.

Note that Async stub users may not be able to call GAE APIs in
callbacks. This is because the threads aren't request threads. They can
override the individual call's executor with
com.google.appengine.api.ThreadManager.currentRequestThreadFactory() in
an interceptor via callOptions.withExecutor().

Fixes #3296
2017-08-24 15:47:45 -07:00
ZHANG Dapeng 23dfc84ccf interop-testing: fix dealineExceeded test flakiness by increasing time interval
Should resolve #1399
2017-08-24 14:27:49 -07:00