Merge pull request #19714 from hcaseyal/channel_state

Move GetChannelConnectivityStateChangeString to channelz code
pull/19685/head
hcaseyal 5 years ago committed by GitHub
commit 228e7557fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/core/ext/filters/client_channel/client_channel.cc
  2. 17
      src/core/lib/channel/channelz.cc
  3. 4
      src/core/lib/channel/channelz.h

@ -733,7 +733,8 @@ class ChannelData::ConnectivityStateAndPickerSetter {
chand->channelz_node_->AddTraceEvent(
channelz::ChannelTrace::Severity::Info,
grpc_slice_from_static_string(
GetChannelConnectivityStateChangeString(state)));
channelz::ChannelNode::GetChannelConnectivityStateChangeString(
state)));
}
// Bounce into the data plane combiner to reset the picker.
GRPC_CHANNEL_STACK_REF(chand->owning_stack_,
@ -744,23 +745,6 @@ class ChannelData::ConnectivityStateAndPickerSetter {
}
private:
static const char* GetChannelConnectivityStateChangeString(
grpc_connectivity_state state) {
switch (state) {
case GRPC_CHANNEL_IDLE:
return "Channel state change to IDLE";
case GRPC_CHANNEL_CONNECTING:
return "Channel state change to CONNECTING";
case GRPC_CHANNEL_READY:
return "Channel state change to READY";
case GRPC_CHANNEL_TRANSIENT_FAILURE:
return "Channel state change to TRANSIENT_FAILURE";
case GRPC_CHANNEL_SHUTDOWN:
return "Channel state change to SHUTDOWN";
}
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
static void SetPicker(void* arg, grpc_error* ignored) {
auto* self = static_cast<ConnectivityStateAndPickerSetter*>(arg);
// Update picker.

@ -192,6 +192,23 @@ ChannelNode::ChannelNode(UniquePtr<char> target,
trace_(channel_tracer_max_nodes),
parent_uuid_(parent_uuid) {}
const char* ChannelNode::GetChannelConnectivityStateChangeString(
grpc_connectivity_state state) {
switch (state) {
case GRPC_CHANNEL_IDLE:
return "Channel state change to IDLE";
case GRPC_CHANNEL_CONNECTING:
return "Channel state change to CONNECTING";
case GRPC_CHANNEL_READY:
return "Channel state change to READY";
case GRPC_CHANNEL_TRANSIENT_FAILURE:
return "Channel state change to TRANSIENT_FAILURE";
case GRPC_CHANNEL_SHUTDOWN:
return "Channel state change to SHUTDOWN";
}
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
grpc_json* ChannelNode::RenderJson() {
// We need to track these three json objects to build our object
grpc_json* top_level_json = grpc_json_create(GRPC_JSON_OBJECT);

@ -153,6 +153,10 @@ class ChannelNode : public BaseNode {
ChannelNode(UniquePtr<char> target, size_t channel_tracer_max_nodes,
intptr_t parent_uuid);
// Returns the string description of the given connectivity state.
static const char* GetChannelConnectivityStateChangeString(
grpc_connectivity_state state);
intptr_t parent_uuid() const { return parent_uuid_; }
grpc_json* RenderJson() override;

Loading…
Cancel
Save