2020
2121#include " src/cpp/server/channelz/channelz_service.h"
2222
23- #include < google/protobuf/text_format.h>
24- #include < google/protobuf/util/json_util.h>
25-
2623#include < grpc/grpc.h>
2724#include < grpc/support/alloc.h>
2825
@@ -33,13 +30,14 @@ Status ChannelzService::GetTopChannels(
3330 channelz::v1::GetTopChannelsResponse* response) {
3431 char * json_str = grpc_channelz_get_top_channels (request->start_channel_id ());
3532 if (json_str == nullptr ) {
36- return Status (INTERNAL, " grpc_channelz_get_top_channels returned null" );
33+ return Status (StatusCode::INTERNAL,
34+ " grpc_channelz_get_top_channels returned null" );
3735 }
38- google ::protobuf::util::Status s =
39- google ::protobuf::util ::JsonStringToMessage (json_str, response);
36+ grpc ::protobuf::util::Status s =
37+ grpc ::protobuf::json ::JsonStringToMessage (json_str, response);
4038 gpr_free (json_str);
41- if (s != google::protobuf::util::Status::OK ) {
42- return Status (INTERNAL, s.ToString ());
39+ if (!s. ok () ) {
40+ return Status (StatusCode:: INTERNAL, s.ToString ());
4341 }
4442 return Status::OK;
4543}
@@ -49,13 +47,14 @@ Status ChannelzService::GetServers(
4947 channelz::v1::GetServersResponse* response) {
5048 char * json_str = grpc_channelz_get_servers (request->start_server_id ());
5149 if (json_str == nullptr ) {
52- return Status (INTERNAL, " grpc_channelz_get_servers returned null" );
50+ return Status (StatusCode::INTERNAL,
51+ " grpc_channelz_get_servers returned null" );
5352 }
54- google ::protobuf::util::Status s =
55- google ::protobuf::util ::JsonStringToMessage (json_str, response);
53+ grpc ::protobuf::util::Status s =
54+ grpc ::protobuf::json ::JsonStringToMessage (json_str, response);
5655 gpr_free (json_str);
57- if (s != google::protobuf::util::Status::OK ) {
58- return Status (INTERNAL, s.ToString ());
56+ if (!s. ok () ) {
57+ return Status (StatusCode:: INTERNAL, s.ToString ());
5958 }
6059 return Status::OK;
6160}
@@ -66,13 +65,14 @@ Status ChannelzService::GetServerSockets(
6665 char * json_str = grpc_channelz_get_server_sockets (request->server_id (),
6766 request->start_socket_id ());
6867 if (json_str == nullptr ) {
69- return Status (INTERNAL, " grpc_channelz_get_server_sockets returned null" );
68+ return Status (StatusCode::INTERNAL,
69+ " grpc_channelz_get_server_sockets returned null" );
7070 }
71- google ::protobuf::util::Status s =
72- google ::protobuf::util ::JsonStringToMessage (json_str, response);
71+ grpc ::protobuf::util::Status s =
72+ grpc ::protobuf::json ::JsonStringToMessage (json_str, response);
7373 gpr_free (json_str);
74- if (s != google::protobuf::util::Status::OK ) {
75- return Status (INTERNAL, s.ToString ());
74+ if (!s. ok () ) {
75+ return Status (StatusCode:: INTERNAL, s.ToString ());
7676 }
7777 return Status::OK;
7878}
@@ -82,13 +82,13 @@ Status ChannelzService::GetChannel(
8282 channelz::v1::GetChannelResponse* response) {
8383 char * json_str = grpc_channelz_get_channel (request->channel_id ());
8484 if (json_str == nullptr ) {
85- return Status (NOT_FOUND, " No object found for that ChannelId" );
85+ return Status (StatusCode:: NOT_FOUND, " No object found for that ChannelId" );
8686 }
87- google ::protobuf::util::Status s =
88- google ::protobuf::util ::JsonStringToMessage (json_str, response);
87+ grpc ::protobuf::util::Status s =
88+ grpc ::protobuf::json ::JsonStringToMessage (json_str, response);
8989 gpr_free (json_str);
90- if (s != google::protobuf::util::Status::OK ) {
91- return Status (INTERNAL, s.ToString ());
90+ if (!s. ok () ) {
91+ return Status (StatusCode:: INTERNAL, s.ToString ());
9292 }
9393 return Status::OK;
9494}
@@ -98,13 +98,14 @@ Status ChannelzService::GetSubchannel(
9898 channelz::v1::GetSubchannelResponse* response) {
9999 char * json_str = grpc_channelz_get_subchannel (request->subchannel_id ());
100100 if (json_str == nullptr ) {
101- return Status (NOT_FOUND, " No object found for that SubchannelId" );
101+ return Status (StatusCode::NOT_FOUND,
102+ " No object found for that SubchannelId" );
102103 }
103- google ::protobuf::util::Status s =
104- google ::protobuf::util ::JsonStringToMessage (json_str, response);
104+ grpc ::protobuf::util::Status s =
105+ grpc ::protobuf::json ::JsonStringToMessage (json_str, response);
105106 gpr_free (json_str);
106- if (s != google::protobuf::util::Status::OK ) {
107- return Status (INTERNAL, s.ToString ());
107+ if (!s. ok () ) {
108+ return Status (StatusCode:: INTERNAL, s.ToString ());
108109 }
109110 return Status::OK;
110111}
@@ -114,13 +115,13 @@ Status ChannelzService::GetSocket(ServerContext* unused,
114115 channelz::v1::GetSocketResponse* response) {
115116 char * json_str = grpc_channelz_get_socket (request->socket_id ());
116117 if (json_str == nullptr ) {
117- return Status (NOT_FOUND, " No object found for that SocketId" );
118+ return Status (StatusCode:: NOT_FOUND, " No object found for that SocketId" );
118119 }
119- google ::protobuf::util::Status s =
120- google ::protobuf::util ::JsonStringToMessage (json_str, response);
120+ grpc ::protobuf::util::Status s =
121+ grpc ::protobuf::json ::JsonStringToMessage (json_str, response);
121122 gpr_free (json_str);
122- if (s != google::protobuf::util::Status::OK ) {
123- return Status (INTERNAL, s.ToString ());
123+ if (!s. ok () ) {
124+ return Status (StatusCode:: INTERNAL, s.ToString ());
124125 }
125126 return Status::OK;
126127}
0 commit comments