Commit Graph

108 Commits

Author SHA1 Message Date
Eric Anderson ba8063e7b0 all: Prefer mock+delegatesTo() over Mockito.spy()
Spies are really magical and easily produce unexpected results. Using them in
tests can easily yield tests that don't do what you think they do. Delegation
is much safer when possible.

Delegation doesn't work when methods `return true`, final methods, and with
restricted visibility, though. So CensusModulesTest and
MaxConnectionIdleManagerTest are left as-is.
2018-01-11 09:32:54 -08:00
Carl Mastrangelo 6eaae5d081
core/grpclb: resolve TXT records in DNS name resolver and include balancer addresses 2017-12-19 10:01:53 -08:00
zpencer 173ca5d332
cronet, grpc-lb, interop-testing: fix lints #3848 2017-12-07 16:09:43 -08:00
Carl Mastrangelo c9b02db276
all: add Status messages to all statuses 2017-12-04 19:00:16 -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
Carl Mastrangelo aee5fc4176
all: update to proto 3.5.0 2017-11-30 11:50:19 -08:00
Kun Zhang 9239984a8a
grpclb: switch to fallback mode if all connections are lost (#3744)
Previously fallback mode can be entered only if the client has not
received any server list and the fallback timeout has expired.

Now the fallback timer is started when the stream to the balancer is broken
AND there is no ready Subchannels. Fallback mode is activated when the
timer expires. When a new server list is received from the balancer, either
the fallback timer is cancelled, or fallback mode is exited.

Also fixed a bug that the fallback timer should've been cancelled when GrpcState
is shut down.
2017-11-29 10:50:09 -08: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
Carl Mastrangelo 87c8791983
compiler: remove references to static fields 2017-10-31 15:24:48 -07:00
Carl Mastrangelo 30b59885b7
compiler: add methods for accessing method descriptors
* MethodDescriptor is lazy loaded, so protobuf loading only happens on demand.  This also means tracing registration happens  on demand.
* The names of the getters all being with `method`.  This makes it harder for autocomplete to pick them up.
* A new field is used, which matches the getter name.  Rather than make the new-getters reference the old-fields, make the old-fields reference the new getters.  This makes removal of the old-fields a simple operation.
* The getters may not be inlineable, but thats an easy fix if it ends up being a problem.  Not worth premature optimization (but is worth future work).

The expected timeline for this is adding this to the 1.8 cut, and deprecating the old-fields.  They will be removed in 1.9.
2017-10-30 10:30:34 -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
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
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
Kun Zhang df92533524 grpclb: fallback to backend addresses (#3439)
The GRPCLB client will use the backend addresses from resolver if it has not received any server list from any balancer after a certain timeout (10s).
2017-09-12 12:25:08 -07:00
Lukasz Strzalkowski 731bbefb17 core, compiler, protobuf: introduce MethodDescriptor#setSchemaDescriptor 2017-09-11 09:57:03 -07:00
Carl Mastrangelo 24ff2748b7 all: update to proto 3.4.0 2017-08-25 11:25:36 -07:00
Kun Zhang 485431880f grpclb: remove expiration_interval. (#3398) 2017-08-25 10:49:46 -07:00
Eric Anderson 182164eafc compiler: Add option to disable version output
If the option becomes popular, we can just remove the version.
2017-08-23 12:37:40 -07:00
Kun Zhang ab65c797bf grpclb: refactor main GRPCLB logic out of GrpclbLoadBalancer. (#3369)
GrpclbLoadBalancer can work in non-GRPCLB (delegate) mode according to
name resolution results.  Previously the policy selection, delegation
and GRPCLB logic are in the same file, which is not very readable.  It
will get worse as we going to implement policy fallback logic soon.
This PR refactors the GRPCLB logic out, and makes GrpclbLoadBalancer
focus on the policy selection and delegation logic.
2017-08-23 11:24:56 -07:00
zpencer ab85c5ae76 Start 1.7.0 development cycle (#3357)
This bump changelist is applied a bit late with respect to the
1.6.0 branch cut. Look at the 1.6.0 to see the source of truth of
where it was cut. Do not assume it is the commit that precedes
this one.
2017-08-22 12:29:03 -07:00
Kun Zhang 8634632019 grpclb: use two-level drop behavior (#3343)
Previously, the round-robin list that the client uses (effective
round-robin list, ERRL) was the received round-robin list (RRRL)
excluding non-READY backends.  Drop and backend entries are in the
same list.

The problem with it is that when not all backends are READY, drop
entries take a larger proportion in ERRL than they do in the RRRL,
resulting a larger drop ratio than intended.

To fix this, we employ a two-list scheme:

- A "drop list" (DL) that is out of the RRRL, with the same size and
  the same number of drop entries.

- A "backend list" (BL) that contains only the backend entries from
  the RRRL, excluding non-READY ones.

For every pick, the client would round-robin on the DL to determine
whether the pick should be dropped.  Only when it's not dropped,
round-robin on the BL to pick the actual backend.

This way, the drop ratio is always equal to the proportion they take
in the RRRL.
2017-08-16 16:03:22 -07:00
myPrecious 13ef2261d6 core: Use bulk operation instead of iteration 2017-08-11 15:42:14 -07:00
ZHANG Dapeng 65ea0bde5d core,grpclb: deprecate LoadBalancer.Helper.updatePicker() 2017-08-10 17:05:54 -07:00
Kun Zhang c8216e45f2 grpclb: update load_balancer.proto to the latest version. (#3329)
Combined drop for rate limiting and drop for load balancing, broken down by token.
2017-08-10 14:53:51 -07:00
ZHANG Dapeng 71353c8f65 grpclb: implement Channel State API for GRPCLB 2017-08-09 18:01:03 -07:00
Kun Zhang f54a2df67f grpclb: force GRPCLB policy when NameResolver returns at least one balancer. (#3291)
Previously only when all addresses returned by NameResolver are
balancers would GRPCLB be forced.  This change is a follow-up of
https://github.com/grpc/grpc/pull/10258
2017-07-31 11:07:11 -07:00
Kun Zhang 04e0450304 core: pass CallOptions to newClientStreamTracer(). (#3276)
Resolves #3256
2017-07-27 12:07:25 -07:00
Carl Mastrangelo 424eeea8f5 all: begin 1.6 release cycle 2017-07-06 10:43:56 -07:00
Carl Mastrangelo 166108a943 all: fix licence whitespace 2017-06-01 14:28:37 -07:00
Carl Mastrangelo 3bfd630bff all: update to Apache 2 licence
Also, update the authors.
2017-05-31 13:29:01 -07:00
Carl Mastrangelo 4ce52d10f6 all: bump to 1.5.0-SNAPSHOT 2017-05-23 17:57:25 -07:00
Carl Mastrangelo 0fe2c5cca6 all: bump to proto 3.3.1 2017-05-23 17:04:51 -07:00
Eric Anderson a343e99252 grpclb: Avoid reference equality for protobuf in oneof
The equivalent of the has* methods for oneofs is to check which Case()
is used. Reworked the code a bit because it seemed obvious that it
wasn't checking all the cases it should, and is probably more natural
now that the code uses Case().
2017-05-15 15:39:49 -07:00
Eric Anderson cf0e161bd6 Remove unused variables
The removal of the poll()s is a behavior change, but the tests weren't
needing to call it.
2017-05-15 15:39:49 -07:00
Eric Anderson f4173c34ad core,grpclb: Update addresses in OobChannel
This allows avoiding re-creating connections unnecessarily. For
NameResolvers that support notifications this avoids stampeding herds
when possible, since all clients may receive the notification at
approximately the same time.
2017-05-09 12:35:00 -07:00
Eric Gribkoff 7aa807ce6d compiler: remove streaming calls from javadoc for newFutureStub
FutureStubs only support unary calls
2017-05-02 10:24:23 -07:00
Kun Zhang 0d6b4184d1 Implement GRPCLB client-side load reporting (#2941)
Also updated load_balancing.proto to the latest version.
2017-04-27 11:28:28 -07:00
Eric Anderson dcc3902eb4 grpclb: remove non-determinism workaround
Issue #2444 is resolved.
2017-04-26 13:35:22 -07:00
Kun Zhang c1a2fb412a grpclb: expose the token metadata key. (#2944)
It is accessed by the server-side load-reporting code which is from a
different package.
2017-04-25 15:17:26 -07:00
Eric Anderson 10dd34b0c0 grpclb: Flatten LB addresses to use pick-first
This has the limitation that all LB addresses must have the same
authority. Future work will try to remove that limitation.
2017-04-20 15:53:25 -07:00
Łukasz Strzałkowski 4f96b0a483 compiler: move over to method descriptor builder 2017-04-12 08:56:46 -07:00
Carl Mastrangelo 17b90169d8 all: begin 1.4.x development cycle 2017-04-11 14:51:39 -07:00
Kun Zhang 123bb315e9 grpclb: skip picker updates that have no effect (#2876)
Each time helper.updatePicker() is called, the Channel will re-process
all pending streams with the new picker.  If the old picker is
equivalent to the old one, it's wasteful.

This is also needed to make our internal integration test easier.
Because the load-balancer may send address list that is identical to the
previous one, just to update the TTL.  Without this change, new picker
replaces the old picker even if they carry the same list, which
effectively resets the round-robin pointer.  This causes a little
imbalance between test backends, resulting in test failure.
2017-04-05 09:43:05 -07:00
Kun Zhang 418d52d16d core: unify EquivalentAddressGroup and its immitators. (#2755)
Resolves #2716

- Add attributes to EquivalentAddressGroup
- Deprecate ResolvedServerInfoGroup by EquivalentAddressGroup
- Deprecate ResolvedServerInfo, because attributes for a single address
  with an address group is not found to be useful.
- The changes on the NameResolver and LoadBalancer interfaces are backward-compatible
  in the next release, with which implementors can switch to the new API smoothly.

As a related change, redefine the semantics of DnsNameResolver and
RoundRobinLoadBalancer:

- Before: DnsNameResolver returns all addresses in one address group.
  RoundRobinLoadBalancer ignores the grouping of addresses and
  round-robin on every single addresses.  It doesn't work well with the
  one-server-multiple-address setup, e.g., both IPv4 and IPv6 addresses
  are returned for a single serve, even if they are put in the same
  address group by the NameResolver.

- After: DnsNameResolver returns every address in its own
  EAG. RoundRobinLoadBalancer takes an EAG as a whole, and only
  round-robin on the list of EAGs. The new behavior is a better
  interpretation of the EAGs, and really allows the case where one
  server has more than one addresses (e.g., IPv4 and IPv6).

This change will affect users that use custom LoadBalancer with the
stock DnsNameResolver, and those who use custom NameResolver with the
stock RoundRobinLoadBalancer.

Users who use both the stock DnsNameResolver and RoundRobinLoadBalancer
or PickFirstBalancer will see no behavioral change. Because they will
still round-robin on individual addresses from DNS, or do pick-first on
all addresses from DNS (PickFirstBalancer flattens all addresses).

The result is a simpler API and reduction of boilderplates.
2017-03-22 18:29:31 -07:00
Kun Zhang 7c3f664e9b grpclb: set LB tokens to headers. (#2812)
The balancer service attaches a token string for each Server entry it
sends to the client.  The client has to set the token to the "lb-token"
header when assigning that Server entry to an RPC.

For convenience of testing, also implemented hashCode() and equals() for
PickResult.
2017-03-10 16:34:33 -08:00
Carl Mastrangelo 7ce2b4f81d all: start 1.3.0 development cycle 2017-03-06 13:12:44 -08:00
Łukasz Strzałkowski 7bb60dc05c core: introduce PickSubchannelArgs (#2740)
This will allow adding new arguments passed to pickSubchannel
without significant API changes in core LB API in the future.

Closes #2737
2017-03-03 12:48:55 -08:00
Kun Zhang 2fab8895dc grpclb: fix a bug in handling server address updates.
It didn't check if the address was already there in the current
subchannel set before creating a new subchannel for it, causing a leak
of subchannels.
2017-03-01 10:47:02 -08:00
Kun Zhang a9bd94781c core: promote LBv2 classes. 2017-02-24 16:48:44 -08:00