rawlinp commented on a change in pull request #2785: In Traffic Router Support 
Snapshots which only update Delivery Services
URL: https://github.com/apache/trafficcontrol/pull/2785#discussion_r237241309
 
 

 ##########
 File path: 
traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/config/ConfigHandler.java
 ##########
 @@ -320,16 +408,100 @@ private void parseTrafficOpsConfig(final JsonNode 
config, final JsonNode stats)
        /**
         * Parses the cache information from the configuration and updates the 
{@link CacheRegister}.
         *
-        * @param trConfig
-        *            the {@link TrafficRouterConfiguration}
+        * @param snap the {@link SnapshotEventsProcessor}
+        * @param cacheRegister the {@link CacheRegister}
+        */
+       @SuppressWarnings({"PMD.AvoidDeeplyNestedIfStmts" })
+       private void parseCacheConfig(final SnapshotEventsProcessor snap,
+                                     final CacheRegister cacheRegister) throws
+                       ParseException {
+               final Map<String, Cache> existingCacheMap = 
cacheRegister.getCacheMap();
+               // first Remove caches that have been deleted
+               existingCacheMap.entrySet().removeIf(exEntry-> {
+                       if 
(snap.getDeleteCacheEvents().contains(exEntry.getKey())){
+                               LOGGER.info("Removed cache from map: 
"+exEntry.getKey());
+                               return true;
+                       }
+                       return false;
+               });
+               // remove deleted caches from locations
+               // this works because 'loc.getCaches()' makes a copy
+               final Set<CacheLocation> exLocations = 
cacheRegister.getCacheLocations();
 
 Review comment:
   Do you mind renaming this to `existingLocations`? `exLocations` makes me 
think "ex-locations" like they're being removed or something.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to