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
ba77db4d
Commit
ba77db4d
authored
Nov 14, 2018
by
TousakaRin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify variable name
parent
09d8247a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
circuit_breaker.cpp
src/brpc/circuit_breaker.cpp
+9
-9
circuit_breaker.h
src/brpc/circuit_breaker.h
+2
-2
No files found.
src/brpc/circuit_breaker.cpp
View file @
ba77db4d
...
...
@@ -63,8 +63,8 @@ CircuitBreaker::EmaErrorRecorder::EmaErrorRecorder(int window_size,
:
_window_size
(
window_size
)
,
_max_error_percent
(
max_error_percent
)
,
_smooth
(
std
::
pow
(
EPSILON
,
1.0
/
window_size
))
,
_sample_count_
of_first_window
(
0
)
,
_error_count_
of_first_window
(
0
)
,
_sample_count_
when_initializing
(
0
)
,
_error_count_
when_initializing
(
0
)
,
_ema_error_cost
(
0
)
,
_ema_latency
(
0
)
{
}
...
...
@@ -83,15 +83,15 @@ bool CircuitBreaker::EmaErrorRecorder::OnCallEnd(int error_code,
// When the window is initializing, use error_rate to determine
// if it needs to be isolated.
if
(
_sample_count_
of_first_window
.
load
(
butil
::
memory_order_relaxed
)
<
_window_size
&&
_sample_count_
of_first_window
.
fetch_add
(
1
,
butil
::
memory_order_relaxed
)
<
_window_size
)
{
if
(
_sample_count_
when_initializing
.
load
(
butil
::
memory_order_relaxed
)
<
_window_size
&&
_sample_count_
when_initializing
.
fetch_add
(
1
,
butil
::
memory_order_relaxed
)
<
_window_size
)
{
if
(
error_code
!=
0
)
{
const
int32_t
error_count
=
_error_count_
of_first_window
.
fetch_add
(
1
,
butil
::
memory_order_relaxed
);
_error_count_
when_initializing
.
fetch_add
(
1
,
butil
::
memory_order_relaxed
);
return
error_count
<
_window_size
*
_max_error_percent
/
100
;
}
// Because once OnCallEnd returned false, the node will be ioslated soon,
so
//
it is OK to return true for any sample which error_code equals to 0
.
// Because once OnCallEnd returned false, the node will be ioslated soon,
//
so when error_code=0, we no longer check the error count
.
return
true
;
}
...
...
@@ -99,8 +99,8 @@ bool CircuitBreaker::EmaErrorRecorder::OnCallEnd(int error_code,
}
void
CircuitBreaker
::
EmaErrorRecorder
::
Reset
()
{
_sample_count_
of_first_window
.
store
(
0
,
butil
::
memory_order_relaxed
);
_error_count_
of_first_window
.
store
(
0
,
butil
::
memory_order_relaxed
);
_sample_count_
when_initializing
.
store
(
0
,
butil
::
memory_order_relaxed
);
_error_count_
when_initializing
.
store
(
0
,
butil
::
memory_order_relaxed
);
_ema_error_cost
.
store
(
0
,
butil
::
memory_order_relaxed
);
_ema_latency
.
store
(
0
,
butil
::
memory_order_relaxed
);
}
...
...
src/brpc/circuit_breaker.h
View file @
ba77db4d
...
...
@@ -74,8 +74,8 @@ private:
const
int
_max_error_percent
;
const
double
_smooth
;
butil
::
atomic
<
int32_t
>
_sample_count_
of_first_window
;
butil
::
atomic
<
int32_t
>
_error_count_
of_first_window
;
butil
::
atomic
<
int32_t
>
_sample_count_
when_initializing
;
butil
::
atomic
<
int32_t
>
_error_count_
when_initializing
;
butil
::
atomic
<
int64_t
>
_ema_error_cost
;
butil
::
atomic
<
int64_t
>
_ema_latency
;
};
...
...
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