Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
40b13429
Unverified
Commit
40b13429
authored
Jun 24, 2019
by
Ge Jun
Committed by
GitHub
Jun 24, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #819 from zyearn/adapt_protobuf_3_7
Adapt to protobuf 3.7 & 3.8
parents
ca6bd6bc
034c9a3b
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
162 additions
and
912 deletions
+162
-912
CMakeLists.txt
CMakeLists.txt
+2
-1
getting_started.md
docs/cn/getting_started.md
+1
-1
callback.h
src/brpc/callback.h
+5
-0
controller.cpp
src/brpc/controller.cpp
+6
-6
controller.h
src/brpc/controller.h
+5
-5
esp_message.cpp
src/brpc/esp_message.cpp
+5
-108
esp_message.h
src/brpc/esp_message.h
+8
-20
memcache.cpp
src/brpc/memcache.cpp
+8
-147
memcache.h
src/brpc/memcache.h
+12
-32
nshead_message.cpp
src/brpc/nshead_message.cpp
+6
-105
nshead_message.h
src/brpc/nshead_message.h
+5
-25
baidu_rpc_protocol.cpp
src/brpc/policy/baidu_rpc_protocol.cpp
+10
-10
hulu_pbrpc_protocol.cpp
src/brpc/policy/hulu_pbrpc_protocol.cpp
+11
-11
sofa_pbrpc_protocol.cpp
src/brpc/policy/sofa_pbrpc_protocol.cpp
+6
-6
progressive_attachment.h
src/brpc/progressive_attachment.h
+1
-1
proto_base.proto
src/brpc/proto_base.proto
+17
-0
redis.cpp
src/brpc/redis.cpp
+20
-158
redis.h
src/brpc/redis.h
+10
-32
rpc_dump.cpp
src/brpc/rpc_dump.cpp
+2
-3
rpc_dump.h
src/brpc/rpc_dump.h
+2
-3
serialized_request.cpp
src/brpc/serialized_request.cpp
+3
-96
serialized_request.h
src/brpc/serialized_request.h
+5
-21
thrift_message.cpp
src/brpc/thrift_message.cpp
+2
-91
thrift_message.h
src/brpc/thrift_message.h
+4
-24
Makefile
test/Makefile
+1
-1
rpc_replay.cpp
tools/rpc_replay/rpc_replay.cpp
+5
-5
No files found.
CMakeLists.txt
View file @
40b13429
...
@@ -371,7 +371,8 @@ set(PROTO_FILES idl_options.proto
...
@@ -371,7 +371,8 @@ set(PROTO_FILES idl_options.proto
brpc/policy/sofa_pbrpc_meta.proto
brpc/policy/sofa_pbrpc_meta.proto
brpc/policy/mongo.proto
brpc/policy/mongo.proto
brpc/trackme.proto
brpc/trackme.proto
brpc/streaming_rpc_meta.proto
)
brpc/streaming_rpc_meta.proto
brpc/proto_base.proto
)
file
(
MAKE_DIRECTORY
${
PROJECT_BINARY_DIR
}
/output/include/brpc
)
file
(
MAKE_DIRECTORY
${
PROJECT_BINARY_DIR
}
/output/include/brpc
)
set
(
PROTOC_FLAGS
${
PROTOC_FLAGS
}
-I
${
PROTOBUF_INCLUDE_DIR
}
)
set
(
PROTOC_FLAGS
${
PROTOC_FLAGS
}
-I
${
PROTOBUF_INCLUDE_DIR
}
)
compile_proto
(
PROTO_HDRS PROTO_SRCS
${
PROJECT_BINARY_DIR
}
compile_proto
(
PROTO_HDRS PROTO_SRCS
${
PROJECT_BINARY_DIR
}
...
...
docs/cn/getting_started.md
View file @
40b13429
...
@@ -350,7 +350,7 @@ no known issues.
...
@@ -350,7 +350,7 @@ no known issues.
no known issues.
no known issues.
## protobuf: 2.4
-3.4
## protobuf: 2.4
+
Be compatible with pb 3.x and pb 2.x with the same file:
Be compatible with pb 3.x and pb 2.x with the same file:
Don't use new types in proto3 and start the proto file with
`syntax="proto2";`
Don't use new types in proto3 and start the proto file with
`syntax="proto2";`
...
...
src/brpc/callback.h
View file @
40b13429
...
@@ -10,6 +10,11 @@
...
@@ -10,6 +10,11 @@
#define BRPC_CALLBACK_H
#define BRPC_CALLBACK_H
#include <google/protobuf/stubs/common.h> // Closure
#include <google/protobuf/stubs/common.h> // Closure
#if GOOGLE_PROTOBUF_VERSION >= 3007000
// After protobuf 3.7.0, callback.h is removed from common.h, we need to explicitly
// include this file.
#include <google/protobuf/stubs/callback.h>
#endif
namespace
brpc
{
namespace
brpc
{
...
...
src/brpc/controller.cpp
View file @
40b13429
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
#include "brpc/retry_policy.h"
#include "brpc/retry_policy.h"
#include "brpc/stream_impl.h"
#include "brpc/stream_impl.h"
#include "brpc/policy/streaming_rpc_protocol.h" // FIXME
#include "brpc/policy/streaming_rpc_protocol.h" // FIXME
#include "brpc/rpc_dump.
pb.
h"
#include "brpc/rpc_dump.h"
#include "brpc/details/usercode_backup_pool.h" // RunUserCode
#include "brpc/details/usercode_backup_pool.h" // RunUserCode
#include "brpc/mongo_service_adaptor.h"
#include "brpc/mongo_service_adaptor.h"
...
@@ -162,7 +162,7 @@ void Controller::ResetNonPods() {
...
@@ -162,7 +162,7 @@ void Controller::ResetNonPods() {
_server
->
_session_local_data_pool
->
Return
(
_session_local_data
);
_server
->
_session_local_data_pool
->
Return
(
_session_local_data
);
}
}
_mongo_session_data
.
reset
();
_mongo_session_data
.
reset
();
delete
_
rpc_dump_meta
;
delete
_
sampled_request
;
if
(
!
is_used_by_rpc
()
&&
_correlation_id
!=
INVALID_BTHREAD_ID
)
{
if
(
!
is_used_by_rpc
()
&&
_correlation_id
!=
INVALID_BTHREAD_ID
)
{
CHECK_NE
(
EPERM
,
bthread_id_cancel
(
_correlation_id
));
CHECK_NE
(
EPERM
,
bthread_id_cancel
(
_correlation_id
));
...
@@ -216,7 +216,7 @@ void Controller::ResetPods() {
...
@@ -216,7 +216,7 @@ void Controller::ResetPods() {
_server
=
NULL
;
_server
=
NULL
;
_oncancel_id
=
INVALID_BTHREAD_ID
;
_oncancel_id
=
INVALID_BTHREAD_ID
;
_auth_context
=
NULL
;
_auth_context
=
NULL
;
_
rpc_dump_meta
=
NULL
;
_
sampled_request
=
NULL
;
_request_protocol
=
PROTOCOL_UNKNOWN
;
_request_protocol
=
PROTOCOL_UNKNOWN
;
_max_retry
=
UNSET_MAGIC_NUM
;
_max_retry
=
UNSET_MAGIC_NUM
;
_retry_policy
=
NULL
;
_retry_policy
=
NULL
;
...
@@ -1334,9 +1334,9 @@ void WebEscape(const std::string& source, std::string* output) {
...
@@ -1334,9 +1334,9 @@ void WebEscape(const std::string& source, std::string* output) {
}
}
}
}
void
Controller
::
reset_
rpc_dump_meta
(
RpcDumpMeta
*
meta
)
{
void
Controller
::
reset_
sampled_request
(
SampledRequest
*
req
)
{
delete
_
rpc_dump_meta
;
delete
_
sampled_request
;
_
rpc_dump_meta
=
meta
;
_
sampled_request
=
req
;
}
}
void
Controller
::
set_stream_creator
(
StreamCreator
*
sc
)
{
void
Controller
::
set_stream_creator
(
StreamCreator
*
sc
)
{
...
...
src/brpc/controller.h
View file @
40b13429
...
@@ -66,7 +66,7 @@ class SharedLoadBalancer;
...
@@ -66,7 +66,7 @@ class SharedLoadBalancer;
class
ExcludedServers
;
class
ExcludedServers
;
class
RPCSender
;
class
RPCSender
;
class
StreamSettings
;
class
StreamSettings
;
class
RpcDumpMeta
;
class
SampledRequest
;
class
MongoContext
;
class
MongoContext
;
class
RetryPolicy
;
class
RetryPolicy
;
class
InputMessageBase
;
class
InputMessageBase
;
...
@@ -261,10 +261,10 @@ public:
...
@@ -261,10 +261,10 @@ public:
int
sub_count
()
const
;
int
sub_count
()
const
;
const
Controller
*
sub
(
int
index
)
const
;
const
Controller
*
sub
(
int
index
)
const
;
// Get/own
RpcDumpMeta
for sending dumped requests.
// Get/own
SampledRequest
for sending dumped requests.
// Deleted along with controller.
// Deleted along with controller.
void
reset_
rpc_dump_meta
(
RpcDumpMeta
*
meta
);
void
reset_
sampled_request
(
SampledRequest
*
req
);
const
RpcDumpMeta
*
rpc_dump_meta
()
{
return
_rpc_dump_meta
;
}
const
SampledRequest
*
sampled_request
()
{
return
_sampled_request
;
}
// Attach a StreamCreator to this RPC. Notice that the ownership of sc has
// Attach a StreamCreator to this RPC. Notice that the ownership of sc has
// been transferred to cntl, and sc->DestroyStreamCreator() would be called
// been transferred to cntl, and sc->DestroyStreamCreator() would be called
...
@@ -675,7 +675,7 @@ private:
...
@@ -675,7 +675,7 @@ private:
bthread_id_t
_oncancel_id
;
bthread_id_t
_oncancel_id
;
const
AuthContext
*
_auth_context
;
// Authentication result
const
AuthContext
*
_auth_context
;
// Authentication result
butil
::
intrusive_ptr
<
MongoContext
>
_mongo_session_data
;
butil
::
intrusive_ptr
<
MongoContext
>
_mongo_session_data
;
RpcDumpMeta
*
_rpc_dump_meta
;
SampledRequest
*
_sampled_request
;
ProtocolType
_request_protocol
;
ProtocolType
_request_protocol
;
// Some of them are copied from `Channel' which might be destroyed
// Some of them are copied from `Channel' which might be destroyed
...
...
src/brpc/esp_message.cpp
View file @
40b13429
...
@@ -15,99 +15,18 @@
...
@@ -15,99 +15,18 @@
// specific language governing permissions and limitations
// specific language governing permissions and limitations
// under the License.
// under the License.
// Generated by the protocol buffer compiler. DO NOT EDIT!
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "esp_message.h"
#include "esp_message.h"
#include <algorithm>
#include <google/protobuf/reflection_ops.h> // ReflectionOps::Merge
#include <google/protobuf/wire_format.h> // WireFormatLite::GetTagWireType
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
namespace
brpc
{
namespace
brpc
{
namespace
{
const
::
google
::
protobuf
::
Descriptor
*
EspMessage_descriptor_
=
NULL
;
}
// namespace
void
protobuf_AssignDesc_esp_5fmessage_2eproto
()
{
protobuf_AddDesc_esp_5fmessage_2eproto
();
const
::
google
::
protobuf
::
FileDescriptor
*
file
=
::
google
::
protobuf
::
DescriptorPool
::
generated_pool
()
->
FindFileByName
(
"esp_message.proto"
);
GOOGLE_CHECK
(
file
!=
NULL
);
EspMessage_descriptor_
=
file
->
message_type
(
0
);
}
namespace
{
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AssignDescriptors_once_
);
inline
void
protobuf_AssignDescriptorsOnce
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AssignDescriptors_once_
,
&
protobuf_AssignDesc_esp_5fmessage_2eproto
);
}
void
protobuf_RegisterTypes
(
const
::
std
::
string
&
)
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedMessage
(
EspMessage_descriptor_
,
&
EspMessage
::
default_instance
());
}
}
// namespace
void
protobuf_ShutdownFile_esp_5fmessage_2eproto
()
{
delete
EspMessage
::
default_instance_
;
}
void
protobuf_AddDesc_esp_5fmessage_2eproto
()
{
static
bool
already_here
=
false
;
if
(
already_here
)
{
return
;
}
already_here
=
true
;
GOOGLE_PROTOBUF_VERIFY_VERSION
;
::
google
::
protobuf
::
DescriptorPool
::
InternalAddGeneratedFile
(
"
\n\021
esp_message.proto
\022\t
baidu.rpc
\"\014\n\n
EspMessage"
,
44
);
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedFile
(
"esp_message.proto"
,
&
protobuf_RegisterTypes
);
EspMessage
::
default_instance_
=
new
EspMessage
();
EspMessage
::
default_instance_
->
InitAsDefaultInstance
();
::
google
::
protobuf
::
internal
::
OnShutdown
(
&
protobuf_ShutdownFile_esp_5fmessage_2eproto
);
}
// Force AddDescriptors() to be called at static initialization time.
struct
StaticDescriptorInitializer_esp_5fmessage_2eproto
{
StaticDescriptorInitializer_esp_5fmessage_2eproto
()
{
protobuf_AddDesc_esp_5fmessage_2eproto
();
}
}
static_descriptor_initializer_esp_5fmessage_2eproto_
;
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
EspMessage
::
EspMessage
()
EspMessage
::
EspMessage
()
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
}
}
void
EspMessage
::
InitAsDefaultInstance
()
{
}
EspMessage
::
EspMessage
(
const
EspMessage
&
from
)
EspMessage
::
EspMessage
(
const
EspMessage
&
from
)
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
...
@@ -123,25 +42,12 @@ EspMessage::~EspMessage() {
...
@@ -123,25 +42,12 @@ EspMessage::~EspMessage() {
}
}
void
EspMessage
::
SharedDtor
()
{
void
EspMessage
::
SharedDtor
()
{
if
(
this
!=
default_instance_
)
{
}
}
}
const
::
google
::
protobuf
::
Descriptor
*
EspMessage
::
descriptor
()
{
const
::
google
::
protobuf
::
Descriptor
*
EspMessage
::
descriptor
()
{
protobuf_AssignDescriptorsOnce
();
return
EspMessageBase
::
descriptor
();
return
EspMessage_descriptor_
;
}
const
EspMessage
&
EspMessage
::
default_instance
()
{
if
(
default_instance_
==
NULL
)
{
protobuf_AddDesc_esp_5fmessage_2eproto
();
}
return
*
default_instance_
;
}
}
EspMessage
*
EspMessage
::
default_instance_
=
NULL
;
EspMessage
*
EspMessage
::
New
()
const
{
EspMessage
*
EspMessage
::
New
()
const
{
return
new
EspMessage
;
return
new
EspMessage
;
}
}
...
@@ -181,10 +87,7 @@ int EspMessage::ByteSize() const {
...
@@ -181,10 +87,7 @@ int EspMessage::ByteSize() const {
void
EspMessage
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
void
EspMessage
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
GOOGLE_CHECK_NE
(
&
from
,
this
);
GOOGLE_CHECK_NE
(
&
from
,
this
);
const
EspMessage
*
source
=
const
EspMessage
*
source
=
dynamic_cast
<
const
EspMessage
*>
(
&
from
);
::
google
::
protobuf
::
internal
::
dynamic_cast_if_available
<
const
EspMessage
*>
(
&
from
);
if
(
source
==
NULL
)
{
if
(
source
==
NULL
)
{
::
google
::
protobuf
::
internal
::
ReflectionOps
::
Merge
(
from
,
this
);
::
google
::
protobuf
::
internal
::
ReflectionOps
::
Merge
(
from
,
this
);
}
else
{
}
else
{
...
@@ -230,16 +133,10 @@ void EspMessage::Swap(EspMessage* other) {
...
@@ -230,16 +133,10 @@ void EspMessage::Swap(EspMessage* other) {
}
}
::
google
::
protobuf
::
Metadata
EspMessage
::
GetMetadata
()
const
{
::
google
::
protobuf
::
Metadata
EspMessage
::
GetMetadata
()
const
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
Metadata
metadata
;
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
EspMessage
_descriptor_
;
metadata
.
descriptor
=
EspMessage
::
descriptor
()
;
metadata
.
reflection
=
NULL
;
metadata
.
reflection
=
NULL
;
return
metadata
;
return
metadata
;
}
}
// @@protoc_insertion_point(namespace_scope)
}
// namespace brpc
}
// namespace brpc
// @@protoc_insertion_point(global_scope)
src/brpc/esp_message.h
View file @
40b13429
...
@@ -20,23 +20,16 @@
...
@@ -20,23 +20,16 @@
#include <string>
#include <string>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/message.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/generated_message_reflection.h> // dynamic_cast_if_available
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/reflection_ops.h> // ReflectionOps::Merge
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_reflection.h>
#include "brpc/esp_head.h"
#include "brpc/esp_head.h"
#include "butil/iobuf.h"
#include "butil/iobuf.h"
#include "brpc/proto_base.pb.h"
namespace
brpc
{
namespace
brpc
{
// Internal implementation detail -- do not call these.
void
protobuf_AddDesc_esp_5fmessage_2eproto
();
void
protobuf_AssignDesc_esp_5fmessage_2eproto
();
void
protobuf_ShutdownFile_esp_5fmessage_2eproto
();
class
EspMessage
:
public
::
google
::
protobuf
::
Message
{
class
EspMessage
:
public
::
google
::
protobuf
::
Message
{
public
:
public
:
EspHead
head
;
EspHead
head
;
...
@@ -76,20 +69,15 @@ public:
...
@@ -76,20 +69,15 @@ public:
::
google
::
protobuf
::
uint8
*
SerializeWithCachedSizesToArray
(
::
google
::
protobuf
::
uint8
*
SerializeWithCachedSizesToArray
(
::
google
::
protobuf
::
uint8
*
output
)
const
;
::
google
::
protobuf
::
uint8
*
output
)
const
;
int
GetCachedSize
()
const
{
return
ByteSize
();
}
int
GetCachedSize
()
const
{
return
ByteSize
();
}
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
protected
:
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
override
;
private
:
private
:
void
SharedCtor
();
void
SharedCtor
();
void
SharedDtor
();
void
SharedDtor
();
friend
void
protobuf_AddDesc_esp_5fmessage_2eproto
();
friend
void
protobuf_AssignDesc_esp_5fmessage_2eproto
();
friend
void
protobuf_ShutdownFile_esp_5fmessage_2eproto
();
void
InitAsDefaultInstance
();
static
EspMessage
*
default_instance_
;
};
};
}
// namespace brpc
}
// namespace brpc
#endif // BRPC_ESP_MESSAGE_H
#endif // PROTOBUF_esp_5fmessage_2eproto__INCLUDED
src/brpc/memcache.cpp
View file @
40b13429
...
@@ -17,119 +17,23 @@
...
@@ -17,119 +17,23 @@
// Authors: Ge,Jun (gejun@baidu.com)
// Authors: Ge,Jun (gejun@baidu.com)
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include <algorithm>
#include <algorithm>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/wire_format.h>
#include "butil/string_printf.h"
#include "butil/string_printf.h"
#include "butil/macros.h"
#include "butil/macros.h"
#include "butil/sys_byteorder.h"
#include "butil/sys_byteorder.h"
#include "b
rpc/controller
.h"
#include "b
util/logging
.h"
#include "brpc/memcache.h"
#include "brpc/memcache.h"
#include "brpc/policy/memcache_binary_header.h"
#include "brpc/policy/memcache_binary_header.h"
namespace
brpc
{
namespace
brpc
{
// Internal implementation detail -- do not call these.
void
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_impl
();
void
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
();
void
protobuf_AssignDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
();
void
protobuf_ShutdownFile_baidu_2frpc_2fmemcache_5fbase_2eproto
();
namespace
{
const
::
google
::
protobuf
::
Descriptor
*
MemcacheRequest_descriptor_
=
NULL
;
const
::
google
::
protobuf
::
Descriptor
*
MemcacheResponse_descriptor_
=
NULL
;
}
// namespace
void
protobuf_AssignDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
();
const
::
google
::
protobuf
::
FileDescriptor
*
file
=
::
google
::
protobuf
::
DescriptorPool
::
generated_pool
()
->
FindFileByName
(
"baidu/rpc/memcache_base.proto"
);
GOOGLE_CHECK
(
file
!=
NULL
);
MemcacheRequest_descriptor_
=
file
->
message_type
(
0
);
MemcacheResponse_descriptor_
=
file
->
message_type
(
1
);
}
namespace
{
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AssignDescriptors_once_
);
inline
void
protobuf_AssignDescriptorsOnce
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AssignDescriptors_once_
,
&
protobuf_AssignDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
);
}
void
protobuf_RegisterTypes
(
const
::
std
::
string
&
)
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedMessage
(
MemcacheRequest_descriptor_
,
&
MemcacheRequest
::
default_instance
());
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedMessage
(
MemcacheResponse_descriptor_
,
&
MemcacheResponse
::
default_instance
());
}
}
// namespace
void
protobuf_ShutdownFile_baidu_2frpc_2fmemcache_5fbase_2eproto
()
{
delete
MemcacheRequest
::
default_instance_
;
delete
MemcacheResponse
::
default_instance_
;
}
void
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_impl
()
{
GOOGLE_PROTOBUF_VERIFY_VERSION
;
#if GOOGLE_PROTOBUF_VERSION >= 3002000
::
google
::
protobuf
::
internal
::
InitProtobufDefaults
();
#else
::
google
::
protobuf
::
protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto
();
#endif
::
google
::
protobuf
::
DescriptorPool
::
InternalAddGeneratedFile
(
"
\n\035
baidu/rpc/memcache_base.proto
\022\t
baidu.r"
"pc
\032
google/protobuf/descriptor.proto
\"\021\n\017
"
"MemcacheRequest
\"\022\n\020
MemcacheResponseB
\003\200\001\001
"
,
120
);
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedFile
(
"baidu/rpc/memcache_base.proto"
,
&
protobuf_RegisterTypes
);
MemcacheRequest
::
default_instance_
=
new
MemcacheRequest
();
MemcacheResponse
::
default_instance_
=
new
MemcacheResponse
();
MemcacheRequest
::
default_instance_
->
InitAsDefaultInstance
();
MemcacheResponse
::
default_instance_
->
InitAsDefaultInstance
();
::
google
::
protobuf
::
internal
::
OnShutdown
(
&
protobuf_ShutdownFile_baidu_2frpc_2fmemcache_5fbase_2eproto
);
}
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_once
);
void
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_once
,
&
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_impl
);
}
// Force AddDescriptors() to be called at static initialization time.
struct
StaticDescriptorInitializer_baidu_2frpc_2fmemcache_5fbase_2eproto
{
StaticDescriptorInitializer_baidu_2frpc_2fmemcache_5fbase_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
();
}
}
static_descriptor_initializer_baidu_2frpc_2fmemcache_5fbase_2eproto_
;
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
MemcacheRequest
::
MemcacheRequest
()
MemcacheRequest
::
MemcacheRequest
()
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
}
}
void
MemcacheRequest
::
InitAsDefaultInstance
()
{
}
MemcacheRequest
::
MemcacheRequest
(
const
MemcacheRequest
&
from
)
MemcacheRequest
::
MemcacheRequest
(
const
MemcacheRequest
&
from
)
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
...
@@ -146,29 +50,16 @@ MemcacheRequest::~MemcacheRequest() {
...
@@ -146,29 +50,16 @@ MemcacheRequest::~MemcacheRequest() {
}
}
void
MemcacheRequest
::
SharedDtor
()
{
void
MemcacheRequest
::
SharedDtor
()
{
if
(
this
!=
default_instance_
)
{
}
}
}
void
MemcacheRequest
::
SetCachedSize
(
int
size
)
const
{
void
MemcacheRequest
::
SetCachedSize
(
int
size
)
const
{
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
();
_cached_size_
=
size
;
_cached_size_
=
size
;
GOOGLE_SAFE_CONCURRENT_WRITES_END
();
}
const
::
google
::
protobuf
::
Descriptor
*
MemcacheRequest
::
descriptor
()
{
protobuf_AssignDescriptorsOnce
();
return
MemcacheRequest_descriptor_
;
}
}
const
MemcacheRequest
&
MemcacheRequest
::
default_instance
()
{
const
::
google
::
protobuf
::
Descriptor
*
MemcacheRequest
::
descriptor
()
{
if
(
default_instance_
==
NULL
)
{
return
MemcacheRequestBase
::
descriptor
();
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
();
}
return
*
default_instance_
;
}
}
MemcacheRequest
*
MemcacheRequest
::
default_instance_
=
NULL
;
MemcacheRequest
*
MemcacheRequest
::
New
()
const
{
MemcacheRequest
*
MemcacheRequest
::
New
()
const
{
return
new
MemcacheRequest
;
return
new
MemcacheRequest
;
}
}
...
@@ -233,16 +124,13 @@ void MemcacheRequest::SerializeWithCachedSizes(
...
@@ -233,16 +124,13 @@ void MemcacheRequest::SerializeWithCachedSizes(
int
MemcacheRequest
::
ByteSize
()
const
{
int
MemcacheRequest
::
ByteSize
()
const
{
int
total_size
=
_buf
.
size
();
int
total_size
=
_buf
.
size
();
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
();
_cached_size_
=
total_size
;
_cached_size_
=
total_size
;
GOOGLE_SAFE_CONCURRENT_WRITES_END
();
return
total_size
;
return
total_size
;
}
}
void
MemcacheRequest
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
void
MemcacheRequest
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
GOOGLE_CHECK_NE
(
&
from
,
this
);
GOOGLE_CHECK_NE
(
&
from
,
this
);
const
MemcacheRequest
*
source
=
const
MemcacheRequest
*
source
=
dynamic_cast
<
const
MemcacheRequest
*>
(
&
from
);
::
google
::
protobuf
::
internal
::
dynamic_cast_if_available
<
const
MemcacheRequest
*>
(
&
from
);
if
(
source
==
NULL
)
{
if
(
source
==
NULL
)
{
::
google
::
protobuf
::
internal
::
ReflectionOps
::
Merge
(
from
,
this
);
::
google
::
protobuf
::
internal
::
ReflectionOps
::
Merge
(
from
,
this
);
}
else
{
}
else
{
...
@@ -281,26 +169,17 @@ void MemcacheRequest::Swap(MemcacheRequest* other) {
...
@@ -281,26 +169,17 @@ void MemcacheRequest::Swap(MemcacheRequest* other) {
}
}
::
google
::
protobuf
::
Metadata
MemcacheRequest
::
GetMetadata
()
const
{
::
google
::
protobuf
::
Metadata
MemcacheRequest
::
GetMetadata
()
const
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
Metadata
metadata
;
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
MemcacheRequest
_descriptor_
;
metadata
.
descriptor
=
MemcacheRequest
::
descriptor
()
;
metadata
.
reflection
=
NULL
;
metadata
.
reflection
=
NULL
;
return
metadata
;
return
metadata
;
}
}
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
MemcacheResponse
::
MemcacheResponse
()
MemcacheResponse
::
MemcacheResponse
()
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
}
}
void
MemcacheResponse
::
InitAsDefaultInstance
()
{
}
MemcacheResponse
::
MemcacheResponse
(
const
MemcacheResponse
&
from
)
MemcacheResponse
::
MemcacheResponse
(
const
MemcacheResponse
&
from
)
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
...
@@ -316,29 +195,15 @@ MemcacheResponse::~MemcacheResponse() {
...
@@ -316,29 +195,15 @@ MemcacheResponse::~MemcacheResponse() {
}
}
void
MemcacheResponse
::
SharedDtor
()
{
void
MemcacheResponse
::
SharedDtor
()
{
if
(
this
!=
default_instance_
)
{
}
}
}
void
MemcacheResponse
::
SetCachedSize
(
int
size
)
const
{
void
MemcacheResponse
::
SetCachedSize
(
int
size
)
const
{
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
();
_cached_size_
=
size
;
_cached_size_
=
size
;
GOOGLE_SAFE_CONCURRENT_WRITES_END
();
}
}
const
::
google
::
protobuf
::
Descriptor
*
MemcacheResponse
::
descriptor
()
{
const
::
google
::
protobuf
::
Descriptor
*
MemcacheResponse
::
descriptor
()
{
protobuf_AssignDescriptorsOnce
();
return
MemcacheResponseBase
::
descriptor
();
return
MemcacheResponse_descriptor_
;
}
}
const
MemcacheResponse
&
MemcacheResponse
::
default_instance
()
{
if
(
default_instance_
==
NULL
)
{
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
();
}
return
*
default_instance_
;
}
MemcacheResponse
*
MemcacheResponse
::
default_instance_
=
NULL
;
MemcacheResponse
*
MemcacheResponse
::
New
()
const
{
MemcacheResponse
*
MemcacheResponse
::
New
()
const
{
return
new
MemcacheResponse
;
return
new
MemcacheResponse
;
}
}
...
@@ -380,16 +245,13 @@ void MemcacheResponse::SerializeWithCachedSizes(
...
@@ -380,16 +245,13 @@ void MemcacheResponse::SerializeWithCachedSizes(
int
MemcacheResponse
::
ByteSize
()
const
{
int
MemcacheResponse
::
ByteSize
()
const
{
int
total_size
=
_buf
.
size
();
int
total_size
=
_buf
.
size
();
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
();
_cached_size_
=
total_size
;
_cached_size_
=
total_size
;
GOOGLE_SAFE_CONCURRENT_WRITES_END
();
return
total_size
;
return
total_size
;
}
}
void
MemcacheResponse
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
void
MemcacheResponse
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
GOOGLE_CHECK_NE
(
&
from
,
this
);
GOOGLE_CHECK_NE
(
&
from
,
this
);
const
MemcacheResponse
*
source
=
const
MemcacheResponse
*
source
=
dynamic_cast
<
const
MemcacheResponse
*>
(
&
from
);
::
google
::
protobuf
::
internal
::
dynamic_cast_if_available
<
const
MemcacheResponse
*>
(
&
from
);
if
(
source
==
NULL
)
{
if
(
source
==
NULL
)
{
::
google
::
protobuf
::
internal
::
ReflectionOps
::
Merge
(
from
,
this
);
::
google
::
protobuf
::
internal
::
ReflectionOps
::
Merge
(
from
,
this
);
}
else
{
}
else
{
...
@@ -429,9 +291,8 @@ void MemcacheResponse::Swap(MemcacheResponse* other) {
...
@@ -429,9 +291,8 @@ void MemcacheResponse::Swap(MemcacheResponse* other) {
}
}
::
google
::
protobuf
::
Metadata
MemcacheResponse
::
GetMetadata
()
const
{
::
google
::
protobuf
::
Metadata
MemcacheResponse
::
GetMetadata
()
const
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
Metadata
metadata
;
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
MemcacheResponse
_descriptor_
;
metadata
.
descriptor
=
MemcacheResponse
::
descriptor
()
;
metadata
.
reflection
=
NULL
;
metadata
.
reflection
=
NULL
;
return
metadata
;
return
metadata
;
}
}
...
...
src/brpc/memcache.h
View file @
40b13429
...
@@ -21,15 +21,11 @@
...
@@ -21,15 +21,11 @@
#define BRPC_MEMCACHE_H
#define BRPC_MEMCACHE_H
#include <string>
#include <string>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/message.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_reflection.h>
#include "google/protobuf/descriptor.pb.h"
#include "butil/iobuf.h"
#include "butil/iobuf.h"
#include "butil/strings/string_piece.h"
#include "butil/strings/string_piece.h"
#include "brpc/proto_base.pb.h"
namespace
brpc
{
namespace
brpc
{
...
@@ -90,6 +86,9 @@ public:
...
@@ -90,6 +86,9 @@ public:
int
pipelined_count
()
const
{
return
_pipelined_count
;
}
int
pipelined_count
()
const
{
return
_pipelined_count
;
}
butil
::
IOBuf
&
raw_buffer
()
{
return
_buf
;
}
const
butil
::
IOBuf
&
raw_buffer
()
const
{
return
_buf
;
}
// Protobuf methods.
// Protobuf methods.
MemcacheRequest
*
New
()
const
;
MemcacheRequest
*
New
()
const
;
void
CopyFrom
(
const
::
google
::
protobuf
::
Message
&
from
);
void
CopyFrom
(
const
::
google
::
protobuf
::
Message
&
from
);
...
@@ -108,11 +107,9 @@ public:
...
@@ -108,11 +107,9 @@ public:
int
GetCachedSize
()
const
{
return
_cached_size_
;
}
int
GetCachedSize
()
const
{
return
_cached_size_
;
}
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
MemcacheRequest
&
default_instance
();
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
butil
::
IOBuf
&
raw_buffer
()
{
return
_buf
;
}
protected
:
const
butil
::
IOBuf
&
raw_buffer
()
const
{
return
_buf
;
}
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
override
;
private
:
private
:
bool
GetOrDelete
(
uint8_t
command
,
const
butil
::
StringPiece
&
key
);
bool
GetOrDelete
(
uint8_t
command
,
const
butil
::
StringPiece
&
key
);
...
@@ -130,14 +127,6 @@ private:
...
@@ -130,14 +127,6 @@ private:
int
_pipelined_count
;
int
_pipelined_count
;
butil
::
IOBuf
_buf
;
butil
::
IOBuf
_buf
;
mutable
int
_cached_size_
;
mutable
int
_cached_size_
;
friend
void
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_impl
();
friend
void
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
();
friend
void
protobuf_AssignDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
();
friend
void
protobuf_ShutdownFile_baidu_2frpc_2fmemcache_5fbase_2eproto
();
void
InitAsDefaultInstance
();
static
MemcacheRequest
*
default_instance_
;
};
};
// Response from Memcache.
// Response from Memcache.
...
@@ -205,6 +194,9 @@ public:
...
@@ -205,6 +194,9 @@ public:
bool
PopDecrement
(
uint64_t
*
new_value
,
uint64_t
*
cas_value
);
bool
PopDecrement
(
uint64_t
*
new_value
,
uint64_t
*
cas_value
);
bool
PopTouch
();
bool
PopTouch
();
bool
PopVersion
(
std
::
string
*
version
);
bool
PopVersion
(
std
::
string
*
version
);
butil
::
IOBuf
&
raw_buffer
()
{
return
_buf
;
}
const
butil
::
IOBuf
&
raw_buffer
()
const
{
return
_buf
;
}
static
const
char
*
status_str
(
Status
);
// implements Message ----------------------------------------------
// implements Message ----------------------------------------------
...
@@ -225,13 +217,9 @@ public:
...
@@ -225,13 +217,9 @@ public:
int
GetCachedSize
()
const
{
return
_cached_size_
;
}
int
GetCachedSize
()
const
{
return
_cached_size_
;
}
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
MemcacheResponse
&
default_instance
();
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
butil
::
IOBuf
&
raw_buffer
()
{
return
_buf
;
}
const
butil
::
IOBuf
&
raw_buffer
()
const
{
return
_buf
;
}
static
const
char
*
status_str
(
Status
);
protected
:
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
private
:
private
:
bool
PopCounter
(
uint8_t
command
,
uint64_t
*
new_value
,
uint64_t
*
cas_value
);
bool
PopCounter
(
uint8_t
command
,
uint64_t
*
new_value
,
uint64_t
*
cas_value
);
...
@@ -244,14 +232,6 @@ private:
...
@@ -244,14 +232,6 @@ private:
std
::
string
_err
;
std
::
string
_err
;
butil
::
IOBuf
_buf
;
butil
::
IOBuf
_buf
;
mutable
int
_cached_size_
;
mutable
int
_cached_size_
;
friend
void
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_impl
();
friend
void
protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
();
friend
void
protobuf_AssignDesc_baidu_2frpc_2fmemcache_5fbase_2eproto
();
friend
void
protobuf_ShutdownFile_baidu_2frpc_2fmemcache_5fbase_2eproto
();
void
InitAsDefaultInstance
();
static
MemcacheResponse
*
default_instance_
;
};
};
}
// namespace brpc
}
// namespace brpc
...
...
src/brpc/nshead_message.cpp
View file @
40b13429
...
@@ -17,104 +17,19 @@
...
@@ -17,104 +17,19 @@
// Authors: Ge,Jun (gejun@baidu.com)
// Authors: Ge,Jun (gejun@baidu.com)
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "brpc/nshead_message.h"
#include <algorithm>
#include <algorithm>
#include "butil/logging.h"
#include <google/protobuf/reflection_ops.h> // ReflectionOps::Merge
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/wire_format.h>
#include "brpc/nshead_message.h"
#include "butil/logging.h"
namespace
brpc
{
namespace
brpc
{
namespace
{
const
::
google
::
protobuf
::
Descriptor
*
NsheadMessage_descriptor_
=
NULL
;
}
// namespace
void
protobuf_AssignDesc_baidu_2frpc_2fnshead_5fmessage_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto
();
const
::
google
::
protobuf
::
FileDescriptor
*
file
=
::
google
::
protobuf
::
DescriptorPool
::
generated_pool
()
->
FindFileByName
(
"baidu/rpc/nshead_message.proto"
);
GOOGLE_CHECK
(
file
!=
NULL
);
NsheadMessage_descriptor_
=
file
->
message_type
(
0
);
}
namespace
{
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AssignDescriptors_once_
);
inline
void
protobuf_AssignDescriptorsOnce
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AssignDescriptors_once_
,
&
protobuf_AssignDesc_baidu_2frpc_2fnshead_5fmessage_2eproto
);
}
void
protobuf_RegisterTypes
(
const
::
std
::
string
&
)
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedMessage
(
NsheadMessage_descriptor_
,
&
NsheadMessage
::
default_instance
());
}
}
// namespace
void
protobuf_ShutdownFile_baidu_2frpc_2fnshead_5fmessage_2eproto
()
{
delete
NsheadMessage
::
default_instance_
;
}
void
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto_impl
()
{
GOOGLE_PROTOBUF_VERIFY_VERSION
;
#if GOOGLE_PROTOBUF_VERSION >= 3002000
::
google
::
protobuf
::
internal
::
InitProtobufDefaults
();
#else
::
google
::
protobuf
::
protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto
();
#endif
::
google
::
protobuf
::
DescriptorPool
::
InternalAddGeneratedFile
(
"
\n\036
baidu/rpc/nshead_message.proto
\022\t
baidu."
"rpc
\032
google/protobuf/descriptor.proto
\"\017\n
"
"
\r
NsheadMessageB
\003\200\001\001
"
,
99
);
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedFile
(
"baidu/rpc/nshead_message.proto"
,
&
protobuf_RegisterTypes
);
NsheadMessage
::
default_instance_
=
new
NsheadMessage
();
NsheadMessage
::
default_instance_
->
InitAsDefaultInstance
();
::
google
::
protobuf
::
internal
::
OnShutdown
(
&
protobuf_ShutdownFile_baidu_2frpc_2fnshead_5fmessage_2eproto
);
}
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto_once
);
void
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto_once
,
&
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto_impl
);
}
// Force AddDescriptors() to be called at static initialization time.
struct
StaticDescriptorInitializer_baidu_2frpc_2fnshead_5fmessage_2eproto
{
StaticDescriptorInitializer_baidu_2frpc_2fnshead_5fmessage_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto
();
}
}
static_descriptor_initializer_baidu_2frpc_2fnshead_5fmessage_2eproto_
;
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
NsheadMessage
::
NsheadMessage
()
NsheadMessage
::
NsheadMessage
()
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
}
}
void
NsheadMessage
::
InitAsDefaultInstance
()
{
}
NsheadMessage
::
NsheadMessage
(
const
NsheadMessage
&
from
)
NsheadMessage
::
NsheadMessage
(
const
NsheadMessage
&
from
)
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
...
@@ -130,23 +45,12 @@ NsheadMessage::~NsheadMessage() {
...
@@ -130,23 +45,12 @@ NsheadMessage::~NsheadMessage() {
}
}
void
NsheadMessage
::
SharedDtor
()
{
void
NsheadMessage
::
SharedDtor
()
{
if
(
this
!=
default_instance_
)
{
}
}
}
const
::
google
::
protobuf
::
Descriptor
*
NsheadMessage
::
descriptor
()
{
const
::
google
::
protobuf
::
Descriptor
*
NsheadMessage
::
descriptor
()
{
protobuf_AssignDescriptorsOnce
();
return
NsheadMessageBase
::
descriptor
();
return
NsheadMessage_descriptor_
;
}
const
NsheadMessage
&
NsheadMessage
::
default_instance
()
{
if
(
default_instance_
==
NULL
)
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto
();
return
*
default_instance_
;
}
}
NsheadMessage
*
NsheadMessage
::
default_instance_
=
NULL
;
NsheadMessage
*
NsheadMessage
::
New
()
const
{
NsheadMessage
*
NsheadMessage
::
New
()
const
{
return
new
NsheadMessage
;
return
new
NsheadMessage
;
}
}
...
@@ -185,9 +89,7 @@ int NsheadMessage::ByteSize() const {
...
@@ -185,9 +89,7 @@ int NsheadMessage::ByteSize() const {
void
NsheadMessage
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
void
NsheadMessage
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
GOOGLE_CHECK_NE
(
&
from
,
this
);
GOOGLE_CHECK_NE
(
&
from
,
this
);
const
NsheadMessage
*
source
=
const
NsheadMessage
*
source
=
dynamic_cast
<
const
NsheadMessage
*>
(
&
from
);
::
google
::
protobuf
::
internal
::
dynamic_cast_if_available
<
const
NsheadMessage
*>
(
&
from
);
if
(
source
==
NULL
)
{
if
(
source
==
NULL
)
{
LOG
(
ERROR
)
<<
"Can only merge from NsheadMessage"
;
LOG
(
ERROR
)
<<
"Can only merge from NsheadMessage"
;
return
;
return
;
...
@@ -229,9 +131,8 @@ void NsheadMessage::Swap(NsheadMessage* other) {
...
@@ -229,9 +131,8 @@ void NsheadMessage::Swap(NsheadMessage* other) {
}
}
::
google
::
protobuf
::
Metadata
NsheadMessage
::
GetMetadata
()
const
{
::
google
::
protobuf
::
Metadata
NsheadMessage
::
GetMetadata
()
const
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
Metadata
metadata
;
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
NsheadMessage
_descriptor_
;
metadata
.
descriptor
=
NsheadMessage
::
descriptor
()
;
metadata
.
reflection
=
NULL
;
metadata
.
reflection
=
NULL
;
return
metadata
;
return
metadata
;
}
}
...
...
src/brpc/nshead_message.h
View file @
40b13429
...
@@ -20,26 +20,13 @@
...
@@ -20,26 +20,13 @@
#ifndef BRPC_NSHEAD_MESSAGE_H
#ifndef BRPC_NSHEAD_MESSAGE_H
#define BRPC_NSHEAD_MESSAGE_H
#define BRPC_NSHEAD_MESSAGE_H
#include <string>
#include <google/protobuf/message.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_reflection.h>
#include "google/protobuf/descriptor.pb.h"
#include "brpc/nshead.h" // nshead_t
#include "brpc/nshead.h" // nshead_t
#include "butil/iobuf.h" // IOBuf
#include "butil/iobuf.h" // IOBuf
#include "brpc/proto_base.pb.h"
namespace
brpc
{
namespace
brpc
{
// Internal implementation detail -- do not call these.
void
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto
();
void
protobuf_AssignDesc_baidu_2frpc_2fnshead_5fmessage_2eproto
();
void
protobuf_ShutdownFile_baidu_2frpc_2fnshead_5fmessage_2eproto
();
// Representing a nshead request or response.
// Representing a nshead request or response.
class
NsheadMessage
:
public
::
google
::
protobuf
::
Message
{
class
NsheadMessage
:
public
::
google
::
protobuf
::
Message
{
public
:
public
:
...
@@ -58,7 +45,6 @@ public:
...
@@ -58,7 +45,6 @@ public:
}
}
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
NsheadMessage
&
default_instance
();
void
Swap
(
NsheadMessage
*
other
);
void
Swap
(
NsheadMessage
*
other
);
...
@@ -79,19 +65,13 @@ public:
...
@@ -79,19 +65,13 @@ public:
::
google
::
protobuf
::
io
::
CodedOutputStream
*
output
)
const
;
::
google
::
protobuf
::
io
::
CodedOutputStream
*
output
)
const
;
::
google
::
protobuf
::
uint8
*
SerializeWithCachedSizesToArray
(
::
google
::
protobuf
::
uint8
*
output
)
const
;
::
google
::
protobuf
::
uint8
*
SerializeWithCachedSizesToArray
(
::
google
::
protobuf
::
uint8
*
output
)
const
;
int
GetCachedSize
()
const
{
return
ByteSize
();
}
int
GetCachedSize
()
const
{
return
ByteSize
();
}
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
protected
:
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
override
;
private
:
private
:
void
SharedCtor
();
void
SharedCtor
();
void
SharedDtor
();
void
SharedDtor
();
private
:
friend
void
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto_impl
();
friend
void
protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto
();
friend
void
protobuf_AssignDesc_baidu_2frpc_2fnshead_5fmessage_2eproto
();
friend
void
protobuf_ShutdownFile_baidu_2frpc_2fnshead_5fmessage_2eproto
();
void
InitAsDefaultInstance
();
static
NsheadMessage
*
default_instance_
;
};
};
}
// namespace brpc
}
// namespace brpc
...
...
src/brpc/policy/baidu_rpc_protocol.cpp
View file @
40b13429
...
@@ -320,12 +320,12 @@ void ProcessRpcRequest(InputMessageBase* msg_base) {
...
@@ -320,12 +320,12 @@ void ProcessRpcRequest(InputMessageBase* msg_base) {
SampledRequest
*
sample
=
AskToBeSampled
();
SampledRequest
*
sample
=
AskToBeSampled
();
if
(
sample
)
{
if
(
sample
)
{
sample
->
set_service_name
(
request_meta
.
service_name
());
sample
->
meta
.
set_service_name
(
request_meta
.
service_name
());
sample
->
set_method_name
(
request_meta
.
method_name
());
sample
->
meta
.
set_method_name
(
request_meta
.
method_name
());
sample
->
set_compress_type
((
CompressType
)
meta
.
compress_type
());
sample
->
meta
.
set_compress_type
((
CompressType
)
meta
.
compress_type
());
sample
->
set_protocol_type
(
PROTOCOL_BAIDU_STD
);
sample
->
meta
.
set_protocol_type
(
PROTOCOL_BAIDU_STD
);
sample
->
set_attachment_size
(
meta
.
attachment_size
());
sample
->
meta
.
set_attachment_size
(
meta
.
attachment_size
());
sample
->
set_authentication_data
(
meta
.
authentication_data
());
sample
->
meta
.
set_authentication_data
(
meta
.
authentication_data
());
sample
->
request
=
msg
->
payload
;
sample
->
request
=
msg
->
payload
;
sample
->
submit
(
start_parse_us
);
sample
->
submit
(
start_parse_us
);
}
}
...
@@ -639,11 +639,11 @@ void PackRpcRequest(butil::IOBuf* req_buf,
...
@@ -639,11 +639,11 @@ void PackRpcRequest(butil::IOBuf* req_buf,
method
->
service
()
->
name
());
method
->
service
()
->
name
());
request_meta
->
set_method_name
(
method
->
name
());
request_meta
->
set_method_name
(
method
->
name
());
meta
.
set_compress_type
(
cntl
->
request_compress_type
());
meta
.
set_compress_type
(
cntl
->
request_compress_type
());
}
else
if
(
cntl
->
rpc_dump_meta
())
{
}
else
if
(
cntl
->
sampled_request
())
{
// Replaying. Keep service-name as the one seen by server.
// Replaying. Keep service-name as the one seen by server.
request_meta
->
set_service_name
(
cntl
->
rpc_dump_meta
()
->
service_name
());
request_meta
->
set_service_name
(
cntl
->
sampled_request
()
->
meta
.
service_name
());
request_meta
->
set_method_name
(
cntl
->
rpc_dump_meta
()
->
method_name
());
request_meta
->
set_method_name
(
cntl
->
sampled_request
()
->
meta
.
method_name
());
meta
.
set_compress_type
(
cntl
->
rpc_dump_meta
()
->
compress_type
());
meta
.
set_compress_type
(
cntl
->
sampled_request
()
->
meta
.
compress_type
());
}
else
{
}
else
{
return
cntl
->
SetFailed
(
ENOMETHOD
,
"%s.method is NULL"
,
__FUNCTION__
);
return
cntl
->
SetFailed
(
ENOMETHOD
,
"%s.method is NULL"
,
__FUNCTION__
);
}
}
...
...
src/brpc/policy/hulu_pbrpc_protocol.cpp
View file @
40b13429
...
@@ -348,15 +348,15 @@ void ProcessHuluRequest(InputMessageBase* msg_base) {
...
@@ -348,15 +348,15 @@ void ProcessHuluRequest(InputMessageBase* msg_base) {
const
CompressType
req_cmp_type
=
Hulu2CompressType
((
HuluCompressType
)
meta
.
compress_type
());
const
CompressType
req_cmp_type
=
Hulu2CompressType
((
HuluCompressType
)
meta
.
compress_type
());
SampledRequest
*
sample
=
AskToBeSampled
();
SampledRequest
*
sample
=
AskToBeSampled
();
if
(
sample
)
{
if
(
sample
)
{
sample
->
set_service_name
(
meta
.
service_name
());
sample
->
meta
.
set_service_name
(
meta
.
service_name
());
sample
->
set_method_index
(
meta
.
method_index
());
sample
->
meta
.
set_method_index
(
meta
.
method_index
());
sample
->
set_compress_type
(
req_cmp_type
);
sample
->
meta
.
set_compress_type
(
req_cmp_type
);
sample
->
set_protocol_type
(
PROTOCOL_HULU_PBRPC
);
sample
->
meta
.
set_protocol_type
(
PROTOCOL_HULU_PBRPC
);
sample
->
set_user_data
(
meta
.
user_data
());
sample
->
meta
.
set_user_data
(
meta
.
user_data
());
if
(
meta
.
has_user_message_size
()
if
(
meta
.
has_user_message_size
()
&&
static_cast
<
size_t
>
(
meta
.
user_message_size
())
<
msg
->
payload
.
size
())
{
&&
static_cast
<
size_t
>
(
meta
.
user_message_size
())
<
msg
->
payload
.
size
())
{
size_t
attachment_size
=
msg
->
payload
.
size
()
-
meta
.
user_message_size
();
size_t
attachment_size
=
msg
->
payload
.
size
()
-
meta
.
user_message_size
();
sample
->
set_attachment_size
(
attachment_size
);
sample
->
meta
.
set_attachment_size
(
attachment_size
);
}
}
sample
->
request
=
msg
->
payload
;
sample
->
request
=
msg
->
payload
;
sample
->
submit
(
start_parse_us
);
sample
->
submit
(
start_parse_us
);
...
@@ -642,13 +642,13 @@ void PackHuluRequest(butil::IOBuf* req_buf,
...
@@ -642,13 +642,13 @@ void PackHuluRequest(butil::IOBuf* req_buf,
meta
.
set_service_name
(
method
->
service
()
->
name
());
meta
.
set_service_name
(
method
->
service
()
->
name
());
meta
.
set_method_index
(
method
->
index
());
meta
.
set_method_index
(
method
->
index
());
meta
.
set_compress_type
(
CompressType2Hulu
(
cntl
->
request_compress_type
()));
meta
.
set_compress_type
(
CompressType2Hulu
(
cntl
->
request_compress_type
()));
}
else
if
(
cntl
->
rpc_dump_meta
())
{
}
else
if
(
cntl
->
sampled_request
())
{
// Replaying. Keep service-name as the one seen by server.
// Replaying. Keep service-name as the one seen by server.
meta
.
set_service_name
(
cntl
->
rpc_dump_meta
()
->
service_name
());
meta
.
set_service_name
(
cntl
->
sampled_request
()
->
meta
.
service_name
());
meta
.
set_method_index
(
cntl
->
rpc_dump_meta
()
->
method_index
());
meta
.
set_method_index
(
cntl
->
sampled_request
()
->
meta
.
method_index
());
meta
.
set_compress_type
(
meta
.
set_compress_type
(
CompressType2Hulu
(
cntl
->
rpc_dump_meta
()
->
compress_type
()));
CompressType2Hulu
(
cntl
->
sampled_request
()
->
meta
.
compress_type
()));
meta
.
set_user_data
(
cntl
->
rpc_dump_meta
()
->
user_data
());
meta
.
set_user_data
(
cntl
->
sampled_request
()
->
meta
.
user_data
());
}
else
{
}
else
{
return
cntl
->
SetFailed
(
ENOMETHOD
,
"method is NULL"
);
return
cntl
->
SetFailed
(
ENOMETHOD
,
"method is NULL"
);
}
}
...
...
src/brpc/policy/sofa_pbrpc_protocol.cpp
View file @
40b13429
...
@@ -325,9 +325,9 @@ void ProcessSofaRequest(InputMessageBase* msg_base) {
...
@@ -325,9 +325,9 @@ void ProcessSofaRequest(InputMessageBase* msg_base) {
SampledRequest
*
sample
=
AskToBeSampled
();
SampledRequest
*
sample
=
AskToBeSampled
();
if
(
sample
)
{
if
(
sample
)
{
sample
->
set_method_name
(
meta
.
method
());
sample
->
meta
.
set_method_name
(
meta
.
method
());
sample
->
set_compress_type
(
req_cmp_type
);
sample
->
meta
.
set_compress_type
(
req_cmp_type
);
sample
->
set_protocol_type
(
PROTOCOL_SOFA_PBRPC
);
sample
->
meta
.
set_protocol_type
(
PROTOCOL_SOFA_PBRPC
);
sample
->
request
=
msg
->
payload
;
sample
->
request
=
msg
->
payload
;
sample
->
submit
(
start_parse_us
);
sample
->
submit
(
start_parse_us
);
}
}
...
@@ -548,11 +548,11 @@ void PackSofaRequest(butil::IOBuf* req_buf,
...
@@ -548,11 +548,11 @@ void PackSofaRequest(butil::IOBuf* req_buf,
if
(
method
)
{
if
(
method
)
{
meta
.
set_method
(
method
->
full_name
());
meta
.
set_method
(
method
->
full_name
());
meta
.
set_compress_type
(
CompressType2Sofa
(
cntl
->
request_compress_type
()));
meta
.
set_compress_type
(
CompressType2Sofa
(
cntl
->
request_compress_type
()));
}
else
if
(
cntl
->
rpc_dump_meta
())
{
}
else
if
(
cntl
->
sampled_request
())
{
// Replaying.
// Replaying.
meta
.
set_method
(
cntl
->
rpc_dump_meta
()
->
method_name
());
meta
.
set_method
(
cntl
->
sampled_request
()
->
meta
.
method_name
());
meta
.
set_compress_type
(
meta
.
set_compress_type
(
CompressType2Sofa
(
cntl
->
rpc_dump_meta
()
->
compress_type
()));
CompressType2Sofa
(
cntl
->
sampled_request
()
->
meta
.
compress_type
()));
}
else
{
}
else
{
return
cntl
->
SetFailed
(
ENOMETHOD
,
"method is NULL"
);
return
cntl
->
SetFailed
(
ENOMETHOD
,
"method is NULL"
);
}
}
...
...
src/brpc/progressive_attachment.h
View file @
40b13429
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#ifndef BRPC_PROGRESSIVE_ATTACHMENT_H
#ifndef BRPC_PROGRESSIVE_ATTACHMENT_H
#define BRPC_PROGRESSIVE_ATTACHMENT_H
#define BRPC_PROGRESSIVE_ATTACHMENT_H
#include "brpc/callback.h"
#include "butil/atomicops.h"
#include "butil/atomicops.h"
#include "butil/iobuf.h"
#include "butil/iobuf.h"
#include "butil/endpoint.h" // butil::EndPoint
#include "butil/endpoint.h" // butil::EndPoint
...
@@ -27,7 +28,6 @@
...
@@ -27,7 +28,6 @@
#include "brpc/socket_id.h" // SocketUniquePtr
#include "brpc/socket_id.h" // SocketUniquePtr
#include "brpc/shared_object.h" // SharedObject
#include "brpc/shared_object.h" // SharedObject
namespace
brpc
{
namespace
brpc
{
class
ProgressiveAttachment
:
public
SharedObject
{
class
ProgressiveAttachment
:
public
SharedObject
{
...
...
src/brpc/proto_base.proto
0 → 100644
View file @
40b13429
syntax
=
"proto2"
;
package
brpc
;
message
RedisRequestBase
{}
message
RedisResponseBase
{}
message
EspMessageBase
{}
message
MemcacheRequestBase
{}
message
MemcacheResponseBase
{}
message
NsheadMessageBase
{}
message
SerializedRequestBase
{}
message
ThriftFramedMessageBase
{}
src/brpc/redis.cpp
View file @
40b13429
...
@@ -17,121 +17,21 @@
...
@@ -17,121 +17,21 @@
// Authors: Ge,Jun (gejun@baidu.com)
// Authors: Ge,Jun (gejun@baidu.com)
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include <google/protobuf/reflection_ops.h> // ReflectionOps::Merge
#include <algorithm>
#include <gflags/gflags.h>
#include <gflags/gflags.h>
#include <google/protobuf/stubs/once.h>
#include "butil/status.h"
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
#include "butil/string_printf.h"
#include "butil/macros.h"
#include "brpc/controller.h"
#include "brpc/redis.h"
#include "brpc/redis.h"
#include "brpc/redis_command.h"
#include "brpc/redis_command.h"
namespace
brpc
{
namespace
brpc
{
DEFINE_bool
(
redis_verbose_crlf2space
,
false
,
"[DEBUG] Show
\\
r
\\
n as a space"
);
DEFINE_bool
(
redis_verbose_crlf2space
,
false
,
"[DEBUG] Show
\\
r
\\
n as a space"
);
// Internal implementation detail -- do not call these.
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl
();
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
void
protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
void
protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto
();
namespace
{
const
::
google
::
protobuf
::
Descriptor
*
RedisRequest_descriptor_
=
NULL
;
const
::
google
::
protobuf
::
Descriptor
*
RedisResponse_descriptor_
=
NULL
;
}
// namespace
void
protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
const
::
google
::
protobuf
::
FileDescriptor
*
file
=
::
google
::
protobuf
::
DescriptorPool
::
generated_pool
()
->
FindFileByName
(
"baidu/rpc/redis_base.proto"
);
GOOGLE_CHECK
(
file
!=
NULL
);
RedisRequest_descriptor_
=
file
->
message_type
(
0
);
RedisResponse_descriptor_
=
file
->
message_type
(
1
);
}
namespace
{
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AssignDescriptors_once_
);
inline
void
protobuf_AssignDescriptorsOnce
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AssignDescriptors_once_
,
&
protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto
);
}
void
protobuf_RegisterTypes
(
const
::
std
::
string
&
)
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedMessage
(
RedisRequest_descriptor_
,
&
RedisRequest
::
default_instance
());
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedMessage
(
RedisResponse_descriptor_
,
&
RedisResponse
::
default_instance
());
}
}
// namespace
void
protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto
()
{
delete
RedisRequest
::
default_instance_
;
delete
RedisResponse
::
default_instance_
;
}
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl
()
{
GOOGLE_PROTOBUF_VERIFY_VERSION
;
#if GOOGLE_PROTOBUF_VERSION >= 3002000
::
google
::
protobuf
::
internal
::
InitProtobufDefaults
();
#else
::
google
::
protobuf
::
protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto
();
#endif
::
google
::
protobuf
::
DescriptorPool
::
InternalAddGeneratedFile
(
"
\n\032
baidu/rpc/redis_base.proto
\022\t
baidu.rpc
\032
"
" google/protobuf/descriptor.proto
\"\016\n\014
Red"
"isRequest
\"\017\n\r
RedisResponseB
\003\200\001\001
"
,
111
);
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedFile
(
"baidu/rpc/redis_base.proto"
,
&
protobuf_RegisterTypes
);
RedisRequest
::
default_instance_
=
new
RedisRequest
();
RedisResponse
::
default_instance_
=
new
RedisResponse
();
RedisRequest
::
default_instance_
->
InitAsDefaultInstance
();
RedisResponse
::
default_instance_
->
InitAsDefaultInstance
();
::
google
::
protobuf
::
internal
::
OnShutdown
(
&
protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto
);
}
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_once
);
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_once
,
&
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl
);
}
// Force AddDescriptors() to be called at static initialization time.
struct
StaticDescriptorInitializer_baidu_2frpc_2fredis_5fbase_2eproto
{
StaticDescriptorInitializer_baidu_2frpc_2fredis_5fbase_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
}
}
static_descriptor_initializer_baidu_2frpc_2fredis_5fbase_2eproto_
;
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
RedisRequest
::
RedisRequest
()
RedisRequest
::
RedisRequest
()
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
}
}
void
RedisRequest
::
InitAsDefaultInstance
()
{
}
RedisRequest
::
RedisRequest
(
const
RedisRequest
&
from
)
RedisRequest
::
RedisRequest
(
const
RedisRequest
&
from
)
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
...
@@ -149,29 +49,12 @@ RedisRequest::~RedisRequest() {
...
@@ -149,29 +49,12 @@ RedisRequest::~RedisRequest() {
}
}
void
RedisRequest
::
SharedDtor
()
{
void
RedisRequest
::
SharedDtor
()
{
if
(
this
!=
default_instance_
)
{
}
}
}
void
RedisRequest
::
SetCachedSize
(
int
size
)
const
{
void
RedisRequest
::
SetCachedSize
(
int
size
)
const
{
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
();
_cached_size_
=
size
;
_cached_size_
=
size
;
GOOGLE_SAFE_CONCURRENT_WRITES_END
();
}
const
::
google
::
protobuf
::
Descriptor
*
RedisRequest
::
descriptor
()
{
protobuf_AssignDescriptorsOnce
();
return
RedisRequest_descriptor_
;
}
}
const
RedisRequest
&
RedisRequest
::
default_instance
()
{
if
(
default_instance_
==
NULL
)
{
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
}
return
*
default_instance_
;
}
RedisRequest
*
RedisRequest
::
default_instance_
=
NULL
;
RedisRequest
*
RedisRequest
::
New
()
const
{
RedisRequest
*
RedisRequest
::
New
()
const
{
return
new
RedisRequest
;
return
new
RedisRequest
;
}
}
...
@@ -200,16 +83,13 @@ void RedisRequest::SerializeWithCachedSizes(
...
@@ -200,16 +83,13 @@ void RedisRequest::SerializeWithCachedSizes(
int
RedisRequest
::
ByteSize
()
const
{
int
RedisRequest
::
ByteSize
()
const
{
int
total_size
=
_buf
.
size
();
int
total_size
=
_buf
.
size
();
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
();
_cached_size_
=
total_size
;
_cached_size_
=
total_size
;
GOOGLE_SAFE_CONCURRENT_WRITES_END
();
return
total_size
;
return
total_size
;
}
}
void
RedisRequest
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
void
RedisRequest
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
GOOGLE_CHECK_NE
(
&
from
,
this
);
GOOGLE_CHECK_NE
(
&
from
,
this
);
const
RedisRequest
*
source
=
const
RedisRequest
*
source
=
dynamic_cast
<
const
RedisRequest
*>
(
&
from
);
::
google
::
protobuf
::
internal
::
dynamic_cast_if_available
<
const
RedisRequest
*>
(
&
from
);
if
(
source
==
NULL
)
{
if
(
source
==
NULL
)
{
::
google
::
protobuf
::
internal
::
ReflectionOps
::
Merge
(
from
,
this
);
::
google
::
protobuf
::
internal
::
ReflectionOps
::
Merge
(
from
,
this
);
}
else
{
}
else
{
...
@@ -249,14 +129,6 @@ void RedisRequest::Swap(RedisRequest* other) {
...
@@ -249,14 +129,6 @@ void RedisRequest::Swap(RedisRequest* other) {
}
}
}
}
::
google
::
protobuf
::
Metadata
RedisRequest
::
GetMetadata
()
const
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
RedisRequest_descriptor_
;
metadata
.
reflection
=
NULL
;
return
metadata
;
}
bool
RedisRequest
::
AddCommand
(
const
butil
::
StringPiece
&
command
)
{
bool
RedisRequest
::
AddCommand
(
const
butil
::
StringPiece
&
command
)
{
if
(
_has_error
)
{
if
(
_has_error
)
{
return
false
;
return
false
;
...
@@ -330,6 +202,17 @@ bool RedisRequest::SerializeTo(butil::IOBuf* buf) const {
...
@@ -330,6 +202,17 @@ bool RedisRequest::SerializeTo(butil::IOBuf* buf) const {
return
true
;
return
true
;
}
}
const
::
google
::
protobuf
::
Descriptor
*
RedisRequest
::
descriptor
()
{
return
RedisRequestBase
::
descriptor
();
}
::
google
::
protobuf
::
Metadata
RedisRequest
::
GetMetadata
()
const
{
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
RedisRequest
::
descriptor
();
metadata
.
reflection
=
NULL
;
return
metadata
;
}
void
RedisRequest
::
Print
(
std
::
ostream
&
os
)
const
{
void
RedisRequest
::
Print
(
std
::
ostream
&
os
)
const
{
butil
::
IOBuf
cp
=
_buf
;
butil
::
IOBuf
cp
=
_buf
;
butil
::
IOBuf
seg
;
butil
::
IOBuf
seg
;
...
@@ -355,19 +238,11 @@ std::ostream& operator<<(std::ostream& os, const RedisRequest& r) {
...
@@ -355,19 +238,11 @@ std::ostream& operator<<(std::ostream& os, const RedisRequest& r) {
return
os
;
return
os
;
}
}
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
RedisResponse
::
RedisResponse
()
RedisResponse
::
RedisResponse
()
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
}
}
void
RedisResponse
::
InitAsDefaultInstance
()
{
}
RedisResponse
::
RedisResponse
(
const
RedisResponse
&
from
)
RedisResponse
::
RedisResponse
(
const
RedisResponse
&
from
)
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
...
@@ -385,26 +260,11 @@ RedisResponse::~RedisResponse() {
...
@@ -385,26 +260,11 @@ RedisResponse::~RedisResponse() {
}
}
void
RedisResponse
::
SharedDtor
()
{
void
RedisResponse
::
SharedDtor
()
{
if
(
this
!=
default_instance_
)
{
}
}
}
void
RedisResponse
::
SetCachedSize
(
int
size
)
const
{
void
RedisResponse
::
SetCachedSize
(
int
size
)
const
{
_cached_size_
=
size
;
_cached_size_
=
size
;
}
}
const
::
google
::
protobuf
::
Descriptor
*
RedisResponse
::
descriptor
()
{
protobuf_AssignDescriptorsOnce
();
return
RedisResponse_descriptor_
;
}
const
RedisResponse
&
RedisResponse
::
default_instance
()
{
if
(
default_instance_
==
NULL
)
{
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
}
return
*
default_instance_
;
}
RedisResponse
*
RedisResponse
::
default_instance_
=
NULL
;
RedisResponse
*
RedisResponse
::
New
()
const
{
RedisResponse
*
RedisResponse
::
New
()
const
{
return
new
RedisResponse
;
return
new
RedisResponse
;
...
@@ -440,8 +300,7 @@ int RedisResponse::ByteSize() const {
...
@@ -440,8 +300,7 @@ int RedisResponse::ByteSize() const {
void
RedisResponse
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
void
RedisResponse
::
MergeFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
GOOGLE_CHECK_NE
(
&
from
,
this
);
GOOGLE_CHECK_NE
(
&
from
,
this
);
const
RedisResponse
*
source
=
const
RedisResponse
*
source
=
dynamic_cast
<
const
RedisResponse
*>
(
&
from
);
::
google
::
protobuf
::
internal
::
dynamic_cast_if_available
<
const
RedisResponse
*>
(
&
from
);
if
(
source
==
NULL
)
{
if
(
source
==
NULL
)
{
::
google
::
protobuf
::
internal
::
ReflectionOps
::
Merge
(
from
,
this
);
::
google
::
protobuf
::
internal
::
ReflectionOps
::
Merge
(
from
,
this
);
}
else
{
}
else
{
...
@@ -508,10 +367,13 @@ void RedisResponse::Swap(RedisResponse* other) {
...
@@ -508,10 +367,13 @@ void RedisResponse::Swap(RedisResponse* other) {
}
}
}
}
const
::
google
::
protobuf
::
Descriptor
*
RedisResponse
::
descriptor
()
{
return
RedisResponseBase
::
descriptor
();
}
::
google
::
protobuf
::
Metadata
RedisResponse
::
GetMetadata
()
const
{
::
google
::
protobuf
::
Metadata
RedisResponse
::
GetMetadata
()
const
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
Metadata
metadata
;
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
RedisResponse
_descriptor_
;
metadata
.
descriptor
=
RedisResponse
::
descriptor
()
;
metadata
.
reflection
=
NULL
;
metadata
.
reflection
=
NULL
;
return
metadata
;
return
metadata
;
}
}
...
...
src/brpc/redis.h
View file @
40b13429
...
@@ -20,21 +20,13 @@
...
@@ -20,21 +20,13 @@
#ifndef BRPC_REDIS_H
#ifndef BRPC_REDIS_H
#define BRPC_REDIS_H
#define BRPC_REDIS_H
#include <string>
#include <google/protobuf/message.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_reflection.h>
#include "google/protobuf/descriptor.pb.h"
#include "butil/iobuf.h"
#include "butil/iobuf.h"
#include "butil/strings/string_piece.h"
#include "butil/strings/string_piece.h"
#include "butil/arena.h"
#include "butil/arena.h"
#include "
redis_reply
.h"
#include "
brpc/proto_base.pb
.h"
#include "
parse_result
.h"
#include "
brpc/redis_reply
.h"
#include "brpc/parse_result.h"
namespace
brpc
{
namespace
brpc
{
...
@@ -128,11 +120,12 @@ public:
...
@@ -128,11 +120,12 @@ public:
int
GetCachedSize
()
const
{
return
_cached_size_
;
}
int
GetCachedSize
()
const
{
return
_cached_size_
;
}
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
RedisRequest
&
default_instance
();
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
void
Print
(
std
::
ostream
&
)
const
;
void
Print
(
std
::
ostream
&
)
const
;
protected
:
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
override
;
private
:
private
:
void
SharedCtor
();
void
SharedCtor
();
void
SharedDtor
();
void
SharedDtor
();
...
@@ -143,14 +136,6 @@ private:
...
@@ -143,14 +136,6 @@ private:
bool
_has_error
;
// previous AddCommand had error
bool
_has_error
;
// previous AddCommand had error
butil
::
IOBuf
_buf
;
// the serialized request.
butil
::
IOBuf
_buf
;
// the serialized request.
mutable
int
_cached_size_
;
// ByteSize
mutable
int
_cached_size_
;
// ByteSize
friend
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl
();
friend
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
friend
void
protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
friend
void
protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto
();
void
InitAsDefaultInstance
();
static
RedisRequest
*
default_instance_
;
};
};
// Response from Redis.
// Response from Redis.
...
@@ -205,8 +190,9 @@ public:
...
@@ -205,8 +190,9 @@ public:
int
GetCachedSize
()
const
{
return
_cached_size_
;
}
int
GetCachedSize
()
const
{
return
_cached_size_
;
}
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
RedisResponse
&
default_instance
();
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
protected
:
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
override
;
private
:
private
:
void
SharedCtor
();
void
SharedCtor
();
...
@@ -218,14 +204,6 @@ private:
...
@@ -218,14 +204,6 @@ private:
butil
::
Arena
_arena
;
butil
::
Arena
_arena
;
int
_nreply
;
int
_nreply
;
mutable
int
_cached_size_
;
mutable
int
_cached_size_
;
friend
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl
();
friend
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
friend
void
protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
friend
void
protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto
();
void
InitAsDefaultInstance
();
static
RedisResponse
*
default_instance_
;
};
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
RedisRequest
&
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
RedisRequest
&
);
...
...
src/brpc/rpc_dump.cpp
View file @
40b13429
...
@@ -34,7 +34,6 @@ namespace bvar {
...
@@ -34,7 +34,6 @@ namespace bvar {
std
::
string
read_command_name
();
std
::
string
read_command_name
();
}
}
namespace
brpc
{
namespace
brpc
{
DECLARE_uint64
(
max_body_size
);
DECLARE_uint64
(
max_body_size
);
...
@@ -243,7 +242,7 @@ bool RpcDumpContext::Serialize(butil::IOBuf& buf, SampledRequest* sample) {
...
@@ -243,7 +242,7 @@ bool RpcDumpContext::Serialize(butil::IOBuf& buf, SampledRequest* sample) {
const
size_t
starting_size
=
buf
.
size
();
const
size_t
starting_size
=
buf
.
size
();
butil
::
IOBufAsZeroCopyOutputStream
buf_stream
(
&
buf
);
butil
::
IOBufAsZeroCopyOutputStream
buf_stream
(
&
buf
);
if
(
!
sample
->
SerializeToZeroCopyStream
(
&
buf_stream
))
{
if
(
!
sample
->
meta
.
SerializeToZeroCopyStream
(
&
buf_stream
))
{
LOG
(
ERROR
)
<<
"Fail to serialize"
;
LOG
(
ERROR
)
<<
"Fail to serialize"
;
return
false
;
return
false
;
}
}
...
@@ -352,7 +351,7 @@ SampledRequest* SampleIterator::Pop(butil::IOBuf& buf, bool* format_error) {
...
@@ -352,7 +351,7 @@ SampledRequest* SampleIterator::Pop(butil::IOBuf& buf, bool* format_error) {
butil
::
IOBuf
meta_buf
;
butil
::
IOBuf
meta_buf
;
buf
.
cutn
(
&
meta_buf
,
meta_size
);
buf
.
cutn
(
&
meta_buf
,
meta_size
);
std
::
unique_ptr
<
SampledRequest
>
req
(
new
SampledRequest
);
std
::
unique_ptr
<
SampledRequest
>
req
(
new
SampledRequest
);
if
(
!
ParsePbFromIOBuf
(
req
.
get
()
,
meta_buf
))
{
if
(
!
ParsePbFromIOBuf
(
&
req
->
meta
,
meta_buf
))
{
LOG
(
ERROR
)
<<
"Fail to parse RpcDumpMeta"
;
LOG
(
ERROR
)
<<
"Fail to parse RpcDumpMeta"
;
*
format_error
=
true
;
*
format_error
=
true
;
return
NULL
;
return
NULL
;
...
...
src/brpc/rpc_dump.h
View file @
40b13429
...
@@ -30,7 +30,6 @@ namespace butil {
...
@@ -30,7 +30,6 @@ namespace butil {
class
FileEnumerator
;
class
FileEnumerator
;
}
}
namespace
brpc
{
namespace
brpc
{
DECLARE_bool
(
rpc_dump
);
DECLARE_bool
(
rpc_dump
);
...
@@ -49,9 +48,9 @@ DECLARE_bool(rpc_dump);
...
@@ -49,9 +48,9 @@ DECLARE_bool(rpc_dump);
// In practice, sampled requests are just small fraction of all requests.
// In practice, sampled requests are just small fraction of all requests.
// The overhead of sampling should be negligible for overall performance.
// The overhead of sampling should be negligible for overall performance.
struct
SampledRequest
:
public
bvar
::
Collected
struct
SampledRequest
:
public
bvar
::
Collected
{
,
public
RpcDumpMeta
{
butil
::
IOBuf
request
;
butil
::
IOBuf
request
;
RpcDumpMeta
meta
;
// Implement methods of Sampled.
// Implement methods of Sampled.
void
dump_and_destroy
(
size_t
round
)
override
;
void
dump_and_destroy
(
size_t
round
)
override
;
...
...
src/brpc/serialized_request.cpp
View file @
40b13429
...
@@ -17,95 +17,16 @@
...
@@ -17,95 +17,16 @@
// Authors: Ge,Jun (gejun@baidu.com)
// Authors: Ge,Jun (gejun@baidu.com)
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "brpc/serialized_request.h"
#include "brpc/serialized_request.h"
#include <algorithm>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
#include "butil/logging.h"
#include "butil/logging.h"
namespace
brpc
{
namespace
brpc
{
namespace
{
const
::
google
::
protobuf
::
Descriptor
*
SerializedRequest_descriptor_
=
NULL
;
}
// namespace
void
protobuf_AssignDesc_baidu_2frpc_2fserialized_5frequest_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto
();
const
::
google
::
protobuf
::
FileDescriptor
*
file
=
::
google
::
protobuf
::
DescriptorPool
::
generated_pool
()
->
FindFileByName
(
"baidu/rpc/serialized_request.proto"
);
GOOGLE_CHECK
(
file
!=
NULL
);
SerializedRequest_descriptor_
=
file
->
message_type
(
0
);
}
namespace
{
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AssignDescriptors_once_
);
inline
void
protobuf_AssignDescriptorsOnce
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AssignDescriptors_once_
,
&
protobuf_AssignDesc_baidu_2frpc_2fserialized_5frequest_2eproto
);
}
void
protobuf_RegisterTypes
(
const
::
std
::
string
&
)
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedMessage
(
SerializedRequest_descriptor_
,
&
SerializedRequest
::
default_instance
());
}
}
// namespace
void
protobuf_ShutdownFile_baidu_2frpc_2fserialized_5frequest_2eproto
()
{
delete
SerializedRequest
::
default_instance_
;
}
void
protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto
()
{
static
bool
already_here
=
false
;
if
(
already_here
)
return
;
already_here
=
true
;
GOOGLE_PROTOBUF_VERIFY_VERSION
;
::
google
::
protobuf
::
DescriptorPool
::
InternalAddGeneratedFile
(
"
\n\"
baidu/rpc/serialized_request.proto
\022\t
ba"
"idu.rpc
\"\023\n\021
SerializedRequest"
,
68
);
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedFile
(
"baidu/rpc/serialized_request.proto"
,
&
protobuf_RegisterTypes
);
SerializedRequest
::
default_instance_
=
new
SerializedRequest
();
SerializedRequest
::
default_instance_
->
InitAsDefaultInstance
();
::
google
::
protobuf
::
internal
::
OnShutdown
(
&
protobuf_ShutdownFile_baidu_2frpc_2fserialized_5frequest_2eproto
);
}
// Force AddDescriptors() to be called at static initialization time.
struct
StaticDescriptorInitializer_baidu_2frpc_2fserialized_5frequest_2eproto
{
StaticDescriptorInitializer_baidu_2frpc_2fserialized_5frequest_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto
();
}
}
static_descriptor_initializer_baidu_2frpc_2fserialized_5frequest_2eproto_
;
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
SerializedRequest
::
SerializedRequest
()
SerializedRequest
::
SerializedRequest
()
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
}
}
void
SerializedRequest
::
InitAsDefaultInstance
()
{
}
SerializedRequest
::
SerializedRequest
(
const
SerializedRequest
&
from
)
SerializedRequest
::
SerializedRequest
(
const
SerializedRequest
&
from
)
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
...
@@ -120,26 +41,15 @@ SerializedRequest::~SerializedRequest() {
...
@@ -120,26 +41,15 @@ SerializedRequest::~SerializedRequest() {
}
}
void
SerializedRequest
::
SharedDtor
()
{
void
SerializedRequest
::
SharedDtor
()
{
if
(
this
!=
default_instance_
)
{
}
}
}
void
SerializedRequest
::
SetCachedSize
(
int
/*size*/
)
const
{
void
SerializedRequest
::
SetCachedSize
(
int
/*size*/
)
const
{
CHECK
(
false
)
<<
"You're not supposed to call "
<<
__FUNCTION__
;
CHECK
(
false
)
<<
"You're not supposed to call "
<<
__FUNCTION__
;
}
}
const
::
google
::
protobuf
::
Descriptor
*
SerializedRequest
::
descriptor
()
{
const
::
google
::
protobuf
::
Descriptor
*
SerializedRequest
::
descriptor
()
{
protobuf_AssignDescriptorsOnce
();
return
SerializedRequestBase
::
descriptor
();
return
SerializedRequest_descriptor_
;
}
}
const
SerializedRequest
&
SerializedRequest
::
default_instance
()
{
if
(
default_instance_
==
NULL
)
protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto
();
return
*
default_instance_
;
}
SerializedRequest
*
SerializedRequest
::
default_instance_
=
NULL
;
SerializedRequest
*
SerializedRequest
::
New
()
const
{
SerializedRequest
*
SerializedRequest
::
New
()
const
{
return
new
SerializedRequest
;
return
new
SerializedRequest
;
}
}
...
@@ -179,9 +89,7 @@ void SerializedRequest::MergeFrom(const SerializedRequest&) {
...
@@ -179,9 +89,7 @@ void SerializedRequest::MergeFrom(const SerializedRequest&) {
void
SerializedRequest
::
CopyFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
void
SerializedRequest
::
CopyFrom
(
const
::
google
::
protobuf
::
Message
&
from
)
{
if
(
&
from
==
this
)
return
;
if
(
&
from
==
this
)
return
;
const
SerializedRequest
*
source
=
const
SerializedRequest
*
source
=
dynamic_cast
<
const
SerializedRequest
*>
(
&
from
);
::
google
::
protobuf
::
internal
::
dynamic_cast_if_available
<
const
SerializedRequest
*>
(
&
from
);
if
(
source
==
NULL
)
{
if
(
source
==
NULL
)
{
CHECK
(
false
)
<<
"SerializedRequest can only CopyFrom SerializedRequest"
;
CHECK
(
false
)
<<
"SerializedRequest can only CopyFrom SerializedRequest"
;
}
else
{
}
else
{
...
@@ -206,9 +114,8 @@ void SerializedRequest::Swap(SerializedRequest* other) {
...
@@ -206,9 +114,8 @@ void SerializedRequest::Swap(SerializedRequest* other) {
}
}
::
google
::
protobuf
::
Metadata
SerializedRequest
::
GetMetadata
()
const
{
::
google
::
protobuf
::
Metadata
SerializedRequest
::
GetMetadata
()
const
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
Metadata
metadata
;
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
SerializedRequest
_descriptor_
;
metadata
.
descriptor
=
SerializedRequest
::
descriptor
()
;
metadata
.
reflection
=
NULL
;
metadata
.
reflection
=
NULL
;
return
metadata
;
return
metadata
;
}
}
...
...
src/brpc/serialized_request.h
View file @
40b13429
...
@@ -20,22 +20,12 @@
...
@@ -20,22 +20,12 @@
#ifndef BRPC_SERIALIZED_REQUEST_H
#ifndef BRPC_SERIALIZED_REQUEST_H
#define BRPC_SERIALIZED_REQUEST_H
#define BRPC_SERIALIZED_REQUEST_H
#include <string>
#include <google/protobuf/message.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_reflection.h>
#include "butil/iobuf.h"
#include "butil/iobuf.h"
#include "brpc/proto_base.pb.h"
namespace
brpc
{
namespace
brpc
{
// Internal implementation detail -- do not call these.
void
protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto
();
void
protobuf_AssignDesc_baidu_2frpc_2fserialized_5frequest_2eproto
();
void
protobuf_ShutdownFile_baidu_2frpc_2fserialized_5frequest_2eproto
();
class
SerializedRequest
:
public
::
google
::
protobuf
::
Message
{
class
SerializedRequest
:
public
::
google
::
protobuf
::
Message
{
public
:
public
:
SerializedRequest
();
SerializedRequest
();
...
@@ -49,7 +39,6 @@ public:
...
@@ -49,7 +39,6 @@ public:
}
}
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
SerializedRequest
&
default_instance
();
void
Swap
(
SerializedRequest
*
other
);
void
Swap
(
SerializedRequest
*
other
);
...
@@ -62,10 +51,12 @@ public:
...
@@ -62,10 +51,12 @@ public:
bool
IsInitialized
()
const
;
bool
IsInitialized
()
const
;
int
ByteSize
()
const
;
int
ByteSize
()
const
;
int
GetCachedSize
()
const
{
return
(
int
)
_serialized
.
size
();
}
int
GetCachedSize
()
const
{
return
(
int
)
_serialized
.
size
();
}
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
butil
::
IOBuf
&
serialized_data
()
{
return
_serialized
;
}
butil
::
IOBuf
&
serialized_data
()
{
return
_serialized
;
}
const
butil
::
IOBuf
&
serialized_data
()
const
{
return
_serialized
;
}
const
butil
::
IOBuf
&
serialized_data
()
const
{
return
_serialized
;
}
protected
:
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
private
:
private
:
bool
MergePartialFromCodedStream
(
bool
MergePartialFromCodedStream
(
::
google
::
protobuf
::
io
::
CodedInputStream
*
input
);
::
google
::
protobuf
::
io
::
CodedInputStream
*
input
);
...
@@ -81,13 +72,6 @@ private:
...
@@ -81,13 +72,6 @@ private:
private
:
private
:
butil
::
IOBuf
_serialized
;
butil
::
IOBuf
_serialized
;
friend
void
protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto
();
friend
void
protobuf_AssignDesc_baidu_2frpc_2fserialized_5frequest_2eproto
();
friend
void
protobuf_ShutdownFile_baidu_2frpc_2fserialized_5frequest_2eproto
();
void
InitAsDefaultInstance
();
static
SerializedRequest
*
default_instance_
;
};
};
}
// namespace brpc
}
// namespace brpc
...
...
src/brpc/thrift_message.cpp
View file @
40b13429
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include <algorithm>
#include <algorithm>
#include "butil/logging.h"
#include "butil/logging.h"
#include "brpc/details/controller_private_accessor.h"
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/coded_stream.h>
...
@@ -33,86 +32,11 @@
...
@@ -33,86 +32,11 @@
namespace
brpc
{
namespace
brpc
{
namespace
{
const
::
google
::
protobuf
::
Descriptor
*
ThriftFramedMessage_descriptor_
=
NULL
;
}
// namespace
void
protobuf_AssignDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
();
const
::
google
::
protobuf
::
FileDescriptor
*
file
=
::
google
::
protobuf
::
DescriptorPool
::
generated_pool
()
->
FindFileByName
(
"thrift_framed_message.proto"
);
GOOGLE_CHECK
(
file
!=
NULL
);
ThriftFramedMessage_descriptor_
=
file
->
message_type
(
0
);
}
namespace
{
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AssignDescriptors_once_
);
inline
void
protobuf_AssignDescriptorsOnce
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AssignDescriptors_once_
,
&
protobuf_AssignDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
);
}
void
protobuf_RegisterTypes
(
const
::
std
::
string
&
)
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedMessage
(
ThriftFramedMessage_descriptor_
,
&
ThriftFramedMessage
::
default_instance
());
}
}
// namespace
void
protobuf_ShutdownFile_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
()
{
delete
ThriftFramedMessage
::
default_instance_
;
}
void
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_impl
()
{
GOOGLE_PROTOBUF_VERIFY_VERSION
;
#if GOOGLE_PROTOBUF_VERSION >= 3002000
::
google
::
protobuf
::
internal
::
InitProtobufDefaults
();
#else
::
google
::
protobuf
::
protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto
();
#endif
::
google
::
protobuf
::
DescriptorPool
::
InternalAddGeneratedFile
(
"
\n\033
thrift_framed_message.proto
\022\004
brpc
\"\025\n\023
ThriftFramedMessage"
,
58
);
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedFile
(
"thrift_framed_message.proto"
,
&
protobuf_RegisterTypes
);
ThriftFramedMessage
::
default_instance_
=
new
ThriftFramedMessage
();
ThriftFramedMessage
::
default_instance_
->
InitAsDefaultInstance
();
::
google
::
protobuf
::
internal
::
OnShutdown
(
&
protobuf_ShutdownFile_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
);
}
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_once
);
void
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_once
,
&
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_impl
);
}
// Force AddDescriptors() to be called at static initialization time.
struct
StaticDescriptorInitializer_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
{
StaticDescriptorInitializer_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
();
}
}
static_descriptor_initializer_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_
;
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
ThriftFramedMessage
::
ThriftFramedMessage
()
ThriftFramedMessage
::
ThriftFramedMessage
()
:
::
google
::
protobuf
::
Message
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
SharedCtor
();
}
}
void
ThriftFramedMessage
::
InitAsDefaultInstance
()
{
}
void
ThriftFramedMessage
::
SharedCtor
()
{
void
ThriftFramedMessage
::
SharedCtor
()
{
field_id
=
THRIFT_INVALID_FID
;
field_id
=
THRIFT_INVALID_FID
;
_own_raw_instance
=
false
;
_own_raw_instance
=
false
;
...
@@ -127,23 +51,12 @@ ThriftFramedMessage::~ThriftFramedMessage() {
...
@@ -127,23 +51,12 @@ ThriftFramedMessage::~ThriftFramedMessage() {
}
}
void
ThriftFramedMessage
::
SharedDtor
()
{
void
ThriftFramedMessage
::
SharedDtor
()
{
if
(
this
!=
default_instance_
)
{
}
}
}
const
::
google
::
protobuf
::
Descriptor
*
ThriftFramedMessage
::
descriptor
()
{
const
::
google
::
protobuf
::
Descriptor
*
ThriftFramedMessage
::
descriptor
()
{
protobuf_AssignDescriptorsOnce
();
return
ThriftFramedMessageBase
::
descriptor
();
return
ThriftFramedMessage_descriptor_
;
}
}
const
ThriftFramedMessage
&
ThriftFramedMessage
::
default_instance
()
{
if
(
default_instance_
==
NULL
)
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
();
return
*
default_instance_
;
}
ThriftFramedMessage
*
ThriftFramedMessage
::
default_instance_
=
NULL
;
ThriftFramedMessage
*
ThriftFramedMessage
::
New
()
const
{
ThriftFramedMessage
*
ThriftFramedMessage
::
New
()
const
{
return
new
ThriftFramedMessage
;
return
new
ThriftFramedMessage
;
}
}
...
@@ -222,9 +135,8 @@ void ThriftFramedMessage::Swap(ThriftFramedMessage* other) {
...
@@ -222,9 +135,8 @@ void ThriftFramedMessage::Swap(ThriftFramedMessage* other) {
}
}
::
google
::
protobuf
::
Metadata
ThriftFramedMessage
::
GetMetadata
()
const
{
::
google
::
protobuf
::
Metadata
ThriftFramedMessage
::
GetMetadata
()
const
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
Metadata
metadata
;
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
ThriftFramedMessage
_descriptor_
;
metadata
.
descriptor
=
ThriftFramedMessage
::
descriptor
()
;
metadata
.
reflection
=
NULL
;
metadata
.
reflection
=
NULL
;
return
metadata
;
return
metadata
;
}
}
...
@@ -239,4 +151,3 @@ void ThriftStub::CallMethod(const char* method_name,
...
@@ -239,4 +151,3 @@ void ThriftStub::CallMethod(const char* method_name,
}
}
}
// namespace brpc
}
// namespace brpc
src/brpc/thrift_message.h
View file @
40b13429
...
@@ -20,20 +20,12 @@
...
@@ -20,20 +20,12 @@
#ifndef BRPC_THRIFT_MESSAGE_H
#ifndef BRPC_THRIFT_MESSAGE_H
#define BRPC_THRIFT_MESSAGE_H
#define BRPC_THRIFT_MESSAGE_H
#include <functional>
#include <google/protobuf/message.h>
#include <string>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_reflection.h>
#include "google/protobuf/descriptor.pb.h"
#include "butil/iobuf.h"
#include "butil/iobuf.h"
#include "butil/class_name.h"
#include "butil/class_name.h"
#include "brpc/channel_base.h"
#include "brpc/channel_base.h"
#include "brpc/controller.h"
#include "brpc/controller.h"
#include "brpc/proto_base.pb.h"
namespace
apache
{
namespace
apache
{
namespace
thrift
{
namespace
thrift
{
...
@@ -46,11 +38,6 @@ class TProtocol;
...
@@ -46,11 +38,6 @@ class TProtocol;
namespace
brpc
{
namespace
brpc
{
// Internal implementation detail -- do not call these.
void
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
();
void
protobuf_AssignDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
();
void
protobuf_ShutdownFile_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
();
class
ThriftStub
;
class
ThriftStub
;
static
const
int16_t
THRIFT_INVALID_FID
=
-
1
;
static
const
int16_t
THRIFT_INVALID_FID
=
-
1
;
...
@@ -92,7 +79,6 @@ public:
...
@@ -92,7 +79,6 @@ public:
ThriftFramedMessage
&
operator
=
(
const
ThriftFramedMessage
&
from
)
=
delete
;
ThriftFramedMessage
&
operator
=
(
const
ThriftFramedMessage
&
from
)
=
delete
;
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
ThriftFramedMessage
&
default_instance
();
void
Swap
(
ThriftFramedMessage
*
other
);
void
Swap
(
ThriftFramedMessage
*
other
);
...
@@ -113,19 +99,13 @@ public:
...
@@ -113,19 +99,13 @@ public:
::
google
::
protobuf
::
io
::
CodedOutputStream
*
output
)
const
;
::
google
::
protobuf
::
io
::
CodedOutputStream
*
output
)
const
;
::
google
::
protobuf
::
uint8
*
SerializeWithCachedSizesToArray
(
::
google
::
protobuf
::
uint8
*
output
)
const
;
::
google
::
protobuf
::
uint8
*
SerializeWithCachedSizesToArray
(
::
google
::
protobuf
::
uint8
*
output
)
const
;
int
GetCachedSize
()
const
{
return
ByteSize
();
}
int
GetCachedSize
()
const
{
return
ByteSize
();
}
protected
:
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
private
:
private
:
void
SharedCtor
();
void
SharedCtor
();
void
SharedDtor
();
void
SharedDtor
();
private
:
friend
void
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_impl
();
friend
void
protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
();
friend
void
protobuf_AssignDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
();
friend
void
protobuf_ShutdownFile_baidu_2frpc_2fthrift_framed_5fmessage_2eproto
();
void
InitAsDefaultInstance
();
static
ThriftFramedMessage
*
default_instance_
;
};
};
class
ThriftStub
{
class
ThriftStub
{
...
...
test/Makefile
View file @
40b13429
...
@@ -162,7 +162,7 @@ all: $(TEST_BINS)
...
@@ -162,7 +162,7 @@ all: $(TEST_BINS)
.PHONY
:
clean
.PHONY
:
clean
clean
:
clean_bins
clean
:
clean_bins
@
echo
"Cleaning"
@
echo
"Cleaning"
@
rm
-rf
$(TEST_BUTIL_OBJS)
$(TEST_BVAR_OBJS)
$(TEST_BTHREAD_OBJS)
$(TEST_BRPC_OBJS)
$(TEST_PROTO_OBJS)
@
rm
-rf
$(TEST_BUTIL_OBJS)
$(TEST_BVAR_OBJS)
$(TEST_BTHREAD_OBJS)
$(TEST_BRPC_OBJS)
$(TEST_PROTO_OBJS)
$
(
TEST_PROTO_SOURCES:.proto
=
.pb.h
)
$
(
TEST_PROTO_SOURCES:.proto
=
.pb.cc
)
@
$(MAKE)
-C
.. clean_debug
@
$(MAKE)
-C
.. clean_debug
.PHONY
:
clean_bins
.PHONY
:
clean_bins
...
...
tools/rpc_replay/rpc_replay.cpp
View file @
40b13429
...
@@ -150,21 +150,21 @@ static void* replay_thread(void* arg) {
...
@@ -150,21 +150,21 @@ static void* replay_thread(void* arg) {
continue
;
continue
;
}
}
brpc
::
Channel
*
chan
=
brpc
::
Channel
*
chan
=
chan_group
->
channel
(
sample
->
protocol_type
());
chan_group
->
channel
(
sample
->
meta
.
protocol_type
());
if
(
chan
==
NULL
)
{
if
(
chan
==
NULL
)
{
LOG
(
ERROR
)
<<
"No channel on protocol="
LOG
(
ERROR
)
<<
"No channel on protocol="
<<
sample
->
protocol_type
();
<<
sample
->
meta
.
protocol_type
();
continue
;
continue
;
}
}
brpc
::
Controller
*
cntl
=
new
brpc
::
Controller
;
brpc
::
Controller
*
cntl
=
new
brpc
::
Controller
;
req
.
Clear
();
req
.
Clear
();
cntl
->
reset_
rpc_dump_meta
(
sample_guard
.
release
());
cntl
->
reset_
sampled_request
(
sample_guard
.
release
());
if
(
sample
->
attachment_size
()
>
0
)
{
if
(
sample
->
meta
.
attachment_size
()
>
0
)
{
sample
->
request
.
cutn
(
sample
->
request
.
cutn
(
&
req
.
serialized_data
(),
&
req
.
serialized_data
(),
sample
->
request
.
size
()
-
sample
->
attachment_size
());
sample
->
request
.
size
()
-
sample
->
meta
.
attachment_size
());
cntl
->
request_attachment
()
=
sample
->
request
.
movable
();
cntl
->
request_attachment
()
=
sample
->
request
.
movable
();
}
else
{
}
else
{
req
.
serialized_data
()
=
sample
->
request
.
movable
();
req
.
serialized_data
()
=
sample
->
request
.
movable
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment