|
27 | 27 | #include "iocore/utils/Machine.h" |
28 | 28 | #include "tsutil/YamlCfg.h" |
29 | 29 | #include "proxy/http/remap/NextHopConsistentHash.h" |
| 30 | +#include "proxy/ParentSelection.h" |
30 | 31 |
|
31 | 32 | // hash_key strings. |
32 | 33 | constexpr std::string_view hash_key_url = "url"; |
@@ -57,16 +58,10 @@ std::shared_ptr<HostRecord> |
57 | 58 | NextHopConsistentHash::chashLookup(const std::shared_ptr<ATSConsistentHash> &ring, uint32_t cur_ring, ParentResult &result, |
58 | 59 | HttpRequestData &request_info, bool *wrapped, uint64_t sm_id) |
59 | 60 | { |
60 | | - uint64_t hash_key = 0; |
61 | | - // Create hash instance based on configured algorithm and seeds |
62 | | - std::unique_ptr<ATSHash64> hash; |
63 | | - if (hash_algorithm == "siphash13") { |
64 | | - hash = std::make_unique<ATSHash64Sip13>(hash_seed0, hash_seed1); |
65 | | - } else { |
66 | | - hash = std::make_unique<ATSHash64Sip24>(hash_seed0, hash_seed1); |
67 | | - } |
68 | | - HostRecord *host_rec = nullptr; |
69 | | - ATSConsistentHashIter *iter = &result.chashIter[cur_ring]; |
| 61 | + uint64_t hash_key = 0; |
| 62 | + std::unique_ptr<ATSHash64> hash = createHashInstance(parseHashAlgorithm(hash_algorithm), hash_seed0, hash_seed1); |
| 63 | + HostRecord *host_rec = nullptr; |
| 64 | + ATSConsistentHashIter *iter = &result.chashIter[cur_ring]; |
70 | 65 |
|
71 | 66 | if (result.chash_init[cur_ring] == false) { |
72 | 67 | hash_key = getHashKey(sm_id, request_info, hash.get()); |
@@ -196,13 +191,7 @@ NextHopConsistentHash::NextHopConsistentHash(const std::string_view name, const |
196 | 191 | "', this strategy will be ignored."); |
197 | 192 | } |
198 | 193 |
|
199 | | - // Create the hash instance based on configured algorithm and seeds |
200 | | - if (hash_algorithm == "siphash13") { |
201 | | - hash = std::make_unique<ATSHash64Sip13>(hash_seed0, hash_seed1); |
202 | | - } else { |
203 | | - // Default to siphash24 |
204 | | - hash = std::make_unique<ATSHash64Sip24>(hash_seed0, hash_seed1); |
205 | | - } |
| 194 | + hash = createHashInstance(parseHashAlgorithm(hash_algorithm), hash_seed0, hash_seed1); |
206 | 195 |
|
207 | 196 | // load up the hash rings. |
208 | 197 | for (uint32_t i = 0; i < groups; i++) { |
|
0 commit comments