@@ -567,7 +567,6 @@ private interface RdsUpdateSupplier {
567
567
568
568
private class LdsWatcher extends XdsWatcherBase <XdsListenerResource .LdsUpdate >
569
569
implements RdsUpdateSupplier {
570
- String rdsName ;
571
570
572
571
private LdsWatcher (String resourceName ) {
573
572
super (XdsListenerResource .getInstance (), resourceName );
@@ -582,43 +581,36 @@ public void onChanged(XdsListenerResource.LdsUpdate update) {
582
581
583
582
HttpConnectionManager httpConnectionManager = update .httpConnectionManager ();
584
583
List <VirtualHost > virtualHosts ;
585
- String rdsName ;
586
584
if (httpConnectionManager == null ) {
587
585
// TCP listener. Unsupported config
588
586
virtualHosts = Collections .emptyList (); // Not null, to not delegate to RDS
589
- rdsName = null ;
590
587
} else {
591
588
virtualHosts = httpConnectionManager .virtualHosts ();
592
- rdsName = httpConnectionManager .rdsName ();
593
589
}
594
-
595
590
if (virtualHosts != null ) {
596
- // No RDS watcher since we are getting RDS updates via LDS
597
591
updateRoutes (virtualHosts );
598
- this .rdsName = null ;
599
- } else {
600
- this .rdsName = rdsName ;
592
+ }
593
+
594
+ String rdsName = getRdsName (update );
595
+ if (rdsName != null ) {
601
596
addRdsWatcher (rdsName );
602
597
}
603
598
604
599
setData (update );
605
600
maybePublishConfig ();
606
601
}
607
602
608
- @ Override
609
- public void onResourceDoesNotExist (String resourceName ) {
610
- if (cancelled ) {
611
- return ;
603
+ private String getRdsName (XdsListenerResource .LdsUpdate update ) {
604
+ HttpConnectionManager httpConnectionManager = update .httpConnectionManager ();
605
+ if (httpConnectionManager == null ) {
606
+ // TCP listener. Unsupported config
607
+ return null ;
612
608
}
613
-
614
- checkArgument (resourceName ().equals (resourceName ), "Resource name does not match" );
615
- setDataAsStatus (Status .UNAVAILABLE .withDescription (
616
- toContextString () + " does not exist" + nodeInfo ()));
617
- rdsName = null ;
618
- maybePublishConfig ();
609
+ return httpConnectionManager .rdsName ();
619
610
}
620
611
621
- private RdsWatcher getRdsWatcher (WatcherTracer tracer ) {
612
+ private RdsWatcher getRdsWatcher (XdsListenerResource .LdsUpdate update , WatcherTracer tracer ) {
613
+ String rdsName = getRdsName (update );
622
614
if (rdsName == null ) {
623
615
return null ;
624
616
}
@@ -637,7 +629,7 @@ public RdsUpdateSupplier getRouteSource(WatcherTracer tracer) {
637
629
if (virtualHosts != null ) {
638
630
return this ;
639
631
}
640
- RdsWatcher rdsWatcher = getRdsWatcher (tracer );
632
+ RdsWatcher rdsWatcher = getRdsWatcher (getData (). getValue (), tracer );
641
633
assert rdsWatcher != null ;
642
634
return rdsWatcher ;
643
635
}
0 commit comments