Commit Graph

1161 Commits

Author SHA1 Message Date
ZHANG Dapeng 358ea0c15d
core: retry part I followup, refactor commit()
It's more reasonable and convenient to return a `Runnable` for `commit()` method because we want to execute part of the commit under a lock and run part of it out of the lock.
2018-01-17 09:12:56 -08:00
Eric Anderson efcbef58e3 core: add missing separator in user-agent
The separator was accidentally removed in 1bbe126b4
2018-01-17 08:17:36 -08:00
zpencer 32ad2311ad
core: channel tracer should report target name and ConnectivityState (#3969)
This addresses regular channels and oob channels.
2018-01-16 10:05:30 -08:00
Carl Mastrangelo 98aa69af72
core: make ManagedChannel honor Service config LB
I think the idle state transitions are correct. I have looked at them and tried tracing a few paths through. This doesn't go full idle because the name resolver doesn't need to be restarted. Also, the LB transition happens inside of a NR callback, so it would be odd to have the NR terminate itself upon successful resolution. (Might this cause recursion? I think it may).
2018-01-12 16:56:54 -08:00
Eric Anderson bd7080337b core: Mention limitations of connectivity state API
These limitations are by design, but may be non-obvious.
2018-01-12 12:21:50 -08:00
Eric Anderson ba8063e7b0 all: Prefer mock+delegatesTo() over Mockito.spy()
Spies are really magical and easily produce unexpected results. Using them in
tests can easily yield tests that don't do what you think they do. Delegation
is much safer when possible.

Delegation doesn't work when methods `return true`, final methods, and with
restricted visibility, though. So CensusModulesTest and
MaxConnectionIdleManagerTest are left as-is.
2018-01-11 09:32:54 -08:00
Eric Anderson af0283477d Update ErrorProne to 2.2.0 and fix failures 2018-01-10 14:14:27 -08:00
zpencer 16cec947c5
core: MethodDescriptor.toBuilder() should copy schemaDescriptor (#3941) 2018-01-10 13:15:25 -08:00
Eric Anderson 4bc0c95d0b Update ErrorProne to 2.1.3 and fix failures
The fixes could have subtle side-effects, but I did take care when making them.
2018-01-09 12:40:55 -08:00
Eric Anderson 35a6bf863d Enable the Guava Beta Checker 2018-01-08 14:52:51 -08:00
Spencer Fang 3809f676ee core: make TransportStats package-private
Limited access will be granted via InternalTransportStats.
2018-01-04 15:35:04 -08:00
ZHANG Dapeng 450a983552
core: rm unused variable and method 2018-01-02 10:06:10 -08:00
ZHANG Dapeng 66119463ad
core: fix java ErrorProne 2017-12-28 13:06:58 -08:00
zpencer e7b2089c85
core: ManagedChannel should not depend on internal (#3898) 2017-12-28 11:04:11 -08:00
ZHANG Dapeng 40453c744f
core: fix unimplemented API in ManageChannel
Two APIs were added to ManageChannel. This would be API breaking if they are still abstract.
2017-12-27 13:30:12 -08:00
Shohei Kamimori b1d62b70c4 core: remove unused variables 2017-12-20 10:27:16 -08:00
ZHANG Dapeng 2fe8ce23b2
core: retry support part 1 followup, channel.shutdown should not fail retry in backoff
As delayedTransport `shutdown` will make retry attempts that are in backoff unable to create new stream. So wrap delayedTransport with `retriableTransport`, which will keep uncommitted retriable streams alive when `shutdown`.
2017-12-20 10:24:28 -08:00
Carl Mastrangelo 172b2d36be
core: add a service config file 2017-12-19 12:33:27 -08:00
Carl Mastrangelo 6eaae5d081
core/grpclb: resolve TXT records in DNS name resolver and include balancer addresses 2017-12-19 10:01:53 -08:00
Kun Zhang 04420dfdf7
Start 1.10.0 development cycle (#3877) 2017-12-18 10:28:02 -08:00
zpencer 9358fc7233
core: BinaryLogProvider should not use ManagedChannelImpl class loader (#3874) 2017-12-18 10:26:26 -08:00
zpencer 39c266cbe7
core: introduce io.grpc.internal.BinaryLogProvider (#3872) 2017-12-17 16:47:33 -08:00
Eric Anderson 1bbe126b44 core: Use hard-coded string for version
Using META-INF for loading the version is broken on Android and
frequently broken when gRPC is shaded. Having hard-coded strings be
replaced on version bumps has been working well.

Fixes #2098
2017-12-15 15:31:26 -08:00
zpencer 7e655beb88
core: ManagedChannel should implement InternalInstrumented 2017-12-14 18:09:46 -08:00
zpencer 02f56b0218
core,services: move BinaryLog class to grpc-services (#3867) 2017-12-14 14:20:30 -08:00
zpencer f1151f91b9
core: InternalInstrumented<T> for instrumented classes (#3817)
Entities that report stats to channelz will implement this interface.
2017-12-13 12:56:25 -08:00
zpencer 5cb609f038
core: Add ChannelStats (#3752)
`ManagedChannelImpl` and `OobChannelq now both have a package
private field `ChannelStats`. There will be an internal access
API coming in a follow up PR.
2017-12-12 09:20:46 -08:00
Carl Mastrangelo 1bb9498ea1
core: fix Attributes value equality
Fixes: #3857
2017-12-11 18:12:49 -08:00
Eric Anderson 2ea77cce1e core: Avoid frequently computing inprocess useragent 2017-12-11 16:02:49 -08:00
jyane 11b5c1a7c1 core: support user-agent in InProcess 2017-12-11 15:26:29 -08:00
zpencer 2b3885bbc2
core,okhttp: add TransportTracer to okhttpclient (#3809) 2017-12-07 17:12:08 -08:00
Carl Mastrangelo 01ea67f5cf
core: move exception to listener for RuntimeException, Error still throws 2017-12-05 10:29:04 -08:00
Carl Mastrangelo c9b02db276
all: add Status messages to all statuses 2017-12-04 19:00:16 -08:00
ZHANG Dapeng 3d6fcfc752
core: retry support part 1 followup, drainedSubstreams should not contain closed ones 2017-12-01 12:50:04 -08:00
zpencer 9e7a4c44be
core: move WithLog and LogId to io.grpc (#3813)
The channelz service must not live in io.grpc.internal, and channelz
needs to be able to get the identifier of the entities it
tracks. Since io.grpc can not refer to io.grpc.internal, the LogId
must be moved out of internal.
2017-11-30 15:04:40 -08:00
ZHANG Dapeng bc54970128
core: retry support part 1, RetriableStream
With an approach using a variant of `DelayedStream` - `RetriableStream`.

`RetriableStream` is a logical stream per call that can create a sequence of `substreams`, the physical streams for the retry attempts. It could also create a family of substreams in parallel in hedging case.
 
`RetriableStream` buffers, delays and executes stream operations before `passThrough`, where `passThrough` is meant by `commit` as well as the buffer `drained` by the winning substream.

This PR only implements buffering messages and replaying buffered messages when retry.
Retry policy, hedging, transparent retry, backoff, max buffer size and APIs that users can enable retry are not included in this PR.
2017-11-30 14:21:39 -08:00
zpencer 25cd0be24c
core,netty,okhttp: move TransportTracer.Stats to io.grpc (#3812)
io.grpc can not refer to io.grpc.internal so this needs to be moved
out.
2017-11-30 13:01:58 -08:00
zpencer d42110c181
core: initial binary log class (#3699)
Each MethodDescriptor will have a binary log, though the log may
be a noop log. The binary log class is a skeleton class at the
moment, but does contain the max header and message length
info. The limits are determined by parsing the shell variable
GRPC_BINARY_LOG_CONFIG.
2017-11-28 12:20:03 -08:00
Eric Anderson e56d98723e core: Increase server handshake timeout to 120s
Previously it was 20s. 20s isn't _bad_, but may be too aggressive.
Having it longer doesn't hurt us too much; we just need some bound.
Since the MAX_BACKOFF on client-side is 120s, this will have client and
server match, except for jitter. Although I will note that the
client-side value covers more work than the server-side, such as
attempting to connect to multiple hosts.
2017-11-27 15:16:40 -08:00
Eric Gribkoff 4d35ea05c4
core,okhttp: handle unresolved proxy addresses 2017-11-23 11:00:09 -08:00
kenji yoshida 4db323c5c4 all: fix grammar typos in javadocs 2017-11-22 18:00:51 -08:00
Eric Anderson 2bde25d2d9 testing: Remove DeadlineSubject
The class is still used internally, so we move it to context's tests for
it to be reused. To avoid a circular dependency with context's tests
depending on core's tests, StaticTestingClassLoader was also moved to
context's tests.

This is driven by a need to modernize DeadlineSubject for newer versions
of Truth, but the newer versions of Truth update Guava. To avoid leaking
the Guava update to all users of grpc-testing, we're removing the
Subject. In our internal tests we can update the Truth dependency with
less issue.
2017-11-22 17:57:46 -08:00
David Cowden 3315d16f7c core: update ManagedChannel docs (#3762)
ManagedChannel now supports the getState/notifyWhenStateChanged API (#2292).
2017-11-17 13:14:42 -08:00
Eric Anderson 6bab82eeb6 auth: Use async version of getRequestMetadata
This avoids using DelayedStream and a thread hop when the credentials
are known immediately.
2017-11-17 11:52:07 -08:00
Eric Anderson 02817e2a9d
core: Stabilize ManagedChannelBuilder.overrideAuthority
The CallOptions from #1767 are not included, so this is not enough to resolve
the issue.
2017-11-17 07:23:35 -08:00
Eric Anderson da75b02c8f core: Stabilize HandlerRegistry
MutableHandlerRegistry from #933 is not stabilized, so this is not enough to
resolve the issue.
2017-11-17 07:16:52 -08:00
Eric Anderson f0dcbc3b03
core: Disable handshakeTimeout for InProcess
handshakeTimeout is unnecessary for InProcess, and the scheduling is causing
Thread creation that is breaking restrictive test environments. Those
environments are mostly broken already because client-side will try to create
Threads as well, but they are currently lucking out that the exception on
client-side doesn't break much.
2017-11-17 06:54:05 -08:00
Eric Gribkoff 667b0611fe
core: correct issue number for getSchemaDescriptor() 2017-11-16 14:39:14 -08:00
Eric Gribkoff 4c483ef7a0
core: workaround for Atomic*FieldUpdater bug on some Android devices 2017-11-16 09:59:47 -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
zpencer 47bee4feee
core,netty: plumb fake clock into transport tracer tests (#3724) 2017-11-13 15:58:29 -08:00
Kun Zhang ca9a41a46e
core: record RPC upstarts to Census. (#3708)
RPC upstarts are counted into metrics
RPC_{CLIENT,SERVER}_STARTED_COUNT. In addition, RPC completions are
counted into metrics RPC_{CLIENT,SERVER}_FINISHED_COUNT.  From these
metrics, users will be able to derive count of RPCs that are currently
active.
2017-11-10 17:22:22 -08:00
Eric Anderson bd32d6f599 bazel: Add dep on opencensus-contrib-grpc-metrics
This fixes the Bazel build after ef2ec949
2017-11-10 16:41:36 -08:00
zpencer d0a84ae5b8
core,netty: wire TransportTracer to netty client (#3705) 2017-11-10 15:55:21 -08:00
Eric Anderson 5a87a6fff6 stub: Improve threading expectation docs
This mainly copies documentation from other places, like StreamObserver
and ClientCall, but does fix some missing important threading notes.

Fixes #3413
2017-11-10 13:10:17 -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 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