|
|
|
@ -201,7 +201,7 @@ void PickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() { |
|
|
|
|
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); |
|
|
|
|
channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_TRANSIENT_FAILURE, |
|
|
|
|
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error))); |
|
|
|
|
MakeUnique<TransientFailurePicker>(error)); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// If one of the subchannels in the new list is already in state
|
|
|
|
@ -319,12 +319,11 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( |
|
|
|
|
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); |
|
|
|
|
p->channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_TRANSIENT_FAILURE, |
|
|
|
|
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error))); |
|
|
|
|
MakeUnique<TransientFailurePicker>(error)); |
|
|
|
|
} else { |
|
|
|
|
p->channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_CONNECTING, |
|
|
|
|
UniquePtr<SubchannelPicker>( |
|
|
|
|
New<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker")))); |
|
|
|
|
MakeUnique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker"))); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) { |
|
|
|
@ -339,20 +338,19 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( |
|
|
|
|
p->selected_ = nullptr; |
|
|
|
|
p->subchannel_list_.reset(); |
|
|
|
|
p->channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_IDLE, UniquePtr<SubchannelPicker>(New<QueuePicker>( |
|
|
|
|
p->Ref(DEBUG_LOCATION, "QueuePicker")))); |
|
|
|
|
GRPC_CHANNEL_IDLE, |
|
|
|
|
MakeUnique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker"))); |
|
|
|
|
} else { |
|
|
|
|
// This is unlikely but can happen when a subchannel has been asked
|
|
|
|
|
// to reconnect by a different channel and this channel has dropped
|
|
|
|
|
// some connectivity state notifications.
|
|
|
|
|
if (connectivity_state == GRPC_CHANNEL_READY) { |
|
|
|
|
p->channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_READY, |
|
|
|
|
UniquePtr<SubchannelPicker>(New<Picker>(subchannel()->Ref()))); |
|
|
|
|
GRPC_CHANNEL_READY, MakeUnique<Picker>(subchannel()->Ref())); |
|
|
|
|
} else { // CONNECTING
|
|
|
|
|
p->channel_control_helper()->UpdateState( |
|
|
|
|
connectivity_state, UniquePtr<SubchannelPicker>(New<QueuePicker>( |
|
|
|
|
p->Ref(DEBUG_LOCATION, "QueuePicker")))); |
|
|
|
|
connectivity_state, |
|
|
|
|
MakeUnique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -396,7 +394,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( |
|
|
|
|
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); |
|
|
|
|
p->channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_TRANSIENT_FAILURE, |
|
|
|
|
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error))); |
|
|
|
|
MakeUnique<TransientFailurePicker>(error)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
sd->CheckConnectivityStateAndStartWatchingLocked(); |
|
|
|
@ -408,8 +406,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( |
|
|
|
|
if (subchannel_list() == p->subchannel_list_.get()) { |
|
|
|
|
p->channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_CONNECTING, |
|
|
|
|
UniquePtr<SubchannelPicker>( |
|
|
|
|
New<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker")))); |
|
|
|
|
MakeUnique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker"))); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -448,8 +445,7 @@ void PickFirst::PickFirstSubchannelData::ProcessUnselectedReadyLocked() { |
|
|
|
|
} |
|
|
|
|
p->selected_ = this; |
|
|
|
|
p->channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_READY, |
|
|
|
|
UniquePtr<SubchannelPicker>(New<Picker>(subchannel()->Ref()))); |
|
|
|
|
GRPC_CHANNEL_READY, MakeUnique<Picker>(subchannel()->Ref())); |
|
|
|
|
for (size_t i = 0; i < subchannel_list()->num_subchannels(); ++i) { |
|
|
|
|
if (i != Index()) { |
|
|
|
|
subchannel_list()->subchannel(i)->ShutdownLocked(); |
|
|
|
@ -488,7 +484,7 @@ class PickFirstFactory : public LoadBalancingPolicyFactory { |
|
|
|
|
public: |
|
|
|
|
OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy( |
|
|
|
|
LoadBalancingPolicy::Args args) const override { |
|
|
|
|
return OrphanablePtr<LoadBalancingPolicy>(New<PickFirst>(std::move(args))); |
|
|
|
|
return MakeOrphanable<PickFirst>(std::move(args)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const char* name() const override { return kPickFirst; } |
|
|
|
@ -510,8 +506,7 @@ class PickFirstFactory : public LoadBalancingPolicyFactory { |
|
|
|
|
void grpc_lb_policy_pick_first_init() { |
|
|
|
|
grpc_core::LoadBalancingPolicyRegistry::Builder:: |
|
|
|
|
RegisterLoadBalancingPolicyFactory( |
|
|
|
|
grpc_core::UniquePtr<grpc_core::LoadBalancingPolicyFactory>( |
|
|
|
|
grpc_core::New<grpc_core::PickFirstFactory>())); |
|
|
|
|
grpc_core::MakeUnique<grpc_core::PickFirstFactory>()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void grpc_lb_policy_pick_first_shutdown() {} |
|
|
|
|