Skip to content

Commit

Permalink
Eliminate doFallbackForAuthority since it became a simple call to man…
Browse files Browse the repository at this point in the history
…ageControlPlaneClient
  • Loading branch information
larry-safran committed Nov 8, 2024
1 parent 5c6b524 commit b979d70
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,13 @@ private <T extends ResourceUpdate> CpcWithFallbackState manageControlPlaneClient
}

ControlPlaneClient activeCpClient = getActiveCpc(subscriber.authority);
if (cpcToUse != activeCpClient && activeCpClient != null) {
didFallback = fallBackToCpc(cpcToUse, subscriber.authority, activeCpClient);
}
if (cpcToUse != activeCpClient) {
if (activeCpClient != null) {
didFallback = fallBackToCpc(cpcToUse, subscriber.authority, activeCpClient);
}

addCpcToAuthority(subscriber.authority, cpcToUse); // makes it active
addCpcToAuthority(subscriber.authority, cpcToUse); // makes it active
}
cpcToUse.adjustResourceSubscription(subscriber.type);
} else {
logger.log(XdsLogLevel.WARNING,
Expand Down Expand Up @@ -658,20 +660,6 @@ private void shutdownLowerPriorityCpcs(ControlPlaneClient activatedCpc) {
}
}

/**
* Try to fallback to a lower priority control plane client.
*
* @return true if a fallback was successful, false otherwise.
*/
private boolean doFallbackForAuthority(ResourceSubscriber<? extends ResourceUpdate> subscriber) {
List<ServerInfo> serverInfos = getServerInfos(subscriber.authority);
if (serverInfos == null || serverInfos.size() < 2) {
return false;
}

return manageControlPlaneClient(subscriber).didFallback;
}

private boolean fallBackToCpc(ControlPlaneClient fallbackCpc, String authority,
ControlPlaneClient oldCpc) {
boolean didFallback = false;
Expand Down Expand Up @@ -1015,7 +1003,7 @@ public void handleStreamClosed(Status status, boolean inRetry) {
}

// try to fallback to lower priority control plane client
if (checkForFallback && doFallbackForAuthority(subscriber)) {
if (checkForFallback && manageControlPlaneClient(subscriber).didFallback) {
authoritiesForClosedCpc.remove(subscriber.authority);
if (authoritiesForClosedCpc.isEmpty()) {
return; // optimization: no need to continue once all authorities have done fallback
Expand Down

0 comments on commit b979d70

Please sign in to comment.