rawlinp commented on a change in pull request #4724:
URL: https://github.com/apache/trafficcontrol/pull/4724#discussion_r442518777



##########
File path: 
traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/config/ConfigHandler.java
##########
@@ -491,21 +491,36 @@ private void parseTopologyConfig(final JsonNode 
allTopologies, final Map<String,
 
                deliveryServiceMap.forEach((xmlId, ds) -> {
                        final List<DeliveryServiceReference> dsReferences = new 
ArrayList<>();
+                       final List<String> dsNames = new ArrayList<>(); // for 
stats
                        Stream.of(ds.getTopology())
-                                       .filter((topologyName) -> 
!Objects.isNull(topologyName) && topologyMap.containsKey(topologyName))
-                                       .flatMap((topologyName) -> 
topologyMap.get(topologyName).stream())
-                                       .flatMap((node) -> 
cacheRegister.getCacheLocation(node).getCaches().stream())
-                                       .filter((cache) -> 
ds.hasRequiredCapabilities(cache.getCapabilities()))
-                                       .forEach((cache) -> {
+                                       .filter(topologyName -> 
!Objects.isNull(topologyName) && topologyMap.containsKey(topologyName))
+                                       .flatMap(topologyName -> {
+                                               statMap.put(ds.getId(), 
dsNames);
+                                               return 
topologyMap.get(topologyName).stream();
+                                       })
+                                       .flatMap(node -> 
cacheRegister.getCacheLocation(node).getCaches().stream())
+                                       .filter(cache -> 
ds.hasRequiredCapabilities(cache.getCapabilities()))
+                                       .forEach(cache -> {
+                                           
cacheRegister.getDeliveryServiceMatchers(ds).stream()
+                                                               
.flatMap(deliveryServiceMatcher -> 
deliveryServiceMatcher.getRequestMatchers().stream())
+                                                               
.map(requestMatcher -> requestMatcher.getPattern().pattern())
+                                                               
.forEach(pattern -> {
+                                                                       final 
String remap = ds.getRemap(pattern);
+                                                                       final 
String fqdn = pattern.contains(".*") && !ds.isDns()
+                                                                               
        ? cache.getId() + "." + remap
+                                                                               
        : remap;
+                                                                       
dsNames.add(getDsName(fqdn, tld));
+                                                                       try {
+                                                                               
dsReferences.add(new DeliveryServiceReference(ds.getId(), fqdn));

Review comment:
       This seems to be a little bit different from the legacy 
(deliveryservice-server) behavior in `parseCacheConfig`. That legacy behavior 
seemed to only add the "standard" `routingName.xmlId.cdnDomain` FQDN for DNS 
deliveryservices or the `hostName.xmlId.cdnDomain` FQDN for HTTP 
deliveryservices into `dsReferences` -- not the "alias" FQDNs. That is because 
the first server-deliveryService reference is never the "alias" FQDN. As far as 
I can tell, it is only the `statTracker` that seems to need the "alias" FQDNs.
   
   Basically, if a cache "cache01" belongs to a topology that has the given 
delivery services assigned:
   ```
   xml_id = foo, routing_name = foo, routing_type = HTTP, 0th pattern = 
.*\.foo\..*
   xml_id = bar, routing_name = bar, routing_type = DNS, 0th pattern = 
.*\.bar\..*
   ```
   I would expect only the following FQDNs to be added to the cache's 
`DeliveryServiceReferences`:
   ```
   cache01.foo.cdn.example.com
   bar.bar.cdn.example.com
   ```
   The aliases, if the delivery services have any, would *not* be added to the 
cache's `DeliveryServiceReferences`, but would only be added to the `dsNames` 
in the `statMap` (in addition to the aforementioned "standard" FQDNs).




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to