@ -464,11 +464,10 @@ XdsOverrideHostLb::Picker::Picker(
: policy_ ( std : : move ( xds_override_host_lb ) ) ,
picker_ ( std : : move ( picker ) ) ,
override_host_health_status_set_ ( override_host_health_status_set ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < policy_ . get ( )
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < policy_ . get ( )
< < " ] constructed new picker " < < this ;
}
}
absl : : optional < LoadBalancingPolicy : : PickResult >
XdsOverrideHostLb : : Picker : : PickOverridenHost (
@ -605,10 +604,9 @@ XdsOverrideHostLb::IdleTimer::IdleTimer(RefCountedPtr<XdsOverrideHostLb> policy,
// Min time between timer runs is 5s so that we don't kill ourselves
// with lock contention and CPU usage due to sweeps over the map.
duration = std : : max ( duration , Duration : : Seconds ( 5 ) ) ;
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < policy_ . get ( ) < < " ] idle timer "
< < this < < " : subchannel cleanup pass will run in " < < duration ;
}
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < policy_ . get ( ) < < " ] idle timer " < < this
< < " : subchannel cleanup pass will run in " < < duration ;
timer_handle_ = policy_ - > channel_control_helper ( ) - > GetEventEngine ( ) - > RunAfter (
duration , [ self = RefAsSubclass < IdleTimer > ( ) ] ( ) mutable {
ApplicationCallbackExecCtx callback_exec_ctx ;
@ -622,10 +620,9 @@ XdsOverrideHostLb::IdleTimer::IdleTimer(RefCountedPtr<XdsOverrideHostLb> policy,
void XdsOverrideHostLb : : IdleTimer : : Orphan ( ) {
if ( timer_handle_ . has_value ( ) ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < policy_ . get ( ) < < " ] idle timer "
< < this < < " : cancelling " ;
}
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < policy_ . get ( ) < < " ] idle timer " < < this
< < " : cancelling " ;
policy_ - > channel_control_helper ( ) - > GetEventEngine ( ) - > Cancel ( * timer_handle_ ) ;
timer_handle_ . reset ( ) ;
}
@ -635,10 +632,9 @@ void XdsOverrideHostLb::IdleTimer::Orphan() {
void XdsOverrideHostLb : : IdleTimer : : OnTimerLocked ( ) {
if ( timer_handle_ . has_value ( ) ) {
timer_handle_ . reset ( ) ;
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < policy_ . get ( ) < < " ] idle timer "
< < this < < " : timer fired " ;
}
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < policy_ . get ( ) < < " ] idle timer " < < this
< < " : timer fired " ;
policy_ - > CleanupSubchannels ( ) ;
}
}
@ -655,11 +651,10 @@ XdsOverrideHostLb::XdsOverrideHostLb(Args args)
}
XdsOverrideHostLb : : ~ XdsOverrideHostLb ( ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < this
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < this
< < " ] destroying xds_override_host LB policy " ;
}
}
void XdsOverrideHostLb : : ShutdownLocked ( ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
@ -695,10 +690,9 @@ void XdsOverrideHostLb::ResetState() {
}
void XdsOverrideHostLb : : ReportTransientFailure ( absl : : Status status ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < this
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < this
< < " ] reporting TRANSIENT_FAILURE: " < < status ;
}
ResetState ( ) ;
channel_control_helper ( ) - > UpdateState (
GRPC_CHANNEL_TRANSIENT_FAILURE , status ,
@ -790,11 +784,10 @@ absl::Status XdsOverrideHostLb::UpdateLocked(UpdateArgs args) {
args . addresses =
std : : make_shared < ChildEndpointIterator > ( std : : move ( * args . addresses ) ) ;
} else {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < this
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < this
< < " ] address error: " < < args . addresses . status ( ) ;
}
}
// Create child policy if needed.
if ( child_policy_ = = nullptr ) {
child_policy_ = CreateChildPolicyLocked ( args . args ) ;
@ -805,10 +798,9 @@ absl::Status XdsOverrideHostLb::UpdateLocked(UpdateArgs args) {
update_args . resolution_note = std : : move ( args . resolution_note ) ;
update_args . config = new_config - > child_config ( ) ;
update_args . args = args_ ;
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < this
< < " ] Updating child policy handler " < < child_policy_ . get ( ) ;
}
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < this < < " ] Updating child policy handler "
< < child_policy_ . get ( ) ;
return child_policy_ - > UpdateLocked ( std : : move ( update_args ) ) ;
}
@ -837,10 +829,9 @@ OrphanablePtr<LoadBalancingPolicy> XdsOverrideHostLb::CreateChildPolicyLocked(
OrphanablePtr < LoadBalancingPolicy > lb_policy =
MakeOrphanable < ChildPolicyHandler > ( std : : move ( lb_policy_args ) ,
& xds_override_host_lb_trace ) ;
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < this
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < this
< < " ] Created new child policy handler " < < lb_policy . get ( ) ;
}
// Add our interested_parties pollset_set to that of the newly created
// child policy. This will make the child policy progress upon activity on
// this policy, which in turn is tied to the application's call.
@ -877,10 +868,9 @@ void XdsOverrideHostLb::UpdateAddressMap(
for ( const auto & address : endpoint . addresses ( ) ) {
auto key = grpc_sockaddr_to_string ( & address , /*normalize=*/ false ) ;
if ( ! key . ok ( ) ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < this
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < this
< < " ] no key for endpoint address; not adding to map " ;
}
} else {
addresses . push_back ( * std : : move ( key ) ) ;
}
@ -907,10 +897,9 @@ void XdsOverrideHostLb::UpdateAddressMap(
MutexLock lock ( & mu_ ) ;
for ( auto it = subchannel_map_ . begin ( ) ; it ! = subchannel_map_ . end ( ) ; ) {
if ( addresses_for_map . find ( it - > first ) = = addresses_for_map . end ( ) ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < this < < " ] removing map key "
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < this < < " ] removing map key "
< < it - > first ;
}
it - > second - > UnsetSubchannel ( & subchannel_refs_to_drop ) ;
it = subchannel_map_ . erase ( it ) ;
} else {
@ -922,10 +911,9 @@ void XdsOverrideHostLb::UpdateAddressMap(
auto & address_info = p . second ;
auto it = subchannel_map_ . find ( address ) ;
if ( it = = subchannel_map_ . end ( ) ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < this < < " ] adding map key "
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < this < < " ] adding map key "
< < address ;
}
it = subchannel_map_ . emplace ( address , MakeRefCounted < SubchannelEntry > ( ) )
. first ;
}
@ -973,10 +961,9 @@ XdsOverrideHostLb::AdoptSubchannel(
}
void XdsOverrideHostLb : : CreateSubchannelForAddress ( absl : : string_view address ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < this
< < " ] creating owned subchannel for " < < address ;
}
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < this < < " ] creating owned subchannel for "
< < address ;
auto addr = StringToSockaddr ( address ) ;
CHECK ( addr . ok ( ) ) ;
// Note: We don't currently have any cases where per_address_args need to
@ -1016,10 +1003,9 @@ void XdsOverrideHostLb::CleanupSubchannels() {
if ( p . second - > last_used_time ( ) < = idle_threshold ) {
auto subchannel = p . second - > TakeOwnedSubchannel ( ) ;
if ( subchannel ! = nullptr ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < this
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < this
< < " ] dropping subchannel for " < < p . first ;
}
subchannel_refs_to_drop . push_back ( std : : move ( subchannel ) ) ;
}
} else {
@ -1093,10 +1079,9 @@ void XdsOverrideHostLb::SubchannelWrapper::CancelConnectivityStateWatch(
}
void XdsOverrideHostLb : : SubchannelWrapper : : Orphaned ( ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb " < < policy_ . get ( )
< < " ] subchannel wrapper " < < this < < " orphaned " ;
}
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb " < < policy_ . get ( ) < < " ] subchannel wrapper "
< < this < < " orphaned " ;
if ( ! IsWorkSerializerDispatchEnabled ( ) ) {
wrapped_subchannel ( ) - > CancelConnectivityStateWatch ( watcher_ ) ;
if ( subchannel_entry_ ! = nullptr ) {
@ -1206,20 +1191,19 @@ void XdsOverrideHostLb::SubchannelEntry::OnSubchannelWrapperOrphan(
auto * subchannel = GetSubchannel ( ) ;
if ( subchannel ! = wrapper ) return ;
if ( last_used_time_ < ( Timestamp : : Now ( ) - connection_idle_timeout ) ) {
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb] removing unowned subchannel wrapper "
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb] removing unowned subchannel "
" wrapper "
< < subchannel ;
}
subchannel_ = nullptr ;
} else {
// The subchannel is being released by the child policy, but it
// is still within its idle timeout, so we make a new copy of
// the wrapper with the same underlying subchannel, and we hold
// our own ref to it.
if ( GRPC_TRACE_FLAG_ENABLED ( xds_override_host_lb ) ) {
LOG ( INFO ) < < " [xds_override_host_lb] subchannel wrapper " < < subchannel
GRPC_TRACE_LOG ( xds_override_host_lb , INFO )
< < " [xds_override_host_lb] subchannel wrapper " < < subchannel
< < " : cloning to gain ownership " ;
}
subchannel_ = wrapper - > Clone ( ) ;
}
}