Commit c2388562 authored by wangxuefeng's avatar wangxuefeng

rename ThriftBinary* to ThriftFramed*

parent c332d839
...@@ -6,7 +6,7 @@ include config.mk ...@@ -6,7 +6,7 @@ include config.mk
# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 # 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8
# 3. Removed -Werror: Not block compilation for non-vital warnings, especially when the # 3. Removed -Werror: Not block compilation for non-vital warnings, especially when the
# code is tested on newer systems. If the code is used in production, add -Werror back # code is tested on newer systems. If the code is used in production, add -Werror back
CPPFLAGS+=-DENABLE_THRIFT_FRAMED_PROTOCOL -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -DBRPC_REVISION=\"$(shell git rev-parse --short HEAD)\" CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -DBRPC_REVISION=\"$(shell git rev-parse --short HEAD)\"
CXXFLAGS=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x CXXFLAGS=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x
CFLAGS=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer CFLAGS=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer
DEBUG_CXXFLAGS = $(filter-out -DNDEBUG,$(CXXFLAGS)) -DUNIT_TEST -DBVAR_NOT_LINK_DEFAULT_VARIABLES DEBUG_CXXFLAGS = $(filter-out -DNDEBUG,$(CXXFLAGS)) -DUNIT_TEST -DBVAR_NOT_LINK_DEFAULT_VARIABLES
......
...@@ -90,7 +90,7 @@ int main(int argc, char* argv[]) { ...@@ -90,7 +90,7 @@ int main(int argc, char* argv[]) {
<< "Sending thrift requests at qps=" << g_latency_recorder.qps(1) << "Sending thrift requests at qps=" << g_latency_recorder.qps(1)
<< " latency=" << g_latency_recorder.latency(1); << " latency=" << g_latency_recorder.latency(1);
sleep(1); //sleep(1);
} }
......
...@@ -48,10 +48,10 @@ public: ...@@ -48,10 +48,10 @@ public:
// Adapt your own thrift-based protocol to use brpc // Adapt your own thrift-based protocol to use brpc
class MyThriftProtocol : public brpc::ThriftFramedService { class MyThriftProtocol : public brpc::ThriftFramedService {
public: public:
void ProcessThriftBinaryRequest(const brpc::Server&, void ProcessThriftFramedRequest(const brpc::Server&,
brpc::Controller* cntl, brpc::Controller* cntl,
const brpc::ThriftBinaryMessage& request, const brpc::ThriftFramedMessage& request,
brpc::ThriftBinaryMessage* response, brpc::ThriftFramedMessage* response,
brpc::ThriftFramedClosure* done) { brpc::ThriftFramedClosure* done) {
// This object helps you to call done->Run() in RAII style. If you need // This object helps you to call done->Run() in RAII style. If you need
// to process the request asynchronously, pass done_guard.release(). // to process the request asynchronously, pass done_guard.release().
...@@ -81,10 +81,10 @@ public: ...@@ -81,10 +81,10 @@ public:
// Adapt your own thrift-based protocol to use brpc // Adapt your own thrift-based protocol to use brpc
class MyThriftProtocolAnother : public brpc::ThriftFramedService { class MyThriftProtocolAnother : public brpc::ThriftFramedService {
public: public:
void ProcessThriftBinaryRequest(const brpc::Server&, void ProcessThriftFramedRequest(const brpc::Server&,
brpc::Controller* cntl, brpc::Controller* cntl,
const brpc::ThriftBinaryMessage& request, const brpc::ThriftFramedMessage& request,
brpc::ThriftBinaryMessage* response, brpc::ThriftFramedMessage* response,
brpc::ThriftFramedClosure* done) { brpc::ThriftFramedClosure* done) {
// This object helps you to call done->Run() in RAII style. If you need // This object helps you to call done->Run() in RAII style. If you need
// to process the request asynchronously, pass done_guard.release(). // to process the request asynchronously, pass done_guard.release().
...@@ -97,7 +97,7 @@ public: ...@@ -97,7 +97,7 @@ public:
return; return;
} }
brpc::ThriftBinaryMessage request_ref = request; brpc::ThriftFramedMessage request_ref = request;
example::EchoRequest* req = request_ref.cast<example::EchoRequest>(); example::EchoRequest* req = request_ref.cast<example::EchoRequest>();
example::EchoResponse* res = response->cast<example::EchoResponse>(); example::EchoResponse* res = response->cast<example::EchoResponse>();
......
...@@ -423,10 +423,10 @@ static void GlobalInitializeOrDieImpl() { ...@@ -423,10 +423,10 @@ static void GlobalInitializeOrDieImpl() {
} }
#ifdef ENABLE_THRIFT_FRAMED_PROTOCOL #ifdef ENABLE_THRIFT_FRAMED_PROTOCOL
Protocol thrift_binary_protocol = { ParseThriftBinaryMessage, Protocol thrift_binary_protocol = { ParseThriftFramedMessage,
SerializeThriftBinaryRequest, PackThriftBinaryRequest, SerializeThriftFramedRequest, PackThriftFramedRequest,
ProcessThriftBinaryRequest, ProcessThriftBinaryResponse, ProcessThriftFramedRequest, ProcessThriftFramedResponse,
VerifyThriftBinaryRequest, NULL, NULL, VerifyThriftFramedRequest, NULL, NULL,
CONNECTION_TYPE_POOLED_AND_SHORT, "thrift" }; CONNECTION_TYPE_POOLED_AND_SHORT, "thrift" };
if (RegisterProtocol(PROTOCOL_THRIFT, thrift_binary_protocol) != 0) { if (RegisterProtocol(PROTOCOL_THRIFT, thrift_binary_protocol) != 0) {
exit(1); exit(1);
......
...@@ -192,7 +192,7 @@ void ThriftFramedClosure::SetMethodName(const std::string& full_method_name) { ...@@ -192,7 +192,7 @@ void ThriftFramedClosure::SetMethodName(const std::string& full_method_name) {
namespace policy { namespace policy {
ParseResult ParseThriftBinaryMessage(butil::IOBuf* source, ParseResult ParseThriftFramedMessage(butil::IOBuf* source,
Socket*, bool /*read_eof*/, const void* /*arg*/) { Socket*, bool /*read_eof*/, const void* /*arg*/) {
char header_buf[sizeof(thrift_binary_head_t) + 3]; char header_buf[sizeof(thrift_binary_head_t) + 3];
...@@ -230,14 +230,14 @@ struct CallMethodInBackupThreadArgs { ...@@ -230,14 +230,14 @@ struct CallMethodInBackupThreadArgs {
ThriftFramedService* service; ThriftFramedService* service;
const Server* server; const Server* server;
Controller* controller; Controller* controller;
const ThriftBinaryMessage* request; const ThriftFramedMessage* request;
ThriftBinaryMessage* response; ThriftFramedMessage* response;
ThriftFramedClosure* done; ThriftFramedClosure* done;
}; };
static void CallMethodInBackupThread(void* void_args) { static void CallMethodInBackupThread(void* void_args) {
CallMethodInBackupThreadArgs* args = (CallMethodInBackupThreadArgs*)void_args; CallMethodInBackupThreadArgs* args = (CallMethodInBackupThreadArgs*)void_args;
args->service->ProcessThriftBinaryRequest(*args->server, args->controller, args->service->ProcessThriftFramedRequest(*args->server, args->controller,
*args->request, args->response, *args->request, args->response,
args->done); args->done);
delete args; delete args;
...@@ -246,8 +246,8 @@ static void CallMethodInBackupThread(void* void_args) { ...@@ -246,8 +246,8 @@ static void CallMethodInBackupThread(void* void_args) {
static void EndRunningCallMethodInPool(ThriftFramedService* service, static void EndRunningCallMethodInPool(ThriftFramedService* service,
const Server& server, const Server& server,
Controller* controller, Controller* controller,
const ThriftBinaryMessage& request, const ThriftFramedMessage& request,
ThriftBinaryMessage* response, ThriftFramedMessage* response,
ThriftFramedClosure* done) { ThriftFramedClosure* done) {
CallMethodInBackupThreadArgs* args = new CallMethodInBackupThreadArgs; CallMethodInBackupThreadArgs* args = new CallMethodInBackupThreadArgs;
args->service = service; args->service = service;
...@@ -259,7 +259,7 @@ static void EndRunningCallMethodInPool(ThriftFramedService* service, ...@@ -259,7 +259,7 @@ static void EndRunningCallMethodInPool(ThriftFramedService* service,
return EndRunningUserCodeInPool(CallMethodInBackupThread, args); return EndRunningUserCodeInPool(CallMethodInBackupThread, args);
}; };
void ProcessThriftBinaryRequest(InputMessageBase* msg_base) { void ProcessThriftFramedRequest(InputMessageBase* msg_base) {
const int64_t start_parse_us = butil::cpuwide_time_us(); const int64_t start_parse_us = butil::cpuwide_time_us();
...@@ -302,8 +302,8 @@ void ProcessThriftBinaryRequest(InputMessageBase* msg_base) { ...@@ -302,8 +302,8 @@ void ProcessThriftBinaryRequest(InputMessageBase* msg_base) {
} }
ThriftFramedClosure* thrift_done = new (space) ThriftFramedClosure(sub_space); ThriftFramedClosure* thrift_done = new (space) ThriftFramedClosure(sub_space);
Controller* cntl = &(thrift_done->_controller); Controller* cntl = &(thrift_done->_controller);
ThriftBinaryMessage* req = &(thrift_done->_request); ThriftFramedMessage* req = &(thrift_done->_request);
ThriftBinaryMessage* res = &(thrift_done->_response); ThriftFramedMessage* res = &(thrift_done->_response);
req->head = *req_head; req->head = *req_head;
msg->payload.swap(req->body); msg->payload.swap(req->body);
...@@ -369,10 +369,10 @@ void ProcessThriftBinaryRequest(InputMessageBase* msg_base) { ...@@ -369,10 +369,10 @@ void ProcessThriftBinaryRequest(InputMessageBase* msg_base) {
span->AsParent(); span->AsParent();
} }
if (!FLAGS_usercode_in_pthread) { if (!FLAGS_usercode_in_pthread) {
return service->ProcessThriftBinaryRequest(*server, cntl, *req, res, thrift_done); return service->ProcessThriftFramedRequest(*server, cntl, *req, res, thrift_done);
} }
if (BeginRunningUserCode()) { if (BeginRunningUserCode()) {
service->ProcessThriftBinaryRequest(*server, cntl, *req, res, thrift_done); service->ProcessThriftFramedRequest(*server, cntl, *req, res, thrift_done);
return EndRunningUserCodeInPlace(); return EndRunningUserCodeInPlace();
} else { } else {
return EndRunningCallMethodInPool( return EndRunningCallMethodInPool(
...@@ -381,11 +381,11 @@ void ProcessThriftBinaryRequest(InputMessageBase* msg_base) { ...@@ -381,11 +381,11 @@ void ProcessThriftBinaryRequest(InputMessageBase* msg_base) {
} }
void ProcessThriftBinaryResponse(InputMessageBase* msg_base) { void ProcessThriftFramedResponse(InputMessageBase* msg_base) {
const int64_t start_parse_us = butil::cpuwide_time_us(); const int64_t start_parse_us = butil::cpuwide_time_us();
DestroyingPtr<MostCommonMessage> msg(static_cast<MostCommonMessage*>(msg_base)); DestroyingPtr<MostCommonMessage> msg(static_cast<MostCommonMessage*>(msg_base));
// Fetch correlation id that we saved before in `PacThriftBinaryRequest' // Fetch correlation id that we saved before in `PacThriftFramedRequest'
const CallId cid = { static_cast<uint64_t>(msg->socket()->correlation_id()) }; const CallId cid = { static_cast<uint64_t>(msg->socket()->correlation_id()) };
Controller* cntl = NULL; Controller* cntl = NULL;
const int rc = bthread_id_lock(cid, (void**)&cntl); const int rc = bthread_id_lock(cid, (void**)&cntl);
...@@ -404,8 +404,8 @@ void ProcessThriftBinaryResponse(InputMessageBase* msg_base) { ...@@ -404,8 +404,8 @@ void ProcessThriftBinaryResponse(InputMessageBase* msg_base) {
span->set_start_parse_us(start_parse_us); span->set_start_parse_us(start_parse_us);
} }
// MUST be ThriftBinaryMessage (checked in SerializeThriftBinaryRequest) // MUST be ThriftFramedMessage (checked in SerializeThriftFramedRequest)
ThriftBinaryMessage* response = (ThriftBinaryMessage*)cntl->response(); ThriftFramedMessage* response = (ThriftFramedMessage*)cntl->response();
const int saved_error = cntl->ErrorCode(); const int saved_error = cntl->ErrorCode();
if (response != NULL) { if (response != NULL) {
msg->meta.copy_to(&response->head, sizeof(thrift_binary_head_t)); msg->meta.copy_to(&response->head, sizeof(thrift_binary_head_t));
...@@ -506,7 +506,7 @@ void ProcessThriftBinaryResponse(InputMessageBase* msg_base) { ...@@ -506,7 +506,7 @@ void ProcessThriftBinaryResponse(InputMessageBase* msg_base) {
accessor.OnResponse(cid, saved_error); accessor.OnResponse(cid, saved_error);
} }
bool VerifyThriftBinaryRequest(const InputMessageBase* msg_base) { bool VerifyThriftFramedRequest(const InputMessageBase* msg_base) {
Server* server = (Server*)msg_base->arg(); Server* server = (Server*)msg_base->arg();
if (server->options().auth) { if (server->options().auth) {
LOG(WARNING) << "thrift does not support authentication"; LOG(WARNING) << "thrift does not support authentication";
...@@ -515,14 +515,14 @@ bool VerifyThriftBinaryRequest(const InputMessageBase* msg_base) { ...@@ -515,14 +515,14 @@ bool VerifyThriftBinaryRequest(const InputMessageBase* msg_base) {
return true; return true;
} }
void SerializeThriftBinaryRequest(butil::IOBuf* request_buf, Controller* cntl, void SerializeThriftFramedRequest(butil::IOBuf* request_buf, Controller* cntl,
const google::protobuf::Message* req_base) { const google::protobuf::Message* req_base) {
if (req_base == NULL) { if (req_base == NULL) {
return cntl->SetFailed(EREQUEST, "request is NULL"); return cntl->SetFailed(EREQUEST, "request is NULL");
} }
ControllerPrivateAccessor accessor(cntl); ControllerPrivateAccessor accessor(cntl);
const ThriftBinaryMessage* req = (const ThriftBinaryMessage*)req_base; const ThriftFramedMessage* req = (const ThriftFramedMessage*)req_base;
thrift_binary_head_t head = req->head; thrift_binary_head_t head = req->head;
...@@ -556,7 +556,7 @@ void SerializeThriftBinaryRequest(butil::IOBuf* request_buf, Controller* cntl, ...@@ -556,7 +556,7 @@ void SerializeThriftBinaryRequest(butil::IOBuf* request_buf, Controller* cntl,
xfer += out_portocol->writeFieldBegin("request", ::apache::thrift::protocol::T_STRUCT, 1); xfer += out_portocol->writeFieldBegin("request", ::apache::thrift::protocol::T_STRUCT, 1);
// request's write // request's write
ThriftBinaryMessage* r = const_cast<ThriftBinaryMessage*>(req); ThriftFramedMessage* r = const_cast<ThriftFramedMessage*>(req);
xfer += r->write(out_portocol.get()); xfer += r->write(out_portocol.get());
// end request's write // end request's write
...@@ -583,7 +583,7 @@ void SerializeThriftBinaryRequest(butil::IOBuf* request_buf, Controller* cntl, ...@@ -583,7 +583,7 @@ void SerializeThriftBinaryRequest(butil::IOBuf* request_buf, Controller* cntl,
} }
void PackThriftBinaryRequest( void PackThriftFramedRequest(
butil::IOBuf* packet_buf, butil::IOBuf* packet_buf,
SocketMessage**, SocketMessage**,
uint64_t correlation_id, uint64_t correlation_id,
......
...@@ -24,18 +24,18 @@ namespace brpc { ...@@ -24,18 +24,18 @@ namespace brpc {
namespace policy { namespace policy {
// Parse binary protocol format of thrift framed // Parse binary protocol format of thrift framed
ParseResult ParseThriftBinaryMessage(butil::IOBuf* source, Socket* socket, bool read_eof, const void *arg); ParseResult ParseThriftFramedMessage(butil::IOBuf* source, Socket* socket, bool read_eof, const void *arg);
// Actions to a (client) request in thrift binary framed format // Actions to a (client) request in thrift binary framed format
void ProcessThriftBinaryRequest(InputMessageBase* msg); void ProcessThriftFramedRequest(InputMessageBase* msg);
// Actions to a (server) response in thrift binary framed format // Actions to a (server) response in thrift binary framed format
void ProcessThriftBinaryResponse(InputMessageBase* msg); void ProcessThriftFramedResponse(InputMessageBase* msg);
void SerializeThriftBinaryRequest(butil::IOBuf* request_buf, Controller* controller, void SerializeThriftFramedRequest(butil::IOBuf* request_buf, Controller* controller,
const google::protobuf::Message* request); const google::protobuf::Message* request);
void PackThriftBinaryRequest( void PackThriftFramedRequest(
butil::IOBuf* packet_buf, butil::IOBuf* packet_buf,
SocketMessage**, SocketMessage**,
uint64_t correlation_id, uint64_t correlation_id,
...@@ -45,7 +45,7 @@ void PackThriftBinaryRequest( ...@@ -45,7 +45,7 @@ void PackThriftBinaryRequest(
const Authenticator*); const Authenticator*);
// Verify authentication information in thrift binary format // Verify authentication information in thrift binary format
bool VerifyThriftBinaryRequest(const InputMessageBase *msg); bool VerifyThriftFramedRequest(const InputMessageBase *msg);
} // namespace policy } // namespace policy
} // namespace brpc } // namespace brpc
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
namespace brpc { namespace brpc {
namespace { namespace {
const ::google::protobuf::Descriptor* ThriftBinaryMessage_descriptor_ = NULL; const ::google::protobuf::Descriptor* ThriftFramedMessage_descriptor_ = NULL;
} // namespace } // namespace
...@@ -41,7 +41,7 @@ void protobuf_AssignDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto() { ...@@ -41,7 +41,7 @@ void protobuf_AssignDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto() {
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
"baidu/rpc/thrift_binary_message.proto"); "baidu/rpc/thrift_binary_message.proto");
GOOGLE_CHECK(file != NULL); GOOGLE_CHECK(file != NULL);
ThriftBinaryMessage_descriptor_ = file->message_type(0); ThriftFramedMessage_descriptor_ = file->message_type(0);
} }
namespace { namespace {
...@@ -55,13 +55,13 @@ inline void protobuf_AssignDescriptorsOnce() { ...@@ -55,13 +55,13 @@ inline void protobuf_AssignDescriptorsOnce() {
void protobuf_RegisterTypes(const ::std::string&) { void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce(); protobuf_AssignDescriptorsOnce();
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
ThriftBinaryMessage_descriptor_, &ThriftBinaryMessage::default_instance()); ThriftFramedMessage_descriptor_, &ThriftFramedMessage::default_instance());
} }
} // namespace } // namespace
void protobuf_ShutdownFile_baidu_2frpc_2fthrift_binary_5fmessage_2eproto() { void protobuf_ShutdownFile_baidu_2frpc_2fthrift_binary_5fmessage_2eproto() {
delete ThriftBinaryMessage::default_instance_; delete ThriftFramedMessage::default_instance_;
} }
void protobuf_AddDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto_impl() { void protobuf_AddDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto_impl() {
...@@ -77,8 +77,8 @@ void protobuf_AddDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto_impl() { ...@@ -77,8 +77,8 @@ void protobuf_AddDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto_impl() {
"hriftBinaryMessage", 58); "hriftBinaryMessage", 58);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"thrift_binary_message.proto", &protobuf_RegisterTypes); "thrift_binary_message.proto", &protobuf_RegisterTypes);
ThriftBinaryMessage::default_instance_ = new ThriftBinaryMessage(); ThriftFramedMessage::default_instance_ = new ThriftFramedMessage();
ThriftBinaryMessage::default_instance_->InitAsDefaultInstance(); ThriftFramedMessage::default_instance_->InitAsDefaultInstance();
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_baidu_2frpc_2fthrift_binary_5fmessage_2eproto); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_baidu_2frpc_2fthrift_binary_5fmessage_2eproto);
} }
...@@ -103,59 +103,59 @@ struct StaticDescriptorInitializer_baidu_2frpc_2fthrift_binary_5fmessage_2eproto ...@@ -103,59 +103,59 @@ struct StaticDescriptorInitializer_baidu_2frpc_2fthrift_binary_5fmessage_2eproto
#ifndef _MSC_VER #ifndef _MSC_VER
#endif // !_MSC_VER #endif // !_MSC_VER
ThriftBinaryMessage::ThriftBinaryMessage() ThriftFramedMessage::ThriftFramedMessage()
: ::google::protobuf::Message() { : ::google::protobuf::Message() {
SharedCtor(); SharedCtor();
} }
void ThriftBinaryMessage::InitAsDefaultInstance() { void ThriftFramedMessage::InitAsDefaultInstance() {
} }
ThriftBinaryMessage::ThriftBinaryMessage(const ThriftBinaryMessage& from) ThriftFramedMessage::ThriftFramedMessage(const ThriftFramedMessage& from)
: ::google::protobuf::Message() { : ::google::protobuf::Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
void ThriftBinaryMessage::SharedCtor() { void ThriftFramedMessage::SharedCtor() {
memset(&head, 0, sizeof(head)); memset(&head, 0, sizeof(head));
} }
ThriftBinaryMessage::~ThriftBinaryMessage() { ThriftFramedMessage::~ThriftFramedMessage() {
SharedDtor(); SharedDtor();
if (thrift_raw_instance && thrift_raw_instance_deleter) { if (thrift_raw_instance && thrift_raw_instance_deleter) {
thrift_raw_instance_deleter(thrift_raw_instance); thrift_raw_instance_deleter(thrift_raw_instance);
} }
} }
void ThriftBinaryMessage::SharedDtor() { void ThriftFramedMessage::SharedDtor() {
if (this != default_instance_) { if (this != default_instance_) {
} }
} }
const ::google::protobuf::Descriptor* ThriftBinaryMessage::descriptor() { const ::google::protobuf::Descriptor* ThriftFramedMessage::descriptor() {
protobuf_AssignDescriptorsOnce(); protobuf_AssignDescriptorsOnce();
return ThriftBinaryMessage_descriptor_; return ThriftFramedMessage_descriptor_;
} }
const ThriftBinaryMessage& ThriftBinaryMessage::default_instance() { const ThriftFramedMessage& ThriftFramedMessage::default_instance() {
if (default_instance_ == NULL) if (default_instance_ == NULL)
protobuf_AddDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto(); protobuf_AddDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto();
return *default_instance_; return *default_instance_;
} }
ThriftBinaryMessage* ThriftBinaryMessage::default_instance_ = NULL; ThriftFramedMessage* ThriftFramedMessage::default_instance_ = NULL;
ThriftBinaryMessage* ThriftBinaryMessage::New() const { ThriftFramedMessage* ThriftFramedMessage::New() const {
return new ThriftBinaryMessage; return new ThriftFramedMessage;
} }
void ThriftBinaryMessage::Clear() { void ThriftFramedMessage::Clear() {
memset(&head, 0, sizeof(head)); memset(&head, 0, sizeof(head));
body.clear(); body.clear();
} }
bool ThriftBinaryMessage::MergePartialFromCodedStream( bool ThriftFramedMessage::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) { ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false #define DO_(EXPRESSION) if (!(EXPRESSION)) return false
::google::protobuf::uint32 tag; ::google::protobuf::uint32 tag;
...@@ -169,55 +169,55 @@ bool ThriftBinaryMessage::MergePartialFromCodedStream( ...@@ -169,55 +169,55 @@ bool ThriftBinaryMessage::MergePartialFromCodedStream(
#undef DO_ #undef DO_
} }
void ThriftBinaryMessage::SerializeWithCachedSizes( void ThriftFramedMessage::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream*) const { ::google::protobuf::io::CodedOutputStream*) const {
} }
::google::protobuf::uint8* ThriftBinaryMessage::SerializeWithCachedSizesToArray( ::google::protobuf::uint8* ThriftFramedMessage::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const { ::google::protobuf::uint8* target) const {
return target; return target;
} }
int ThriftBinaryMessage::ByteSize() const { int ThriftFramedMessage::ByteSize() const {
return sizeof(thrift_binary_head_t) + body.size(); return sizeof(thrift_binary_head_t) + body.size();
} }
void ThriftBinaryMessage::MergeFrom(const ::google::protobuf::Message& from) { void ThriftFramedMessage::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this); GOOGLE_CHECK_NE(&from, this);
const ThriftBinaryMessage* source = const ThriftFramedMessage* source =
::google::protobuf::internal::dynamic_cast_if_available<const ThriftBinaryMessage*>( ::google::protobuf::internal::dynamic_cast_if_available<const ThriftFramedMessage*>(
&from); &from);
if (source == NULL) { if (source == NULL) {
LOG(ERROR) << "Can only merge from ThriftBinaryMessage"; LOG(ERROR) << "Can only merge from ThriftFramedMessage";
return; return;
} else { } else {
MergeFrom(*source); MergeFrom(*source);
} }
} }
void ThriftBinaryMessage::MergeFrom(const ThriftBinaryMessage& from) { void ThriftFramedMessage::MergeFrom(const ThriftFramedMessage& from) {
GOOGLE_CHECK_NE(&from, this); GOOGLE_CHECK_NE(&from, this);
head = from.head; head = from.head;
body = from.body; body = from.body;
} }
void ThriftBinaryMessage::CopyFrom(const ::google::protobuf::Message& from) { void ThriftFramedMessage::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return; if (&from == this) return;
Clear(); Clear();
MergeFrom(from); MergeFrom(from);
} }
void ThriftBinaryMessage::CopyFrom(const ThriftBinaryMessage& from) { void ThriftFramedMessage::CopyFrom(const ThriftFramedMessage& from) {
if (&from == this) return; if (&from == this) return;
Clear(); Clear();
MergeFrom(from); MergeFrom(from);
} }
bool ThriftBinaryMessage::IsInitialized() const { bool ThriftFramedMessage::IsInitialized() const {
return true; return true;
} }
void ThriftBinaryMessage::Swap(ThriftBinaryMessage* other) { void ThriftFramedMessage::Swap(ThriftFramedMessage* other) {
if (other != this) { if (other != this) {
const thrift_binary_head_t tmp = other->head; const thrift_binary_head_t tmp = other->head;
other->head = head; other->head = head;
...@@ -226,10 +226,10 @@ void ThriftBinaryMessage::Swap(ThriftBinaryMessage* other) { ...@@ -226,10 +226,10 @@ void ThriftBinaryMessage::Swap(ThriftBinaryMessage* other) {
} }
} }
::google::protobuf::Metadata ThriftBinaryMessage::GetMetadata() const { ::google::protobuf::Metadata ThriftFramedMessage::GetMetadata() const {
protobuf_AssignDescriptorsOnce(); protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata; ::google::protobuf::Metadata metadata;
metadata.descriptor = ThriftBinaryMessage_descriptor_; metadata.descriptor = ThriftFramedMessage_descriptor_;
metadata.reflection = NULL; metadata.reflection = NULL;
return metadata; return metadata;
} }
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <functional> #include <functional>
#include <string> #include <string>
#include <boost/make_shared.hpp>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/generated_message_util.h> #include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h> #include <google/protobuf/repeated_field.h>
...@@ -53,7 +55,7 @@ void protobuf_AssignDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto(); ...@@ -53,7 +55,7 @@ void protobuf_AssignDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto();
void protobuf_ShutdownFile_baidu_2frpc_2fthrift_binary_5fmessage_2eproto(); void protobuf_ShutdownFile_baidu_2frpc_2fthrift_binary_5fmessage_2eproto();
// Representing a thrift_binary request or response. // Representing a thrift_binary request or response.
class ThriftBinaryMessage : public ::google::protobuf::Message { class ThriftFramedMessage : public ::google::protobuf::Message {
public: public:
thrift_binary_head_t head; thrift_binary_head_t head;
butil::IOBuf body; butil::IOBuf body;
...@@ -62,28 +64,28 @@ public: ...@@ -62,28 +64,28 @@ public:
void* thrift_raw_instance; void* thrift_raw_instance;
public: public:
ThriftBinaryMessage(); ThriftFramedMessage();
virtual ~ThriftBinaryMessage(); virtual ~ThriftFramedMessage();
ThriftBinaryMessage(const ThriftBinaryMessage& from); ThriftFramedMessage(const ThriftFramedMessage& from);
inline ThriftBinaryMessage& operator=(const ThriftBinaryMessage& from) { inline ThriftFramedMessage& operator=(const ThriftFramedMessage& from) {
CopyFrom(from); CopyFrom(from);
return *this; return *this;
} }
static const ::google::protobuf::Descriptor* descriptor(); static const ::google::protobuf::Descriptor* descriptor();
static const ThriftBinaryMessage& default_instance(); static const ThriftFramedMessage& default_instance();
void Swap(ThriftBinaryMessage* other); void Swap(ThriftFramedMessage* other);
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
ThriftBinaryMessage* New() const; ThriftFramedMessage* New() const;
void CopyFrom(const ::google::protobuf::Message& from); void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const ThriftBinaryMessage& from); void CopyFrom(const ThriftFramedMessage& from);
void MergeFrom(const ThriftBinaryMessage& from); void MergeFrom(const ThriftFramedMessage& from);
void Clear(); void Clear();
bool IsInitialized() const; bool IsInitialized() const;
...@@ -188,11 +190,11 @@ friend void protobuf_AssignDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto(); ...@@ -188,11 +190,11 @@ friend void protobuf_AssignDesc_baidu_2frpc_2fthrift_binary_5fmessage_2eproto();
friend void protobuf_ShutdownFile_baidu_2frpc_2fthrift_binary_5fmessage_2eproto(); friend void protobuf_ShutdownFile_baidu_2frpc_2fthrift_binary_5fmessage_2eproto();
void InitAsDefaultInstance(); void InitAsDefaultInstance();
static ThriftBinaryMessage* default_instance_; static ThriftFramedMessage* default_instance_;
}; };
template <typename T> template <typename T>
class ThriftMessage : public ThriftBinaryMessage { class ThriftMessage : public ThriftFramedMessage {
public: public:
ThriftMessage() { ThriftMessage() {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#define BRPC_THRIFT_SERVICE_H #define BRPC_THRIFT_SERVICE_H
#include "brpc/controller.h" // Controller #include "brpc/controller.h" // Controller
#include "brpc/thrift_binary_message.h" // ThriftBinaryMessage #include "brpc/thrift_binary_message.h" // ThriftFramedMessage
#include "brpc/describable.h" #include "brpc/describable.h"
...@@ -29,7 +29,7 @@ class Server; ...@@ -29,7 +29,7 @@ class Server;
class MethodStatus; class MethodStatus;
class StatusService; class StatusService;
namespace policy { namespace policy {
void ProcessThriftBinaryRequest(InputMessageBase* msg_base); void ProcessThriftFramedRequest(InputMessageBase* msg_base);
} }
// The continuation of request processing. Namely send response back to client. // The continuation of request processing. Namely send response back to client.
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
void DoNotRespond(); void DoNotRespond();
private: private:
friend void policy::ProcessThriftBinaryRequest(InputMessageBase* msg_base); friend void policy::ProcessThriftFramedRequest(InputMessageBase* msg_base);
friend class DeleteThriftFramedClosure; friend class DeleteThriftFramedClosure;
// Only callable by Run(). // Only callable by Run().
~ThriftFramedClosure(); ~ThriftFramedClosure();
...@@ -64,8 +64,8 @@ friend class DeleteThriftFramedClosure; ...@@ -64,8 +64,8 @@ friend class DeleteThriftFramedClosure;
Socket* _socket_ptr; Socket* _socket_ptr;
const Server* _server; const Server* _server;
int64_t _start_parse_us; int64_t _start_parse_us;
ThriftBinaryMessage _request; ThriftFramedMessage _request;
ThriftBinaryMessage _response; ThriftFramedMessage _response;
bool _do_respond; bool _do_respond;
void* _additional_space; void* _additional_space;
Controller _controller; Controller _controller;
...@@ -98,10 +98,10 @@ public: ...@@ -98,10 +98,10 @@ public:
// request The thrift_binary request received. // request The thrift_binary request received.
// response The thrift_binary response that you should fill in. // response The thrift_binary response that you should fill in.
// done You must call done->Run() to end the processing. // done You must call done->Run() to end the processing.
virtual void ProcessThriftBinaryRequest(const Server& server, virtual void ProcessThriftFramedRequest(const Server& server,
Controller* controller, Controller* controller,
const ThriftBinaryMessage& request, const ThriftFramedMessage& request,
ThriftBinaryMessage* response, ThriftFramedMessage* response,
ThriftFramedClosure* done) = 0; ThriftFramedClosure* done) = 0;
// Put descriptions into the stream. // Put descriptions into the stream.
...@@ -110,14 +110,14 @@ public: ...@@ -110,14 +110,14 @@ public:
private: private:
DISALLOW_COPY_AND_ASSIGN(ThriftFramedService); DISALLOW_COPY_AND_ASSIGN(ThriftFramedService);
friend class ThriftFramedClosure; friend class ThriftFramedClosure;
friend void policy::ProcessThriftBinaryRequest(InputMessageBase* msg_base); friend void policy::ProcessThriftFramedRequest(InputMessageBase* msg_base);
friend class StatusService; friend class StatusService;
friend class Server; friend class Server;
private: private:
void Expose(const butil::StringPiece& prefix); void Expose(const butil::StringPiece& prefix);
// Tracking status of non ThriftBinaryPbService // Tracking status of non ThriftFramedPbService
MethodStatus* _status; MethodStatus* _status;
size_t _additional_space; size_t _additional_space;
std::string _cached_name; std::string _cached_name;
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
namespace brpc { namespace brpc {
bool brpc_thrift_server_helper(const brpc::ThriftBinaryMessage& request, bool brpc_thrift_server_helper(const brpc::ThriftFramedMessage& request,
brpc::ThriftBinaryMessage* response, brpc::ThriftFramedMessage* response,
boost::shared_ptr<::apache::thrift::TDispatchProcessor> processor) { boost::shared_ptr<::apache::thrift::TDispatchProcessor> processor) {
auto in_buffer = auto in_buffer =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment