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
cc3de349
Commit
cc3de349
authored
Mar 25, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
health_check_using_rpc: add necessary logs
parent
4acdf923
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
12 deletions
+14
-12
controller.h
src/brpc/controller.h
+1
-1
socket.cpp
src/brpc/socket.cpp
+8
-6
socket.h
src/brpc/socket.h
+1
-1
brpc_load_balancer_unittest.cpp
test/brpc_load_balancer_unittest.cpp
+4
-4
No files found.
src/brpc/controller.h
View file @
cc3de349
...
...
@@ -118,7 +118,7 @@ friend int StreamCreate(StreamId*, Controller&, const StreamOptions*);
friend
int
StreamAccept
(
StreamId
*
,
Controller
&
,
const
StreamOptions
*
);
friend
void
policy
::
ProcessMongoRequest
(
InputMessageBase
*
);
friend
void
policy
::
ProcessThriftRequest
(
InputMessageBase
*
);
friend
class
On
HealthCheckRPC
Done
;
friend
class
On
AppHealthCheck
Done
;
friend
class
HealthCheckManager
;
// << Flags >>
static
const
uint32_t
FLAGS_IGNORE_EOVERCROWDED
=
1
;
...
...
src/brpc/socket.cpp
View file @
cc3de349
...
...
@@ -1008,10 +1008,10 @@ int HealthCheckChannel::Init(SocketId id, const ChannelOptions* options) {
return
0
;
}
class
On
HealthCheckRPC
Done
:
public
google
::
protobuf
::
Closure
{
class
On
AppHealthCheck
Done
:
public
google
::
protobuf
::
Closure
{
public
:
void
Run
()
{
std
::
unique_ptr
<
On
HealthCheckRPC
Done
>
self_guard
(
this
);
std
::
unique_ptr
<
On
AppHealthCheck
Done
>
self_guard
(
this
);
SocketUniquePtr
ptr
;
const
int
rc
=
Socket
::
AddressFailedAsWell
(
id
,
&
ptr
);
if
(
rc
<
0
)
{
...
...
@@ -1020,12 +1020,13 @@ public:
return
;
}
if
(
!
cntl
.
Failed
()
||
ptr
->
Failed
())
{
LOG_IF
(
INFO
,
!
cntl
.
Failed
())
<<
"AppRevived "
<<
ptr
->
remote_side
()
<<
FLAGS_health_check_path
;
ptr
->
_ninflight_app_health_check
.
fetch_sub
(
1
,
butil
::
memory_order_relaxed
);
return
;
}
RPC_VLOG
<<
"Fail to health check using rpc, error="
<<
cntl
.
ErrorText
();
RPC_VLOG
<<
"Fail to AppCheck, "
<<
cntl
.
ErrorText
();
bthread_usleep
(
interval_s
*
1000000
);
cntl
.
Reset
();
cntl
.
http_request
().
uri
()
=
FLAGS_health_check_path
;
...
...
@@ -1049,11 +1050,12 @@ public:
<<
" was abandoned during health checking"
;
return
;
}
OnHealthCheckRPCDone
*
done
=
new
OnHealthCheckRPCDone
;
LOG
(
INFO
)
<<
"AppChecking "
<<
ptr
->
remote_side
()
<<
FLAGS_health_check_path
;
OnAppHealthCheckDone
*
done
=
new
OnAppHealthCheckDone
;
done
->
id
=
id
;
done
->
interval_s
=
check_interval_s
;
brpc
::
ChannelOptions
options
;
options
.
protocol
=
"http"
;
options
.
protocol
=
PROTOCOL_HTTP
;
options
.
max_retry
=
0
;
options
.
timeout_ms
=
FLAGS_health_check_timeout_ms
;
if
(
done
->
channel
.
Init
(
id
,
&
options
)
!=
0
)
{
...
...
src/brpc/socket.h
View file @
cc3de349
...
...
@@ -186,7 +186,7 @@ friend class policy::ConsistentHashingLoadBalancer;
friend
class
policy
::
RtmpContext
;
friend
class
schan
::
ChannelBalancer
;
friend
class
HealthCheckTask
;
friend
class
On
HealthCheckRPC
Done
;
friend
class
On
AppHealthCheck
Done
;
friend
class
HealthCheckManager
;
friend
class
policy
::
H2GlobalStreamCreator
;
class
SharedPart
;
...
...
test/brpc_load_balancer_unittest.cpp
View file @
cc3de349
...
...
@@ -732,7 +732,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) {
brpc
::
SocketUniquePtr
ptr
;
ASSERT_EQ
(
0
,
brpc
::
Socket
::
Address
(
ids
[
0
].
id
,
&
ptr
));
ptr
->
_ninflight_app_
level_
health_check
.
store
(
1
,
butil
::
memory_order_relaxed
);
ptr
->
_ninflight_app_health_check
.
store
(
1
,
butil
::
memory_order_relaxed
);
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
brpc
::
SocketUniquePtr
ptr
;
brpc
::
LoadBalancer
::
SelectIn
in
=
{
0
,
false
,
false
,
0u
,
NULL
};
...
...
@@ -743,7 +743,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) {
}
ASSERT_EQ
(
0
,
brpc
::
Socket
::
Address
(
ids
[
1
].
id
,
&
ptr
));
ptr
->
_ninflight_app_
level_
health_check
.
store
(
1
,
butil
::
memory_order_relaxed
);
ptr
->
_ninflight_app_health_check
.
store
(
1
,
butil
::
memory_order_relaxed
);
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
brpc
::
SocketUniquePtr
ptr
;
brpc
::
LoadBalancer
::
SelectIn
in
=
{
0
,
false
,
false
,
0u
,
NULL
};
...
...
@@ -753,9 +753,9 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) {
}
ASSERT_EQ
(
0
,
brpc
::
Socket
::
Address
(
ids
[
0
].
id
,
&
ptr
));
ptr
->
_ninflight_app_
level_
health_check
.
store
(
0
,
butil
::
memory_order_relaxed
);
ptr
->
_ninflight_app_health_check
.
store
(
0
,
butil
::
memory_order_relaxed
);
ASSERT_EQ
(
0
,
brpc
::
Socket
::
Address
(
ids
[
1
].
id
,
&
ptr
));
ptr
->
_ninflight_app_
level_
health_check
.
store
(
0
,
butil
::
memory_order_relaxed
);
ptr
->
_ninflight_app_health_check
.
store
(
0
,
butil
::
memory_order_relaxed
);
// After reset health check state, the lb should work fine
bool
get_server1
=
false
;
bool
get_server2
=
false
;
...
...
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