Commit Graph

931 Commits

Author SHA1 Message Date
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
Carl Mastrangelo e60a179772 core: hide access to pseudo headers
Previously anyone could create metadata keys with a leading ":", due to not having a way to prevent it. This change effectively only allows internal code to make use of this.
2017-07-17 11:00:53 -07:00
ZHANG Dapeng 1661b51272 core: refactor SubchannelImpl
* refactor SubchannelImpl -> AbstractSubchannel

The old `SubchannelImpl` is actually not implementing anything, and the old `SubchannelImplImpl` has a weird name.
2017-07-14 11:05:09 -07:00
zpencer 26caa488a5 core: update javadocs regarding ClientCall mocks (#3140)
Change the @DoNotMock message to refer to InProcessServerBuilder, and include some usage examples that users may find useful.

fixes #3124
2017-07-13 08:19:29 -07:00
Bogdan Drutu 482b651605 core: Change gRPC to use io.opencensus:opencensus-api:0.5.1. (#3204) 2017-07-11 10:13:23 -07:00
Carl Mastrangelo 3a5f115dbc core: clarify security methods on channel and server 2017-07-07 10:56:54 -07:00
Eric Anderson c637b42b71 core: Stop using context ClassLoader in Providers
currentThread().getContextClassLoader() was originally used to match
ServiceLoader's default. ServiceLoader is mostly used with SPIs that
exist in the bootclasspath and so the class's ClassLoader would not
work. But in gRPC we have a library in the application's ClassLoader.

Context ClassLoader has been causing problems in any case more than one
application ClassLoader exists, like in Servlet containers, Android, and
plugins. To my knowledge, in every case the context class loader is
different from the provider's class loader, the context class loader has
caused breakage, not success. In addition, since we use static fields
for storing the provider results, using anything but the provider's
class loader is asking to have results that vary simply depending on
which thread called gRPC first.

Fixes #2375
2017-07-06 11:02:31 -07:00
Eric Anderson 7384ea9da1 core: Simplify ServerImpl constructor; testable Builder 2017-07-04 20:20:04 -07:00
Eric Anderson c436561fc5 all: Use fixed version number for java 6/7 signatures
This is important for stable builds, as if the signature changes the old source
may no longer validate.
2017-06-30 15:25:34 -07:00
Eric Anderson 6d8a66f3e3 core: Mark InternalNotifyOnServerBuilder @Internal
It is misnamed if it is @ExperimentalApi. Even being @Internal is
strange, since nothing in io.grpc actually uses it and so it could
actually be in io.grpc.internal.

I'm not trying to fix the API, but just make it slightly more
consistent.
2017-06-29 21:46:20 -07:00
Eric Anderson a3ac64a883 core: Move client-side decompressor selection to stream
Previously ClientCallImpl's stream listener would call
stream.setDecompressor(), but this has always been a bit strange as the
only case where the call listener calls the stream and forms a bit of a
loop. It also turned out to be racy in the presence of
DelayedClientStream since DelayedClientStream does not guarantee that
the listener has processed before returning.

Now we let the stream handle decompressor selection itself. Compressor
selection on client and server and decompressor selection on server
remain unchanged. Nothing prevents them from being changed, other than
it is currently unnecessary to fix the severe compressionTest flake.

Fixes #2865
Fixes #2157
2017-06-29 18:12:53 -07:00
Carl Mastrangelo 45085c3ce4 core: minor cleanup of 859d211b6e 2017-06-28 12:36:33 -07:00
Kun Zhang 4b94237bb9 core: stop spying ServerCall in UtilServerInterceptorsTest. (#3146)
Per our internal checker, DoNotMock applies to spy() too.
2017-06-27 17:15:43 -07:00
Eric Anderson 418c8846d0 core: Fix Bazel building for :util
It is now using io.grpc.internal.SerializingExecutor.
2017-06-27 11:10:34 -07:00
ZHANG Dapeng b7e50ddd05 testing: move NoopClientCall & NoopServerCall to internal
one step for #3105
2017-06-22 15:10:58 -07:00
Simon Horlick 6d9e149dcb build: Add Bazel java_grpc_library rule
Bazel third party dependencies are specified in repositories.bzl which
gives the consumer the ability to opt-out of any dependencies they use
directly in their own project.

Fixes #2756
2017-06-22 13:06:49 -07:00
Carl Mastrangelo 51ce204f53 inprocess: mark all classes final 2017-06-22 12:25:32 -07:00
Kun Zhang 859d211b6e core: ServerBuilder.intercept(). (#3118)
This adds server-wide interceptors that applies to all call handlers.
Because ServerCallHandler is acquired per request, and can be dynamicly
provided by the fallback registry, the interceptors have to be installed
on a per-request basis. This adds a few object allocations per request,
which is acceptable.
2017-06-21 08:55:16 -07:00
Eric Gribkoff 3dce2ee84b core: add RunWith annotation to OverrideAuthorityNameResolverTest 2017-06-20 12:12:16 -07:00
zpencer 2b1eee90e5 core: Do not leak server state when application callbacks throw exceptions (#3064)
Today JumpToApplicationThreadServerStreamListener leaks server state by transmitting details about uncaught StatusRuntimeException throwables to the client. This is a security problem.

This PR ensures that uncaught exceptions always close the ServerCall without leaking any state information. Users running in a trusted environment who want to transmit error details can install the TransmitStatusRuntimeExceptionInterceptor.

fixes #2189
2017-06-19 11:15:22 -07:00
Carl Mastrangelo 8d2194cf31 core: don't intern Metadata keys
Interning strings isn't needed much any more since keys are now
compared by byte value.  Also, intern is slow (about 150ns per)
which affects code that creates keys often.  Lastly, older
versions of Java don't garbage collect interned strings, which
lowers the applications stability.
2017-06-17 10:53:37 -07:00
zpencer 726c23b7da core: OverrideAuthorityNameResolverFactory should forward refresh() (#3061)
The current implementation has a bug where certain methods are not forwarded to the delegate.

This is essentially the same as e4f1f39 which was merged to the v1.4.x branch. This PR uses the new license header.

Fixes #3061
2017-06-16 18:54:47 -07:00
Eric Anderson cb53bbf0be all: Filter out Internal* classes from Javadoc
core's sources already have filters applied, so it isn't necessary to
copy them to all.
2017-06-16 14:53:51 -07:00
zpencer 532450996a core: detect invalid states on server side (eg zero responses for unary) (#3068)
The current check in ServerCallImpl is theoretically unsafe (#3059). Move that check into the stub, and expand the unit tests to cover other interesting edge cases on the server side:

client sends one, but zero requests received at onHalfClose
client sends one, but > 1 requests received at onHalfClose
server sends one, but zero responses sent at onComplete
server sends one, but > 1 responses sent via onNext
fixes #2243
fixes #3059
2017-06-15 09:33:01 -07:00
Eric Anderson 0a8d761c19 core: Simplify ChannelImpl constructor; testable Builder
Add some example tests for easier fields in AbstractManagedChannelImplBuilder.

Many fields are no longer Nullable, in order to move logic from construction to
mutation, which eases testing and simplifies cross-class interactions.

The nameResolverFactory comment starting "Avoid loading the provider unless
necessary" was outdated and has not been a concern since #2071 which swapped to
a hard-coded list on Android.
2017-06-12 15:47:44 -07:00
Eric Gribkoff 49b9216e83 core: set server stream decompressor in transport thread 2017-06-12 12:00:21 -07:00