Repository: qpid-dispatch Updated Branches: refs/heads/master 01a2c5fb9 -> c71dd1526
DISPATCH-57 - Use ineligible (full) links in balanced distribution only if there are no eligible links. Don't return zero-fanout unless there are no available destinations. Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/c71dd152 Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/c71dd152 Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/c71dd152 Branch: refs/heads/master Commit: c71dd152664f3bf4240f1b6f83b01171afb793b4 Parents: 01a2c5f Author: Ted Ross <[email protected]> Authored: Mon May 16 15:44:30 2016 -0400 Committer: Ted Ross <[email protected]> Committed: Mon May 16 15:44:30 2016 -0400 ---------------------------------------------------------------------- src/router_core/forwarder.c | 60 ++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/c71dd152/src/router_core/forwarder.c ---------------------------------------------------------------------- diff --git a/src/router_core/forwarder.c b/src/router_core/forwarder.c index 43c966f..35d2f55 100644 --- a/src/router_core/forwarder.c +++ b/src/router_core/forwarder.c @@ -430,16 +430,21 @@ int qdr_forward_balanced_CT(qdr_core_t *core, addr->outstanding_deliveries[i] = 0; } - qdr_link_t *chosen_link = 0; - int chosen_link_bit = -1; - uint32_t link_value = UINT32_MAX; - bool transit = false; + qdr_link_t *best_eligible_link = 0; + int best_eligible_link_bit = -1; + uint32_t eligible_link_value = UINT32_MAX; + qdr_link_t *best_ineligible_link = 0; + int best_ineligible_link_bit = -1; + uint32_t ineligible_link_value = UINT32_MAX; // // Find all the possible outbound links for this delivery, searching for the one with the // smallest eligible value. Value = outstanding_deliveries + minimum_downrange_cost. // A link is ineligible if the outstanding_deliveries is equal to the link's capacity. // + // If there are no eligible links, use the best ineligible link. Zero fanout should be returned + // only if there are no available destinations. + // // // Start with the local links @@ -451,11 +456,15 @@ int qdr_forward_balanced_CT(qdr_core_t *core, bool eligible = link->capacity > value; // - // If this is the best eligible link thus far, choose it. + // If this is the best eligible link so far, record the fact. + // Otherwise, if this is the best ineligible link, make note of that. // - if (eligible && link_value > value) { - chosen_link = link; - link_value = value; + if (eligible && eligible_link_value > value) { + best_eligible_link = link; + eligible_link_value = value; + } else if (!eligible && ineligible_link_value > value) { + best_ineligible_link = link; + ineligible_link_value = value; } link_ref = DEQ_NEXT(link_ref); @@ -465,7 +474,7 @@ int qdr_forward_balanced_CT(qdr_core_t *core, // If we haven't already found a link with zero (best possible) value, check the // inter-router links as well. // - if (!chosen_link || link_value > 0) { + if (!best_eligible_link || eligible_link_value > 0) { // // Get the mask bit associated with the ingress router for the message. // This will be compared against the "valid_origin" masks for each @@ -488,23 +497,40 @@ int qdr_forward_balanced_CT(qdr_core_t *core, qdr_node_t *rnode = core->routers_by_mask_bit[node_bit]; qdr_node_t *next_node = rnode->next_hop ? rnode->next_hop : rnode; qdr_link_t *link = next_node->peer_data_link; + if (!link) continue; int link_bit = link->conn->mask_bit; int value = addr->outstanding_deliveries[link_bit]; - if (value < link->capacity && qd_bitmask_value(rnode->valid_origins, origin)) { + bool eligible = link->capacity > value; + + if (qd_bitmask_value(rnode->valid_origins, origin)) { // - // Link is eligible, adjust the value by the bias (node cost). + // Link is a candidate, adjust the value by the bias (node cost). // value += rnode->cost; - if (link_value > value) { - chosen_link = link; - chosen_link_bit = link_bit; - link_value = value; - transit = true; + if (eligible && eligible_link_value > value) { + best_eligible_link = link; + best_eligible_link_bit = link_bit; + eligible_link_value = value; + } else if (!eligible && ineligible_link_value > value) { + best_ineligible_link = link; + best_ineligible_link_bit = link_bit; + ineligible_link_value = value; } } } } + qdr_link_t *chosen_link = 0; + int chosen_link_bit = -1; + + if (best_eligible_link) { + chosen_link = best_eligible_link; + chosen_link_bit = best_eligible_link_bit; + } else if (best_ineligible_link) { + chosen_link = best_ineligible_link; + chosen_link_bit = best_ineligible_link_bit; + } + if (chosen_link) { qdr_delivery_t *out_delivery = qdr_forward_new_delivery_CT(core, in_delivery, chosen_link, msg); qdr_forward_deliver_CT(core, chosen_link, out_delivery); @@ -521,7 +547,7 @@ int qdr_forward_balanced_CT(qdr_core_t *core, // // Bump the appropriate counter based on where we sent the delivery. // - if (transit) + if (chosen_link_bit >= 0) addr->deliveries_transit++; else addr->deliveries_egress++; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
