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 f805d307374f669ed2f6267e24e085a638204282 Author: Rawlin Peters <rawlin_pet...@comcast.com> AuthorDate: Mon Feb 5 14:09:17 2018 -0700 Don't select steering targets not in CRConfig yet This way adding a steering target DS that hasn't been snapshotted yet won't cause clients to be 503'd if that non-snapped DS is selected. --- .../traffic_router/core/router/TrafficRouter.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 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 acaa9d4..49be6d4 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 @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; +import java.util.stream.Collectors; import com.comcast.cdn.traffic_control.traffic_router.configuration.ConfigurationListener; import com.comcast.cdn.traffic_control.traffic_router.core.ds.SteeringTarget; @@ -772,7 +773,7 @@ public class TrafficRouter { for (final SteeringTarget steeringTarget : steeringTargets) { final DeliveryService target = cacheRegister.getDeliveryService(steeringTarget.getDeliveryService()); - if (target != null) { + if (target != null) { // target might not be in CRConfig yet deliveryServices.add(target); } } @@ -797,10 +798,17 @@ public class TrafficRouter { final String bypassDeliveryServiceId = steering.getBypassDestination(requestPath); if (bypassDeliveryServiceId != null && !bypassDeliveryServiceId.isEmpty()) { - return cacheRegister.getDeliveryService(bypassDeliveryServiceId); + final DeliveryService bypass = cacheRegister.getDeliveryService(bypassDeliveryServiceId); + if (bypass != null) { // bypass DS target might not be in CRConfig yet. Until then, try existing targets + return bypass; + } } - final SteeringTarget steeringTarget = consistentHasher.selectHashable(steering.getTargets(), deliveryService.getDispersion(), requestPath); + // only select from targets in CRConfig + final List<SteeringTarget> availableTargets = steering.getTargets().stream() + .filter(target -> cacheRegister.getDeliveryService(target.getDeliveryService()) != null) + .collect(Collectors.toList()); + final SteeringTarget steeringTarget = consistentHasher.selectHashable(availableTargets, deliveryService.getDispersion(), requestPath); return cacheRegister.getDeliveryService(steeringTarget.getDeliveryService()); } -- To stop receiving notification emails like this one, please contact els...@apache.org.