mirror of https://github.com/grpc/grpc-java.git
xds: always update priority LB connectivity state (#9527)
Removes the option of skipping the update of the priority LB state when the failover timer is pending. This consistency facilitates a future change weher we delay child LB status updates if the priority LB is performing an update. The upcoming priority LB policy gRFC also does not require this update to ever be skipped.
This commit is contained in:
parent
6bafca93a7
commit
53a2d50695
|
@ -99,9 +99,7 @@ final class PriorityLoadBalancer extends LoadBalancer {
|
||||||
children.get(priority).updateResolvedAddresses();
|
children.get(priority).updateResolvedAddresses();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Not to report connecting in case a pending priority bumps up on top of the current READY
|
tryNextPriority();
|
||||||
// priority.
|
|
||||||
tryNextPriority(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,7 +126,7 @@ final class PriorityLoadBalancer extends LoadBalancer {
|
||||||
children.clear();
|
children.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryNextPriority(boolean reportConnecting) {
|
private void tryNextPriority() {
|
||||||
for (int i = 0; i < priorityNames.size(); i++) {
|
for (int i = 0; i < priorityNames.size(); i++) {
|
||||||
String priority = priorityNames.get(i);
|
String priority = priorityNames.get(i);
|
||||||
if (!children.containsKey(priority)) {
|
if (!children.containsKey(priority)) {
|
||||||
|
@ -153,9 +151,7 @@ final class PriorityLoadBalancer extends LoadBalancer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (child.failOverTimer != null && child.failOverTimer.isPending()) {
|
if (child.failOverTimer != null && child.failOverTimer.isPending()) {
|
||||||
if (reportConnecting) {
|
updateOverallState(priority, child.connectivityState, child.picker);
|
||||||
updateOverallState(priority, CONNECTING, BUFFER_PICKER);
|
|
||||||
}
|
|
||||||
return; // Give priority i time to connect.
|
return; // Give priority i time to connect.
|
||||||
}
|
}
|
||||||
if (priority.equals(currentPriority) && child.connectivityState != TRANSIENT_FAILURE) {
|
if (priority.equals(currentPriority) && child.connectivityState != TRANSIENT_FAILURE) {
|
||||||
|
@ -216,7 +212,7 @@ final class PriorityLoadBalancer extends LoadBalancer {
|
||||||
Status.UNAVAILABLE.withDescription("Connection timeout for priority " + priority));
|
Status.UNAVAILABLE.withDescription("Connection timeout for priority " + priority));
|
||||||
logger.log(XdsLogLevel.DEBUG, "Priority {0} failed over to next", priority);
|
logger.log(XdsLogLevel.DEBUG, "Priority {0} failed over to next", priority);
|
||||||
currentPriority = null; // reset currentPriority to guarantee failover happen
|
currentPriority = null; // reset currentPriority to guarantee failover happen
|
||||||
tryNextPriority(true);
|
tryNextPriority();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +320,7 @@ final class PriorityLoadBalancer extends LoadBalancer {
|
||||||
seenReadyOrIdleSinceTransientFailure = false;
|
seenReadyOrIdleSinceTransientFailure = false;
|
||||||
failOverTimer.cancel();
|
failOverTimer.cancel();
|
||||||
}
|
}
|
||||||
tryNextPriority(true);
|
tryNextPriority();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static io.grpc.ConnectivityState.READY;
|
||||||
import static io.grpc.ConnectivityState.TRANSIENT_FAILURE;
|
import static io.grpc.ConnectivityState.TRANSIENT_FAILURE;
|
||||||
import static io.grpc.xds.XdsSubchannelPickers.BUFFER_PICKER;
|
import static io.grpc.xds.XdsSubchannelPickers.BUFFER_PICKER;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.ArgumentMatchers.isA;
|
||||||
import static org.mockito.Mockito.atLeastOnce;
|
import static org.mockito.Mockito.atLeastOnce;
|
||||||
import static org.mockito.Mockito.clearInvocations;
|
import static org.mockito.Mockito.clearInvocations;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
@ -675,7 +676,7 @@ public class PriorityLoadBalancerTest {
|
||||||
.setAddresses(ImmutableList.<EquivalentAddressGroup>of())
|
.setAddresses(ImmutableList.<EquivalentAddressGroup>of())
|
||||||
.setLoadBalancingPolicyConfig(priorityLbConfig)
|
.setLoadBalancingPolicyConfig(priorityLbConfig)
|
||||||
.build());
|
.build());
|
||||||
verify(helper).updateBalancingState(eq(CONNECTING), eq(BUFFER_PICKER));
|
verify(helper, times(2)).updateBalancingState(eq(CONNECTING), isA(SubchannelPicker.class));
|
||||||
|
|
||||||
// LB shutdown and subchannel state change can happen simultaneously. If shutdown runs first,
|
// LB shutdown and subchannel state change can happen simultaneously. If shutdown runs first,
|
||||||
// any further balancing state update should be ignored.
|
// any further balancing state update should be ignored.
|
||||||
|
|
Loading…
Reference in New Issue