Commit Graph

228 Commits

Author SHA1 Message Date
Kun Zhang a57f1a9636
services: fix a local variable name (#6802) 2020-03-04 14:31:09 -08:00
Jihun Cho 2162ad0436
service: HealthCheckingLoadBalancerFactory using its own attribute (#6704) 2020-02-28 17:11:20 -08:00
Eric Anderson e7d7c5bde4
examples: Add hostname example
This is placed in its own directory since it depends on grpc-services.
2020-01-17 15:50:49 -08:00
Tomo Suzuki 75f6fd8f10 Upgrade error_prone_annotations to 2.3.4 2020-01-03 14:50:34 -08:00
Jihun Cho 90969b3471
core: make service config error handling optional implementation (#6564) 2019-12-26 15:07:20 -08:00
Tomo Suzuki 29638780ae build: Replaced outdated comments (#6492) 2019-12-05 13:53:51 -08:00
Jihun Cho 7db873f1f6
Roll-forward of stub,compiler: generated stub extends Abstract{Async,Future,Blocking}Stub #6196 (#6458)
This reverts commit 2eb3f8c34e (#6317).
2019-11-25 09:41:16 -08:00
ZHANG Dapeng b009e92156
xds: Bump perfmark to 0.19.0
Resolves #6217
2019-10-22 16:55:39 -07:00
Jihun Cho 2eb3f8c34e
stub,compiler: Rollback Abstract{Future,Blocking,Async}Stub (#6317)
rollback of #6304 & #6196
2019-10-22 13:27:30 -07:00
Jihun Cho 45d49a56cc
stub,compiler: generated stub extends Abstract{Async,Future,Blocking}Stub (#6196) 2019-10-17 14:49:24 -07:00
Eric Anderson 024a46bd11
bazel: Support --incompatible_load_proto_rules_from_bzl
This flag will be enabled by default in Bazel 1.0

Since I changed the grpc-proto repo version for Bazel, I also synced the
protos.
2019-10-09 14:46:17 -07:00
Jihun Cho e9ac1b4a76
all: update modules to wait until other module's sourceSet is available (#6232) 2019-10-02 15:05:44 -07:00
Eric Anderson 2b945774b6 Apply animalsniffer plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 4215b80b81 Apply java plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 5b838e5284 Apply maven-publish plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 3c3a823a81 Swap to Gradle's Plugin DSL for much of build
Examples and android projects were left unchanged. They can be changed
later.

No plugin versions were changed, to make this as non-functional of a
change as possible. Upgrading Gradle to 5.6 was necessary for
pluginManagement in settings.gradle.
2019-09-13 09:42:17 -07:00
Chengyuan Zhang b8933faae1
services: added even more (context-related) test cases for CallMetricRecorder (#6033) 2019-08-01 10:09:26 -07:00
Chengyuan Zhang 99993bee13
xds: implement a server interceptor for taking server application metrics and sending to client side in ORCA format (#6018)
* Added methods in CallMetricRecorder accessor for accessing context key and creating new CallMetricRecorder instance.

* Added impl for a server interceptor that records and sends custom metric values to client side.

* Added unit test for the server interceptor.

* Modified dependencies to have xds package depends on grpc-services (for CallMetricRecorder) and grpc-testing-proto (for testing proto).

* Changed usage of GrpcServerRule to GrpcCleanupRule.

* make constant fields static

* use GrpcCleanupRule to register InProcessChannel to avoid manual shutdown.

* Make class public and match the usage of grpclb's load reporting server tracer.

* added ExperimentalApi annotation
2019-07-29 14:46:24 -07:00
Chengyuan Zhang 50df56f949
xds: add a missing test case for CallMetricRecorder and polish test data. (#6019) 2019-07-29 14:43:42 -07:00
Chengyuan Zhang f15a6bd363
services: implement a lb policy agnostic call metric recorder for backend applications (#6004)
* services: implement a lb policy agnostic call metric recorder for backend applications.

* Renamed snapshot() to finalizeAndDump() and make it package-private with an internal accessor class.

* Added Javadoc link for Context.

* Added ExperimentalApi annotation.

* Added since annotations.
2019-07-25 15:39:22 -07:00
liym 47b11ab7a1 compiler: Use 'SERVICE_NAME' instead of duplicated '$Package$$service… (#5943)
* compiler: Use 'SERVICE_NAME' instead of duplicated '$Package$$service_name$'

* compiler: Align indentation

* Fix typo

* Add modified golden files and all re-generated code to meet Travis CI and Windows build requirements

See PR #5943

* Polishing
2019-07-24 10:37:13 -07:00
Kun Zhang ff33ecd339
services: fix HealthCheckingLoadBalancer.shutdown() (#5887)
The issue: HealthCheckingLoadBalancer.shutdown() calls
hcState.onSubchannelState(SHUTDOWN) which removes that hcState from
helper.hcStates. Therefore, if more than one Subchannels are present,
ConcurrentModificationException will be thrown.

This is an alternative approach from #5848 that was reverted in #5875. Thanks to #5883, HealthCheckingLoadBalancer.shutdown() no longer has to fake SHUTDOWN notifications, and can completely rely on Subchannels' real SHUTDOWN notifications for triggering the clean-up.
2019-06-14 16:47:17 -07:00
Eric Anderson 8e59a2d1e5 Revert "services: fix HealthCheckingLoadBalancer.shutdown(). (#5848)"
This reverts commit c6f15162ff. It broke
an internal health checking test because the server wouldn't shut down.
We assume the health checking RPC isn't getting closed.
2019-06-13 15:04:41 -07:00
Kun Zhang c6f15162ff
services: fix HealthCheckingLoadBalancer.shutdown(). (#5848)
HealthCheckingLoadBalancer.shutdown() calls
hcState.onSubchannelState(SHUTDOWN) which removes that hcState from
helper.hcStates.  Therefore, if more than one Subchannels are present,
ConcurrentModificationException will be thrown.

Since HealthCheckingLoadBalancer.shutdown() will clear the hcStates
set after the loop, it's unnecessary to do the deletion within the
loop.  However, when a Subchannel is shutdown by LoadBalancer, its
HcState still needs to be removed.  To do that, change moves the
deletion to Subchannel.shutdown().
2019-06-07 09:32:55 -07:00
ZHANG Dapeng 6aadaf0a64
core,services: cleanup io.grpc.internal.IoUtils 2019-06-05 17:31:46 -07:00
Chengyuan Zhang 00d4cc29ad
all: fix lint (#5770)
* fixed lint warnings

* remove unused arg for subchannel
2019-05-23 01:05:22 -07:00
Kun Zhang 7934594dfe
api: pass Subchannel state updates to SubchannelStateListener rather than LoadBalancer (take 2) (#5722)
This is a revised version of #5503 (62b03fd), which was rolled back in f8d0868. The newer version passes SubchannelStateListener to Subchannel.start() instead of SubchannelCreationArgs, which allows us to remove the Subchannel argument from the listener, which works as a solution for #5676.

LoadBalancers that call the old createSubchannel() will get start() implicitly called with a listener that passes updates to the deprecated LoadBalancer.handleSubchannelState(). Those who call the new createSubchannel() will have to call start() explicitly.

GRPCLB code is still using the old API, because it's a pain to migrate the SubchannelPool to the new API.  Since CachedSubchannelHelper is on the way, it's easier to switch to it when it's ready. Keeping
GRPCLB with the old API would also confirm the backward compatibility.
2019-05-17 16:37:41 -07:00
Kun Zhang f8d0868e1d
Revert "core: pass Subchannel state updates to SubchannelStateListener rather than LoadBalancer (#5503)" (#5684)
This reverts commit 62b03fd7e6.

Effectively reverts its follow-up commits:
dc218b6d4d
405d8c3865
44840fe813
2019-05-08 09:01:45 -07:00
Carl Mastrangelo 04e07034f3
all: update to truth 0.44 2019-04-23 10:50:49 -07:00
Carl Mastrangelo a395eec4a3
core: update LB and NR API names
Updates #1770
2019-04-17 12:45:29 -07:00
Eric Anderson 80c3c992a6 core: Move io.grpc to grpc-api
io.grpc has fewer dependencies than io.grpc.internal. Moving it to a
separate artifact lets users use the API without bringing in the deps.
If the library has an optional dependency on grpc, that can be quite
convenient.

We now version-pin both grpc-api and grpc-core, since both contain
internal APIs.

I had to change a few tests in grpc-api to avoid FakeClock. Moving
FakeClock to grpc-api was difficult because it uses
io.grpc.internal.TimeProvider, which can't be moved since it is a
production class. Having grpc-api's tests depend on grpc-core's test
classes would be weird and cause a circular dependincy. Having
grpc-api's tests depend on grpc-core is likely possible, but weird and
fairly unnecessary at this point. So instead I rewrote the tests to
avoid FakeClock.

Fixes #1447
2019-04-16 21:45:40 -07:00
Kun Zhang 62b03fd7e6
core: pass Subchannel state updates to SubchannelStateListener rather than LoadBalancer (#5503)
Resolves #5497

## Motivation

In hierarchical `LoadBalancer`s (e.g., `XdsLoadBalancer`) or wrapped `LoadBalancer`s (e.g., `HealthCheckingLoadBalancerFactory`, the top-level `LoadBalancer` receives `Subchannel` state updates from the Channel impl, and they almost always pass it down to its children `LoadBalancer`s.

Sometimes the children `LoadBalancer`s are not directly created by the parent, thus requires whatever API in the middle to also pass Subchannel state updates, complicating that API. For example, the proposed [`RequestDirector`](https://github.com/grpc/grpc-java/issues/5496#issuecomment-476008051) includes `handleSubchannelState()` solely to plumb state updates to where they are used. We also see this pattern in `HealthCheckingLoadBalancerFactory`, `GrpclbState` and `SubchannelPool`.

Another minor issue is, the parent `LoadBalancer` would need to intercept the `Helper` passed to its children to map Subchannels to the children `LoadBalancer`s, so that it pass updates about relevant Subchannels to the children.  Otherwise, a child `LoadBalancer` may be surprised by seeing Subchannel not created by it, and it's not efficient to broadcast Subchannel updates to all children.

## API Proposal
We will pass a `SubchannelStateListener` when creating a `Subchannel` to accept state updates, those updates could be directly passed to where the `Subchannel` is created, skipping the explicit chaining in the middle.

Also define a first-class object `CreateSubchannelArgs` to pass arguments for the reasons below:
1. It may avoid breakages when we add new arguments to `createSubchannel()`.  For example, a `LoadBalancer` may wrap `Helper` and intercept `createSubchannel()` in a hierarchical case. It may not be interested in all arguments. Passing a single `CreateSubchannelArgs` will not break the parent `LoadBalancer` if we add new fields later.
2. This also reduces the eventual size of Helper interface, as the convenience `createSubchannel()` that accepts one EAG instead of a List is no longer necessary, since that convenience is moved into `CreateSubchannelArgs`.

```java
interface SubchannelStateListener {
  void onSubchannelState(Subchannel subchannel, ConnectivityStateInfo newState);
}

abstract class LoadBalancer.Helper {
  abstract Subchannel createSubchannel(CreateSubchannelArgs args);
}

final class CreateSubchannelArgs {
  final List<EquivalentAddressGroup> getAddresses();
  final Attributes getAttributes();
  final SubchannelStateListener getStateListener();
  final class Builder () {
    ...
  }
}
```

The new `createSubchannel()` must be called from synchronization context, as a step towards #5015.

## How the new API helps

Most hierarchical `LoadBalancer`s would just let the listener from the child `LoadBalancer`s directly pass through to gRPC core, which is less boilerplate than before.

Without any effort by the parent, each child will only see updates for the Subchannels it has created, which is clearer and more efficient.

If a parent `LoadBalancer` does want to look at or alter the Subchannel state updates for its delegate (like in `HealthCheckingLoadBalancerFactory`), it can still do so in the wrapping `LoadBalancer.Helper` passed to the delegate by intercepting the `SubchannelStateListener`.

## Migration implications
Existing `LoadBalancer` implementations will continue to work, while they will see deprecation warnings when compiled:
 - The old `LoadBalancer.Helper#createSubchannel` variants are now deprecated, but will work until they are deleted. They create a `SubchannelStateListener` that delegates to `LoadBalancer#handleSubchannelState`.
 - `LoadBalancer#handleSubchannelState` is now deprecated, and will throw if called and the implementation doesn't override it. It will be deleted in a future release.

The migration for most `LoadBalancer` implementation would be moving the logic from `LoadBalancer#handleSubchannelState` into a `SubchannelStateListener`.
2019-04-12 10:58:09 -07:00
Kun Zhang 0244418d2d
core: Move ConfigOrError up level up. (#5578)
This class is used in other places than just NameResolver.Helper.  It
should not be an inner class of Helper.

Strictly speaking this is an API-breaking change.  However, this is
part of the service config error handling API that hasn't been done
yet.  Nobody has a legitimate reason to use it.
2019-04-10 16:28:23 -07:00
Eric Anderson bcb4515832 services: Remove dependency on re2j
re2j is a fairly unnecessary dependency. Our usage of Pattern is quite limited
and isn't all that hard to do manually. Our usage would be safe to use normal
java.util.regex, but it's sort of annoying to keep re-explaining to others who
are (rightly) concerned with java.util.regex's poor pathological behavior.
2019-04-09 15:19:46 -07:00
Eric Anderson 52dff83717 Update Protobuf to 3.7.1
This mainly avoids protoc from 3.7.0 which has a dependency on libatomic. Most
of our systems have libatomic, so it mostly works, but the interop docker
container does not, so building fails. Version 3.7.1 was rebuilt to avoid
needing the libatomic shared library.

This has the added benefit that Bazel is now on the same version as Gradle, as
3.7.1 included fixes for Bazel.
2019-04-05 10:55:14 -07:00
Carl Mastrangelo 17d67f17fa
all: add LoadBalancer overload for Resolution results 2019-03-29 09:31:24 -07:00
Carl Mastrangelo 5ef8377efa
core: remove Type from ConfigOrError 2019-03-28 09:40:50 -07:00
Chengyuan Zhang 43d38cfa03
services/grpclb: use Stopwatch to provide elapsed time for backoffs (#5491)
* grpclb: use a stopwatch to manage elapased time for LB backoff

* reformatt lines

* create a new Stopwatch for each single newly created HC stream

* use existing stopwatch supplier provided by FakeClock in tests
2019-03-25 10:40:58 -07:00
Tim van der Lippe d35fbd7eee all: Update to Mockito 2
This is the public port of cl/238445847

Fixes #5319
2019-03-19 14:17:52 -07:00
Carl Mastrangelo c6b505229c
all: move LB parsing logic into LB.Factory 2019-03-19 13:33:13 -07:00
Derek Perez e0477bb6e6 bazel: Bazel services + grpc_proto dependency 2019-03-15 11:43:13 -07:00
Eric Anderson d7e53e871b
Merge pull request #5454 from ejona86/protobuf-3.7.0
Upgrade to Protobuf 3.7.0
2019-03-11 15:39:50 -06:00
Carl Mastrangelo e5e01b5169
core,grpclb: use better generics on service config 2019-03-08 14:11:13 -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
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
Eric Anderson eaca73473c
Upgrade to protobuf 3.6.1
For Bazel, we upgrade to protobuf 3.6.1.2 and javalite HEAD to fix
incompatibilities in newer Bazel releases.

compiler/Dockerfile is unused, so it was removed instead of being updated.

protoc no longer includes codegen for nano, so we remain on the older protoc
any time nano is used.

Protobuf now requires C++11 when compiling, so windows was swapped to
VC 14.
2019-02-07 13:40:53 -08:00
Carl Mastrangelo 3a39b81cf5
all: remove java6 type args 2019-02-04 10:03:50 -08:00
Tim van der Lippe a31473ef20 all: fix usages of any(<Primitive>.class) matchers
In Mockito 2, if a method expects a primitive type, but an any(<Primitive>.class) matcher is used in its place, it will throw an error. To prepare for this upcoming breakage, change
all existing any(<Primitive>.class) matchers to use the correct any<Primitive>() matcher.
2019-02-04 09:01:00 -08:00
Carl Mastrangelo ed0a9f3f1d
netty: support listening on multiple ports 2019-01-29 10:13:40 -08:00
Carl Mastrangelo 32fc0bcd38
services: set the default serving state of all services to SERVING 2019-01-24 15:19:51 -08:00