xds: Delegate more RingHashLB address updates to MultiChildLB · grpc/grpc-java@fd8734f

File tree

2 files changed

lines changed

  • util/src/main/java/io/grpc/util

  • xds/src/main/java/io/grpc/xds

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -231,7 +231,7 @@ protected final AcceptResolvedAddrRetVal acceptResolvedAddressesInternal(

231231

return new AcceptResolvedAddrRetVal(Status.OK, getRemovedChildren(newChildren.keySet()));

232232

}

233233
234-

protected final void addMissingChildren(Map<Object, ChildLbState> newChildren) {

234+

private void addMissingChildren(Map<Object, ChildLbState> newChildren) {

235235

// Do adds and identify reused children

236236

for (Map.Entry<Object, ChildLbState> entry : newChildren.entrySet()) {

237237

final Object key = entry.getKey();

@@ -241,7 +241,7 @@ protected final void addMissingChildren(Map<Object, ChildLbState> newChildren) {

241241

}

242242

}

243243
244-

protected final void updateChildrenWithResolvedAddresses(ResolvedAddresses resolvedAddresses,

244+

private void updateChildrenWithResolvedAddresses(ResolvedAddresses resolvedAddresses,

245245

Map<Object, ChildLbState> newChildren) {

246246

for (Map.Entry<Object, ChildLbState> entry : newChildren.entrySet()) {

247247

Object childConfig = entry.getValue().getConfig();

@@ -256,7 +256,7 @@ protected final void updateChildrenWithResolvedAddresses(ResolvedAddresses resol

256256

/**

257257

* Identifies which children have been removed (are not part of the newChildKeys).

258258

*/

259-

protected final List<ChildLbState> getRemovedChildren(Set<Object> newChildKeys) {

259+

private List<ChildLbState> getRemovedChildren(Set<Object> newChildKeys) {

260260

List<ChildLbState> removedChildren = new ArrayList<>();

261261

// Do removals

262262

for (Object key : ImmutableList.copyOf(childLbStates.keySet())) {

Original file line numberDiff line numberDiff line change

@@ -89,19 +89,11 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {

8989
9090

try {

9191

resolvingAddresses = true;

92-

// Subclass handles any special manipulation to create appropriate types of ChildLbStates

93-

Map<Object, ChildLbState> newChildren = createChildLbMap(resolvedAddresses);

94-
95-

if (newChildren.isEmpty()) {

96-

addressValidityStatus = Status.UNAVAILABLE.withDescription(

97-

"Ring hash lb error: EDS resolution was successful, but there were no valid addresses");

98-

handleNameResolutionError(addressValidityStatus);

99-

return addressValidityStatus;

92+

AcceptResolvedAddrRetVal acceptRetVal = acceptResolvedAddressesInternal(resolvedAddresses);

93+

if (!acceptRetVal.status.isOk()) {

94+

return acceptRetVal.status;

10095

}

10196
102-

addMissingChildren(newChildren);

103-

updateChildrenWithResolvedAddresses(resolvedAddresses, newChildren);

104-
10597

// Now do the ringhash specific logic with weights and building the ring

10698

RingHashConfig config = (RingHashConfig) resolvedAddresses.getLoadBalancingPolicyConfig();

10799

if (config == null) {

@@ -145,7 +137,7 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {

145137

// clusters and resolver can remove them in service config.

146138

updateOverallBalancingState();

147139
148-

shutdownRemoved(getRemovedChildren(newChildren.keySet()));

140+

shutdownRemoved(acceptRetVal.removedChildren);

149141

} finally {

150142

this.resolvingAddresses = false;

151143

}