Revert "Refactor Channelz Service to Support Internal Build"

pull/16993/head
Noah Eisen 7 years ago committed by GitHub
parent 2b54c93c65
commit 2eafaccba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      include/grpcpp/impl/codegen/config_protobuf.h
  2. 67
      src/cpp/server/channelz/channelz_service.cc

@ -66,11 +66,6 @@
#define GRPC_CUSTOM_CODEDINPUTSTREAM ::google::protobuf::io::CodedInputStream #define GRPC_CUSTOM_CODEDINPUTSTREAM ::google::protobuf::io::CodedInputStream
#endif #endif
#ifndef GRPC_CUSTOM_UTIL_STATUS
#include <google/protobuf/util/json_util.h>
#define GRPC_CUSTOM_UTIL_STATUS ::google::protobuf::util::Status
#endif
namespace grpc { namespace grpc {
namespace protobuf { namespace protobuf {
@ -88,17 +83,6 @@ typedef GRPC_CUSTOM_SERVICEDESCRIPTOR ServiceDescriptor;
typedef GRPC_CUSTOM_SIMPLEDESCRIPTORDATABASE SimpleDescriptorDatabase; typedef GRPC_CUSTOM_SIMPLEDESCRIPTORDATABASE SimpleDescriptorDatabase;
typedef GRPC_CUSTOM_SOURCELOCATION SourceLocation; typedef GRPC_CUSTOM_SOURCELOCATION SourceLocation;
namespace util {
typedef GRPC_CUSTOM_UTIL_STATUS Status;
inline util::Status JsonStringToMessage(const std::string& input,
Message* message) {
return ::google::protobuf::util::JsonStringToMessage(
input, message, ::google::protobuf::util::JsonParseOptions());
}
} // namespace util
namespace io { namespace io {
typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream; typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream;
typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream; typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream;

@ -20,6 +20,9 @@
#include "src/cpp/server/channelz/channelz_service.h" #include "src/cpp/server/channelz/channelz_service.h"
#include <google/protobuf/text_format.h>
#include <google/protobuf/util/json_util.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
@ -30,14 +33,13 @@ Status ChannelzService::GetTopChannels(
channelz::v1::GetTopChannelsResponse* response) { channelz::v1::GetTopChannelsResponse* response) {
char* json_str = grpc_channelz_get_top_channels(request->start_channel_id()); char* json_str = grpc_channelz_get_top_channels(request->start_channel_id());
if (json_str == nullptr) { if (json_str == nullptr) {
return Status(StatusCode::INTERNAL, return Status(INTERNAL, "grpc_channelz_get_top_channels returned null");
"grpc_channelz_get_top_channels returned null");
} }
grpc::protobuf::util::Status s = google::protobuf::util::Status s =
grpc::protobuf::util::JsonStringToMessage(json_str, response); google::protobuf::util::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (s != google::protobuf::util::Status::OK) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(INTERNAL, s.ToString());
} }
return Status::OK; return Status::OK;
} }
@ -47,14 +49,13 @@ Status ChannelzService::GetServers(
channelz::v1::GetServersResponse* response) { channelz::v1::GetServersResponse* response) {
char* json_str = grpc_channelz_get_servers(request->start_server_id()); char* json_str = grpc_channelz_get_servers(request->start_server_id());
if (json_str == nullptr) { if (json_str == nullptr) {
return Status(StatusCode::INTERNAL, return Status(INTERNAL, "grpc_channelz_get_servers returned null");
"grpc_channelz_get_servers returned null");
} }
grpc::protobuf::util::Status s = google::protobuf::util::Status s =
grpc::protobuf::util::JsonStringToMessage(json_str, response); google::protobuf::util::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (s != google::protobuf::util::Status::OK) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(INTERNAL, s.ToString());
} }
return Status::OK; return Status::OK;
} }
@ -65,14 +66,13 @@ Status ChannelzService::GetServerSockets(
char* json_str = grpc_channelz_get_server_sockets(request->server_id(), char* json_str = grpc_channelz_get_server_sockets(request->server_id(),
request->start_socket_id()); request->start_socket_id());
if (json_str == nullptr) { if (json_str == nullptr) {
return Status(StatusCode::INTERNAL, return Status(INTERNAL, "grpc_channelz_get_server_sockets returned null");
"grpc_channelz_get_server_sockets returned null");
} }
grpc::protobuf::util::Status s = google::protobuf::util::Status s =
grpc::protobuf::util::JsonStringToMessage(json_str, response); google::protobuf::util::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (s != google::protobuf::util::Status::OK) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(INTERNAL, s.ToString());
} }
return Status::OK; return Status::OK;
} }
@ -82,13 +82,13 @@ Status ChannelzService::GetChannel(
channelz::v1::GetChannelResponse* response) { channelz::v1::GetChannelResponse* response) {
char* json_str = grpc_channelz_get_channel(request->channel_id()); char* json_str = grpc_channelz_get_channel(request->channel_id());
if (json_str == nullptr) { if (json_str == nullptr) {
return Status(StatusCode::NOT_FOUND, "No object found for that ChannelId"); return Status(NOT_FOUND, "No object found for that ChannelId");
} }
grpc::protobuf::util::Status s = google::protobuf::util::Status s =
grpc::protobuf::util::JsonStringToMessage(json_str, response); google::protobuf::util::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (s != google::protobuf::util::Status::OK) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(INTERNAL, s.ToString());
} }
return Status::OK; return Status::OK;
} }
@ -98,14 +98,13 @@ Status ChannelzService::GetSubchannel(
channelz::v1::GetSubchannelResponse* response) { channelz::v1::GetSubchannelResponse* response) {
char* json_str = grpc_channelz_get_subchannel(request->subchannel_id()); char* json_str = grpc_channelz_get_subchannel(request->subchannel_id());
if (json_str == nullptr) { if (json_str == nullptr) {
return Status(StatusCode::NOT_FOUND, return Status(NOT_FOUND, "No object found for that SubchannelId");
"No object found for that SubchannelId");
} }
grpc::protobuf::util::Status s = google::protobuf::util::Status s =
grpc::protobuf::util::JsonStringToMessage(json_str, response); google::protobuf::util::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (s != google::protobuf::util::Status::OK) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(INTERNAL, s.ToString());
} }
return Status::OK; return Status::OK;
} }
@ -115,13 +114,13 @@ Status ChannelzService::GetSocket(ServerContext* unused,
channelz::v1::GetSocketResponse* response) { channelz::v1::GetSocketResponse* response) {
char* json_str = grpc_channelz_get_socket(request->socket_id()); char* json_str = grpc_channelz_get_socket(request->socket_id());
if (json_str == nullptr) { if (json_str == nullptr) {
return Status(StatusCode::NOT_FOUND, "No object found for that SocketId"); return Status(NOT_FOUND, "No object found for that SocketId");
} }
grpc::protobuf::util::Status s = google::protobuf::util::Status s =
grpc::protobuf::util::JsonStringToMessage(json_str, response); google::protobuf::util::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (s != google::protobuf::util::Status::OK) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(INTERNAL, s.ToString());
} }
return Status::OK; return Status::OK;
} }

Loading…
Cancel
Save