This repository was archived by the owner on Nov 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 356
Changes for Backup Edge Cache Group #1908
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -265,8 +265,9 @@ public List<Cache> getCachesByGeo(final DeliveryService ds, final Geolocation cl | |
| protected List<Cache> selectCaches(final HTTPRequest request, final DeliveryService ds, final Track track) throws GeolocationException { | ||
| CacheLocation cacheLocation; | ||
| ResultType result = ResultType.CZ; | ||
| final boolean useDeep = (ds.getDeepCache() == DeliveryService.DeepCachingType.ALWAYS); | ||
|
|
||
| if (ds.getDeepCache() == DeliveryService.DeepCachingType.ALWAYS) { | ||
| if (useDeep) { | ||
| // Deep caching is enabled. See if there are deep caches available | ||
| cacheLocation = getDeepCoverageZoneCacheLocation(request.getClientIP(), ds); | ||
| if (cacheLocation != null && cacheLocation.getCaches().size() != 0) { | ||
|
|
@@ -278,7 +279,7 @@ protected List<Cache> selectCaches(final HTTPRequest request, final DeliveryServ | |
| } | ||
| } else { | ||
| // Deep caching not enabled for this Delivery Service; use the regular CZ | ||
| cacheLocation = getCoverageZoneCacheLocation(request.getClientIP(), ds); | ||
| cacheLocation = getCoverageZoneCacheLocation(request.getClientIP(), ds, track, useDeep); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally this line should just pass |
||
| } | ||
|
|
||
| List<Cache>caches = selectCachesByCZ(ds, cacheLocation, track, result); | ||
|
|
@@ -295,15 +296,15 @@ protected List<Cache> selectCaches(final HTTPRequest request, final DeliveryServ | |
| track.setResult(ResultType.MISS); | ||
| track.setResultDetails(ResultDetails.DS_CZ_ONLY); | ||
| } | ||
| } else { | ||
| } else if (track.isUseNextClosest()) { | ||
| //Even with Geo limit none, TR wont do geo look-up, if fallback is disabled via backupZones configuration | ||
| caches = selectCachesByGeo(request.getClientIP(), ds, cacheLocation, track); | ||
| } | ||
|
|
||
| return caches; | ||
| } | ||
|
|
||
| public List<Cache> selectCachesByGeo(final String clientIp, final DeliveryService deliveryService, final CacheLocation cacheLocation, final Track track) throws GeolocationException { | ||
|
|
||
| Geolocation clientLocation = null; | ||
|
|
||
| try { | ||
|
|
@@ -365,7 +366,7 @@ public DNSRouteResult route(final DNSRequest request, final Track track) throws | |
| return result; | ||
| } | ||
|
|
||
| final CacheLocation cacheLocation = getCoverageZoneCacheLocation(request.getClientIP(), ds); | ||
| final CacheLocation cacheLocation = getCoverageZoneCacheLocation(request.getClientIP(), ds, track, false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it possible to change the method signature to have this be |
||
| List<Cache> caches = selectCachesByCZ(ds, cacheLocation, track); | ||
|
|
||
| if (caches != null) { | ||
|
|
@@ -394,7 +395,9 @@ public DNSRouteResult route(final DNSRequest request, final Track track) throws | |
| LOGGER.error("Bad client address: '" + request.getClientIP() + "'"); | ||
| } | ||
|
|
||
| caches = selectCachesByGeo(request.getClientIP(), ds, cacheLocation, track); | ||
| if (track.isUseNextClosest()) { | ||
| caches = selectCachesByGeo(request.getClientIP(), ds, cacheLocation, track); | ||
| } | ||
|
|
||
| if (caches != null) { | ||
| track.setResult(ResultType.GEO); | ||
|
|
@@ -486,6 +489,9 @@ private List<Cache> selectCachesByCZ(final DeliveryService ds, final CacheLocati | |
|
|
||
| if (caches != null && track != null) { | ||
| track.setResult(result); | ||
| if (track.isFromBackupCzGroup()) { | ||
| track.setResultDetails(ResultDetails.DS_CZ_BACKUP_CG); | ||
| } | ||
| track.setResultLocation(cacheLocation.getGeolocation()); | ||
| } | ||
|
|
||
|
|
@@ -655,11 +661,11 @@ protected NetworkNode getNetworkNode(final String ip) { | |
| } | ||
|
|
||
| public CacheLocation getCoverageZoneCacheLocation(final String ip, final String deliveryServiceId) { | ||
| return getCoverageZoneCacheLocation(ip, deliveryServiceId, false); // default is not deep | ||
| return getCoverageZoneCacheLocation(ip, deliveryServiceId, null, false); // default is not deep | ||
| } | ||
|
|
||
| @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) | ||
| public CacheLocation getCoverageZoneCacheLocation(final String ip, final String deliveryServiceId, final boolean useDeep) { | ||
| public CacheLocation getCoverageZoneCacheLocation(final String ip, final String deliveryServiceId, final Track track, final boolean useDeep) { | ||
| final NetworkNode networkNode = useDeep ? getDeepNetworkNode(ip) : getNetworkNode(ip); | ||
|
|
||
| if (networkNode == null) { | ||
|
|
@@ -695,17 +701,48 @@ public CacheLocation getCoverageZoneCacheLocation(final String ip, final String | |
| return cacheLocation; | ||
| } | ||
|
|
||
| // 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)); | ||
| if (networkNode.getBackupCacheGroups() != null) { | ||
| for (final String cacheGroup : networkNode.getBackupCacheGroups()) { | ||
| final CacheLocation bkCacheLocation = getCacheRegister().getCacheLocationById(cacheGroup); | ||
| if (bkCacheLocation != null && !getSupportingCaches(bkCacheLocation.getCaches(), deliveryService).isEmpty()) { | ||
| LOGGER.debug("Got backup CZ cache group " + bkCacheLocation.getId() + " for " + ip + ", ds " + deliveryServiceId); | ||
| if (track != null) { | ||
| track.setFromBackupCzGroup(true); | ||
| } | ||
| return bkCacheLocation; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| CacheLocation closestCacheLocation = null; | ||
|
|
||
| if (networkNode.isUseClosest()) { | ||
| // 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. | ||
| closestCacheLocation = getClosestCacheLocation(cacheRegister.filterAvailableLocations(deliveryServiceId), networkNode.getGeolocation(), cacheRegister.getDeliveryService(deliveryServiceId)); | ||
| if (closestCacheLocation != null) { | ||
| LOGGER.debug("Got closest CZ cache group " + closestCacheLocation.getId() + " for " + ip + ", ds " + deliveryServiceId); | ||
| if (track != null) { | ||
| track.setFromBackupCzGroup(true); | ||
|
|
||
| } | ||
| return closestCacheLocation; | ||
| } | ||
| } else { | ||
| if (track != null) { | ||
| track.setUseNextClosest(false); | ||
| } | ||
| } | ||
|
|
||
| return closestCacheLocation; | ||
| } | ||
|
|
||
| public CacheLocation getDeepCoverageZoneCacheLocation(final String ip, final DeliveryService deliveryService) { | ||
| return getCoverageZoneCacheLocation(ip, deliveryService, true); | ||
| return getCoverageZoneCacheLocation(ip, deliveryService, null, true); | ||
| } | ||
|
|
||
| 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, final Track track, final boolean useDeep) { | ||
| return getCoverageZoneCacheLocation(ip, deliveryService.getId(), track, useDeep); | ||
| } | ||
|
|
||
| protected CacheLocation getCoverageZoneCacheLocation(final String ip, final DeliveryService deliveryService) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add
DS_CZ_NO_BKPto signify that the matched cachegroup and its configured backup cachegroups were unavailable.