rawlinp commented on a change in pull request #1908: Changes for Backup Edge
Cache Group
URL:
https://github.com/apache/incubator-trafficcontrol/pull/1908#discussion_r171952777
##########
File path:
traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
##########
@@ -106,15 +108,33 @@ public static NetworkNode generateTree(final JsonNode
json, final boolean verify
final String loc = czIter.next();
final JsonNode locData = JsonUtils.getJsonNode(coverageZones,
loc);
final JsonNode coordinates = locData.get("coordinates");
+ final JsonNode backupConfigNode = locData.get("backupZones");
+ JsonNode fallbackNode = null;
+ boolean useClosestOnBackupFailure = false;
+
Geolocation geolocation = null;
+ List<String> bkCacheLoc = null;
if (coordinates != null && coordinates.has("latitude") &&
coordinates.has("longitude")) {
final double latitude =
coordinates.get("latitude").asDouble();
final double longitude =
coordinates.get("longitude").asDouble();
geolocation = new Geolocation(latitude, longitude);
}
- if (!addNetworkNodesToRoot(root, loc, locData, geolocation,
useDeep)) {
+ if (backupConfigNode != null) {
+ if (backupConfigNode.has("list")) {
+ bkCacheLoc = new ArrayList<>();
+ for (final JsonNode network :
JsonUtils.getJsonNode(backupConfigNode, "list")) {
+ bkCacheLoc.add(network.asText());
+ }
+ }
+ fallbackNode =
backupConfigNode.get("fallbackToClosestGroup");
+ useClosestOnBackupFailure = (fallbackNode != null) ?
fallbackNode.asBoolean(): false;
+ } else {
+ useClosestOnBackupFailure = true;
Review comment:
I think we should just initialize `useClosestOnBackupFailure` to true on
L113 and omit this if-else block. It doesn't change behavior; it would just be
cleaner because it will be set to false in the previous block if configured
anyway.
----------------------------------------------------------------
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