You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by el...@apache.org on 2018/01/24 17:23:26 UTC
[incubator-trafficcontrol] 17/36: Code cleanup/clarifying comments
This is an automated email from the ASF dual-hosted git repository.
elsloo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git
commit 4f4a915995fa39fa5e403d556e46c994b979d46e
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed Nov 1 16:47:20 2017 -0600
Code cleanup/clarifying comments
---
.../traffic_router/core/config/ConfigHandler.java | 4 ++++
.../traffic_router/core/ds/DeliveryService.java | 1 -
.../traffic_router/core/router/TrafficRouter.java | 23 +++++++---------------
3 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/config/ConfigHandler.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/config/ConfigHandler.java
index d9531a4..c13b4e6 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/config/ConfigHandler.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/config/ConfigHandler.java
@@ -220,6 +220,10 @@ public class ConfigHandler {
* never have traffic routed to it, as the old List<Cache> does not contain the Cache that was moved to ONLINE.
* NetworkNode is a singleton and is managed asynchronously. As long as we swap out the CacheRegister first,
* then clear cache locations, the lazy loading should work as designed. See issue TC-401 for details.
+ *
+ * Update for DDC (Dynamic Deep Caching): NetworkNode now has a 2nd singleton (deepInstance) that is managed
+ * similarly to the non-deep instance. However, instead of clearing a NetworkNode's CacheLocation, only the
+ * Caches are cleared from the CacheLocation then lazily loaded at request time.
*/
NetworkNode.getInstance().clearCacheLocations();
NetworkNode.getDeepInstance().clearCacheLocations(true);
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/DeliveryService.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/DeliveryService.java
index 7adc191..facb1ba 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/DeliveryService.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/DeliveryService.java
@@ -95,7 +95,6 @@ public class DeliveryService {
private final boolean redirectToHttps;
private final int deepCache;
- // enums are hard in Java.
public static final int DC_NEVER = 0;
public static final int DC_ALWAYS = 1;
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouter.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouter.java
index 91d3751..00fafdb 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouter.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouter.java
@@ -246,9 +246,6 @@ public class TrafficRouter {
@SuppressWarnings("PMD.CyclomaticComplexity")
protected List<Cache> selectCaches(final HTTPRequest request, final DeliveryService ds, final Track track) throws GeolocationException {
- // DDC - Dynamic Deep Caching
- // cacheLocation has a list of caches that we can hash this request to.
- // Make this list different for content that should be cached deep.
CacheLocation cacheLocation;
ResultType result = ResultType.CZ;
@@ -257,10 +254,9 @@ public class TrafficRouter {
cacheLocation = getDeepCoverageZoneCacheLocation(request.getClientIP(), ds);
if (cacheLocation != null && cacheLocation.getCaches().size() != 0) {
// Found deep caches for this client, and there are caches that might be available there.
- // Use the deep cacheLocation, and set result to DEEP_CZ
result = ResultType.DEEP_CZ;
} else {
- // No deep caches for this client, would have used them if there were any...
+ // No deep caches for this client, would have used them if there were any. Fallback to regular CZ
result = ResultType.DEEP_CZ_MISS;
cacheLocation = getCoverageZoneCacheLocation(request.getClientIP(), ds);
}
@@ -644,12 +640,7 @@ public class TrafficRouter {
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
public CacheLocation getCoverageZoneCacheLocation(final String ip, final String deliveryServiceId, final boolean useDeep) {
- NetworkNode networkNode;
- if (useDeep) {
- networkNode = getDeepNetworkNode(ip);
- } else {
- networkNode = getNetworkNode(ip);
- }
+ NetworkNode networkNode = useDeep ? getDeepNetworkNode(ip) : getNetworkNode(ip);
if (networkNode == null) {
return null;
@@ -667,6 +658,11 @@ public class TrafficRouter {
return cacheLocation;
}
+ if (useDeep) {
+ // there were no available deep caches in the deep CZF
+ return null;
+ }
+
if (networkNode.getLoc() == null) {
return null;
}
@@ -679,11 +675,6 @@ public class TrafficRouter {
return cacheLocation;
}
- if (useDeep) {
- // no available deep caches in the deep CZF (fall back to regular CZF)
- return null;
- }
-
// We had a hit in the CZF but the name does not match a known cache location.
// Check whether the CZF entry has a geolocation and use it if so.
return getClosestCacheLocation(cacheRegister.filterAvailableLocations(deliveryServiceId), networkNode.getGeolocation(), cacheRegister.getDeliveryService(deliveryServiceId));
--
To stop receiving notification emails like this one, please contact
elsloo@apache.org.