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:09 UTC

[incubator-trafficcontrol] branch master updated (87489f1 -> 04d8665)

This is an automated email from the ASF dual-hosted git repository.

elsloo pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git.


    from 87489f1  Fix TO not_a_parent server exclusion
     new 1689697  Add deep_caching_type to DB, API, CRConfig, and UI.
     new 6584109  Reverse schema for deep_caching_type
     new 4f6eaa2  Only show Deep Caching field for HTTP delivery services
     new c41a029  Add Deep Caching field to TP
     new bfb1b56  Add DeepCachingType field to DS struct in go client
     new 87cc97c  Update TO unit/integration tests for deep_caching_type
     new 0577ddc  Add Dynamic Deep Caching
     new ef134c5  Make param 'deepcoveragezone.polling.url' optional
     new 714c82a  Refactor NetworkNode.generateTree() to reduce duplication
     new 6e403ad  Fix failing unit tests due to DDC changes
     new 235f4c7  Clean up DDC code in TR a bit
     new de83812  Properly fall back to the regular CZF if deep CZF miss
     new dfda01a  Remove the need for deepcoveragezone.polling.initialDelay parameter
     new 5a7fd58  Fix how deep NetworkNodes are loaded with a CacheLocation
     new 0e52c33  Rename goose migration file for deep_caching_type due to rebase
     new d20eae6  Fix Java PMD violations
     new 4f4a915  Code cleanup/clarifying comments
     new a717748  Refactor NetworkUpdater/DeepNetworkUpdater to reduce duplication
     new d5ec744  Add deep NetworkNode test coverage
     new fa13b4c  Add test deep coverage zone file
     new 696caf1  WIP Dynamic Deep Caching docs
     new 5b890a0  More DDC documentation
     new aa6c536  Add Deep Caching docs for overview/how to use
     new b9d4b5e  DDC documentation cleanup
     new 23fa917  Show Deep Caching field for STEERING Delivery Services
     new d8612e7  Change deep_caching_type from an int to an ENUM
     new c829851  Update Traffic Router to use deepCachingType as an enum
     new 71a07a0  Improve error message for invalid deepCachingType when parsing
     new 013909d  Address DDC review comments
     new efefb8b  Update API ref to show deepCachingType is now a string
     new f22d2ec  Fix broken unit test and error message
     new 7b5a819  Revert "Show Deep Caching field for STEERING Delivery Services"
     new 2da3fc8  Rename goose migration due to rebase making it no longer latest
     new b6c84b9  Rename Deep Caching goose migration script again due to rebase
     new a63a07c  Remove DEEP_CZ_MISS rtype from Traffic Router
     new 04d8665  Move loadDeepCaches() into CacheLocation and add synchronization

The 36 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/source/admin/traffic_ops/using.rst            |  93 +++++++++++--
 docs/source/admin/traffic_router.rst               |  88 +++++++++---
 .../traffic_ops_api/v12/deliveryservice.rst        |  48 ++++++-
 .../development/traffic_ops_api/v12/server.rst     |   6 +
 .../development/traffic_ops_api/v12/user.rst       |   6 +
 lib/go-tc/deliveryservices.go                      |   1 +
 lib/go-tc/enum.go                                  |  48 +++++++
 .../20180110000000_add_deep_caching_type.sql       |  26 ++--
 traffic_ops/app/lib/API/Deliveryservice.pm         |  14 +-
 traffic_ops/app/lib/Fixtures/Deliveryservice.pm    |  15 ++
 .../lib/Fixtures/Integration/Deliveryservice.pm    |   8 ++
 .../app/lib/Schema/Result/Deliveryservice.pm       |  38 +++--
 traffic_ops/app/lib/UI/DeliveryService.pm          |   3 +
 traffic_ops/app/lib/UI/Topology.pm                 |   5 +
 traffic_ops/app/t/api/1.2/deliveryservice.t        |   7 +
 traffic_ops/app/t/api/1.2/deliveryservice_crud.t   |  13 ++
 traffic_ops/app/t/deliveryservice.t                |   5 +
 .../app/templates/delivery_service/_form.html.ep   |  12 ++
 .../app/templates/delivery_service/add.html.ep     |   4 +
 .../app/templates/delivery_service/edit.html.ep    |   4 +
 .../client_tests/fixtures/delivery_service.go      |   1 +
 .../client_tests/fixtures/traffic_router_config.go |   8 +-
 .../tests/integration/deliveryservice_test.go      |   2 +
 .../FormDeliveryServiceController.js               |   5 +
 .../form.deliveryService.HTTP.tpl.html             |  10 ++
 .../app/src/traffic_portal_properties.json         |   1 +
 .../traffic_router/core/cache/CacheLocation.java   |  25 ++++
 .../traffic_router/core/config/ConfigHandler.java  |  21 +++
 .../traffic_router/core/ds/DeliveryService.java    |  21 ++-
 ...kNodeException.java => DeepNetworkUpdater.java} |  17 ++-
 .../traffic_router/core/loc/NetworkNode.java       | 154 +++++++++++++++------
 .../traffic_router/core/loc/NetworkUpdater.java    |   8 +-
 .../traffic_router/core/router/StatTracker.java    |  12 +-
 .../traffic_router/core/router/TrafficRouter.java  |  65 ++++++++-
 .../src/main/webapp/WEB-INF/applicationContext.xml |  11 +-
 .../traffic_router/core/external/StatsTest.java    |   4 +-
 .../traffic_router/core/loc/CoverageZoneTest.java  |   1 +
 .../traffic_router/core/loc/NetworkNodeTest.java   |  47 +++++--
 .../core/loc/NetworkNodeUnitTest.java              |  27 ++++
 .../DeliveryServiceHTTPRoutingMissesTest.java      |   2 +
 .../core/router/TrafficRouterTest.java             |   4 +-
 .../src/test/resources/{czmap.json => dczmap.json} |   9 +-
 42 files changed, 769 insertions(+), 130 deletions(-)
 copy traffic_router/core/src/main/webapp/crossdomain.xml => traffic_ops/app/db/migrations/20180110000000_add_deep_caching_type.sql (50%)
 copy traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/{NetworkNodeException.java => DeepNetworkUpdater.java} (65%)
 copy traffic_router/core/src/test/resources/{czmap.json => dczmap.json} (64%)

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 12/36: Properly fall back to the regular CZF if deep CZF miss

Posted by el...@apache.org.
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 de838120767bce3484fde6d460b3cee0cbf69f3b
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Thu Oct 26 16:32:56 2017 -0600

    Properly fall back to the regular CZF if deep CZF miss
---
 .../traffic_control/traffic_router/core/router/TrafficRouter.java  | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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 76c5627..705ec5b 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
@@ -256,7 +256,7 @@ public class TrafficRouter {
 			// Deep caching is enabled. See if there are deep caches available
 			cacheLocation = getDeepCoverageZoneCacheLocation(request.getClientIP(), ds);
 			if (cacheLocation != null && cacheLocation.getCaches().size() != 0) {
-				// Found deep caches for this client, and there are caches available there.
+				// 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 {
@@ -673,6 +673,11 @@ 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.

[incubator-trafficcontrol] 35/36: Remove DEEP_CZ_MISS rtype from Traffic Router

Posted by el...@apache.org.
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 a63a07c630a6d08cf482422266698c26ed28cbea
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Tue Jan 23 16:36:50 2018 -0700

    Remove DEEP_CZ_MISS rtype from Traffic Router
    
    Falling back to the regular CZ will be logged as CZ rather than
    DEEP_CZ_MISS.
---
 docs/source/admin/traffic_ops/using.rst            |  4 +--
 docs/source/admin/traffic_router.rst               | 36 ++++++++++------------
 .../traffic_router/core/router/StatTracker.java    | 12 +-------
 .../traffic_router/core/router/TrafficRouter.java  |  1 -
 .../traffic_router/core/external/StatsTest.java    |  4 +--
 5 files changed, 22 insertions(+), 35 deletions(-)

diff --git a/docs/source/admin/traffic_ops/using.rst b/docs/source/admin/traffic_ops/using.rst
index b11e20d..e7e8eb2 100644
--- a/docs/source/admin/traffic_ops/using.rst
+++ b/docs/source/admin/traffic_ops/using.rst
@@ -867,7 +867,7 @@ The Coverage Zone File (CZF) should contain a cachegroup name to network prefix
           "192.168.8.0/24",
           "192.168.9.0/24"
         ]
-      }
+      },
       "cache-group-02": {
         "coordinates": {
           "latitude":  3.3,
@@ -916,7 +916,7 @@ The Deep Coverage Zone File (DCZF) format is similar to the CZF format but adds
           "edge-01",
           "edge-02"
         ]
-      }
+      },
       "location-02": {
         "coordinates": {
           "latitude":  7.7,
diff --git a/docs/source/admin/traffic_router.rst b/docs/source/admin/traffic_router.rst
index 84b0f25..474dc96 100644
--- a/docs/source/admin/traffic_router.rst
+++ b/docs/source/admin/traffic_router.rst
@@ -187,23 +187,23 @@ Items within brackets below are detailed under the HTTP and DNS sections
 Fields Always Present
 ---------------------
 
-+------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
-|Name  |Description                                                                      |Data                                                                       |
-+======+=================================================================================+===========================================================================+
-|qtype |Whether the request was for DNS or HTTP                                          |Always DNS or HTTP                                                         |
-+------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
-|chi   |The IP address of the requester                                                  |Depends on whether this was a DNS or HTTP request, see below sections      |
-+------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
-|ttms  |The amount of time in milliseconds it took Traffic Router to process the request |A number greater than or equal to zero                                     |
-+------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
-|rtype |Routing Result Type                                                              |One of ERROR, CZ, GEO, MISS, STATIC_ROUTE, DS_REDIRECT, DS_MISS, INIT, FED |
-+------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
-|rloc  |GeoLocation of result                                                            |Latitude and Longitude in Decimal Degrees                                  |
-+------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
-|rdtl  |Result Details Associated with unusual conditions                                |One of DS_NOT_FOUND, DS_NO_BYPASS, DS_BYPASS, DS_CZ_ONLY                   |
-+------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
-|rerr  |Message about internal Traffic Router Error                                      |String                                                                     |
-+------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------+
++------+---------------------------------------------------------------------------------+------------------------------------------------------------------------------------+
+|Name  |Description                                                                      |Data                                                                                |
++======+=================================================================================+====================================================================================+
+|qtype |Whether the request was for DNS or HTTP                                          |Always DNS or HTTP                                                                  |
++------+---------------------------------------------------------------------------------+------------------------------------------------------------------------------------+
+|chi   |The IP address of the requester                                                  |Depends on whether this was a DNS or HTTP request, see below sections               |
++------+---------------------------------------------------------------------------------+------------------------------------------------------------------------------------+
+|ttms  |The amount of time in milliseconds it took Traffic Router to process the request |A number greater than or equal to zero                                              |
++------+---------------------------------------------------------------------------------+------------------------------------------------------------------------------------+
+|rtype |Routing Result Type                                                              |One of ERROR, CZ, DEEP_CZ, GEO, MISS, STATIC_ROUTE, DS_REDIRECT, DS_MISS, INIT, FED |
++------+---------------------------------------------------------------------------------+------------------------------------------------------------------------------------+
+|rloc  |GeoLocation of result                                                            |Latitude and Longitude in Decimal Degrees                                           |
++------+---------------------------------------------------------------------------------+------------------------------------------------------------------------------------+
+|rdtl  |Result Details Associated with unusual conditions                                |One of DS_NOT_FOUND, DS_NO_BYPASS, DS_BYPASS, DS_CZ_ONLY                            |
++------+---------------------------------------------------------------------------------+------------------------------------------------------------------------------------+
+|rerr  |Message about internal Traffic Router Error                                      |String                                                                              |
++------+---------------------------------------------------------------------------------+------------------------------------------------------------------------------------+
 
 **rtype meanings**
 
@@ -216,8 +216,6 @@ Fields Always Present
 +-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 |DEEP_CZ      |The result was derived from Deep Coverage Zone data based on the address in the chi field                                                                               |
 +-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-|DEEP_CZ_MISS |Traffic Router was unable to find a "deep" cache for the requested resource but fell back to the regular Coverage Zone to derive a result based on the chi address      |
-+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 |GEO          |The result was derived from geolocation service based on the address in the chi field                                                                                   |
 +-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 |MISS         |Traffic Router was unable to resolve a DNS request or find a cache for the requested resource                                                                           |
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
index 78e1772..b444cd8 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
@@ -50,12 +50,6 @@ public class StatTracker {
 		public void setDeepCzCount(final int deepCzCount) {
 			this.deepCzCount = deepCzCount;
 		}
-		public int getDeepCzMissCount() {
-			return deepCzMissCount;
-		}
-		public void setDeepCzMissCount(final int deepCzMissCount) {
-			this.deepCzMissCount = deepCzMissCount;
-		}
 		public int getDsrCount() {
 			return dsrCount;
 		}
@@ -102,7 +96,6 @@ public class StatTracker {
 		public int czCount;
 		public int geoCount;
 		public int deepCzCount;
-		public int deepCzMissCount;
 		public int missCount;
 		public int dsrCount;
 		public int errCount;
@@ -118,7 +111,7 @@ public class StatTracker {
 		}
 
 		public static enum ResultType {
-			ERROR, CZ, GEO, MISS, STATIC_ROUTE, DS_REDIRECT, DS_MISS, INIT, FED, RGDENY, RGALT, GEO_REDIRECT, DEEP_CZ, DEEP_CZ_MISS
+			ERROR, CZ, GEO, MISS, STATIC_ROUTE, DS_REDIRECT, DS_MISS, INIT, FED, RGDENY, RGALT, GEO_REDIRECT, DEEP_CZ
 		}
 
 		public enum ResultDetails {
@@ -291,9 +284,6 @@ public class StatTracker {
 		case DEEP_CZ:
 			tallies.deepCzCount++;
 			break;
-		case DEEP_CZ_MISS:
-			tallies.deepCzMissCount++;
-			break;
 		case MISS:
 			tallies.missCount++;
 			break;
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 8037497..bb1dbb5 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
@@ -257,7 +257,6 @@ public class TrafficRouter {
 				result = ResultType.DEEP_CZ;
 			} else {
 				// 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);
 			}
 		} else {
diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/external/StatsTest.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/external/StatsTest.java
index 97674ab..b68b43b 100644
--- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/external/StatsTest.java
+++ b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/external/StatsTest.java
@@ -85,12 +85,12 @@ public class StatsTest {
 			Map<String, Object> dnsStats = (Map<String, Object>) statsData.get("dnsMap");
 			Map<String, Object> cacheDnsStats = (Map<String, Object>) dnsStats.values().iterator().next();
 			assertThat(cacheDnsStats.keySet(), containsInAnyOrder("czCount", "geoCount", "missCount", "dsrCount", "errCount",
-					"deepCzCount", "deepCzMissCount", "staticRouteCount", "fedCount", "regionalDeniedCount", "regionalAlternateCount"));
+					"deepCzCount", "staticRouteCount", "fedCount", "regionalDeniedCount", "regionalAlternateCount"));
 
 			Map<String, Object> httpStats = (Map<String, Object>) statsData.get("httpMap");
 			Map<String, Object> cacheHttpStats = (Map<String, Object>) httpStats.values().iterator().next();
 			assertThat(cacheHttpStats.keySet(), containsInAnyOrder("czCount", "geoCount", "missCount", "dsrCount", "errCount",
-					"deepCzCount", "deepCzMissCount", "staticRouteCount", "fedCount", "regionalDeniedCount", "regionalAlternateCount"));
+					"deepCzCount", "staticRouteCount", "fedCount", "regionalDeniedCount", "regionalAlternateCount"));
 
 			Map<String, Object> updateTracker = (Map<String, Object>) statsData.get("updateTracker");
 			Set<String> keys = updateTracker.keySet();

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 28/36: Improve error message for invalid deepCachingType when parsing

Posted by el...@apache.org.
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 71a07a097cd5792c30745186499308aaa537c213
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Fri Nov 10 11:47:27 2017 -0700

    Improve error message for invalid deepCachingType when parsing
---
 .../cdn/traffic_control/traffic_router/core/ds/DeliveryService.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 e7d3727..3ac4ac9 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
@@ -155,7 +155,7 @@ public class DeliveryService {
 		try {
 			dct = DeepCachingType.valueOf(dctString);
 		} catch (IllegalArgumentException e) {
-			LOGGER.error("Unrecognized deepCachingType: '" + dct + "'. Defaulting to 'NEVER' instead");
+			LOGGER.error("DeliveryService '" + id + "' has an unrecognized deepCachingType: '" + dct + "'. Defaulting to 'NEVER' instead");
 		} finally {
 			this.deepCache = dct;
 		}

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 18/36: Refactor NetworkUpdater/DeepNetworkUpdater to reduce duplication

Posted by el...@apache.org.
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 a7177480692f29c8f34c4859c6ded2b9a7ab08ff
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Thu Nov 2 17:11:42 2017 -0600

    Refactor NetworkUpdater/DeepNetworkUpdater to reduce duplication
    
    Move specialized code into a separate method and make DeepNetworkUpdater
    extend NetworkUpdater and override the specialized method.
---
 .../core/loc/DeepNetworkUpdater.java               | 22 ++++------------------
 .../traffic_router/core/loc/NetworkUpdater.java    |  8 ++++++--
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java
index b4df7b8..c978b63 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java
@@ -18,7 +18,8 @@ package com.comcast.cdn.traffic_control.traffic_router.core.loc;
 import java.io.File;
 import java.io.IOException;
 
-public class DeepNetworkUpdater extends AbstractServiceUpdater {
+
+public class DeepNetworkUpdater extends NetworkUpdater {
 
 	public DeepNetworkUpdater() {
 		sourceCompressed = false;
@@ -27,23 +28,8 @@ public class DeepNetworkUpdater extends AbstractServiceUpdater {
 	}
 
 	@Override
-	public boolean loadDatabase() throws IOException {
-		final File existingDB = databasesDirectory.resolve(databaseName).toFile();
-
-		if (!existingDB.exists() || !existingDB.canRead()) {
-			return false;
-		}
-
-		return NetworkNode.generateTree(existingDB, false, true) != null;
-	}
-
-	@Override
-	public boolean verifyDatabase(final File dbFile) throws IOException {
-		if (!dbFile.exists() || !dbFile.canRead()) {
-			return false;
-		}
-
-		return NetworkNode.generateTree(dbFile, true, true) != null;
+	public NetworkNode generateTree(final File dbFile, final boolean verifyOnly) throws IOException {
+		return NetworkNode.generateTree(dbFile, verifyOnly, true);
 	}
 
 }
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java
index 92d9e05..d1dc4c5 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java
@@ -35,7 +35,7 @@ public class NetworkUpdater extends AbstractServiceUpdater {
 			return false;
 		}
 
-		return NetworkNode.generateTree(existingDB, false) != null;
+		return generateTree(existingDB, false) != null;
 	}
 
 	@Override
@@ -44,7 +44,11 @@ public class NetworkUpdater extends AbstractServiceUpdater {
 			return false;
 		}
 
-		return NetworkNode.generateTree(dbFile, true) != null;
+		return generateTree(dbFile, true) != null;
+	}
+
+	public NetworkNode generateTree(final File dbFile, final boolean verifyOnly) throws IOException, JSONException {
+		return NetworkNode.generateTree(dbFile, verifyOnly);
 	}
 
 }

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 04/36: Add Deep Caching field to TP

Posted by el...@apache.org.
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 c41a029e7e4afba411c5378afc7f2f3394d49515
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Fri Oct 13 11:12:33 2017 -0600

    Add Deep Caching field to TP
---
 .../form/deliveryService/FormDeliveryServiceController.js      |  5 +++++
 .../form/deliveryService/form.deliveryService.HTTP.tpl.html    | 10 ++++++++++
 traffic_portal/app/src/traffic_portal_properties.json          |  1 +
 3 files changed, 16 insertions(+)

diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
index 71927fc..049a11b 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
+++ b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
@@ -128,6 +128,11 @@ var FormDeliveryServiceController = function(deliveryService, type, types, $scop
         { value: 56, label: '56  - CS7' }
     ];
 
+    $scope.deepCachingTypes = [
+        { value: 0, label: '0 - Never' },
+        { value: 1, label: '1 - Always' }
+    ]
+
     $scope.dispersions = [
         { value: 1, label: '1 - OFF' },
         { value: 2, label: '2' },
diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html
index b651434..a36afe6 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html
@@ -168,6 +168,16 @@ under the License.
                     </div>
                 </div>
 
+                <div class="form-group" ng-class="{'has-error': hasError(deliveryServiceForm.deepCachingType), 'has-feedback': hasError(deliveryServiceForm.deepCachingType)}">
+                    <label class="control-label col-md-2 col-sm-2 col-xs-12">Deep Caching *</label>
+                    <div class="col-md-10 col-sm-10 col-xs-12">
+                        <select id="deepCachingType" name="deepCachingType" class="form-control" ng-model="deliveryService.deepCachingType" ng-options="dct.value as dct.label for dct in deepCachingTypes" required>
+                            <option value="">Select...</option>
+                        </select>
+                        <small class="input-error" ng-show="hasPropertyError(deliveryServiceForm.deepCachingType, 'required')">Required</small>
+                    </div>
+                </div>
+
                 <div class="form-group" ng-class="{'has-error': hasError(deliveryServiceForm.dscp), 'has-feedback': hasError(deliveryServiceForm.dscp)}">
                     <label class="control-label col-md-2 col-sm-2 col-xs-12">DSCP Tag *</label>
                     <div class="col-md-10 col-sm-10 col-xs-12">
diff --git a/traffic_portal/app/src/traffic_portal_properties.json b/traffic_portal/app/src/traffic_portal_properties.json
index d1bb1f0..2935001 100644
--- a/traffic_portal/app/src/traffic_portal_properties.json
+++ b/traffic_portal/app/src/traffic_portal_properties.json
@@ -83,6 +83,7 @@
         },
         "HTTP": {
           "routingName": "cdn",
+          "deepCachingType": "NEVER",
           "dscp": 0,
           "ipv6RoutingEnabled": false,
           "rangeRequestHandling": 0,

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 33/36: Rename goose migration due to rebase making it no longer latest

Posted by el...@apache.org.
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 2da3fc87cfeafc1d29c7c7dbb651b634fa8d01ff
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Mon Dec 18 16:47:19 2017 -0700

    Rename goose migration due to rebase making it no longer latest
---
 ...add_deep_caching_type.sql => 20171218000000_add_deep_caching_type.sql} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/traffic_ops/app/db/migrations/20171101000000_add_deep_caching_type.sql b/traffic_ops/app/db/migrations/20171218000000_add_deep_caching_type.sql
similarity index 100%
rename from traffic_ops/app/db/migrations/20171101000000_add_deep_caching_type.sql
rename to traffic_ops/app/db/migrations/20171218000000_add_deep_caching_type.sql

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 19/36: Add deep NetworkNode test coverage

Posted by el...@apache.org.
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 d5ec7447eb7d520d26438076fda8feb5c52b2bc2
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Fri Nov 3 16:34:55 2017 -0600

    Add deep NetworkNode test coverage
---
 .../traffic_router/core/router/TrafficRouter.java  |  2 +-
 .../traffic_router/core/loc/NetworkNodeTest.java   | 44 +++++++++++++++-------
 .../core/loc/NetworkNodeUnitTest.java              | 27 +++++++++++++
 3 files changed, 59 insertions(+), 14 deletions(-)

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 00fafdb..be0579d 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
@@ -640,7 +640,7 @@ public class TrafficRouter {
 
 	@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
 	public CacheLocation getCoverageZoneCacheLocation(final String ip, final String deliveryServiceId, final boolean useDeep) {
-		NetworkNode networkNode = useDeep ? getDeepNetworkNode(ip) : getNetworkNode(ip);
+		final NetworkNode networkNode = useDeep ? getDeepNetworkNode(ip) : getNetworkNode(ip);
 
 		if (networkNode == null) {
 			return null;
diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeTest.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeTest.java
index 0a1e7dd..3517751 100644
--- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeTest.java
+++ b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeTest.java
@@ -42,36 +42,45 @@ import org.junit.experimental.categories.Category;
 public class NetworkNodeTest {
 	private static final Logger LOGGER = Logger.getLogger(NetworkNodeTest.class);
 	private Map<String, List<String>> netMap = new HashMap<String, List<String>>();
+	private Map<String, List<String>> deepNetMap = new HashMap<String, List<String>>();
 	private NetworkNode root;
+	private NetworkNode deepRoot;
 
 	@Before
 	public void setUp() throws Exception {
-		final File file = new File(getClass().getClassLoader().getResource("czmap.json").toURI());
-		root = NetworkNode.generateTree(file, false);
+		root = setUp("czmap.json", false);
+		deepRoot = setUp("dczmap.json", true);
+	}
+
+	private NetworkNode setUp(final String filename, final boolean useDeep) throws Exception {
+		final Map<String, List<String>> testNetMap = useDeep ? deepNetMap : netMap;
+		final File file = new File(getClass().getClassLoader().getResource(filename).toURI());
+		final NetworkNode nn = NetworkNode.generateTree(file, false, useDeep);
 		final ObjectMapper mapper = new ObjectMapper();
 		final JsonNode jsonNode = mapper.readTree(file);
 		final JsonNode coverageZones = jsonNode.get("coverageZones");
 
 		final Iterator<String> networkIter = coverageZones.fieldNames();
 		while (networkIter.hasNext()) {
-			final String loc = networkIter.next();
+		    final String loc = networkIter.next();
 			final JsonNode locData = coverageZones.get(loc);
-			for (final JsonNode networkType : locData) {
-				final String network = networkType.get(0).asText().split("/")[0];
+			for (String networkType : new String[]{"network", "network6"}) {
+				final JsonNode networks = locData.get(networkType);
+				final String network = networks.get(0).asText().split("/")[0];
 				InetAddress ip = InetAddresses.forString(network);
 				ip = InetAddresses.increment(ip);
 
-				if (!netMap.containsKey(loc)) {
-					netMap.put(loc, new ArrayList<String>());
+				if (!testNetMap.containsKey(loc)) {
+					testNetMap.put(loc, new ArrayList<String>());
 				}
 
-				final List<String> addressList = netMap.get(loc);
+				final List<String> addressList = testNetMap.get(loc);
 				addressList.add(InetAddresses.toAddrString(ip));
 
-				netMap.put(loc, addressList);
-
+				testNetMap.put(loc, addressList);
 			}
 		}
+		return nn;
 	}
 
 	@Test
@@ -93,15 +102,24 @@ public class NetworkNodeTest {
 
 	@Test
 	public void testNetworkNodePerformance() {
+		testNetworkNodePerformance(root, netMap);
+	}
+
+	@Test
+	public void testDeepNetworkNodePerformance() {
+		testNetworkNodePerformance(deepRoot, deepNetMap);
+	}
+
+	private void testNetworkNodePerformance(NetworkNode testRoot, Map<String, List<String>> testNetMap) {
 		final int iterations = 100000;
 		final long startTime = System.currentTimeMillis();
 		final long nnTPS = Long.parseLong(System.getProperty("nnTPS", "12000"));
 
 		for (int i = 0; i < iterations; i++) {
-			for (final String location : netMap.keySet()) {
+			for (final String location : testNetMap.keySet()) {
 				try {
-					for (final String address : netMap.get(location)) {
-						final NetworkNode nn = root.getNetwork(address);
+					for (final String address : testNetMap.get(location)) {
+						final NetworkNode nn = testRoot.getNetwork(address);
 					}
 				} catch (final NetworkNodeException e) {
 					e.printStackTrace();
diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeUnitTest.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeUnitTest.java
index c12bfd6..f4dd55a 100644
--- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeUnitTest.java
+++ b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeUnitTest.java
@@ -20,8 +20,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import org.junit.Test;
 
 
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.equalTo;
@@ -87,6 +89,31 @@ public class NetworkNodeUnitTest {
     }
 
     @Test
+    public void itSupportsDeepCaches() throws Exception {
+        String czmapString = "{" +
+                "\"revision\": \"Mon Dec 21 15:04:01 2015\"," +
+                "\"customerName\": \"Kabletown\"," +
+                "\"coverageZones\": {" +
+                "\"us-co-denver\": {" +
+                "\"network\": [\"192.168.55.0/24\",\"192.168.6.0/24\",\"192.168.0.0/16\"]," +
+                "\"network6\": [\"1234:5678::/64\",\"1234:5679::/64\"]," +
+                "\"caches\": [\"host1\",\"host2\"]" +
+                "}" +
+                "}" +
+                "}";
+
+        JSONTokener jsonTokener = new JSONTokener(czmapString);
+        final JSONObject json = new JSONObject(jsonTokener);
+        NetworkNode networkNode = NetworkNode.generateTree(json, false, true);
+        NetworkNode foundNetworkNode = networkNode.getNetwork("192.168.55.100");
+
+        Set<String> expected = new HashSet<String>();
+        expected.add("host1");
+        expected.add("host2");
+        assertThat(foundNetworkNode.getDeepCacheNames(), equalTo(expected));
+    }
+
+    @Test
     public void itDoesIpV6() throws Exception {
         String czmapString = "{" +
             "\"revision\": \"Mon Dec 21 15:04:01 2015\"," +

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 29/36: Address DDC review comments

Posted by el...@apache.org.
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 013909de88439c87e48b6af29642e7670896ec11
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Fri Nov 10 15:57:43 2017 -0700

    Address DDC review comments
    
    Changed DCZF to use 'deepCoverageZones' key instead of 'coverageZones'
    for better separation.
    
    Created enum type DeepCachingType to use in DeliveryService struct in
    lib/go-tc.
---
 docs/source/admin/traffic_ops/using.rst            |  4 +-
 lib/go-tc/deliveryservices.go                      |  2 +-
 lib/go-tc/enum.go                                  | 48 ++++++++++++++++++++++
 .../traffic_router/core/ds/DeliveryService.java    |  2 +-
 .../traffic_router/core/loc/NetworkNode.java       |  3 +-
 .../traffic_router/core/loc/NetworkUpdater.java    |  2 +-
 .../traffic_router/core/loc/NetworkNodeTest.java   |  3 +-
 .../core/loc/NetworkNodeUnitTest.java              |  6 +--
 traffic_router/core/src/test/resources/dczmap.json |  2 +-
 9 files changed, 61 insertions(+), 11 deletions(-)

diff --git a/docs/source/admin/traffic_ops/using.rst b/docs/source/admin/traffic_ops/using.rst
index 5ac1a0d..6a6c130 100644
--- a/docs/source/admin/traffic_ops/using.rst
+++ b/docs/source/admin/traffic_ops/using.rst
@@ -895,10 +895,10 @@ The script that generates the CZF file is not part of Traffic Control, since it
 
 The Deep Coverage Zone File
 +++++++++++++++++++++++++++
-The Deep Coverage Zone File (DCZF) format is similar to the CZF format but adds a ``caches`` list under each ``coverageZone``: ::
+The Deep Coverage Zone File (DCZF) format is similar to the CZF format but adds a ``caches`` list under each ``deepCoverageZone``: ::
 
   {
-    "coverageZones": {
+    "deepCoverageZones": {
       "location-01": {
         "coordinates": {
           "latitude":  5.5,
diff --git a/lib/go-tc/deliveryservices.go b/lib/go-tc/deliveryservices.go
index b27b655..9d621a8 100644
--- a/lib/go-tc/deliveryservices.go
+++ b/lib/go-tc/deliveryservices.go
@@ -56,7 +56,7 @@ type DeliveryService struct {
 	Active               bool                   `json:"active"`
 	DSCP                 int                    `json:"dscp"`
 	RoutingName          string                 `json:"routingName"`
-	DeepCachingType      string                 `json:"deepCachingType"`
+	DeepCachingType      DeepCachingType        `json:"deepCachingType"`
 	Signed               bool                   `json:"signed"`
 	QStringIgnore        int                    `json:"qstringIgnore"`
 	GeoLimit             int                    `json:"geoLimit"`
diff --git a/lib/go-tc/enum.go b/lib/go-tc/enum.go
index 46aa9d0..f8f3a66 100644
--- a/lib/go-tc/enum.go
+++ b/lib/go-tc/enum.go
@@ -29,6 +29,8 @@ package tc
  */
 
 import (
+	"errors"
+	"strconv"
 	"strings"
 )
 
@@ -182,3 +184,49 @@ func CacheStatusFromString(s string) CacheStatus {
 		return CacheStatusInvalid
 	}
 }
+
+// DeepCachingType represents a Delivery Service's deep caching type. The string values of this type should match the Traffic Ops values.
+type DeepCachingType string
+
+const (
+	DeepCachingTypeAlways  = DeepCachingType("ALWAYS")
+	DeepCachingTypeNever   = DeepCachingType("NEVER")
+	DeepCachingTypeInvalid = DeepCachingType("")
+)
+
+// String returns a string representation of this deep caching type
+func (t DeepCachingType) String() string {
+	switch t {
+	case DeepCachingTypeAlways:
+		return string(t)
+	case DeepCachingTypeNever:
+		return string(t)
+	default:
+		return "INVALID"
+	}
+}
+
+// DeepCachingTypeFromString returns a DeepCachingType from its string representation, or DeepCachingTypeInvalid if the string is not a valid type.
+func DeepCachingTypeFromString(s string) DeepCachingType {
+	switch strings.ToLower(s) {
+	case "always":
+		return DeepCachingTypeAlways
+	case "never":
+		return DeepCachingTypeNever
+	default:
+		return DeepCachingTypeInvalid
+	}
+}
+
+// UnmarshalJSON unmarshals a JSON representation of a DeepCachingType (i.e. a string) or returns an error if the DeepCachingType is invalid
+func (t *DeepCachingType) UnmarshalJSON(data []byte) error {
+	s, err := strconv.Unquote(string(data))
+	if err != nil {
+		return errors.New(string(data) + " JSON not quoted")
+	}
+	*t = DeepCachingTypeFromString(s)
+	if *t == DeepCachingTypeInvalid {
+		return errors.New(string(data) + " is not a DeepCachingType")
+	}
+	return nil
+}
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 3ac4ac9..6305e12 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
@@ -150,7 +150,7 @@ public class DeliveryService {
 		acceptHttp = JsonUtils.optBoolean(protocol, "acceptHttp", true);
 		acceptHttps = JsonUtils.optBoolean(protocol, "acceptHttps");
 		redirectToHttps = JsonUtils.optBoolean(protocol, "redirectToHttps");
-		final String dctString = JsonUtils.optString(dsJo, "deepCachingType", "NEVER");
+		final String dctString = JsonUtils.optString(dsJo, "deepCachingType", "NEVER").toUpperCase();
 		DeepCachingType dct = DeepCachingType.NEVER;
 		try {
 			dct = DeepCachingType.valueOf(dctString);
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
index c098320..9d292ae 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
@@ -96,7 +96,8 @@ public class NetworkNode implements Comparable<NetworkNode> {
     @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
     public static NetworkNode generateTree(final JsonNode json, final boolean verifyOnly, final boolean useDeep) {
         try {
-            final JsonNode coverageZones = JsonUtils.getJsonNode(json, "coverageZones");
+            final String czKey = useDeep ? "deepCoverageZones" : "coverageZones";
+            final JsonNode coverageZones = JsonUtils.getJsonNode(json, czKey);
 
             final SuperNode root = new SuperNode();
 
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java
index d1dc4c5..2ae2938 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkUpdater.java
@@ -47,7 +47,7 @@ public class NetworkUpdater extends AbstractServiceUpdater {
 		return generateTree(dbFile, true) != null;
 	}
 
-	public NetworkNode generateTree(final File dbFile, final boolean verifyOnly) throws IOException, JSONException {
+	public NetworkNode generateTree(final File dbFile, final boolean verifyOnly) throws IOException {
 		return NetworkNode.generateTree(dbFile, verifyOnly);
 	}
 
diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeTest.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeTest.java
index 3517751..e4301af 100644
--- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeTest.java
+++ b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeTest.java
@@ -58,7 +58,8 @@ public class NetworkNodeTest {
 		final NetworkNode nn = NetworkNode.generateTree(file, false, useDeep);
 		final ObjectMapper mapper = new ObjectMapper();
 		final JsonNode jsonNode = mapper.readTree(file);
-		final JsonNode coverageZones = jsonNode.get("coverageZones");
+		final String czKey = useDeep ? "deepCoverageZones" : "coverageZones";
+		final JsonNode coverageZones = jsonNode.get(czKey);
 
 		final Iterator<String> networkIter = coverageZones.fieldNames();
 		while (networkIter.hasNext()) {
diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeUnitTest.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeUnitTest.java
index f4dd55a..3ebb10e 100644
--- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeUnitTest.java
+++ b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNodeUnitTest.java
@@ -93,7 +93,7 @@ public class NetworkNodeUnitTest {
         String czmapString = "{" +
                 "\"revision\": \"Mon Dec 21 15:04:01 2015\"," +
                 "\"customerName\": \"Kabletown\"," +
-                "\"coverageZones\": {" +
+                "\"deepCoverageZones\": {" +
                 "\"us-co-denver\": {" +
                 "\"network\": [\"192.168.55.0/24\",\"192.168.6.0/24\",\"192.168.0.0/16\"]," +
                 "\"network6\": [\"1234:5678::/64\",\"1234:5679::/64\"]," +
@@ -102,8 +102,8 @@ public class NetworkNodeUnitTest {
                 "}" +
                 "}";
 
-        JSONTokener jsonTokener = new JSONTokener(czmapString);
-        final JSONObject json = new JSONObject(jsonTokener);
+        final ObjectMapper mapper = new ObjectMapper();
+        final JsonNode json = mapper.readTree(czmapString);
         NetworkNode networkNode = NetworkNode.generateTree(json, false, true);
         NetworkNode foundNetworkNode = networkNode.getNetwork("192.168.55.100");
 
diff --git a/traffic_router/core/src/test/resources/dczmap.json b/traffic_router/core/src/test/resources/dczmap.json
index 39185c1..bfc5c5b 100644
--- a/traffic_router/core/src/test/resources/dczmap.json
+++ b/traffic_router/core/src/test/resources/dczmap.json
@@ -1,5 +1,5 @@
 {
-	"coverageZones":
+	"deepCoverageZones":
 	{
 		"cache-group-01":
 		{

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 32/36: Revert "Show Deep Caching field for STEERING Delivery Services"

Posted by el...@apache.org.
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 7b5a8193dfb1fd3cc97f5c9f51911c344ddf6f50
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Mon Nov 13 16:20:11 2017 -0700

    Revert "Show Deep Caching field for STEERING Delivery Services"
    
    This reverts commit 704aae655c2a78e39472edeaf5f6fec2e3d31ca1.
    
    My original thought was correct; deepCachingType is not applied to
    STEERING DSes, only the target DSes.
---
 traffic_ops/app/templates/delivery_service/add.html.ep  | 2 +-
 traffic_ops/app/templates/delivery_service/edit.html.ep | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/traffic_ops/app/templates/delivery_service/add.html.ep b/traffic_ops/app/templates/delivery_service/add.html.ep
index 26ea456..c2f0841 100644
--- a/traffic_ops/app/templates/delivery_service/add.html.ep
+++ b/traffic_ops/app/templates/delivery_service/add.html.ep
@@ -235,7 +235,7 @@
             $('#range_request_handlingi_row').hide(speed);
             $('#dns_bypass_ip_row').hide(speed);
             $('#dns_bypass_ip6_row').hide(speed);
-            $('#deep_caching_type').show(speed);
+            $('#deep_caching_type').hide(speed);
 			$('#regional_geo_blocking_row').show(speed);
 	    	$('#dns_bypass_cname_row').hide(speed);
             $('#dns_bypass_ttl_row').hide(speed);
diff --git a/traffic_ops/app/templates/delivery_service/edit.html.ep b/traffic_ops/app/templates/delivery_service/edit.html.ep
index 223e210..699361a 100644
--- a/traffic_ops/app/templates/delivery_service/edit.html.ep
+++ b/traffic_ops/app/templates/delivery_service/edit.html.ep
@@ -327,7 +327,7 @@ function setup_form(speed) {
             $('#range_request_handlingi_row').hide(speed);
             $('#dns_bypass_ip_row').hide(speed);
             $('#dns_bypass_ip6_row').hide(speed);
-            $('#deep_caching_type').show(speed);
+            $('#deep_caching_type').hide(speed);
 			$('#regional_geo_blocking_row').show(speed);
 	    	$('#dns_bypass_cname_row').hide(speed);
             $('#dns_bypass_ttl_row').hide(speed);

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 20/36: Add test deep coverage zone file

Posted by el...@apache.org.
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 fa13b4c4945680d3bea981528353c8a6d3a4643b
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Mon Nov 6 16:49:31 2017 -0700

    Add test deep coverage zone file
---
 traffic_router/core/src/test/resources/dczmap.json | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/traffic_router/core/src/test/resources/dczmap.json b/traffic_router/core/src/test/resources/dczmap.json
new file mode 100644
index 0000000..39185c1
--- /dev/null
+++ b/traffic_router/core/src/test/resources/dczmap.json
@@ -0,0 +1,25 @@
+{
+	"coverageZones":
+	{
+		"cache-group-01":
+		{
+			"network6":
+			[
+				"1234:5678::/64",
+				"1234:5679::/64"
+			],
+			"network":
+			[
+				"192.168.8.0/24",
+				"192.168.9.0/24"
+			],
+			"caches":
+			[
+				"host1",
+				"host2",
+				"host3",
+				"host4"
+			]
+		}
+	}
+}

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 27/36: Update Traffic Router to use deepCachingType as an enum

Posted by el...@apache.org.
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 c82985184e5b2995e96d18d09b949eea2dd1428e
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Thu Nov 9 17:32:25 2017 -0700

    Update Traffic Router to use deepCachingType as an enum
---
 .../traffic_router/core/ds/DeliveryService.java     | 21 +++++++++++++++------
 .../traffic_router/core/router/TrafficRouter.java   |  2 +-
 2 files changed, 16 insertions(+), 7 deletions(-)

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 facb1ba..e7d3727 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
@@ -93,10 +93,12 @@ public class DeliveryService {
 	private final boolean acceptHttp;
 	private final boolean acceptHttps;
 	private final boolean redirectToHttps;
-	private final int deepCache;
+	private final DeepCachingType deepCache;
 
-	public static final int DC_NEVER   = 0;
-	public static final int DC_ALWAYS  = 1;
+	public enum DeepCachingType {
+		NEVER,
+		ALWAYS
+	}
 
 	public DeliveryService(final String id, final JsonNode dsJo) throws JsonUtilsException {
 		this.id = id;
@@ -148,8 +150,15 @@ public class DeliveryService {
 		acceptHttp = JsonUtils.optBoolean(protocol, "acceptHttp", true);
 		acceptHttps = JsonUtils.optBoolean(protocol, "acceptHttps");
 		redirectToHttps = JsonUtils.optBoolean(protocol, "redirectToHttps");
-
-		this.deepCache = JsonUtils.optInt(dsJo, "deepCachingType", DC_NEVER);
+		final String dctString = JsonUtils.optString(dsJo, "deepCachingType", "NEVER");
+		DeepCachingType dct = DeepCachingType.NEVER;
+		try {
+			dct = DeepCachingType.valueOf(dctString);
+		} catch (IllegalArgumentException e) {
+			LOGGER.error("Unrecognized deepCachingType: '" + dct + "'. Defaulting to 'NEVER' instead");
+		} finally {
+			this.deepCache = dct;
+		}
 	}
 
 	public String getId() {
@@ -394,7 +403,7 @@ public class DeliveryService {
 		this.isDns = isDns;
 	}
 
-	public int getDeepCache() {
+	public DeepCachingType getDeepCache() {
 		return deepCache;
 	}
 
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 be0579d..8037497 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
@@ -249,7 +249,7 @@ public class TrafficRouter {
 		CacheLocation cacheLocation;
 		ResultType result = ResultType.CZ;
 
-		if (ds.getDeepCache() == DeliveryService.DC_ALWAYS) {
+		if (ds.getDeepCache() == DeliveryService.DeepCachingType.ALWAYS) {
 			// Deep caching is enabled. See if there are deep caches available
 			cacheLocation = getDeepCoverageZoneCacheLocation(request.getClientIP(), ds);
 			if (cacheLocation != null && cacheLocation.getCaches().size() != 0) {

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 31/36: Fix broken unit test and error message

Posted by el...@apache.org.
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 f22d2ec561a6af978403b10217d5d8e1be5ae82d
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Mon Nov 13 12:49:08 2017 -0700

    Fix broken unit test and error message
---
 .../cdn/traffic_control/traffic_router/core/ds/DeliveryService.java     | 2 +-
 .../core/router/DeliveryServiceHTTPRoutingMissesTest.java               | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

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 6305e12..4aadd70 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
@@ -155,7 +155,7 @@ public class DeliveryService {
 		try {
 			dct = DeepCachingType.valueOf(dctString);
 		} catch (IllegalArgumentException e) {
-			LOGGER.error("DeliveryService '" + id + "' has an unrecognized deepCachingType: '" + dct + "'. Defaulting to 'NEVER' instead");
+			LOGGER.error("DeliveryService '" + id + "' has an unrecognized deepCachingType: '" + dctString + "'. Defaulting to 'NEVER' instead");
 		} finally {
 			this.deepCache = dct;
 		}
diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/router/DeliveryServiceHTTPRoutingMissesTest.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/router/DeliveryServiceHTTPRoutingMissesTest.java
index 01d9815..1714dc8 100644
--- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/router/DeliveryServiceHTTPRoutingMissesTest.java
+++ b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/router/DeliveryServiceHTTPRoutingMissesTest.java
@@ -47,6 +47,8 @@ public class DeliveryServiceHTTPRoutingMissesTest {
         when(unusedByTest.get("routingName")).thenReturn(mapper.readTree("\"edge\""));
         when(unusedByTest.has("coverageZoneOnly")).thenReturn(true);
         when(unusedByTest.get("coverageZoneOnly")).thenReturn(mapper.readTree("true"));
+        when(unusedByTest.has("deepCachingType")).thenReturn(true);
+        when(unusedByTest.get("deepCachingType")).thenReturn(mapper.readTree("\"NEVER\""));
         deliveryService = new DeliveryService("ignoredbytest", unusedByTest);
         httpRequest = mock(HTTPRequest.class);
         track = StatTracker.getTrack();

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 34/36: Rename Deep Caching goose migration script again due to rebase

Posted by el...@apache.org.
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 b6c84b925599de1d23a57aed4b42e79c959714de
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed Jan 10 10:17:20 2018 -0700

    Rename Deep Caching goose migration script again due to rebase
---
 ...add_deep_caching_type.sql => 20180110000000_add_deep_caching_type.sql} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/traffic_ops/app/db/migrations/20171218000000_add_deep_caching_type.sql b/traffic_ops/app/db/migrations/20180110000000_add_deep_caching_type.sql
similarity index 100%
rename from traffic_ops/app/db/migrations/20171218000000_add_deep_caching_type.sql
rename to traffic_ops/app/db/migrations/20180110000000_add_deep_caching_type.sql

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 14/36: Fix how deep NetworkNodes are loaded with a CacheLocation

Posted by el...@apache.org.
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 5a7fd581605370fe344c88d76792d9f84d2c66bb
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Tue Oct 31 16:12:31 2017 -0600

    Fix how deep NetworkNodes are loaded with a CacheLocation
    
    Lazily load Caches into a deep NetworkNode's CacheLocation rather than
    setting its CacheLocation and greedily loading Caches into it at the
    time of NetworkNode.generateTree(). This allows changes in Cache status
    to be reflected in deep CZF lookups (i.e. when a Cache is set to
    OFFLINE, stop deep routing to it). Whenever a new CRConfig is processed,
    clear out deep Caches from the CacheLocations so that they can be lazily
    loaded again (similar to how non-deep CacheLocations are reset to null).
---
 .../traffic_router/core/cache/CacheLocation.java   |   4 +
 .../traffic_router/core/config/ConfigHandler.java  |   2 +-
 .../traffic_router/core/loc/NetworkNode.java       | 108 +++++++++++----------
 .../traffic_router/core/router/TrafficRouter.java  |  17 ++++
 4 files changed, 77 insertions(+), 54 deletions(-)

diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/cache/CacheLocation.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/cache/CacheLocation.java
index e2bf78d..7caf2a3 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/cache/CacheLocation.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/cache/CacheLocation.java
@@ -60,6 +60,10 @@ public class CacheLocation {
 			caches.put(cache.getId(), cache);
 	}
 
+	public void clearCaches() {
+		caches.clear();
+	}
+
 	@Override
 	public boolean equals(final Object obj) {
 		if (this == obj) {
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 53f3188..d9531a4 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
@@ -205,7 +205,6 @@ public class ConfigHandler {
 				parseCacheConfig(JsonUtils.getJsonNode(jo, "contentServers"), cacheRegister);
 				parseMonitorConfig(JsonUtils.getJsonNode(jo, "monitors"));
 
-				NetworkNode.setCacheRegister(cacheRegister);
 				federationsWatcher.configure(config);
 				steeringWatcher.configure(config);
 				steeringWatcher.setCacheRegister(cacheRegister);
@@ -223,6 +222,7 @@ public class ConfigHandler {
 				 * then clear cache locations, the lazy loading should work as designed. See issue TC-401 for details.
 				 */
 				NetworkNode.getInstance().clearCacheLocations();
+				NetworkNode.getDeepInstance().clearCacheLocations(true);
 				setLastSnapshotTimestamp(sts);
 			} catch (ParseException e) {
 				isProcessing.set(false);
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
index 0b89d2e..c852184 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
@@ -20,11 +20,12 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeMap;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.concurrent.CountDownLatch;
 
 import com.comcast.cdn.traffic_control.traffic_router.core.util.CidrAddress;
 import com.comcast.cdn.traffic_control.traffic_router.core.util.JsonUtils;
@@ -35,9 +36,7 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.log4j.Logger;
 
-import com.comcast.cdn.traffic_control.traffic_router.core.cache.Cache;
 import com.comcast.cdn.traffic_control.traffic_router.core.cache.CacheLocation;
-import com.comcast.cdn.traffic_control.traffic_router.core.cache.CacheRegister;
 
 public class NetworkNode implements Comparable<NetworkNode> {
     private static final Logger LOGGER = Logger.getLogger(NetworkNode.class);
@@ -46,14 +45,12 @@ public class NetworkNode implements Comparable<NetworkNode> {
     private static NetworkNode instance;
     private static NetworkNode deepInstance;
 
-    private static CacheRegister cacheRegister;
-    private static final CountDownLatch cacheRegisterLatch = new CountDownLatch(1);
-
     private CidrAddress cidrAddress;
     private String loc;
     private CacheLocation cacheLocation = null;
     private Geolocation geolocation = null;
     protected Map<NetworkNode,NetworkNode> children;
+    private Set<String> deepCacheNames;
 
     public static NetworkNode getInstance() {
         if (instance != null) {
@@ -83,21 +80,6 @@ public class NetworkNode implements Comparable<NetworkNode> {
         return deepInstance;
     }
 
-    public static void setCacheRegister(final CacheRegister cr) {
-        cacheRegister = cr;
-        cacheRegisterLatch.countDown();
-    }
-
-    public static CacheRegister getCacheRegisterBlocking() {
-        try {
-            cacheRegisterLatch.await();
-        } catch (InterruptedException e) {
-            LOGGER.warn(e);
-        } finally {
-            return cacheRegister;
-        }
-    }
-
     public static NetworkNode generateTree(final File f, final boolean verifyOnly, final boolean useDeep) throws IOException  {
         final ObjectMapper mapper = new ObjectMapper();
         return generateTree(mapper.readTree(f), verifyOnly, useDeep);
@@ -130,31 +112,8 @@ public class NetworkNode implements Comparable<NetworkNode> {
                     final double longitude = coordinates.get("longitude").asDouble();
                     geolocation = new Geolocation(latitude, longitude);
                 }
-                CacheLocation deepLoc = null;
-                if (useDeep) {
-                    try {
-                        final JsonNode caches = JsonUtils.getJsonNode(locData, "caches");
-                        for (final JsonNode cacheJson : caches) {
-                            final String cacheHostname = cacheJson.asText();
-                            if (deepLoc == null) {
-                                deepLoc = new CacheLocation( "deep." + loc, new Geolocation(0.0, 0.0));  // TODO JvD
-                            }
-                            // Get the cache from the cacheregister here - don't create a new cache due to the deep file, only reuse the
-                            // ones we already know about.
-                            final Cache cache = getCacheRegisterBlocking().getCacheMap().get(cacheHostname);
-                            if (cache == null) {
-                                LOGGER.warn("DDC: deep cache entry " + cacheHostname + " not found in crconfig server list (it might not belong to this CDN)");
-                            } else {
-                                LOGGER.info("DDC: Adding " + cacheHostname + " to " + deepLoc.getId() + ".");
-                                deepLoc.addCache(cache);
-                            }
-                        }
-                    } catch (JsonUtilsException ex) {
-                        LOGGER.warn("An exception was caught while accessing the caches key of " + loc + " in the incoming coverage zone file: " + ex.getMessage());
-                    }
-                }
 
-                if (!addNetworkNodesToRoot(root, locData, loc, deepLoc, geolocation, useDeep)) {
+                if (!addNetworkNodesToRoot(root, loc, locData, geolocation, useDeep)) {
                     return null;
                 }
             }
@@ -177,8 +136,11 @@ public class NetworkNode implements Comparable<NetworkNode> {
         return null;
     }
 
-    private static boolean addNetworkNodesToRoot(final SuperNode root, final JsonNode locData, final String loc,
-                                                 final CacheLocation deepLoc, final Geolocation geolocation, final boolean useDeep) {
+    private static boolean addNetworkNodesToRoot(final SuperNode root, final String loc, final JsonNode locData,
+                                                 final Geolocation geolocation, final boolean useDeep) {
+        CacheLocation deepLoc = new CacheLocation( "deep." + loc, geolocation != null ? geolocation : new Geolocation(0.0, 0.0));  // TODO JvD
+        final Set<String> cacheNames = parseDeepCacheNames(locData);
+
         for (final String key : new String[]{"network6", "network"}) {
             try {
                 for (final JsonNode network : JsonUtils.getJsonNode(locData, key)) {
@@ -186,7 +148,12 @@ public class NetworkNode implements Comparable<NetworkNode> {
 
                     try {
                         final NetworkNode nn = new NetworkNode(ip, loc, geolocation);
-                        if (useDeep && deepLoc != null) { // for deepLoc, we add the location here; normally it gets added by setLocation.
+                        if (useDeep) {
+                            // For a deep NetworkNode, we set the CacheLocation here without any Caches.
+                            // The deep Caches will be lazily loaded in getCoverageZoneCacheLocation() where we have
+                            // access to the latest CacheRegister, similar to how normal NetworkNodes are lazily loaded
+                            // with a CacheLocation.
+                            nn.setDeepCacheNames(cacheNames);
                             nn.setCacheLocation(deepLoc);
                         }
                         if ("network6".equals(key)) {
@@ -206,6 +173,25 @@ public class NetworkNode implements Comparable<NetworkNode> {
         return true;
     }
 
+    private static Set<String> parseDeepCacheNames(JsonNode locationData) {
+        final Set<String> cacheNames = new HashSet<String>();
+        final JsonNode cacheArray;
+
+        try {
+            cacheArray = JsonUtils.getJsonNode(locationData, "caches");
+        } catch (JsonUtilsException ex) {
+            return cacheNames;
+        }
+
+        for (final JsonNode cache : cacheArray) {
+            final String cacheName = cache.asText();
+            if (!cacheName.isEmpty()) {
+                cacheNames.add(cacheName);
+            }
+        }
+        return cacheNames;
+    }
+
     public NetworkNode(final String str) throws NetworkNodeException {
         this(str, null);
     }
@@ -302,6 +288,14 @@ public class NetworkNode implements Comparable<NetworkNode> {
         this.cacheLocation = cacheLocation;
     }
 
+    public Set<String> getDeepCacheNames() {
+        return deepCacheNames;
+    }
+
+    public void setDeepCacheNames(final Set<String> deepCacheNames) {
+        this.deepCacheNames = deepCacheNames;
+    }
+
     public int size() {
         if (children == null) {
             return 1;
@@ -317,22 +311,30 @@ public class NetworkNode implements Comparable<NetworkNode> {
     }
 
     public void clearCacheLocations() {
+        clearCacheLocations(false);
+    }
+
+    public void clearCacheLocations(boolean clearCachesOnly) {
         synchronized(this) {
-            cacheLocation = null;
+            if (clearCachesOnly && cacheLocation != null) {
+                cacheLocation.clearCaches();
+            } else {
+                cacheLocation = null;
+            }
 
             if (this instanceof SuperNode) {
                 final SuperNode superNode = (SuperNode) this;
 
                 if (superNode.children6 != null) {
                     for (final NetworkNode child : superNode.children6.keySet()) {
-                        child.clearCacheLocations();
+                        child.clearCacheLocations(clearCachesOnly);
                     }
                 }
             }
 
             if (children != null) {
                 for (final NetworkNode child : children.keySet()) {
-                    child.clearCacheLocations();
+                    child.clearCacheLocations(clearCachesOnly);
                 }
             }
         }
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 705ec5b..68dfb6b 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
@@ -657,6 +657,11 @@ public class TrafficRouter {
 		final DeliveryService deliveryService = cacheRegister.getDeliveryService(deliveryServiceId);
 		CacheLocation cacheLocation = networkNode.getCacheLocation();
 
+		if (useDeep && cacheLocation != null && cacheLocation.getCaches().isEmpty()) {
+			// lazily load deep Caches into the deep CacheLocation
+			loadDeepCaches(networkNode, cacheLocation);
+		}
+
 		if (cacheLocation != null && !getSupportingCaches(cacheLocation.getCaches(), deliveryService).isEmpty()) {
 			return cacheLocation;
 		}
@@ -683,6 +688,18 @@ public class TrafficRouter {
 		return getClosestCacheLocation(cacheRegister.filterAvailableLocations(deliveryServiceId), networkNode.getGeolocation(), cacheRegister.getDeliveryService(deliveryServiceId));
 	}
 
+	private void loadDeepCaches(NetworkNode networkNode, CacheLocation cacheLocation) {
+		if (networkNode.getDeepCacheNames() != null) {
+			for (final String deepCacheName : networkNode.getDeepCacheNames()) {
+				final Cache deepCache = cacheRegister.getCacheMap().get(deepCacheName);
+				if (deepCache != null) {
+					LOGGER.debug("DDC: Adding " + deepCacheName + " to " + cacheLocation.getId());
+					cacheLocation.addCache(deepCache);
+				}
+			}
+		}
+	}
+
 	public CacheLocation getDeepCoverageZoneCacheLocation(final String ip, final DeliveryService deliveryService) {
 		return getCoverageZoneCacheLocation(ip, deliveryService, true);
 	}

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 22/36: More DDC documentation

Posted by el...@apache.org.
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 5b890a008a073d6e36f114152ac22c76f0ab8003
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Tue Nov 7 15:44:47 2017 -0700

    More DDC documentation
---
 docs/source/admin/traffic_ops/using.rst            | 20 ++++++-----
 docs/source/admin/traffic_router.rst               |  8 +++++
 .../traffic_ops_api/v12/deliveryservice.rst        | 40 +++++++++++++++++++++-
 .../development/traffic_ops_api/v12/server.rst     |  5 +++
 .../development/traffic_ops_api/v12/user.rst       |  5 +++
 5 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/docs/source/admin/traffic_ops/using.rst b/docs/source/admin/traffic_ops/using.rst
index 19fb72a..e37be4d 100644
--- a/docs/source/admin/traffic_ops/using.rst
+++ b/docs/source/admin/traffic_ops/using.rst
@@ -306,7 +306,7 @@ The fields in the Delivery Service view are:
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Content Routing Type                             | The type of content routing this delivery service will use. See :ref:`rl-ds-types`.                                                                                                                                 |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| Deep Caching                                     | (for HTTP routed delivery services only) When to do deep caching for this delivery service (see :ref:`Deep Caching <insert-ref-here>` for more details:                                                             |
+| Deep Caching                                     | (for HTTP routed delivery services only) When to do deep caching for this delivery service (see :ref:`Deep Caching <insert-ref-here>` for more details):                                                            |
 |                                                  | - NEVER                                                                                                                                                                                                             |
 |                                                  | - ALWAYS                                                                                                                                                                                                            |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@@ -714,7 +714,11 @@ Traffic Router Profile
 +-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | coveragezone.polling.interval           | CRConfig.json          | How often to refresh the coverage zone map in ms                                                                                                                                                          |
 +-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| coveragezone.polling.url                | CRConfig.json          | The location (URL) to retrieve the coverage zone map file in XML format from.                                                                                                                             |
+| coveragezone.polling.url                | CRConfig.json          | The location (URL) to retrieve the coverage zone map file in JSON format from.                                                                                                                            |
++-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| deepcoveragezone.polling.interval       | CRConfig.json          | How often to refresh the deep coverage zone map in ms                                                                                                                                                     |
++-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| deepcoveragezone.polling.url            | CRConfig.json          | The location (URL) to retrieve the deep coverage zone map file in JSON format from.                                                                                                                       |
 +-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | tld.soa.expire                          | CRConfig.json          | The value for the expire field the Traffic Router DNS Server will respond with on Start of Authority (SOA) records.                                                                                       |
 +-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@@ -852,7 +856,7 @@ The Coverage Zone File (CZF) should contain a cachegroup name to network prefix
       "cache-group-01": {
         "coordinates": {
           "latitude":  1.1,
-          "longitude": 2.2,
+          "longitude": 2.2
         },
         "network6": [
           "1234:5678::/64",
@@ -866,7 +870,7 @@ The Coverage Zone File (CZF) should contain a cachegroup name to network prefix
       "cache-group-02": {
         "coordinates": {
           "latitude":  3.3,
-          "longitude": 4.4,
+          "longitude": 4.4
         },
         "network6": [
           "1234:567a::/64",
@@ -890,14 +894,14 @@ The script that generates the CZF file is not part of Traffic Control, since it
 
 The Deep Coverage Zone File
 +++++++++++++++++++++++++++
-The Deep Coverage Zone File (DCZF) format is similar the CZF format but contains a ``caches`` list under each ``coverageZone``: ::
+The Deep Coverage Zone File (DCZF) format is similar to the CZF format but adds a ``caches`` list under each ``coverageZone``: ::
 
   {
     "coverageZones": {
       "location-01": {
         "coordinates": {
           "latitude":  5.5,
-          "longitude": 6.6,
+          "longitude": 6.6
         },
         "network6": [
           "1234:5678::/64",
@@ -915,7 +919,7 @@ The Deep Coverage Zone File (DCZF) format is similar the CZF format but contains
       "location-02": {
         "coordinates": {
           "latitude":  7.7,
-          "longitude": 8.8,
+          "longitude": 8.8
         },
         "network6": [
           "1234:567a::/64",
@@ -933,7 +937,7 @@ The Deep Coverage Zone File (DCZF) format is similar the CZF format but contains
     }
   }
 
-Each entry in the ``caches`` list is the hostname of an edge cache registered in Traffic Ops which will be used for "deep" caching in that Deep Coverage Zone. Unlike a regular CZF, coverage zones in the DCZF do not map to a Cache Group in Traffic Ops, so currently the deep coverage zone name can be chosen arbitrarily.
+Each entry in the ``caches`` list is the hostname of an edge cache registered in Traffic Ops which will be used for "deep" caching in that Deep Coverage Zone. Unlike a regular CZF, coverage zones in the DCZF do not map to a Cache Group in Traffic Ops, so currently the deep coverage zone name only needs to be unique.
 
 If the Traffic Router gets a DCZF "hit" for a requested Delivery Service that has Deep Caching enabled, the client will be routed to an available "deep" cache from that zone's ``caches`` list.
 
diff --git a/docs/source/admin/traffic_router.rst b/docs/source/admin/traffic_router.rst
index 3a37781..0fe1707 100644
--- a/docs/source/admin/traffic_router.rst
+++ b/docs/source/admin/traffic_router.rst
@@ -102,6 +102,10 @@ Configuration files
 |                            +-------------------------------------------+-----------------------------------------------------------------------------------------------------+---------------------------------------------------+
 |                            | cache.czmap.database.refresh.period       | The interval in milliseconds which Traffic Router will poll for a new coverage zone file            | 10800000                                          |
 |                            +-------------------------------------------+-----------------------------------------------------------------------------------------------------+---------------------------------------------------+
+|                            | cache.dczmap.database                     | Full path to the local copy of the deep coverage zone file                                          | /opt/traffic_router/db/dczmap.json                |
+|                            +-------------------------------------------+-----------------------------------------------------------------------------------------------------+---------------------------------------------------+
+|                            | cache.dczmap.database.refresh.period      | The interval in milliseconds which Traffic Router will poll for a new deep coverage zone file       | 10800000                                          |
+|                            +-------------------------------------------+-----------------------------------------------------------------------------------------------------+---------------------------------------------------+
 |                            | cache.health.json                         | Full path to the local copy of the health state                                                     | /opt/traffic_router/db/health.json                |
 |                            +-------------------------------------------+-----------------------------------------------------------------------------------------------------+---------------------------------------------------+
 |                            | cache.health.json.refresh.period          | The interval in milliseconds which Traffic Router will poll for a new health state file             | 1000                                              |
@@ -210,6 +214,10 @@ Fields Always Present
 +-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 |CZ           |The result was derived from Coverage Zone data based on the address in the chi field                                                                                    |
 +-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|DEEP_CZ      |The result was derived from Deep Coverage Zone data based on the address in the chi field                                                                               |
++-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|DEEP_CZ_MISS |Traffic Router was unable to find a "deep" cache for the requested resource but fell back to the regular Coverage Zone to derive a result based on the chi address      |
++-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 |GEO          |The result was derived from geolocation service based on the address in the chi field                                                                                   |
 +-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 |MISS         |Traffic Router was unable to resolve a DNS request or find a cache for the requested resource                                                                           |
diff --git a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
index 2884a4b..3eaff73 100644
--- a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
+++ b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
@@ -66,6 +66,10 @@ Delivery Service
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
+  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        | - 0: NEVER (default)                                                                                                                 |
+  |                          |        | - 1: ALWAYS                                                                                                                          |
+  +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``dnsBypassCname``       | string |                                                                                                                                      |
@@ -206,6 +210,7 @@ Delivery Service
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
+            "deepCachingType": 0,
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
@@ -301,6 +306,10 @@ Delivery Service
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
+  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        | - 0: NEVER (default)                                                                                                                 |
+  |                          |        | - 1: ALWAYS                                                                                                                          |
+  +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``dnsBypassCname``       | string |                                                                                                                                      |
@@ -449,6 +458,7 @@ Delivery Service
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
+            "deepCachingType": 0,
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
@@ -1918,6 +1928,10 @@ URL Sig Keys
   +----------------------------------------+--------+----------+---------------------------------------------------------------------------------------------+
   | ``>customer``                          | string | yes      | Name of the customer to associated with the delivery service.                               |
   +----------------------------------------+--------+----------+---------------------------------------------------------------------------------------------+
+  | ``>deepCachingType``                   |  int   | no       | When to do Deep Caching for this Delivery Service:                                          |
+  |                                        |        |          | - 0: NEVER (default)                                                                        |
+  |                                        |        |          | - 1: ALWAYS                                                                                 |
+  +----------------------------------------+--------+----------+---------------------------------------------------------------------------------------------+
   | ``>deliveryProtocol``                  | string | yes      | Eg. http or http/https                                                                      |
   +----------------------------------------+--------+----------+---------------------------------------------------------------------------------------------+
   | ``>routingType``                       | string | yes      | Eg. DNS or HTTP Redirect                                                                    |
@@ -1978,6 +1992,7 @@ URL Sig Keys
        "details": {
           "customer": "XYZ Corporation",
           "contentType": "video-on-demand",
+          "deepCachingType": 0,
           "deliveryProtocol": "http",
           "routingType": "dns",
           "routingName": "foo",
@@ -2062,6 +2077,10 @@ URL Sig Keys
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | checkPath              | no       | The path portion of the URL to check this deliveryservice for health.                                   |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
+  | deepCachingType        | no       | When to do Deep Caching for this Delivery Service:                                                      |
+  |                        |          | - 0: NEVER (default)                                                                                    |
+  |                        |          | - 1: ALWAYS                                                                                             |
+  +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | displayName            | yes      | Display name                                                                                            |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | dnsBypassCname         | no       | Bypass CNAME                                                                                            |
@@ -2232,6 +2251,10 @@ URL Sig Keys
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
+  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        | - 0: NEVER (default)                                                                                                                 |
+  |                          |        | - 1: ALWAYS                                                                                                                          |
+  +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``dnsBypassCname``       | string |                                                                                                                                      |
@@ -2376,6 +2399,7 @@ URL Sig Keys
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
+            "deepCachingType": 0,
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
@@ -2472,6 +2496,10 @@ URL Sig Keys
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | checkPath              | no       | The path portion of the URL to check this deliveryservice for health.                                   |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
+  | deepCachingType        | no       | When to do Deep Caching for this Delivery Service:                                                      |
+  |                        |          | - 0: NEVER (default)                                                                                    |
+  |                        |          | - 1: ALWAYS                                                                                             |
+  +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | displayName            | yes      | Display name                                                                                            |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | dnsBypassCname         | no       | Bypass CNAME                                                                                            |
@@ -2602,7 +2630,7 @@ URL Sig Keys
     {
         "xmlId": "my_ds_1",
         "displayName": "my_ds_displayname_1",
-	"tenantId": 1,
+        "tenantId": 1,
         "protocol": 1,
         "orgServerFqdn": "http://10.75.168.91",
         "cdnId": 2,
@@ -2642,6 +2670,10 @@ URL Sig Keys
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
+  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        | - 0: NEVER (default)                                                                                                                 |
+  |                          |        | - 1: ALWAYS                                                                                                                          |
+  +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``dnsBypassCname``       | string |                                                                                                                                      |
@@ -2786,6 +2818,7 @@ URL Sig Keys
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
+            "deepCachingType": 0,
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
@@ -2911,6 +2944,10 @@ URL Sig Keys
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
+  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        | - 0: NEVER (default)                                                                                                                 |
+  |                          |        | - 1: ALWAYS                                                                                                                          |
+  +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``dnsBypassCname``       | string |                                                                                                                                      |
@@ -3055,6 +3092,7 @@ URL Sig Keys
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
+            "deepCachingType": 0,
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
diff --git a/docs/source/development/traffic_ops_api/v12/server.rst b/docs/source/development/traffic_ops_api/v12/server.rst
index 77ae9f8..bae5b8a 100644
--- a/docs/source/development/traffic_ops_api/v12/server.rst
+++ b/docs/source/development/traffic_ops_api/v12/server.rst
@@ -378,6 +378,10 @@ Server
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
+  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        | - 0: NEVER (default)                                                                                                                 |
+  |                          |        | - 1: ALWAYS                                                                                                                          |
+  +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``dnsBypassIp``          | string | The IPv4 IP to use for bypass on a DNS deliveryservice  - bypass starts when serving more than the                                   |
@@ -516,6 +520,7 @@ Server
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
+            "deepCachingType": 0,
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
diff --git a/docs/source/development/traffic_ops_api/v12/user.rst b/docs/source/development/traffic_ops_api/v12/user.rst
index fe07920..f89b566 100644
--- a/docs/source/development/traffic_ops_api/v12/user.rst
+++ b/docs/source/development/traffic_ops_api/v12/user.rst
@@ -454,6 +454,10 @@ Users
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
+  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        | - 0: NEVER (default)                                                                                                                 |
+  |                          |        | - 1: ALWAYS                                                                                                                          |
+  +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``dnsBypassIp``          | string | The IPv4 IP to use for bypass on a DNS deliveryservice  - bypass starts when serving more than the                                   |
@@ -592,6 +596,7 @@ Users
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
+            "deepCachingType": 0,
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 07/36: Add Dynamic Deep Caching

Posted by el...@apache.org.
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 0577ddcfbcc6012b463e40539137c323c61404fd
Author: Jan van Doorn <ja...@cable.comcast.com>
AuthorDate: Fri Nov 18 21:26:53 2016 +0000

    Add Dynamic Deep Caching
    
    (cherry picked from commit ef5734bbfa77d6088407604cfb5790a53f49691c)
---
 .../traffic_router/core/config/ConfigHandler.java  | 17 +++++
 .../traffic_router/core/ds/DeliveryService.java    | 14 ++++
 .../core/loc/AbstractServiceUpdater.java           | 12 +++-
 .../core/loc/DeepNetworkUpdater.java               | 49 ++++++++++++++
 .../traffic_router/core/loc/NetworkNode.java       | 78 ++++++++++++++++++++--
 .../traffic_router/core/router/StatTracker.java    | 22 +++++-
 .../traffic_router/core/router/TrafficRouter.java  | 69 +++++++++++++++++--
 .../src/main/webapp/WEB-INF/applicationContext.xml |  9 +++
 .../core/router/TrafficRouterTest.java             |  4 +-
 9 files changed, 259 insertions(+), 15 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 a657e23..e6bd2df 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
@@ -36,6 +36,7 @@ import com.comcast.cdn.traffic_control.traffic_router.core.loc.FederationsWatche
 import com.comcast.cdn.traffic_control.traffic_router.core.loc.GeolocationDatabaseUpdater;
 import com.comcast.cdn.traffic_control.traffic_router.core.loc.NetworkNode;
 import com.comcast.cdn.traffic_control.traffic_router.core.loc.NetworkUpdater;
+import com.comcast.cdn.traffic_control.traffic_router.core.loc.DeepNetworkUpdater;
 import com.comcast.cdn.traffic_control.traffic_router.core.loc.RegionalGeoUpdater;
 
 import com.comcast.cdn.traffic_control.traffic_router.core.secure.CertificatesPoller;
@@ -76,6 +77,7 @@ public class ConfigHandler {
 	private TrafficOpsUtils trafficOpsUtils;
 
 	private NetworkUpdater networkUpdater;
+	private DeepNetworkUpdater deepNetworkUpdater;
 	private FederationsWatcher federationsWatcher;
 	private RegionalGeoUpdater regionalGeoUpdater;
 	private SteeringWatcher steeringWatcher;
@@ -102,6 +104,9 @@ public class ConfigHandler {
 	public NetworkUpdater getNetworkUpdater () {
 		return networkUpdater;
 	}
+	public DeepNetworkUpdater getDeepNetworkUpdater () {
+		return deepNetworkUpdater;
+	}
 
 	public RegionalGeoUpdater getRegionalGeoUpdater() {
 		return regionalGeoUpdater;
@@ -141,6 +146,7 @@ public class ConfigHandler {
 			try {
 				parseGeolocationConfig(config);
 				parseCoverageZoneNetworkConfig(config);
+				parseDeepCoverageZoneNetworkConfig(config);
 				parseRegionalGeoConfig(jo);
 
 				final CacheRegister cacheRegister = new CacheRegister();
@@ -199,6 +205,7 @@ public class ConfigHandler {
 				parseCacheConfig(JsonUtils.getJsonNode(jo, "contentServers"), cacheRegister);
 				parseMonitorConfig(JsonUtils.getJsonNode(jo, "monitors"));
 
+				NetworkNode.setCacheRegister(cacheRegister);
 				federationsWatcher.configure(config);
 				steeringWatcher.configure(config);
 				steeringWatcher.setCacheRegister(cacheRegister);
@@ -251,6 +258,9 @@ public class ConfigHandler {
 	public void setNetworkUpdater(final NetworkUpdater nu) {
 		this.networkUpdater = nu;
 	}
+	public void setDeepNetworkUpdater(final DeepNetworkUpdater dnu) {
+		this.deepNetworkUpdater = dnu;
+	}
 
 	public void setRegionalGeoUpdater(final RegionalGeoUpdater regionalGeoUpdater) {
 		this.regionalGeoUpdater = regionalGeoUpdater;
@@ -541,6 +551,13 @@ public class ConfigHandler {
 			);
 	}
 
+	private void parseDeepCoverageZoneNetworkConfig(final JsonNode config) throws JsonUtilsException {
+		getDeepNetworkUpdater().setDataBaseURL(
+				JsonUtils.getString(config, "deepcoveragezone.polling.url"),
+				JsonUtils.optLong(config, "deepcoveragezone.polling.interval")
+		);
+	}
+
 	private void parseRegionalGeoConfig(final JsonNode jo) throws JsonUtilsException {
 		final JsonNode config = JsonUtils.getJsonNode(jo, "config");
 		final String url = JsonUtils.optString(config, "regional_geoblock.polling.url", null);
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 33cd406..e124fb4 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
@@ -93,6 +93,11 @@ public class DeliveryService {
 	private final boolean acceptHttp;
 	private final boolean acceptHttps;
 	private final boolean redirectToHttps;
+	private int deepCache; // should this be final or should it be settable?
+
+	// enums are hard in Java.
+	public static final int DC_NEVER   = 0;
+	public static final int DC_ALWAYS  = 1;
 
 	public DeliveryService(final String id, final JsonNode dsJo) throws JsonUtilsException {
 		this.id = id;
@@ -145,6 +150,7 @@ public class DeliveryService {
 		acceptHttps = JsonUtils.optBoolean(protocol, "acceptHttps");
 		redirectToHttps = JsonUtils.optBoolean(protocol, "redirectToHttps");
 
+		this.deepCache = JsonUtils.optInt(dsJo, "deepCachingType", DC_NEVER);
 	}
 
 	public String getId() {
@@ -389,6 +395,14 @@ public class DeliveryService {
 		this.isDns = isDns;
 	}
 
+	public int getDeepCache() {
+		return deepCache;
+	}
+	public void setDeepCache(final int deepCache) {
+		this.deepCache = deepCache;
+	}
+
+
 	public boolean appendQueryString() {
 		return shouldAppendQueryString;
 	}
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AbstractServiceUpdater.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AbstractServiceUpdater.java
index 3304119..650bdea 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AbstractServiceUpdater.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AbstractServiceUpdater.java
@@ -48,6 +48,7 @@ public abstract class AbstractServiceUpdater {
 	protected String databaseName;
 	protected ScheduledExecutorService executorService;
 	private long pollingInterval;
+	private long initialDelay = -1;
 	protected boolean loaded = false;
 	protected ScheduledFuture<?> scheduledService;
 	private TrafficRouterManager trafficRouterManager;
@@ -92,9 +93,13 @@ public abstract class AbstractServiceUpdater {
 
 	public void init() {
 		final long pollingInterval = getPollingInterval();
+        if (initialDelay == -1) {
+             initialDelay = pollingInterval;
+        }
+
 		final Date nextFetchDate = new Date(System.currentTimeMillis() + pollingInterval);
 		LOGGER.info("[" + getClass().getSimpleName() + "] Fetching external resource " + dataBaseURL + " at interval: " + pollingInterval + " : " + TimeUnit.MILLISECONDS + " next update occurrs at " + nextFetchDate);
-		scheduledService = executorService.scheduleWithFixedDelay(updater, pollingInterval, pollingInterval, TimeUnit.MILLISECONDS);
+		scheduledService = executorService.scheduleWithFixedDelay(updater, initialDelay, pollingInterval, TimeUnit.MILLISECONDS);
 	}
 
 	@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
@@ -194,6 +199,11 @@ public abstract class AbstractServiceUpdater {
 		dataBaseURL = null;
 	}
 
+    public void setDataBaseURL(final String url, final long refresh, final long iDelay) {
+        this.initialDelay = iDelay;
+        this.setDataBaseURL(url, refresh);
+    }
+
 	public void setDataBaseURL(final String url, final long refresh) {
 		if (refresh !=0 && refresh != pollingInterval) {
 
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java
new file mode 100644
index 0000000..b4df7b8
--- /dev/null
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/DeepNetworkUpdater.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.comcast.cdn.traffic_control.traffic_router.core.loc;
+
+import java.io.File;
+import java.io.IOException;
+
+public class DeepNetworkUpdater extends AbstractServiceUpdater {
+
+	public DeepNetworkUpdater() {
+		sourceCompressed = false;
+		tmpPrefix = "deepczf";
+		tmpSuffix = ".json";
+	}
+
+	@Override
+	public boolean loadDatabase() throws IOException {
+		final File existingDB = databasesDirectory.resolve(databaseName).toFile();
+
+		if (!existingDB.exists() || !existingDB.canRead()) {
+			return false;
+		}
+
+		return NetworkNode.generateTree(existingDB, false, true) != null;
+	}
+
+	@Override
+	public boolean verifyDatabase(final File dbFile) throws IOException {
+		if (!dbFile.exists() || !dbFile.canRead()) {
+			return false;
+		}
+
+		return NetworkNode.generateTree(dbFile, true, true) != null;
+	}
+
+}
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
index 77dc22b..e4e32dd 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
@@ -35,13 +35,18 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.log4j.Logger;
 
+import com.comcast.cdn.traffic_control.traffic_router.core.cache.Cache;
 import com.comcast.cdn.traffic_control.traffic_router.core.cache.CacheLocation;
+import com.comcast.cdn.traffic_control.traffic_router.core.cache.CacheRegister;
 
 public class NetworkNode implements Comparable<NetworkNode> {
     private static final Logger LOGGER = Logger.getLogger(NetworkNode.class);
     private static final String DEFAULT_SUB_STR = "0.0.0.0/0";
 
     private static NetworkNode instance;
+    private static NetworkNode deepInstance;
+
+    private static CacheRegister cacheRegister;
 
     private CidrAddress cidrAddress;
     private String loc;
@@ -63,13 +68,39 @@ public class NetworkNode implements Comparable<NetworkNode> {
         return instance;
     }
 
-    public static NetworkNode generateTree(final File f, final boolean verifyOnly) throws IOException {
+    public static NetworkNode getDeepInstance() {
+        if (deepInstance != null) {
+            return deepInstance;
+        }
+
+        try {
+            deepInstance = new NetworkNode(DEFAULT_SUB_STR);
+        } catch (NetworkNodeException e) {
+            LOGGER.warn(e);
+        }
+
+        return deepInstance;
+    }
+
+    public static void setCacheRegister(final CacheRegister cr) {
+        cacheRegister = cr;
+    }
+
+    public static NetworkNode generateTree(final File f, final boolean verifyOnly, final boolean useDeep) throws IOException  {
         final ObjectMapper mapper = new ObjectMapper();
-        return generateTree(mapper.readTree(f), verifyOnly);
+        return generateTree(mapper.readTree(f), verifyOnly, useDeep);
+    }
+
+    public static NetworkNode generateTree(final File f, final boolean verifyOnly) throws IOException  {
+        return generateTree(f, verifyOnly, false);
     }
 
-    @SuppressWarnings("PMD.CyclomaticComplexity")
     public static NetworkNode generateTree(final JsonNode json, final boolean verifyOnly) {
+        return generateTree(json, verifyOnly, false);
+    }
+
+    @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
+    public static NetworkNode generateTree(final JsonNode json, final boolean verifyOnly, final boolean useDeep) {
         try {
             final JsonNode coverageZones = JsonUtils.getJsonNode(json, "coverageZones");
 
@@ -87,13 +118,40 @@ public class NetworkNode implements Comparable<NetworkNode> {
                     final double longitude = coordinates.get("longitude").asDouble();
                     geolocation = new Geolocation(latitude, longitude);
                 }
+                CacheLocation deepLoc = null;
+                if (useDeep) {
+                    try {
+                        final JsonNode caches = JsonUtils.getJsonNode(locData, "caches");
+                        for (final JsonNode cacheJson : caches) {
+                            final String cacheHostname = cacheJson.asText();
+                            if (deepLoc == null) {
+                                deepLoc = new CacheLocation( "deep." + loc, new Geolocation(0.0, 0.0));  // TODO JvD
+                            }
+                            // Get the cache from the cacheregister here - don't create a new cache due to the deep file, only reuse the
+                            // ones we already know about.
+                            final Cache cache = cacheRegister.getCacheMap().get(cacheHostname);
+                            if (cache == null) {
+                                LOGGER.error("DDC: deep cache entry " + cacheHostname + " not found in crconfig server list!");
+                            } else {
+                                LOGGER.info("DDC: Adding " + cacheHostname + " to " + deepLoc.getId() + ".");
+                                deepLoc.addCache(cache);
+                            }
+                        }
+                    } catch (JsonUtilsException ex) {
+                        LOGGER.warn("An exception was caught while accessing the caches key of " + loc + " in the incoming coverage zone file: " + ex.getMessage());
+                    }
+                }
 
                 try {
                     for (final JsonNode network6 : JsonUtils.getJsonNode(locData, "network6")) {
                         final String ip = network6.asText();
 
                         try {
-                            root.add6(new NetworkNode(ip, loc, geolocation));
+                            final NetworkNode nn = new NetworkNode(ip, loc, geolocation);
+                            if (useDeep && deepLoc != null) { // for deepLoc, we add the location here; normally it gets added by setLocation.
+                                nn.setCacheLocation(deepLoc);
+                            }
+                            root.add6(nn);
                         } catch (NetworkNodeException ex) {
                             LOGGER.error(ex, ex);
                             return null;
@@ -108,7 +166,11 @@ public class NetworkNode implements Comparable<NetworkNode> {
                         final String ip = network.asText();
 
                         try {
-                            root.add(new NetworkNode(ip, loc, geolocation));
+                            final NetworkNode nn = new NetworkNode(ip, loc, geolocation);
+                            if (useDeep && deepLoc != null) {
+                                nn.setCacheLocation(deepLoc);
+                            }
+                            root.add(nn);
                         } catch (NetworkNodeException ex) {
                             LOGGER.error(ex, ex);
                             return null;
@@ -120,7 +182,11 @@ public class NetworkNode implements Comparable<NetworkNode> {
             }
 
             if (!verifyOnly) {
-                instance = root;
+                if (useDeep) {
+                    deepInstance = root;
+                } else {
+                    instance = root;
+                }
             }
 
             return root;
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
index f628afd..78e1772 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
@@ -44,6 +44,18 @@ public class StatTracker {
 		public void setGeoCount(final int geoCount) {
 			this.geoCount = geoCount;
 		}
+		public int getDeepCzCount() {
+			return deepCzCount;
+		}
+		public void setDeepCzCount(final int deepCzCount) {
+			this.deepCzCount = deepCzCount;
+		}
+		public int getDeepCzMissCount() {
+			return deepCzMissCount;
+		}
+		public void setDeepCzMissCount(final int deepCzMissCount) {
+			this.deepCzMissCount = deepCzMissCount;
+		}
 		public int getDsrCount() {
 			return dsrCount;
 		}
@@ -89,6 +101,8 @@ public class StatTracker {
 
 		public int czCount;
 		public int geoCount;
+		public int deepCzCount;
+		public int deepCzMissCount;
 		public int missCount;
 		public int dsrCount;
 		public int errCount;
@@ -104,7 +118,7 @@ public class StatTracker {
 		}
 
 		public static enum ResultType {
-			ERROR, CZ, GEO, MISS, STATIC_ROUTE, DS_REDIRECT, DS_MISS, INIT, FED, RGDENY, RGALT, GEO_REDIRECT
+			ERROR, CZ, GEO, MISS, STATIC_ROUTE, DS_REDIRECT, DS_MISS, INIT, FED, RGDENY, RGALT, GEO_REDIRECT, DEEP_CZ, DEEP_CZ_MISS
 		}
 
 		public enum ResultDetails {
@@ -274,6 +288,12 @@ public class StatTracker {
 		case GEO:
 			tallies.geoCount++;
 			break;
+		case DEEP_CZ:
+			tallies.deepCzCount++;
+			break;
+		case DEEP_CZ_MISS:
+			tallies.deepCzMissCount++;
+			break;
 		case MISS:
 			tallies.missCount++;
 			break;
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 7db9ab2..b1b2623 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
@@ -243,9 +243,42 @@ public class TrafficRouter {
 
 		return null;
 	}
-	protected List<Cache> selectCaches(final Request request, final DeliveryService ds, final Track track) throws GeolocationException {
-		final CacheLocation cacheLocation = getCoverageZoneCacheLocation(request.getClientIP(), ds);
-		List<Cache> caches = selectCachesByCZ(ds, cacheLocation, track);
+
+	@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.
+		//boolean useDeepCZ = false;
+		// first get the cachegroup, because the popularity is by cachegroup...
+		// this is expensive, but i see no other option.
+		final CacheLocation cacheGroup = getCoverageZoneCacheLocation(request.getClientIP(), ds, false);
+		CacheLocation cacheLocation = null;
+		ResultType result = ResultType.CZ;
+		if (cacheGroup != null) {
+			// change true to a function that returns yes if the request.getPath is popular
+			//boolean isPop = isPopular(request.getPath(), ds.getId(), cacheGroup.getId());
+			if (ds.getDeepCache() == DeliveryService.DC_ALWAYS) {
+				// Deep caching is enabled and wanted for the requested URL. See if there are deep caches available
+				cacheLocation = getCoverageZoneCacheLocation(request.getClientIP(), ds, true);
+				if (cacheLocation != null && cacheLocation.getCaches().size() != 0) {
+					// Found deep caches for this client, and there are caches available there.
+					// Use the 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...
+					// set the cacheLocation to the cacheGroup found earlier.
+					result = ResultType.DEEP_CZ_MISS;
+					cacheLocation = cacheGroup;
+				}
+			} else {
+				// Deep caching not enabled or not for this URL. Back to cachegroup.
+				cacheLocation = cacheGroup;
+			}
+
+		}
+
+		List<Cache>caches = selectCachesByCZ(ds, cacheLocation, track, result);
 
 		if (caches != null) {
 			return caches;
@@ -434,6 +467,10 @@ public class TrafficRouter {
 	}
 
 	private List<Cache> selectCachesByCZ(final DeliveryService ds, final CacheLocation cacheLocation, final Track track) {
+		return selectCachesByCZ(ds, cacheLocation, track, ResultType.CZ); // RestultType.CZ was the original default before DDC
+	}
+
+	private List<Cache> selectCachesByCZ(final DeliveryService ds, final CacheLocation cacheLocation, final Track track, final ResultType result) {
 		if (cacheLocation == null || ds == null || !ds.isLocationAvailable(cacheLocation)) {
 			return null;
 		}
@@ -441,7 +478,7 @@ public class TrafficRouter {
 		final List<Cache> caches = selectCaches(cacheLocation, ds);
 
 		if (caches != null && track != null) {
-			track.setResult(ResultType.CZ);
+			track.setResult(result);
 			track.setResultLocation(cacheLocation.getGeolocation());
 		}
 
@@ -592,6 +629,15 @@ public class TrafficRouter {
 		return false;
 	}
 
+	protected NetworkNode getDeepNetworkNode(final String ip) {
+		try {
+			return NetworkNode.getDeepInstance().getNetwork(ip);
+		} catch (NetworkNodeException e) {
+			LOGGER.warn(e);
+		}
+		return null;
+	}
+
 	protected NetworkNode getNetworkNode(final String ip) {
 		try {
 			return NetworkNode.getInstance().getNetwork(ip);
@@ -602,7 +648,16 @@ public class TrafficRouter {
 	}
 
 	public CacheLocation getCoverageZoneCacheLocation(final String ip, final String deliveryServiceId) {
-		final NetworkNode networkNode = getNetworkNode(ip);
+		return getCoverageZoneCacheLocation(ip, deliveryServiceId, false); // default is not deep
+	}
+
+	public CacheLocation getCoverageZoneCacheLocation(final String ip, final String deliveryServiceId, final boolean useDeep) {
+		NetworkNode networkNode;
+		if (useDeep) {
+			networkNode = getDeepNetworkNode(ip);
+		} else {
+			networkNode = getNetworkNode(ip);
+		}
 
 		if (networkNode == null) {
 			return null;
@@ -632,6 +687,10 @@ public class TrafficRouter {
 		return getClosestCacheLocation(cacheRegister.filterAvailableLocations(deliveryServiceId), networkNode.getGeolocation(), cacheRegister.getDeliveryService(deliveryServiceId));
 	}
 
+	protected CacheLocation getCoverageZoneCacheLocation(final String ip, final DeliveryService deliveryService, final boolean useDeep) {
+		return getCoverageZoneCacheLocation(ip, deliveryService.getId(), useDeep);
+	}
+
 	protected CacheLocation getCoverageZoneCacheLocation(final String ip, final DeliveryService deliveryService) {
 		return getCoverageZoneCacheLocation(ip, deliveryService.getId());
 	}
diff --git a/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml b/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml
index 4e3f869..d416a3f 100644
--- a/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml
@@ -109,6 +109,7 @@
 		<property name="trafficRouterManager" ref="trafficRouterManager" />
 		<property name="geolocationDatabaseUpdater" ref="geolocationDatabaseUpdater" />
 		<property name="networkUpdater" ref="networkUpdater" />
+		<property name="deepNetworkUpdater" ref="deepNetworkUpdater" />
 		<property name="regionalGeoUpdater" ref="regionalGeoUpdater" />
 		<property name="statTracker" ref="statTracker" />
 		<property name="configDir" value="/opt/traffic_router/conf" />
@@ -144,6 +145,14 @@
 		<property name="trafficRouterManager" ref="trafficRouterManager" />
 	</bean>
 
+	<bean id="deepNetworkUpdater" class="com.comcast.cdn.traffic_control.traffic_router.core.loc.DeepNetworkUpdater" init-method="init">
+		<property name="executorService" ref="ScheduledExecutorService" />
+		<property name="databasesDirectory" ref="databasesDir" />
+		<property name="databaseName" value="$[cache.dczmap.database:dczmap.json]" />
+		<property name="pollingInterval" value="$[cache.dczmap.database.refresh.period:10800000]" />
+		<property name="trafficRouterManager" ref="trafficRouterManager" />
+	</bean>
+
 	<bean id="regionalGeoUpdater" class="com.comcast.cdn.traffic_control.traffic_router.core.loc.RegionalGeoUpdater"
 		init-method="init">
 		<property name="executorService" ref="ScheduledExecutorService" />
diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouterTest.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouterTest.java
index 1c6e971..2e7a54a 100644
--- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouterTest.java
+++ b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouterTest.java
@@ -138,7 +138,7 @@ public class TrafficRouterTest {
 
         List<Cache> caches = new ArrayList<Cache>();
         caches.add(cache);
-        when(trafficRouter.selectCaches(any(Request.class), any(DeliveryService.class), any(Track.class))).thenReturn(caches);
+        when(trafficRouter.selectCaches(any(HTTPRequest.class), any(DeliveryService.class), any(Track.class))).thenReturn(caches);
         when(trafficRouter.selectCachesByGeo(anyString(), any(DeliveryService.class), any(CacheLocation.class), any(Track.class))).thenCallRealMethod();
         when(trafficRouter.getClientLocation(anyString(), any(DeliveryService.class), any(CacheLocation.class), any(Track.class))).thenReturn(new Geolocation(40, -100));
         when(trafficRouter.getCachesByGeo(any(DeliveryService.class), any(Geolocation.class), any(Track.class))).thenCallRealMethod();
@@ -168,7 +168,7 @@ public class TrafficRouterTest {
         when(deliveryService.isLocationAvailable(cacheLocation)).thenReturn(true);
         when(deliveryService.filterAvailableLocations(any(Collection.class))).thenCallRealMethod();
 
-        when(trafficRouter.selectCaches(any(Request.class), any(DeliveryService.class), any(Track.class))).thenCallRealMethod();
+        when(trafficRouter.selectCaches(any(HTTPRequest.class), any(DeliveryService.class), any(Track.class))).thenCallRealMethod();
         when(trafficRouter.selectCachesByGeo(anyString(), any(DeliveryService.class), any(CacheLocation.class), any(Track.class))).thenCallRealMethod();
 
         Geolocation clientLocation = new Geolocation(40, -100);

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 21/36: WIP Dynamic Deep Caching docs

Posted by el...@apache.org.
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 696caf1361750f797bdfe8fa540fdb8f542ad451
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Mon Nov 6 16:50:31 2017 -0700

    WIP Dynamic Deep Caching docs
---
 docs/source/admin/traffic_ops/using.rst | 84 +++++++++++++++++++++++++++++----
 1 file changed, 76 insertions(+), 8 deletions(-)

diff --git a/docs/source/admin/traffic_ops/using.rst b/docs/source/admin/traffic_ops/using.rst
index 7a78bd1..19fb72a 100644
--- a/docs/source/admin/traffic_ops/using.rst
+++ b/docs/source/admin/traffic_ops/using.rst
@@ -306,6 +306,10 @@ The fields in the Delivery Service view are:
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Content Routing Type                             | The type of content routing this delivery service will use. See :ref:`rl-ds-types`.                                                                                                                                 |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| Deep Caching                                     | (for HTTP routed delivery services only) When to do deep caching for this delivery service (see :ref:`Deep Caching <insert-ref-here>` for more details:                                                             |
+|                                                  | - NEVER                                                                                                                                                                                                             |
+|                                                  | - ALWAYS                                                                                                                                                                                                            |
++--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Delivery Service DNS TTL                         | The Time To Live on the DNS record for the Traffic Router A and AAAA records (``<routing-name>.<deliveryservice>.<cdn-domain>``).                                                                                   |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Delivery Servics URLs                            | (Read Only) An example of how the delivery URL may start. This could be multiple rows if multiple HOST_REGEXP entries have been entered.                                                                            |
@@ -846,23 +850,31 @@ The Coverage Zone File (CZF) should contain a cachegroup name to network prefix
   {
     "coverageZones": {
       "cache-group-01": {
+        "coordinates": {
+          "latitude":  1.1,
+          "longitude": 2.2,
+        },
         "network6": [
-          "1234:5678::\/64",
-          "1234:5679::\/64"
+          "1234:5678::/64",
+          "1234:5679::/64"
         ],
         "network": [
-          "192.168.8.0\/24",
-          "192.168.9.0\/24"
+          "192.168.8.0/24",
+          "192.168.9.0/24"
         ]
       }
       "cache-group-02": {
+        "coordinates": {
+          "latitude":  3.3,
+          "longitude": 4.4,
+        },
         "network6": [
-          "1234:567a::\/64",
-          "1234:567b::\/64"
+          "1234:567a::/64",
+          "1234:567b::/64"
         ],
         "network": [
-          "192.168.4.0\/24",
-          "192.168.5.0\/24"
+          "192.168.4.0/24",
+          "192.168.5.0/24"
         ]
       }
     }
@@ -872,6 +884,62 @@ The CZF is an input to the Traffic Control CDN, and as such does not get generat
 
 The script that generates the CZF file is not part of Traffic Control, since it is different for each situation.
 
+.. note:: The "coordinates" section is optional and may be used by Traffic Router for localization in the case of a CZF "hit" where the zone name does not map to a Cache Group name in Traffic Ops (i.e. Traffic Router will route to the closest Cache Group(s) geographically).
+
+.. _rl-deep-czf:
+
+The Deep Coverage Zone File
++++++++++++++++++++++++++++
+The Deep Coverage Zone File (DCZF) format is similar the CZF format but contains a ``caches`` list under each ``coverageZone``: ::
+
+  {
+    "coverageZones": {
+      "location-01": {
+        "coordinates": {
+          "latitude":  5.5,
+          "longitude": 6.6,
+        },
+        "network6": [
+          "1234:5678::/64",
+          "1234:5679::/64"
+        ],
+        "network": [
+          "192.168.8.0/24",
+          "192.168.9.0/24"
+        ],
+        "caches": [
+          "edge-01",
+          "edge-02"
+        ]
+      }
+      "location-02": {
+        "coordinates": {
+          "latitude":  7.7,
+          "longitude": 8.8,
+        },
+        "network6": [
+          "1234:567a::/64",
+          "1234:567b::/64"
+        ],
+        "network": [
+          "192.168.4.0/24",
+          "192.168.5.0/24"
+        ],
+        "caches": [
+          "edge-02",
+          "edge-03"
+        ]
+      }
+    }
+  }
+
+Each entry in the ``caches`` list is the hostname of an edge cache registered in Traffic Ops which will be used for "deep" caching in that Deep Coverage Zone. Unlike a regular CZF, coverage zones in the DCZF do not map to a Cache Group in Traffic Ops, so currently the deep coverage zone name can be chosen arbitrarily.
+
+If the Traffic Router gets a DCZF "hit" for a requested Delivery Service that has Deep Caching enabled, the client will be routed to an available "deep" cache from that zone's ``caches`` list.
+
+.. note:: The "coordinates" section is optional.
+
+
 .. _rl-working-with-profiles:
 
 Parameters and Profiles

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 25/36: Show Deep Caching field for STEERING Delivery Services

Posted by el...@apache.org.
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 23fa917f9a0e9fd6ee76a25a25ee934e9a707f6e
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Thu Nov 9 14:16:21 2017 -0700

    Show Deep Caching field for STEERING Delivery Services
---
 traffic_ops/app/templates/delivery_service/add.html.ep  | 2 +-
 traffic_ops/app/templates/delivery_service/edit.html.ep | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/traffic_ops/app/templates/delivery_service/add.html.ep b/traffic_ops/app/templates/delivery_service/add.html.ep
index c2f0841..26ea456 100644
--- a/traffic_ops/app/templates/delivery_service/add.html.ep
+++ b/traffic_ops/app/templates/delivery_service/add.html.ep
@@ -235,7 +235,7 @@
             $('#range_request_handlingi_row').hide(speed);
             $('#dns_bypass_ip_row').hide(speed);
             $('#dns_bypass_ip6_row').hide(speed);
-            $('#deep_caching_type').hide(speed);
+            $('#deep_caching_type').show(speed);
 			$('#regional_geo_blocking_row').show(speed);
 	    	$('#dns_bypass_cname_row').hide(speed);
             $('#dns_bypass_ttl_row').hide(speed);
diff --git a/traffic_ops/app/templates/delivery_service/edit.html.ep b/traffic_ops/app/templates/delivery_service/edit.html.ep
index 699361a..223e210 100644
--- a/traffic_ops/app/templates/delivery_service/edit.html.ep
+++ b/traffic_ops/app/templates/delivery_service/edit.html.ep
@@ -327,7 +327,7 @@ function setup_form(speed) {
             $('#range_request_handlingi_row').hide(speed);
             $('#dns_bypass_ip_row').hide(speed);
             $('#dns_bypass_ip6_row').hide(speed);
-            $('#deep_caching_type').hide(speed);
+            $('#deep_caching_type').show(speed);
 			$('#regional_geo_blocking_row').show(speed);
 	    	$('#dns_bypass_cname_row').hide(speed);
             $('#dns_bypass_ttl_row').hide(speed);

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 30/36: Update API ref to show deepCachingType is now a string

Posted by el...@apache.org.
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 efefb8b30e63adbe3ffc165e0d5d73ca1084e061
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Fri Nov 10 16:24:18 2017 -0700

    Update API ref to show deepCachingType is now a string
---
 docs/source/admin/traffic_ops/using.rst            |  4 +-
 .../traffic_ops_api/v12/deliveryservice.rst        | 56 +++++++++++-----------
 .../development/traffic_ops_api/v12/server.rst     |  8 ++--
 .../development/traffic_ops_api/v12/user.rst       |  8 ++--
 4 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/docs/source/admin/traffic_ops/using.rst b/docs/source/admin/traffic_ops/using.rst
index 6a6c130..b11e20d 100644
--- a/docs/source/admin/traffic_ops/using.rst
+++ b/docs/source/admin/traffic_ops/using.rst
@@ -308,8 +308,8 @@ The fields in the Delivery Service view are:
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Deep Caching                                     | (for HTTP routed delivery services only) When to do deep caching for this delivery service (see :ref:`Deep Caching <rl-deep-cache>` for more details):                                                              |
 |                                                  |                                                                                                                                                                                                                     |
-|                                                  | - 0 - NEVER                                                                                                                                                                                                         |
-|                                                  | - 1 - ALWAYS                                                                                                                                                                                                        |
+|                                                  | - NEVER                                                                                                                                                                                                             |
+|                                                  | - ALWAYS                                                                                                                                                                                                            |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Delivery Service DNS TTL                         | The Time To Live on the DNS record for the Traffic Router A and AAAA records (``<routing-name>.<deliveryservice>.<cdn-domain>``).                                                                                   |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
diff --git a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
index 42005f7..6dee578 100644
--- a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
+++ b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
@@ -66,10 +66,10 @@ Delivery Service
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  | ``deepCachingType``      | string | When to do Deep Caching for this Delivery Service:                                                                                   |
   |                          |        |                                                                                                                                      |
-  |                          |        | - 0: NEVER (default)                                                                                                                 |
-  |                          |        | - 1: ALWAYS                                                                                                                          |
+  |                          |        | - NEVER (default)                                                                                                                    |
+  |                          |        | - ALWAYS                                                                                                                             |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -211,7 +211,7 @@ Delivery Service
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
-            "deepCachingType": 0,
+            "deepCachingType": "NEVER",
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
@@ -307,10 +307,10 @@ Delivery Service
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  | ``deepCachingType``      | string | When to do Deep Caching for this Delivery Service:                                                                                   |
   |                          |        |                                                                                                                                      |
-  |                          |        | - 0: NEVER (default)                                                                                                                 |
-  |                          |        | - 1: ALWAYS                                                                                                                          |
+  |                          |        | - NEVER (default)                                                                                                                    |
+  |                          |        | - ALWAYS                                                                                                                             |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -460,7 +460,7 @@ Delivery Service
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
-            "deepCachingType": 0,
+            "deepCachingType": "NEVER",
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
@@ -1930,10 +1930,10 @@ URL Sig Keys
   +----------------------------------------+--------+----------+---------------------------------------------------------------------------------------------+
   | ``>customer``                          | string | yes      | Name of the customer to associated with the delivery service.                               |
   +----------------------------------------+--------+----------+---------------------------------------------------------------------------------------------+
-  | ``>deepCachingType``                   |  int   | no       | When to do Deep Caching for this Delivery Service:                                          |
+  | ``>deepCachingType``                   | string | no       | When to do Deep Caching for this Delivery Service:                                          |
   |                                        |        |          |                                                                                             |
-  |                                        |        |          | - 0: NEVER (default)                                                                        |
-  |                                        |        |          | - 1: ALWAYS                                                                                 |
+  |                                        |        |          | - NEVER (default)                                                                           |
+  |                                        |        |          | - ALWAYS                                                                                    |
   +----------------------------------------+--------+----------+---------------------------------------------------------------------------------------------+
   | ``>deliveryProtocol``                  | string | yes      | Eg. http or http/https                                                                      |
   +----------------------------------------+--------+----------+---------------------------------------------------------------------------------------------+
@@ -1995,7 +1995,7 @@ URL Sig Keys
        "details": {
           "customer": "XYZ Corporation",
           "contentType": "video-on-demand",
-          "deepCachingType": 0,
+          "deepCachingType": "NEVER",
           "deliveryProtocol": "http",
           "routingType": "dns",
           "routingName": "foo",
@@ -2082,8 +2082,8 @@ URL Sig Keys
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | deepCachingType        | no       | When to do Deep Caching for this Delivery Service:                                                      |
   |                        |          |                                                                                                         |
-  |                        |          | - 0: NEVER (default)                                                                                    |
-  |                        |          | - 1: ALWAYS                                                                                             |
+  |                        |          | - NEVER (default)                                                                                       |
+  |                        |          | - ALWAYS                                                                                                |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | displayName            | yes      | Display name                                                                                            |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
@@ -2255,10 +2255,10 @@ URL Sig Keys
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  | ``deepCachingType``      | string | When to do Deep Caching for this Delivery Service:                                                                                   |
   |                          |        |                                                                                                                                      |
-  |                          |        | - 0: NEVER (default)                                                                                                                 |
-  |                          |        | - 1: ALWAYS                                                                                                                          |
+  |                          |        | - NEVER (default)                                                                                                                    |
+  |                          |        | - ALWAYS                                                                                                                             |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -2404,7 +2404,7 @@ URL Sig Keys
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
-            "deepCachingType": 0,
+            "deepCachingType": "NEVER",
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
@@ -2503,8 +2503,8 @@ URL Sig Keys
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | deepCachingType        | no       | When to do Deep Caching for this Delivery Service:                                                      |
   |                        |          |                                                                                                         |
-  |                        |          | - 0: NEVER (default)                                                                                    |
-  |                        |          | - 1: ALWAYS                                                                                             |
+  |                        |          | - NEVER (default)                                                                                       |
+  |                        |          | - ALWAYS                                                                                                |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | displayName            | yes      | Display name                                                                                            |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
@@ -2676,10 +2676,10 @@ URL Sig Keys
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  | ``deepCachingType``      | string | When to do Deep Caching for this Delivery Service:                                                                                   |
   |                          |        |                                                                                                                                      |
-  |                          |        | - 0: NEVER (default)                                                                                                                 |
-  |                          |        | - 1: ALWAYS                                                                                                                          |
+  |                          |        | - NEVER (default)                                                                                                                    |
+  |                          |        | - ALWAYS                                                                                                                             |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -2825,7 +2825,7 @@ URL Sig Keys
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
-            "deepCachingType": 0,
+            "deepCachingType": "NEVER",
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
@@ -2951,10 +2951,10 @@ URL Sig Keys
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  | ``deepCachingType``      | string | When to do Deep Caching for this Delivery Service:                                                                                   |
   |                          |        |                                                                                                                                      |
-  |                          |        | - 0: NEVER (default)                                                                                                                 |
-  |                          |        | - 1: ALWAYS                                                                                                                          |
+  |                          |        | - NEVER (default)                                                                                                                    |
+  |                          |        | - ALWAYS                                                                                                                             |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -3100,7 +3100,7 @@ URL Sig Keys
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
-            "deepCachingType": 0,
+            "deepCachingType": "NEVER",
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
diff --git a/docs/source/development/traffic_ops_api/v12/server.rst b/docs/source/development/traffic_ops_api/v12/server.rst
index 9b2a42b..779f19a 100644
--- a/docs/source/development/traffic_ops_api/v12/server.rst
+++ b/docs/source/development/traffic_ops_api/v12/server.rst
@@ -378,10 +378,10 @@ Server
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  | ``deepCachingType``      | string | When to do Deep Caching for this Delivery Service:                                                                                   |
   |                          |        |                                                                                                                                      |
-  |                          |        | - 0: NEVER (default)                                                                                                                 |
-  |                          |        | - 1: ALWAYS                                                                                                                          |
+  |                          |        | - NEVER (default)                                                                                                                    |
+  |                          |        | - ALWAYS                                                                                                                             |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -521,7 +521,7 @@ Server
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
-            "deepCachingType": 0,
+            "deepCachingType": "NEVER",
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",
diff --git a/docs/source/development/traffic_ops_api/v12/user.rst b/docs/source/development/traffic_ops_api/v12/user.rst
index b589a3b..27efc22 100644
--- a/docs/source/development/traffic_ops_api/v12/user.rst
+++ b/docs/source/development/traffic_ops_api/v12/user.rst
@@ -454,10 +454,10 @@ Users
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  | ``deepCachingType``      | string | When to do Deep Caching for this Delivery Service:                                                                                   |
   |                          |        |                                                                                                                                      |
-  |                          |        | - 0: NEVER (default)                                                                                                                 |
-  |                          |        | - 1: ALWAYS                                                                                                                          |
+  |                          |        | - NEVER (default)                                                                                                                    |
+  |                          |        | - ALWAYS                                                                                                                             |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``displayName``          | string | The display name of the delivery service.                                                                                            |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -597,7 +597,7 @@ Users
             "cdnId": "2",
             "cdnName": "over-the-top",
             "checkPath": "",
-            "deepCachingType": 0,
+            "deepCachingType": "NEVER",
             "displayName": "My Cool Delivery Service",
             "dnsBypassCname": "",
             "dnsBypassIp": "",

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 26/36: Change deep_caching_type from an int to an ENUM

Posted by el...@apache.org.
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 d8612e76afa587cf8387bc1a142255787d4c2c23
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Thu Nov 9 16:50:36 2017 -0700

    Change deep_caching_type from an int to an ENUM
---
 lib/go-tc/deliveryservices.go                      |  2 +-
 .../20171101000000_add_deep_caching_type.sql       |  8 ++++--
 traffic_ops/app/lib/API/Deliveryservice.pm         |  2 +-
 traffic_ops/app/lib/Fixtures/Deliveryservice.pm    | 30 +++++++++++-----------
 .../lib/Fixtures/Integration/Deliveryservice.pm    | 16 ++++++------
 .../app/lib/Schema/Result/Deliveryservice.pm       | 26 +++++++++++--------
 traffic_ops/app/t/api/1.2/deliveryservice.t        | 10 ++++----
 traffic_ops/app/t/api/1.2/deliveryservice_crud.t   | 26 +++++++++----------
 traffic_ops/app/t/deliveryservice.t                | 10 ++++----
 .../app/templates/delivery_service/_form.html.ep   |  9 +++----
 .../client_tests/fixtures/delivery_service.go      |  2 +-
 .../client_tests/fixtures/traffic_router_config.go |  2 +-
 .../tests/integration/deliveryservice_test.go      |  2 +-
 .../FormDeliveryServiceController.js               |  4 +--
 14 files changed, 77 insertions(+), 72 deletions(-)

diff --git a/lib/go-tc/deliveryservices.go b/lib/go-tc/deliveryservices.go
index 6c1f381..b27b655 100644
--- a/lib/go-tc/deliveryservices.go
+++ b/lib/go-tc/deliveryservices.go
@@ -56,7 +56,7 @@ type DeliveryService struct {
 	Active               bool                   `json:"active"`
 	DSCP                 int                    `json:"dscp"`
 	RoutingName          string                 `json:"routingName"`
-	DeepCachingType      int                    `json:"deepCachingType"`
+	DeepCachingType      string                 `json:"deepCachingType"`
 	Signed               bool                   `json:"signed"`
 	QStringIgnore        int                    `json:"qstringIgnore"`
 	GeoLimit             int                    `json:"geoLimit"`
diff --git a/traffic_ops/app/db/migrations/20171101000000_add_deep_caching_type.sql b/traffic_ops/app/db/migrations/20171101000000_add_deep_caching_type.sql
index 17c78cc..7c6d94b 100644
--- a/traffic_ops/app/db/migrations/20171101000000_add_deep_caching_type.sql
+++ b/traffic_ops/app/db/migrations/20171101000000_add_deep_caching_type.sql
@@ -15,9 +15,13 @@
 -- +goose Up
 -- SQL in section 'Up' is executed when this migration is applied
 
-alter table deliveryservice add column deep_caching_type smallint default 0;
+CREATE TYPE deep_caching_type AS ENUM ('NEVER', 'ALWAYS');
+
+ALTER TABLE deliveryservice ADD COLUMN deep_caching_type deep_caching_type DEFAULT 'NEVER';
 
 -- +goose Down
 -- SQL section 'Down' is executed when this migration is rolled back
 
- alter table deliveryservice drop column deep_caching_type;
+ALTER TABLE deliveryservice DROP COLUMN IF EXISTS deep_caching_type;
+
+DROP TYPE IF EXISTS deep_caching_type;
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm b/traffic_ops/app/lib/API/Deliveryservice.pm
index b78b5a7..675c1da 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -1387,7 +1387,7 @@ sub is_deliveryservice_valid {
 			active				=> [ is_required("is required") ],
 			cdnId				=> [ is_required("is required"), \&is_valid_int_or_undef ],
 			ccrDnsTtl			=> [ \&is_valid_int_or_undef ],
-			deepCachingType      => [ is_like( qr/^[01]$/, "must be 0 (never) or 1 (always)" ) ],
+			deepCachingType      => [ is_like( qr/^NEVER|ALWAYS$/, "must be NEVER or ALWAYS" ) ],
 			dnsBypassTtl			=> [ \&is_valid_int_or_undef ],
 			dscp				=> [ is_required("is required"), \&is_valid_int_or_undef ],
 			displayName			=> [ is_required("is required"), is_long_at_most( 48, 'too long' ) ],
diff --git a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
index 7cd06dc..4069ccc 100644
--- a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
@@ -27,7 +27,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -67,7 +67,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -107,7 +107,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -147,7 +147,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -187,7 +187,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -227,7 +227,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -267,7 +267,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -305,7 +305,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -343,7 +343,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -381,7 +381,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -419,7 +419,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -457,7 +457,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -495,7 +495,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -533,7 +533,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => 10**9,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -573,7 +573,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
-			deep_caching_type     => 0,
+			deep_caching_type     => 'NEVER',
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
index 6578119..c4e3a3a 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
@@ -47,7 +47,7 @@ my %definition_for = (
 			type                        => '16',
 			dns_bypass_ip6              => undef,
 			dscp                        => '40',
-			deep_caching_type           => 0,
+			deep_caching_type           => 'NEVER',
 			routing_name                => 'foo',
 			mid_header_rewrite          => 'cond %{REMAP_PSEUDO_HOOK} __RETURN__ set-config proxy.config.http.parent_origin.dead_server_retry_enabled 1',
 			active                      => '1',
@@ -122,7 +122,7 @@ my %definition_for = (
 			max_dns_answers             => '0',
 			miss_lat                    => '41.881944',
 			dscp                        => '40',
-			deep_caching_type           => 0,
+			deep_caching_type           => 'NEVER',
 			routing_name                => 'foo',
 			mid_header_rewrite          => undef,
 			regex_remap                 => undef,
@@ -145,7 +145,7 @@ my %definition_for = (
 			qstring_ignore              => '0',
 			ccr_dns_ttl                 => '3600',
 			dscp                        => '40',
-			deep_caching_type           => 0,
+			deep_caching_type           => 'NEVER',
 			routing_name                => 'foo',
 			last_updated                => '2015-12-10 15:44:37',
 			org_server_fqdn             => 'http://images.origin.kabletown.net',
@@ -197,7 +197,7 @@ my %definition_for = (
 			mid_header_rewrite	 				=>
 				'cond %{REMAP_PSEUDO_HOOK} __RETURN__ set-config proxy.config.http.parent_origin.dead_server_retry_enabled 1__RETURN__ set-config proxy.config.http.parent_origin.simple_retry_enabled 1__RETURN__ set-config proxy.config.http.parent_origin.simple_retry_response_codes "400,404,412"__RETURN__ set-config proxy.config.http.parent_origin.dead_server_retry_response_codes "502,503" __RETURN__ set-config proxy.config.http.connect_attempts_timeout 2 __RETURN__ set-config proxy.config.http.conne [...]
 			dscp                        => '40',
-			deep_caching_type           => 0,
+			deep_caching_type           => 'NEVER',
 			routing_name                => 'foo',
 			info_url                    => 'http://movies.info.kabletown.net',
 			last_updated                => '2015-12-10 15:44:37',
@@ -255,7 +255,7 @@ my %definition_for = (
 			regex_remap                 => undef,
 			dns_bypass_ip6              => undef,
 			dscp                        => '40',
-			deep_caching_type           => 0,
+			deep_caching_type           => 'NEVER',
 			routing_name                => 'foo',
 			range_request_handling      => '0',
 			display_name                => 'tv-c1',
@@ -310,7 +310,7 @@ my %definition_for = (
 			check_path                  => '/crossdomain.xml',
 			dns_bypass_cname            => undef,
 			dscp                        => '40',
-			deep_caching_type           => 0,
+			deep_caching_type           => 'NEVER',
 			routing_name                => 'foo',
 			remap_text                  => undef,
 			global_max_mbps             => '0',
@@ -362,7 +362,7 @@ my %definition_for = (
 			ccr_dns_ttl                 => '3600',
 			dns_bypass_cname            => undef,
 			dscp                        => '40',
-			deep_caching_type           => 0,
+			deep_caching_type           => 'NEVER',
 			routing_name                => 'foo',
 			global_max_tps              => '0',
 			initial_dispersion          => '1',
@@ -401,7 +401,7 @@ my %definition_for = (
 			signing_algorithm           => undef,
 			dns_bypass_cname            => undef,
 			dscp                        => '40',
-			deep_caching_type           => 0,
+			deep_caching_type           => 'NEVER',
 			routing_name                => 'foo',
 			geo_limit                   => '0',
 			initial_dispersion          => '1',
diff --git a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
index d2e64f8..b458b40 100644
--- a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
@@ -49,7 +49,6 @@ __PACKAGE__->table("deliveryservice");
 =head2 signing_algorithm
 
   data_type: 'deliveryservice_signature_type'
-  default_value: null
   is_nullable: 1
 
 =head2 qstring_ignore
@@ -302,8 +301,9 @@ __PACKAGE__->table("deliveryservice");
 
 =head2 deep_caching_type
 
-  data_type: 'smallint'
-  default_value: 0
+  data_type: 'enum'
+  default_value: 'NEVER'
+  extra: {custom_type_name => "deep_caching_type",list => ["NEVER","ALWAYS"]}
   is_nullable: 1
 
 =cut
@@ -323,11 +323,7 @@ __PACKAGE__->add_columns(
   "dscp",
   { data_type => "bigint", is_nullable => 0 },
   "signing_algorithm",
-  {
-    data_type     => "deliveryservice_signature_type",
-    default_value => \"null",
-    is_nullable   => 1,
-  },
+  { data_type => "deliveryservice_signature_type", is_nullable => 1 },
   "qstring_ignore",
   { data_type => "smallint", is_nullable => 1 },
   "geo_limit",
@@ -426,7 +422,15 @@ __PACKAGE__->add_columns(
   "routing_name",
   { data_type => "text", default_value => "cdn", is_nullable => 0 },
   "deep_caching_type",
-  { data_type => "smallint", default_value => 0, is_nullable => 1 },
+  {
+    data_type => "enum",
+    default_value => "NEVER",
+    extra => {
+      custom_type_name => "deep_caching_type",
+      list => ["NEVER", "ALWAYS"],
+    },
+    is_nullable => 1,
+  },
 );
 
 =head1 PRIMARY KEY
@@ -662,8 +666,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-10-12 15:07:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:JOlBU3gXo4iidTQarqMAcA
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-11-09 14:44:59
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IA1IQ3w/BEYermjf9PoVtA
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 #
diff --git a/traffic_ops/app/t/api/1.2/deliveryservice.t b/traffic_ops/app/t/api/1.2/deliveryservice.t
index 6c3f3bf..c34eb76 100644
--- a/traffic_ops/app/t/api/1.2/deliveryservice.t
+++ b/traffic_ops/app/t/api/1.2/deliveryservice.t
@@ -82,7 +82,7 @@ $t->get_ok('/api/1.2/deliveryservices/100/servers/eligible')->status_is(200)->$c
 ok $t->get_ok("/api/1.2/deliveryservices")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } )
 		->json_is( "/response/0/xmlId", "steering-ds1" )
 		->json_is( "/response/0/routingName", "foo" )
-		->json_is( "/response/0/deepCachingType", 0 )
+		->json_is( "/response/0/deepCachingType", "NEVER" )
 		->json_is( "/response/0/logsEnabled", 0 )
 		->json_is( "/response/0/ipv6RoutingEnabled", 1 )
 		->json_is( "/response/1/xmlId", "steering-ds2" );
@@ -230,7 +230,7 @@ ok $t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
         ->json_is( "/response/0/tenantId" => $tenant_id)
         ->json_is( "/response/0/cdnName" => "cdn1")
 		->json_is( "/response/0/routingName" => "foo")
-		->json_is( "/response/0/deepCachingType" => 0)
+		->json_is( "/response/0/deepCachingType" => "NEVER")
 		->json_is( "/response/0/displayName" => "ds_displayname_1")
 		->json_is( "/response/0/xmlId" => "ds_1")
 		->json_is( "/response/0/multiSiteOrigin" => 0)
@@ -269,7 +269,7 @@ ok $t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
 		->json_is( "/response/0/displayName" => "ds_displayname_11")
 		->json_is( "/response/0/xmlId" => "ds_1")
 		->json_is( "/response/0/routingName" => "bar")
-		->json_is( "/response/0/deepCachingType" => 0)
+		->json_is( "/response/0/deepCachingType" => "NEVER")
 		->json_is( "/response/0/multiSiteOrigin" => 0)
 		->json_is( "/response/0/orgServerFqdn" => "http://10.75.168.91")
 		->json_is( "/response/0/protocol" => 2)
@@ -282,7 +282,7 @@ ok $t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
 				"displayName" => "ds_displayname_11",
 				"dscp" => 1,
 				"routingName" => "baz",
-				"deepCachingType" => 0,
+				"deepCachingType" => "NEVER",
 				"geoLimit" => 1,
 				"geoProvider" => 1,
 				"ipv6RoutingEnabled" => 1,
@@ -312,7 +312,7 @@ ok $t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
 				"displayName" => "ds_displayname_11",
 				"dscp" => 1,
 				"routingName" => "foo",
-				"deepCachingType" => 0,
+				"deepCachingType" => "NEVER",
 				"geoLimit" => 1,
 				"geoProvider" => 1,
 				"initialDispersion" => 2,
diff --git a/traffic_ops/app/t/api/1.2/deliveryservice_crud.t b/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
index cb36541..fe666d0 100644
--- a/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
+++ b/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
@@ -62,7 +62,7 @@ sub run_ut {
 	ok $t->get_ok("/api/1.2/deliveryservices")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } )
 			->json_is( "/response/0/xmlId", "steering-ds1" )
 			->json_is( "/response/0/routingName", "foo" )
-			->json_is( "/response/0/deepCachingType", 0)
+			->json_is( "/response/0/deepCachingType", "NEVER")
 			->json_is( "/response/0/logsEnabled", 0 )
 			->json_is( "/response/0/ipv6RoutingEnabled", 1 )
 			->json_is( "/response/1/xmlId", "steering-ds2" );
@@ -144,7 +144,7 @@ sub run_ut {
         	"active" => "false",
         	"dscp" => 0,
         	"routingName" => "foo",
-			"deepCachingType" => 0,
+        	"deepCachingType" => "NEVER",
         	"ipv6RoutingEnabled" => "true",
         	"logsEnabled" => "true",
         	"initialDispersion" => 1,
@@ -161,7 +161,7 @@ sub run_ut {
 	    ->json_is( "/response/0/orgServerFqdn" => "http://10.75.168.91")
 	    ->json_is( "/response/0/cdnId" => 100)
 	    ->json_is( "/response/0/routingName" => "foo")
-	    ->json_is( "/response/0/deepCachingType" => 0)
+	    ->json_is( "/response/0/deepCachingType" => "NEVER")
 	    ->json_is( "/response/0/tenantId" => $tenant_id)
 	    ->json_is( "/response/0/profileId" => 300)
 	    ->json_is( "/response/0/protocol" => "1")
@@ -180,7 +180,7 @@ sub run_ut {
 	    ->json_is( "/response/0/orgServerFqdn" => "http://10.75.168.91")
 	    ->json_is( "/response/0/cdnId" => 100)
 	    ->json_is( "/response/0/routingName" => "foo")
-	    ->json_is( "/response/0/deepCachingType" => 0)
+	    ->json_is( "/response/0/deepCachingType" => "NEVER")
 	    ->json_is( "/response/0/tenantId" => $tenant_id)
 	    ->json_is( "/response/0/tenant" => $tenant_name)
 	    ->json_is( "/response/0/profileId" => 300)
@@ -208,7 +208,7 @@ sub run_ut {
 	        "active" => "false",
 	        "dscp" => 0,
 	        "routingName" => "foo",
-	        "deepCachingType" => 0,
+	        "deepCachingType" => "NEVER",
 	        "ipv6RoutingEnabled" => "true",
 	        "logsEnabled" => "true",
 	        "initialDispersion" => 1,
@@ -251,7 +251,7 @@ sub run_ut {
 					"active"               => "false",
 					"dscp"                 => 0,
 					"routingName"          => "foo",
-					"deepCachingType"      => 0,
+					"deepCachingType"      => "NEVER",
 					"ipv6RoutingEnabled"   => "true",
 					"logsEnabled"          => "true",
 					"initialDispersion"    => 1,
@@ -285,7 +285,7 @@ sub run_ut {
 					"active"               => "false",
 					"dscp"                 => 0,
 					"routingName"          => "foo",
-					"deepCachingType"      => 0,
+					"deepCachingType"      => "NEVER",
 					"ipv6RoutingEnabled"   => "true",
 					"logsEnabled"          => "true",
 					"initialDispersion"    => 1,
@@ -319,7 +319,7 @@ sub run_ut {
        	        "active" => "false",
        	        "dscp" => 0,
        	        "routingName" => "foo",
-       	        "deepCachingType" => 0,
+       	        "deepCachingType" => "NEVER",
        	        "ipv6RoutingEnabled" => "true",
        	        "logsEnabled" => "true",
        	        "initialDispersion" => 1,
@@ -353,7 +353,7 @@ sub run_ut {
        	        "active" => "false",
        	        "dscp" => 0,
        	        "routingName" => "foo",
-       	        "deepCachingType" => 0,
+       	        "deepCachingType" => "NEVER",
        	        "ipv6RoutingEnabled" => "true",
        	        "logsEnabled" => "true",
        	        "initialDispersion" => 1,
@@ -388,7 +388,7 @@ sub run_ut {
        	        "active" => "false",
        	        "dscp" => 0,
        	        "routingName" => "foo",
-       	        "deepCachingType" => 0,
+       	        "deepCachingType" => "NEVER",
        	        "ipv6RoutingEnabled" => "true",
        	        "logsEnabled" => "true",
        	        "initialDispersion" => 1,
@@ -423,7 +423,7 @@ sub run_ut {
 	        "active" => "false",
 	        "dscp" => 0,
 	        "routingName" => "foo",
-	        "deepCachingType" => 0,
+	        "deepCachingType" => "NEVER",
 	        "ipv6RoutingEnabled" => "true",
 	        "logsEnabled" => "true",
 	        "initialDispersion" => 1,
@@ -474,7 +474,7 @@ sub run_ut {
         "active" => "false",
         "dscp" => 0,
         "routingName" => "foo",
-        "deepCachingType" => 0,
+        "deepCachingType" => "NEVER",
         "ipv6RoutingEnabled" => "true",
         "logsEnabled" => "true",
         "initialDispersion" => 1,
@@ -521,7 +521,7 @@ sub run_ut {
         "active" => "false",
         "dscp" => 0,
         "routingName" => "foo",
-        "deepCachingType" => 0,
+        "deepCachingType" => "NEVER",
         "ipv6RoutingEnabled" => "true",
         "logsEnabled" => "true",
         "initialDispersion" => 1,
diff --git a/traffic_ops/app/t/deliveryservice.t b/traffic_ops/app/t/deliveryservice.t
index 2e47697..c6b76ce 100644
--- a/traffic_ops/app/t/deliveryservice.t
+++ b/traffic_ops/app/t/deliveryservice.t
@@ -63,7 +63,7 @@ ok $t->post_ok(
 		'ds.dns_bypass_ttl'              => '30',
 		'ds.dscp'                        => '40',
 		'ds.routing_name'                => 'foo',
-		'ds.deep_caching_type'           => '0',
+		'ds.deep_caching_type'           => 'NEVER',
 		'ds.geo_limit'                   => '0',
 		'ds.geo_limit_countries'         => '',
 		'ds.geo_provider'                => '1',
@@ -116,7 +116,7 @@ ok $t->post_ok(
 		'ds.dns_bypass_ttl'              => '30',
 		'ds.dscp'                        => '42',
 		'ds.routing_name'                => '',
-		'ds.deep_caching_type'           => '0',
+		'ds.deep_caching_type'           => 'NEVER',
 		'ds.geo_limit'                   => '0',
 		'ds.geo_limit_countries'         => '',
 		'ds.global_max_mbps'             => '',
@@ -168,7 +168,7 @@ ok $t->post_ok(
 		'ds.dns_bypass_ttl'              => '30',
 		'ds.dscp'                        => '40',
 		'ds.routing_name'                => 'foo',
-		'ds.deep_caching_type'           => '0',
+		'ds.deep_caching_type'           => 'NEVER',
 		'ds.geo_limit'                   => '1',
 		'ds.geo_limit_countries'         => '',
 		'ds.global_max_mbps'             => '30G',
@@ -249,7 +249,7 @@ ok $t->post_ok(
 		'ds.dns_bypass_ttl'              => '31',
 		'ds.dscp'                        => '41',
 		'ds.routing_name'                => 'bar',
-		'ds.deep_caching_type'           => '0',
+		'ds.deep_caching_type'           => 'NEVER',
 		'ds.geo_limit'                   => '2',
 		'ds.geo_limit_countries'         => '',
 		'ds.geo_provider'                => '1',
@@ -298,7 +298,7 @@ ok $t->get_ok('/datadeliveryservice')->status_is(200)
   ->or( sub { diag $t->tx->res->content->asset->{content}; } )
   ->json_is( '/1/dscp' => '41' )
   ->json_is( '/1/routing_name' => 'bar' )
-  ->json_is( '/1/deep_caching_type' => '0' )
+  ->json_is( '/1/deep_caching_type' => 'NEVER' )
   ->json_is( '/1/active' => '0' )
   ->json_is( '/1/profile_description' => 'mid description' )
   ->json_is( '/1/org_server_fqdn'     => 'http://update.knutsel.com' )
diff --git a/traffic_ops/app/templates/delivery_service/_form.html.ep b/traffic_ops/app/templates/delivery_service/_form.html.ep
index 50d1802..b2e0156 100644
--- a/traffic_ops/app/templates/delivery_service/_form.html.ep
+++ b/traffic_ops/app/templates/delivery_service/_form.html.ep
@@ -623,13 +623,10 @@
 		<% } %>
 		%= label_for 'deep_caching_type' => '* Deep Caching', class => 'label'
 		<% if ($priv_level >= 20) { %>
-		%= field('ds.deep_caching_type')->select([["Never" => 0], ["Always" => 1]]);
+		%= field('ds.deep_caching_type')->select([["NEVER" => "NEVER"], ["ALWAYS" => "ALWAYS"]]);
 		<% } else { %>
-			<%  if ($ds->deep_caching_type == 0 ) {%>
-				%= field('ds.deep_caching_type')->text(class => 'field', readonly => 'readonly', value => 'Never');
-			<% } elsif ($ds->deep_caching_type == 1 ) {%>
-				%= field('ds.deep_caching_type')->text(class => 'field', readonly => 'readonly', value => 'Always');
-			<% } %>
+		%= field('ds.deep_caching_type')->text(class => 'field', readonly => 'readonly', value => $ds->deep_caching_type);
+
 		<% } %>
 	</div>
 </div>
diff --git a/traffic_ops/client_tests/fixtures/delivery_service.go b/traffic_ops/client_tests/fixtures/delivery_service.go
index dcc714b..f7c7cc9 100644
--- a/traffic_ops/client_tests/fixtures/delivery_service.go
+++ b/traffic_ops/client_tests/fixtures/delivery_service.go
@@ -26,7 +26,7 @@ func DeliveryServices() *client.GetDeliveryServiceResponse {
 				XMLID:                "ds-test",
 				Active:               true,
 				DSCP:                 40,
-				DeepCachingType:      0,
+				DeepCachingType:      "NEVER",
 				RoutingName:          "edge",
 				Signed:               false,
 				QStringIgnore:        1,
diff --git a/traffic_ops/client_tests/fixtures/traffic_router_config.go b/traffic_ops/client_tests/fixtures/traffic_router_config.go
index b4508b3..82ee5fe 100644
--- a/traffic_ops/client_tests/fixtures/traffic_router_config.go
+++ b/traffic_ops/client_tests/fixtures/traffic_router_config.go
@@ -114,7 +114,7 @@ func TrafficRouterConfig() *client.TRConfigResponse {
 						"ga.atlanta.kabletown.net",
 					},
 					RoutingName:     "edge",
-					DeepCachingType: 0,
+					DeepCachingType: "NEVER",
 					MissLocation: client.MissLocation{
 						Latitude:  75,
 						Longitude: 65,
diff --git a/traffic_ops/client_tests/tests/integration/deliveryservice_test.go b/traffic_ops/client_tests/tests/integration/deliveryservice_test.go
index 14193af..b2fb797 100644
--- a/traffic_ops/client_tests/tests/integration/deliveryservice_test.go
+++ b/traffic_ops/client_tests/tests/integration/deliveryservice_test.go
@@ -62,7 +62,7 @@ func init() {
 	testDs.CDNID = cdn.ID
 	testDs.CacheURL = "cacheURL"
 	testDs.CheckPath = "CheckPath"
-	testDs.DeepCachingType = 0
+	testDs.DeepCachingType = "NEVER"
 	testDs.DNSBypassCname = "DNSBypassCNAME"
 	testDs.DNSBypassIP = "10.10.10.10"
 	testDs.DNSBypassIP6 = "FF01:0:0:0:0:0:0:FB"
diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
index 049a11b..e554e76 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
+++ b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
@@ -129,8 +129,8 @@ var FormDeliveryServiceController = function(deliveryService, type, types, $scop
     ];
 
     $scope.deepCachingTypes = [
-        { value: 0, label: '0 - Never' },
-        { value: 1, label: '1 - Always' }
+        { value: 'NEVER', label: 'NEVER' },
+        { value: 'ALWAYS', label: 'ALWAYS' }
     ]
 
     $scope.dispersions = [

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 17/36: Code cleanup/clarifying comments

Posted by el...@apache.org.
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.

[incubator-trafficcontrol] 08/36: Make param 'deepcoveragezone.polling.url' optional

Posted by el...@apache.org.
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 ef134c5c6376e50b98733000a91ea5b560b99587
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Mon Oct 23 17:17:27 2017 -0600

    Make param 'deepcoveragezone.polling.url' optional
---
 .../cdn/traffic_control/traffic_router/core/config/ConfigHandler.java | 4 ++--
 1 file changed, 2 insertions(+), 2 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 e6bd2df..53f3188 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
@@ -553,8 +553,8 @@ public class ConfigHandler {
 
 	private void parseDeepCoverageZoneNetworkConfig(final JsonNode config) throws JsonUtilsException {
 		getDeepNetworkUpdater().setDataBaseURL(
-				JsonUtils.getString(config, "deepcoveragezone.polling.url"),
-				JsonUtils.optLong(config, "deepcoveragezone.polling.interval")
+			JsonUtils.optString(config, "deepcoveragezone.polling.url", null),
+			JsonUtils.optLong(config, "deepcoveragezone.polling.interval")
 		);
 	}
 

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 09/36: Refactor NetworkNode.generateTree() to reduce duplication

Posted by el...@apache.org.
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 714c82a0df934afb317fa3e7baff3a08799215de
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Tue Oct 24 15:27:56 2017 -0600

    Refactor NetworkNode.generateTree() to reduce duplication
---
 .../traffic_router/core/loc/NetworkNode.java       | 69 ++++++++++------------
 1 file changed, 32 insertions(+), 37 deletions(-)

diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
index e4e32dd..bab5a2e 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
@@ -131,7 +131,7 @@ public class NetworkNode implements Comparable<NetworkNode> {
                             // ones we already know about.
                             final Cache cache = cacheRegister.getCacheMap().get(cacheHostname);
                             if (cache == null) {
-                                LOGGER.error("DDC: deep cache entry " + cacheHostname + " not found in crconfig server list!");
+                                LOGGER.warn("DDC: deep cache entry " + cacheHostname + " not found in crconfig server list (it might not belong to this CDN)");
                             } else {
                                 LOGGER.info("DDC: Adding " + cacheHostname + " to " + deepLoc.getId() + ".");
                                 deepLoc.addCache(cache);
@@ -142,42 +142,8 @@ public class NetworkNode implements Comparable<NetworkNode> {
                     }
                 }
 
-                try {
-                    for (final JsonNode network6 : JsonUtils.getJsonNode(locData, "network6")) {
-                        final String ip = network6.asText();
-
-                        try {
-                            final NetworkNode nn = new NetworkNode(ip, loc, geolocation);
-                            if (useDeep && deepLoc != null) { // for deepLoc, we add the location here; normally it gets added by setLocation.
-                                nn.setCacheLocation(deepLoc);
-                            }
-                            root.add6(nn);
-                        } catch (NetworkNodeException ex) {
-                            LOGGER.error(ex, ex);
-                            return null;
-                        }
-                    }
-                } catch (JsonUtilsException ex) {
-                    LOGGER.warn("An exception was caught while accessing the network6 key of " + loc + " in the incoming coverage zone file: " + ex.getMessage());
-                }
-
-                try {
-                    for (final JsonNode network : JsonUtils.getJsonNode(locData, "network")) {
-                        final String ip = network.asText();
-
-                        try {
-                            final NetworkNode nn = new NetworkNode(ip, loc, geolocation);
-                            if (useDeep && deepLoc != null) {
-                                nn.setCacheLocation(deepLoc);
-                            }
-                            root.add(nn);
-                        } catch (NetworkNodeException ex) {
-                            LOGGER.error(ex, ex);
-                            return null;
-                        }
-                    }
-                } catch (JsonUtilsException ex) {
-                    LOGGER.warn("An exception was caught while accessing the network key of " + loc + " in the incoming coverage zone file: " + ex.getMessage());
+                if (!addNetworkNodesToRoot(root, locData, loc, deepLoc, geolocation, useDeep)) {
+                    return null;
                 }
             }
 
@@ -199,6 +165,35 @@ public class NetworkNode implements Comparable<NetworkNode> {
         return null;
     }
 
+    private static boolean addNetworkNodesToRoot(final SuperNode root, final JsonNode locData, final String loc,
+                                                 final CacheLocation deepLoc, final Geolocation geolocation, final boolean useDeep) {
+        for (final String key : new String[]{"network6", "network"}) {
+            try {
+                for (final JsonNode network : JsonUtils.getJsonNode(locData, key)) {
+                    final String ip = network.asText();
+
+                    try {
+                        final NetworkNode nn = new NetworkNode(ip, loc, geolocation);
+                        if (useDeep && deepLoc != null) { // for deepLoc, we add the location here; normally it gets added by setLocation.
+                            nn.setCacheLocation(deepLoc);
+                        }
+                        if ("network6".equals(key)) {
+                            root.add6(nn);
+                        } else {
+                            root.add(nn);
+                        }
+                    } catch (NetworkNodeException ex) {
+                        LOGGER.error(ex, ex);
+                        return false;
+                    }
+                }
+            } catch (JsonUtilsException ex) {
+                LOGGER.warn("An exception was caught while accessing the " + key + " key of " + loc + " in the incoming coverage zone file: " + ex.getMessage());
+            }
+        }
+        return true;
+    }
+
     public NetworkNode(final String str) throws NetworkNodeException {
         this(str, null);
     }

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 11/36: Clean up DDC code in TR a bit

Posted by el...@apache.org.
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 235f4c75500326854b7d5d76ec3b38b1647c66a9
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed Oct 25 17:02:17 2017 -0600

    Clean up DDC code in TR a bit
---
 .../traffic_router/core/ds/DeliveryService.java    |  5 +--
 .../traffic_router/core/router/TrafficRouter.java  | 45 ++++++++++------------
 2 files changed, 21 insertions(+), 29 deletions(-)

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 e124fb4..7adc191 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
@@ -93,7 +93,7 @@ public class DeliveryService {
 	private final boolean acceptHttp;
 	private final boolean acceptHttps;
 	private final boolean redirectToHttps;
-	private int deepCache; // should this be final or should it be settable?
+	private final int deepCache;
 
 	// enums are hard in Java.
 	public static final int DC_NEVER   = 0;
@@ -398,9 +398,6 @@ public class DeliveryService {
 	public int getDeepCache() {
 		return deepCache;
 	}
-	public void setDeepCache(final int deepCache) {
-		this.deepCache = deepCache;
-	}
 
 
 	public boolean appendQueryString() {
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 b1b2623..76c5627 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
@@ -249,33 +249,24 @@ public class TrafficRouter {
 		// 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.
-		//boolean useDeepCZ = false;
-		// first get the cachegroup, because the popularity is by cachegroup...
-		// this is expensive, but i see no other option.
-		final CacheLocation cacheGroup = getCoverageZoneCacheLocation(request.getClientIP(), ds, false);
-		CacheLocation cacheLocation = null;
+		CacheLocation cacheLocation;
 		ResultType result = ResultType.CZ;
-		if (cacheGroup != null) {
-			// change true to a function that returns yes if the request.getPath is popular
-			//boolean isPop = isPopular(request.getPath(), ds.getId(), cacheGroup.getId());
-			if (ds.getDeepCache() == DeliveryService.DC_ALWAYS) {
-				// Deep caching is enabled and wanted for the requested URL. See if there are deep caches available
-				cacheLocation = getCoverageZoneCacheLocation(request.getClientIP(), ds, true);
-				if (cacheLocation != null && cacheLocation.getCaches().size() != 0) {
-					// Found deep caches for this client, and there are caches available there.
-					// Use the 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...
-					// set the cacheLocation to the cacheGroup found earlier.
-					result = ResultType.DEEP_CZ_MISS;
-					cacheLocation = cacheGroup;
-				}
+
+		if (ds.getDeepCache() == DeliveryService.DC_ALWAYS) {
+			// Deep caching is enabled. See if there are deep caches available
+			cacheLocation = getDeepCoverageZoneCacheLocation(request.getClientIP(), ds);
+			if (cacheLocation != null && cacheLocation.getCaches().size() != 0) {
+				// Found deep caches for this client, and there are caches available there.
+				// Use the deep cacheLocation, and set result to DEEP_CZ
+				result = ResultType.DEEP_CZ;
 			} else {
-				// Deep caching not enabled or not for this URL. Back to cachegroup.
-				cacheLocation = cacheGroup;
+				// No deep caches for this client, would have used them if there were any...
+				result = ResultType.DEEP_CZ_MISS;
+				cacheLocation = getCoverageZoneCacheLocation(request.getClientIP(), ds);
 			}
-
+		} else {
+			// Deep caching not enabled for this Delivery Service; use the regular CZ
+			cacheLocation = getCoverageZoneCacheLocation(request.getClientIP(), ds);
 		}
 
 		List<Cache>caches = selectCachesByCZ(ds, cacheLocation, track, result);
@@ -467,7 +458,7 @@ public class TrafficRouter {
 	}
 
 	private List<Cache> selectCachesByCZ(final DeliveryService ds, final CacheLocation cacheLocation, final Track track) {
-		return selectCachesByCZ(ds, cacheLocation, track, ResultType.CZ); // RestultType.CZ was the original default before DDC
+		return selectCachesByCZ(ds, cacheLocation, track, ResultType.CZ); // ResultType.CZ was the original default before DDC
 	}
 
 	private List<Cache> selectCachesByCZ(final DeliveryService ds, final CacheLocation cacheLocation, final Track track, final ResultType result) {
@@ -687,6 +678,10 @@ public class TrafficRouter {
 		return getClosestCacheLocation(cacheRegister.filterAvailableLocations(deliveryServiceId), networkNode.getGeolocation(), cacheRegister.getDeliveryService(deliveryServiceId));
 	}
 
+	public CacheLocation getDeepCoverageZoneCacheLocation(final String ip, final DeliveryService deliveryService) {
+		return getCoverageZoneCacheLocation(ip, deliveryService, true);
+	}
+
 	protected CacheLocation getCoverageZoneCacheLocation(final String ip, final DeliveryService deliveryService, final boolean useDeep) {
 		return getCoverageZoneCacheLocation(ip, deliveryService.getId(), useDeep);
 	}

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 13/36: Remove the need for deepcoveragezone.polling.initialDelay parameter

Posted by el...@apache.org.
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 dfda01a0e3f4db4452d0c9ea81db78ef04da2d5b
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Mon Oct 30 16:47:13 2017 -0600

    Remove the need for deepcoveragezone.polling.initialDelay parameter
---
 .../traffic_router/core/loc/AbstractServiceUpdater.java  | 12 +-----------
 .../traffic_router/core/loc/NetworkNode.java             | 16 ++++++++++++++--
 .../core/src/main/webapp/WEB-INF/applicationContext.xml  |  2 +-
 3 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AbstractServiceUpdater.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AbstractServiceUpdater.java
index 650bdea..3304119 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AbstractServiceUpdater.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AbstractServiceUpdater.java
@@ -48,7 +48,6 @@ public abstract class AbstractServiceUpdater {
 	protected String databaseName;
 	protected ScheduledExecutorService executorService;
 	private long pollingInterval;
-	private long initialDelay = -1;
 	protected boolean loaded = false;
 	protected ScheduledFuture<?> scheduledService;
 	private TrafficRouterManager trafficRouterManager;
@@ -93,13 +92,9 @@ public abstract class AbstractServiceUpdater {
 
 	public void init() {
 		final long pollingInterval = getPollingInterval();
-        if (initialDelay == -1) {
-             initialDelay = pollingInterval;
-        }
-
 		final Date nextFetchDate = new Date(System.currentTimeMillis() + pollingInterval);
 		LOGGER.info("[" + getClass().getSimpleName() + "] Fetching external resource " + dataBaseURL + " at interval: " + pollingInterval + " : " + TimeUnit.MILLISECONDS + " next update occurrs at " + nextFetchDate);
-		scheduledService = executorService.scheduleWithFixedDelay(updater, initialDelay, pollingInterval, TimeUnit.MILLISECONDS);
+		scheduledService = executorService.scheduleWithFixedDelay(updater, pollingInterval, pollingInterval, TimeUnit.MILLISECONDS);
 	}
 
 	@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
@@ -199,11 +194,6 @@ public abstract class AbstractServiceUpdater {
 		dataBaseURL = null;
 	}
 
-    public void setDataBaseURL(final String url, final long refresh, final long iDelay) {
-        this.initialDelay = iDelay;
-        this.setDataBaseURL(url, refresh);
-    }
-
 	public void setDataBaseURL(final String url, final long refresh) {
 		if (refresh !=0 && refresh != pollingInterval) {
 
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
index bab5a2e..0b89d2e 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
@@ -24,7 +24,7 @@ import java.util.Map;
 import java.util.TreeMap;
 import java.util.List;
 import java.util.ArrayList;
-
+import java.util.concurrent.CountDownLatch;
 
 import com.comcast.cdn.traffic_control.traffic_router.core.util.CidrAddress;
 import com.comcast.cdn.traffic_control.traffic_router.core.util.JsonUtils;
@@ -47,6 +47,7 @@ public class NetworkNode implements Comparable<NetworkNode> {
     private static NetworkNode deepInstance;
 
     private static CacheRegister cacheRegister;
+    private static final CountDownLatch cacheRegisterLatch = new CountDownLatch(1);
 
     private CidrAddress cidrAddress;
     private String loc;
@@ -84,6 +85,17 @@ public class NetworkNode implements Comparable<NetworkNode> {
 
     public static void setCacheRegister(final CacheRegister cr) {
         cacheRegister = cr;
+        cacheRegisterLatch.countDown();
+    }
+
+    public static CacheRegister getCacheRegisterBlocking() {
+        try {
+            cacheRegisterLatch.await();
+        } catch (InterruptedException e) {
+            LOGGER.warn(e);
+        } finally {
+            return cacheRegister;
+        }
     }
 
     public static NetworkNode generateTree(final File f, final boolean verifyOnly, final boolean useDeep) throws IOException  {
@@ -129,7 +141,7 @@ public class NetworkNode implements Comparable<NetworkNode> {
                             }
                             // Get the cache from the cacheregister here - don't create a new cache due to the deep file, only reuse the
                             // ones we already know about.
-                            final Cache cache = cacheRegister.getCacheMap().get(cacheHostname);
+                            final Cache cache = getCacheRegisterBlocking().getCacheMap().get(cacheHostname);
                             if (cache == null) {
                                 LOGGER.warn("DDC: deep cache entry " + cacheHostname + " not found in crconfig server list (it might not belong to this CDN)");
                             } else {
diff --git a/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml b/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml
index d416a3f..fb5cca3 100644
--- a/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml
@@ -191,7 +191,7 @@
 	</bean>
 
 	<bean id="languidState" class="com.comcast.cdn.traffic_control.traffic_router.core.util.LanguidState" init-method="init"
-		depends-on="geolocationDatabaseUpdater, networkUpdater, regionalGeoUpdater, MonitorWatcher, trafficRouterManager, ConfigHandler">
+		depends-on="geolocationDatabaseUpdater, networkUpdater, deepNetworkUpdater, regionalGeoUpdater, MonitorWatcher, trafficRouterManager, ConfigHandler">
 		<!-- todo: add bean refs that can be validated inside the method called -->
 		<property name="trafficRouterManager" ref="trafficRouterManager" />
 	</bean>

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 05/36: Add DeepCachingType field to DS struct in go client

Posted by el...@apache.org.
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 bfb1b56a2ab709687b213f3895c64ea60d55cfc4
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Fri Oct 13 16:09:17 2017 -0600

    Add DeepCachingType field to DS struct in go client
---
 lib/go-tc/deliveryservices.go                                     | 1 +
 traffic_ops/client_tests/fixtures/delivery_service.go             | 1 +
 traffic_ops/client_tests/fixtures/traffic_router_config.go        | 8 ++++----
 .../client_tests/tests/integration/deliveryservice_test.go        | 2 ++
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/go-tc/deliveryservices.go b/lib/go-tc/deliveryservices.go
index 66a65b4..6c1f381 100644
--- a/lib/go-tc/deliveryservices.go
+++ b/lib/go-tc/deliveryservices.go
@@ -56,6 +56,7 @@ type DeliveryService struct {
 	Active               bool                   `json:"active"`
 	DSCP                 int                    `json:"dscp"`
 	RoutingName          string                 `json:"routingName"`
+	DeepCachingType      int                    `json:"deepCachingType"`
 	Signed               bool                   `json:"signed"`
 	QStringIgnore        int                    `json:"qstringIgnore"`
 	GeoLimit             int                    `json:"geoLimit"`
diff --git a/traffic_ops/client_tests/fixtures/delivery_service.go b/traffic_ops/client_tests/fixtures/delivery_service.go
index dd869e8..dcc714b 100644
--- a/traffic_ops/client_tests/fixtures/delivery_service.go
+++ b/traffic_ops/client_tests/fixtures/delivery_service.go
@@ -26,6 +26,7 @@ func DeliveryServices() *client.GetDeliveryServiceResponse {
 				XMLID:                "ds-test",
 				Active:               true,
 				DSCP:                 40,
+				DeepCachingType:      0,
 				RoutingName:          "edge",
 				Signed:               false,
 				QStringIgnore:        1,
diff --git a/traffic_ops/client_tests/fixtures/traffic_router_config.go b/traffic_ops/client_tests/fixtures/traffic_router_config.go
index 4dca715..b4508b3 100644
--- a/traffic_ops/client_tests/fixtures/traffic_router_config.go
+++ b/traffic_ops/client_tests/fixtures/traffic_router_config.go
@@ -8,9 +8,9 @@ package fixtures
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,7 +19,6 @@ package fixtures
  * under the License.
  */
 
-
 import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
 
 // TrafficRouterConfig returns a default TRConfigResponse to be used for testing.
@@ -114,7 +113,8 @@ func TrafficRouterConfig() *client.TRConfigResponse {
 					Domains: []string{
 						"ga.atlanta.kabletown.net",
 					},
-					RoutingName: "edge",
+					RoutingName:     "edge",
+					DeepCachingType: 0,
 					MissLocation: client.MissLocation{
 						Latitude:  75,
 						Longitude: 65,
diff --git a/traffic_ops/client_tests/tests/integration/deliveryservice_test.go b/traffic_ops/client_tests/tests/integration/deliveryservice_test.go
index 2aefc4d..14193af 100644
--- a/traffic_ops/client_tests/tests/integration/deliveryservice_test.go
+++ b/traffic_ops/client_tests/tests/integration/deliveryservice_test.go
@@ -62,6 +62,7 @@ func init() {
 	testDs.CDNID = cdn.ID
 	testDs.CacheURL = "cacheURL"
 	testDs.CheckPath = "CheckPath"
+	testDs.DeepCachingType = 0
 	testDs.DNSBypassCname = "DNSBypassCNAME"
 	testDs.DNSBypassIP = "10.10.10.10"
 	testDs.DNSBypassIP6 = "FF01:0:0:0:0:0:0:FB"
@@ -94,6 +95,7 @@ func init() {
 	testDs.RangeRequestHandling = 0
 	testDs.RegexRemap = "regexRemap"
 	testDs.RemapText = "remapText"
+	testDs.RoutingName = "edge"
 	testDs.Signed = false
 	testDs.TRResponseHeaders = "TRResponseHeaders"
 	testDs.Type = dsType.Name

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 36/36: Move loadDeepCaches() into CacheLocation and add synchronization

Posted by el...@apache.org.
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 04d86651fb6d846f2ea10a48b9fe4303b28b725c
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Tue Jan 23 17:46:43 2018 -0700

    Move loadDeepCaches() into CacheLocation and add synchronization
---
 .../traffic_router/core/cache/CacheLocation.java   | 23 +++++++++++++++++++++-
 .../traffic_router/core/router/TrafficRouter.java  | 16 ++-------------
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/cache/CacheLocation.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/cache/CacheLocation.java
index 7caf2a3..67159c1 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/cache/CacheLocation.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/cache/CacheLocation.java
@@ -23,6 +23,7 @@ import java.util.Set;
 
 import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.log4j.Logger;
 
 import com.comcast.cdn.traffic_control.traffic_router.geolocation.Geolocation;
 
@@ -31,6 +32,8 @@ import com.comcast.cdn.traffic_control.traffic_router.geolocation.Geolocation;
  */
 public class CacheLocation {
 
+	public static final Logger LOGGER = Logger.getLogger(CacheLocation.class);
+
 	private final String id;
 	private final Geolocation geolocation;
 
@@ -57,11 +60,29 @@ public class CacheLocation {
 	 *            the cache to add
 	 */
 	public void addCache(final Cache cache) {
+	    synchronized (caches) {
 			caches.put(cache.getId(), cache);
+		}
 	}
 
 	public void clearCaches() {
-		caches.clear();
+		synchronized (caches) {
+			caches.clear();
+		}
+	}
+
+	public void loadDeepCaches(final Set<String> deepCacheNames, final CacheRegister cacheRegister) {
+	    synchronized (caches) {
+			if (caches.isEmpty() && deepCacheNames != null) {
+				for (final String deepCacheName : deepCacheNames) {
+					final Cache deepCache = cacheRegister.getCacheMap().get(deepCacheName);
+					if (deepCache != null) {
+						LOGGER.debug("DDC: Adding " + deepCacheName + " to " + getId());
+						caches.put(deepCache.getId(), deepCache);
+					}
+				}
+			}
+		}
 	}
 
 	@Override
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 bb1dbb5..b63e075 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
@@ -648,9 +648,9 @@ public class TrafficRouter {
 		final DeliveryService deliveryService = cacheRegister.getDeliveryService(deliveryServiceId);
 		CacheLocation cacheLocation = networkNode.getCacheLocation();
 
-		if (useDeep && cacheLocation != null && cacheLocation.getCaches().isEmpty()) {
+		if (useDeep && cacheLocation != null) {
 			// lazily load deep Caches into the deep CacheLocation
-			loadDeepCaches(networkNode, cacheLocation);
+			cacheLocation.loadDeepCaches(networkNode.getDeepCacheNames(), cacheRegister);
 		}
 
 		if (cacheLocation != null && !getSupportingCaches(cacheLocation.getCaches(), deliveryService).isEmpty()) {
@@ -679,18 +679,6 @@ public class TrafficRouter {
 		return getClosestCacheLocation(cacheRegister.filterAvailableLocations(deliveryServiceId), networkNode.getGeolocation(), cacheRegister.getDeliveryService(deliveryServiceId));
 	}
 
-	private void loadDeepCaches(final NetworkNode networkNode, final CacheLocation cacheLocation) {
-		if (networkNode.getDeepCacheNames() != null) {
-			for (final String deepCacheName : networkNode.getDeepCacheNames()) {
-				final Cache deepCache = cacheRegister.getCacheMap().get(deepCacheName);
-				if (deepCache != null) {
-					LOGGER.debug("DDC: Adding " + deepCacheName + " to " + cacheLocation.getId());
-					cacheLocation.addCache(deepCache);
-				}
-			}
-		}
-	}
-
 	public CacheLocation getDeepCoverageZoneCacheLocation(final String ip, final DeliveryService deliveryService) {
 		return getCoverageZoneCacheLocation(ip, deliveryService, true);
 	}

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 06/36: Update TO unit/integration tests for deep_caching_type

Posted by el...@apache.org.
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 87cc97c3fa945c7e1fd459bfd510e2605f3e7af3
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Thu Oct 19 15:05:32 2017 -0600

    Update TO unit/integration tests for deep_caching_type
---
 traffic_ops/app/lib/Fixtures/Deliveryservice.pm           | 15 +++++++++++++++
 .../app/lib/Fixtures/Integration/Deliveryservice.pm       |  8 ++++++++
 traffic_ops/app/t/api/1.2/deliveryservice.t               |  7 +++++++
 traffic_ops/app/t/api/1.2/deliveryservice_crud.t          | 13 +++++++++++++
 traffic_ops/app/t/deliveryservice.t                       |  5 +++++
 5 files changed, 48 insertions(+)

diff --git a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
index 0ca854c..7cd06dc 100644
--- a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
@@ -27,6 +27,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -66,6 +67,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -105,6 +107,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -144,6 +147,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -183,6 +187,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -222,6 +227,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -261,6 +267,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -298,6 +305,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -335,6 +343,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -372,6 +381,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -409,6 +419,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -446,6 +457,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -483,6 +495,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -520,6 +533,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => 10**9,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
@@ -559,6 +573,7 @@ my %definition_for = (
 			active                => 1,
 			tenant_id             => undef,
 			dscp                  => 40,
+			deep_caching_type     => 0,
 			routing_name          => 'foo',
 			qstring_ignore        => 0,
 			geo_limit             => 0,
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
index c88ac07..6578119 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
@@ -47,6 +47,7 @@ my %definition_for = (
 			type                        => '16',
 			dns_bypass_ip6              => undef,
 			dscp                        => '40',
+			deep_caching_type           => 0,
 			routing_name                => 'foo',
 			mid_header_rewrite          => 'cond %{REMAP_PSEUDO_HOOK} __RETURN__ set-config proxy.config.http.parent_origin.dead_server_retry_enabled 1',
 			active                      => '1',
@@ -121,6 +122,7 @@ my %definition_for = (
 			max_dns_answers             => '0',
 			miss_lat                    => '41.881944',
 			dscp                        => '40',
+			deep_caching_type           => 0,
 			routing_name                => 'foo',
 			mid_header_rewrite          => undef,
 			regex_remap                 => undef,
@@ -143,6 +145,7 @@ my %definition_for = (
 			qstring_ignore              => '0',
 			ccr_dns_ttl                 => '3600',
 			dscp                        => '40',
+			deep_caching_type           => 0,
 			routing_name                => 'foo',
 			last_updated                => '2015-12-10 15:44:37',
 			org_server_fqdn             => 'http://images.origin.kabletown.net',
@@ -194,6 +197,7 @@ my %definition_for = (
 			mid_header_rewrite	 				=>
 				'cond %{REMAP_PSEUDO_HOOK} __RETURN__ set-config proxy.config.http.parent_origin.dead_server_retry_enabled 1__RETURN__ set-config proxy.config.http.parent_origin.simple_retry_enabled 1__RETURN__ set-config proxy.config.http.parent_origin.simple_retry_response_codes "400,404,412"__RETURN__ set-config proxy.config.http.parent_origin.dead_server_retry_response_codes "502,503" __RETURN__ set-config proxy.config.http.connect_attempts_timeout 2 __RETURN__ set-config proxy.config.http.conne [...]
 			dscp                        => '40',
+			deep_caching_type           => 0,
 			routing_name                => 'foo',
 			info_url                    => 'http://movies.info.kabletown.net',
 			last_updated                => '2015-12-10 15:44:37',
@@ -251,6 +255,7 @@ my %definition_for = (
 			regex_remap                 => undef,
 			dns_bypass_ip6              => undef,
 			dscp                        => '40',
+			deep_caching_type           => 0,
 			routing_name                => 'foo',
 			range_request_handling      => '0',
 			display_name                => 'tv-c1',
@@ -305,6 +310,7 @@ my %definition_for = (
 			check_path                  => '/crossdomain.xml',
 			dns_bypass_cname            => undef,
 			dscp                        => '40',
+			deep_caching_type           => 0,
 			routing_name                => 'foo',
 			remap_text                  => undef,
 			global_max_mbps             => '0',
@@ -356,6 +362,7 @@ my %definition_for = (
 			ccr_dns_ttl                 => '3600',
 			dns_bypass_cname            => undef,
 			dscp                        => '40',
+			deep_caching_type           => 0,
 			routing_name                => 'foo',
 			global_max_tps              => '0',
 			initial_dispersion          => '1',
@@ -394,6 +401,7 @@ my %definition_for = (
 			signing_algorithm           => undef,
 			dns_bypass_cname            => undef,
 			dscp                        => '40',
+			deep_caching_type           => 0,
 			routing_name                => 'foo',
 			geo_limit                   => '0',
 			initial_dispersion          => '1',
diff --git a/traffic_ops/app/t/api/1.2/deliveryservice.t b/traffic_ops/app/t/api/1.2/deliveryservice.t
index e73a7c5..6c3f3bf 100644
--- a/traffic_ops/app/t/api/1.2/deliveryservice.t
+++ b/traffic_ops/app/t/api/1.2/deliveryservice.t
@@ -82,6 +82,7 @@ $t->get_ok('/api/1.2/deliveryservices/100/servers/eligible')->status_is(200)->$c
 ok $t->get_ok("/api/1.2/deliveryservices")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } )
 		->json_is( "/response/0/xmlId", "steering-ds1" )
 		->json_is( "/response/0/routingName", "foo" )
+		->json_is( "/response/0/deepCachingType", 0 )
 		->json_is( "/response/0/logsEnabled", 0 )
 		->json_is( "/response/0/ipv6RoutingEnabled", 1 )
 		->json_is( "/response/1/xmlId", "steering-ds2" );
@@ -205,6 +206,7 @@ ok $t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
 	ok $t->post_ok('/api/1.2/deliveryservices' => {Accept => 'application/json'} => json => {
 			"active" => \0,
 			"cdnId" => 100,
+			"deepCachingType" => "NEVER",
 			"displayName" => "ds_displayname_1",
 			"dscp" => 0,
 			"geoLimit" => 0,
@@ -228,6 +230,7 @@ ok $t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
         ->json_is( "/response/0/tenantId" => $tenant_id)
         ->json_is( "/response/0/cdnName" => "cdn1")
 		->json_is( "/response/0/routingName" => "foo")
+		->json_is( "/response/0/deepCachingType" => 0)
 		->json_is( "/response/0/displayName" => "ds_displayname_1")
 		->json_is( "/response/0/xmlId" => "ds_1")
 		->json_is( "/response/0/multiSiteOrigin" => 0)
@@ -240,6 +243,7 @@ ok $t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
 	ok $t->put_ok('/api/1.2/deliveryservices/' . $ds_id => {Accept => 'application/json'} => json => {
 			"active" => \1,
 			"cdnId" => 100,
+			"deepCachingType" => "NEVER",
             "displayName" => "ds_displayname_11",
 			"dscp" => 1,
 			"geoLimit" => 1,
@@ -265,6 +269,7 @@ ok $t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
 		->json_is( "/response/0/displayName" => "ds_displayname_11")
 		->json_is( "/response/0/xmlId" => "ds_1")
 		->json_is( "/response/0/routingName" => "bar")
+		->json_is( "/response/0/deepCachingType" => 0)
 		->json_is( "/response/0/multiSiteOrigin" => 0)
 		->json_is( "/response/0/orgServerFqdn" => "http://10.75.168.91")
 		->json_is( "/response/0/protocol" => 2)
@@ -277,6 +282,7 @@ ok $t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
 				"displayName" => "ds_displayname_11",
 				"dscp" => 1,
 				"routingName" => "baz",
+				"deepCachingType" => 0,
 				"geoLimit" => 1,
 				"geoProvider" => 1,
 				"ipv6RoutingEnabled" => 1,
@@ -306,6 +312,7 @@ ok $t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
 				"displayName" => "ds_displayname_11",
 				"dscp" => 1,
 				"routingName" => "foo",
+				"deepCachingType" => 0,
 				"geoLimit" => 1,
 				"geoProvider" => 1,
 				"initialDispersion" => 2,
diff --git a/traffic_ops/app/t/api/1.2/deliveryservice_crud.t b/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
index 7dbe1de..cb36541 100644
--- a/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
+++ b/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
@@ -62,6 +62,7 @@ sub run_ut {
 	ok $t->get_ok("/api/1.2/deliveryservices")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } )
 			->json_is( "/response/0/xmlId", "steering-ds1" )
 			->json_is( "/response/0/routingName", "foo" )
+			->json_is( "/response/0/deepCachingType", 0)
 			->json_is( "/response/0/logsEnabled", 0 )
 			->json_is( "/response/0/ipv6RoutingEnabled", 1 )
 			->json_is( "/response/1/xmlId", "steering-ds2" );
@@ -143,6 +144,7 @@ sub run_ut {
         	"active" => "false",
         	"dscp" => 0,
         	"routingName" => "foo",
+			"deepCachingType" => 0,
         	"ipv6RoutingEnabled" => "true",
         	"logsEnabled" => "true",
         	"initialDispersion" => 1,
@@ -159,6 +161,7 @@ sub run_ut {
 	    ->json_is( "/response/0/orgServerFqdn" => "http://10.75.168.91")
 	    ->json_is( "/response/0/cdnId" => 100)
 	    ->json_is( "/response/0/routingName" => "foo")
+	    ->json_is( "/response/0/deepCachingType" => 0)
 	    ->json_is( "/response/0/tenantId" => $tenant_id)
 	    ->json_is( "/response/0/profileId" => 300)
 	    ->json_is( "/response/0/protocol" => "1")
@@ -177,6 +180,7 @@ sub run_ut {
 	    ->json_is( "/response/0/orgServerFqdn" => "http://10.75.168.91")
 	    ->json_is( "/response/0/cdnId" => 100)
 	    ->json_is( "/response/0/routingName" => "foo")
+	    ->json_is( "/response/0/deepCachingType" => 0)
 	    ->json_is( "/response/0/tenantId" => $tenant_id)
 	    ->json_is( "/response/0/tenant" => $tenant_name)
 	    ->json_is( "/response/0/profileId" => 300)
@@ -204,6 +208,7 @@ sub run_ut {
 	        "active" => "false",
 	        "dscp" => 0,
 	        "routingName" => "foo",
+	        "deepCachingType" => 0,
 	        "ipv6RoutingEnabled" => "true",
 	        "logsEnabled" => "true",
 	        "initialDispersion" => 1,
@@ -246,6 +251,7 @@ sub run_ut {
 					"active"               => "false",
 					"dscp"                 => 0,
 					"routingName"          => "foo",
+					"deepCachingType"      => 0,
 					"ipv6RoutingEnabled"   => "true",
 					"logsEnabled"          => "true",
 					"initialDispersion"    => 1,
@@ -279,6 +285,7 @@ sub run_ut {
 					"active"               => "false",
 					"dscp"                 => 0,
 					"routingName"          => "foo",
+					"deepCachingType"      => 0,
 					"ipv6RoutingEnabled"   => "true",
 					"logsEnabled"          => "true",
 					"initialDispersion"    => 1,
@@ -312,6 +319,7 @@ sub run_ut {
        	        "active" => "false",
        	        "dscp" => 0,
        	        "routingName" => "foo",
+       	        "deepCachingType" => 0,
        	        "ipv6RoutingEnabled" => "true",
        	        "logsEnabled" => "true",
        	        "initialDispersion" => 1,
@@ -345,6 +353,7 @@ sub run_ut {
        	        "active" => "false",
        	        "dscp" => 0,
        	        "routingName" => "foo",
+       	        "deepCachingType" => 0,
        	        "ipv6RoutingEnabled" => "true",
        	        "logsEnabled" => "true",
        	        "initialDispersion" => 1,
@@ -379,6 +388,7 @@ sub run_ut {
        	        "active" => "false",
        	        "dscp" => 0,
        	        "routingName" => "foo",
+       	        "deepCachingType" => 0,
        	        "ipv6RoutingEnabled" => "true",
        	        "logsEnabled" => "true",
        	        "initialDispersion" => 1,
@@ -413,6 +423,7 @@ sub run_ut {
 	        "active" => "false",
 	        "dscp" => 0,
 	        "routingName" => "foo",
+	        "deepCachingType" => 0,
 	        "ipv6RoutingEnabled" => "true",
 	        "logsEnabled" => "true",
 	        "initialDispersion" => 1,
@@ -463,6 +474,7 @@ sub run_ut {
         "active" => "false",
         "dscp" => 0,
         "routingName" => "foo",
+        "deepCachingType" => 0,
         "ipv6RoutingEnabled" => "true",
         "logsEnabled" => "true",
         "initialDispersion" => 1,
@@ -509,6 +521,7 @@ sub run_ut {
         "active" => "false",
         "dscp" => 0,
         "routingName" => "foo",
+        "deepCachingType" => 0,
         "ipv6RoutingEnabled" => "true",
         "logsEnabled" => "true",
         "initialDispersion" => 1,
diff --git a/traffic_ops/app/t/deliveryservice.t b/traffic_ops/app/t/deliveryservice.t
index e580d2c..2e47697 100644
--- a/traffic_ops/app/t/deliveryservice.t
+++ b/traffic_ops/app/t/deliveryservice.t
@@ -63,6 +63,7 @@ ok $t->post_ok(
 		'ds.dns_bypass_ttl'              => '30',
 		'ds.dscp'                        => '40',
 		'ds.routing_name'                => 'foo',
+		'ds.deep_caching_type'           => '0',
 		'ds.geo_limit'                   => '0',
 		'ds.geo_limit_countries'         => '',
 		'ds.geo_provider'                => '1',
@@ -115,6 +116,7 @@ ok $t->post_ok(
 		'ds.dns_bypass_ttl'              => '30',
 		'ds.dscp'                        => '42',
 		'ds.routing_name'                => '',
+		'ds.deep_caching_type'           => '0',
 		'ds.geo_limit'                   => '0',
 		'ds.geo_limit_countries'         => '',
 		'ds.global_max_mbps'             => '',
@@ -166,6 +168,7 @@ ok $t->post_ok(
 		'ds.dns_bypass_ttl'              => '30',
 		'ds.dscp'                        => '40',
 		'ds.routing_name'                => 'foo',
+		'ds.deep_caching_type'           => '0',
 		'ds.geo_limit'                   => '1',
 		'ds.geo_limit_countries'         => '',
 		'ds.global_max_mbps'             => '30G',
@@ -246,6 +249,7 @@ ok $t->post_ok(
 		'ds.dns_bypass_ttl'              => '31',
 		'ds.dscp'                        => '41',
 		'ds.routing_name'                => 'bar',
+		'ds.deep_caching_type'           => '0',
 		'ds.geo_limit'                   => '2',
 		'ds.geo_limit_countries'         => '',
 		'ds.geo_provider'                => '1',
@@ -294,6 +298,7 @@ ok $t->get_ok('/datadeliveryservice')->status_is(200)
   ->or( sub { diag $t->tx->res->content->asset->{content}; } )
   ->json_is( '/1/dscp' => '41' )
   ->json_is( '/1/routing_name' => 'bar' )
+  ->json_is( '/1/deep_caching_type' => '0' )
   ->json_is( '/1/active' => '0' )
   ->json_is( '/1/profile_description' => 'mid description' )
   ->json_is( '/1/org_server_fqdn'     => 'http://update.knutsel.com' )

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 16/36: Fix Java PMD violations

Posted by el...@apache.org.
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 d20eae653176d0855c261fda98657e5f66cce284
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed Nov 1 14:36:15 2017 -0600

    Fix Java PMD violations
---
 .../cdn/traffic_control/traffic_router/core/loc/NetworkNode.java    | 6 +++---
 .../traffic_control/traffic_router/core/router/TrafficRouter.java   | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
index c852184..c098320 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/NetworkNode.java
@@ -138,7 +138,7 @@ public class NetworkNode implements Comparable<NetworkNode> {
 
     private static boolean addNetworkNodesToRoot(final SuperNode root, final String loc, final JsonNode locData,
                                                  final Geolocation geolocation, final boolean useDeep) {
-        CacheLocation deepLoc = new CacheLocation( "deep." + loc, geolocation != null ? geolocation : new Geolocation(0.0, 0.0));  // TODO JvD
+        final CacheLocation deepLoc = new CacheLocation( "deep." + loc, geolocation != null ? geolocation : new Geolocation(0.0, 0.0));  // TODO JvD
         final Set<String> cacheNames = parseDeepCacheNames(locData);
 
         for (final String key : new String[]{"network6", "network"}) {
@@ -173,7 +173,7 @@ public class NetworkNode implements Comparable<NetworkNode> {
         return true;
     }
 
-    private static Set<String> parseDeepCacheNames(JsonNode locationData) {
+    private static Set<String> parseDeepCacheNames(final JsonNode locationData) {
         final Set<String> cacheNames = new HashSet<String>();
         final JsonNode cacheArray;
 
@@ -314,7 +314,7 @@ public class NetworkNode implements Comparable<NetworkNode> {
         clearCacheLocations(false);
     }
 
-    public void clearCacheLocations(boolean clearCachesOnly) {
+    public void clearCacheLocations(final boolean clearCachesOnly) {
         synchronized(this) {
             if (clearCachesOnly && cacheLocation != null) {
                 cacheLocation.clearCaches();
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 68dfb6b..91d3751 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
@@ -642,6 +642,7 @@ public class TrafficRouter {
 		return getCoverageZoneCacheLocation(ip, deliveryServiceId, false); // default is not deep
 	}
 
+	@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
 	public CacheLocation getCoverageZoneCacheLocation(final String ip, final String deliveryServiceId, final boolean useDeep) {
 		NetworkNode networkNode;
 		if (useDeep) {
@@ -688,7 +689,7 @@ public class TrafficRouter {
 		return getClosestCacheLocation(cacheRegister.filterAvailableLocations(deliveryServiceId), networkNode.getGeolocation(), cacheRegister.getDeliveryService(deliveryServiceId));
 	}
 
-	private void loadDeepCaches(NetworkNode networkNode, CacheLocation cacheLocation) {
+	private void loadDeepCaches(final NetworkNode networkNode, final CacheLocation cacheLocation) {
 		if (networkNode.getDeepCacheNames() != null) {
 			for (final String deepCacheName : networkNode.getDeepCacheNames()) {
 				final Cache deepCache = cacheRegister.getCacheMap().get(deepCacheName);

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 15/36: Rename goose migration file for deep_caching_type due to rebase

Posted by el...@apache.org.
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 0e52c33ec7ac6641405d6efb1829e2d2179ab37f
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed Nov 1 14:33:56 2017 -0600

    Rename goose migration file for deep_caching_type due to rebase
---
 ...add_deep_caching_type.sql => 20171101000000_add_deep_caching_type.sql} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/traffic_ops/app/db/migrations/20171012000000_add_deep_caching_type.sql b/traffic_ops/app/db/migrations/20171101000000_add_deep_caching_type.sql
similarity index 100%
rename from traffic_ops/app/db/migrations/20171012000000_add_deep_caching_type.sql
rename to traffic_ops/app/db/migrations/20171101000000_add_deep_caching_type.sql

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 10/36: Fix failing unit tests due to DDC changes

Posted by el...@apache.org.
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 6e403ad205183f059754acce4661909395662885
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed Oct 25 10:37:25 2017 -0600

    Fix failing unit tests due to DDC changes
---
 .../cdn/traffic_control/traffic_router/core/external/StatsTest.java   | 4 ++--
 .../cdn/traffic_control/traffic_router/core/loc/CoverageZoneTest.java | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/external/StatsTest.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/external/StatsTest.java
index 006419d..97674ab 100644
--- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/external/StatsTest.java
+++ b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/external/StatsTest.java
@@ -85,12 +85,12 @@ public class StatsTest {
 			Map<String, Object> dnsStats = (Map<String, Object>) statsData.get("dnsMap");
 			Map<String, Object> cacheDnsStats = (Map<String, Object>) dnsStats.values().iterator().next();
 			assertThat(cacheDnsStats.keySet(), containsInAnyOrder("czCount", "geoCount", "missCount", "dsrCount", "errCount",
-				"staticRouteCount", "fedCount", "regionalDeniedCount", "regionalAlternateCount"));
+					"deepCzCount", "deepCzMissCount", "staticRouteCount", "fedCount", "regionalDeniedCount", "regionalAlternateCount"));
 
 			Map<String, Object> httpStats = (Map<String, Object>) statsData.get("httpMap");
 			Map<String, Object> cacheHttpStats = (Map<String, Object>) httpStats.values().iterator().next();
 			assertThat(cacheHttpStats.keySet(), containsInAnyOrder("czCount", "geoCount", "missCount", "dsrCount", "errCount",
-				"staticRouteCount", "fedCount", "regionalDeniedCount", "regionalAlternateCount"));
+					"deepCzCount", "deepCzMissCount", "staticRouteCount", "fedCount", "regionalDeniedCount", "regionalAlternateCount"));
 
 			Map<String, Object> updateTracker = (Map<String, Object>) statsData.get("updateTracker");
 			Set<String> keys = updateTracker.keySet();
diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/CoverageZoneTest.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/CoverageZoneTest.java
index 1e7523a..0387c89 100644
--- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/CoverageZoneTest.java
+++ b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/CoverageZoneTest.java
@@ -88,6 +88,7 @@ public class CoverageZoneTest {
 		trafficRouter = PowerMockito.mock(TrafficRouter.class);
 		Whitebox.setInternalState(trafficRouter, "cacheRegister", cacheRegister);
 		when(trafficRouter.getCoverageZoneCacheLocation("12.23.34.45", "delivery-service-1")).thenCallRealMethod();
+		when(trafficRouter.getCoverageZoneCacheLocation("12.23.34.45", "delivery-service-1", false)).thenCallRealMethod();
 		when(trafficRouter.getCacheRegister()).thenReturn(cacheRegister);
 		when(trafficRouter.orderCacheLocations(cacheGroups,testLocation)).thenCallRealMethod();
 		when(trafficRouter.getSupportingCaches(anyListOf(Cache.class), eq(deliveryService))).thenCallRealMethod();

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 24/36: DDC documentation cleanup

Posted by el...@apache.org.
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 b9d4b5ead62d8d2b4287b040a441b4ff2f8b2dec
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed Nov 8 15:35:39 2017 -0700

    DDC documentation cleanup
---
 docs/source/admin/traffic_ops/using.rst            |  9 +-
 docs/source/admin/traffic_router.rst               | 96 +++++++++++-----------
 .../traffic_ops_api/v12/deliveryservice.rst        |  8 ++
 .../development/traffic_ops_api/v12/server.rst     |  1 +
 .../development/traffic_ops_api/v12/user.rst       |  1 +
 5 files changed, 63 insertions(+), 52 deletions(-)

diff --git a/docs/source/admin/traffic_ops/using.rst b/docs/source/admin/traffic_ops/using.rst
index 334eb58..5ac1a0d 100644
--- a/docs/source/admin/traffic_ops/using.rst
+++ b/docs/source/admin/traffic_ops/using.rst
@@ -307,8 +307,9 @@ The fields in the Delivery Service view are:
 | Content Routing Type                             | The type of content routing this delivery service will use. See :ref:`rl-ds-types`.                                                                                                                                 |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Deep Caching                                     | (for HTTP routed delivery services only) When to do deep caching for this delivery service (see :ref:`Deep Caching <rl-deep-cache>` for more details):                                                              |
-|                                                  | - NEVER                                                                                                                                                                                                             |
-|                                                  | - ALWAYS                                                                                                                                                                                                            |
+|                                                  |                                                                                                                                                                                                                     |
+|                                                  | - 0 - NEVER                                                                                                                                                                                                         |
+|                                                  | - 1 - ALWAYS                                                                                                                                                                                                        |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Delivery Service DNS TTL                         | The Time To Live on the DNS record for the Traffic Router A and AAAA records (``<routing-name>.<deliveryservice>.<cdn-domain>``).                                                                                   |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@@ -888,7 +889,7 @@ The CZF is an input to the Traffic Control CDN, and as such does not get generat
 
 The script that generates the CZF file is not part of Traffic Control, since it is different for each situation.
 
-.. note:: The "coordinates" section is optional and may be used by Traffic Router for localization in the case of a CZF "hit" where the zone name does not map to a Cache Group name in Traffic Ops (i.e. Traffic Router will route to the closest Cache Group(s) geographically).
+.. note:: The ``"coordinates"`` section is optional and may be used by Traffic Router for localization in the case of a CZF "hit" where the zone name does not map to a Cache Group name in Traffic Ops (i.e. Traffic Router will route to the closest Cache Group(s) geographically).
 
 .. _rl-deep-czf:
 
@@ -941,7 +942,7 @@ Each entry in the ``caches`` list is the hostname of an edge cache registered in
 
 If the Traffic Router gets a DCZF "hit" for a requested Delivery Service that has Deep Caching enabled, the client will be routed to an available "deep" cache from that zone's ``caches`` list.
 
-.. note:: The "coordinates" section is optional.
+.. note:: The ``"coordinates"`` section is optional.
 
 
 .. _rl-working-with-profiles:
diff --git a/docs/source/admin/traffic_router.rst b/docs/source/admin/traffic_router.rst
index 7dd60d9..84b0f25 100644
--- a/docs/source/admin/traffic_router.rst
+++ b/docs/source/admin/traffic_router.rst
@@ -144,54 +144,6 @@ Traffic Router currently follows the zone signing key pre-publishing operational
 
 .. _section 4.1.1.1 of RFC 6781: https://tools.ietf.org/html/rfc6781#section-4.1.1.1
 
-
-.. _rl-deep-cache:
-
-Deep Caching - Deep Coverage Zone Topology
-==========================================
-
-Overview
---------
-
-Deep Caching is a feature that enables clients to be routed to the closest
-possible "deep" edge caches on a per Delivery Service basis. The term "deep" is
-used in the networking sense, meaning that the edge caches are located deep in
-the network where the number of network hops to a client is as minimal as
-possible. This deep caching topology is desirable because storing content closer
-to the client gives better bandwidth savings, and sometimes the cost of
-bandwidth usage in the network outweighs the cost of adding storage. While it
-may not be feasible to cache an entire copy of the CDN's contents in every deep
-location (for the best possible bandwidth savings), storing just a relatively
-small amount of the CDN's most requested content can lead to very high bandwidth
-savings.
-
-Getting started
----------------
-
-What you need:
-
-#. Edge caches deployed in "deep" locations and registered in Traffic Ops
-#. A Deep Coverage Zone File (DCZF) mapping these deep cache hostnames to specific network prefixes (see :ref:`rl-deep-czf` for details)
-#. Deep caching parameters in the Traffic Router Profile (see :ref:`rl-ccr-profile` for details):
-
-   * ``deepcoveragezone.polling.interval``
-   * ``deepcoveragezone.polling.url``
-
-#. Deep Caching enabled on one or more HTTP Delivery Services (i.e. ``deepCachingType`` = ALWAYS)
-
-How it works
-------------
-
-Deep Coverage Zone routing is very similar to that of regular Coverage Zone
-routing, except that the DCZF is preferred over the regular  CZF for Delivery
-Services with DC (Deep Caching) enabled. If the client requests a DC-enabled
-Delivery Service and their IP address gets a "hit" in the DCZF, Traffic Router
-will attempt to route that client to one of the available deep caches in the
-client's corresponding zone. If there are no deep caches available for a
-client's request, Traffic Router will "fall back" to the regular CZF and
-continue regular CZF routing from there.
-
-
 Troubleshooting and log files
 =============================
 Traffic Router log files are in ``/opt/traffic_router/var/log``, and Tomcat log files are in ``/opt/tomcat/logs``. Application related logging is in ``/opt/traffic_router/var/log/traffic_router.log``, while access logs are written to ``/opt/traffic_router/var/log/access.log``.
@@ -403,6 +355,54 @@ The URL has 3 kinds of formats, which have different meanings:
 
 3. URL with domain that doesn't match with the delivery service. For this URL, the router will return the configured url directly to the client.
 
+
+.. _rl-deep-cache:
+
+Deep Caching - Deep Coverage Zone Topology
+==========================================
+
+Overview
+--------
+
+Deep Caching is a feature that enables clients to be routed to the closest
+possible "deep" edge caches on a per Delivery Service basis. The term "deep" is
+used in the networking sense, meaning that the edge caches are located deep in
+the network where the number of network hops to a client is as minimal as
+possible. This deep caching topology is desirable because storing content closer
+to the client gives better bandwidth savings, and sometimes the cost of
+bandwidth usage in the network outweighs the cost of adding storage. While it
+may not be feasible to cache an entire copy of the CDN's contents in every deep
+location (for the best possible bandwidth savings), storing just a relatively
+small amount of the CDN's most requested content can lead to very high bandwidth
+savings.
+
+Getting started
+---------------
+
+What you need:
+
+#. Edge caches deployed in "deep" locations and registered in Traffic Ops
+#. A Deep Coverage Zone File (DCZF) mapping these deep cache hostnames to specific network prefixes (see :ref:`rl-deep-czf` for details)
+#. Deep caching parameters in the Traffic Router Profile (see :ref:`rl-ccr-profile` for details):
+
+   * ``deepcoveragezone.polling.interval``
+   * ``deepcoveragezone.polling.url``
+
+#. Deep Caching enabled on one or more HTTP Delivery Services (i.e. ``deepCachingType`` = ALWAYS)
+
+How it works
+------------
+
+Deep Coverage Zone routing is very similar to that of regular Coverage Zone
+routing, except that the DCZF is preferred over the regular  CZF for Delivery
+Services with DC (Deep Caching) enabled. If the client requests a DC-enabled
+Delivery Service and their IP address gets a "hit" in the DCZF, Traffic Router
+will attempt to route that client to one of the available deep caches in the
+client's corresponding zone. If there are no deep caches available for a
+client's request, Traffic Router will "fall back" to the regular CZF and
+continue regular CZF routing from there.
+
+
 .. _rl-tr-steering:
 
 Steering feature
diff --git a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
index 3eaff73..42005f7 100644
--- a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
+++ b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
@@ -67,6 +67,7 @@ Delivery Service
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        |                                                                                                                                      |
   |                          |        | - 0: NEVER (default)                                                                                                                 |
   |                          |        | - 1: ALWAYS                                                                                                                          |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -307,6 +308,7 @@ Delivery Service
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        |                                                                                                                                      |
   |                          |        | - 0: NEVER (default)                                                                                                                 |
   |                          |        | - 1: ALWAYS                                                                                                                          |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -1929,6 +1931,7 @@ URL Sig Keys
   | ``>customer``                          | string | yes      | Name of the customer to associated with the delivery service.                               |
   +----------------------------------------+--------+----------+---------------------------------------------------------------------------------------------+
   | ``>deepCachingType``                   |  int   | no       | When to do Deep Caching for this Delivery Service:                                          |
+  |                                        |        |          |                                                                                             |
   |                                        |        |          | - 0: NEVER (default)                                                                        |
   |                                        |        |          | - 1: ALWAYS                                                                                 |
   +----------------------------------------+--------+----------+---------------------------------------------------------------------------------------------+
@@ -2078,6 +2081,7 @@ URL Sig Keys
   | checkPath              | no       | The path portion of the URL to check this deliveryservice for health.                                   |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | deepCachingType        | no       | When to do Deep Caching for this Delivery Service:                                                      |
+  |                        |          |                                                                                                         |
   |                        |          | - 0: NEVER (default)                                                                                    |
   |                        |          | - 1: ALWAYS                                                                                             |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
@@ -2252,6 +2256,7 @@ URL Sig Keys
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        |                                                                                                                                      |
   |                          |        | - 0: NEVER (default)                                                                                                                 |
   |                          |        | - 1: ALWAYS                                                                                                                          |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -2497,6 +2502,7 @@ URL Sig Keys
   | checkPath              | no       | The path portion of the URL to check this deliveryservice for health.                                   |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
   | deepCachingType        | no       | When to do Deep Caching for this Delivery Service:                                                      |
+  |                        |          |                                                                                                         |
   |                        |          | - 0: NEVER (default)                                                                                    |
   |                        |          | - 1: ALWAYS                                                                                             |
   +------------------------+----------+---------------------------------------------------------------------------------------------------------+
@@ -2671,6 +2677,7 @@ URL Sig Keys
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        |                                                                                                                                      |
   |                          |        | - 0: NEVER (default)                                                                                                                 |
   |                          |        | - 1: ALWAYS                                                                                                                          |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -2945,6 +2952,7 @@ URL Sig Keys
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        |                                                                                                                                      |
   |                          |        | - 0: NEVER (default)                                                                                                                 |
   |                          |        | - 1: ALWAYS                                                                                                                          |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
diff --git a/docs/source/development/traffic_ops_api/v12/server.rst b/docs/source/development/traffic_ops_api/v12/server.rst
index bae5b8a..9b2a42b 100644
--- a/docs/source/development/traffic_ops_api/v12/server.rst
+++ b/docs/source/development/traffic_ops_api/v12/server.rst
@@ -379,6 +379,7 @@ Server
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        |                                                                                                                                      |
   |                          |        | - 0: NEVER (default)                                                                                                                 |
   |                          |        | - 1: ALWAYS                                                                                                                          |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
diff --git a/docs/source/development/traffic_ops_api/v12/user.rst b/docs/source/development/traffic_ops_api/v12/user.rst
index f89b566..b589a3b 100644
--- a/docs/source/development/traffic_ops_api/v12/user.rst
+++ b/docs/source/development/traffic_ops_api/v12/user.rst
@@ -455,6 +455,7 @@ Users
   | ``checkPath``            | string | The path portion of the URL to check this deliveryservice for health.                                                                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``deepCachingType``      |  int   | When to do Deep Caching for this Delivery Service:                                                                                   |
+  |                          |        |                                                                                                                                      |
   |                          |        | - 0: NEVER (default)                                                                                                                 |
   |                          |        | - 1: ALWAYS                                                                                                                          |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 03/36: Only show Deep Caching field for HTTP delivery services

Posted by el...@apache.org.
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 4f6eaa2305d4e29468f8c121f5f8653970c74b42
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Thu Oct 12 16:25:00 2017 -0600

    Only show Deep Caching field for HTTP delivery services
---
 traffic_ops/app/templates/delivery_service/add.html.ep  | 4 ++++
 traffic_ops/app/templates/delivery_service/edit.html.ep | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/traffic_ops/app/templates/delivery_service/add.html.ep b/traffic_ops/app/templates/delivery_service/add.html.ep
index a04c525..c2f0841 100644
--- a/traffic_ops/app/templates/delivery_service/add.html.ep
+++ b/traffic_ops/app/templates/delivery_service/add.html.ep
@@ -115,6 +115,7 @@
             $('#range_request_handlingi_row').show(speed);
             $('#dns_bypass_ip_row').hide(speed);
             $('#dns_bypass_ip6_row').hide(speed);
+            $('#deep_caching_type').show(speed);
             $('#regional_geo_blocking_row').show(speed);
             $('#dns_bypass_cname_row').hide(speed);
             $('#dns_bypass_ttl_row').show(speed);
@@ -157,6 +158,7 @@
             $('#range_request_handlingi_row').show(speed);
             $('#dns_bypass_ip_row').show(speed);
             $('#dns_bypass_ip6_row').show(speed);
+            $('#deep_caching_type').hide(speed);
 			$('#regional_geo_blocking_row').hide(speed);
 	    	$('#dns_bypass_cname_row').show(speed);
             $('#dns_bypass_ttl_row').show(speed);
@@ -195,6 +197,7 @@
             $('#dns_bypass_ip_row').hide(speed);
             $('#dns_bypass_ip6_row').hide(speed);
             $('#dns_bypass_cname_row').hide(speed);
+            $('#deep_caching_type').hide(speed);
             $('#regional_geo_blocking_row').show(speed);
             $('#dns_bypass_ttl_row').hide(speed);
             $('#max_dns_answers_row').hide(speed);
@@ -232,6 +235,7 @@
             $('#range_request_handlingi_row').hide(speed);
             $('#dns_bypass_ip_row').hide(speed);
             $('#dns_bypass_ip6_row').hide(speed);
+            $('#deep_caching_type').hide(speed);
 			$('#regional_geo_blocking_row').show(speed);
 	    	$('#dns_bypass_cname_row').hide(speed);
             $('#dns_bypass_ttl_row').hide(speed);
diff --git a/traffic_ops/app/templates/delivery_service/edit.html.ep b/traffic_ops/app/templates/delivery_service/edit.html.ep
index 4de0875..699361a 100644
--- a/traffic_ops/app/templates/delivery_service/edit.html.ep
+++ b/traffic_ops/app/templates/delivery_service/edit.html.ep
@@ -209,6 +209,7 @@ function setup_form(speed) {
             $('#range_request_handlingi_row').show(speed);
             $('#dns_bypass_ip_row').hide(speed);
             $('#dns_bypass_ip6_row').hide(speed);
+            $('#deep_caching_type').show(speed);
             $('#regional_geo_blocking_row').show(speed);
             $('#dns_bypass_cname_row').hide(speed);
             $('#dns_bypass_ttl_row').show(speed);
@@ -249,6 +250,7 @@ function setup_form(speed) {
             $('#range_request_handlingi_row').show(speed);
             $('#dns_bypass_ip_row').show(speed);
             $('#dns_bypass_ip6_row').show(speed);
+            $('#deep_caching_type').hide(speed);
 			$('#regional_geo_blocking_row').hide(speed);
 	    	$('#dns_bypass_cname_row').show(speed);
             $('#dns_bypass_ttl_row').show(speed);
@@ -286,6 +288,7 @@ function setup_form(speed) {
             $('#range_request_handlingi_row').hide(speed);
             $('#dns_bypass_ip_row').hide(speed);
             $('#dns_bypass_ip6_row').hide(speed);
+            $('#deep_caching_type').hide(speed);
 			$('#regional_geo_blocking_row').show(speed);
 	    	$('#dns_bypass_cname_row').hide(speed);
             $('#dns_bypass_ttl_row').hide(speed);
@@ -324,6 +327,7 @@ function setup_form(speed) {
             $('#range_request_handlingi_row').hide(speed);
             $('#dns_bypass_ip_row').hide(speed);
             $('#dns_bypass_ip6_row').hide(speed);
+            $('#deep_caching_type').hide(speed);
 			$('#regional_geo_blocking_row').show(speed);
 	    	$('#dns_bypass_cname_row').hide(speed);
             $('#dns_bypass_ttl_row').hide(speed);

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 02/36: Reverse schema for deep_caching_type

Posted by el...@apache.org.
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 6584109186031a1929dcffda83b4857fbdf9ed24
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Thu Oct 12 15:21:45 2017 -0600

    Reverse schema for deep_caching_type
    
    There are also a couple other changes from running reverse_schema that
    are unrelated to the new deep_caching_type column (forgot to run it the
    last time the schema was updated).
---
 .../app/lib/Schema/Result/Deliveryservice.pm       | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
index f40cd87..d2e64f8 100644
--- a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
@@ -297,9 +297,15 @@ __PACKAGE__->table("deliveryservice");
 =head2 routing_name
 
   data_type: 'text'
-  default_value: 'ds'
+  default_value: 'cdn'
   is_nullable: 0
 
+=head2 deep_caching_type
+
+  data_type: 'smallint'
+  default_value: 0
+  is_nullable: 1
+
 =cut
 
 __PACKAGE__->add_columns(
@@ -418,7 +424,9 @@ __PACKAGE__->add_columns(
   "tenant_id",
   { data_type => "bigint", is_foreign_key => 1, is_nullable => 1 },
   "routing_name",
-  { data_type => "text", default_value => "ds", is_nullable => 0 },
+  { data_type => "text", default_value => "cdn", is_nullable => 0 },
+  "deep_caching_type",
+  { data_type => "smallint", default_value => 0, is_nullable => 1 },
 );
 
 =head1 PRIMARY KEY
@@ -603,7 +611,7 @@ __PACKAGE__->has_many(
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
-=head2 steering_target_deliveryservices_2s
+=head2 steering_target_targets
 
 Type: has_many
 
@@ -612,9 +620,9 @@ Related object: L<Schema::Result::SteeringTarget>
 =cut
 
 __PACKAGE__->has_many(
-  "steering_target_deliveryservices_2s",
+  "steering_target_targets",
   "Schema::Result::SteeringTarget",
-  { "foreign.deliveryservice" => "self.id" },
+  { "foreign.target" => "self.id" },
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
@@ -654,8 +662,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-08-09 15:16:31
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FXNj6wNNq+jajg/rVqOSBw
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-10-12 15:07:17
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:JOlBU3gXo4iidTQarqMAcA
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 #

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 01/36: Add deep_caching_type to DB, API, CRConfig, and UI.

Posted by el...@apache.org.
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 16896974085669bebce296c4a116f96b5b047b0f
Author: Jan van Doorn <ja...@cable.comcast.com>
AuthorDate: Fri Nov 18 12:40:43 2016 -0700

    Add deep_caching_type to DB, API, CRConfig, and UI.
    
    (cherry picked from commit 160a539446c46f9a593e208492bded4781418c6e)
---
 .../20171012000000_add_deep_caching_type.sql       | 23 ++++++++++++++++++++++
 traffic_ops/app/lib/API/Deliveryservice.pm         | 14 +++++++++++--
 traffic_ops/app/lib/UI/DeliveryService.pm          |  3 +++
 traffic_ops/app/lib/UI/Topology.pm                 |  5 +++++
 .../app/templates/delivery_service/_form.html.ep   | 15 ++++++++++++++
 5 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/traffic_ops/app/db/migrations/20171012000000_add_deep_caching_type.sql b/traffic_ops/app/db/migrations/20171012000000_add_deep_caching_type.sql
new file mode 100644
index 0000000..17c78cc
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20171012000000_add_deep_caching_type.sql
@@ -0,0 +1,23 @@
+/*
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+
+	    http://www.apache.org/licenses/LICENSE-2.0
+
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+
+alter table deliveryservice add column deep_caching_type smallint default 0;
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+
+ alter table deliveryservice drop column deep_caching_type;
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm b/traffic_ops/app/lib/API/Deliveryservice.pm
index 5db2fd2..b78b5a7 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -106,6 +106,7 @@ sub index {
 				"cdnId"                => $row->cdn->id,
 				"cdnName"              => $row->cdn->name,
 				"checkPath"            => $row->check_path,
+				"deepCachingType"      => $row->deep_caching_type,
 				"displayName"          => $row->display_name,
 				"dnsBypassCname"       => $row->dns_bypass_cname,
 				"dnsBypassIp"          => $row->dns_bypass_ip,
@@ -226,6 +227,7 @@ sub show {
 				"cdnId"                => $row->cdn->id,
 				"cdnName"              => $row->cdn->name,
 				"checkPath"            => $row->check_path,
+				"deepCachingType"      => $row->deep_caching_type,
 				"displayName"          => $row->display_name,
 				"dnsBypassCname"       => $row->dns_bypass_cname,
 				"dnsBypassIp"          => $row->dns_bypass_ip,
@@ -332,6 +334,7 @@ sub update {
 		ccr_dns_ttl            => $params->{ccrDnsTtl},
 		cdn_id                 => $params->{cdnId},
 		check_path             => $params->{checkPath},
+		deep_caching_type      => $params->{deepCachingType},
 		display_name           => $params->{displayName},
 		dns_bypass_cname       => $params->{dnsBypassCname},
 		dns_bypass_ip          => $params->{dnsBypassIp},
@@ -429,6 +432,7 @@ sub update {
 				"cdnId"                    => $rs->cdn->id,
 				"cdnName"                  => $rs->cdn->name,
 				"checkPath"                => $rs->check_path,
+				"deepCachingType"          => $rs->deep_caching_type,
 				"displayName"              => $rs->display_name,
 				"dnsBypassCname"           => $rs->dns_bypass_cname,
 				"dnsBypassIp"              => $rs->dns_bypass_ip,
@@ -560,6 +564,7 @@ sub safe_update {
 				"cdnId"                    => $rs->cdn->id,
 				"cdnName"                  => $rs->cdn->name,
 				"checkPath"                => $rs->check_path,
+				"deepCachingType"          => $rs->deep_caching_type,
 				"displayName"              => $rs->display_name,
 				"dnsBypassCname"           => $rs->dns_bypass_cname,
 				"dnsBypassIp"              => $rs->dns_bypass_ip,
@@ -666,6 +671,7 @@ sub create {
 		ccr_dns_ttl            => $params->{ccrDnsTtl},
 		cdn_id                 => $params->{cdnId},
 		check_path             => $params->{checkPath},
+		deep_caching_type      => $params->{deepCachingType},
 		display_name           => $params->{displayName},
 		dns_bypass_cname       => $params->{dnsBypassCname},
 		dns_bypass_ip          => $params->{dnsBypassIp},
@@ -774,6 +780,7 @@ sub create {
 				"cdnId"                    => $insert->cdn->id,
 				"cdnName"                  => $insert->cdn->name,
 				"checkPath"                => $insert->check_path,
+				"deepCachingType"          => $insert->deep_caching_type,
 				"displayName"              => $insert->display_name,
 				"dnsBypassCname"           => $insert->dns_bypass_cname,
 				"dnsBypassIp"              => $insert->dns_bypass_ip,
@@ -966,6 +973,7 @@ sub get_deliveryservices_by_serverId {
 					"cdnId"                => $row->cdn->id,
 					"cdnName"              => $row->cdn->name,
 					"checkPath"            => $row->check_path,
+					"deepCachingType"      => $row->deep_caching_type,
 					"displayName"          => $row->display_name,
 					"dnsBypassCname"       => $row->dns_bypass_cname,
 					"dnsBypassIp"          => $row->dns_bypass_ip,
@@ -1064,6 +1072,7 @@ sub get_deliveryservices_by_userId {
 					"cdnId"                => $row->cdn->id,
 					"cdnName"              => $row->cdn->name,
 					"checkPath"            => $row->check_path,
+					"deepCachingType"      => $row->deep_caching_type,
 					"displayName"          => $row->display_name,
 					"dnsBypassCname"       => $row->dns_bypass_cname,
 					"dnsBypassIp"          => $row->dns_bypass_ip,
@@ -1335,7 +1344,7 @@ sub is_deliveryservice_request_valid {
 
 	my $rules = {
 		fields => [
-			qw/customer contentType deliveryProtocol routingType routingName serviceDesc peakBPSEstimate peakTPSEstimate maxLibrarySizeEstimate originURL hasOriginDynamicRemap originTestFile hasOriginACLWhitelist originHeaders otherOriginSecurity queryStringHandling rangeRequestHandling hasSignedURLs hasNegativeCachingCustomization negativeCachingCustomizationNote serviceAliases rateLimitingGBPS rateLimitingTPS overflowService headerRewriteEdge headerRewriteMid headerRewriteRedirectRouter notes/
+			qw/customer contentType deepCachingType deliveryProtocol routingType routingName serviceDesc peakBPSEstimate peakTPSEstimate maxLibrarySizeEstimate originURL hasOriginDynamicRemap originTestFile hasOriginACLWhitelist originHeaders otherOriginSecurity queryStringHandling rangeRequestHandling hasSignedURLs hasNegativeCachingCustomization negativeCachingCustomizationNote serviceAliases rateLimitingGBPS rateLimitingTPS overflowService headerRewriteEdge headerRewriteMid headerRewriteRedire [...]
 		],
 
 		# Validation checks to perform
@@ -1370,7 +1379,7 @@ sub is_deliveryservice_valid {
 
 	my $rules = {
 		fields => [
-			qw/active cacheurl ccrDnsTtl cdnId checkPath displayName dnsBypassCname dnsBypassIp dnsBypassIp6 dnsBypassTtl dscp edgeHeaderRewrite geoLimitRedirectURL geoLimit geoLimitCountries geoProvider globalMaxMbps globalMaxTps httpBypassFqdn infoUrl initialDispersion ipv6RoutingEnabled logsEnabled longDesc longDesc1 longDesc2 maxDnsAnswers midHeaderRewrite missLat missLong multiSiteOrigin multiSiteOriginAlgorithm orgServerFqdn originShield profileId protocol qstringIgnore rangeRequestHandling [...]
+			qw/active cacheurl ccrDnsTtl cdnId checkPath deepCachingType displayName dnsBypassCname dnsBypassIp dnsBypassIp6 dnsBypassTtl dscp edgeHeaderRewrite geoLimitRedirectURL geoLimit geoLimitCountries geoProvider globalMaxMbps globalMaxTps httpBypassFqdn infoUrl initialDispersion ipv6RoutingEnabled logsEnabled longDesc longDesc1 longDesc2 maxDnsAnswers midHeaderRewrite missLat missLong multiSiteOrigin multiSiteOriginAlgorithm orgServerFqdn originShield profileId protocol qstringIgnore rang [...]
 		],
 
 		# validation checks to perform for ALL delivery services
@@ -1378,6 +1387,7 @@ sub is_deliveryservice_valid {
 			active				=> [ is_required("is required") ],
 			cdnId				=> [ is_required("is required"), \&is_valid_int_or_undef ],
 			ccrDnsTtl			=> [ \&is_valid_int_or_undef ],
+			deepCachingType      => [ is_like( qr/^[01]$/, "must be 0 (never) or 1 (always)" ) ],
 			dnsBypassTtl			=> [ \&is_valid_int_or_undef ],
 			dscp				=> [ is_required("is required"), \&is_valid_int_or_undef ],
 			displayName			=> [ is_required("is required"), is_long_at_most( 48, 'too long' ) ],
diff --git a/traffic_ops/app/lib/UI/DeliveryService.pm b/traffic_ops/app/lib/UI/DeliveryService.pm
index c9fac43..f1c47d9 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -255,6 +255,7 @@ sub read {
 				"initial_dispersion"          => $row->initial_dispersion,
 				"regional_geo_blocking"       => $row->regional_geo_blocking,
 				"logs_enabled"                => \$row->logs_enabled,
+				"deep_caching_type"           => $row->deep_caching_type,
 			}
 		);
 	}
@@ -835,6 +836,7 @@ sub update {
 			remap_text         => $self->paramAsScalar( 'ds.remap_text',         undef ),
 			initial_dispersion => $self->paramAsScalar( 'ds.initial_dispersion', 1 ),
 			logs_enabled       => $self->paramAsScalar('ds.logs_enabled'),
+			deep_caching_type  => $self->paramAsScalar('ds.deep_caching_type'),
 		);
 
 		my $typename = $self->typename();
@@ -1073,6 +1075,7 @@ sub create {
 				initial_dispersion => $self->paramAsScalar( 'ds.initial_dispersion', 1 ),
 				logs_enabled       => $self->paramAsScalar('ds.logs_enabled'),
 				tenant_id => $tenant_id,
+				deep_caching_type  => $self->paramAsScalar('ds.deep_caching_type'),
 		};
 
 		my $insert = $self->db->resultset('Deliveryservice')->create($new_ds);
diff --git a/traffic_ops/app/lib/UI/Topology.pm b/traffic_ops/app/lib/UI/Topology.pm
index e22addd..93c176b 100644
--- a/traffic_ops/app/lib/UI/Topology.pm
+++ b/traffic_ops/app/lib/UI/Topology.pm
@@ -399,6 +399,8 @@ sub gen_crconfig_json {
             $data_obj->{'deliveryServices'}->{ $row->xml_id }->{'geoEnabled'} = $geoEnabled;
         }
 
+        $data_obj->{'deliveryServices'}->{ $row->xml_id }->{'deepCachingType'} = $row->deep_caching_type;
+
         # Default to 'http only'
         $data_obj->{'deliveryServices'}->{ $row->xml_id }->{'sslEnabled'} = 'false';
         $data_obj->{'deliveryServices'}->{ $row->xml_id }->{'protocol'}->{'acceptHttps'} = 'false';
@@ -705,6 +707,9 @@ sub stringify_ds {
     if ( defined( $ds->{'missLocation'} ) ) {
         $string .= "|GeoMiss: " . $ds->{'missLocation'}->{'lat'} . "," . $ds->{'missLocation'}->{'long'};
     }
+    if (defined( $ds->{'deepCachingType'} ) ) {
+        $string .= "|deepCachingType: " . $ds->{'deepCachingType'};
+    }
     if ( defined( $ds->{'bypassDestination'} ) ) {
         $string .= "<br>|BypassDest:";
         if ( defined( $ds->{'bypassDestination'}->{'DNS'}->{'ip'} ) ) {
diff --git a/traffic_ops/app/templates/delivery_service/_form.html.ep b/traffic_ops/app/templates/delivery_service/_form.html.ep
index 36cff33..50d1802 100644
--- a/traffic_ops/app/templates/delivery_service/_form.html.ep
+++ b/traffic_ops/app/templates/delivery_service/_form.html.ep
@@ -617,4 +617,19 @@
 			<% } %>
 		<% } %>
 	</div>
+	<div class="block form-row" id="deep_caching_type">
+		<% unless (field('ds.deep_caching_type')->valid) { %>
+			<span class="field-with-error"><%= field('ds.deep_caching_type')->error %></span>
+		<% } %>
+		%= label_for 'deep_caching_type' => '* Deep Caching', class => 'label'
+		<% if ($priv_level >= 20) { %>
+		%= field('ds.deep_caching_type')->select([["Never" => 0], ["Always" => 1]]);
+		<% } else { %>
+			<%  if ($ds->deep_caching_type == 0 ) {%>
+				%= field('ds.deep_caching_type')->text(class => 'field', readonly => 'readonly', value => 'Never');
+			<% } elsif ($ds->deep_caching_type == 1 ) {%>
+				%= field('ds.deep_caching_type')->text(class => 'field', readonly => 'readonly', value => 'Always');
+			<% } %>
+		<% } %>
+	</div>
 </div>

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.

[incubator-trafficcontrol] 23/36: Add Deep Caching docs for overview/how to use

Posted by el...@apache.org.
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 aa6c53698cc0c6d1dbba94c20dbc6730596e2802
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed Nov 8 15:05:27 2017 -0700

    Add Deep Caching docs for overview/how to use
---
 docs/source/admin/traffic_ops/using.rst |  2 +-
 docs/source/admin/traffic_router.rst    | 48 +++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/docs/source/admin/traffic_ops/using.rst b/docs/source/admin/traffic_ops/using.rst
index e37be4d..334eb58 100644
--- a/docs/source/admin/traffic_ops/using.rst
+++ b/docs/source/admin/traffic_ops/using.rst
@@ -306,7 +306,7 @@ The fields in the Delivery Service view are:
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Content Routing Type                             | The type of content routing this delivery service will use. See :ref:`rl-ds-types`.                                                                                                                                 |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| Deep Caching                                     | (for HTTP routed delivery services only) When to do deep caching for this delivery service (see :ref:`Deep Caching <insert-ref-here>` for more details):                                                            |
+| Deep Caching                                     | (for HTTP routed delivery services only) When to do deep caching for this delivery service (see :ref:`Deep Caching <rl-deep-cache>` for more details):                                                              |
 |                                                  | - NEVER                                                                                                                                                                                                             |
 |                                                  | - ALWAYS                                                                                                                                                                                                            |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
diff --git a/docs/source/admin/traffic_router.rst b/docs/source/admin/traffic_router.rst
index 0fe1707..7dd60d9 100644
--- a/docs/source/admin/traffic_router.rst
+++ b/docs/source/admin/traffic_router.rst
@@ -144,6 +144,54 @@ Traffic Router currently follows the zone signing key pre-publishing operational
 
 .. _section 4.1.1.1 of RFC 6781: https://tools.ietf.org/html/rfc6781#section-4.1.1.1
 
+
+.. _rl-deep-cache:
+
+Deep Caching - Deep Coverage Zone Topology
+==========================================
+
+Overview
+--------
+
+Deep Caching is a feature that enables clients to be routed to the closest
+possible "deep" edge caches on a per Delivery Service basis. The term "deep" is
+used in the networking sense, meaning that the edge caches are located deep in
+the network where the number of network hops to a client is as minimal as
+possible. This deep caching topology is desirable because storing content closer
+to the client gives better bandwidth savings, and sometimes the cost of
+bandwidth usage in the network outweighs the cost of adding storage. While it
+may not be feasible to cache an entire copy of the CDN's contents in every deep
+location (for the best possible bandwidth savings), storing just a relatively
+small amount of the CDN's most requested content can lead to very high bandwidth
+savings.
+
+Getting started
+---------------
+
+What you need:
+
+#. Edge caches deployed in "deep" locations and registered in Traffic Ops
+#. A Deep Coverage Zone File (DCZF) mapping these deep cache hostnames to specific network prefixes (see :ref:`rl-deep-czf` for details)
+#. Deep caching parameters in the Traffic Router Profile (see :ref:`rl-ccr-profile` for details):
+
+   * ``deepcoveragezone.polling.interval``
+   * ``deepcoveragezone.polling.url``
+
+#. Deep Caching enabled on one or more HTTP Delivery Services (i.e. ``deepCachingType`` = ALWAYS)
+
+How it works
+------------
+
+Deep Coverage Zone routing is very similar to that of regular Coverage Zone
+routing, except that the DCZF is preferred over the regular  CZF for Delivery
+Services with DC (Deep Caching) enabled. If the client requests a DC-enabled
+Delivery Service and their IP address gets a "hit" in the DCZF, Traffic Router
+will attempt to route that client to one of the available deep caches in the
+client's corresponding zone. If there are no deep caches available for a
+client's request, Traffic Router will "fall back" to the regular CZF and
+continue regular CZF routing from there.
+
+
 Troubleshooting and log files
 =============================
 Traffic Router log files are in ``/opt/traffic_router/var/log``, and Tomcat log files are in ``/opt/tomcat/logs``. Application related logging is in ``/opt/traffic_router/var/log/traffic_router.log``, while access logs are written to ``/opt/traffic_router/var/log/access.log``.

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.