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
df189862
Commit
df189862
authored
Apr 17, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revived_from_all_failed: replace StringSplitter with KeyValyePairsSplitter
parent
24d21623
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
cluster_recover_policy.cpp
src/brpc/cluster_recover_policy.cpp
+9
-10
consistent_hashing_load_balancer.cpp
src/brpc/policy/consistent_hashing_load_balancer.cpp
+3
-3
string_splitter.h
src/butil/string_splitter.h
+1
-0
No files found.
src/brpc/cluster_recover_policy.cpp
View file @
df189862
...
...
@@ -110,27 +110,26 @@ bool GetRecoverPolicyByParams(const butil::StringPiece& params,
int64_t
minimum_working_instances
=
-
1
;
int64_t
hold_time_ms
=
-
1
;
bool
has_meet_params
=
false
;
for
(
butil
::
StringSplitter
sp
(
params
.
begin
(),
params
.
end
(),
' '
);
sp
!=
nullptr
;
++
sp
)
{
butil
::
StringPiece
key_value
(
sp
.
field
(),
sp
.
length
());
size_t
p
=
key_value
.
find
(
'='
);
if
(
p
==
key_value
.
npos
||
p
==
key_value
.
size
()
-
1
)
{
// No value configed.
for
(
butil
::
KeyValuePairsSplitter
sp
(
params
.
begin
(),
params
.
end
(),
'='
,
' '
);
sp
;
++
sp
)
{
if
(
sp
.
value
().
empty
())
{
LOG
(
ERROR
)
<<
"Empty value for "
<<
sp
.
key
()
<<
" in lb parameter"
;
return
false
;
}
if
(
key_value
.
substr
(
0
,
p
)
==
"minimum_working_instances"
)
{
if
(
!
butil
::
StringToInt64
(
key_value
.
substr
(
p
+
1
),
&
minimum_working_instances
))
{
if
(
sp
.
key
(
)
==
"minimum_working_instances"
)
{
if
(
!
butil
::
StringToInt64
(
sp
.
value
(
),
&
minimum_working_instances
))
{
return
false
;
}
has_meet_params
=
true
;
continue
;
}
else
if
(
key_value
.
substr
(
0
,
p
)
==
"hold_time_ms"
)
{
if
(
!
butil
::
StringToInt64
(
key_value
.
substr
(
p
+
1
),
&
hold_time_ms
))
{
}
else
if
(
sp
.
key
(
)
==
"hold_time_ms"
)
{
if
(
!
butil
::
StringToInt64
(
sp
.
value
(
),
&
hold_time_ms
))
{
return
false
;
}
has_meet_params
=
true
;
continue
;
}
LOG
(
ERROR
)
<<
"Failed to set this unknown parameters "
<<
key_value
;
LOG
(
ERROR
)
<<
"Failed to set this unknown parameters "
<<
sp
.
key_and_value
()
;
}
if
(
minimum_working_instances
>
0
&&
hold_time_ms
>
0
)
{
ptr_out
->
reset
(
...
...
src/brpc/policy/consistent_hashing_load_balancer.cpp
View file @
df189862
...
...
@@ -385,13 +385,13 @@ bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPiece& para
LOG
(
ERROR
)
<<
"Empty value for "
<<
sp
.
key
()
<<
" in lb parameter"
;
return
false
;
}
if
(
key_value
.
substr
(
0
,
p
)
==
"replicas"
)
{
if
(
!
butil
::
StringToSizeT
(
key_value
.
substr
(
p
+
1
),
&
_num_replicas
))
{
if
(
sp
.
key
(
)
==
"replicas"
)
{
if
(
!
butil
::
StringToSizeT
(
sp
.
value
(
),
&
_num_replicas
))
{
return
false
;
}
continue
;
}
LOG
(
ERROR
)
<<
"Failed to set this unknown parameters "
<<
key_value
;
LOG
(
ERROR
)
<<
"Failed to set this unknown parameters "
<<
sp
.
key_and_value
()
;
}
return
true
;
}
...
...
src/butil/string_splitter.h
View file @
df189862
...
...
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdint.h>
#include "butil/strings/string_piece.h"
// It's common to encode data into strings separated by special characters
// and decode them back, but functions such as `split_string' has to modify
...
...
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