From b979d702f9847894457cc3ddc6fe57d4e9c11f12 Mon Sep 17 00:00:00 2001 From: Larry Safran Date: Thu, 7 Nov 2024 16:54:05 -0800 Subject: [PATCH] Eliminate doFallbackForAuthority since it became a simple call to manageControlPlaneClient --- .../io/grpc/xds/client/XdsClientImpl.java | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java b/xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java index f2bfd8c2e01..a27f8d10041 100644 --- a/xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java +++ b/xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java @@ -311,11 +311,13 @@ private 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, @@ -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 subscriber) { - List 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; @@ -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