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
fd34cbd6
Commit
fd34cbd6
authored
Jun 21, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert changes related to SampleRequest
parent
0a7432f0
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
27 deletions
+35
-27
controller.cpp
src/brpc/controller.cpp
+5
-5
controller.h
src/brpc/controller.h
+5
-5
baidu_rpc_protocol.cpp
src/brpc/policy/baidu_rpc_protocol.cpp
+4
-4
hulu_pbrpc_protocol.cpp
src/brpc/policy/hulu_pbrpc_protocol.cpp
+5
-5
sofa_pbrpc_protocol.cpp
src/brpc/policy/sofa_pbrpc_protocol.cpp
+3
-3
rpc_dump.h
src/brpc/rpc_dump.h
+11
-3
rpc_dump.proto
src/brpc/rpc_dump.proto
+1
-1
rpc_replay.cpp
tools/rpc_replay/rpc_replay.cpp
+1
-1
No files found.
src/brpc/controller.cpp
View file @
fd34cbd6
...
...
@@ -159,7 +159,7 @@ void Controller::ResetNonPods() {
_server
->
_session_local_data_pool
->
Return
(
_session_local_data
);
}
_mongo_session_data
.
reset
();
delete
_
sampled_request
;
delete
_
rpc_dump_meta
;
if
(
!
is_used_by_rpc
()
&&
_correlation_id
!=
INVALID_BTHREAD_ID
)
{
CHECK_NE
(
EPERM
,
bthread_id_cancel
(
_correlation_id
));
...
...
@@ -213,7 +213,7 @@ void Controller::ResetPods() {
_server
=
NULL
;
_oncancel_id
=
INVALID_BTHREAD_ID
;
_auth_context
=
NULL
;
_
sampled_request
=
NULL
;
_
rpc_dump_meta
=
NULL
;
_request_protocol
=
PROTOCOL_UNKNOWN
;
_max_retry
=
UNSET_MAGIC_NUM
;
_retry_policy
=
NULL
;
...
...
@@ -1331,9 +1331,9 @@ void WebEscape(const std::string& source, std::string* output) {
}
}
void
Controller
::
reset_
sampled_request
(
SampledRequest
*
req
)
{
delete
_
sampled_request
;
_
sampled_request
=
req
;
void
Controller
::
reset_
rpc_dump_meta
(
RpcDumpMeta
*
meta
)
{
delete
_
rpc_dump_meta
;
_
rpc_dump_meta
=
meta
;
}
void
Controller
::
set_stream_creator
(
StreamCreator
*
sc
)
{
...
...
src/brpc/controller.h
View file @
fd34cbd6
...
...
@@ -63,7 +63,7 @@ class SharedLoadBalancer;
class
ExcludedServers
;
class
RPCSender
;
class
StreamSettings
;
class
SampledRequest
;
class
RpcDumpMeta
;
class
MongoContext
;
class
RetryPolicy
;
class
InputMessageBase
;
...
...
@@ -258,10 +258,10 @@ public:
int
sub_count
()
const
;
const
Controller
*
sub
(
int
index
)
const
;
// Get/own
SampledRquest
for sending dumped requests.
// Get/own
RpcDumpMeta
for sending dumped requests.
// Deleted along with controller.
void
reset_
sampled_request
(
SampledRequest
*
req
);
const
SampledRequest
*
sampled_request
()
{
return
_sampled_request
;
}
void
reset_
rpc_dump_meta
(
RpcDumpMeta
*
meta
);
const
RpcDumpMeta
*
rpc_dump_meta
()
{
return
_rpc_dump_meta
;
}
// Attach a StreamCreator to this RPC. Notice that the ownership of sc has
// been transferred to cntl, and sc->DestroyStreamCreator() would be called
...
...
@@ -672,7 +672,7 @@ private:
bthread_id_t
_oncancel_id
;
const
AuthContext
*
_auth_context
;
// Authentication result
butil
::
intrusive_ptr
<
MongoContext
>
_mongo_session_data
;
SampledRequest
*
_sampled_request
;
RpcDumpMeta
*
_rpc_dump_meta
;
ProtocolType
_request_protocol
;
// Some of them are copied from `Channel' which might be destroyed
...
...
src/brpc/policy/baidu_rpc_protocol.cpp
View file @
fd34cbd6
...
...
@@ -636,11 +636,11 @@ void PackRpcRequest(butil::IOBuf* req_buf,
method
->
service
()
->
name
());
request_meta
->
set_method_name
(
method
->
name
());
meta
.
set_compress_type
(
cntl
->
request_compress_type
());
}
else
if
(
cntl
->
sampled_request
())
{
}
else
if
(
cntl
->
rpc_dump_meta
())
{
// Replaying. Keep service-name as the one seen by server.
request_meta
->
set_service_name
(
cntl
->
sampled_request
()
->
meta
.
service_name
());
request_meta
->
set_method_name
(
cntl
->
sampled_request
()
->
meta
.
method_name
());
meta
.
set_compress_type
(
cntl
->
sampled_request
()
->
meta
.
compress_type
());
request_meta
->
set_service_name
(
cntl
->
rpc_dump_meta
()
->
meta
.
service_name
());
request_meta
->
set_method_name
(
cntl
->
rpc_dump_meta
()
->
meta
.
method_name
());
meta
.
set_compress_type
(
cntl
->
rpc_dump_meta
()
->
meta
.
compress_type
());
}
else
{
return
cntl
->
SetFailed
(
ENOMETHOD
,
"%s.method is NULL"
,
__FUNCTION__
);
}
...
...
src/brpc/policy/hulu_pbrpc_protocol.cpp
View file @
fd34cbd6
...
...
@@ -639,13 +639,13 @@ void PackHuluRequest(butil::IOBuf* req_buf,
meta
.
set_service_name
(
method
->
service
()
->
name
());
meta
.
set_method_index
(
method
->
index
());
meta
.
set_compress_type
(
CompressType2Hulu
(
cntl
->
request_compress_type
()));
}
else
if
(
cntl
->
sampled_request
())
{
}
else
if
(
cntl
->
rpc_dump_meta
())
{
// Replaying. Keep service-name as the one seen by server.
meta
.
set_service_name
(
cntl
->
sampled_request
()
->
meta
.
service_name
());
meta
.
set_method_index
(
cntl
->
sampled_request
()
->
meta
.
method_index
());
meta
.
set_service_name
(
cntl
->
rpc_dump_meta
()
->
meta
.
service_name
());
meta
.
set_method_index
(
cntl
->
rpc_dump_meta
()
->
meta
.
method_index
());
meta
.
set_compress_type
(
CompressType2Hulu
(
cntl
->
sampled_request
()
->
meta
.
compress_type
()));
meta
.
set_user_data
(
cntl
->
sampled_request
()
->
meta
.
user_data
());
CompressType2Hulu
(
cntl
->
rpc_dump_meta
()
->
meta
.
compress_type
()));
meta
.
set_user_data
(
cntl
->
rpc_dump_meta
()
->
meta
.
user_data
());
}
else
{
return
cntl
->
SetFailed
(
ENOMETHOD
,
"method is NULL"
);
}
...
...
src/brpc/policy/sofa_pbrpc_protocol.cpp
View file @
fd34cbd6
...
...
@@ -545,11 +545,11 @@ void PackSofaRequest(butil::IOBuf* req_buf,
if
(
method
)
{
meta
.
set_method
(
method
->
full_name
());
meta
.
set_compress_type
(
CompressType2Sofa
(
cntl
->
request_compress_type
()));
}
else
if
(
cntl
->
sampled_request
())
{
}
else
if
(
cntl
->
rpc_dump_meta
())
{
// Replaying.
meta
.
set_method
(
cntl
->
sampled_request
()
->
meta
.
method_name
());
meta
.
set_method
(
cntl
->
rpc_dump_meta
()
->
meta
.
method_name
());
meta
.
set_compress_type
(
CompressType2Sofa
(
cntl
->
sampled_request
()
->
meta
.
compress_type
()));
CompressType2Sofa
(
cntl
->
rpc_dump_meta
()
->
meta
.
compress_type
()));
}
else
{
return
cntl
->
SetFailed
(
ENOMETHOD
,
"method is NULL"
);
}
...
...
src/brpc/rpc_dump.h
View file @
fd34cbd6
...
...
@@ -21,7 +21,7 @@
#include "butil/iobuf.h" // IOBuf
#include "butil/files/file_path.h" // FilePath
#include "bvar/collector.h"
#include "brpc/rpc_dump.pb.h"
// RpcDumpMeta
#include "brpc/rpc_dump.pb.h"
// RpcDumpMetaProto
namespace
butil
{
class
FileEnumerator
;
...
...
@@ -46,9 +46,17 @@ DECLARE_bool(rpc_dump);
// In practice, sampled requests are just small fraction of all requests.
// The overhead of sampling should be negligible for overall performance.
struct
SampledRequest
:
public
bvar
::
Collected
{
// According to
// https://developers.google.com/protocol-buffers/docs/cpptutorial#parsing-and-serialization,
// we use combination instead of inheritance.
class
RpcDumpMeta
{
public
:
RpcDumpMetaProto
meta
;
};
struct
SampledRequest
:
public
bvar
::
Collected
,
public
RpcDumpMeta
{
butil
::
IOBuf
request
;
RpcDumpMeta
meta
;
// Implement methods of Sampled.
void
dump_and_destroy
(
size_t
round
)
override
;
...
...
src/brpc/rpc_dump.proto
View file @
fd34cbd6
...
...
@@ -3,7 +3,7 @@ import "brpc/options.proto";
package
brpc
;
message
RpcDumpMeta
{
message
RpcDumpMeta
Proto
{
// baidu_std, hulu_pbrpc
optional
string
service_name
=
1
;
...
...
tools/rpc_replay/rpc_replay.cpp
View file @
fd34cbd6
...
...
@@ -157,7 +157,7 @@ static void* replay_thread(void* arg) {
brpc
::
Controller
*
cntl
=
new
brpc
::
Controller
;
req
.
Clear
();
cntl
->
reset_
sampled_request
(
sample_guard
.
release
());
cntl
->
reset_
rpc_dump_meta
(
sample_guard
.
release
());
if
(
sample
->
meta
.
attachment_size
()
>
0
)
{
sample
->
request
.
cutn
(
&
req
.
serialized_data
(),
...
...
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