Commit Graph

3380 Commits

Author SHA1 Message Date
Eric Anderson c63752789e java_grpc_library.bzl: Pre-migrate for Bazel incompatible_use_toolchain_providers_in_java_common
This doesn't actually yet work with
--incompatible_use_toolchain_providers_in_java_common, as Bazel 0.23 didn't
include enough pieces. But this will work in 0.24 with the flag flipped. In
both cases it will continue working if the flag is not specified.

See https://github.com/grpc/grpc-java/issues/5383#issuecomment-470357965 and
https://github.com/bazelbuild/bazel/issues/7186
2019-03-07 18:09:53 -07:00
Eric Anderson 2dc00cec4a SECURITY.md: Fix syntax and typos in mutual TLS interceptor example
Fixes #4905
2019-03-07 16:53:34 -07:00
Kun Zhang 04f8d06147
grpclb: use fallback addresses if no balancer address is given (#5445) 2019-03-07 15:39:45 -08:00
Kun Zhang 034675e555
grpclb: keep track of state updates for cached Subchannels. (#5441)
The problem: GrpclbState tracks Subchannels' states as a mutable
attribute in Subchannel.getAttributes(). However, GrpclbState only
update this attribute for the Subchannels its managing. For those
cached in SubchannelPool, their state attributes are stale. When they
are given back to GrpclbState, IDLE state is assumed.  As a result, if
a Subchannel is READY when it's reclaimed from the pool, it will not
be picked.

To fix that, this change expands SubchannelPool interface to handle
Subchannel state updates, which GrpclbState will call. SubchannelPool
saves the latest state and delivers it when it's returned to
GrpclbState by scheduling a call to handleSubchannelState() in the
SynchronizationContext, so that GrpclbState will take the latest state
as if it was just reported from the Channel.
2019-03-07 13:14:21 -08:00
Carl Mastrangelo 6b0325c84f
core: normalize log statement callsite
Make the "logged" method be consistent, and refer to the public logging class name and method.  This makes the log statements return the same class name used to set the log level.  

Before:

```
190306 13:29:39.290:D 1 [io.grpc.internal.ChannelTracer.logOnly] [Channel<1>: (localhost:10000)] Channel for 'localhost:10000' created
190306 13:29:39.414:D 1 [io.grpc.internal.ChannelTracer.logOnly] [Channel<1>: (localhost:10000)] Exiting idle mode
190306 13:29:39.622:D 17 [io.grpc.internal.ChannelTracer.logOnly] [Channel<1>: (localhost:10000)] Resolved address: [[[/127.0.0.1:10000]/{}]], config={}
190306 13:29:39.623:D 17 [io.grpc.internal.ChannelTracer.logOnly] [Channel<1>: (localhost:10000)] Address resolved: [[[/127.0.0.1:10000]/{}]]
190306 13:29:39.624:D 17 [io.grpc.internal.ChannelTracer.logOnly] [Subchannel<3>] Subchannel for [[[/127.0.0.1:10000]/{}]] created
```

After:

```
190306 13:49:15.654:D 1 [io.grpc.ChannelLogger.log] [Channel<1>: (localhost:10000)] Channel for 'localhost:10000' created
190306 13:49:15.772:D 1 [io.grpc.ChannelLogger.log] [Channel<1>: (localhost:10000)] Exiting idle mode
190306 13:49:15.995:D 18 [io.grpc.ChannelLogger.log] [Channel<1>: (localhost:10000)] Resolved address: [[[/127.0.0.1:10000]/{}]], config={}
190306 13:49:15.995:D 18 [io.grpc.ChannelLogger.log] [Channel<1>: (localhost:10000)] Address resolved: [[[/127.0.0.1:10000]/{}]]
190306 13:49:15.997:D 18 [io.grpc.ChannelLogger.log] [Subchannel<3>] Subchannel for [[[/127.0.0.1:10000]/{}]] created
190306 13:49:15.999:D 18 [io.grpc.ChannelLogger.log] [Channel<1>: (localhost:10000)] Child Subchannel created
```
2019-03-06 15:29:46 -08:00
Kun Zhang 2f50d88678
grpclb: support "pick_first" child policy (#5438)
The PICK_FIRST mode puts all backend addresses in a single Subchannel. There are a few points where it's different from the default ROUND_ROBIN mode:

1. PICK_FIRST doesn't eagerly connect to backends like ROUND_ROBIN does. Instead, it requests for connections when the Subchannel is picked.

2. PICK_FIRST adds tokens to the headers via a different code path (`TokenAttachingTracerFactory`) than ROUND_ROBIN

3. For simple implementation, when the mode is changed by service config when the LoadBalancer is working, we will shut down `GrpclbState` and starts a new one with the new mode. All connections will be closed during the transition. We don't expect this to happen in practice given the specific use case of PICK_FIRST.
2019-03-06 13:02:32 -08:00
AmiDavidW 128409000a examples: add an example of server side compression support 2019-03-06 12:25:57 -08:00
Carl Mastrangelo 5cc71f1de9
netty, core: pass log-only channel logger into transport 2019-03-06 11:49:42 -08:00
Carl Mastrangelo 07d7b99e31
netty: expose methods of ProtocolNegotiationEvent through accessor 2019-03-06 10:59:41 -08:00
Kun Zhang b0bbd7537b
core/grpclb: propagation and parsing of grpclb config (#5419)
Make sure the config for grpclb is passed to the GrpclbLoadBalancer, which will support two child policies -- "round_robin" (default) and "pick_first".

Previously the presence of balancer addresses would dictate "grpclb" policy, despite of the service config. Service config will now take precedence instead.

Implement config parsing logic in GrpclbLoadBalancer. Per offline discussions with @markdroth and @ejona86, we will ignore configuration errors for now. The more appropriate config error handling is upcoming.
2019-03-05 15:39:48 -08:00
Eric Anderson b48b0ac1d4 all: Stop committing generated protobuf messages
This commit swaps to using a Sync task to place generated code in the
src/generated folder instead of the gradle-protobuf-plugin's
generatedFilesBaseDir. This provides much nicer results on failed
builds, and you will no longer see all the generated files deleted.

But at the same time the Sync task makes it easy to only copy the
grpc-generated code. This was not previously done because we were lazy
and using generatedFilesBaseDir, which made it difficult to treat the
services differently from the messages.
2019-03-05 16:28:55 -07:00
ZHANG Dapeng b7dd92e7bb
core: suppress android lint error for javax.naming.*
Resolves #5422
2019-03-05 14:46:38 -08:00
Carl Mastrangelo d833767037
netty: expose some of the reusable handlers in ProtocolNegotiators 2019-03-05 11:29:32 -08:00
Carl Mastrangelo 3ffec383e3
netty: make WaitUntilActiveHandler not check if the channel is active 2019-03-05 10:29:38 -08:00
Liam Miller-Cushon 952a767b9c Rename source jar outputs to avoid conflicts with java_common.compile
More information: https://github.com/bazelbuild/bazel/issues/5824
2019-03-05 08:44:22 -07:00
Carl Mastrangelo 801cc5c189
core,netty,okhttp: propagate the subchannel logger to the transport 2019-03-04 15:16:53 -08:00
Carl Mastrangelo 3bae61e83b
netty: switch plaintext upgrade negotiator to new format 2019-03-04 14:48:28 -08:00
Kun Zhang 2336eb6f57
test: test the header mutation inside newClientStreamTracer() (#5421)
newClientStreamTracer() is called from transport implementations, thus
needs to be tested in AbstractTransportTest.
2019-03-04 13:53:03 -08:00
Kun Zhang a15a3117de
core: deprecate LoadBalancer.Helper#getNameResolverFactory (#5418)
This was added for the potential use case of needing to resolve target
names (of the same scheme as the top-level channel's target's) in the
LoadBalancer.  Now actual use cases come up in xDS that we need to
resolve fully-qualified target strings with arbitrary schemes.  This
method has never been used and won't fit future uses because it's too
restrictive.
2019-03-04 13:37:49 -08:00
Kun Zhang 59a336c3ae
core: add internal transport attribute ATTR_CLIENT_EAG_ATTRS (#5420)
This is needed for GRPCLB pick_first support, which needs to attach
tokens to headers, and the tokens are per server. In pick_first, all
addresses are in a single Subchannel, thus the LoadBalancer needs to
know which backend is used for a new stream.
2019-03-04 12:38:26 -08:00
Kun Zhang 0e7b8fd9ef
core: add LoadBalancer.Helper#createResolvingOobChannel() (#5415)
This can be used by xds LoadBalancer to create a channel to the XDS
traffic director, as the service config will only specify the target
name of the balancer.

This PR only adds the interface to unblock the xds work.
Implementation would take some time thus will come later.
2019-03-04 09:42:17 -08:00
ZHANG Dapeng 0665af289a
netty: fix lint 2019-03-04 09:40:42 -08:00
Kun Zhang 02f55189aa
core: refactor load-balancing config handling (#5397)
The LoadBalancingConfig message, which looks like
```json
{
  "policy_name" : {
    "config_key1" : "config_value1",
    "config_key2" : "config_value2"
   }
}
```
appears multiple times. It gets super tedious and confusing to handle, because both the whole config and the value (in the above example is `{ "config_key1" : "config_value1" }`) are just `Map<String, Object>`, and each user needs to do the following validation:
 1. The whole config must have exactly one key
 2. The value must be a map

Here I define `LbConfig` that holds the policy name and the config value, and a method in `ServiceConfigUtil` that converts the parsed JSON format into `LbConfig`.

There is also multiple cases where you need to handle a list of configs (top-level balancing policy, child and fallback policies in xds, grpclb child policies). I also made another helper method in `ServiceConfigUtil` to convert them into `List<LbConfig>`.

Found and fixed a bug in the xds code, where the top-level balancer should pass the config value (excluding the policy name), not the whole config to the child balancers. Search for "supported_1_option" in the diff to see it in the tests.
2019-03-01 19:05:33 -08:00
Kun Zhang 8806403b3a
core: remove unnecessary private method (#5417) 2019-03-01 17:28:30 -08:00
Carl Mastrangelo 5cfff5bfce
netty: replace TLS protocol negotiator with new style handlers 2019-03-01 11:37:07 -08:00
Eric Anderson a818c81a71 testing: Move AbstractTransportTest to core to avoid Truth dep
Fixes #5301
2019-02-28 21:33:19 -07:00
Rodrigo Queiro 0959a846c8 bazel: update to new ProtoInfo provider
This is part of #5383. As Bazel 0.22.0 is the only supported version
now, use this in the Kokoro build.
2019-02-28 21:30:48 -07:00
Rodrigo Queiro 054def3c63 Use newer Bazel actions API
Also pass in the binary correctly as a tool. This is required for #5383.

I have tested the build with older Bazel versions and this doesn't
appear to affect compatibility, ie grpc-java continues to be compatible
with Bazel >=0.19.
2019-02-28 20:47:15 -07:00
Nguyen Quang Huy 05d5e4802a doc: Change http to https for security links
For security, we should change http into https links.

Co-Authored-By: Nguyen Van Trung [trungnvfet@outlook.com](mailto:trungnvfet@outlook.com)
Signed-off-by: Nguyen Quang Huy [huynq0911@gmail.com](mailto:huynq0911@gmail.com)
2019-02-27 17:25:42 -08:00
Carl Mastrangelo c5d2d483e2
all: try out mockito rule 2019-02-27 16:40:47 -08:00
Eric Anderson 08aaf7a8b1 Upgrade to Mockito 1.10.19 2019-02-27 17:06:01 -07:00
Eric Anderson 0d97507919
SECURITY.md: Don't suggest users to use Jetty ALPN
I fixed many of these elsewhere in the document via 4ba168f28, but I
didn't update the troubleshooting section previously.
2019-02-27 16:32:59 -07:00
Carl Mastrangelo b86fdfa12e
all: update README to reference 1.19.0 2019-02-27 14:55:09 -08:00
sanjaypujare 5d87f8b8dd
add a missing critical whitespace (#5408) 2019-02-27 14:33:43 -08:00
Eric Anderson 1da3f65e7b SECURITY.md: tcnative/ALPN works on Alpine
In testing, I discovered that Alpine does in fact work. Update the
documentation with the error you might see if you are simply missing a
package (for Googling) as well as fixes.
2019-02-27 15:19:49 -07:00
Eric Anderson 2a3e0616ff travis.yml: Stop testing jdk9
JDK 11 is LTS and superceded JDK 9 and 10. Nobody should really be using JDK 9
(just like the already untested JDK 10) so let's not waste the CPU testing it.
As long as we support JDK 8 and 11 it is unlikely we break JDK 9, though.
2019-02-27 11:20:19 -07:00
Jihun Cho 68f6ce9ddd
all: fix publish not having checksum (#5398) 2019-02-27 09:39:02 -08:00
ZHANG Dapeng b9fb649ce1
xds: fallback handling
added fallback handling
in addition: 
- made XdsLbState not abstract for now
- did not include graceful swapping balancers when service config change, for now just shutdown the old one and use the new one.
2019-02-26 13:13:42 -08:00
Jihun Cho 539d6bf67d
all: when publishing to maven/mavenLocal excludes xds and gae-interops (#5391) 2019-02-26 12:52:06 -08:00
Nguyen Quang Huy 69a4917a8c doc: Remove some duplicated words in comment
Correct spelling for code comment.
2019-02-25 10:18:52 -08:00
ZHANG Dapeng dd466039b5
doc: Update NOTICE with xds third_party dependencies 2019-02-21 11:15:26 -08:00
Kun Zhang 83b92cfc9f
core: pass transport attributes to ClientStreamTracer.Factory.newClientStreamTracer() (#5380)
This will be a new override.  The old override is now deprecated.

In order to pass new information without adding new overrides, I shoved most information
into an object called StreamInfo.  The Metadata is left out to draw attention because
it's mutable.

Motivation: this is needed for correctly supporting pick_first in GRPCLB.  GRPCLB needs to
add a token to the headers, and the token varies among servers.  With round_robin, GRPCLB
create a Subchannel for each server, thus can attach the token when the Subchannel is picked.
To implement pick_first, all server addresses will be put in a single Subchannel, we will
need to add the header in newClientStreamTracer(), by looking up the server address from
the transport attributes and deciding which token to add.
2019-02-21 11:13:51 -08:00
Eric Gribkoff 6c32eaf9d4
okhttp: add socketFactory method to channel builder (#5378) 2019-02-20 19:17:20 -08:00
David Hoover d44d015c44 doc: Fix typo 2019-02-20 16:40:57 -08:00
Kun Zhang 86f974333e
core: delete deprecated ClientStreamTracer.Factory#newClientStreamTracer (#5377) 2019-02-20 12:07:15 -08:00
Kun Zhang b867f8e4fc
core: make NameResolver not thread-safe (#5364)
Resolves #2649

As a prerequisite, added `getSynchronizationContext()` to `NameResolver.Helper`.

`DnsNameResolver` has gone through a small refactor around the `Resolve` runnable, which makes it a little simpler.
2019-02-20 11:45:38 -08:00
Dan 05b6156d43 core: using correct key for hedging max attempts 2019-02-19 15:22:16 -08:00
Jihun Cho 5f60f22b6a netty: prevent IndexOutOfBoundsException when no handler is passed to BufferingHandler 2019-02-15 15:18:48 -08:00
Carl Mastrangelo 8e6fa122a6
netty,alts: hide ProtocolNegotiator behind an accessor, and...
...and move the `close()` method to ProtocolNegotiator rather than Handler.

Since this is a breaking change (for people who ignored our `@Internal` annotations), I wanted to make both changes in the same PR so as to fix them both at the same time.
2019-02-15 13:59:58 -08:00
ZHANG Dapeng 5ae9d91039
xds: use shadow plugin for generated code
* Import envoy proto file to the latest internal version, which has correct java proto options. (The PGV proto, `validate.proto`, doesn't have the correct and up-to-date java_package proto option yet, but as long as we don't use those generated classes, it seems fine.)
* Stop modifying java proto options by import.sh.
* Apply shadow plugin when publishing.
2019-02-15 10:19:44 -08:00