3131import io .grpc .LoadBalancerProvider ;
3232import io .grpc .LoadBalancerRegistry ;
3333import io .grpc .NameResolver .ConfigOrError ;
34+ import io .grpc .Status ;
3435import io .grpc .internal .ObjectPool ;
3536import io .grpc .rls .ChildLoadBalancerHelper .ChildLoadBalancerHelperProvider ;
3637import io .grpc .rls .RlsProtoData .RouteLookupConfig ;
@@ -211,7 +212,7 @@ static final class RefCountedChildPolicyWrapperFactory {
211212 private final ChildLoadBalancerHelperProvider childLbHelperProvider ;
212213 private final ChildLbStatusListener childLbStatusListener ;
213214 private final ChildLoadBalancingPolicy childPolicy ;
214- private final ResolvedAddressFactory childLbResolvedAddressFactory ;
215+ private ResolvedAddressFactory childLbResolvedAddressFactory ;
215216
216217 public RefCountedChildPolicyWrapperFactory (
217218 ChildLoadBalancingPolicy childPolicy ,
@@ -229,6 +230,19 @@ void init() {
229230 childLbHelperProvider .init ();
230231 }
231232
233+ Status acceptResolvedAddressFactory (ResolvedAddressFactory childLbResolvedAddressFactory ) {
234+ this .childLbResolvedAddressFactory = childLbResolvedAddressFactory ;
235+ Status status = Status .OK ;
236+ for (RefCountedChildPolicyWrapper wrapper : childPolicyMap .values ()) {
237+ Status newStatus =
238+ wrapper .childPolicyWrapper .acceptResolvedAddressFactory (childLbResolvedAddressFactory );
239+ if (!newStatus .isOk ()) {
240+ status = newStatus ;
241+ }
242+ }
243+ return status ;
244+ }
245+
232246 ChildPolicyWrapper createOrGet (String target ) {
233247 // TODO(creamsoup) check if the target is valid or not
234248 RefCountedChildPolicyWrapper pooledChildPolicyWrapper = childPolicyMap .get (target );
@@ -277,6 +291,7 @@ static final class ChildPolicyWrapper {
277291 private final String target ;
278292 private final ChildPolicyReportingHelper helper ;
279293 private final LoadBalancer lb ;
294+ private final Object childLbConfig ;
280295 private volatile SubchannelPicker picker ;
281296 private ConnectivityState state ;
282297
@@ -295,21 +310,26 @@ public ChildPolicyWrapper(
295310 .parseLoadBalancingPolicyConfig (
296311 childPolicy .getEffectiveChildPolicy (target ));
297312 this .lb = lbProvider .newLoadBalancer (helper );
313+ this .childLbConfig = lbConfig .getConfig ();
298314 helper .getChannelLogger ().log (
299- ChannelLogLevel .DEBUG , "RLS child lb created. config: {0}" , lbConfig . getConfig () );
315+ ChannelLogLevel .DEBUG , "RLS child lb created. config: {0}" , childLbConfig );
300316 helper .getSynchronizationContext ().execute (
301317 new Runnable () {
302318 @ Override
303319 public void run () {
304- if (!lb .acceptResolvedAddresses (
305- childLbResolvedAddressFactory .create (lbConfig .getConfig ())).isOk ()) {
320+ if (!acceptResolvedAddressFactory (childLbResolvedAddressFactory ).isOk ()) {
306321 helper .refreshNameResolution ();
307322 }
308323 lb .requestConnection ();
309324 }
310325 });
311326 }
312327
328+ Status acceptResolvedAddressFactory (ResolvedAddressFactory childLbResolvedAddressFactory ) {
329+ helper .getSynchronizationContext ().throwIfNotInThisSynchronizationContext ();
330+ return lb .acceptResolvedAddresses (childLbResolvedAddressFactory .create (childLbConfig ));
331+ }
332+
313333 String getTarget () {
314334 return target ;
315335 }
0 commit comments