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
f3acf3d8
Commit
f3acf3d8
authored
Apr 18, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revived_from_all_failed: fix codes after rebase
parent
fd3295d3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
37 deletions
+33
-37
cluster_recover_policy.cpp
src/brpc/cluster_recover_policy.cpp
+1
-1
consistent_hashing_load_balancer.cpp
src/brpc/policy/consistent_hashing_load_balancer.cpp
+8
-9
uri.h
src/brpc/uri.h
+3
-3
string_splitter.h
src/butil/string_splitter.h
+12
-12
variable.cpp
src/bvar/variable.cpp
+6
-9
string_splitter_unittest.cpp
test/string_splitter_unittest.cpp
+3
-3
No files found.
src/brpc/cluster_recover_policy.cpp
View file @
f3acf3d8
...
@@ -110,7 +110,7 @@ bool GetRecoverPolicyByParams(const butil::StringPiece& params,
...
@@ -110,7 +110,7 @@ bool GetRecoverPolicyByParams(const butil::StringPiece& params,
int64_t
min_working_instances
=
-
1
;
int64_t
min_working_instances
=
-
1
;
int64_t
hold_seconds
=
-
1
;
int64_t
hold_seconds
=
-
1
;
bool
has_meet_params
=
false
;
bool
has_meet_params
=
false
;
for
(
butil
::
KeyValuePairsSplitter
sp
(
params
.
begin
(),
params
.
end
(),
'
='
,
'
'
);
for
(
butil
::
KeyValuePairsSplitter
sp
(
params
.
begin
(),
params
.
end
(),
'
'
,
'=
'
);
sp
;
++
sp
)
{
sp
;
++
sp
)
{
if
(
sp
.
value
().
empty
())
{
if
(
sp
.
value
().
empty
())
{
LOG
(
ERROR
)
<<
"Empty value for "
<<
sp
.
key
()
<<
" in lb parameter"
;
LOG
(
ERROR
)
<<
"Empty value for "
<<
sp
.
key
()
<<
" in lb parameter"
;
...
...
src/brpc/policy/consistent_hashing_load_balancer.cpp
View file @
f3acf3d8
...
@@ -273,7 +273,7 @@ size_t ConsistentHashingLoadBalancer::RemoveServersInBatch(
...
@@ -273,7 +273,7 @@ size_t ConsistentHashingLoadBalancer::RemoveServersInBatch(
LoadBalancer
*
ConsistentHashingLoadBalancer
::
New
(
const
butil
::
StringPiece
&
params
)
const
{
LoadBalancer
*
ConsistentHashingLoadBalancer
::
New
(
const
butil
::
StringPiece
&
params
)
const
{
ConsistentHashingLoadBalancer
*
lb
=
ConsistentHashingLoadBalancer
*
lb
=
new
(
std
::
nothrow
)
ConsistentHashingLoadBalancer
(
_type
);
new
(
std
::
nothrow
)
ConsistentHashingLoadBalancer
(
_type
);
if
(
lb
!=
nullptr
&&
!
lb
->
SetParameters
(
params
))
{
if
(
lb
&&
!
lb
->
SetParameters
(
params
))
{
delete
lb
;
delete
lb
;
lb
=
nullptr
;
lb
=
nullptr
;
}
}
...
@@ -377,20 +377,19 @@ void ConsistentHashingLoadBalancer::GetLoads(
...
@@ -377,20 +377,19 @@ void ConsistentHashingLoadBalancer::GetLoads(
}
}
bool
ConsistentHashingLoadBalancer
::
SetParameters
(
const
butil
::
StringPiece
&
params
)
{
bool
ConsistentHashingLoadBalancer
::
SetParameters
(
const
butil
::
StringPiece
&
params
)
{
for
(
butil
::
StringSplitter
sp
(
params
.
begin
(),
params
.
end
(),
' '
);
sp
!=
nullptr
;
++
sp
)
{
for
(
butil
::
KeyValuePairsSplitter
sp
(
params
.
begin
(),
params
.
end
(),
' '
,
'='
);
butil
::
StringPiece
key_value
(
sp
.
field
(),
sp
.
length
());
sp
;
++
sp
)
{
size_t
p
=
key_value
.
find
(
'='
);
if
(
sp
.
value
().
empty
())
{
if
(
p
==
key_value
.
npos
||
p
==
key_value
.
size
()
-
1
)
{
LOG
(
ERROR
)
<<
"Empty value for "
<<
sp
.
key
()
<<
" in lb parameter"
;
// No value configed.
return
false
;
return
false
;
}
}
if
(
key_value
.
substr
(
0
,
p
)
==
"replicas"
)
{
if
(
sp
.
key
(
)
==
"replicas"
)
{
if
(
!
butil
::
StringToSizeT
(
key_value
.
substr
(
p
+
1
),
&
_num_replicas
))
{
if
(
!
butil
::
StringToSizeT
(
sp
.
value
(
),
&
_num_replicas
))
{
return
false
;
return
false
;
}
}
continue
;
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
;
return
true
;
}
}
...
...
src/brpc/uri.h
View file @
f3acf3d8
...
@@ -198,15 +198,15 @@ inline std::ostream& operator<<(std::ostream& os, const URI& uri) {
...
@@ -198,15 +198,15 @@ inline std::ostream& operator<<(std::ostream& os, const URI& uri) {
class
QuerySplitter
:
public
butil
::
KeyValuePairsSplitter
{
class
QuerySplitter
:
public
butil
::
KeyValuePairsSplitter
{
public
:
public
:
inline
QuerySplitter
(
const
char
*
str_begin
,
const
char
*
str_end
)
inline
QuerySplitter
(
const
char
*
str_begin
,
const
char
*
str_end
)
:
KeyValuePairsSplitter
(
str_begin
,
str_end
,
'
='
,
'&
'
)
:
KeyValuePairsSplitter
(
str_begin
,
str_end
,
'
&'
,
'=
'
)
{}
{}
inline
QuerySplitter
(
const
char
*
str_begin
)
inline
QuerySplitter
(
const
char
*
str_begin
)
:
KeyValuePairsSplitter
(
str_begin
,
'
='
,
'&
'
)
:
KeyValuePairsSplitter
(
str_begin
,
'
&'
,
'=
'
)
{}
{}
inline
QuerySplitter
(
const
butil
::
StringPiece
&
sp
)
inline
QuerySplitter
(
const
butil
::
StringPiece
&
sp
)
:
KeyValuePairsSplitter
(
sp
,
'
='
,
'&
'
)
:
KeyValuePairsSplitter
(
sp
,
'
&'
,
'=
'
)
{}
{}
};
};
...
...
src/butil/string_splitter.h
View file @
f3acf3d8
...
@@ -167,8 +167,8 @@ private:
...
@@ -167,8 +167,8 @@ private:
// Split query in the format according to the given delimiters.
// Split query in the format according to the given delimiters.
// This class can also handle some exceptional cases.
// This class can also handle some exceptional cases.
// 1. consecutive
key_value_
pair_delimiter are omitted, for example,
// 1. consecutive pair_delimiter are omitted, for example,
// suppose key_value_delimiter is '=' and
key_value_
pair_delimiter
// suppose key_value_delimiter is '=' and pair_delimiter
// is '&', then 'k1=v1&&&k2=v2' is normalized to 'k1=k2&k2=v2'.
// is '&', then 'k1=v1&&&k2=v2' is normalized to 'k1=k2&k2=v2'.
// 2. key or value can be empty or both can be empty.
// 2. key or value can be empty or both can be empty.
// 3. consecutive key_value_delimiter are not omitted, for example,
// 3. consecutive key_value_delimiter are not omitted, for example,
...
@@ -178,25 +178,25 @@ class KeyValuePairsSplitter {
...
@@ -178,25 +178,25 @@ class KeyValuePairsSplitter {
public
:
public
:
inline
KeyValuePairsSplitter
(
const
char
*
str_begin
,
inline
KeyValuePairsSplitter
(
const
char
*
str_begin
,
const
char
*
str_end
,
const
char
*
str_end
,
char
key_value
_delimiter
,
char
pair
_delimiter
,
char
key_value_
pair_
delimiter
)
char
key_value_delimiter
)
:
_sp
(
str_begin
,
str_end
,
key_value_
pair_delimiter
)
:
_sp
(
str_begin
,
str_end
,
pair_delimiter
)
,
_delim_pos
(
StringPiece
::
npos
)
,
_delim_pos
(
StringPiece
::
npos
)
,
_key_value_delim
(
key_value_delimiter
)
{
,
_key_value_delim
(
key_value_delimiter
)
{
UpdateDelimiterPosition
();
UpdateDelimiterPosition
();
}
}
inline
KeyValuePairsSplitter
(
const
char
*
str_begin
,
inline
KeyValuePairsSplitter
(
const
char
*
str_begin
,
char
key_value
_delimiter
,
char
pair
_delimiter
,
char
key_value_
pair_
delimiter
)
char
key_value_delimiter
)
:
KeyValuePairsSplitter
(
str_begin
,
NULL
,
:
KeyValuePairsSplitter
(
str_begin
,
NULL
,
key_value_delimiter
,
key_value_pair
_delimiter
)
{}
pair_delimiter
,
key_value
_delimiter
)
{}
inline
KeyValuePairsSplitter
(
const
StringPiece
&
sp
,
inline
KeyValuePairsSplitter
(
const
StringPiece
&
sp
,
char
key_value
_delimiter
,
char
pair
_delimiter
,
char
key_value_
pair_
delimiter
)
char
key_value_delimiter
)
:
KeyValuePairsSplitter
(
sp
.
begin
(),
sp
.
end
(),
:
KeyValuePairsSplitter
(
sp
.
begin
(),
sp
.
end
(),
key_value_delimiter
,
key_value_pair
_delimiter
)
{}
pair_delimiter
,
key_value
_delimiter
)
{}
inline
StringPiece
key
()
{
inline
StringPiece
key
()
{
return
key_and_value
().
substr
(
0
,
_delim_pos
);
return
key_and_value
().
substr
(
0
,
_delim_pos
);
...
@@ -206,7 +206,7 @@ public:
...
@@ -206,7 +206,7 @@ public:
return
key_and_value
().
substr
(
_delim_pos
+
1
);
return
key_and_value
().
substr
(
_delim_pos
+
1
);
}
}
// Get the current value of key and value
// Get the current value of key and value
// in the format of "key=value"
// in the format of "key=value"
inline
StringPiece
key_and_value
()
{
inline
StringPiece
key_and_value
()
{
return
StringPiece
(
_sp
.
field
(),
_sp
.
length
());
return
StringPiece
(
_sp
.
field
(),
_sp
.
length
());
...
...
src/bvar/variable.cpp
View file @
f3acf3d8
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#include "butil/containers/flat_map.h" // butil::FlatMap
#include "butil/containers/flat_map.h" // butil::FlatMap
#include "butil/scoped_lock.h" // BAIDU_SCOPE_LOCK
#include "butil/scoped_lock.h" // BAIDU_SCOPE_LOCK
#include "butil/string_splitter.h" // butil::StringSplitter
#include "butil/string_splitter.h" // butil::StringSplitter
#include "butil/strings/string_split.h" // butil::SplitStringIntoKeyValuePairs
#include "butil/errno.h" // berror
#include "butil/errno.h" // berror
#include "butil/time.h" // milliseconds_from_now
#include "butil/time.h" // milliseconds_from_now
#include "butil/file_util.h" // butil::FilePath
#include "butil/file_util.h" // butil::FilePath
...
@@ -627,15 +626,13 @@ public:
...
@@ -627,15 +626,13 @@ public:
// .data will be appended later
// .data will be appended later
path
=
path
.
RemoveFinalExtension
();
path
=
path
.
RemoveFinalExtension
();
}
}
butil
::
StringPairs
pairs
;
pairs
.
reserve
(
8
);
for
(
butil
::
KeyValuePairsSplitter
sp
(
tabs
,
';'
,
'='
);
sp
;
++
sp
)
{
butil
::
SplitStringIntoKeyValuePairs
(
tabs
,
'='
,
';'
,
&
pairs
);
std
::
string
key
=
sp
.
key
().
as_string
();
dumpers
.
reserve
(
pairs
.
size
()
+
1
);
std
::
string
value
=
sp
.
value
().
as_string
();
//matchers.reserve(pairs.size());
for
(
size_t
i
=
0
;
i
<
pairs
.
size
();
++
i
)
{
FileDumper
*
f
=
new
FileDumper
(
FileDumper
*
f
=
new
FileDumper
(
path
.
AddExtension
(
pairs
[
i
].
first
).
AddExtension
(
"data"
).
value
(),
s
);
path
.
AddExtension
(
key
).
AddExtension
(
"data"
).
value
(),
s
);
WildcardMatcher
*
m
=
new
WildcardMatcher
(
pairs
[
i
].
second
,
'?'
,
true
);
WildcardMatcher
*
m
=
new
WildcardMatcher
(
value
,
'?'
,
true
);
dumpers
.
push_back
(
std
::
make_pair
(
f
,
m
));
dumpers
.
push_back
(
std
::
make_pair
(
f
,
m
));
}
}
dumpers
.
push_back
(
std
::
make_pair
(
dumpers
.
push_back
(
std
::
make_pair
(
...
...
test/string_splitter_unittest.cpp
View file @
f3acf3d8
...
@@ -343,12 +343,12 @@ TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) {
...
@@ -343,12 +343,12 @@ TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) {
// Test three constructors
// Test three constructors
butil
::
KeyValuePairsSplitter
*
psplitter
=
NULL
;
butil
::
KeyValuePairsSplitter
*
psplitter
=
NULL
;
if
(
i
==
0
)
{
if
(
i
==
0
)
{
psplitter
=
new
butil
::
KeyValuePairsSplitter
(
kvstr
,
'
='
,
'&
'
);
psplitter
=
new
butil
::
KeyValuePairsSplitter
(
kvstr
,
'
&'
,
'=
'
);
}
else
if
(
i
==
1
)
{
}
else
if
(
i
==
1
)
{
psplitter
=
new
butil
::
KeyValuePairsSplitter
(
psplitter
=
new
butil
::
KeyValuePairsSplitter
(
kvstr
.
data
(),
kvstr
.
data
()
+
kvstr
.
size
(),
'
='
,
'&
'
);
kvstr
.
data
(),
kvstr
.
data
()
+
kvstr
.
size
(),
'
&'
,
'=
'
);
}
else
if
(
i
==
2
)
{
}
else
if
(
i
==
2
)
{
psplitter
=
new
butil
::
KeyValuePairsSplitter
(
kvstr
.
c_str
(),
'
='
,
'&
'
);
psplitter
=
new
butil
::
KeyValuePairsSplitter
(
kvstr
.
c_str
(),
'
&'
,
'=
'
);
}
}
butil
::
KeyValuePairsSplitter
&
splitter
=
*
psplitter
;
butil
::
KeyValuePairsSplitter
&
splitter
=
*
psplitter
;
...
...
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