Skip to content

Commit

Permalink
Cache serializingRetries value so that it doesn't have to look up the…
Browse files Browse the repository at this point in the history
… flag every time.
  • Loading branch information
larry-safran committed Sep 12, 2024
1 parent a7937a8 commit ebf046f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ final class PickFirstLeafLoadBalancer extends LoadBalancer {
private BackoffPolicy reconnectPolicy;
@Nullable
private ScheduledHandle reconnectTask = null;
private boolean serializingRetries = isSerializingRetries();

PickFirstLeafLoadBalancer(Helper helper) {
this.helper = checkNotNull(helper, "helper");
Expand Down Expand Up @@ -332,7 +333,7 @@ void processSubchannelState(SubchannelData subchannelData, ConnectivityStateInfo
* Only called after all addresses attempted and failed (TRANSIENT_FAILURE).
*/
private void scheduleBackoff() {
if (!isSerializingRetries()) {
if (!serializingRetries) {
return;
}

Expand Down Expand Up @@ -464,7 +465,7 @@ public void requestConnection() {
break; // let the already scheduled task do its job

Check warning on line 465 in core/src/main/java/io/grpc/internal/PickFirstLeafLoadBalancer.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/io/grpc/internal/PickFirstLeafLoadBalancer.java#L465

Added line #L465 was not covered by tests
}
addressIndex.increment();
if (!isSerializingRetries()) {
if (!serializingRetries) {
requestConnection();
} else {
if (!addressIndex.isValid()) {
Expand Down Expand Up @@ -540,7 +541,7 @@ private SubchannelData createNewSubchannel(SocketAddress addr, Attributes attrs)
}

private boolean isPassComplete() {
if ((!isSerializingRetries() && addressIndex.isValid())
if ((!serializingRetries && addressIndex.isValid())
|| subchannels.size() < addressIndex.size()) {
return false;
}
Expand Down

0 comments on commit ebf046f

Please sign in to comment.