diff --git a/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc index 6190c34e0df..27e4ed811d0 100644 --- a/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc @@ -340,11 +340,7 @@ class WeightedRoundRobin : public LoadBalancingPolicy { ABSL_EXCLUSIVE_LOCKS_REQUIRED(&timer_mu_); RefCountedPtr wrr_; - const bool use_per_rpc_utilization_; - const Duration weight_update_period_; - const Duration weight_expiration_period_; - const Duration blackout_period_; - const float error_utilization_penalty_; + RefCountedPtr config_; std::vector subchannels_; Mutex scheduler_mu_; @@ -505,11 +501,7 @@ WeightedRoundRobin::Picker::Picker( RefCountedPtr wrr, WeightedRoundRobinSubchannelList* subchannel_list) : wrr_(std::move(wrr)), - use_per_rpc_utilization_(!wrr_->config_->enable_oob_load_report()), - weight_update_period_(wrr_->config_->weight_update_period()), - weight_expiration_period_(wrr_->config_->weight_expiration_period()), - blackout_period_(wrr_->config_->blackout_period()), - error_utilization_penalty_(wrr_->config_->error_utilization_penalty()), + config_(wrr_->config_), last_picked_index_(absl::Uniform(wrr_->bit_gen_)) { for (size_t i = 0; i < subchannel_list->num_subchannels(); ++i) { WeightedRoundRobinSubchannelData* sd = subchannel_list->subchannel(i); @@ -548,9 +540,9 @@ WeightedRoundRobin::PickResult WeightedRoundRobin::Picker::Pick( auto& subchannel_info = subchannels_[index]; // Collect per-call utilization data if needed. std::unique_ptr subchannel_call_tracker; - if (use_per_rpc_utilization_) { + if (!config_->enable_oob_load_report()) { subchannel_call_tracker = std::make_unique( - subchannel_info.weight, error_utilization_penalty_); + subchannel_info.weight, config_->error_utilization_penalty()); } if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_wrr_trace)) { gpr_log(GPR_INFO, @@ -582,7 +574,7 @@ void WeightedRoundRobin::Picker::BuildSchedulerAndStartTimerLocked() { weights.reserve(subchannels_.size()); for (const auto& subchannel : subchannels_) { weights.push_back(subchannel.weight->GetWeight( - now, weight_expiration_period_, blackout_period_)); + now, config_->weight_expiration_period(), config_->blackout_period())); } if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_wrr_trace)) { gpr_log(GPR_INFO, "[WRR %p picker %p] new weights: %s", wrr_.get(), this, @@ -609,7 +601,7 @@ void WeightedRoundRobin::Picker::BuildSchedulerAndStartTimerLocked() { // Start timer. WeakRefCountedPtr self = WeakRef(); timer_handle_ = wrr_->channel_control_helper()->GetEventEngine()->RunAfter( - weight_update_period_, [self = std::move(self)]() mutable { + config_->weight_update_period(), [self = std::move(self)]() mutable { ApplicationCallbackExecCtx callback_exec_ctx; ExecCtx exec_ctx; {