Commit Graph

1056 Commits

Author SHA1 Message Date
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 ddae5ddaa5 core: Add negotation timeout for all server transports
Negotation is the period between transport creation and ready.
2017-11-10 10:42:29 -08:00
zpencer 18fb4d9c1b
core: ShardedAtomicLongCounter -> AtomicLongCounter (#3704) 2017-11-09 13:06:39 -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
sebright ef2ec94911 core: use new OpenCensus stats/tagging API. (#3647)
This commit updates gRPC core to use io.opencensus:opencensus-api and
io.opencensus:opencensus-contrib-grpc-metrics instead of
com.google.instrumentation:instrumentation-api for stats and tagging. The gRPC
Monitoring Service continues to use instrumentation-api.

The main changes affecting gRPC:

- The StatsContextFactory is replaced by three objects, StatsRecorder, Tagger,
  and TagContextBinarySerializer.

- The StatsRecorder, Tagger, and TagContextBinarySerializer are never null,
  but the objects are no-ops when the OpenCensus implementation is not
  available.

This commit includes changes written by @songy23 and @sebright.
2017-11-07 12:25:03 -08:00
zpencer a7300150de
core: no ProxyDetector for GAE+JDK7 (#3677) 2017-11-07 09:51:22 -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 f86dc6cd83
core: add reflection based LongAdder (#3659) 2017-11-06 10:40:42 -08:00
Eric Gribkoff b31db3cc9b
core: add resetConnectBackoff() method to ManagedChannel 2017-11-03 13:59:50 -07:00
zpencer 2162cd07d5
netty,core: add a TransportTracer class (#3454) 2017-11-02 15:44:21 -07:00
Eric Anderson 2e99214548 core: Add description for Status mapped from error-less Context
The message isn't great, but _much_ better than no message.
2017-11-01 17:10:09 -07:00
Kun Zhang d87ef74082
core: set sampled for local span per MethodDescriptor. (#3627)
This moves away from the global String-based Span name registry which
is not as flexible as we desire.

Also renamed the option name to be more accurate.  This is not
API-breaking because the origianl addition to MethodDescriptor and
code-gen didn't make it into the 1.7.0 release.
2017-11-01 16:46:05 -07:00
ZHANG Dapeng 9a06c4eb0e
testing: favor voidMethod and deprecate noopMethod 2017-11-01 09:36:24 -07:00
ZHANG Dapeng 7a4aa47070 core: remove unnecessary type params in ServerStreamTracer 2017-10-26 12:05:41 -07:00
ZHANG Dapeng 071942dc3b core: fix a race in InProcessTransport
Resolves #3571
2017-10-26 09:32:41 -07:00
Eric Anderson 0ef9ec6275 core: Fix naming style of string constants 2017-10-24 11:48:17 -07:00
Eric Anderson a83fe7bf96 core: Use literal host:port instead of computing
Using HostAndPort just complicates the code. HostAndPort is also @Beta,
which is generally fine to use in tests, but is needless here.
2017-10-24 11:47:46 -07:00
Eric Anderson 8016a1f0e5 core: Add port to proxy URL for Authenticator
Otherwise the scheme (https) is used to determine the port.
2017-10-20 13:50:50 -07:00
Eric Anderson 698ba803d5 Move ProxyDetectorImplTest to core.
It should never have been in okhttp.
2017-10-20 13:49:54 -07:00
Carl Mastrangelo 0ffe759bec core: add since tags for LoadBalancer and NameResolver 2017-10-19 15:21:54 -07:00
Kun Zhang 04f4065a63 core: refresh name resolution when an OOB connection is closed. (#3588)
This is required by an internal use case.  We have already been doing
so for Subchannels.
2017-10-18 15:31:19 -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
Carl Mastrangelo 8187f1e784 util: improve scalability of RR load balancer
In relative order of importance:

* Don't acquire lock when picking subchannel.
* Use O(1) lookup for updating channel state
* Use non synchronized ref instead of AtomicReference
* Dont store size in picker.
* make class final
* remove test that was not valid
2017-10-16 17:43:40 -07:00
Carl Mastrangelo 1c7421be78 core: Remove deprecated load balancer and name resolver APIs 2017-10-12 15:53:31 -07:00
Kun Zhang eae4569e16 core: do not call LoadBalancer callbacks after it's shut down. (#3573)
This behavior is documented in the javadoc of LoadBalancer.shutdown().
2017-10-11 16:46:36 -07:00
Kun Zhang 18ba417241 core: add drop to hashCode() and equals() for PickResult (#3570) 2017-10-11 13:54:16 -07:00
Kun Zhang 61d5baa5f2 core: fix build in CensusStatsModule. 2017-10-09 15:47:57 -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 95a2723ea5 core,grpclb: use denser atomics for census 2017-10-06 17:02:36 -07:00
Kun Zhang 72f6d9bc08 core: add first-class drop support in LoadBalancer.
Resolves #3355

GrpclbLoadBalancer should use PickResult.withDrop() instead of PickResult.withError() when dropping RPCs.
2017-10-06 16:23:10 -07:00
Carl Mastrangelo 291f17059e core: allow attributes to be built multiple times 2017-10-06 16:16:01 -07:00
Carl Mastrangelo 5e36a8deb5 all: upgrade to JUnit 4.12 2017-10-05 11:24:15 -07:00
Carl Mastrangelo f56be5423e core: sort bazel file 2017-10-04 17:39:33 -07:00
Devin Smith f5026cd334 core: remove unused, non-public INTEGER_MARSHALLER (#3530) 2017-10-03 10:42:52 -07:00
Carl Mastrangelo 02466744bb core: move census registration into internal
also preserve tracing bit when rebuilding a MethodDescriptor
2017-09-29 18:20:37 -07:00
ZHANG Dapeng 0d52e68a86 core: fix Bazel build
Resolves #3503
2017-09-29 09:59:55 -07:00
Eric Anderson e92b72588d Promote keepalive to ManagedChannelBuilder; stabilize
Fixes #3493
2017-09-27 11:59:04 -07:00
Eric Gribkoff 63c660b29c core: make enableFullStreamDecompression non-abstract 2017-09-26 10:00:43 -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
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 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
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
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
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
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
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
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
Carl Mastrangelo a53d030b5c core: fix lint warnings 2017-08-25 11:23:03 -07:00
Eric Gribkoff cfc9433ee3 core: advance past empty buffer in CompositeReadableBuffer (#3392) 2017-08-24 21:35:25 -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
John Hume 5c902c9384 Fix gson / opencensus bazel naming mixup
In 72b9ee2, gson kept its old name while opencensus got what should have
become gson's new name instead of a fixed opencensus name.
2017-08-23 15:48:08 -07:00
ZHANG Dapeng dafea0100a core: ForwardingChannelBuilder
Introduced `ForwardingChannelBuilder`, in the same pattern as `ForwardingClientCall` etc.
2017-08-23 12:48:12 -07:00
Kun Zhang 8d6ff4c9b4 core: enable Census trace context propagation. (#3361)
Note a Census tracing implementation, which is not included in gRPC,
is still required for tracing to work.
2017-08-18 17:19:52 -07:00
Kun Zhang 34857580ff core/test: remove ineffective assertions. (#3352)
The assertions are actually wrong and fail every time.  It doesn't
cause test failures because SharedResourceHolder calls them in a
scheduled executor because of its delayed close feature.

It's better to remove them, rather than leaving them there deceiving
us.
2017-08-16 15:59: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 c71e2919de all: fix typo of overridden
s/overriden/overridden/g
2017-08-11 16:53:53 -07:00
ZHANG Dapeng 8e0cf27822 core: use static imports for repeated state enums 2017-08-11 16:53:16 -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 a446b5388f core: switch to scheduled closing of MessageDeframer 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
myPrecious 13ef2261d6 core: Use bulk operation instead of iteration 2017-08-11 15:42:14 -07:00
ZHANG Dapeng 65ea0bde5d core,grpclb: deprecate LoadBalancer.Helper.updatePicker() 2017-08-10 17:05:54 -07:00
ZHANG Dapeng e5ef92c57c core: implement Channel State API for RoundRobin 2017-08-09 18:00:01 -07:00
ZHANG Dapeng 04fd4bc9b1 core: implement Channel State API for PickFirst 2017-08-09 17:59:34 -07:00
Eric Anderson c16edb3c90 core: Providers should consider Robolectric as Android
null class loader means to use the bootstrap class loader, which would
normally make sense. However, Robolectric tests run on OpenJDK and
provide the Android environment as part of the application, so "Android"
won't be present in the bootstrap class loader.
2017-08-09 11:01:15 -07:00
myPrecious f46280ae9f core: Java Refactor
Duplicate throws exception, and Javadoc issues: ManagedChannelImplTransportManagerTest.java has been deleted.
2017-08-09 09:11:19 -07:00
Kun Zhang 16f4de4636 core/stats: report message count metrics to Census. (#3312) 2017-08-04 15:58:21 -07:00
Carl Mastrangelo 02cb718767 testing,core: don't use mocks for stream tracers (#3305)
This is a big, but mostly mechanical change.  The newly added Test*StreamTracer classes are designed to be extended which is why they are non final and have protected fields.  There are a few notable things in this:

1.  verifyNoMoreInteractions is gone.   The API for StreamTracers doesn't make this guarantee.  I have recovered this behavior by failing duplicate calls.  This has resulted in a few bugs in the test code being fixed.

2.  StreamTracers cannot be mocked anymore.  Tracers need to be thread safe, which mocks simply are not.  This leads to a HUGE number of reports when trying to find real races in gRPC.

3.  If these classes are useful, we can promote them out of internal.  I just put them here out of convenience.
2017-08-03 16:59:06 -07:00
Eric Anderson c4f91272d2 all: Remove unused variables and squelch incorrect ErrorProne warning 2017-08-02 15:48:23 -07:00
Stephen Haberman db9b7ed8c0 Don't schedule multiple pings.
If onTransportActive ran while SendPing was already scheduled, we would
schedule another SendPing, which seems fine, but the server might observe
us sending pings too quickly, and make us GOAWAY.

Fixes #3274.
2017-08-01 11:25:24 -07:00
ZHANG Dapeng 18970e6ef3 core: fix ConnectivityStateManager is already disabled bug 2017-08-01 10:26:02 -07:00
Kun Zhang a3a306fd4e core: enable Census tags propagation by default. (#3294)
According to Census team, the tag wire format is now stable.
2017-07-31 14:55:48 -07:00
Eric Anderson 9be41ba0e8 core,auth: Stabilize auth flow using CallCredentials
As discussed in #1914, we need CallCredentials and MoreCallCredentials
to be stable, but there's less of a strong need for the contents of
CallCredentials to be stable. We're willing to commit to the name,
without needing to commit to the plumbing.
2017-07-27 18:07:18 -07:00
Kun Zhang 04e0450304 core: pass CallOptions to newClientStreamTracer(). (#3276)
Resolves #3256
2017-07-27 12:07:25 -07:00
Eric Anderson bd743f3afd core: Channel uses transport's ScheduledExecutorService
Coupled with the similar change on server-side, this removes the need for a
thread when using Netty. For InProcess and OkHttp, it would allow us to let the
user to provide the scheduler for tests or application-wide thread sharing.
2017-07-25 14:26:16 -07:00
ZHANG Dapeng 883a85ee93 core,netty,okhttp: remove 2-arg ClientTransport.newStream()
to keep only one `newStream()` method in the `ClientTransport` interface
2017-07-25 14:12:36 -07:00
Kun Zhang 0fb0fda3e1 core: Override SubchannelImpl.toString() (#3265)
LoadBalancer may log subchannels. This makes the logs more informative.
2017-07-21 17:13:35 -07:00
ZHANG Dapeng 946c29ac32 core: not to expose ClientCallImpl#cancelled() 2017-07-19 12:08:57 -07:00
ZHANG Dapeng 7e9e5a55b1 channel state API plumbing
This is only implementing how subchannel state changes are hooked up to channel state APIs. Debates in state semantics and transition rules for loadbalanced channel such as #2873 are not addressed. Any changes in state semantics and transition rules in the future can be easily adapted.
2017-07-19 11:56:00 -07:00
Eric Anderson 994f200d15 core: Server uses transport's ScheduledExecutorService
For Netty, this reduces the number of threads necessary for servers (although
until channel is converted, actual number of threads isn't impacted) and
naturally reduces contention and timeout latency.

For InProcess, this gets us closer to allowing applications to provide all
executors, which is especially useful during tests.
2017-07-19 10:31:26 -07:00
Eric Anderson d325919f62 core: Use Class.forName(String) in provider for Android
Class.forName(String) is understood by ProGuard, removing the need for
manual ProGuard configuration and allows ProGuard to rename the provider
classes. Previously the provider classes could not be renamed.

Fixes #2633
2017-07-19 10:15:03 -07:00
Carl Mastrangelo 84fce477c2 all: fix minor lint warnings 2017-07-17 17:21:07 -07:00