-
Notifications
You must be signed in to change notification settings - Fork 106
Conversation
Codecov Report
@@ Coverage Diff @@
## master #494 +/- ##
============================================
- Coverage 70.5% 70.43% -0.07%
- Complexity 810 813 +3
============================================
Files 165 165
Lines 3773 3781 +8
Branches 289 293 +4
============================================
+ Hits 2660 2663 +3
- Misses 990 992 +2
- Partials 123 126 +3
Continue to review full report at Codecov.
|
Whoa, that was fast! |
ManagedChannel getChannel(int affinity) { | ||
int index = affinity % channels.size(); | ||
index = Math.abs(index); | ||
// If index is the most negative int, abs(index) is still negative. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* reverse is not true: Two calls with different affinities might return the same channel. | ||
* However, the implementation should attempt to spread load evenly. | ||
*/ | ||
ManagedChannel getChannel(int affinity) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -63,26 +63,29 @@ | |||
private final CallOptions callOptions; | |||
@Nullable private final Duration streamWaitTimeout; | |||
@Nullable private final Duration streamIdleTimeout; | |||
@Nullable private final Integer channelAffinity; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -57,6 +58,11 @@ | |||
CallOptions callOptions = grpcContext.getCallOptions(); | |||
Preconditions.checkNotNull(callOptions); | |||
|
|||
return grpcContext.getChannel().newCall(descriptor, callOptions); | |||
Channel channel = grpcContext.getChannel(); | |||
if (grpcContext.getChannelAffinity() != null && channel instanceof ChannelPool) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ManagedChannel getChannel(int affinity) { | ||
int index = affinity % channels.size(); | ||
index = Math.abs(index); | ||
// If index is the most negative int, abs(index) is still negative. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -57,6 +58,11 @@ | |||
CallOptions callOptions = grpcContext.getCallOptions(); | |||
Preconditions.checkNotNull(callOptions); | |||
|
|||
return grpcContext.getChannel().newCall(descriptor, callOptions); | |||
Channel channel = grpcContext.getChannel(); | |||
if (grpcContext.getChannelAffinity() != null && channel instanceof ChannelPool) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@vam-google Thank you for the review! |
Updates googleapis/google-cloud-java#3022.
cc @igorbernstein2 @hzyi-google