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
3541f089
Commit
3541f089
authored
Jun 29, 2018
by
TousakaRin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix unit-test
parent
78534f7a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
29 deletions
+43
-29
status_service.cpp
src/brpc/builtin/status_service.cpp
+1
-1
method_status.cpp
src/brpc/details/method_status.cpp
+12
-1
method_status.h
src/brpc/details/method_status.h
+7
-2
gradient_concurrency_limiter.cpp
src/brpc/policy/gradient_concurrency_limiter.cpp
+1
-1
server.cpp
src/brpc/server.cpp
+21
-22
server.h
src/brpc/server.h
+1
-2
No files found.
src/brpc/builtin/status_service.cpp
View file @
3541f089
...
...
@@ -160,7 +160,7 @@ void StatusService::default_method(::google::protobuf::RpcController* cntl_base,
}
const
MethodStatus
*
mp_status
=
mp
->
status
;
if
(
NULL
!=
mp_status
&&
mp_status
->
max_concurrency
()
>
0
)
{
os
<<
" max_concurrency="
<<
mp
->
status
->
max_concurrency
();
os
<<
" max_concurrency="
<<
mp
_
status
->
max_concurrency
();
}
}
os
<<
"</h4>
\n
"
;
...
...
src/brpc/details/method_status.cpp
View file @
3541f089
...
...
@@ -29,7 +29,18 @@ MethodStatus::MethodStatus()
:
_cl
(
NULL
)
,
_nprocessing_bvar
(
cast_nprocessing
,
&
_nprocessing
)
,
_nrefused_per_second
(
&
_nrefused_bvar
,
1
)
,
_nprocessing
(
0
)
{}
,
_nprocessing
(
0
)
{
const
ConcurrencyLimiter
*
cl
=
ConcurrencyLimiterExtension
()
->
Find
(
"constant"
);
if
(
NULL
==
cl
)
{
LOG
(
FATAL
)
<<
"Fail to find ConcurrentLimiter by `constant`"
;
}
ConcurrencyLimiter
*
cl_copy
=
cl
->
New
();
if
(
NULL
==
cl_copy
)
{
LOG
(
FATAL
)
<<
"Fail to new ConcurrencyLimiter"
;
}
_cl
=
cl_copy
;
}
MethodStatus
::~
MethodStatus
()
{
if
(
_cl
)
{
...
...
src/brpc/details/method_status.h
View file @
3541f089
...
...
@@ -25,7 +25,6 @@
namespace
brpc
{
class
Server
;
class
Controller
;
// Record accessing stats of a method.
class
MethodStatus
:
public
Describable
{
...
...
@@ -58,10 +57,16 @@ public:
}
int
&
max_concurrency
()
{
return
_cl
->
MaxConcurrency
();
}
void
ResetConcurrencyLimiter
(
ConcurrencyLimiter
*
cl
)
{
if
(
_cl
)
{
_cl
->
Destroy
();
}
_cl
=
cl
;
}
private
:
friend
class
ScopedMethodStatus
;
friend
class
Server
;
DISALLOW_COPY_AND_ASSIGN
(
MethodStatus
);
void
OnError
();
...
...
src/brpc/policy/gradient_concurrency_limiter.cpp
View file @
3541f089
...
...
@@ -38,7 +38,7 @@ DEFINE_int32(gradient_cl_min_sample_count, 100,
DEFINE_int32
(
gradient_cl_adjust_smooth
,
50
,
"Smooth coefficient for adjust the max concurrency, the value is 0-99,"
"the larger the value, the smaller the amount of each change"
);
DEFINE_int32
(
gradient_cl_initial_max_concurrency
,
6
00
,
DEFINE_int32
(
gradient_cl_initial_max_concurrency
,
4
00
,
"Initial max concurrency for grandient concurrency limiter"
);
DEFINE_bool
(
gradient_cl_enable_error_punish
,
true
,
"Whether to consider failed requests when calculating maximum concurrency"
);
...
...
src/brpc/server.cpp
View file @
3541f089
...
...
@@ -889,33 +889,32 @@ int Server::StartInternal(const butil::ip_t& ip,
LOG
(
FATAL
)
<<
"Fail to new ConcurrencyLimiter"
;
}
_cl
=
cl_copy
;
if
(
_options
.
max_concurrency
==
"constant"
)
{
_cl
->
MaxConcurrency
()
=
_options
.
max_concurrency
;
}
else
{
_cl
->
MaxConcurrency
()
=
0
;
}
for
(
MethodMap
::
iterator
it
=
_method_map
.
begin
();
it
!=
_method_map
.
end
();
++
it
)
{
if
(
NULL
!=
it
->
second
.
status
->
_cl
)
{
continue
;
}
const
ConcurrencyLimiter
*
cl
=
NULL
;
const
std
::
string
cl_name
=
it
->
second
.
is_builtin_service
?
"constant"
:
_options
.
max_concurrency
.
name
();
cl
=
ConcurrencyLimiterExtension
()
->
Find
(
cl_name
.
c_str
());
if
(
NULL
==
cl
)
{
LOG
(
FATAL
)
<<
"Fail to find ConcurrencyLimiter by `"
<<
_options
.
max_concurrency
.
name
()
<<
'`'
;
return
-
1
;
}
ConcurrencyLimiter
*
cl_copy
=
cl
->
New
();
if
(
NULL
==
cl_copy
)
{
LOG
(
FATAL
)
<<
"Fail to find ConcurrencyLimiter by `"
<<
_options
.
max_concurrency
.
name
()
<<
'`'
;
return
-
1
;
for
(
MethodMap
::
iterator
it
=
_method_map
.
begin
();
it
!=
_method_map
.
end
();
++
it
)
{
if
(
it
->
second
.
is_builtin_service
)
{
continue
;
}
const
ConcurrencyLimiter
*
cl
=
NULL
;
cl
=
ConcurrencyLimiterExtension
()
->
Find
(
_options
.
max_concurrency
.
name
().
c_str
());
if
(
NULL
==
cl
)
{
LOG
(
FATAL
)
<<
"Fail to find ConcurrencyLimiter by `"
<<
_options
.
max_concurrency
.
name
()
<<
'`'
;
return
-
1
;
}
ConcurrencyLimiter
*
cl_copy
=
cl
->
New
();
if
(
NULL
==
cl_copy
)
{
LOG
(
FATAL
)
<<
"Fail to find ConcurrencyLimiter by `"
<<
_options
.
max_concurrency
.
name
()
<<
'`'
;
return
-
1
;
}
it
->
second
.
status
->
ResetConcurrencyLimiter
(
cl_copy
);
}
it
->
second
.
status
->
_cl
=
cl_copy
;
}
// Create listening ports
...
...
src/brpc/server.h
View file @
3541f089
...
...
@@ -119,8 +119,7 @@ struct ServerOptions {
// NOTE: Once you have chosen the automatic concurrency limit strategy, brpc
// ONLY limits concurrency at the method level, And each method will use
// the strategy you set in ServerOptions to limit the maximum concurrency,
// unless you have set a maximum concurrency for this method before starting
// the server.
// even if you have set a maximum concurrency through `SetMaxConcurrencyOf`.
AdaptiveMaxConcurrency
max_concurrency
;
...
...
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