Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions plugins/experimental/parent_select/consistenthash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,8 @@ PLNextHopConsistentHash::deleteTxn(void *txn)
}

void
PLNextHopConsistentHash::next(TSHttpTxn txnp, void *strategyTxn, const char *exclude_hostname, size_t exclude_hostname_len,
in_port_t exclude_port, const char **out_hostname, size_t *out_hostname_len, in_port_t *out_port,
bool *out_retry, bool *out_no_cache, time_t now)
PLNextHopConsistentHash::next(TSHttpTxn txnp, void *strategyTxn, const char **out_hostname, size_t *out_hostname_len,
in_port_t *out_port, bool *out_retry, bool *out_no_cache, time_t now)
{
// TODO add logic in the strategy to track when someone is retrying, and not give it out to multiple threads at once, to prevent
// thundering retries See github issue #7485
Expand Down
5 changes: 2 additions & 3 deletions plugins/experimental/parent_select/consistenthash.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ class PLNextHopConsistentHash : public PLNextHopSelectionStrategy
PLNextHopConsistentHash() = delete;
PLNextHopConsistentHash(const std::string_view name, const YAML::Node &n);
~PLNextHopConsistentHash();
void next(TSHttpTxn txnp, void *strategyTxn, const char *exclude_hostname, size_t exclude_hostname_len, in_port_t exclude_port,
const char **out_hostname, size_t *out_hostname_len, in_port_t *out_port, bool *out_retry, bool *out_no_cache,
time_t now = 0) override;
void next(TSHttpTxn txnp, void *strategyTxn, const char **out_hostname, size_t *out_hostname_len, in_port_t *out_port,
bool *out_retry, bool *out_no_cache, time_t now = 0) override;
void mark(TSHttpTxn txnp, void *strategyTxn, const char *hostname, const size_t hostname_len, const in_port_t port,
const PLNHCmd status, const time_t now) override;
void *newTxn() override;
Expand Down
13 changes: 3 additions & 10 deletions plugins/experimental/parent_select/parent_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ handle_read_response(TSHttpTxn txnp, StrategyTxn *strategyTxn)
TSResponseAction ra;
TSHttpTxnResponseActionGet(txnp, &ra);
ra.responseIsRetryable = strategy->responseIsRetryable(strategyTxn->request_count - 1, status);

TSHttpTxnResponseActionSet(txnp, &ra);
}

Expand Down Expand Up @@ -168,11 +169,7 @@ handle_os_dns(TSHttpTxn txnp, StrategyTxn *strategyTxn)

TSResponseAction ra;
memset(&ra, 0, sizeof(TSResponseAction));
const char *const exclude_host = strategyTxn->prev_ra.hostname;
const size_t exclude_host_len = strategyTxn->prev_ra.hostname_len;
const in_port_t exclude_port = strategyTxn->prev_ra.port;
strategy->next(txnp, strategyTxn->txn, exclude_host, exclude_host_len, exclude_port, &ra.hostname, &ra.hostname_len, &ra.port,
&ra.is_retry, &ra.no_cache);
strategy->next(txnp, strategyTxn->txn, &ra.hostname, &ra.hostname_len, &ra.port, &ra.is_retry, &ra.no_cache);

ra.fail = ra.hostname == nullptr; // failed is whether to immediately fail and return the client a 502. In this case: whether or
// not we found another parent.
Expand Down Expand Up @@ -340,11 +337,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)

TSResponseAction ra;
memset(&ra, 0, sizeof(TSResponseAction)); // because {0} gives a C++ warning. Ugh.
constexpr const char *const exclude_host = nullptr;
constexpr const size_t exclude_host_len = 0;
constexpr const in_port_t exclude_port = 0;
strategy->next(txnp, strategyTxn->txn, exclude_host, exclude_host_len, exclude_port, &ra.hostname, &ra.hostname_len, &ra.port,
&ra.is_retry, &ra.no_cache);
strategy->next(txnp, strategyTxn->txn, &ra.hostname, &ra.hostname_len, &ra.port, &ra.is_retry, &ra.no_cache);

ra.nextHopExists = ra.hostname != nullptr;
ra.fail = !ra.nextHopExists;
Expand Down
10 changes: 4 additions & 6 deletions plugins/experimental/parent_select/strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ class TSNextHopSelectionStrategy
virtual ~TSNextHopSelectionStrategy(){};

virtual const char *name() = 0;
virtual void next(TSHttpTxn txnp, void *strategyTxn, const char *exclude_hostname, size_t exclude_hostname_len,
in_port_t exclude_port, const char **out_hostname, size_t *out_hostname_len, in_port_t *out_port,
virtual void next(TSHttpTxn txnp, void *strategyTxn, const char **out_hostname, size_t *out_hostname_len, in_port_t *out_port,
bool *out_retry, bool *out_no_cache, time_t now = 0) = 0;
virtual void mark(TSHttpTxn txnp, void *strategyTxn, const char *hostname, const size_t hostname_len, const in_port_t port,
const PLNHCmd status, const time_t now = 0) = 0;
Expand All @@ -244,11 +243,10 @@ class PLNextHopSelectionStrategy : public TSNextHopSelectionStrategy
PLNextHopSelectionStrategy(const std::string_view &name, const YAML::Node &n);
virtual ~PLNextHopSelectionStrategy(){};

void next(TSHttpTxn txnp, void *strategyTxn, const char *exclude_hostname, size_t exclude_hostname_len, in_port_t exclude_port,
const char **out_hostname, size_t *out_hostname_len, in_port_t *out_port, bool *out_retry, bool *out_no_cache,
time_t now = 0) override = 0;
void next(TSHttpTxn txnp, void *strategyTxn, const char **out_hostname, size_t *out_hostname_len, in_port_t *out_port,
bool *out_retry, bool *out_no_cache, time_t now = 0) override = 0;
void mark(TSHttpTxn txnp, void *strategyTxn, const char *hostname, const size_t hostname_len, const in_port_t port,
const PLNHCmd status, const time_t now = 0) override = 0;
const PLNHCmd status, const time_t now = 0) override = 0;
bool nextHopExists(TSHttpTxn txnp) override;
bool codeIsFailure(TSHttpStatus response_code) override;
bool responseIsRetryable(unsigned int current_retry_attempts, TSHttpStatus response_code) override;
Expand Down