Commit Graph

1102 Commits

Author SHA1 Message Date
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