clang-format

reviewable/pr14886/r3
Mark D. Roth 7 years ago
parent eef0cf6416
commit 5dd42ab4bb
  1. 15
      src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
  2. 38
      src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
  3. 55
      src/core/ext/filters/client_channel/lb_policy/subchannel_list.h

@ -73,8 +73,8 @@ class PickFirst : public LoadBalancingPolicy {
const grpc_lb_address& address,
grpc_subchannel* subchannel,
grpc_combiner* combiner)
: SubchannelData(subchannel_list, user_data_vtable, address,
subchannel, combiner) {}
: SubchannelData(subchannel_list, user_data_vtable, address, subchannel,
combiner) {}
void ProcessConnectivityChangeLocked(grpc_error* error) override;
};
@ -83,9 +83,9 @@ class PickFirst : public LoadBalancingPolicy {
: public SubchannelList<PickFirstSubchannelList,
PickFirstSubchannelData> {
public:
PickFirstSubchannelList(
PickFirst* policy, TraceFlag* tracer,
const grpc_lb_addresses* addresses, grpc_combiner* combiner,
PickFirstSubchannelList(PickFirst* policy, TraceFlag* tracer,
const grpc_lb_addresses* addresses,
grpc_combiner* combiner,
grpc_client_channel_factory* client_channel_factory,
const grpc_channel_args& args)
: SubchannelList(policy, tracer, addresses, combiner,
@ -430,9 +430,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
"sd->subchannel_list->shutting_down=%d error=%s",
p, subchannel(), Index(), subchannel_list()->num_subchannels(),
subchannel_list(),
grpc_connectivity_state_name(connectivity_state()),
p->shutdown_, subchannel_list()->shutting_down(),
grpc_error_string(error));
grpc_connectivity_state_name(connectivity_state()), p->shutdown_,
subchannel_list()->shutting_down(), grpc_error_string(error));
}
// If the policy is shutting down, unref and return.
if (p->shutdown_) {

@ -91,8 +91,8 @@ class RoundRobin : public LoadBalancingPolicy {
const grpc_lb_address& address,
grpc_subchannel* subchannel,
grpc_combiner* combiner)
: SubchannelData(subchannel_list, user_data_vtable, address,
subchannel, combiner),
: SubchannelData(subchannel_list, user_data_vtable, address, subchannel,
combiner),
user_data_vtable_(user_data_vtable),
user_data_(user_data_vtable_ != nullptr
? user_data_vtable_->copy(address.user_data)
@ -255,8 +255,8 @@ size_t RoundRobin::GetNextReadySubchannelIndexLocked() {
gpr_log(GPR_DEBUG,
"[RR %p] found next ready subchannel (%p) at index %" PRIuPTR
" of subchannel_list %p",
this, subchannel_list_->subchannel(index)->subchannel(),
index, subchannel_list_.get());
this, subchannel_list_->subchannel(index)->subchannel(), index,
subchannel_list_.get());
}
return index;
}
@ -272,13 +272,13 @@ void RoundRobin::UpdateLastReadySubchannelIndexLocked(size_t last_ready_index) {
GPR_ASSERT(last_ready_index < subchannel_list_->num_subchannels());
last_ready_subchannel_index_ = last_ready_index;
if (grpc_lb_round_robin_trace.enabled()) {
gpr_log(GPR_DEBUG,
gpr_log(
GPR_DEBUG,
"[RR %p] setting last_ready_subchannel_index=%" PRIuPTR
" (SC %p, CSC %p)",
this, last_ready_index,
subchannel_list_->subchannel(last_ready_index)->subchannel(),
subchannel_list_->subchannel(last_ready_index)
->connected_subchannel());
subchannel_list_->subchannel(last_ready_index)->connected_subchannel());
}
}
@ -382,8 +382,7 @@ bool RoundRobin::DoPickLocked(PickState* pick) {
*pick->user_data = sd->user_data();
}
if (grpc_lb_round_robin_trace.enabled()) {
gpr_log(
GPR_DEBUG,
gpr_log(GPR_DEBUG,
"[RR %p] Picked target <-- Subchannel %p (connected %p) (sl %p, "
"index %" PRIuPTR ")",
this, sd->subchannel(), pick->connected_subchannel.get(),
@ -508,8 +507,8 @@ void RoundRobin::RoundRobinSubchannelList::UpdateStateCountersLocked(
// Sets the RR policy's connectivity state based on the current
// subchannel list.
void
RoundRobin::RoundRobinSubchannelList::MaybeUpdateConnectivityStateLocked() {
void RoundRobin::RoundRobinSubchannelList::
MaybeUpdateConnectivityStateLocked() {
RoundRobin* p = static_cast<RoundRobin*>(policy());
// Only set connectivity state if this is the current subchannel list.
if (p->subchannel_list_ != this) return;
@ -586,14 +585,14 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked(
gpr_log(
GPR_DEBUG,
"[RR %p] connectivity changed for subchannel %p, subchannel_list %p "
"(index %" PRIuPTR " of %" PRIuPTR "): prev_state=%s new_state=%s "
"(index %" PRIuPTR " of %" PRIuPTR
"): prev_state=%s new_state=%s "
"p->shutdown=%d sd->subchannel_list->shutting_down=%d error=%s",
p, subchannel(), subchannel_list(), Index(),
subchannel_list()->num_subchannels(),
grpc_connectivity_state_name(prev_connectivity_state_),
grpc_connectivity_state_name(connectivity_state()),
p->shutdown_, subchannel_list()->shutting_down(),
grpc_error_string(error));
grpc_connectivity_state_name(connectivity_state()), p->shutdown_,
subchannel_list()->shutting_down(), grpc_error_string(error));
}
GPR_ASSERT(subchannel() != nullptr);
// If the subchannel list is shutting down, stop watching.
@ -633,9 +632,8 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked(
case GRPC_CHANNEL_IDLE:; // fallthrough
}
// Update state counters.
subchannel_list()->UpdateStateCountersLocked(prev_connectivity_state_,
connectivity_state(),
GRPC_ERROR_REF(error));
subchannel_list()->UpdateStateCountersLocked(
prev_connectivity_state_, connectivity_state(), GRPC_ERROR_REF(error));
prev_connectivity_state_ = connectivity_state();
// If we've started watching, update overall state and renew notification.
if (subchannel_list()->started_watching()) {
@ -694,8 +692,8 @@ void RoundRobin::UpdateLocked(const grpc_channel_args& args) {
if (latest_pending_subchannel_list_ != nullptr) {
if (grpc_lb_round_robin_trace.enabled()) {
gpr_log(GPR_DEBUG,
"[RR %p] Shutting down previous pending subchannel list %p",
this, latest_pending_subchannel_list_.get());
"[RR %p] Shutting down previous pending subchannel list %p", this,
latest_pending_subchannel_list_.get());
}
latest_pending_subchannel_list_->ShutdownLocked("sl_outdated");
}

@ -154,8 +154,7 @@ class SubchannelData {
GRPC_ABSTRACT_BASE_CLASS
protected:
SubchannelData(
SubchannelListType* subchannel_list,
SubchannelData(SubchannelListType* subchannel_list,
const grpc_lb_user_data_vtable* user_data_vtable,
const grpc_lb_address& address, grpc_subchannel* subchannel,
grpc_combiner* combiner);
@ -195,8 +194,7 @@ class SubchannelData {
// A list of subchannels.
template <typename SubchannelListType, typename SubchannelDataType>
class SubchannelList
: public RefCountedWithTracing<SubchannelListType> {
class SubchannelList : public RefCountedWithTracing<SubchannelListType> {
public:
typedef InlinedVector<SubchannelDataType, 10> SubchannelVector;
@ -278,17 +276,16 @@ SubchannelData<SubchannelListType, SubchannelDataType>::~SubchannelData() {
}
template <typename SubchannelListType, typename SubchannelDataType>
void SubchannelData<SubchannelListType,
SubchannelDataType>::UnrefSubchannelLocked(
const char* reason) {
void SubchannelData<SubchannelListType, SubchannelDataType>::
UnrefSubchannelLocked(const char* reason) {
if (subchannel_ != nullptr) {
if (subchannel_list_->tracer()->enabled()) {
gpr_log(GPR_DEBUG,
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
" (subchannel %p): unreffing subchannel",
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
subchannel_list_, Index(),
subchannel_list_->num_subchannels(), subchannel_);
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
subchannel_);
}
GRPC_SUBCHANNEL_UNREF(subchannel_, reason);
subchannel_ = nullptr;
@ -300,21 +297,19 @@ template <typename SubchannelListType, typename SubchannelDataType>
void SubchannelData<SubchannelListType,
SubchannelDataType>::StartConnectivityWatchLocked() {
if (subchannel_list_->tracer()->enabled()) {
gpr_log(
GPR_DEBUG,
gpr_log(GPR_DEBUG,
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
" (subchannel %p): requesting connectivity change "
"notification (from %s)",
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
subchannel_list_, Index(),
subchannel_list_->num_subchannels(), subchannel_,
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
subchannel_,
grpc_connectivity_state_name(pending_connectivity_state_unsafe_));
}
connectivity_notification_pending_ = true;
grpc_subchannel_notify_on_state_change(
subchannel_, subchannel_list_->policy()->interested_parties(),
&pending_connectivity_state_unsafe_,
&connectivity_changed_closure_);
&pending_connectivity_state_unsafe_, &connectivity_changed_closure_);
}
template <typename SubchannelListType, typename SubchannelDataType>
@ -325,33 +320,31 @@ void SubchannelData<SubchannelListType,
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
" (subchannel %p): stopping connectivity watch",
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
subchannel_list_, Index(),
subchannel_list_->num_subchannels(), subchannel_);
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
subchannel_);
}
GPR_ASSERT(connectivity_notification_pending_);
connectivity_notification_pending_ = false;
}
template <typename SubchannelListType, typename SubchannelDataType>
void SubchannelData<SubchannelListType,
SubchannelDataType>::CancelConnectivityWatchLocked(
const char* reason) {
void SubchannelData<SubchannelListType, SubchannelDataType>::
CancelConnectivityWatchLocked(const char* reason) {
if (subchannel_list_->tracer()->enabled()) {
gpr_log(GPR_DEBUG,
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
" (subchannel %p): canceling connectivity watch (%s)",
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
subchannel_list_, Index(),
subchannel_list_->num_subchannels(), subchannel_, reason);
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
subchannel_, reason);
}
grpc_subchannel_notify_on_state_change(subchannel_, nullptr, nullptr,
&connectivity_changed_closure_);
}
template <typename SubchannelListType, typename SubchannelDataType>
void SubchannelData<SubchannelListType,
SubchannelDataType>::OnConnectivityChangedLocked(
void* arg, grpc_error* error) {
void SubchannelData<SubchannelListType, SubchannelDataType>::
OnConnectivityChangedLocked(void* arg, grpc_error* error) {
SubchannelData* sd = static_cast<SubchannelData*>(arg);
// Now that we're inside the combiner, copy the pending connectivity
// state (which was set by the connectivity state watcher) to
@ -365,8 +358,8 @@ void SubchannelData<SubchannelListType,
}
template <typename SubchannelListType, typename SubchannelDataType>
void SubchannelData<SubchannelListType,
SubchannelDataType>::ShutdownLocked(const char* reason) {
void SubchannelData<SubchannelListType, SubchannelDataType>::ShutdownLocked(
const char* reason) {
// If there's a pending notification for this subchannel, cancel it;
// the callback is responsible for unreffing the subchannel.
// Otherwise, unref the subchannel directly.
@ -447,14 +440,14 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
template <typename SubchannelListType, typename SubchannelDataType>
SubchannelList<SubchannelListType, SubchannelDataType>::~SubchannelList() {
if (tracer_->enabled()) {
gpr_log(GPR_DEBUG, "[%s %p] Destroying subchannel_list %p",
tracer_->name(), policy_, this);
gpr_log(GPR_DEBUG, "[%s %p] Destroying subchannel_list %p", tracer_->name(),
policy_, this);
}
}
template <typename SubchannelListType, typename SubchannelDataType>
void SubchannelList<SubchannelListType,
SubchannelDataType>::ShutdownLocked(const char* reason) {
void SubchannelList<SubchannelListType, SubchannelDataType>::ShutdownLocked(
const char* reason) {
if (tracer_->enabled()) {
gpr_log(GPR_DEBUG, "[%s %p] Shutting down subchannel_list %p (%s)",
tracer_->name(), policy_, this, reason);

Loading…
Cancel
Save