You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/02/07 19:56:19 UTC

[GitHub] rivasj closed pull request #1853: Implemented default.lat/long.to.override configs to avoid using maxmind default coordinates

rivasj closed pull request #1853: Implemented default.lat/long.to.override configs to avoid using maxmind default coordinates
URL: https://github.com/apache/incubator-trafficcontrol/pull/1853
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 acaa9d4105..b233ad5d07 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
@@ -85,6 +85,8 @@
 	private final ConsistentHasher consistentHasher = new ConsistentHasher();
 	private SteeringRegistry steeringRegistry;
 
+	private final Geolocation defaultLocationToOverride;
+
 	public TrafficRouter(final CacheRegister cr, 
 			final GeolocationService geolocationService, 
 			final GeolocationService geolocationService6, 
@@ -98,6 +100,13 @@ public TrafficRouter(final CacheRegister cr,
 		this.federationRegistry = federationRegistry;
 		this.consistentDNSRouting = JsonUtils.optBoolean(cr.getConfig(), "consistent.dns.routing");
 		this.zoneManager = new ZoneManager(this, statTracker, trafficOpsUtils, trafficRouterManager);
+		final double geoLat = JsonUtils.optDouble(cr.getConfig(), "default.lat.to.override");
+		final double geoLong = JsonUtils.optDouble(cr.getConfig(), "default.long.to.override");
+		if (geoLat != 0 && geoLong != 0) {
+			this.defaultLocationToOverride = new Geolocation(geoLat, geoLong);
+		} else {
+			this.defaultLocationToOverride = null;
+		}
 	}
 
 	public ZoneManager getZoneManager() {
@@ -308,6 +317,10 @@ public Geolocation getLocation(final String clientIP, final DeliveryService deli
 			}
 		}
 
+		if (deliveryService.getMissLocation() != null && clientLocation.equals(this.defaultLocationToOverride)) {
+			clientLocation = deliveryService.getMissLocation();
+		}
+
 		final List<Cache> caches = getCachesByGeo(deliveryService, clientLocation, track);
 
 		if (caches == null || caches.isEmpty()) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services