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 fda0e85e96b7f7b32b566831f1bfbad06269a2fc
Author: Jesse Rivas <jesse_ri...@comcast.com>
AuthorDate: Tue Feb 27 09:48:35 2018 -0700

    Added deep caching endpoints
---
 .../api/controllers/ConsistentHashController.java  | 15 ++++++++
 .../controllers/DeepCoverageZoneController.java    | 45 ++++++++++++++++++++++
 .../traffic_router/core/router/TrafficRouter.java  |  6 ++-
 3 files changed, 65 insertions(+), 1 deletion(-)

diff --git 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/api/controllers/ConsistentHashController.java
 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/api/controllers/ConsistentHashController.java
index 42e2108..8704cd3 100644
--- 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/api/controllers/ConsistentHashController.java
+++ 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/api/controllers/ConsistentHashController.java
@@ -47,6 +47,21 @@ public class ConsistentHashController {
                return ResponseEntity.ok(cache);
        }
 
+       @RequestMapping(value = "/cache/deep/coveragezone")
+       public @ResponseBody
+       ResponseEntity hashCoverageZoneDeepCache(@RequestParam(name="ip") final 
String ip,
+                                                                               
 @RequestParam(name = "deliveryServiceId") final String deliveryServiceId,
+                                                                               
 @RequestParam(name = "requestPath") final String requestPath) {
+
+               final Cache cache = 
trafficRouterManager.getTrafficRouter().consistentHashForCoverageZone(ip, 
deliveryServiceId, requestPath, true);
+
+               if (cache == null) {
+                       return 
ResponseEntity.status(HttpStatus.NOT_FOUND).body("{}");
+               }
+
+               return ResponseEntity.ok(cache);
+       }
+
        @RequestMapping(value = "/cache/geolocation")
        public @ResponseBody
        ResponseEntity hashGeolocatedCache(@RequestParam(name="ip") final 
String ip,
diff --git 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/api/controllers/DeepCoverageZoneController.java
 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/api/controllers/DeepCoverageZoneController.java
new file mode 100644
index 0000000..6503bcb
--- /dev/null
+++ 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/api/controllers/DeepCoverageZoneController.java
@@ -0,0 +1,45 @@
+/*
+ *
+ * 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.api.controllers;
+
+import com.comcast.cdn.traffic_control.traffic_router.core.cache.CacheLocation;
+import 
com.comcast.cdn.traffic_control.traffic_router.core.router.TrafficRouterManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller
+@RequestMapping("/deepcoveragezone")
+public class DeepCoverageZoneController {
+    @Autowired
+    TrafficRouterManager trafficRouterManager;
+
+    @RequestMapping(value = "/cachelocation")
+    public @ResponseBody
+    ResponseEntity<CacheLocation> getCacheLocationForIp(@RequestParam(name = 
"ip") final String ip,
+                                                        @RequestParam(name = 
"deliveryServiceId") final String deliveryServiceId) {
+        final CacheLocation cacheLocation = 
trafficRouterManager.getTrafficRouter().getCoverageZoneCacheLocation(ip, 
deliveryServiceId, true);
+        if (cacheLocation == null) {
+            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
+        }
+
+        return ResponseEntity.ok(cacheLocation);
+    }
+}
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 da05a5c..9662fd8 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
@@ -713,13 +713,17 @@ public class TrafficRouter {
        }
 
        public Cache consistentHashForCoverageZone(final String ip, final 
String deliveryServiceId, final String requestPath) {
+               return consistentHashForCoverageZone(ip, deliveryServiceId, 
requestPath, false);
+       }
+
+       public Cache consistentHashForCoverageZone(final String ip, final 
String deliveryServiceId, final String requestPath, final boolean useDeep) {
                final DeliveryService deliveryService = 
cacheRegister.getDeliveryService(deliveryServiceId);
                if (deliveryService == null) {
                        LOGGER.error("Failed getting delivery service from 
cache register for id '" + deliveryServiceId + "'");
                        return null;
                }
 
-               final CacheLocation coverageZoneCacheLocation = 
getCoverageZoneCacheLocation(ip, deliveryService);
+               final CacheLocation coverageZoneCacheLocation = 
getCoverageZoneCacheLocation(ip, deliveryService, useDeep);
                final List<Cache> caches = selectCachesByCZ(deliveryService, 
coverageZoneCacheLocation);
 
                if (caches == null || caches.isEmpty()) {

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

Reply via email to