elsloo closed pull request #1886: Fix for Traffic Router zero dispersion issue
URL: https://github.com/apache/incubator-trafficcontrol/pull/1886
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/ds/Dispersion.java
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/Dispersion.java
index 1f978d3916..ee41ff34f6 100644
---
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/Dispersion.java
+++
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/Dispersion.java
@@ -37,7 +37,10 @@ public Dispersion(final JsonNode dsJo) {
final JsonNode jo = dsJo.get("dispersion");
if (jo != null) {
- this.setLimit(JsonUtils.optInt(jo, "limit",
DEFAULT_LIMIT));
+ final int limit = JsonUtils.optInt(jo, "limit",
DEFAULT_LIMIT);
+ if (limit != 0) {
+ this.setLimit(limit);
+ }
this.setShuffled(JsonUtils.optBoolean(jo, "shuffled",
DEFAULT_SHUFFLED));
} else if (dsJo.has("maxDnsIpsForLocation")) {
// if no specific dispersion, use maxDnsIpsForLocation
(should be DNS DSs only)
diff --git
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/hash/ConsistentHasher.java
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/hash/ConsistentHasher.java
index 91cbdb6994..e3642eeb16 100644
---
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/hash/ConsistentHasher.java
+++
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/hash/ConsistentHasher.java
@@ -28,7 +28,8 @@
final private MD5HashFunction hashFunction = new MD5HashFunction();
public <T extends Hashable> T selectHashable(final List<T> hashables,
final Dispersion dispersion, final String s) {
- return selectHashables(hashables, dispersion, s).get(0);
+ final List<T> selectedHashables = selectHashables(hashables,
dispersion, s);
+ return !selectedHashables.isEmpty() ? selectedHashables.get(0)
: null;
}
public <T extends Hashable> List<T> selectHashables(final List<T>
hashables, final String s) {
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services