|
24 | 24 | import static io.grpc.ConnectivityState.TRANSIENT_FAILURE; |
25 | 25 |
|
26 | 26 | import com.google.common.annotations.VisibleForTesting; |
27 | | -import com.google.common.base.MoreObjects; |
28 | 27 | import com.google.common.collect.ImmutableList; |
29 | 28 | import com.google.common.collect.Lists; |
30 | 29 | import io.grpc.Attributes; |
@@ -164,7 +163,7 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) { |
164 | 163 | if (noOldAddrs) { |
165 | 164 | // Make tests happy; they don't properly assume starting in CONNECTING |
166 | 165 | rawConnectivityState = CONNECTING; |
167 | | - updateBalancingState(CONNECTING, new Picker(PickResult.withNoResult())); |
| 166 | + updateBalancingState(CONNECTING, new FixedResultPicker(PickResult.withNoResult())); |
168 | 167 | } |
169 | 168 |
|
170 | 169 | if (rawConnectivityState == READY) { |
@@ -237,7 +236,7 @@ public void handleNameResolutionError(Status error) { |
237 | 236 | subchannels.clear(); |
238 | 237 | addressIndex.updateGroups(ImmutableList.of()); |
239 | 238 | rawConnectivityState = TRANSIENT_FAILURE; |
240 | | - updateBalancingState(TRANSIENT_FAILURE, new Picker(PickResult.withError(error))); |
| 239 | + updateBalancingState(TRANSIENT_FAILURE, new FixedResultPicker(PickResult.withError(error))); |
241 | 240 | } |
242 | 241 |
|
243 | 242 | void processSubchannelState(SubchannelData subchannelData, ConnectivityStateInfo stateInfo) { |
@@ -290,7 +289,7 @@ void processSubchannelState(SubchannelData subchannelData, ConnectivityStateInfo |
290 | 289 |
|
291 | 290 | case CONNECTING: |
292 | 291 | rawConnectivityState = CONNECTING; |
293 | | - updateBalancingState(CONNECTING, new Picker(PickResult.withNoResult())); |
| 292 | + updateBalancingState(CONNECTING, new FixedResultPicker(PickResult.withNoResult())); |
294 | 293 | break; |
295 | 294 |
|
296 | 295 | case READY: |
@@ -322,7 +321,7 @@ void processSubchannelState(SubchannelData subchannelData, ConnectivityStateInfo |
322 | 321 | if (isPassComplete()) { |
323 | 322 | rawConnectivityState = TRANSIENT_FAILURE; |
324 | 323 | updateBalancingState(TRANSIENT_FAILURE, |
325 | | - new Picker(PickResult.withError(stateInfo.getStatus()))); |
| 324 | + new FixedResultPicker(PickResult.withError(stateInfo.getStatus()))); |
326 | 325 |
|
327 | 326 | // Refresh Name Resolution, but only when all 3 conditions are met |
328 | 327 | // * We are at the end of addressIndex |
@@ -385,11 +384,11 @@ private void updateHealthCheckedState(SubchannelData subchannelData) { |
385 | 384 | updateBalancingState(READY, |
386 | 385 | new FixedResultPicker(PickResult.withSubchannel(subchannelData.subchannel))); |
387 | 386 | } else if (subchannelData.getHealthState() == TRANSIENT_FAILURE) { |
388 | | - updateBalancingState(TRANSIENT_FAILURE, new Picker(PickResult.withError( |
| 387 | + updateBalancingState(TRANSIENT_FAILURE, new FixedResultPicker(PickResult.withError( |
389 | 388 | subchannelData.healthStateInfo.getStatus()))); |
390 | 389 | } else if (concludedState != TRANSIENT_FAILURE) { |
391 | 390 | updateBalancingState(subchannelData.getHealthState(), |
392 | | - new Picker(PickResult.withNoResult())); |
| 391 | + new FixedResultPicker(PickResult.withNoResult())); |
393 | 392 | } |
394 | 393 | } |
395 | 394 |
|
@@ -593,28 +592,6 @@ ConnectivityState getConcludedConnectivityState() { |
593 | 592 | return this.concludedState; |
594 | 593 | } |
595 | 594 |
|
596 | | - /** |
597 | | - * No-op picker which doesn't add any custom picking logic. It just passes already known result |
598 | | - * received in constructor. |
599 | | - */ |
600 | | - private static final class Picker extends SubchannelPicker { |
601 | | - private final PickResult result; |
602 | | - |
603 | | - Picker(PickResult result) { |
604 | | - this.result = checkNotNull(result, "result"); |
605 | | - } |
606 | | - |
607 | | - @Override |
608 | | - public PickResult pickSubchannel(PickSubchannelArgs args) { |
609 | | - return result; |
610 | | - } |
611 | | - |
612 | | - @Override |
613 | | - public String toString() { |
614 | | - return MoreObjects.toStringHelper(Picker.class).add("result", result).toString(); |
615 | | - } |
616 | | - } |
617 | | - |
618 | 595 | /** |
619 | 596 | * Picker that requests connection during the first pick, and returns noResult. |
620 | 597 | */ |
|
0 commit comments