Commit Graph

1517 Commits

Author SHA1 Message Date
Carl Mastrangelo 1bf8476cd7
core: standardize logid format and add details for channelz 2018-12-17 17:22:11 -08:00
ZHANG Dapeng 0cf91e333b
core: hide RetriableStream type from ClientTransportProvider 2018-12-12 10:04:39 -08:00
ZHANG Dapeng 07f96f8000
core: fix a typo in javadoc 2018-12-10 10:53:08 -08:00
Kun Zhang c0175e4cbe
core: add LoadBalancer.canHandleEmptyAddressListFromNameResolution() (#5148)
Currently ManagedChannelImpl will interpret empty address list from
NameResolver as an error, and LoadBalancer will NEVER receive an empty
list from handleResolvedAddressGroups().  There is a case in the
request-routing design where a LoadBalancer only receives service
config with which it constructs children NameResolver/LoadBalancer
pairs, thus no address is expected at this level.

canHandleEmptyAddressListFromNameResolution() is a signal to Channel
(and to the parent LoadBalancer in case of hierachical LoadBalancers)
about whether it accepts empty address lists.  The default is false,
which is the current behavior.

The logic is currently duplicated in ManagedChannelImpl and
AutoConfiguredLoadBalancer.  The one in ManagedChannelImpl will be
removed once we delete ManagedChannelBuilder.loadBalancerFactory() as
AutoConfiguredLoadBalancer will always be the top-level LoadBalancer
by then.
2018-12-10 10:18:19 -08:00
Grant Oakley 01f79bb909 core: fix bug in CallOptions#withOption()
Previously, overwriting an existing Key would cause the original CallOptions instance to also be mutated.

See #5142

Also adds a regression test for this issue.
2018-12-07 16:32:02 -08:00
Eric Anderson 1299986999 core: Fix reversed arguments to assertEquals 2018-12-07 11:37:21 -08:00
Kun Zhang 1fbf7bb3a7
core: add ManagedChannelBuilder.defaultLoadBalancingPolicy() (#5135)
ManagedChannelBuilder.loadBalancingFactory() overrides the proper
policy selection logic implemented in AutoConfiguredLoadBalancer, thus
has problems in cases where NameResolver returns balancer addresses,
because custom LoadBalancers normally don't differentiate between
normal server addresses with balancer addresses.  The policy selection
logic will filter out balancer addresses.
2018-12-07 08:30:58 -08:00
Eric Anderson de9bc0bcf1 Specify Locale to toLowerCase and lint fixes 2018-12-06 17:15:48 -08:00
Kun Zhang 4631c0c7e8
core: fix a bug that Channel won't work if NameResolver returns a ServiceConfig without LB config. (#5134) 2018-12-06 16:51:45 -08:00
Kun Zhang 0cc0f2d170
core: do not fail RPCs if balancer address exists but grpclb is unavailable (#5129)
When service owner turns on grpclb through service config, it
shouldn't break existing clients that don't have grpclb in their
classpath.

Resolves #4602
2018-12-06 13:40:30 -08:00
Carl Mastrangelo 2d654496ee
context: make Deadline toString() more readable 2018-12-05 17:44:44 -08:00
Kun Zhang 3a86a176fe
core: add LoadBalancer.Helper.refreshNameResolution() (#5121) 2018-12-05 13:11:45 -08:00
ST-DDT 0dda74dda4 core: Fix deprecation warning in RoundRobinLoadBalancerFactory 2018-12-05 10:03:02 -08:00
ZHANG Dapeng 0c95dad0da
core: fix bazel NameResolverProvider not found 2018-12-05 09:45:41 -08:00
Kun Zhang 5054aefe03
core: support LoadBalancingConfig from Service Config (#5073) 2018-12-04 16:56:06 -08:00
Kun Zhang b5acbedd55
core: record real-time metrics to OpenCensus (updated to 1.18.0) (#5099)
Real-time metrics are total sent/received bytes and messages per
method, and are updated as the events occur rather than at the end of
RPCs.
2018-11-29 16:30:58 -08:00
Kun Zhang 2961857451
core: refactor flags in CensusStatsModule. (#5095)
There are currently three boolean flags, and there will be one more
soon.  Put them all in the top-level class instead of passing them as
arguments on lower levels.
2018-11-28 14:20:40 -08:00
Kun Zhang 98ae834dfa
core: use SynchronizationContext.schedule() for NameResolver refresh (#5089)
This also fixes the bug where NameResolverRefresh is not run from
syncContext if run from ScheduledExecutorService.
2018-11-28 09:42:29 -08:00
Kun Zhang 3ff4790212
core: allow ClientStreamTracer to intercept trailers. (#5088)
This would allow LoadBalancers to intercept trailers which could carry
load information.
2018-11-27 12:47:31 -08:00
Kun Zhang c8b2cdc023
core/services: test/debug friendlier (#5079)
Raise visibility of AutoConfiguredLoadBalancerFactory as internal
tests need to access it from a different package.

Rename HealthCheckingLoadBalancerFactory.LoadBalancerImpl to
*.HealthCheckingLoadBalancer so that its toString() output is more
informative.
2018-11-21 10:45:18 -08:00
Kun Zhang 268793f321
core: add (de)register() in LoadBalancerRegistry. (#5070) 2018-11-20 12:07:31 -08:00
zpencer 777bbbb121
core: TimeProvider should not assume that the clock never changes (#4883)
We should reflect changes in the system clock.
2018-11-20 11:34:58 -08:00
ZHANG Dapeng 6b15aa9e4e
core: implement hedging 2018-11-20 09:38:01 -08:00
Jihun Cho 1506135333 Start 1.18.0 development cycle 2018-11-19 14:49:35 -08:00
Eric Anderson 033cf21118 core: Explicitly mention MCB.intercept's execution order
New users are much more likely to use MCB to add an interceptor instead
of ClientInterceptors, so may not be aware of the interesting execution
order.
2018-11-19 11:02:44 -08:00
Jihun Cho ab5257504b
core: use fakeClock in MessageDeframer tests to fix flaky test (#5055) 2018-11-14 15:13:10 -08:00
Kun Zhang 5b87e99622
core: move round-robin to util and include it to hard-coded list (#5057)
This is needed for internal issue b/119247688.

A particular test that runs GRPC Android build in a non-Android
environment failed because RoundRobinLoadBalancerProvider was deleted
by ProGuard but the service-loader META-INF file still referred to it,
causing a loading failure.

This could be fixed by adding RoundRobinLoadBalancerProvider to the
hard-coded list, which is recognized by ProGuard then it will keep the
class.

However, we don't expect anyone to use RoundRobinLoadBalancerProvider
on Android, including the class on Android would increase code size,
which Android apps are sensitive to. Hence we move
RoundRobinLoadBalancerProvider to a different package (util), which is
built as a separate artifact internally which Android users usually
don't depend on. (Note that in open-source util is in the same artifact as core,
which is unfortunately).
2018-11-13 17:06:01 -08:00
Rodrigo Queiro 8481943866 Add missing j2objc dependency to Bazel build
This avoids a warning when building artifacts that depend on Guava.

Fixes #5046.
2018-11-13 13:39:35 -08:00
Eric Anderson 7a89ce2a90 Lint fixes
Remove unused variables and prefer ArrayDeque to LinkedList. The swap to
Queue from Deque was just to make it more obvious what the usage was,
since the original swap to Deque was to avoid the same LinkedList lint
violation (3d51756d).
2018-11-09 17:15:25 -08:00
Yang Song 09b13fecaa core: Update OpenCensus version to 0.17.0 (#4494) 2018-11-09 16:44:01 -08:00
ZHANG Dapeng bff008fbc8
core: Emit bin-headers with unpadded encoding
Following the [grpc PROTOCOL-HTTP2 spec](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md)
"Note that HTTP2 does not allow arbitrary octet sequences for header values so binary header values must be encoded using Base64 as per https://tools.ietf.org/html/rfc4648#section-4. Implementations MUST accept padded and un-padded values and should emit un-padded values. "
2018-11-09 13:39:01 -08:00
Jihun Cho a7196eb311
core: remove I/O from DNS test which caused flaky test (#5044) 2018-11-07 16:00:26 -08:00
Carl Mastrangelo e7e88a9af8
core: narrow SharedResourceHolder types, and make the scheduler unconfigurable 2018-11-07 13:12:21 -08:00
Kun Zhang 6b48eb4e08
core: ChannelLogger (#5024)
Introduce ChannelLogger, which is a utility provided to LoadBalancer implementations (potentially NameResolvers too) for recording events to channel trace. This is immediately required by client-side health checking (#4932, https://github.com/grpc/proposal/blob/master/A17-client-side-health-checking.md) to record an error about disabling health checking. It is also useful for any LoadBalancer implementations to record important information.

ChannelLogger implementation is backed by the internal ChannelTracer/Channelz. Because Channelz limits the number of retained events, and events are lost once the process ends, I have expanded it to also log Java logger. This would provide a "last resort" in cases where there are too many events or off-line investigation is needed. All logs are prefixed with logId so that they can be easily associated with the involved Channel/Subchannel.

To prevent log spamming, the logs are all at FINE level or below so that they are not visible by default. They are logged to ChannelLogger's logger, so that user can have precise control.

There are also more verbose information that may not fit in ChannelTracer, but can be useful for debugging. It's desirable that these logs are associated with logId, but they currently manually include the logId, which is cumbersome and may result in inconsistency. For this use case, I added the DEBUG level for ChannelLogger, which formats the log in the same way as other levels, while not recorded to Channelz.

I have converted most logging and channel tracer recording in the Channel implementation and LoadBalancers.
2018-11-06 16:48:09 -08:00
Eric Anderson f8f86da480 core: Add missing synchronization in KeepAliveManager 2018-11-06 09:28:38 -08:00
Eric Anderson 424daa0920 core: Improve error for Auto-LB configuration failure
The ManagedChannelImpl change prevents any LB initialization failure
from producing a useless exception like:
java.lang.NullPointerException
	at io.grpc.internal.ManagedChannelImpl.shutdownNameResolverAndLoadBalancer(ManagedChannelImpl.java:321)
	at io.grpc.internal.ManagedChannelImpl.panic(ManagedChannelImpl.java:738)
	at io.grpc.internal.ManagedChannelImpl$1.uncaughtException(ManagedChannelImpl.java:144)

Instead, now it will have the expected panic behavior of an INTERNAL
Status with a proper cause.

Since the NPE in AutoConfiguredLoadBalancerFactory wouldn't mean much to
users, it now has a more explicit message.
2018-11-05 14:08:50 -08:00
ZHANG Dapeng 85b244bb41
core,netty,testing: Support dup headers joined with commas
Following the [spec](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md) on duplicate header names:

**Custom-Metadata** header order is not guaranteed to be preserved except for values with duplicate header names. Duplicate header names may have their values joined with "," as the delimiter and be considered semantically equivalent. Implementations must split Binary-Headers on "," before decoding the Base64-encoded values.
2018-11-01 16:17:05 -07:00
zpencer 3d51756d61
core, services: fix more import lints (#5021) 2018-11-01 16:14:42 -07:00
Kun Zhang f5d0f40bdf
services: client-side health checking main implementation (#5014)
Spec: https://github.com/grpc/proposal/blob/master/A17-client-side-health-checking.md

This comes in the form of a wrapper LoadBalancerFactory. The public wrapping utility and the wrapping of RoundRobinLoadBalancer will come in follow-up changes.
2018-10-31 09:29:46 -07:00
zpencer f3e371c712
core, grpclb: fix import lints (#5017) 2018-10-30 14:24:02 -07:00
Kun Zhang 7d19683018
core: suggest LoadBalancer.Helper.createSubChannel() to be called from SynchronizationContext (#5016)
Because otherwise the user logic around Subchannel creation will
likely to race with handleSubchannelState().

Will log a warning if LoadBalancer.Helper.createSubChannel() is called
outside of the SynchronizationContext.

Adds SynchronizationContext.throwIfNotInThisSynchronizationContext()
to facilitate this warning.  It can also be used by LoadBalancer
implementations to make it a requirement.
2018-10-30 07:22:15 -07:00
Kun Zhang 4c6e202df3
core: service-loader-based LoadBalancerProvider (#4996)
LoadBalancerProvider is the interface that extends LoadBalancer.Factory. LoadBalancerRegistry is the one that loads the providers through service loader, and allows users to access providers through their names.

pick_first and round_robin balancer factories, which are experimental public API are now deprecated. Their providers are internal, as they are accessible by policy name.

AutoConfiguredLoadBalancerFactory is modified to access implementations purely by their names, thus hard-coded class names are no longer needed, and it can support arbitrary policy selected by service config.
2018-10-29 10:39:11 -07:00
Eric Anderson e5339d25c6 core: Trim trailing dot from SRV hostnames
The trailing dot denotes the hostname to be absolute. It is fine to
leave, but removing it makes the authority match the more common form
and hopefully reduces confusion.

This happens to works around SNI failures caused when using gRPC-LB,
since SNI prohibits the trailing dot. However, that is not the reason
for this change as we have to support users directly providing a
hostname with the trailing dot anyway (and doing so is not hard).

See #4912
2018-10-26 17:13:16 -07:00
Carl Mastrangelo dabe719913
core: add option to fail tests that use Status.equals 2018-10-26 16:27:03 -07:00
Eric Anderson acf62ab0c8 core: Make MetadataApplier an interface again
Swapping MetadataApplier to an abstract class is not ABI-safe for
callers. So I revert back to the previous interface definition and
introduce a CallCredentials2.MetadataApplier which is an abstract class.
Once everyone is on CallCredentials2 then we can swap it to an abstract
class again.

Fixes #5002
2018-10-26 10:15:10 -07:00
zpencer d7af1ee874
core: fix FakeClock, SynchronizationContext lints (#4991)
Fix lints for import.

Remove unused vars. Make path and package match so tests run
successfully internally.
2018-10-25 10:00:55 -07:00
Kun Zhang 7582049a95
core: SynchronizationContext exposed by LoadBalancer.Helper (#4971)
Provides a `SynchronizationContext` for scheduling tasks, with and without delay, from LoadBalancer implementations. This absorbs and extends the internal utility `ChannelExecutor`. It supersedes `Helper.runSerialized()`, which is now deprecated.

# Motivation

I see multiple cases that schedule tasks with a delay while requiring the task to run in the "Channel Executor". There have been repeated work to wrap scheduled tasks and handle races between cancellation and task run (see the diff in `GrpclbState.java` for example). The LoadBalancer implementation (e.g., GrpclbLoadBalancer) also has to acquire the `ScheduledExecutorService` from somewhere and release it upon shutdown.

The upcoming HealthCheckLoadBalancer (#4932), which would use back-off policy to retry health-checking streams, would have to do all the things above. At this point I think we need to provide something that combines `runSerialized()` with a scheduled executor with the same synchronization guarantees.

# Design details

`SynchronizationContext` is a similar to `ScheduledExecutorService` but tailored for use in `LoadBalancer` and potentially other cases outside of `LoadBalancer`. It offers task queuing and serialization and delayed scheduling. It guarantees non-reentrancy and happens-before among tasks. It owns no thread, but run tasks on caller's or caller-provided threads.

All channel-level state mutations and callback methods on `LoadBalancer` are done in a SynchronizationContext, which was previously referred to as "Channel Executor". 

`SynchronizationContext.schedule()` returns a `ScheduledHandle` for status checking and cancellation. `ScheduedFuture` from `SchedulingExecutorService.schedule()` is too broad for our use cases (e.g., the blocking `get()` should never be used).

`SynchronizationContext.schedule()` requires a `ScheduledExecutorService`, which is now available through `Helper.getScheduledExecutorService()`. LoadBalancers don't need to worry about where to get `SchedulingExecutorService` any more.

# Alternatives

Alternatively, we could keep `Helper.runSerialized()` and add something like `Helper.runSerialiezdWithDelay()`, but having them on their own interface allows clean fake implementation by `FakeClock` for test, and allows other components (potentially `InternalSubchannel` for reconnection backoff) to use it too.

Instead of asking caller of `schedule()` to provide the `ScheduledExecutorService`, we considered having SynchronizationContext take a `ScheduledExecutorService` at construction. It would be inconvenient for LoadBalancer implementations that don't use `schedule()`, as they would be forced to provide a fake `ScheduledExecutorService` (which is cumbersome).

Instead of making `SynchronizationContext` a (semi-)concrete class, we considered making it an pure abstract class. However, we found it nontrivial to implement `execute()` correctly with the non-reentrancy guarantee.
2018-10-23 15:25:15 -07:00
Kun Zhang ade5c497f4
Revert "core: promote CallCredentials API v2. (#4952)" (#4983)
This reverts commit ef8a84421d.

Firebase is not yet ready to migrate to the new API. Will try again once we made the release and migrated them to CallCredentials2.
2018-10-22 16:43:37 -07:00
Thomas Broyer 183e1f6735 all: update Error Prone to 2.3.2
This will allow enabling Error Prone on JDK 10+ (after
updating the net.ltgt.errorprone plugin), and is also a
prerequisite to that plugin update.

Also remove net.ltgt.apt plugin, as Gradle has native
support for annotationProcessor.
2018-10-19 13:08:36 -07:00
Kun Zhang 9aaf29c5e6
core: annotate Attributes key annotations as experimental API. (#4974)
Also annotate NameResolver.Listener as experimental because
annotations of an outer class don't show in the javadoc page of its
inner classes.
2018-10-19 13:04:32 -07:00
Carl Mastrangelo 93d9b32d12
core: ignore localhost and IP addresses for JNDI
This change is mainly to fix a test, but it also is an implementation of the proposal here: https://github.com/grpc/proposal/pull/79

In short:

* Do not do SRV or TXT lookups when the target name is `localhost`.  This can be overriden by a system property
* Do not do SRV or TXT lookups when the target name is an IPv6 or IPv4 address.  This _cannot_ be overriden.  The constructed domains for these queries would themselves not be valid.  (e.g. _grpclb._tcp.192.168.0.1)
* Speeds up initial connection when communicating over local host, since it is extremely uncommon that such a connection would need gRPCLB or SRV records

I expect to remove the system property after a release if no one asks about it.
2018-10-19 12:19:36 -07:00
Eric Anderson b7c3d276c9 core: Add maxInboundMetadataSize to builders
This is a rename of the pre-existing Netty builder method, so aliases
were added to the Netty builders.

Fixes #4050. This API was a minor rename to the pre-existing Netty API,
so has already undergone API review and thus is not ExperimentalApi.
2018-10-18 14:34:03 -07:00
Eric Anderson 0eefa5263b inprocess: Add maxInboundMetadataSize 2018-10-18 14:34:03 -07:00
Eric Anderson 0fbc1153bd testing: Add transport tests for maxInboundMetadataSize 2018-10-18 14:34:03 -07:00
Jihun Cho b7dc501bbe core: For Android, ignores DNS cache
There is a known issue that causes DNS lookup issue when network
siwtchover on android. This issue is tracked separately in #4962.
This change simply disables DNS cache to avoid the issue on Android.
2018-10-17 22:51:43 -07:00
Jihun Cho 0a7fa14042 core: Roll forward "core: DnsNameResolver caches refresh (#4812)"
This reverts commit 0e8cf58d1a.
2018-10-17 22:51:43 -07:00
Carl Mastrangelo c729a0f76b
core: enable SRV records lookup 2018-10-16 10:10:08 -07:00
Kun Zhang 6adc1797c9
core: finalize convenient overrides on LoadBalancer.Helper and Subchannel. (#4954)
Those overrides are kept for backward compatibility and convenience
for callers.  Documentation already says implementations should not
override them.  Making them final reduces confusion around which
override should be verified in tests and be overridden in forwarding
classes, thus prevents bugs caused by such confusion.
2018-10-16 09:43:58 -07:00
Carl Mastrangelo 60b02c0b9c
core: throw exception on resolution failure and no jndi resolver 2018-10-15 16:59:02 -07:00
Kun Zhang c528df8ae8
core: add internal Subchannel.asChannel() (#4950)
Returns a Channel that allows a LoadBalancer to make auxiliary RPCs on already-established application connections. We need this to implement client-side health-checking (#4932)

See comments on the API for its semantics.

Notable changes:

- Transports are modified to use InUseStateAggregator so that they can exclude RPCs made on Subchannel.asChannel() when reporting in-use state for idle mode.
- OobChannel shares the same Executor as Subchannel.asChannel(). Because the latter is not a ManagedChannel and doesn't have life-cycle, thus can't determine when to return the Executor to a pool, the Executor is now returned only when ManagedChannelImpl is terminated.
2018-10-15 15:39:21 -07:00
Kun Zhang ef8a84421d
core: promote CallCredentials API v2. (#4952)
This is Step 3 of #4901.  The old interface has been deprecated in the
latest release.  Now it's time to replace it with the new API.
2018-10-15 15:37:20 -07:00
Carl Mastrangelo 6b7c8694a9
core: make DnsNameResolver Error on empty addresses
This change does 3 main things (in 3 commits):

1.  Refactor the resolution runnable to be testable
2.  Add Finer level logging to aid in debugging
3.  Check that there are addresses before passing them to ManagedChannelImpl.
2018-10-12 18:11:45 -07:00
ZHANG Dapeng 595e5acfd1
core: temporarily disable census when enableRetry 2018-10-12 16:42:51 -07:00
Jihun Cho 2ce6ddfb5c core: removed unused expression 2018-10-12 16:18:03 -07:00
Jihun Cho 0e8cf58d1a Revert "core: DnsNameResolver caches refresh (#4812)"
This reverts commit 189991012b.
2018-10-12 15:30:38 -07:00
Jihun Cho c24f2fd25b Revert "core: android use smaller(2s) DNS cache TTL (#4943)"
This reverts commit ecb206f277.
2018-10-12 15:30:38 -07:00
creamsoup ecb206f277
core: android use smaller(2s) DNS cache TTL (#4943)
android use smaller (2s) DNS cache TTL
2018-10-12 13:56:49 -07:00
Carl Mastrangelo d06c8e3bf7
core: include what name resolver was used when it fails 2018-10-11 13:39:20 -07:00
Eric Anderson 967cc64770 Start 1.17.0 development cycle 2018-10-11 09:29:23 -07:00
Kun Zhang 861f9147ed
core: add CallCredentials2 and deprecate CallCredentials' old interface (#4902)
This is the first step of smoothly changing the CallCredentials API.

Security level and authority are parameters required to be passed to
applyRequestMetadata(). This change wraps them, along with
MethodDescriptor and the transport attributes to RequestInfo, which is
more clear to the implementers.

ATTR_SECURITY_LEVEL is moved to the internal GrpcAttributes and
annotated as TransportAttr, because transports are required to set it,
but no user is actually reading them from
{Client,Server}Call.getAttributes().

ATTR_AUTHORITY is removed, because no transport is overriding it.

All involved interfaces are changed to abstract classes, as this will
make further API changes smoother.

The CallCredentials name is stabilized, thus we first introduce
CallCredentials2, ask CallCredentials implementations to migrate to
it, while GRPC accepting both at the same time, then replace
CallCredentials with CallCredentials2.
2018-10-10 21:45:56 -07:00
Kun Zhang cc5e3c19df
core: ForwardingLoadBalancerHelper (#4911)
This will be used by LoadBalancer plugins that delegates to another,
which is what the new request routing (go/grpc-request-routing-design)
requires.  This will also be used to wrap LoadBalancers to add
client-side health-checking functionality.
2018-10-06 12:36:35 -07:00
Kun Zhang fbfc3a40d0
core: add Grpc.TRANSPORT_ATTR_LOCAL_ADDR (#4906)
Resolves #4135
2018-10-03 16:43:37 -07:00
Carl Mastrangelo 6b7fa40378
core: name anonymous classes in ManagedChannel for clear stacktraces 2018-10-03 14:09:00 -07:00
Kun Zhang ebbf8005be
doc: organize Attributes with annotations. (#4892)
* doc: organize Attributes Keys with annotations.

Keys are annotated with the following annotations:

1. Grpc.TransportAttr: transport attributes returned by
{Client,Server}Call.getAttributes().

2. NameResolver.ResolutionResultAttr: attributes passed as the
argument of NameResolver.Listener.onAddresses() and
LoadBalancer.handleResolvedAddressGroups()

3. EquivalentAddressGroup.Attr: attributes from
EquivalentAddressGroups.

* Expand the usage of annotations to Attributes variables.
2018-10-01 10:11:01 -07:00
zpencer 2fae9a3a97
core: permanently store authority at channel creation (#4886)
Getting the authority must not rely on the name resolver being
non-null, because that can trivially happen if the channel is shut
down.
2018-09-28 16:10:14 -07:00
Jesse Wilson 8b16899bc1 Upgrade to Guava 26.0-android and jsr305 3.0.2 2018-09-28 13:23:55 -07:00
zpencer da87ffb329
core,services: v1 binlog (#4846)
Log using new proto definition

- Remove io.grpc.BinaryLog.CallId because a call ID is now an AtomicLong
- Add the concept of "always included" and "never included" metadata
  keys. This is needed because grpc-status-details-bin is already
  logged in the binlog msg, and we will log grpc-trace-bin for the
  census info.
- unit tests are effectively rewritten
2018-09-27 13:19:24 -07:00
Spencer Fang cc09eab9af core: fix channelz import on AutoConfiguredLoadBalancerFactory
The original PR was stale when merged.
2018-09-19 14:32:16 -07:00
ZHANG Dapeng 0afc10c2d6
core: channel tracing to log lb policy changes 2018-09-19 11:36:33 -07:00
Carl Mastrangelo b0f423295b
all: use Java7 brackets 2018-09-14 13:52:29 -07:00
Nick Hill ed709ff9ff core: remove redundant SubchannelPicker refreshes in RoundRobinLoadBalancer
* Remove redundant SubchannelPicker refreshes in RoundRobinLoadBalancer

- Ensure active subchannel list and round-robin index is only
regenerated/refreshed when it changes
- Make it so that Subchannels exist in subchannels map iff their state
!= SHUTDOWN
- Add EmptyPicker class since logic for this case is disjoint from the
non-empty case

* remove explicit initialization of boolean ready field

per @carl-mastrangelo's review comment

* minor restructuring to make logic clearer; more explanatory comments

* move some checks inside updateBalancingState method for clarity

* store current state and picker in RRLB, only update when new one is diff

* some more simplification/refactoring; improve test coverage

- remove now redundant check in handleSubchannelState

- collapse getAggregatedState() and getAggregatedError() into
handleBalancingState()

- have both pickers extend new RoundRobinPicker, move
areEquivalentPickers() logic into RoundRobinPicker.isEquivalentTo()

- extend unit tests to cover some additional cases

* Address latest review comments from @zhangkun83

- Use explicit check for non-empty list instead of assert
- Change EmptyPicker.status to be non-nullable
- Further test coverage improvement including explicit picker comparison
tests

* use EMPTY_OK instead of Status.OK for initial empty picker
2018-09-12 15:06:46 -07:00
ZHANG Dapeng c8975e987b
all: fix lint warnings in import 2018-09-11 16:24:44 -07:00
zpencer 95fd47d747
core, services: remove census from binary logs (#4845)
The exact census span behavior wrt gRPC is not yet defined, so let's
punt on tight integration.

It may be fine to log grpc-trace-bin on server side because it is a
key visible to the application.
2018-09-10 16:35:08 -07:00
creamsoup 189991012b
core: DnsNameResolver caches refresh (#4812)
DnsNameResolver caches refresh using java security property networkaddress.cache.ttl.

Resolves #4745
2018-09-06 16:58:34 -07:00
zpencer 2fca42feb9
all: prepend internal classes with Internal (#4826)
This is a safer way to hide the classes, because they will not appear
in public targets for some build configurations.
2018-09-05 18:48:42 -07:00
zpencer 4d366ce978
all: move Channelz to io.grpc as InternalChannelz (#4797)
This is an API used to coordinate across packages and must live in
`io.grpc`.

Prepending `Internal` makes it easier to detect and hide this class
from public visibility when using certain build tools.

fixes #4796
2018-09-04 16:52:01 -07:00
creamsoup bbacd164f9
skip populating trace header if no census impl is available. (#4805) 2018-08-30 14:45:11 -07:00
ZHANG Dapeng 6037659dd7
core: make HedgingPolicy final
Just as RetryPolicy is final.
2018-08-28 17:09:05 -07:00
Eric Gribkoff 67ee4b6a8f
core: switch to Java 7 source and bytecode (#4801)
javac can produce code that invokes Object.requireNonNull when instantiating
an inner class using a instance variable. See
https://bugs.openjdk.java.net/browse/JDK-8202137
2018-08-27 20:48:57 -07:00
Kun Zhang 28d44ae46d
Start 1.16.0 development cycle (#4803) 2018-08-27 17:21:46 -07:00
Eric Anderson 7b126b00a0 all: Swap to Java 7 source and bytecode
Core and OkHttp are left with Java 6 for the moment. Once we resolve
their issues they could be bumped as well.

Updates #3961
2018-08-27 15:29:03 -07:00
ZHANG Dapeng e9b6568450
core: plumb hedging policy
This is only API plumbing for hedging, following exactly the same way as its retry counterpart, so it is almost trivial.
2018-08-23 14:38:10 -07:00
Carl Mastrangelo 3f05a6e331
core: minor cleanup of NameResolverProvider
* Make the list of providers an immutable List
* Make obvious that the list is statically initialized
* Add documentation for when methods were added.
* Use RuntimeException, rather than IllegalStateException.
2018-08-20 12:59:55 -07:00
Carl Mastrangelo 7fe49f9b52
core: add ability to create stackless status exceptions 2018-08-17 11:40:11 -07:00
zpencer a48b090dc6
core: Handle null ProxySelector (#4762)
ProxySelector.getDefault() can return null

Fixes #4677
2018-08-16 15:04:33 -07:00
creamsoup ba4db45e71 Fix errror message when DNS name is invalid. (#4751)
It used to throw NPE, since URI.create creates URI with null hostname. Now it
thorws IllegalArgumentException for invalid DNS name, NPE for null name.
2018-08-13 16:55:20 -07:00
Eric Anderson 3cfc5af4f1 core: Avoid implicit requestConnection in PickFirst
This makes the behavior more clear.
2018-08-13 09:41:06 -07:00
Spencer Fang 9f477b27bb core: fix unused variable lint 2018-08-09 13:31:23 -07:00
Eric Gribkoff 79b24709b9
all: update animalsniffer to Java 7 and add Android 14 (#4727) 2018-08-09 09:09:21 -07:00
Carl Mastrangelo 67352081f8
core: revert warning about `Status.asException(null)`
There seem to be some users converting from StatusRuntimeException
to StatusException using the following paradigm:

sre.getStatus().toException(sre.getTrailers())

Since there isn't a viable alternative, revert the warning.
2018-08-06 11:44:52 -07:00
Kun Zhang 2aa02fd869
core: remove unused fullMethodName field from CensusStatsModule. (#4731) 2018-08-03 09:16:29 -07:00
Carl Mastrangelo 9895e243b1
inprocess: prevent null names, and define socket address equality 2018-08-02 17:28:36 -07:00
Eric Anderson b64cde1488 Encourage using grpc-netty-shaded instead of grpc-netty
grpc-netty is still really useful, but for most users who aren't doing
anything advanced using grpc-netty-shaded is much safer from a
dependency basis.

grpc-netty-shaded has seen more usage and has shown itself to be stable
and reduce the number of conflicts due to Netty versions.
2018-08-02 16:58:59 -07:00
Tom Leach b9d1bb8b8b core: initialize round robin load balancer picker to random index (#4462)
RoundRobinLoadBalancerFactory creates a new Picker instance every time the set of provided address groups changes or the connection state of subchannels associated with existing address groups changes. In certain scenarios, such as deployment/replacement of the target service cluster, this can lead to high churn of Picker objects. Given that each new Picker's subchannel index is initialized to zero, in these scenarios requests can end up getting disproportionately routed through subchannels (and hence server nodes) which are earlier in the list of address groups.

At Netflix we have measured that some service nodes end up taking 3-4x the load that of other nodes during deployment.

This commit randomizes the start index of the RoundRobinLoadBalancerFactory.Picker which eliminates this behavior.
2018-08-01 13:15:17 -07:00
Carl Mastrangelo 85448189ee
all: add tracking issues for all experimental APIs and make it required
Additionally, make Status*Exception.getTrailers() non experimental
2018-07-31 15:28:48 -07:00
Carl Mastrangelo bcbc6ae8fd
core: stabilize Status Exceptions API, and warn on null trailers in Status 2018-07-27 15:53:44 -07:00
Carl Mastrangelo 9b200eb7be
core: add flags for selectively enabling grpclb 2018-07-27 15:24:43 -07:00
ZHANG Dapeng 658e73a69e
core: let channel tracing log service config changes
This is the implementation of the second one of the changes to the channel tracing spec
grpc/proposal#89
2018-07-25 10:42:00 -07:00
ZHANG Dapeng 03d85ee53e
doc: clarify channel state API unimplemented until v1.6.1
Resolves #4624
2018-07-24 14:01:24 -07:00
Carl Mastrangelo 8da06a8bc4
all: remove unneeded deps on errorprone 2018-07-23 17:51:44 -07:00
zpencer 67073c921e
core: turn PairSocketAddress into ProxySocketAddress (#4649)
This internal class will only ever be used to plumb proxy info.
2018-07-23 17:43:26 -07:00
George Gensure 19b2a17801 core: Don't close in TSREI in cancelled contexts (#4596)
Prevent multiple effective close calls either by successful completion
of a cancel or complete notification, or through successive exceptions
handled within a single call.
2018-07-23 14:39:39 -07:00
ZHANG Dapeng e1865b565d
core: channel tracing log only when number of backends changed between zeor and nonzero
This is to implement one of changes made in the spec
https://github.com/grpc/proposal/pull/89/files
2018-07-23 14:30:38 -07:00
Eric Gribkoff 877b1a198f
core: enterIdleMode() exits idle if still in use (#4630) 2018-07-23 09:45:06 -07:00
Carl Mastrangelo 64d272ae7c
core: make service config errors recoverable 2018-07-20 17:47:03 -07:00
Eric Anderson 15a5ba2698 Remove DoNotMock annotation in favor of JavaDoc
DoNotMock was removed from error_prone_annotations in 2.1.3, because
there was no enforcement mechanism (which is in google/error-prone#572).
Guava and Trust also depend on error_prone_annotations and are beginning
to use newer versions, so our usage of DoNotMock is causing diamond
dependency problems. This allows us to update to 2.2.0.

The annotations were useful internally; we're solving that in cl/205294089.
2018-07-20 14:03:55 -07:00
zpencer 4335445d98
Start 1.15.0 development cycle (#4650) 2018-07-18 10:48:04 -07:00
Carl Mastrangelo 146b6006b3
compiler,stub: update RpcMethod docs and usage 2018-07-12 17:01:47 -07:00
Eric Anderson 9222dc5d01 core: Add missing @Nullable annotations to ClientTransportOptions
Convert the checkNotNull into our more standard line while I'm cleaning
it up.
2018-07-09 17:21:51 -07:00
Eric Anderson 9d6241eedc Propagate EquivalentAddressGroup attributes to transports
Most of the changes are changing the signature of newClientTransport.
Since this is annoying, I choose to introduce a ClientTransportOptions
object to avoid the churn in the future.

With ClientTransportOptions in place, there's only a few lines necessary
of plumbing for the Attributes: add the field to ClientTransportOptions
and populate it in InternalSubchannel. There are no consumers of the
field in this commit.
2018-07-09 13:00:17 -07:00
Eric Anderson 2b48210b73 grpclb: Plumb attributes for OOB and backend channels
These attributes can be used by ALTS-specific code to determine whether
ALTS or TLS should be used.
2018-07-09 11:25:49 -07:00
Eric Anderson dd57b667cc
Fix unused variables
Unused variables in tests were deleted. The unused variable in Netty
was a future that needed completing; that was a bug.
2018-07-04 07:32:57 -07:00
Yang Song 02ad99e1f5 core: Avoid compare default TagContext in thread local with empty. (#4613) 2018-07-03 15:28:05 -07:00
ZHANG Dapeng 6dad047126
core: add jndi timeout and dirContext.close 2018-07-02 17:36:05 -07:00
Eric Anderson e3ff1ade07
core: Add support for List<EAG> in Subchannels
This avoids the needs to flatten to EAGs for cases like PickFirst,
making the Attributes in EAGs able to be used in communication with
core. See #4302 for some discussion on the topic.
2018-07-02 14:00:05 -07:00
Carl Mastrangelo 39d2dd0eaa
core: make InternalHandlerRegistry a HandlerRegistry 2018-06-29 13:01:25 -07:00
Nick Hill b2dd6ae7f0 util: Improve RoundRobinLoadBalancer scalability with stickiness
- Rework stickiness picker logic to be non-blocking
- Stash `Subchannel` ref in an attribute rather than dedicated map
2018-06-29 09:49:23 -07:00
Marco Ferrer ac55604527 fixed typo in round robin factory name const
Fixes: #4598
2018-06-29 09:16:30 -07:00
Eric Anderson 3e67a5be75 core: Avoid unnecessary unchecked cast in DnsNameResolver 2018-06-28 15:47:06 -07:00
Carl Mastrangelo a74bb350b7
core: always do SRV record lookup in DnsNameResolver
Instead of failing after a a missing A/AAAA record, this change
makes the resolver keep going and try out SRV records too.  This
is needed for use with ALTS, and is part of the gRPCLB spec.

This change also moved the JNDI code to a separate, reflectively
loaded file.  This makes it easy to exclude the file and not worry
about the missing class references on Android.  Additionally, if
javax.naming might be available on Android, this allows it to be
loaded.  A key side effect of this is that DnsNameResolver is
smaller, and more cleanly tested.
2018-06-26 16:15:52 -07:00
Carl Mastrangelo 81da3eb95b
core: make Auto config load balancer not depend on service config
Also, add some tests
2018-06-26 13:36:02 -07:00
Doug Lawrie ffd0f9feca inprocess: add a toString for InProcessSocketAddress
The motivation here is in some cases we log the remote-addr that is set in the gRPC call attributes, and have to special case this type to support inprocess servers.
2018-06-22 10:32:42 -07:00
Kun Zhang 15786520f9
grpclb: use exponential back-off for retries of balancer RPCs (#4525) 2018-06-12 14:04:45 -07:00
Grant Oakley defb955f3a core: add clarification to ClientCall javadoc
* Improve ClientCall documentation. Clarify that some methods of ClientCall may be invoked from any thread. Adds @throws clauses to request().
2018-06-12 10:23:01 -07:00
ZHANG Dapeng 5ce10f0146
all: add gradle format checker
This PR adds an automatic gradle format checker and reformats all the *.gradle files. After this, new changes to *.gradle files will fail to build if not in good format, just like checkStyle failure.
2018-06-11 18:35:18 -07:00
Carl Mastrangelo 8f51c27319
core: fix lint 2018-06-06 17:14:58 -07:00
apolcyn 6dbe3921ed core: fix SRV record parsing
* only unquote TXT data, so as to not remove spaces from SRV data
2018-06-04 18:59:15 -07:00
ZHANG Dapeng c796901aca
core: channel tracing to log events for channel state change 2018-06-04 17:38:26 -07:00
ZHANG Dapeng 8a3e623be7
Start 1.14.0 development cycle 2018-06-04 16:08:31 -07:00
Bogdan Drutu 2a127ce3e7 core: update opencensus to 0.12.3. (#4530)
Changed calls to deprecated methods to the newly added methods.
2018-06-04 15:27:27 -07:00
ZHANG Dapeng a0794d5a68
core: Implement channel tracing for some events
Includes 
- API plumbing for channel tracing `+ManagedChannelBuilder.maxTraceEvents()`
- trace logging for channel/subchannel creation events and name resolving events.

Trace logging for all other events will be added in subsequent PRs.
2018-06-01 07:33:37 -07:00
zpencer 25a2ec1ef3
core: fix ServerBuilder.setBinaryLog javadoc (#4514)
The javadoc should refer to server not channel.
2018-05-31 18:14:44 -07:00
ZHANG Dapeng 608ce3d344
core: unit test for channel shutdown during retry backoff 2018-05-24 17:18:05 -07:00
zpencer ff9aa39bb6
core,services: fix lints (#4504)
- Type parameters must be upper camel case
- constant case field must be final
2018-05-24 11:12:30 -07:00
Eric Anderson e41e054776 Propagate CallCredentials.ATTR_SECURITY_LEVEL from transports
Previously no transport provided the key so CallCredentials would always
see the security as NONE.
2018-05-24 09:51:45 -07:00
zpencer 27439876f2
services,core: make BinaryLogSink visible, add setter (#4503)
* make BinaryLogSink public
* add io.grpc.BinaryLog to server/channel builder
2018-05-23 20:49:09 -07:00
zpencer 1f99fcdc82
move io.grpc.BinaryLogProvider to io.grpc.services (#4501)
Add internal accessors for ServerInterceptors and ClientInterceptors because some helpers were pkg private
Fix tests that were once creating BinaryLogProvider instances, they should now only create io.grpc.BinaryLog instances
2018-05-23 17:04:48 -07:00
zpencer 1aec994475
io.grpc.BinaryLog is now the fully functional API (#4498)
classes in internal now use the io.grpc.BinaryLog API,
io.grpc.BinaryLogProvider is an implementation of the API and will be
moved to io.grpc.services.
2018-05-23 15:58:37 -07:00
ZHANG Dapeng 6f2980e979
core: fix Attributes hashCode 2018-05-23 13:27:03 -07:00
Kun Zhang 68a462e447
noop: resolve lint warnings found at import. (#4496) 2018-05-23 11:58:19 -07:00
ZHANG Dapeng 451c412354
core: fix client does not detect truncated message
Resolves #3264
2018-05-21 13:51:15 -07:00
Jianwei Mao 10291d5ccc core: fix missing comment for headers param 2018-05-21 13:10:58 -07:00
ZHANG Dapeng f5f560ad36
all: TimeProvider to use nanos rather than millis
This is the same practice as #2833
2018-05-21 12:44:06 -07:00
zpencer faffb09f0a
core: remove io.grpc core dependency on census (#4461)
io.grpc (core) does not strictly require census. Move the usages and
and remove census from BUILD.bazel .
2018-05-18 14:56:45 -07:00
zpencer 850249f9ca
core: fix lints from import (#4472)
The import surfaced a few linter issues.
2018-05-17 16:21:30 -07:00
ZHANG Dapeng 4d94163bbd
core: Add ChannelTracer
This is a class similar to `CallTracer`, to be used for Channel Tracing.

The constructor arg `maxEvents` is a param supposed to be provided by `ManagedChannelBuilder`.
2018-05-16 10:56:41 -07:00
zpencer e806e387fe
core: put @ExperimentalApi on CallOptions.of() (#4466)
This marks the method as still experimental, to be clear to users that
they are using an experimental api.
2018-05-15 15:56:42 -07:00
ZHANG Dapeng 6a96656764
core: make channel stats' channel state consistent with subchannels
Moved `setState()` inside of `channelExecutor` runnable together with `setSubchannels`, otherwise the state may be inconsistent with subchannels, say channel state is the initial IDLE but subchannels is non-empty with active transports, or channel state is READY but subchannels is empty.
2018-05-15 15:48:57 -07:00
ZHANG Dapeng bf4a00c6de
context/core/netty: Add @CheckReturnValue to Context
By adding inner class annotations without introducing external dependencies.
2018-05-15 13:14:30 -07:00
ZHANG Dapeng 561583be14
core,services: Add ChannelTracing data object
Added `ChannelTrace` as an inner class of `Channelz`.

This is in preparation for the implementation of [Channel Tracing](https://github.com/grpc/proposal/blob/master/A3-channel-tracing.md)
2018-05-15 11:33:44 -07:00
zpencer 04a90bcad2
core: stabilize custom CallOptions API (#4457)
Deprecate `of()` in favor of `create()` and
`createWithDefault()`. Emphasize that the name string is only for
debug purposes.

Fixes #1869
2018-05-15 10:03:46 -07:00
zpencer 21b73bbdc1
core: partially stabilize Attributes API (#4458)
Deprecate static builder method, Keys.of(), add a notice of plans to
remove keys(), emphasize that the name is only a debug label.
The `@ExperimentalAPI` is left on the class because there are still
issues around hashCode/equals.
2018-05-14 11:30:06 -07:00
zpencer 902baa0cde
core: do not use internal accessors in BinaryLogProvider (#4454)
Now that this class is in `io.grpc` the accessor is not needed.
2018-05-09 12:21:05 -07:00
zpencer 247a76ed93
core,netty,okhttp: make toString more consistent for channelz (#4434)
Use MoreObjects.toStringHelper and use only the log id's long value,
because the class name is already present in the toStringHelper.
2018-05-07 11:38:16 -07:00
zpencer 6f29b60dcf
core, services: make BinaryLog an explicit object that is passed into channels/servers (#4431)
remove SPI, io.grpc.BinaryLog is a public API that is passed into builders and must be
explicitly closed.
2018-05-07 07:41:42 -07:00
Carl Mastrangelo 60a0b0c471
all: normalize copyright header 2018-05-03 14:55:21 -07:00
Eric Anderson 894c815832
core: Document Metadata ownership passes to the Call{,Listener}
This was already clearly documented in ServerCall.Listener and
ClientCall.
2018-05-03 07:08:27 -07:00
Grant Oakley 6bf8e0c084 core: add @CheckReturnValue to CallOptions 2018-05-02 15:56:52 -07:00
ZHANG Dapeng e19e8f7d40
core: populate effective deadline to ClientStream
Added `ClientStream.setDeadline(Deadline deadline)` method, which will set the timeout header.

Resolves #4412
2018-05-02 13:31:03 -07:00
ZHANG Dapeng d50c191aca
core/stub: fix lint warnings 2018-05-02 10:37:32 -07:00
Grant Oakley fcb48ff216 core,stub: Add toString() to ClientCallImpl and GrpcFuture 2018-05-01 16:49:56 -07:00
ZHANG Dapeng b58e0f4059
core: stickiness for RoundRobinLoadBalancer
Add weak stickiness support for Round Robin lb.
2018-04-30 16:46:35 -07:00
zpencer acfb3b9851
services,core: simplify CallId generation (#4365)
BinaryLog.java is the class that is responsible for intercepting
client and server calls. It now requires a CallId to be passed
in. The BinaryLogProviderImpl is responsible for generating a
CallId and passing it in.
2018-04-27 18:32:36 -07:00
zpencer 9ada30b25d
(low priority) core,netty,interop-testing: stabilize maxInboundMessageSize API (#4399)
On server side, `maxMessageSize` is deprecated for
`maxInboundMessageSize` to match the channel builder.

Update usages to use new setter.
2018-04-27 16:01:16 -07:00
zpencer 1a2d076aed
core,netty,okhttp,services,testing: expose security info to channelz (#4300)
Pull the TLS info from the SSLSession object for TLS, and AltsContext for ALTS.
2018-04-25 14:38:09 -07:00
zpencer 62e6e2de78
Start 1.13.0 development cycle (#4383) 2018-04-23 15:24:24 -07:00
Carl Mastrangelo c37ea15830
core: also expose parser on JsonParser 2018-04-20 13:25:21 -07:00
ZHANG Dapeng 74532acce0
core: use List instead of Set for drainedSubstreams
This improves latency performance (retry enabled) for NETTY transport by about 2us. For INPROCESS, NETTY_LOCAL, OKHTTP transports, the improvement seems much less than 2us.

```
before
Benchmark                                               (direct)  (transport)    Mode     Cnt         Score     Error  Units
TransportBenchmark.unaryCall1024                            true        NETTY  sample  260801     76566.536 ± 189.439  ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.00        true        NETTY  sample             60480.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.50        true        NETTY  sample             75264.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.90        true        NETTY  sample             85504.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.95        true        NETTY  sample             87424.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.99        true        NETTY  sample            100864.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.999       true        NETTY  sample            140800.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.9999      true        NETTY  sample            205547.469            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p1.00        true        NETTY  sample           3915776.000            ns/op 
TransportBenchmark.unaryCall1024                           false        NETTY  sample  208352     95865.619 ± 113.142  ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.00       false        NETTY  sample             72576.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.50       false        NETTY  sample             93568.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.90       false        NETTY  sample            105728.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.95       false        NETTY  sample            109568.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.99       false        NETTY  sample            124544.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.999      false        NETTY  sample            161792.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.9999     false        NETTY  sample            230520.448            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p1.00       false        NETTY  sample           3997696.000            ns/op
```

```
after
Benchmark                                               (direct)  (transport)    Mode     Cnt         Score     Error  Units
TransportBenchmark.unaryCall1024                            true        NETTY  sample  269471     74104.666 ± 182.514  ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.00        true        NETTY  sample             60992.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.50        true        NETTY  sample             70912.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.90        true        NETTY  sample             83584.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.95        true        NETTY  sample             85888.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.99        true        NETTY  sample            100224.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.999       true        NETTY  sample            142848.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.9999      true        NETTY  sample            489527.706            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p1.00        true        NETTY  sample           4300800.000            ns/op
TransportBenchmark.unaryCall1024                           false        NETTY  sample  216000     92468.337 ±  90.229  ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.00       false        NETTY  sample             68480.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.50       false        NETTY  sample             89472.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.90       false        NETTY  sample            103680.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.95       false        NETTY  sample            107008.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.99       false        NETTY  sample            120960.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.999      false        NETTY  sample            159232.000            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.9999     false        NETTY  sample            272076.493            ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p1.00       false        NETTY  sample           2662400.000            ns/op
```
2018-04-20 11:22:32 -07:00
Eric Anderson ddf77f59cc core: Fix experimental API issue for channel state API
The earlier issue was for the feature itself, not the stabilization.
2018-04-19 17:38:20 -07:00
zpencer 934c2e2fd7
core: clarify binlog API (#4362)
The interceptors are a part of the implementation and not meant for
callers.

Both methods for wrapping clients / servers can be `final`.
2018-04-19 17:32:45 -07:00
zpencer ec95999124
core: remove unneeded binlog tests for ManagedChannelImpl ServerImpl (#4361)
Replace the tests with tests that just make sure binary log is
installed. Better tests exist today in BinaryLogProviderTest to make
sure the actual logic is correct.
2018-04-19 16:55:32 -07:00
ZHANG Dapeng e67a61fa08
core: refactor ManagedChannelImplTest with a configurable builder
In previous code of `ManagedChannelImplTest`, new tests will have to add more and more custom args in `createChannel(...)`, and each time when a custom arg is needed all other default args need be repeatedly provided in `createChannel(...)`. In most cases those args are just builder attributes. So this PR makes ManagedChannelImplTest easier to stub by providing a builder field, then new tests will just set necessary builder attributes before calling `createChannel()`.
2018-04-19 10:06:39 -07:00
ZHANG Dapeng f6a032d6b2
core: forward toString for forwarding classes
Forward `toString()` method for forwarding classes to improve debug information.

For example, `ForwardingManagedChannel.toString()` will return something like:

```
ForwardingManagedChannel{delegate=ManagedChannelImpl{logId=tag-13247, target=localhost:8080}}
```
2018-04-19 10:05:48 -07:00
Carl Mastrangelo f754bff906
core: make JsonParser public 2018-04-18 18:49:08 -07:00
zpencer 30400e0e58
core: add sockets to subchannel stat (#4345)
This is info not being reported at the moment and is missing from the
display.
2018-04-16 11:33:28 -07:00
zpencer c04278ea07
services: turn channelz null futures into Status.UNIMPLEMENTED (#4346)
Then channelz GUI will take this into account. This is particularly
useful for InProcessTransport, where I have decided we do not need
special support for in channelz. The server and channel stats are
already sufficient.
2018-04-16 09:54:35 -07:00
zpencer 791a29f63b
services: socket options were erroneously ignored if socket has no stats (#4336)
This fixes listen sockets. It is ok to have no data but report socket
options.
2018-04-13 14:59:35 -07:00
Carl Mastrangelo e4502aca5d
stub: add docs clarifying readiness 2018-04-13 14:12:54 -07:00
Carl Mastrangelo 03465a7f45
core: don't warn on absent service config
Fixes #4333
2018-04-13 11:13:57 -07:00
ZHANG Dapeng a6811d5bb1
all: add toString() to Server to improve debug info 2018-04-13 09:41:09 -07:00
ZHANG Dapeng 0eafb8e9ca
core: compare doubles with compare instead of ==
Always not compare equality for doubles with `==`.
2018-04-13 09:39:59 -07:00
Eric Anderson 0a598c053c core: Fix lint, style, "good ideas" violations 2018-04-12 17:26:54 -07:00
ZHANG Dapeng 6d7e19cbe5
core: replumb RetryPolicy
- replumbed `RetryPolicy` with `MethodInfo` without breaking the existing `RetryPolicyTest`.
- moved `ServiceConfigInterceptor.MethodInfo.RetryPolicy` out as a top level class so that `RetriableStream` does not import `ServiceConfigInterceptor`.
2018-04-12 11:41:04 -07:00
Kun Zhang 3f63cd0ad4
core: always call StreamTracer.streamClosed() when stream is officially closed. (#4331)
Previously StreamTracer.streamClosed() is called in
ServerStream.close(), but it is not exactly when the stream is
officially closed.  ServerStreamListener.closed() is guaranteed to be
called and it is the official end of the stream.
2018-04-12 09:05:48 -07:00
zpencer 137e759fda
core, netty: allow InputStream based certs (#4316)
Allow ServerBuilder to read certs from InputStream, not just from a
File.
2018-04-11 16:14:58 -07:00
zpencer 62cc2b1ae3
core,netty: add NettySocketSupport to populate TcpInfo (#4306)
NettySocketSupport is responsible for making the low level calls to
get and populate the TcpInfo structure.
2018-04-05 10:36:49 -07:00
Carl Mastrangelo 2df76cc710
core: apply service config 2018-04-04 17:45:12 -07:00
Carl Mastrangelo 9ed84258aa
core: don't reschedule idle timer if it is already active
Benchmark results (3 runs each)

non direct

```
Before:
50.0%ile Latency (in nanos):		157471
90.0%ile Latency (in nanos):		185927
95.0%ile Latency (in nanos):		195135
99.0%ile Latency (in nanos):		218815
99.9%ile Latency (in nanos):		1188735
100.0%ile Latency (in nanos):		18333695
QPS:                           6126
50.0%ile Latency (in nanos):		160407
90.0%ile Latency (in nanos):		188551
95.0%ile Latency (in nanos):		197487
99.0%ile Latency (in nanos):		219575
99.9%ile Latency (in nanos):		390239
100.0%ile Latency (in nanos):		18338815
QPS:                           6106
50.0%ile Latency (in nanos):		157831
90.0%ile Latency (in nanos):		186439
95.0%ile Latency (in nanos):		195815
99.0%ile Latency (in nanos):		216951
99.9%ile Latency (in nanos):		281167
100.0%ile Latency (in nanos):		5384447
QPS:                           6235

After:
50.0%ile Latency (in nanos):		152255
90.0%ile Latency (in nanos):		180551
95.0%ile Latency (in nanos):		188943
99.0%ile Latency (in nanos):		209623
99.9%ile Latency (in nanos):		1184831
100.0%ile Latency (in nanos):		4351999
QPS:                           6313
50.0%ile Latency (in nanos):		153663
90.0%ile Latency (in nanos):		181671
95.0%ile Latency (in nanos):		189991
99.0%ile Latency (in nanos):		210495
99.9%ile Latency (in nanos):		278895
100.0%ile Latency (in nanos):		18283519
QPS:                           6300
50.0%ile Latency (in nanos):		152767
90.0%ile Latency (in nanos):		180839
95.0%ile Latency (in nanos):		189791
99.0%ile Latency (in nanos):		211719
99.9%ile Latency (in nanos):		280927
100.0%ile Latency (in nanos):		12231167
QPS:                           6381
```

direct:

```
Before:
50.0%ile Latency (in nanos):		133943
90.0%ile Latency (in nanos):		153671
95.0%ile Latency (in nanos):		163655
99.0%ile Latency (in nanos):		188871
99.9%ile Latency (in nanos):		235791
100.0%ile Latency (in nanos):		7864575
QPS:                           7134
50.0%ile Latency (in nanos):		131623
90.0%ile Latency (in nanos):		151863
95.0%ile Latency (in nanos):		162095
99.0%ile Latency (in nanos):		187719
99.9%ile Latency (in nanos):		234983
100.0%ile Latency (in nanos):		17836031
QPS:                           7250
50.0%ile Latency (in nanos):		131223
90.0%ile Latency (in nanos):		150823
95.0%ile Latency (in nanos):		161311
99.0%ile Latency (in nanos):		187719
99.9%ile Latency (in nanos):		237471
100.0%ile Latency (in nanos):		4416255
QPS:                           7273

After:
50.0%ile Latency (in nanos):		122751
90.0%ile Latency (in nanos):		140967
95.0%ile Latency (in nanos):		148911
99.0%ile Latency (in nanos):		173215
99.9%ile Latency (in nanos):		214823
100.0%ile Latency (in nanos):		18509823
QPS:                           7774
50.0%ile Latency (in nanos):		124507
90.0%ile Latency (in nanos):		145855
95.0%ile Latency (in nanos):		156623
99.0%ile Latency (in nanos):		183111
99.9%ile Latency (in nanos):		235679
100.0%ile Latency (in nanos):		18289663
QPS:                           7625
50.0%ile Latency (in nanos):		124295
90.0%ile Latency (in nanos):		145071
95.0%ile Latency (in nanos):		156439
99.0%ile Latency (in nanos):		183919
99.9%ile Latency (in nanos):		232447
100.0%ile Latency (in nanos):		3712383
QPS:                           7632
```
2018-04-04 16:02:02 -07:00
Shohei Kamimori 8f01084bb3 core: add a `close` to InputBufferStream
Before:
`InputBufferStream.close()` does not close their buffer so the buffer will leak.

After:
Resolves #4198.
Override the `close` for closing their buffer.
2018-04-03 16:11:19 -07:00
zpencer b1d91b9f60
core,services: binary log should use real peer socket and call id (#4266)
The peer socket is read from TRANSPORT_ATTR_REMOTE_ADDR from the
stream attributes. We only log the peer on receive initial metadata.

The call id assumes census is available. The call ID read from the
context via SERVER_CALL_ID_CONTEXT_KEY on server side, and read from
CallOptions via CLIENT_CALL_ID_CALLOPTION_KEY on client side. The
value is copied from CONTEXT_SPAN_KEY which is set by census.

Pass around CallId with two longs, not a byte[].
2018-04-03 13:39:11 -07:00