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
4acdf923
Commit
4acdf923
authored
Mar 25, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
health_check_using_rpc: replace app_level_health_check with app_health_check
parent
ddcb0749
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
20 additions
and
20 deletions
+20
-20
channel.cpp
src/brpc/channel.cpp
+1
-1
controller.cpp
src/brpc/controller.cpp
+1
-1
consistent_hashing_load_balancer.cpp
src/brpc/policy/consistent_hashing_load_balancer.cpp
+1
-1
dynpart_load_balancer.cpp
src/brpc/policy/dynpart_load_balancer.cpp
+1
-1
locality_aware_load_balancer.cpp
src/brpc/policy/locality_aware_load_balancer.cpp
+1
-1
randomized_load_balancer.cpp
src/brpc/policy/randomized_load_balancer.cpp
+1
-1
round_robin_load_balancer.cpp
src/brpc/policy/round_robin_load_balancer.cpp
+1
-1
weighted_round_robin_load_balancer.cpp
src/brpc/policy/weighted_round_robin_load_balancer.cpp
+1
-1
socket.cpp
src/brpc/socket.cpp
+8
-8
socket.h
src/brpc/socket.h
+2
-2
socket_inl.h
src/brpc/socket_inl.h
+2
-2
No files found.
src/brpc/channel.cpp
View file @
4acdf923
...
...
@@ -558,7 +558,7 @@ int Channel::CheckHealth() {
SocketUniquePtr
ptr
;
if
(
Socket
::
Address
(
_server_id
,
&
ptr
)
==
0
&&
!
ptr
->
IsLogOff
()
&&
!
ptr
->
IsApp
Level
HealthCheck
())
{
!
ptr
->
IsAppHealthCheck
())
{
return
0
;
}
return
-
1
;
...
...
src/brpc/controller.cpp
View file @
4acdf923
...
...
@@ -987,7 +987,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) {
// of the backup call.
const
int
rc
=
Socket
::
Address
(
_single_server_id
,
&
tmp_sock
);
if
(
rc
!=
0
||
tmp_sock
->
IsLogOff
()
||
(
!
is_health_check_call
()
&&
tmp_sock
->
IsApp
Level
HealthCheck
()))
{
(
!
is_health_check_call
()
&&
tmp_sock
->
IsAppHealthCheck
()))
{
SetFailed
(
EHOSTDOWN
,
"Not connected to %s yet, server_id=%"
PRIu64
,
endpoint2str
(
_remote_side
).
c_str
(),
_single_server_id
);
tmp_sock
.
reset
();
// Release ref ASAP
...
...
src/brpc/policy/consistent_hashing_load_balancer.cpp
View file @
4acdf923
...
...
@@ -222,7 +222,7 @@ int ConsistentHashingLoadBalancer::SelectServer(
||
!
ExcludedServers
::
IsExcluded
(
in
.
excluded
,
choice
->
server_sock
.
id
))
&&
Socket
::
Address
(
choice
->
server_sock
.
id
,
out
->
ptr
)
==
0
&&
!
(
*
out
->
ptr
)
->
IsLogOff
()
&&
!
(
*
out
->
ptr
)
->
IsApp
Level
HealthCheck
())
{
&&
!
(
*
out
->
ptr
)
->
IsAppHealthCheck
())
{
return
0
;
}
else
{
if
(
++
choice
==
s
->
end
())
{
...
...
src/brpc/policy/dynpart_load_balancer.cpp
View file @
4acdf923
...
...
@@ -123,7 +123,7 @@ int DynPartLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) {
const
SocketId
id
=
s
->
server_list
[
i
].
id
;
if
((
!
exclusion
||
!
ExcludedServers
::
IsExcluded
(
in
.
excluded
,
id
))
&&
Socket
::
Address
(
id
,
&
ptrs
[
nptr
].
first
)
==
0
&&
!
(
*
out
->
ptr
)
->
IsApp
Level
HealthCheck
())
{
&&
!
(
*
out
->
ptr
)
->
IsAppHealthCheck
())
{
int
w
=
schan
::
GetSubChannelWeight
(
ptrs
[
nptr
].
first
->
user
());
total_weight
+=
w
;
if
(
nptr
<
8
)
{
...
...
src/brpc/policy/locality_aware_load_balancer.cpp
View file @
4acdf923
...
...
@@ -304,7 +304,7 @@ int LocalityAwareLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out)
}
}
else
if
(
Socket
::
Address
(
info
.
server_id
,
out
->
ptr
)
==
0
&&
!
(
*
out
->
ptr
)
->
IsLogOff
()
&&
!
(
*
out
->
ptr
)
->
IsApp
Level
HealthCheck
())
{
&&
!
(
*
out
->
ptr
)
->
IsAppHealthCheck
())
{
if
((
ntry
+
1
)
==
n
// Instead of fail with EHOSTDOWN, we prefer
// choosing the server again.
||
!
ExcludedServers
::
IsExcluded
(
in
.
excluded
,
info
.
server_id
))
{
...
...
src/brpc/policy/randomized_load_balancer.cpp
View file @
4acdf923
...
...
@@ -119,7 +119,7 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) {
||
!
ExcludedServers
::
IsExcluded
(
in
.
excluded
,
id
))
&&
Socket
::
Address
(
id
,
out
->
ptr
)
==
0
&&
!
(
*
out
->
ptr
)
->
IsLogOff
()
&&
!
(
*
out
->
ptr
)
->
IsApp
Level
HealthCheck
())
{
&&
!
(
*
out
->
ptr
)
->
IsAppHealthCheck
())
{
// We found an available server
return
0
;
}
...
...
src/brpc/policy/round_robin_load_balancer.cpp
View file @
4acdf923
...
...
@@ -123,7 +123,7 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) {
||
!
ExcludedServers
::
IsExcluded
(
in
.
excluded
,
id
))
&&
Socket
::
Address
(
id
,
out
->
ptr
)
==
0
&&
!
(
*
out
->
ptr
)
->
IsLogOff
()
&&
!
(
*
out
->
ptr
)
->
IsApp
Level
HealthCheck
())
{
&&
!
(
*
out
->
ptr
)
->
IsAppHealthCheck
())
{
s
.
tls
()
=
tls
;
return
0
;
}
...
...
src/brpc/policy/weighted_round_robin_load_balancer.cpp
View file @
4acdf923
...
...
@@ -181,7 +181,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut*
if
(
!
ExcludedServers
::
IsExcluded
(
in
.
excluded
,
server_id
)
&&
Socket
::
Address
(
server_id
,
out
->
ptr
)
==
0
&&
!
(
*
out
->
ptr
)
->
IsLogOff
()
&&
!
(
*
out
->
ptr
)
->
IsApp
Level
HealthCheck
())
{
&&
!
(
*
out
->
ptr
)
->
IsAppHealthCheck
())
{
// update tls.
tls
.
remain_server
=
tls_temp
.
remain_server
;
tls
.
position
=
tls_temp
.
position
;
...
...
src/brpc/socket.cpp
View file @
4acdf923
...
...
@@ -483,7 +483,7 @@ Socket::Socket(Forbidden)
,
_epollout_butex
(
NULL
)
,
_write_head
(
NULL
)
,
_stream_set
(
NULL
)
,
_ninflight_app_
level_
health_check
(
0
)
,
_ninflight_app_health_check
(
0
)
{
CreateVarsOnce
();
pthread_mutex_init
(
&
_id_wait_list_mutex
,
NULL
);
...
...
@@ -666,7 +666,7 @@ int Socket::Create(const SocketOptions& options, SocketId* id) {
m
->
_error_code
=
0
;
m
->
_error_text
.
clear
();
m
->
_agent_socket_id
.
store
(
INVALID_SOCKET_ID
,
butil
::
memory_order_relaxed
);
m
->
_ninflight_app_
level_
health_check
.
store
(
0
,
butil
::
memory_order_relaxed
);
m
->
_ninflight_app_health_check
.
store
(
0
,
butil
::
memory_order_relaxed
);
// NOTE: last two params are useless in bthread > r32787
const
int
rc
=
bthread_id_list_init
(
&
m
->
_id_wait_list
,
512
,
512
);
if
(
rc
)
{
...
...
@@ -1020,7 +1020,7 @@ public:
return
;
}
if
(
!
cntl
.
Failed
()
||
ptr
->
Failed
())
{
ptr
->
_ninflight_app_
level_
health_check
.
fetch_sub
(
ptr
->
_ninflight_app_health_check
.
fetch_sub
(
1
,
butil
::
memory_order_relaxed
);
return
;
}
...
...
@@ -1058,7 +1058,7 @@ public:
options
.
timeout_ms
=
FLAGS_health_check_timeout_ms
;
if
(
done
->
channel
.
Init
(
id
,
&
options
)
!=
0
)
{
LOG
(
WARNING
)
<<
"Fail to init health check channel to SocketId="
<<
id
;
ptr
->
_ninflight_app_
level_
health_check
.
fetch_sub
(
ptr
->
_ninflight_app_health_check
.
fetch_sub
(
1
,
butil
::
memory_order_relaxed
);
delete
done
;
return
;
...
...
@@ -1115,12 +1115,12 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) {
s_vars
->
channel_conn
<<
-
1
;
}
if
(
!
FLAGS_health_check_path
.
empty
())
{
ptr
->
_ninflight_app_
level_
health_check
.
fetch_add
(
ptr
->
_ninflight_app_health_check
.
fetch_add
(
1
,
butil
::
memory_order_relaxed
);
}
ptr
->
Revive
();
ptr
->
_hc_count
=
0
;
if
(
ptr
->
IsApp
Level
HealthCheck
())
{
if
(
ptr
->
IsAppHealthCheck
())
{
HealthCheckManager
::
StartCheck
(
_id
,
ptr
->
_health_check_interval_s
);
}
return
false
;
...
...
@@ -2303,8 +2303,8 @@ void Socket::DebugSocket(std::ostream& os, SocketId id) {
<<
"
\n
auth_context="
<<
ptr
->
_auth_context
<<
"
\n
logoff_flag="
<<
ptr
->
_logoff_flag
.
load
(
butil
::
memory_order_relaxed
)
<<
"
\n
recycle_flag="
<<
ptr
->
_recycle_flag
.
load
(
butil
::
memory_order_relaxed
)
<<
"
\n
ninflight_app_
level_
health_check="
<<
ptr
->
_ninflight_app_
level_
health_check
.
load
(
butil
::
memory_order_relaxed
)
<<
"
\n
ninflight_app_health_check="
<<
ptr
->
_ninflight_app_health_check
.
load
(
butil
::
memory_order_relaxed
)
<<
"
\n
agent_socket_id="
;
const
SocketId
asid
=
ptr
->
_agent_socket_id
.
load
(
butil
::
memory_order_relaxed
);
if
(
asid
!=
INVALID_SOCKET_ID
)
{
...
...
src/brpc/socket.h
View file @
4acdf923
...
...
@@ -354,7 +354,7 @@ public:
// Check Whether the state is in app level health checking state or
// not, which means this socket would not be selected in further
// user request until app level check succeed.
bool
IsApp
Level
HealthCheck
()
const
;
bool
IsAppHealthCheck
()
const
;
// Start to process edge-triggered events from the fd.
// This function does not block caller.
...
...
@@ -798,7 +798,7 @@ private:
butil
::
Mutex
_stream_mutex
;
std
::
set
<
StreamId
>
*
_stream_set
;
butil
::
atomic
<
int64_t
>
_ninflight_app_
level_
health_check
;
butil
::
atomic
<
int64_t
>
_ninflight_app_health_check
;
};
}
// namespace brpc
...
...
src/brpc/socket_inl.h
View file @
4acdf923
...
...
@@ -245,8 +245,8 @@ inline bool Socket::IsLogOff() const {
return
_logoff_flag
.
load
(
butil
::
memory_order_relaxed
);
}
inline
bool
Socket
::
IsApp
Level
HealthCheck
()
const
{
return
(
_ninflight_app_
level_
health_check
.
load
(
butil
::
memory_order_relaxed
)
!=
0
);
inline
bool
Socket
::
IsAppHealthCheck
()
const
{
return
(
_ninflight_app_health_check
.
load
(
butil
::
memory_order_relaxed
)
!=
0
);
}
static
const
uint32_t
EOF_FLAG
=
(
1
<<
31
);
...
...
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