Merge branch 'master' into remove_gpr_assertion_failed

pull/36912/head
tanvi-jagtap 5 months ago
commit faded6fd6d
  1. 51
      src/core/load_balancing/child_policy_handler.cc
  2. 65
      src/core/load_balancing/grpclb/grpclb.cc
  3. 58
      src/core/load_balancing/health_check_client.cc
  4. 8
      src/core/load_balancing/oob_backend_metric.cc
  5. 45
      src/core/load_balancing/pick_first/pick_first.cc
  6. 9
      src/core/load_balancing/priority/priority.cc
  7. 55
      src/core/load_balancing/ring_hash/ring_hash.cc
  8. 33
      src/core/load_balancing/rls/rls.cc
  9. 77
      src/core/load_balancing/round_robin/round_robin.cc
  10. 32
      src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc
  11. 102
      src/core/load_balancing/weighted_target/weighted_target.cc
  12. 25
      src/core/load_balancing/xds/cds.cc
  13. 98
      src/core/load_balancing/xds/xds_cluster_impl.cc
  14. 65
      src/core/load_balancing/xds/xds_cluster_manager.cc
  15. 155
      src/core/load_balancing/xds/xds_override_host.cc
  16. 37
      src/core/load_balancing/xds/xds_wrr_locality.cc
  17. 2
      src/ruby/ext/grpc/rb_server.c
  18. 4
      test/core/address_utils/parse_address_with_named_scope_id_test.cc
  19. 5
      test/core/client_channel/BUILD
  20. 3
      test/core/client_channel/client_channel_test.cc
  21. 2
      test/core/end2end/fixtures/http_proxy_fixture.cc
  22. 12
      test/core/iomgr/fd_posix_test.cc
  23. 10
      test/core/slice/slice_test.cc

@ -20,12 +20,12 @@
#include <string>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include <grpc/impl/connectivity_state.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/channel/channel_args.h"
@ -68,11 +68,10 @@ class ChildPolicyHandler::Helper final
// into place.
if (CalledByPendingChild()) {
if (GRPC_TRACE_FLAG_ENABLED_OBJ(*(parent()->tracer_))) {
gpr_log(GPR_INFO,
"[child_policy_handler %p] helper %p: pending child policy %p "
"reports state=%s (%s)",
parent(), this, child_, ConnectivityStateName(state),
status.ToString().c_str());
LOG(INFO) << "[child_policy_handler " << parent() << "] helper " << this
<< ": pending child policy " << child_
<< " reports state=" << ConnectivityStateName(state) << " ("
<< status << ")";
}
if (state == GRPC_CHANNEL_CONNECTING) return;
grpc_pollset_set_del_pollset_set(
@ -98,8 +97,8 @@ class ChildPolicyHandler::Helper final
: parent()->child_policy_.get();
if (child_ != latest_child_policy) return;
if (GRPC_TRACE_FLAG_ENABLED_OBJ(*(parent()->tracer_))) {
gpr_log(GPR_INFO, "[child_policy_handler %p] requesting re-resolution",
parent());
LOG(INFO) << "[child_policy_handler " << parent()
<< "] requesting re-resolution";
}
parent()->channel_control_helper()->RequestReresolution();
}
@ -133,13 +132,13 @@ class ChildPolicyHandler::Helper final
void ChildPolicyHandler::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED_OBJ(*tracer_)) {
gpr_log(GPR_INFO, "[child_policy_handler %p] shutting down", this);
LOG(INFO) << "[child_policy_handler " << this << "] shutting down";
}
shutting_down_ = true;
if (child_policy_ != nullptr) {
if (GRPC_TRACE_FLAG_ENABLED_OBJ(*tracer_)) {
gpr_log(GPR_INFO, "[child_policy_handler %p] shutting down lb_policy %p",
this, child_policy_.get());
LOG(INFO) << "[child_policy_handler " << this
<< "] shutting down lb_policy " << child_policy_.get();
}
grpc_pollset_set_del_pollset_set(child_policy_->interested_parties(),
interested_parties());
@ -147,9 +146,9 @@ void ChildPolicyHandler::ShutdownLocked() {
}
if (pending_child_policy_ != nullptr) {
if (GRPC_TRACE_FLAG_ENABLED_OBJ(*tracer_)) {
gpr_log(GPR_INFO,
"[child_policy_handler %p] shutting down pending lb_policy %p",
this, pending_child_policy_.get());
LOG(INFO) << "[child_policy_handler " << this
<< "] shutting down pending lb_policy "
<< pending_child_policy_.get();
}
grpc_pollset_set_del_pollset_set(
pending_child_policy_->interested_parties(), interested_parties());
@ -224,10 +223,9 @@ absl::Status ChildPolicyHandler::UpdateLocked(UpdateArgs args) {
// switch to the new policy, even if the new policy stays in
// CONNECTING for a very long period of time.
if (GRPC_TRACE_FLAG_ENABLED_OBJ(*tracer_)) {
gpr_log(GPR_INFO,
"[child_policy_handler %p] creating new %schild policy %s", this,
child_policy_ == nullptr ? "" : "pending ",
std::string(args.config->name()).c_str());
LOG(INFO) << "[child_policy_handler " << this << "] creating new "
<< (child_policy_ == nullptr ? "" : "pending ")
<< "child policy " << args.config->name();
}
auto& lb_policy =
child_policy_ == nullptr ? child_policy_ : pending_child_policy_;
@ -244,10 +242,10 @@ absl::Status ChildPolicyHandler::UpdateLocked(UpdateArgs args) {
CHECK_NE(policy_to_update, nullptr);
// Update the policy.
if (GRPC_TRACE_FLAG_ENABLED_OBJ(*tracer_)) {
gpr_log(GPR_INFO, "[child_policy_handler %p] updating %schild policy %p",
this,
policy_to_update == pending_child_policy_.get() ? "pending " : "",
policy_to_update);
LOG(INFO) << "[child_policy_handler " << this << "] updating "
<< (policy_to_update == pending_child_policy_.get() ? "pending "
: "")
<< "child policy " << policy_to_update;
}
return policy_to_update->UpdateLocked(std::move(args));
}
@ -282,15 +280,14 @@ OrphanablePtr<LoadBalancingPolicy> ChildPolicyHandler::CreateChildPolicy(
OrphanablePtr<LoadBalancingPolicy> lb_policy =
CreateLoadBalancingPolicy(child_policy_name, std::move(lb_policy_args));
if (GPR_UNLIKELY(lb_policy == nullptr)) {
gpr_log(GPR_ERROR, "could not create LB policy \"%s\"",
std::string(child_policy_name).c_str());
LOG(ERROR) << "could not create LB policy \"" << child_policy_name << "\"";
return nullptr;
}
helper->set_child(lb_policy.get());
if (GRPC_TRACE_FLAG_ENABLED_OBJ(*tracer_)) {
gpr_log(GPR_INFO,
"[child_policy_handler %p] created new LB policy \"%s\" (%p)", this,
std::string(child_policy_name).c_str(), lb_policy.get());
LOG(INFO) << "[child_policy_handler " << this
<< "] created new LB policy \"" << child_policy_name << "\" ("
<< lb_policy.get() << ")";
}
channel_control_helper()->AddTraceEvent(
ChannelControlHelper::TRACE_INFO,

@ -609,19 +609,15 @@ bool IsServerValid(const GrpcLbServer& server, size_t idx, bool log) {
if (server.drop) return false;
if (GPR_UNLIKELY(server.port >> 16 != 0)) {
if (log) {
gpr_log(GPR_ERROR,
"Invalid port '%d' at index %" PRIuPTR
" of serverlist. Ignoring.",
server.port, idx);
LOG(ERROR) << "Invalid port '" << server.port << "' at index " << idx
<< " of serverlist. Ignoring.";
}
return false;
}
if (GPR_UNLIKELY(server.ip_size != 4 && server.ip_size != 16)) {
if (log) {
gpr_log(GPR_ERROR,
"Expected IP to be 4 or 16 bytes, got %d at index %" PRIuPTR
" of serverlist. Ignoring",
server.ip_size, idx);
LOG(ERROR) << "Expected IP to be 4 or 16 bytes, got " << server.ip_size
<< " at index " << idx << " of serverlist. Ignoring";
}
return false;
}
@ -672,11 +668,9 @@ class GrpcLb::Serverlist::AddressIterator final
std::string lb_token(server.load_balance_token, lb_token_length);
if (lb_token.empty()) {
auto addr_uri = grpc_sockaddr_to_uri(&addr);
gpr_log(GPR_INFO,
"Missing LB token for backend address '%s'. The empty token "
"will be used instead",
addr_uri.ok() ? addr_uri->c_str()
: addr_uri.status().ToString().c_str());
LOG(INFO) << "Missing LB token for backend address '"
<< (addr_uri.ok() ? *addr_uri : addr_uri.status().ToString())
<< "'. The empty token will be used instead";
}
// Return address with a channel arg containing LB token and stats object.
callback(EndpointAddresses(
@ -1094,9 +1088,8 @@ void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
grpc_call_error call_error = grpc_call_start_batch_and_execute(
lb_call_, &op, 1, &client_load_report_done_closure_);
if (GPR_UNLIKELY(call_error != GRPC_CALL_OK)) {
gpr_log(GPR_ERROR,
"[grpclb %p] lb_calld=%p call_error=%d sending client load report",
grpclb_policy_.get(), this, call_error);
LOG(ERROR) << "[grpclb " << grpclb_policy_.get() << "] lb_calld=" << this
<< " call_error=" << call_error << " sending client load report";
CHECK_EQ(call_error, GRPC_CALL_OK);
}
}
@ -1469,10 +1462,9 @@ GrpcLb::GrpcLb(Args args)
.value_or(Duration::Milliseconds(
GRPC_GRPCLB_DEFAULT_SUBCHANNEL_DELETION_DELAY_MS)))) {
if (GRPC_TRACE_FLAG_ENABLED(glb)) {
gpr_log(GPR_INFO,
"[grpclb %p] Will use '%s' as the server name for LB request.",
this,
std::string(channel_control_helper()->GetAuthority()).c_str());
LOG(INFO) << "[grpclb " << this << "] Will use '"
<< std::string(channel_control_helper()->GetAuthority())
<< "' as the server name for LB request.";
}
}
@ -1539,8 +1531,8 @@ class GrpcLb::NullLbTokenEndpointIterator final
const override {
parent_it_->ForEach([&](const EndpointAddresses& endpoint) {
if (GRPC_TRACE_FLAG_ENABLED(glb)) {
gpr_log(GPR_INFO, "[grpclb %p] fallback address: %s", this,
endpoint.ToString().c_str());
LOG(INFO) << "[grpclb " << this
<< "] fallback address: " << endpoint.ToString();
}
callback(EndpointAddresses(endpoint.addresses(),
endpoint.args().SetObject(empty_token_)));
@ -1555,7 +1547,7 @@ class GrpcLb::NullLbTokenEndpointIterator final
absl::Status GrpcLb::UpdateLocked(UpdateArgs args) {
if (GRPC_TRACE_FLAG_ENABLED(glb)) {
gpr_log(GPR_INFO, "[grpclb %p] received update", this);
LOG(INFO) << "[grpclb " << this << "] received update";
}
const bool is_initial_update = lb_channel_ == nullptr;
config_ = args.config.TakeAsSubclass<GrpcLbConfig>();
@ -1613,8 +1605,8 @@ absl::Status GrpcLb::UpdateBalancerChannelLocked() {
EndpointAddressesList balancer_addresses = ExtractBalancerAddresses(args_);
if (GRPC_TRACE_FLAG_ENABLED(glb)) {
for (const auto& endpoint : balancer_addresses) {
gpr_log(GPR_INFO, "[grpclb %p] balancer address: %s", this,
endpoint.ToString().c_str());
LOG(INFO) << "[grpclb " << this
<< "] balancer address: " << endpoint.ToString();
}
}
absl::Status status;
@ -1679,13 +1671,13 @@ void GrpcLb::StartBalancerCallLocked() {
void GrpcLb::StartBalancerCallRetryTimerLocked() {
Duration timeout = lb_call_backoff_.NextAttemptTime() - Timestamp::Now();
if (GRPC_TRACE_FLAG_ENABLED(glb)) {
gpr_log(GPR_INFO, "[grpclb %p] Connection to LB server lost...", this);
LOG(INFO) << "[grpclb " << this << "] Connection to LB server lost...";
if (timeout > Duration::Zero()) {
gpr_log(GPR_INFO, "[grpclb %p] ... retry_timer_active in %" PRId64 "ms.",
this, timeout.millis());
} else {
gpr_log(GPR_INFO, "[grpclb %p] ... retry_timer_active immediately.",
this);
LOG(INFO) << "[grpclb " << this
<< "] ... retry_timer_active immediately.";
}
}
lb_call_retry_timer_handle_ =
@ -1708,7 +1700,7 @@ void GrpcLb::OnBalancerCallRetryTimerLocked() {
lb_call_retry_timer_handle_.reset();
if (!shutting_down_ && lb_calld_ == nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(glb)) {
gpr_log(GPR_INFO, "[grpclb %p] Restarting call to LB server", this);
LOG(INFO) << "[grpclb " << this << "] Restarting call to LB server";
}
StartBalancerCallLocked();
}
@ -1740,10 +1732,9 @@ void GrpcLb::OnFallbackTimerLocked() {
// If we receive a serverlist after the timer fires but before this callback
// actually runs, don't fall back.
if (fallback_at_startup_checks_pending_ && !shutting_down_) {
gpr_log(GPR_INFO,
"[grpclb %p] No response from balancer after fallback timeout; "
"entering fallback mode",
this);
LOG(INFO) << "[grpclb " << this
<< "] No response from balancer after fallback timeout; "
"entering fallback mode";
fallback_at_startup_checks_pending_ = false;
CancelBalancerChannelConnectivityWatchLocked();
fallback_mode_ = true;
@ -1778,8 +1769,8 @@ OrphanablePtr<LoadBalancingPolicy> GrpcLb::CreateChildPolicyLocked(
OrphanablePtr<LoadBalancingPolicy> lb_policy =
MakeOrphanable<ChildPolicyHandler>(std::move(lb_policy_args), &glb_trace);
if (GRPC_TRACE_FLAG_ENABLED(glb)) {
gpr_log(GPR_INFO, "[grpclb %p] Created new child policy handler (%p)", this,
lb_policy.get());
LOG(INFO) << "[grpclb " << this << "] Created new child policy handler ("
<< lb_policy.get() << ")";
}
// Add the gRPC LB's interested_parties pollset_set to that of the newly
// created child policy. This will make the child policy progress upon
@ -1832,8 +1823,8 @@ void GrpcLb::CreateOrUpdateChildPolicyLocked() {
}
// Update the policy.
if (GRPC_TRACE_FLAG_ENABLED(glb)) {
gpr_log(GPR_INFO, "[grpclb %p] Updating child policy handler %p", this,
child_policy_.get());
LOG(INFO) << "[grpclb " << this << "] Updating child policy handler "
<< child_policy_.get();
}
// TODO(roth): If we're in fallback mode and the child policy rejects the
// update, we should propagate that failure back to the resolver somehow.

@ -25,6 +25,7 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -37,7 +38,6 @@
#include <grpc/impl/connectivity_state.h>
#include <grpc/slice.h>
#include <grpc/status.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/channelz/channel_trace.h"
@ -146,11 +146,9 @@ void HealthProducer::HealthChecker::OnConnectivityStateChangeLocked(
void HealthProducer::HealthChecker::StartHealthStreamLocked() {
if (GRPC_TRACE_FLAG_ENABLED(health_check_client)) {
gpr_log(GPR_INFO,
"HealthProducer %p HealthChecker %p: "
"creating HealthClient for \"%s\"",
producer_.get(), this,
std::string(health_check_service_name_).c_str());
LOG(INFO) << "HealthProducer " << producer_.get() << " HealthChecker "
<< this << ": creating HealthClient for \""
<< health_check_service_name_ << "\"";
}
stream_client_ = MakeOrphanable<SubchannelStreamClient>(
producer_->connected_subchannel_, producer_->subchannel_->pollset_set(),
@ -161,10 +159,9 @@ void HealthProducer::HealthChecker::StartHealthStreamLocked() {
void HealthProducer::HealthChecker::NotifyWatchersLocked(
grpc_connectivity_state state, absl::Status status) {
if (GRPC_TRACE_FLAG_ENABLED(health_check_client)) {
gpr_log(
GPR_INFO,
"HealthProducer %p HealthChecker %p: reporting state %s to watchers",
producer_.get(), this, ConnectivityStateName(state));
LOG(INFO) << "HealthProducer " << producer_.get() << " HealthChecker "
<< this << ": reporting state " << ConnectivityStateName(state)
<< " to watchers";
}
work_serializer_->Schedule(
[self = Ref(), state, status = std::move(status)]() {
@ -269,7 +266,7 @@ class HealthProducer::HealthChecker::HealthStreamEventHandler final
static const char kErrorMessage[] =
"health checking Watch method returned UNIMPLEMENTED; "
"disabling health checks but assuming server is healthy";
gpr_log(GPR_ERROR, kErrorMessage);
LOG(ERROR) << kErrorMessage;
auto* channelz_node =
health_checker_->producer_->subchannel_->channelz_node();
if (channelz_node != nullptr) {
@ -301,8 +298,9 @@ class HealthProducer::HealthChecker::HealthStreamEventHandler final
grpc_connectivity_state state,
const char* reason) {
if (GRPC_TRACE_FLAG_ENABLED(health_check_client)) {
gpr_log(GPR_INFO, "HealthCheckClient %p: setting state=%s reason=%s",
client, ConnectivityStateName(state), reason);
LOG(INFO) << "HealthCheckClient " << client
<< ": setting state=" << ConnectivityStateName(state)
<< " reason=" << reason;
}
health_checker_->OnHealthWatchStatusChange(
state, state == GRPC_CHANNEL_TRANSIENT_FAILURE
@ -344,8 +342,8 @@ class HealthProducer::ConnectivityWatcher final
void HealthProducer::Start(RefCountedPtr<Subchannel> subchannel) {
if (GRPC_TRACE_FLAG_ENABLED(health_check_client)) {
gpr_log(GPR_INFO, "HealthProducer %p: starting with subchannel %p", this,
subchannel.get());
LOG(INFO) << "HealthProducer " << this << ": starting with subchannel "
<< subchannel.get();
}
subchannel_ = std::move(subchannel);
{
@ -360,7 +358,7 @@ void HealthProducer::Start(RefCountedPtr<Subchannel> subchannel) {
void HealthProducer::Orphaned() {
if (GRPC_TRACE_FLAG_ENABLED(health_check_client)) {
gpr_log(GPR_INFO, "HealthProducer %p: shutting down", this);
LOG(INFO) << "HealthProducer " << this << ": shutting down";
}
{
MutexLock lock(&mu_);
@ -410,9 +408,9 @@ void HealthProducer::RemoveWatcher(
void HealthProducer::OnConnectivityStateChange(grpc_connectivity_state state,
const absl::Status& status) {
if (GRPC_TRACE_FLAG_ENABLED(health_check_client)) {
gpr_log(GPR_INFO,
"HealthProducer %p: subchannel state update: state=%s status=%s",
this, ConnectivityStateName(state), status.ToString().c_str());
LOG(INFO) << "HealthProducer " << this
<< ": subchannel state update: state="
<< ConnectivityStateName(state) << " status=" << status;
}
MutexLock lock(&mu_);
state_ = state;
@ -436,11 +434,9 @@ void HealthProducer::OnConnectivityStateChange(grpc_connectivity_state state,
HealthWatcher::~HealthWatcher() {
if (GRPC_TRACE_FLAG_ENABLED(health_check_client)) {
gpr_log(GPR_INFO,
"HealthWatcher %p: unregistering from producer %p "
"(health_check_service_name=\"%s\")",
this, producer_.get(),
health_check_service_name_.value_or("N/A").c_str());
LOG(INFO) << "HealthWatcher " << this << ": unregistering from producer "
<< producer_.get() << " (health_check_service_name=\""
<< health_check_service_name_.value_or("N/A") << "\")";
}
if (producer_ != nullptr) {
producer_->RemoveWatcher(this, health_check_service_name_);
@ -472,11 +468,10 @@ void HealthWatcher::SetSubchannel(Subchannel* subchannel) {
// Register ourself with the producer.
producer_->AddWatcher(this, health_check_service_name_);
if (GRPC_TRACE_FLAG_ENABLED(health_check_client)) {
gpr_log(GPR_INFO,
"HealthWatcher %p: registered with producer %p (created=%d, "
"health_check_service_name=\"%s\")",
this, producer_.get(), created,
health_check_service_name_.value_or("N/A").c_str());
LOG(INFO) << "HealthWatcher " << this << ": registered with producer "
<< producer_.get() << " (created=" << created
<< ", health_check_service_name=\""
<< health_check_service_name_.value_or("N/A") << "\")";
}
}
@ -504,9 +499,8 @@ MakeHealthCheckWatcher(
args.GetOwnedString(GRPC_ARG_HEALTH_CHECK_SERVICE_NAME);
}
if (GRPC_TRACE_FLAG_ENABLED(health_check_client)) {
gpr_log(GPR_INFO,
"creating HealthWatcher -- health_check_service_name=\"%s\"",
health_check_service_name.value_or("N/A").c_str());
LOG(INFO) << "creating HealthWatcher -- health_check_service_name=\""
<< health_check_service_name.value_or("N/A") << "\"";
}
return std::make_unique<HealthWatcher>(std::move(work_serializer),
std::move(health_check_service_name),

@ -24,6 +24,7 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/duration.upb.h"
@ -34,7 +35,6 @@
#include <grpc/slice.h>
#include <grpc/status.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
@ -147,7 +147,7 @@ class OrcaProducer::OrcaStreamEventHandler final
if (status == GRPC_STATUS_UNIMPLEMENTED) {
static const char kErrorMessage[] =
"Orca stream returned UNIMPLEMENTED; disabling";
gpr_log(GPR_ERROR, kErrorMessage);
LOG(ERROR) << kErrorMessage;
auto* channelz_node = producer_->subchannel_->channelz_node();
if (channelz_node != nullptr) {
channelz_node->AddTraceEvent(
@ -275,8 +275,8 @@ void OrcaProducer::MaybeStartStreamLocked() {
void OrcaProducer::NotifyWatchers(
const BackendMetricData& backend_metric_data) {
if (GRPC_TRACE_FLAG_ENABLED(orca_client)) {
gpr_log(GPR_INFO, "OrcaProducer %p: reporting backend metrics to watchers",
this);
LOG(INFO) << "OrcaProducer " << this
<< ": reporting backend metrics to watchers";
}
MutexLock lock(&mu_);
for (OrcaWatcher* watcher : watchers_) {

@ -28,6 +28,7 @@
#include "absl/algorithm/container.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
@ -421,20 +422,20 @@ PickFirst::PickFirst(Args args)
.value_or(250),
100, 2000))) {
if (GRPC_TRACE_FLAG_ENABLED(pick_first)) {
gpr_log(GPR_INFO, "Pick First %p created.", this);
LOG(INFO) << "Pick First " << this << " created.";
}
}
PickFirst::~PickFirst() {
if (GRPC_TRACE_FLAG_ENABLED(pick_first)) {
gpr_log(GPR_INFO, "Destroying Pick First %p", this);
LOG(INFO) << "Destroying Pick First " << this;
}
CHECK(subchannel_list_ == nullptr);
}
void PickFirst::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(pick_first)) {
gpr_log(GPR_INFO, "Pick First %p Shutting down", this);
LOG(INFO) << "Pick First " << this << " Shutting down";
}
shutdown_ = true;
UnsetSelectedSubchannel();
@ -445,7 +446,7 @@ void PickFirst::ExitIdleLocked() {
if (shutdown_) return;
if (IsIdle()) {
if (GRPC_TRACE_FLAG_ENABLED(pick_first)) {
gpr_log(GPR_INFO, "Pick First %p exiting idle", this);
LOG(INFO) << "Pick First " << this << " exiting idle";
}
AttemptToConnectUsingLatestUpdateArgsLocked();
}
@ -463,8 +464,8 @@ void PickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() {
}
// Replace subchannel_list_.
if (GRPC_TRACE_FLAG_ENABLED(pick_first) && subchannel_list_ != nullptr) {
gpr_log(GPR_INFO, "[PF %p] Shutting down previous subchannel list %p", this,
subchannel_list_.get());
LOG(INFO) << "[PF " << this << "] Shutting down previous subchannel list "
<< subchannel_list_.get();
}
subchannel_list_ = MakeOrphanable<SubchannelList>(
RefAsSubclass<PickFirst>(DEBUG_LOCATION, "SubchannelList"), addresses,
@ -517,10 +518,11 @@ class AddressFamilyIterator final {
absl::Status PickFirst::UpdateLocked(UpdateArgs args) {
if (GRPC_TRACE_FLAG_ENABLED(pick_first)) {
if (args.addresses.ok()) {
gpr_log(GPR_INFO, "Pick First %p received update", this);
LOG(INFO) << "Pick First " << this << " received update";
} else {
gpr_log(GPR_INFO, "Pick First %p received update with address error: %s",
this, args.addresses.status().ToString().c_str());
LOG(INFO) << "Pick First " << this
<< " received update with address error: "
<< args.addresses.status();
}
}
// Set return status based on the address list.
@ -1393,13 +1395,13 @@ OldPickFirst::OldPickFirst(Args args)
.value_or(250),
100, 2000))) {
if (GRPC_TRACE_FLAG_ENABLED(pick_first)) {
gpr_log(GPR_INFO, "Pick First %p created.", this);
LOG(INFO) << "Pick First " << this << " created.";
}
}
OldPickFirst::~OldPickFirst() {
if (GRPC_TRACE_FLAG_ENABLED(pick_first)) {
gpr_log(GPR_INFO, "Destroying Pick First %p", this);
LOG(INFO) << "Destroying Pick First " << this;
}
CHECK(subchannel_list_ == nullptr);
CHECK(latest_pending_subchannel_list_ == nullptr);
@ -1407,7 +1409,7 @@ OldPickFirst::~OldPickFirst() {
void OldPickFirst::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(pick_first)) {
gpr_log(GPR_INFO, "Pick First %p Shutting down", this);
LOG(INFO) << "Pick First " << this << " Shutting down";
}
shutdown_ = true;
UnsetSelectedSubchannel();
@ -1419,7 +1421,7 @@ void OldPickFirst::ExitIdleLocked() {
if (shutdown_) return;
if (IsIdle()) {
if (GRPC_TRACE_FLAG_ENABLED(pick_first)) {
gpr_log(GPR_INFO, "Pick First %p exiting idle", this);
LOG(INFO) << "Pick First " << this << " exiting idle";
}
AttemptToConnectUsingLatestUpdateArgsLocked();
}
@ -1441,9 +1443,9 @@ void OldPickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() {
// Replace latest_pending_subchannel_list_.
if (GRPC_TRACE_FLAG_ENABLED(pick_first) &&
latest_pending_subchannel_list_ != nullptr) {
gpr_log(GPR_INFO,
"[PF %p] Shutting down previous pending subchannel list %p", this,
latest_pending_subchannel_list_.get());
LOG(INFO) << "[PF " << this
<< "] Shutting down previous pending subchannel list "
<< latest_pending_subchannel_list_.get();
}
latest_pending_subchannel_list_ = MakeOrphanable<SubchannelList>(
RefAsSubclass<OldPickFirst>(), addresses, latest_update_args_.args);
@ -1464,8 +1466,8 @@ void OldPickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() {
if (latest_pending_subchannel_list_->size() == 0 || selected_ == nullptr) {
UnsetSelectedSubchannel();
if (GRPC_TRACE_FLAG_ENABLED(pick_first) && subchannel_list_ != nullptr) {
gpr_log(GPR_INFO, "[PF %p] Shutting down previous subchannel list %p",
this, subchannel_list_.get());
LOG(INFO) << "[PF " << this << "] Shutting down previous subchannel list "
<< subchannel_list_.get();
}
subchannel_list_ = std::move(latest_pending_subchannel_list_);
}
@ -1474,10 +1476,11 @@ void OldPickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() {
absl::Status OldPickFirst::UpdateLocked(UpdateArgs args) {
if (GRPC_TRACE_FLAG_ENABLED(pick_first)) {
if (args.addresses.ok()) {
gpr_log(GPR_INFO, "Pick First %p received update", this);
LOG(INFO) << "Pick First " << this << " received update";
} else {
gpr_log(GPR_INFO, "Pick First %p received update with address error: %s",
this, args.addresses.status().ToString().c_str());
LOG(INFO) << "Pick First " << this
<< " received update with address error: "
<< args.addresses.status();
}
}
// Set return status based on the address list.

@ -26,6 +26,7 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -295,19 +296,19 @@ PriorityLb::PriorityLb(Args args)
.GetDurationFromIntMillis(GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS)
.value_or(kDefaultChildFailoverTimeout))) {
if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) {
gpr_log(GPR_INFO, "[priority_lb %p] created", this);
LOG(INFO) << "[priority_lb " << this << "] created";
}
}
PriorityLb::~PriorityLb() {
if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) {
gpr_log(GPR_INFO, "[priority_lb %p] destroying priority LB policy", this);
LOG(INFO) << "[priority_lb " << this << "] destroying priority LB policy";
}
}
void PriorityLb::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) {
gpr_log(GPR_INFO, "[priority_lb %p] shutting down", this);
LOG(INFO) << "[priority_lb " << this << "] shutting down";
}
shutting_down_ = true;
children_.clear();
@ -331,7 +332,7 @@ void PriorityLb::ResetBackoffLocked() {
absl::Status PriorityLb::UpdateLocked(UpdateArgs args) {
if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) {
gpr_log(GPR_INFO, "[priority_lb %p] received update", this);
LOG(INFO) << "[priority_lb " << this << "] received update";
}
// Update config.
config_ = args.config.TakeAsSubclass<PriorityLbConfig>();

@ -30,6 +30,7 @@
#include "absl/base/attributes.h"
#include "absl/container/inlined_vector.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -530,11 +531,10 @@ void RingHash::RingHashEndpoint::CreateChildPolicy() {
"pick_first", std::move(lb_policy_args));
if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) {
const EndpointAddresses& endpoint = ring_hash_->endpoints_[index_];
gpr_log(GPR_INFO,
"[RH %p] endpoint %p (index %" PRIuPTR " of %" PRIuPTR
", %s): created child policy %p",
ring_hash_.get(), this, index_, ring_hash_->endpoints_.size(),
endpoint.ToString().c_str(), child_policy_.get());
LOG(INFO) << "[RH " << ring_hash_.get() << "] endpoint " << this
<< " (index " << index_ << " of " << ring_hash_->endpoints_.size()
<< ", " << endpoint.ToString() << "): created child policy "
<< child_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
@ -601,19 +601,19 @@ void RingHash::RingHashEndpoint::OnStateUpdate(
RingHash::RingHash(Args args) : LoadBalancingPolicy(std::move(args)) {
if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) {
gpr_log(GPR_INFO, "[RH %p] Created", this);
LOG(INFO) << "[RH " << this << "] Created";
}
}
RingHash::~RingHash() {
if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) {
gpr_log(GPR_INFO, "[RH %p] Destroying Ring Hash policy", this);
LOG(INFO) << "[RH " << this << "] Destroying Ring Hash policy";
}
}
void RingHash::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) {
gpr_log(GPR_INFO, "[RH %p] Shutting down", this);
LOG(INFO) << "[RH " << this << "] Shutting down";
}
shutdown_ = true;
endpoint_map_.clear();
@ -629,7 +629,7 @@ absl::Status RingHash::UpdateLocked(UpdateArgs args) {
// Check address list.
if (args.addresses.ok()) {
if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) {
gpr_log(GPR_INFO, "[RH %p] received update", this);
LOG(INFO) << "[RH " << this << "] received update";
}
// De-dup endpoints, taking weight into account.
endpoints_.clear();
@ -645,10 +645,9 @@ absl::Status RingHash::UpdateLocked(UpdateArgs args) {
int prev_weight_arg =
prev_endpoint.args().GetInt(GRPC_ARG_ADDRESS_WEIGHT).value_or(1);
if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) {
gpr_log(GPR_INFO,
"[RH %p] merging duplicate endpoint for %s, combined "
"weight %d",
this, key.ToString().c_str(), weight_arg + prev_weight_arg);
LOG(INFO) << "[RH " << this << "] merging duplicate endpoint for "
<< key.ToString() << ", combined weight "
<< weight_arg + prev_weight_arg;
}
prev_endpoint = EndpointAddresses(
prev_endpoint.addresses(),
@ -660,8 +659,8 @@ absl::Status RingHash::UpdateLocked(UpdateArgs args) {
});
} else {
if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) {
gpr_log(GPR_INFO, "[RH %p] received update with addresses error: %s",
this, args.addresses.status().ToString().c_str());
LOG(INFO) << "[RH " << this << "] received update with addresses error: "
<< args.addresses.status();
}
// If we already have an endpoint list, then keep using the existing
// list, but still report back that the update was not accepted.
@ -770,14 +769,13 @@ void RingHash::UpdateAggregatedConnectivityStateLocked(
start_connection_attempt = true;
}
if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) {
gpr_log(GPR_INFO,
"[RH %p] setting connectivity state to %s (num_idle=%" PRIuPTR
", num_connecting=%" PRIuPTR ", num_ready=%" PRIuPTR
", num_transient_failure=%" PRIuPTR ", size=%" PRIuPTR
") -- start_connection_attempt=%d",
this, ConnectivityStateName(state), num_idle, num_connecting,
num_ready, num_transient_failure, endpoints_.size(),
start_connection_attempt);
LOG(INFO) << "[RH " << this << "] setting connectivity state to "
<< ConnectivityStateName(state) << " (num_idle=" << num_idle
<< ", num_connecting=" << num_connecting
<< ", num_ready=" << num_ready
<< ", num_transient_failure=" << num_transient_failure
<< ", size=" << endpoints_.size()
<< ") -- start_connection_attempt=" << start_connection_attempt;
}
// In TRANSIENT_FAILURE, report the last reported failure.
// Otherwise, report OK.
@ -848,12 +846,11 @@ void RingHash::UpdateAggregatedConnectivityStateLocked(
EndpointAddressSet(endpoints_[first_idle_index].addresses()));
CHECK(it != endpoint_map_.end());
if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) {
gpr_log(GPR_INFO,
"[RH %p] triggering internal connection attempt for endpoint "
"%p (%s) (index %" PRIuPTR " of %" PRIuPTR ")",
this, it->second.get(),
endpoints_[first_idle_index].ToString().c_str(),
first_idle_index, endpoints_.size());
LOG(INFO) << "[RH " << this
<< "] triggering internal connection attempt for endpoint "
<< it->second.get() << " ("
<< endpoints_[first_idle_index].ToString() << ") (index "
<< first_idle_index << " of " << endpoints_.size() << ")";
}
it->second->RequestConnectionLocked();
}

@ -42,6 +42,7 @@
#include "absl/base/thread_annotations.h"
#include "absl/hash/hash.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
@ -1963,7 +1964,7 @@ RlsLb::RlsLb(Args args)
},
Duration::Seconds(5), kMetricCacheSize, kMetricCacheEntries)) {
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] policy created", this);
LOG(INFO) << "[rlslb " << this << "] policy created";
}
}
@ -1990,7 +1991,7 @@ bool EndpointsEqual(
absl::Status RlsLb::UpdateLocked(UpdateArgs args) {
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] policy updated", this);
LOG(INFO) << "[rlslb " << this << "] policy updated";
}
update_in_progress_ = true;
// Swap out config.
@ -1999,8 +2000,8 @@ absl::Status RlsLb::UpdateLocked(UpdateArgs args) {
if (GRPC_TRACE_FLAG_ENABLED(rls_lb) &&
(old_config == nullptr ||
old_config->child_policy_config() != config_->child_policy_config())) {
gpr_log(GPR_INFO, "[rlslb %p] updated child policy config: %s", this,
JsonDump(config_->child_policy_config()).c_str());
LOG(INFO) << "[rlslb " << this << "] updated child policy config: "
<< JsonDump(config_->child_policy_config());
}
// Swap out addresses.
// If the new address list is an error and we have an existing address list,
@ -2025,14 +2026,14 @@ absl::Status RlsLb::UpdateLocked(UpdateArgs args) {
config_->default_target() != old_config->default_target()) {
if (config_->default_target().empty()) {
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] unsetting default target", this);
LOG(INFO) << "[rlslb " << this << "] unsetting default target";
}
default_child_policy_.reset();
} else {
auto it = child_policy_map_.find(config_->default_target());
if (it == child_policy_map_.end()) {
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] creating new default target", this);
LOG(INFO) << "[rlslb " << this << "] creating new default target";
}
default_child_policy_ = MakeRefCounted<ChildPolicyWrapper>(
RefAsSubclass<RlsLb>(DEBUG_LOCATION, "ChildPolicyWrapper"),
@ -2065,15 +2066,15 @@ absl::Status RlsLb::UpdateLocked(UpdateArgs args) {
// Start update of child policies if needed.
if (update_child_policies) {
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] starting child policy updates", this);
LOG(INFO) << "[rlslb " << this << "] starting child policy updates";
}
for (auto& p : child_policy_map_) {
p.second->StartUpdate();
}
} else if (created_default_child) {
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] starting default child policy update",
this);
LOG(INFO) << "[rlslb " << this
<< "] starting default child policy update";
}
default_child_policy_->StartUpdate();
}
@ -2082,7 +2083,7 @@ absl::Status RlsLb::UpdateLocked(UpdateArgs args) {
std::vector<std::string> errors;
if (update_child_policies) {
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] finishing child policy updates", this);
LOG(INFO) << "[rlslb " << this << "] finishing child policy updates";
}
for (auto& p : child_policy_map_) {
absl::Status status = p.second->MaybeFinishUpdate();
@ -2093,8 +2094,8 @@ absl::Status RlsLb::UpdateLocked(UpdateArgs args) {
}
} else if (created_default_child) {
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] finishing default child policy update",
this);
LOG(INFO) << "[rlslb " << this
<< "] finishing default child policy update";
}
absl::Status status = default_child_policy_->MaybeFinishUpdate();
if (!status.ok()) {
@ -2138,7 +2139,7 @@ void RlsLb::ResetBackoffLocked() {
void RlsLb::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] policy shutdown", this);
LOG(INFO) << "[rlslb " << this << "] policy shutdown";
}
registered_metric_callback_.reset();
MutexLock lock(&mu_);
@ -2182,7 +2183,7 @@ void RlsLb::UpdatePickerLocked() {
// is being propagated to our children.
if (update_in_progress_) return;
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] updating picker", this);
LOG(INFO) << "[rlslb " << this << "] updating picker";
}
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
if (!child_policy_map_.empty()) {
@ -2218,8 +2219,8 @@ void RlsLb::UpdatePickerLocked() {
}
}
if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) {
gpr_log(GPR_INFO, "[rlslb %p] reporting state %s", this,
ConnectivityStateName(state));
LOG(INFO) << "[rlslb " << this << "] reporting state "
<< ConnectivityStateName(state);
}
absl::Status status;
if (state == GRPC_CHANNEL_TRANSIENT_FAILURE) {

@ -25,6 +25,7 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/meta/type_traits.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
@ -185,11 +186,10 @@ RoundRobin::Picker::Picker(
size_t index = absl::Uniform<size_t>(parent->bit_gen_, 0, pickers_.size());
last_picked_index_.store(index, std::memory_order_relaxed);
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO,
"[RR %p picker %p] created picker from endpoint_list=%p "
"with %" PRIuPTR " READY children; last_picked_index_=%" PRIuPTR,
parent_, this, parent_->endpoint_list_.get(), pickers_.size(),
index);
LOG(INFO) << "[RR " << parent_ << " picker " << this
<< "] created picker from endpoint_list="
<< parent_->endpoint_list_.get() << " with " << pickers_.size()
<< " READY children; last_picked_index_=" << index;
}
}
@ -197,9 +197,9 @@ RoundRobin::PickResult RoundRobin::Picker::Pick(PickArgs args) {
size_t index = last_picked_index_.fetch_add(1, std::memory_order_relaxed) %
pickers_.size();
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO,
"[RR %p picker %p] using picker index %" PRIuPTR ", picker=%p",
parent_, this, index, pickers_[index].get());
LOG(INFO) << "[RR " << parent_ << " picker " << this
<< "] using picker index " << index
<< ", picker=" << pickers_[index].get();
}
return pickers_[index]->Pick(args);
}
@ -210,13 +210,13 @@ RoundRobin::PickResult RoundRobin::Picker::Pick(PickArgs args) {
RoundRobin::RoundRobin(Args args) : LoadBalancingPolicy(std::move(args)) {
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO, "[RR %p] Created", this);
LOG(INFO) << "[RR " << this << "] Created";
}
}
RoundRobin::~RoundRobin() {
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO, "[RR %p] Destroying Round Robin policy", this);
LOG(INFO) << "[RR " << this << "] Destroying Round Robin policy";
}
CHECK(endpoint_list_ == nullptr);
CHECK(latest_pending_endpoint_list_ == nullptr);
@ -224,7 +224,7 @@ RoundRobin::~RoundRobin() {
void RoundRobin::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO, "[RR %p] Shutting down", this);
LOG(INFO) << "[RR " << this << "] Shutting down";
}
shutdown_ = true;
endpoint_list_.reset();
@ -242,13 +242,13 @@ absl::Status RoundRobin::UpdateLocked(UpdateArgs args) {
EndpointAddressesIterator* addresses = nullptr;
if (args.addresses.ok()) {
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO, "[RR %p] received update", this);
LOG(INFO) << "[RR " << this << "] received update";
}
addresses = args.addresses->get();
} else {
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO, "[RR %p] received update with address error: %s", this,
args.addresses.status().ToString().c_str());
LOG(INFO) << "[RR " << this << "] received update with address error: "
<< args.addresses.status();
}
// If we already have a child list, then keep using the existing
// list, but still report back that the update was not accepted.
@ -257,8 +257,8 @@ absl::Status RoundRobin::UpdateLocked(UpdateArgs args) {
// Create new child list, replacing the previous pending list, if any.
if (GRPC_TRACE_FLAG_ENABLED(round_robin) &&
latest_pending_endpoint_list_ != nullptr) {
gpr_log(GPR_INFO, "[RR %p] replacing previous pending child list %p", this,
latest_pending_endpoint_list_.get());
LOG(INFO) << "[RR " << this << "] replacing previous pending child list "
<< latest_pending_endpoint_list_.get();
}
std::vector<std::string> errors;
latest_pending_endpoint_list_ = MakeOrphanable<RoundRobinEndpointList>(
@ -268,8 +268,8 @@ absl::Status RoundRobin::UpdateLocked(UpdateArgs args) {
// endpoint_list_ and report TRANSIENT_FAILURE.
if (latest_pending_endpoint_list_->size() == 0) {
if (GRPC_TRACE_FLAG_ENABLED(round_robin) && endpoint_list_ != nullptr) {
gpr_log(GPR_INFO, "[RR %p] replacing previous child list %p", this,
endpoint_list_.get());
LOG(INFO) << "[RR " << this << "] replacing previous child list "
<< endpoint_list_.get();
}
endpoint_list_ = std::move(latest_pending_endpoint_list_);
absl::Status status =
@ -303,18 +303,19 @@ void RoundRobin::RoundRobinEndpointList::RoundRobinEndpoint::OnStateUpdate(
auto* rr_endpoint_list = endpoint_list<RoundRobinEndpointList>();
auto* round_robin = policy<RoundRobin>();
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(
GPR_INFO,
"[RR %p] connectivity changed for child %p, endpoint_list %p "
"(index %" PRIuPTR " of %" PRIuPTR "): prev_state=%s new_state=%s (%s)",
round_robin, this, rr_endpoint_list, Index(), rr_endpoint_list->size(),
(old_state.has_value() ? ConnectivityStateName(*old_state) : "N/A"),
ConnectivityStateName(new_state), status.ToString().c_str());
LOG(INFO) << "[RR " << round_robin << "] connectivity changed for child "
<< this << ", endpoint_list " << rr_endpoint_list << " (index "
<< Index() << " of " << rr_endpoint_list->size()
<< "): prev_state="
<< (old_state.has_value() ? ConnectivityStateName(*old_state)
: "N/A")
<< " new_state=" << ConnectivityStateName(new_state) << " ("
<< status << ")";
}
if (new_state == GRPC_CHANNEL_IDLE) {
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO, "[RR %p] child %p reported IDLE; requesting connection",
round_robin, this);
LOG(INFO) << "[RR " << round_robin << "] child " << this
<< " reported IDLE; requesting connection";
}
ExitIdleLocked();
}
@ -380,10 +381,10 @@ void RoundRobin::RoundRobinEndpointList::
round_robin->endpoint_list_ != nullptr
? round_robin->endpoint_list_->CountersString()
: "";
gpr_log(GPR_INFO,
"[RR %p] swapping out child list %p (%s) in favor of %p (%s)",
round_robin, round_robin->endpoint_list_.get(),
old_counters_string.c_str(), this, CountersString().c_str());
LOG(INFO) << "[RR " << round_robin << "] swapping out child list "
<< round_robin->endpoint_list_.get() << " ("
<< old_counters_string << ") in favor of " << this << " ("
<< CountersString() << ")";
}
round_robin->endpoint_list_ =
std::move(round_robin->latest_pending_endpoint_list_);
@ -396,8 +397,8 @@ void RoundRobin::RoundRobinEndpointList::
// 3) ALL children are TRANSIENT_FAILURE => policy is TRANSIENT_FAILURE.
if (num_ready_ > 0) {
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO, "[RR %p] reporting READY with child list %p",
round_robin, this);
LOG(INFO) << "[RR " << round_robin << "] reporting READY with child list "
<< this;
}
std::vector<RefCountedPtr<LoadBalancingPolicy::SubchannelPicker>> pickers;
for (const auto& endpoint : endpoints()) {
@ -412,17 +413,17 @@ void RoundRobin::RoundRobinEndpointList::
MakeRefCounted<Picker>(round_robin, std::move(pickers)));
} else if (num_connecting_ > 0) {
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO, "[RR %p] reporting CONNECTING with child list %p",
round_robin, this);
LOG(INFO) << "[RR " << round_robin
<< "] reporting CONNECTING with child list " << this;
}
round_robin->channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING, absl::Status(),
MakeRefCounted<QueuePicker>(nullptr));
} else if (num_transient_failure_ == size()) {
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
gpr_log(GPR_INFO,
"[RR %p] reporting TRANSIENT_FAILURE with child list %p: %s",
round_robin, this, status_for_tf.ToString().c_str());
LOG(INFO) << "[RR " << round_robin
<< "] reporting TRANSIENT_FAILURE with child list " << this
<< ": " << status_for_tf;
}
if (!status_for_tf.ok()) {
last_failure_ = absl::UnavailableError(

@ -29,6 +29,7 @@
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/meta/type_traits.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
@ -708,14 +709,14 @@ WeightedRoundRobin::WeightedRoundRobin(Args args)
.GetString(GRPC_ARG_LB_WEIGHTED_TARGET_CHILD)
.value_or("")) {
if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) {
gpr_log(GPR_INFO, "[WRR %p] Created -- locality_name=\"%s\"", this,
std::string(locality_name_).c_str());
LOG(INFO) << "[WRR " << this << "] Created -- locality_name=\""
<< std::string(locality_name_) << "\"";
}
}
WeightedRoundRobin::~WeightedRoundRobin() {
if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) {
gpr_log(GPR_INFO, "[WRR %p] Destroying Round Robin policy", this);
LOG(INFO) << "[WRR " << this << "] Destroying Round Robin policy";
}
CHECK(endpoint_list_ == nullptr);
CHECK(latest_pending_endpoint_list_ == nullptr);
@ -723,7 +724,7 @@ WeightedRoundRobin::~WeightedRoundRobin() {
void WeightedRoundRobin::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) {
gpr_log(GPR_INFO, "[WRR %p] Shutting down", this);
LOG(INFO) << "[WRR " << this << "] Shutting down";
}
shutdown_ = true;
endpoint_list_.reset();
@ -743,7 +744,7 @@ absl::Status WeightedRoundRobin::UpdateLocked(UpdateArgs args) {
std::shared_ptr<EndpointAddressesIterator> addresses;
if (args.addresses.ok()) {
if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) {
gpr_log(GPR_INFO, "[WRR %p] received update", this);
LOG(INFO) << "[WRR " << this << "] received update";
}
// Weed out duplicate endpoints. Also sort the endpoints so that if
// the set of endpoints doesn't change, their indexes in the endpoint
@ -771,8 +772,8 @@ absl::Status WeightedRoundRobin::UpdateLocked(UpdateArgs args) {
ordered_addresses.begin(), ordered_addresses.end()));
} else {
if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) {
gpr_log(GPR_INFO, "[WRR %p] received update with address error: %s", this,
args.addresses.status().ToString().c_str());
LOG(INFO) << "[WRR " << this << "] received update with address error: "
<< args.addresses.status().ToString();
}
// If we already have an endpoint list, then keep using the existing
// list, but still report back that the update was not accepted.
@ -781,8 +782,9 @@ absl::Status WeightedRoundRobin::UpdateLocked(UpdateArgs args) {
// Create new endpoint list, replacing the previous pending list, if any.
if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb) &&
latest_pending_endpoint_list_ != nullptr) {
gpr_log(GPR_INFO, "[WRR %p] replacing previous pending endpoint list %p",
this, latest_pending_endpoint_list_.get());
LOG(INFO) << "[WRR " << this
<< "] replacing previous pending endpoint list "
<< latest_pending_endpoint_list_.get();
}
std::vector<std::string> errors;
latest_pending_endpoint_list_ = MakeOrphanable<WrrEndpointList>(
@ -792,8 +794,8 @@ absl::Status WeightedRoundRobin::UpdateLocked(UpdateArgs args) {
if (latest_pending_endpoint_list_->size() == 0) {
if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb) &&
endpoint_list_ != nullptr) {
gpr_log(GPR_INFO, "[WRR %p] replacing previous endpoint list %p", this,
endpoint_list_.get());
LOG(INFO) << "[WRR " << this << "] replacing previous endpoint list "
<< endpoint_list_.get();
}
endpoint_list_ = std::move(latest_pending_endpoint_list_);
absl::Status status =
@ -983,16 +985,16 @@ void WeightedRoundRobin::WrrEndpointList::
// 3) ALL children are TRANSIENT_FAILURE => policy is TRANSIENT_FAILURE.
if (num_ready_ > 0) {
if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) {
gpr_log(GPR_INFO, "[WRR %p] reporting READY with endpoint list %p", wrr,
this);
LOG(INFO) << "[WRR " << wrr << "] reporting READY with endpoint list "
<< this;
}
wrr->channel_control_helper()->UpdateState(
GRPC_CHANNEL_READY, absl::Status(),
MakeRefCounted<Picker>(wrr->RefAsSubclass<WeightedRoundRobin>(), this));
} else if (num_connecting_ > 0) {
if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) {
gpr_log(GPR_INFO, "[WRR %p] reporting CONNECTING with endpoint list %p",
wrr, this);
LOG(INFO) << "[WRR " << wrr
<< "] reporting CONNECTING with endpoint list " << this;
}
wrr->channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING, absl::Status(),

@ -28,6 +28,7 @@
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/meta/type_traits.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
@ -39,7 +40,6 @@
#include <grpc/event_engine/event_engine.h>
#include <grpc/impl/connectivity_state.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/channel/channel_args.h"
@ -285,21 +285,20 @@ WeightedTargetLb::PickResult WeightedTargetLb::WeightedPicker::Pick(
WeightedTargetLb::WeightedTargetLb(Args args)
: LoadBalancingPolicy(std::move(args)) {
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO, "[weighted_target_lb %p] created", this);
LOG(INFO) << "[weighted_target_lb " << this << "] created";
}
}
WeightedTargetLb::~WeightedTargetLb() {
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] destroying weighted_target LB policy",
this);
LOG(INFO) << "[weighted_target_lb " << this
<< "] destroying weighted_target LB policy";
}
}
void WeightedTargetLb::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO, "[weighted_target_lb %p] shutting down", this);
LOG(INFO) << "[weighted_target_lb " << this << "] shutting down";
}
shutting_down_ = true;
targets_.clear();
@ -312,7 +311,7 @@ void WeightedTargetLb::ResetBackoffLocked() {
absl::Status WeightedTargetLb::UpdateLocked(UpdateArgs args) {
if (shutting_down_) return absl::OkStatus();
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO, "[weighted_target_lb %p] Received update", this);
LOG(INFO) << "[weighted_target_lb " << this << "] received update";
}
update_in_progress_ = true;
// Update config.
@ -384,10 +383,8 @@ void WeightedTargetLb::UpdateStateLocked() {
// is being propagated to our children.
if (update_in_progress_) return;
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] scanning children to determine "
"connectivity state",
this);
LOG(INFO) << "[weighted_target_lb " << this
<< "] scanning children to determine connectivity state";
}
// Construct lists of child pickers with associated weights, one for
// children that are in state READY and another for children that are
@ -411,11 +408,11 @@ void WeightedTargetLb::UpdateStateLocked() {
}
auto child_picker = child->picker();
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] child=%s state=%s weight=%u picker=%p",
this, child_name.c_str(),
ConnectivityStateName(child->connectivity_state()),
child->weight(), child_picker.get());
LOG(INFO) << "[weighted_target_lb " << this << "] child=" << child_name
<< " state="
<< ConnectivityStateName(child->connectivity_state())
<< " weight=" << child->weight()
<< " picker=" << child_picker.get();
}
switch (child->connectivity_state()) {
case GRPC_CHANNEL_READY: {
@ -454,8 +451,8 @@ void WeightedTargetLb::UpdateStateLocked() {
connectivity_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
}
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO, "[weighted_target_lb %p] connectivity changed to %s",
this, ConnectivityStateName(connectivity_state));
LOG(INFO) << "[weighted_target_lb " << this << "] connectivity changed to "
<< ConnectivityStateName(connectivity_state);
}
RefCountedPtr<SubchannelPicker> picker;
absl::Status status;
@ -498,11 +495,11 @@ WeightedTargetLb::WeightedChild::DelayedRemovalTimer::DelayedRemovalTimer(
void WeightedTargetLb::WeightedChild::DelayedRemovalTimer::Orphan() {
if (timer_handle_.has_value()) {
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] WeightedChild %p %s: cancelling "
"delayed removal timer",
weighted_child_->weighted_target_policy_.get(),
weighted_child_.get(), weighted_child_->name_.c_str());
LOG(INFO) << "[weighted_target_lb "
<< weighted_child_->weighted_target_policy_.get()
<< "] WeightedChild " << weighted_child_.get() << " "
<< weighted_child_->name_
<< ": cancelling delayed removal timer";
}
weighted_child_->weighted_target_policy_->channel_control_helper()
->GetEventEngine()
@ -529,25 +526,25 @@ WeightedTargetLb::WeightedChild::WeightedChild(
name_(name),
picker_(MakeRefCounted<QueuePicker>(nullptr)) {
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO, "[weighted_target_lb %p] created WeightedChild %p for %s",
weighted_target_policy_.get(), this, name_.c_str());
LOG(INFO) << "[weighted_target_lb " << weighted_target_policy_.get()
<< "] created WeightedChild " << this << " for " << name_;
}
}
WeightedTargetLb::WeightedChild::~WeightedChild() {
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] WeightedChild %p %s: destroying child",
weighted_target_policy_.get(), this, name_.c_str());
LOG(INFO) << "[weighted_target_lb " << weighted_target_policy_.get()
<< "] WeightedChild " << this << " " << name_
<< ": destroying child";
}
weighted_target_policy_.reset(DEBUG_LOCATION, "WeightedChild");
}
void WeightedTargetLb::WeightedChild::Orphan() {
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] WeightedChild %p %s: shutting down child",
weighted_target_policy_.get(), this, name_.c_str());
LOG(INFO) << "[weighted_target_lb " << weighted_target_policy_.get()
<< "] WeightedChild " << this << " " << name_
<< ": shutting down child";
}
// Remove the child policy's interested_parties pollset_set from the
// xDS policy.
@ -574,11 +571,9 @@ WeightedTargetLb::WeightedChild::CreateChildPolicyLocked(
MakeOrphanable<ChildPolicyHandler>(std::move(lb_policy_args),
&weighted_target_lb_trace);
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] WeightedChild %p %s: Created new child "
"policy handler %p",
weighted_target_policy_.get(), this, name_.c_str(),
lb_policy.get());
LOG(INFO) << "[weighted_target_lb " << weighted_target_policy_.get()
<< "] WeightedChild " << this << " " << name_
<< ": created new child policy handler " << lb_policy.get();
}
// Add the xDS's interested_parties pollset_set to that of the newly created
// child policy. This will make the child policy progress upon activity on
@ -596,16 +591,17 @@ absl::Status WeightedTargetLb::WeightedChild::UpdateLocked(
if (weighted_target_policy_->shutting_down_) return absl::OkStatus();
// Update child weight.
if (weight_ != config.weight && GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO, "[weighted_target_lb %p] WeightedChild %p %s: weight=%u",
weighted_target_policy_.get(), this, name_.c_str(), config.weight);
LOG(INFO) << "[weighted_target_lb " << weighted_target_policy_.get()
<< "] WeightedChild " << this << " " << name_
<< ": weight=" << config.weight;
}
weight_ = config.weight;
// Reactivate if needed.
if (delayed_removal_timer_ != nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] WeightedChild %p %s: reactivating",
weighted_target_policy_.get(), this, name_.c_str());
LOG(INFO) << "[weighted_target_lb " << weighted_target_policy_.get()
<< "] WeightedChild " << this << " " << name_
<< ": reactivating";
}
delayed_removal_timer_.reset();
}
@ -622,11 +618,9 @@ absl::Status WeightedTargetLb::WeightedChild::UpdateLocked(
update_args.args = std::move(args);
// Update the policy.
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] WeightedChild %p %s: Updating child "
"policy handler %p",
weighted_target_policy_.get(), this, name_.c_str(),
child_policy_.get());
LOG(INFO) << "[weighted_target_lb " << weighted_target_policy_.get()
<< "] WeightedChild " << this << " " << name_
<< ": updating child policy handler " << child_policy_.get();
}
return child_policy_->UpdateLocked(std::move(update_args));
}
@ -641,12 +635,11 @@ void WeightedTargetLb::WeightedChild::OnConnectivityStateUpdateLocked(
// Cache the picker in the WeightedChild.
picker_ = std::move(picker);
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] WeightedChild %p %s: connectivity "
"state update: state=%s (%s) picker=%p",
weighted_target_policy_.get(), this, name_.c_str(),
ConnectivityStateName(state), status.ToString().c_str(),
picker_.get());
LOG(INFO) << "[weighted_target_lb " << weighted_target_policy_.get()
<< "] WeightedChild " << this << " " << name_
<< ": connectivity state update: state="
<< ConnectivityStateName(state) << " (" << status
<< ") picker=" << picker_.get();
}
// If the child reports IDLE, immediately tell it to exit idle.
if (state == GRPC_CHANNEL_IDLE) child_policy_->ExitIdleLocked();
@ -665,9 +658,8 @@ void WeightedTargetLb::WeightedChild::DeactivateLocked() {
// If already deactivated, don't do that again.
if (weight_ == 0) return;
if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) {
gpr_log(GPR_INFO,
"[weighted_target_lb %p] WeightedChild %p %s: deactivating",
weighted_target_policy_.get(), this, name_.c_str());
LOG(INFO) << "[weighted_target_lb " << weighted_target_policy_.get()
<< "] WeightedChild " << this << " " << name_ << ": deactivating";
}
// Set the child weight to 0 so that future picker won't contain this child.
weight_ = 0;

@ -24,6 +24,7 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -184,19 +185,19 @@ class CdsLb final : public LoadBalancingPolicy {
CdsLb::CdsLb(Args args) : LoadBalancingPolicy(std::move(args)) {
if (GRPC_TRACE_FLAG_ENABLED(cds_lb)) {
gpr_log(GPR_INFO, "[cdslb %p] created", this);
LOG(INFO) << "[cdslb " << this << "] created";
}
}
CdsLb::~CdsLb() {
if (GRPC_TRACE_FLAG_ENABLED(cds_lb)) {
gpr_log(GPR_INFO, "[cdslb %p] destroying cds LB policy", this);
LOG(INFO) << "[cdslb " << this << "] destroying cds LB policy";
}
}
void CdsLb::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(cds_lb)) {
gpr_log(GPR_INFO, "[cdslb %p] shutting down", this);
LOG(INFO) << "[cdslb " << this << "] shutting down";
}
shutting_down_ = true;
ResetState();
@ -295,9 +296,9 @@ absl::Status CdsLb::UpdateLocked(UpdateArgs args) {
// Start dynamic subscription if needed.
if (new_config->is_dynamic() && subscription_ == nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(cds_lb)) {
gpr_log(GPR_INFO,
"[cdslb %p] obtaining dynamic subscription for cluster %s", this,
cluster_name_.c_str());
LOG(INFO) << "[cdslb " << this
<< "] obtaining dynamic subscription for cluster "
<< cluster_name_;
}
auto* dependency_mgr = args.args.GetObject<XdsDependencyManager>();
if (dependency_mgr == nullptr) {
@ -663,8 +664,8 @@ Json CdsLb::CreateChildPolicyConfigForLeafCluster(
Json::FromObject(std::move(outlier_detection_config))},
})});
if (GRPC_TRACE_FLAG_ENABLED(cds_lb)) {
gpr_log(GPR_INFO, "[cdslb %p] generated config for child policy: %s", this,
JsonDump(outlier_detection_policy, /*indent=*/1).c_str());
LOG(INFO) << "[cdslb " << this << "] generated config for child policy: "
<< JsonDump(outlier_detection_policy, /*indent=*/1);
}
return outlier_detection_policy;
}
@ -696,8 +697,8 @@ Json CdsLb::CreateChildPolicyConfigForAggregateCluster(
})},
})});
if (GRPC_TRACE_FLAG_ENABLED(cds_lb)) {
gpr_log(GPR_INFO, "[cdslb %p] generated config for child policy: %s", this,
JsonDump(json, /*indent=*/1).c_str());
LOG(INFO) << "[cdslb " << this << "] generated config for child policy: "
<< JsonDump(json, /*indent=*/1);
}
return json;
}
@ -715,8 +716,8 @@ void CdsLb::ResetState() {
void CdsLb::ReportTransientFailure(absl::Status status) {
if (GRPC_TRACE_FLAG_ENABLED(cds_lb)) {
gpr_log(GPR_INFO, "[cdslb %p] reporting TRANSIENT_FAILURE: %s", this,
status.ToString().c_str());
LOG(INFO) << "[cdslb " << this
<< "] reporting TRANSIENT_FAILURE: " << status;
}
ResetState();
channel_control_helper()->UpdateState(

@ -26,6 +26,7 @@
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -396,8 +397,8 @@ XdsClusterImplLb::Picker::Picker(XdsClusterImplLb* xds_cluster_impl_lb,
drop_stats_(xds_cluster_impl_lb->drop_stats_),
picker_(std::move(picker)) {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO, "[xds_cluster_impl_lb %p] constructed new picker %p",
xds_cluster_impl_lb, this);
LOG(INFO) << "[xds_cluster_impl_lb " << xds_cluster_impl_lb
<< "] constructed new picker " << this;
}
}
@ -478,22 +479,21 @@ XdsClusterImplLb::XdsClusterImplLb(RefCountedPtr<GrpcXdsClient> xds_client,
Args args)
: LoadBalancingPolicy(std::move(args)), xds_client_(std::move(xds_client)) {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO, "[xds_cluster_impl_lb %p] created -- using xds client %p",
this, xds_client_.get());
LOG(INFO) << "[xds_cluster_impl_lb " << this
<< "] created -- using xds client " << xds_client_.get();
}
}
XdsClusterImplLb::~XdsClusterImplLb() {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_impl_lb %p] destroying xds_cluster_impl LB policy",
this);
LOG(INFO) << "[xds_cluster_impl_lb " << this
<< "] destroying xds_cluster_impl LB policy";
}
}
void XdsClusterImplLb::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO, "[xds_cluster_impl_lb %p] shutting down", this);
LOG(INFO) << "[xds_cluster_impl_lb " << this << "] shutting down";
}
shutting_down_ = true;
ResetState();
@ -516,9 +516,8 @@ void XdsClusterImplLb::ResetState() {
void XdsClusterImplLb::ReportTransientFailure(absl::Status status) {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_impl_lb %p] reporting TRANSIENT_FAILURE: %s", this,
status.ToString().c_str());
LOG(INFO) << "[xds_cluster_impl_lb " << this
<< "] reporting TRANSIENT_FAILURE: " << status;
}
ResetState();
channel_control_helper()->UpdateState(
@ -544,7 +543,7 @@ std::string GetEdsResourceName(const XdsClusterResource& cluster_resource) {
absl::Status XdsClusterImplLb::UpdateLocked(UpdateArgs args) {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO, "[xds_cluster_impl_lb %p] Received update", this);
LOG(INFO) << "[xds_cluster_impl_lb " << this << "] Received update";
}
// Grab new LB policy config.
auto new_config = args.config.TakeAsSubclass<XdsClusterImplLbConfig>();
@ -615,15 +614,13 @@ absl::Status XdsClusterImplLb::UpdateLocked(UpdateArgs args) {
*new_cluster_config.cluster->lrs_load_reporting_server,
new_config->cluster_name(), new_eds_service_name);
if (drop_stats_ == nullptr) {
gpr_log(
GPR_ERROR,
"[xds_cluster_impl_lb %p] Failed to get cluster drop stats for "
"LRS server %s, cluster %s, EDS service name %s, load "
"reporting for drops will not be done.",
this,
new_cluster_config.cluster->lrs_load_reporting_server->server_uri()
.c_str(),
new_config->cluster_name().c_str(), new_eds_service_name.c_str());
LOG(ERROR)
<< "[xds_cluster_impl_lb " << this
<< "] Failed to get cluster drop stats for LRS server "
<< new_cluster_config.cluster->lrs_load_reporting_server->server_uri()
<< ", cluster " << new_config->cluster_name() << ", EDS service name "
<< new_eds_service_name
<< ", load reporting for drops will not be done.";
}
}
// Update call counter if needed.
@ -706,10 +703,9 @@ void XdsClusterImplLb::MaybeUpdatePickerLocked() {
if (drop_config_ != nullptr && drop_config_->drop_all()) {
auto drop_picker = MakeRefCounted<Picker>(this, picker_);
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_impl_lb %p] updating connectivity (drop all): "
"state=READY picker=%p",
this, drop_picker.get());
LOG(INFO) << "[xds_cluster_impl_lb " << this
<< "] updating connectivity (drop all): state=READY picker="
<< drop_picker.get();
}
channel_control_helper()->UpdateState(GRPC_CHANNEL_READY, absl::Status(),
std::move(drop_picker));
@ -719,11 +715,10 @@ void XdsClusterImplLb::MaybeUpdatePickerLocked() {
if (picker_ != nullptr) {
auto drop_picker = MakeRefCounted<Picker>(this, picker_);
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_impl_lb %p] updating connectivity: state=%s "
"status=(%s) picker=%p",
this, ConnectivityStateName(state_), status_.ToString().c_str(),
drop_picker.get());
LOG(INFO) << "[xds_cluster_impl_lb " << this
<< "] updating connectivity: state="
<< ConnectivityStateName(state_) << " status=(" << status_
<< ") picker=" << drop_picker.get();
}
channel_control_helper()->UpdateState(state_, status_,
std::move(drop_picker));
@ -741,9 +736,8 @@ OrphanablePtr<LoadBalancingPolicy> XdsClusterImplLb::CreateChildPolicyLocked(
MakeOrphanable<ChildPolicyHandler>(std::move(lb_policy_args),
&xds_cluster_impl_lb_trace);
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_impl_lb %p] Created new child policy handler %p",
this, lb_policy.get());
LOG(INFO) << "[xds_cluster_impl_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
@ -769,9 +763,8 @@ absl::Status XdsClusterImplLb::UpdateChildPolicyLocked(
args.Set(GRPC_ARG_XDS_CLUSTER_NAME, config_->cluster_name());
// Update the policy.
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_impl_lb %p] Updating child policy handler %p", this,
child_policy_.get());
LOG(INFO) << "[xds_cluster_impl_lb " << this
<< "] Updating child policy handler " << child_policy_.get();
}
return child_policy_->UpdateLocked(std::move(update_args));
}
@ -795,16 +788,15 @@ RefCountedPtr<SubchannelInterface> XdsClusterImplLb::Helper::CreateSubchannel(
parent()->config_->cluster_name(),
GetEdsResourceName(*parent()->cluster_resource_), locality_name);
if (locality_stats == nullptr) {
gpr_log(GPR_ERROR,
"[xds_cluster_impl_lb %p] Failed to get locality stats object "
"for LRS server %s, cluster %s, EDS service name %s; load "
"reports will not be generated",
parent(),
parent()
->cluster_resource_->lrs_load_reporting_server->server_uri()
.c_str(),
parent()->config_->cluster_name().c_str(),
GetEdsResourceName(*parent()->cluster_resource_).c_str());
LOG(ERROR)
<< "[xds_cluster_impl_lb " << parent()
<< "] Failed to get locality stats object for LRS server "
<< parent()
->cluster_resource_->lrs_load_reporting_server->server_uri()
<< ", cluster " << parent()->config_->cluster_name()
<< ", EDS service name "
<< GetEdsResourceName(*parent()->cluster_resource_)
<< "; load reports will not be generated";
}
}
StatsSubchannelWrapper::LocalityData locality_data;
@ -824,11 +816,10 @@ void XdsClusterImplLb::Helper::UpdateState(
RefCountedPtr<SubchannelPicker> picker) {
if (parent()->shutting_down_) return;
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_impl_lb %p] child connectivity state update: "
"state=%s (%s) picker=%p",
parent(), ConnectivityStateName(state), status.ToString().c_str(),
picker.get());
LOG(INFO) << "[xds_cluster_impl_lb " << parent()
<< "] child connectivity state update: state="
<< ConnectivityStateName(state) << " (" << status
<< ") picker=" << picker.get();
}
// Save the state and picker.
parent()->state_ = state;
@ -878,9 +869,8 @@ class XdsClusterImplLbFactory final : public LoadBalancingPolicyFactory {
auto xds_client = args.args.GetObjectRef<GrpcXdsClient>(DEBUG_LOCATION,
"XdsClusterImplLb");
if (xds_client == nullptr) {
gpr_log(GPR_ERROR,
"XdsClient not present in channel args -- cannot instantiate "
"xds_cluster_impl LB policy");
LOG(ERROR) << "XdsClient not present in channel args -- cannot "
"instantiate xds_cluster_impl LB policy";
return nullptr;
}
return MakeOrphanable<XdsClusterImplLb>(std::move(xds_client),

@ -25,6 +25,7 @@
#include <utility>
#include <vector>
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -259,7 +260,7 @@ XdsClusterManagerLb::~XdsClusterManagerLb() {
void XdsClusterManagerLb::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) {
gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] shutting down", this);
LOG(INFO) << "[xds_cluster_manager_lb " << this << "] shutting down";
}
shutting_down_ = true;
children_.clear();
@ -276,7 +277,7 @@ void XdsClusterManagerLb::ResetBackoffLocked() {
absl::Status XdsClusterManagerLb::UpdateLocked(UpdateArgs args) {
if (shutting_down_) return absl::OkStatus();
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) {
gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] Received update", this);
LOG(INFO) << "[xds_cluster_manager_lb " << this << "] Received update";
}
update_in_progress_ = true;
// Update config.
@ -369,8 +370,9 @@ void XdsClusterManagerLb::UpdateStateLocked() {
connectivity_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
}
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) {
gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] connectivity changed to %s",
this, ConnectivityStateName(connectivity_state));
LOG(INFO) << "[xds_cluster_manager_lb " << this
<< "] connectivity changed to "
<< ConnectivityStateName(connectivity_state);
}
ClusterPicker::ClusterMap cluster_map;
for (const auto& p : config_->cluster_map()) {
@ -379,10 +381,9 @@ void XdsClusterManagerLb::UpdateStateLocked() {
child_picker = children_[cluster_name]->picker();
if (child_picker == nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_manager_lb %p] child %s has not yet returned a "
"picker; creating a QueuePicker.",
this, cluster_name.c_str());
LOG(INFO) << "[xds_cluster_manager_lb " << this << "] child "
<< cluster_name
<< " has not yet returned a picker; creating a QueuePicker.";
}
child_picker =
MakeRefCounted<QueuePicker>(Ref(DEBUG_LOCATION, "QueuePicker"));
@ -409,28 +410,24 @@ XdsClusterManagerLb::ClusterChild::ClusterChild(
name_(name),
picker_(MakeRefCounted<QueuePicker>(nullptr)) {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_manager_lb %p] created ClusterChild %p for %s",
xds_cluster_manager_policy_.get(), this, name_.c_str());
LOG(INFO) << "[xds_cluster_manager_lb " << xds_cluster_manager_policy_.get()
<< "] created ClusterChild " << this << " for " << name_;
}
}
XdsClusterManagerLb::ClusterChild::~ClusterChild() {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_manager_lb %p] ClusterChild %p: destroying "
"child",
xds_cluster_manager_policy_.get(), this);
LOG(INFO) << "[xds_cluster_manager_lb " << xds_cluster_manager_policy_.get()
<< "] ClusterChild " << this << ": destroying child";
}
xds_cluster_manager_policy_.reset(DEBUG_LOCATION, "ClusterChild");
}
void XdsClusterManagerLb::ClusterChild::Orphan() {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_manager_lb %p] ClusterChild %p %s: "
"shutting down child",
xds_cluster_manager_policy_.get(), this, name_.c_str());
LOG(INFO) << "[xds_cluster_manager_lb " << xds_cluster_manager_policy_.get()
<< "] ClusterChild " << this << " " << name_
<< ": shutting down child";
}
// Remove the child policy's interested_parties pollset_set from the
// xDS policy.
@ -463,12 +460,9 @@ XdsClusterManagerLb::ClusterChild::CreateChildPolicyLocked(
MakeOrphanable<ChildPolicyHandler>(std::move(lb_policy_args),
&xds_cluster_manager_lb_trace);
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_manager_lb %p] ClusterChild %p %s: Created "
"new child "
"policy handler %p",
xds_cluster_manager_policy_.get(), this, name_.c_str(),
lb_policy.get());
LOG(INFO) << "[xds_cluster_manager_lb " << xds_cluster_manager_policy_.get()
<< "] ClusterChild " << this << " " << name_
<< ": Created new child policy handler " << lb_policy.get();
}
// Add the xDS's interested_parties pollset_set to that of the newly created
// child policy. This will make the child policy progress upon activity on
@ -503,12 +497,9 @@ absl::Status XdsClusterManagerLb::ClusterChild::UpdateLocked(
update_args.args = args;
// Update the policy.
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) {
gpr_log(GPR_INFO,
"[xds_cluster_manager_lb %p] ClusterChild %p %s: "
"Updating child "
"policy handler %p",
xds_cluster_manager_policy_.get(), this, name_.c_str(),
child_policy_.get());
LOG(INFO) << "[xds_cluster_manager_lb " << xds_cluster_manager_policy_.get()
<< "] ClusterChild " << this << " " << name_
<< ": Updating child policy handler " << child_policy_.get();
}
return child_policy_->UpdateLocked(std::move(update_args));
}
@ -557,13 +548,11 @@ void XdsClusterManagerLb::ClusterChild::Helper::UpdateState(
grpc_connectivity_state state, const absl::Status& status,
RefCountedPtr<SubchannelPicker> picker) {
if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) {
gpr_log(
GPR_INFO,
"[xds_cluster_manager_lb %p] child %s: received update: state=%s (%s) "
"picker=%p",
xds_cluster_manager_child_->xds_cluster_manager_policy_.get(),
xds_cluster_manager_child_->name_.c_str(), ConnectivityStateName(state),
status.ToString().c_str(), picker.get());
LOG(INFO) << "[xds_cluster_manager_lb "
<< xds_cluster_manager_child_->xds_cluster_manager_policy_.get()
<< "] child " << xds_cluster_manager_child_->name_
<< ": received update: state=" << ConnectivityStateName(state)
<< " (" << status << ") picker=" << picker.get();
}
if (xds_cluster_manager_child_->xds_cluster_manager_policy_->shutting_down_) {
return;

@ -45,7 +45,6 @@
#include <grpc/event_engine/event_engine.h>
#include <grpc/impl/connectivity_state.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/client_channel/client_channel_internal.h"
@ -466,8 +465,8 @@ XdsOverrideHostLb::Picker::Picker(
picker_(std::move(picker)),
override_host_health_status_set_(override_host_health_status_set) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO, "[xds_override_host_lb %p] constructed new picker %p",
policy_.get(), this);
LOG(INFO) << "[xds_override_host_lb " << policy_.get()
<< "] constructed new picker " << this;
}
}
@ -489,18 +488,16 @@ XdsOverrideHostLb::Picker::PickOverridenHost(
if (!override_host_health_status_set_.Contains(
it->second->eds_health_status())) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"Subchannel %s health status is not overridden (%s)",
std::string(address).c_str(),
it->second->eds_health_status().ToString());
LOG(INFO) << "Subchannel " << address
<< " health status is not overridden ("
<< it->second->eds_health_status().ToString() << ")";
}
continue;
}
auto subchannel = it->second->GetSubchannelRef();
if (subchannel == nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO, "No subchannel for %s",
std::string(address).c_str());
LOG(INFO) << "No subchannel for " << address;
}
if (address_with_no_subchannel.empty()) {
address_with_no_subchannel = it->first;
@ -512,8 +509,7 @@ XdsOverrideHostLb::Picker::PickOverridenHost(
// Found a READY subchannel. Pass back the actual address list
// and return the subchannel.
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO, "Picker override found READY subchannel %s",
std::string(address).c_str());
LOG(INFO) << "Picker override found READY subchannel " << address;
}
it->second->set_last_used_time();
override_host_attr->set_actual_address_list(it->second->address_list());
@ -610,10 +606,8 @@ XdsOverrideHostLb::IdleTimer::IdleTimer(RefCountedPtr<XdsOverrideHostLb> policy,
// 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)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] idle timer %p: subchannel cleanup "
"pass will run in %s",
policy_.get(), this, duration.ToString().c_str());
LOG(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 {
@ -629,8 +623,8 @@ XdsOverrideHostLb::IdleTimer::IdleTimer(RefCountedPtr<XdsOverrideHostLb> policy,
void XdsOverrideHostLb::IdleTimer::Orphan() {
if (timer_handle_.has_value()) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO, "[xds_override_host_lb %p] idle timer %p: cancelling",
policy_.get(), this);
LOG(INFO) << "[xds_override_host_lb " << policy_.get() << "] idle timer "
<< this << ": cancelling";
}
policy_->channel_control_helper()->GetEventEngine()->Cancel(*timer_handle_);
timer_handle_.reset();
@ -642,8 +636,8 @@ void XdsOverrideHostLb::IdleTimer::OnTimerLocked() {
if (timer_handle_.has_value()) {
timer_handle_.reset();
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO, "[xds_override_host_lb %p] idle timer %p: timer fired",
policy_.get(), this);
LOG(INFO) << "[xds_override_host_lb " << policy_.get() << "] idle timer "
<< this << ": timer fired";
}
policy_->CleanupSubchannels();
}
@ -656,21 +650,20 @@ void XdsOverrideHostLb::IdleTimer::OnTimerLocked() {
XdsOverrideHostLb::XdsOverrideHostLb(Args args)
: LoadBalancingPolicy(std::move(args)) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO, "[xds_override_host_lb %p] created", this);
LOG(INFO) << "[xds_override_host_lb " << this << "] created";
}
}
XdsOverrideHostLb::~XdsOverrideHostLb() {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] destroying xds_override_host LB policy",
this);
LOG(INFO) << "[xds_override_host_lb " << this
<< "] destroying xds_override_host LB policy";
}
}
void XdsOverrideHostLb::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO, "[xds_override_host_lb %p] shutting down", this);
LOG(INFO) << "[xds_override_host_lb " << this << "] shutting down";
}
shutting_down_ = true;
ResetState();
@ -703,9 +696,8 @@ void XdsOverrideHostLb::ResetState() {
void XdsOverrideHostLb::ReportTransientFailure(absl::Status status) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] reporting TRANSIENT_FAILURE: %s", this,
status.ToString().c_str());
LOG(INFO) << "[xds_override_host_lb " << this
<< "] reporting TRANSIENT_FAILURE: " << status;
}
ResetState();
channel_control_helper()->UpdateState(
@ -741,10 +733,9 @@ class ChildEndpointIterator final : public EndpointAddressesIterator {
XdsHealthStatus status = GetEndpointHealthStatus(endpoint);
if (status.status() != XdsHealthStatus::kDraining) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] endpoint %s: not draining, "
"passing to child",
this, endpoint.ToString().c_str());
LOG(INFO) << "[xds_override_host_lb " << this << "] endpoint "
<< endpoint.ToString()
<< ": not draining, passing to child";
}
callback(endpoint);
}
@ -757,7 +748,7 @@ class ChildEndpointIterator final : public EndpointAddressesIterator {
absl::Status XdsOverrideHostLb::UpdateLocked(UpdateArgs args) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO, "[xds_override_host_lb %p] Received update", this);
LOG(INFO) << "[xds_override_host_lb " << this << "] Received update";
}
// Grab new LB policy config.
if (args.config == nullptr) {
@ -787,11 +778,11 @@ absl::Status XdsOverrideHostLb::UpdateLocked(UpdateArgs args) {
override_host_status_set_ = it->second->cluster->override_host_statuses;
connection_idle_timeout_ = it->second->cluster->connection_idle_timeout;
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] override host status set: %s "
"connection idle timeout: %s",
this, override_host_status_set_.ToString().c_str(),
connection_idle_timeout_.ToString().c_str());
LOG(INFO) << "[xds_override_host_lb " << this
<< "] override host status set: "
<< override_host_status_set_.ToString()
<< " connection idle timeout: "
<< connection_idle_timeout_.ToString();
}
// Update address map and wrap endpoint iterator for child policy.
if (args.addresses.ok()) {
@ -800,8 +791,8 @@ absl::Status XdsOverrideHostLb::UpdateLocked(UpdateArgs args) {
std::make_shared<ChildEndpointIterator>(std::move(*args.addresses));
} else {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO, "[xds_override_host_lb %p] address error: %s", this,
args.addresses.status().ToString().c_str());
LOG(INFO) << "[xds_override_host_lb " << this
<< "] address error: " << args.addresses.status();
}
}
// Create child policy if needed.
@ -815,9 +806,8 @@ absl::Status XdsOverrideHostLb::UpdateLocked(UpdateArgs args) {
update_args.config = new_config->child_config();
update_args.args = args_;
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] Updating child policy handler %p", this,
child_policy_.get());
LOG(INFO) << "[xds_override_host_lb " << this
<< "] Updating child policy handler " << child_policy_.get();
}
return child_policy_->UpdateLocked(std::move(update_args));
}
@ -827,11 +817,10 @@ void XdsOverrideHostLb::MaybeUpdatePickerLocked() {
auto xds_override_host_picker = MakeRefCounted<Picker>(
RefAsSubclass<XdsOverrideHostLb>(), picker_, override_host_status_set_);
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] updating connectivity: state=%s "
"status=(%s) picker=%p",
this, ConnectivityStateName(state_), status_.ToString().c_str(),
xds_override_host_picker.get());
LOG(INFO) << "[xds_override_host_lb " << this
<< "] updating connectivity: state="
<< ConnectivityStateName(state_) << " status=(" << status_
<< ") picker=" << xds_override_host_picker.get();
}
channel_control_helper()->UpdateState(state_, status_,
std::move(xds_override_host_picker));
@ -849,9 +838,8 @@ OrphanablePtr<LoadBalancingPolicy> XdsOverrideHostLb::CreateChildPolicyLocked(
MakeOrphanable<ChildPolicyHandler>(std::move(lb_policy_args),
&xds_override_host_lb_trace);
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] Created new child policy handler %p",
this, lb_policy.get());
LOG(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
@ -877,10 +865,10 @@ void XdsOverrideHostLb::UpdateAddressMap(
if (status.status() == XdsHealthStatus::kDraining &&
!override_host_status_set_.Contains(status)) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] endpoint %s: draining but not in "
"override_host_status set -- ignoring",
this, endpoint.ToString().c_str());
LOG(INFO) << "[xds_override_host_lb " << this << "] endpoint "
<< endpoint.ToString()
<< ": draining but not in override_host_status set -- "
"ignoring";
}
return;
}
@ -890,10 +878,8 @@ void XdsOverrideHostLb::UpdateAddressMap(
auto key = grpc_sockaddr_to_string(&address, /*normalize=*/false);
if (!key.ok()) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] no key for endpoint address; "
"not adding to map",
this);
LOG(INFO) << "[xds_override_host_lb " << this
<< "] no key for endpoint address; not adding to map";
}
} else {
addresses.push_back(*std::move(key));
@ -922,8 +908,8 @@ void XdsOverrideHostLb::UpdateAddressMap(
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)) {
gpr_log(GPR_INFO, "[xds_override_host_lb %p] removing map key %s",
this, it->first.c_str());
LOG(INFO) << "[xds_override_host_lb " << this << "] removing map key "
<< it->first;
}
it->second->UnsetSubchannel(&subchannel_refs_to_drop);
it = subchannel_map_.erase(it);
@ -937,19 +923,18 @@ void XdsOverrideHostLb::UpdateAddressMap(
auto it = subchannel_map_.find(address);
if (it == subchannel_map_.end()) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO, "[xds_override_host_lb %p] adding map key %s", this,
address.c_str());
LOG(INFO) << "[xds_override_host_lb " << this << "] adding map key "
<< address;
}
it = subchannel_map_.emplace(address, MakeRefCounted<SubchannelEntry>())
.first;
}
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] map key %s: setting "
"eds_health_status=%s address_list=%s",
this, address.c_str(),
address_info.eds_health_status.ToString(),
address_info.address_list.c_str());
LOG(INFO) << "[xds_override_host_lb " << this << "] map key " << address
<< ": setting "
<< "eds_health_status="
<< address_info.eds_health_status.ToString()
<< " address_list=" << address_info.address_list.c_str();
}
it->second->set_eds_health_status(address_info.eds_health_status);
it->second->set_address_list(std::move(address_info.address_list));
@ -989,9 +974,8 @@ XdsOverrideHostLb::AdoptSubchannel(
void XdsOverrideHostLb::CreateSubchannelForAddress(absl::string_view address) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] creating owned subchannel for %s", this,
std::string(address).c_str());
LOG(INFO) << "[xds_override_host_lb " << this
<< "] creating owned subchannel for " << address;
}
auto addr = StringToSockaddr(address);
CHECK(addr.ok());
@ -1033,9 +1017,8 @@ void XdsOverrideHostLb::CleanupSubchannels() {
auto subchannel = p.second->TakeOwnedSubchannel();
if (subchannel != nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] dropping subchannel for %s",
this, p.first.c_str());
LOG(INFO) << "[xds_override_host_lb " << this
<< "] dropping subchannel for " << p.first;
}
subchannel_refs_to_drop.push_back(std::move(subchannel));
}
@ -1061,11 +1044,9 @@ RefCountedPtr<SubchannelInterface> XdsOverrideHostLb::Helper::CreateSubchannel(
const ChannelArgs& args) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
auto key = grpc_sockaddr_to_string(&address, /*normalize=*/false);
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] creating subchannel for %s, "
"per_address_args=%s, args=%s",
this, key.value_or("<unknown>").c_str(),
per_address_args.ToString().c_str(), args.ToString().c_str());
LOG(INFO) << "[xds_override_host_lb " << this
<< "] creating subchannel for " << key.value_or("<unknown>")
<< ", per_address_args=" << per_address_args << ", args=" << args;
}
auto subchannel = parent()->channel_control_helper()->CreateSubchannel(
address, per_address_args, args);
@ -1113,9 +1094,8 @@ void XdsOverrideHostLb::SubchannelWrapper::CancelConnectivityStateWatch(
void XdsOverrideHostLb::SubchannelWrapper::Orphaned() {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb %p] subchannel wrapper %p orphaned",
policy_.get(), this);
LOG(INFO) << "[xds_override_host_lb " << policy_.get()
<< "] subchannel wrapper " << this << " orphaned";
}
if (!IsWorkSerializerDispatchEnabled()) {
wrapped_subchannel()->CancelConnectivityStateWatch(watcher_);
@ -1227,9 +1207,8 @@ void XdsOverrideHostLb::SubchannelEntry::OnSubchannelWrapperOrphan(
if (subchannel != wrapper) return;
if (last_used_time_ < (Timestamp::Now() - connection_idle_timeout)) {
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb] removing unowned subchannel wrapper %p",
subchannel);
LOG(INFO) << "[xds_override_host_lb] removing unowned subchannel wrapper "
<< subchannel;
}
subchannel_ = nullptr;
} else {
@ -1238,10 +1217,8 @@ void XdsOverrideHostLb::SubchannelEntry::OnSubchannelWrapperOrphan(
// the wrapper with the same underlying subchannel, and we hold
// our own ref to it.
if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) {
gpr_log(GPR_INFO,
"[xds_override_host_lb] subchannel wrapper %p: cloning "
"to gain ownership",
subchannel);
LOG(INFO) << "[xds_override_host_lb] subchannel wrapper " << subchannel
<< ": cloning to gain ownership";
}
subchannel_ = wrapper->Clone();
}

@ -20,6 +20,7 @@
#include <string>
#include <utility>
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -136,13 +137,13 @@ XdsWrrLocalityLb::XdsWrrLocalityLb(Args args)
XdsWrrLocalityLb::~XdsWrrLocalityLb() {
if (GRPC_TRACE_FLAG_ENABLED(xds_wrr_locality_lb)) {
gpr_log(GPR_INFO, "[xds_wrr_locality_lb %p] destroying", this);
LOG(INFO) << "[xds_wrr_locality_lb " << this << "] destroying";
}
}
void XdsWrrLocalityLb::ShutdownLocked() {
if (GRPC_TRACE_FLAG_ENABLED(xds_wrr_locality_lb)) {
gpr_log(GPR_INFO, "[xds_wrr_locality_lb %p] shutting down", this);
LOG(INFO) << "[xds_wrr_locality_lb " << this << "] shutting down";
}
if (child_policy_ != nullptr) {
grpc_pollset_set_del_pollset_set(child_policy_->interested_parties(),
@ -161,7 +162,7 @@ void XdsWrrLocalityLb::ResetBackoffLocked() {
absl::Status XdsWrrLocalityLb::UpdateLocked(UpdateArgs args) {
if (GRPC_TRACE_FLAG_ENABLED(xds_wrr_locality_lb)) {
gpr_log(GPR_INFO, "[xds_wrr_locality_lb %p] Received update", this);
LOG(INFO) << "[xds_wrr_locality_lb " << this << "] Received update";
}
auto config = args.config.TakeAsSubclass<XdsWrrLocalityLbConfig>();
// Scan the addresses to find the weight for each locality.
@ -175,10 +176,10 @@ absl::Status XdsWrrLocalityLb::UpdateLocked(UpdateArgs args) {
auto p = locality_weights.emplace(
locality_name->human_readable_string(), weight);
if (!p.second && p.first->second != weight) {
gpr_log(GPR_ERROR,
"INTERNAL ERROR: xds_wrr_locality found different weights "
"for locality %s (%u vs %u); using first value",
p.first->first.c_str(), p.first->second, weight);
LOG(ERROR) << "INTERNAL ERROR: xds_wrr_locality found different "
"weights for locality "
<< p.first->first.c_str() << " (" << p.first->second
<< " vs " << weight << "); using first value";
}
}
});
@ -203,9 +204,9 @@ absl::Status XdsWrrLocalityLb::UpdateLocked(UpdateArgs args) {
}),
});
if (GRPC_TRACE_FLAG_ENABLED(xds_wrr_locality_lb)) {
gpr_log(GPR_INFO,
"[xds_wrr_locality_lb %p] generated child policy config: %s", this,
JsonDump(child_config_json, /*indent=*/1).c_str());
LOG(INFO) << "[xds_wrr_locality_lb " << this
<< "] generated child policy config: "
<< JsonDump(child_config_json, /*indent=*/1);
}
// Parse config.
auto child_config =
@ -214,10 +215,10 @@ absl::Status XdsWrrLocalityLb::UpdateLocked(UpdateArgs args) {
if (!child_config.ok()) {
// This should never happen, but if it does, we basically have no
// way to fix it, so we put the channel in TRANSIENT_FAILURE.
gpr_log(GPR_ERROR,
"[xds_wrr_locality %p] error parsing generated child policy "
"config -- putting channel in TRANSIENT_FAILURE: %s",
this, child_config.status().ToString().c_str());
LOG(ERROR) << "[xds_wrr_locality " << this
<< "] error parsing generated child policy config -- putting "
"channel in TRANSIENT_FAILURE: "
<< child_config.status();
absl::Status status = absl::InternalError(absl::StrCat(
"xds_wrr_locality LB policy: error parsing generated child policy "
"config: ",
@ -239,8 +240,8 @@ absl::Status XdsWrrLocalityLb::UpdateLocked(UpdateArgs args) {
update_args.args = std::move(args.args);
// Update the policy.
if (GRPC_TRACE_FLAG_ENABLED(xds_wrr_locality_lb)) {
gpr_log(GPR_INFO, "[xds_wrr_locality_lb %p] updating child policy %p", this,
child_policy_.get());
LOG(INFO) << "[xds_wrr_locality_lb " << this << "] updating child policy "
<< child_policy_.get();
}
return child_policy_->UpdateLocked(std::move(update_args));
}
@ -256,8 +257,8 @@ OrphanablePtr<LoadBalancingPolicy> XdsWrrLocalityLb::CreateChildPolicyLocked(
CoreConfiguration::Get().lb_policy_registry().CreateLoadBalancingPolicy(
"weighted_target_experimental", std::move(lb_policy_args));
if (GRPC_TRACE_FLAG_ENABLED(xds_wrr_locality_lb)) {
gpr_log(GPR_INFO, "[xds_wrr_locality_lb %p] created new child policy %p",
this, lb_policy.get());
LOG(INFO) << "[xds_wrr_locality_lb " << this
<< "] created new child policy " << 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

@ -193,7 +193,7 @@ struct server_request_call_args {
static void shutdown_server_unblock_func(void* arg) {
grpc_rb_server* server = (grpc_rb_server*)arg;
gpr_log(GPR_INFO, "GRPC_RUBY: shutdown_server_unblock_func");
GPR_ASSERT(server->wrapped != NULL);
GRPC_RUBY_ASSERT(server->wrapped != NULL);
grpc_event event;
void* tag = &event;
grpc_server_shutdown_and_notify(server->wrapped, server->queue, tag);

@ -51,7 +51,7 @@ static void test_grpc_parse_ipv6_parity_with_getaddrinfo(
grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(target);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status();
ASSERT_TRUE(uri.ok());
}
grpc_resolved_address addr;
@ -75,7 +75,7 @@ static void test_grpc_parse_ipv6_parity_with_getaddrinfo(
struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) {
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(uri_text);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status();
EXPECT_TRUE(uri.ok());
}
std::string host;

@ -57,7 +57,10 @@ grpc_yodel_simple_test(
grpc_yodel_simple_test(
name = "load_balanced_call_destination",
srcs = ["load_balanced_call_destination_test.cc"],
external_deps = ["gtest"],
external_deps = [
"absl/log:log",
"gtest",
],
deps = [
"//:grpc_client_channel",
"//test/core/call/yodel:yodel_test",

@ -17,6 +17,7 @@
#include <atomic>
#include <memory>
#include "absl/log/log.h"
#include "absl/strings/string_view.h"
#include "gtest/gtest.h"
@ -118,7 +119,7 @@ class ClientChannelTest : public YodelTest {
RefCountedPtr<Subchannel> CreateSubchannel(
const grpc_resolved_address& address,
const ChannelArgs& args) override {
gpr_log(GPR_INFO, "CreateSubchannel: args=%s", args.ToString().c_str());
LOG(INFO) << "CreateSubchannel: args=" << args.ToString();
return Subchannel::Create(MakeOrphanable<TestConnector>(), address, args);
}
};

@ -208,7 +208,7 @@ static void on_read_request_done_locked(void* arg, grpc_error_handle error);
static void proxy_connection_failed(proxy_connection* conn,
failure_type failure, const char* prefix,
grpc_error_handle error) {
gpr_log(GPR_INFO, "%s: %s", prefix, grpc_core::StatusToString(error).c_str());
LOG(INFO) << prefix << ": " << grpc_core::StatusToString(error);
// Decide whether we should shut down the client and server.
bool shutdown_client = false;
bool shutdown_server = false;

@ -164,8 +164,7 @@ static void session_read_cb(void* arg, // session
// before notify_on_read is called.
grpc_fd_notify_on_read(se->em_fd, &se->session_read_closure);
} else {
grpc_core::Crash(absl::StrFormat("Unhandled read error %s",
grpc_core::StrError(errno).c_str()));
LOG(FATAL) << "Unhandled read error " << grpc_core::StrError(errno);
}
}
}
@ -330,8 +329,7 @@ static void client_session_write(void* arg, // client
}
gpr_mu_unlock(g_mu);
} else {
grpc_core::Crash(absl::StrFormat("unknown errno %s",
grpc_core::StrError(errno).c_str()));
LOG(FATAL) << "unknown errno " << grpc_core::StrError(errno).c_str();
}
}
@ -348,12 +346,10 @@ static void client_start(client* cl, int port) {
pfd.events = POLLOUT;
pfd.revents = 0;
if (poll(&pfd, 1, -1) == -1) {
gpr_log(GPR_ERROR, "poll() failed during connect; errno=%d", errno);
abort();
LOG(FATAL) << "poll() failed during connect; errno=" << errno;
}
} else {
grpc_core::Crash(
absl::StrFormat("Failed to connect to the server (errno=%d)", errno));
LOG(FATAL) << "Failed to connect to the server (errno=" << errno << ")";
}
}

@ -33,7 +33,6 @@
#include "gtest/gtest.h"
#include <grpc/slice.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/gprpp/memory.h"
@ -395,14 +394,19 @@ size_t SumSlice(const Slice& slice) {
TEST(SliceTest, ExternalAsOwned) {
auto external_string = std::make_unique<std::string>(RandomString(1024));
Slice slice = Slice::FromExternalString(*external_string);
const auto initial_sum = SumSlice(slice);
const size_t initial_sum = SumSlice(slice);
Slice owned = slice.AsOwned();
EXPECT_EQ(initial_sum, SumSlice(owned));
external_string.reset();
// In ASAN (where we can be sure that it'll crash), go ahead and read the
// bytes we just deleted.
if (BuiltUnderAsan()) {
ASSERT_DEATH({ gpr_log(GPR_DEBUG, "%" PRIdPTR, SumSlice(slice)); }, "");
ASSERT_DEATH(
{
size_t sum = SumSlice(slice);
VLOG(2) << sum;
},
"");
}
EXPECT_EQ(initial_sum, SumSlice(owned));
}

Loading…
Cancel
Save