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
3d7bcc67
Commit
3d7bcc67
authored
Aug 09, 2018
by
root
Committed by
caidaojin
Aug 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
little change
parent
45222e8d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
39 deletions
+29
-39
couchbase_channel.cpp
src/brpc/couchbase_channel.cpp
+29
-39
No files found.
src/brpc/couchbase_channel.cpp
View file @
3d7bcc67
...
...
@@ -375,49 +375,39 @@ void CouchbaseChannel::CallMethod(const google::protobuf::MethodDescriptor* meth
const
CouchbaseRequest
*
req
=
reinterpret_cast
<
const
CouchbaseRequest
*>
(
request
);
Controller
*
cntl
=
static_cast
<
Controller
*>
(
controller
);
Channel
*
channel
=
nullptr
;
do
{
std
::
string
key
;
policy
::
MemcacheBinaryCommand
command
;
// Do not support Flush/Version
if
(
req
->
ParseRequest
(
&
key
,
&
command
)
!=
0
)
{
cntl
->
SetFailed
(
"failed to parse key and command from request"
);
break
;
}
{
butil
::
DoublyBufferedData
<
VBucketServerMap
>::
ScopedPtr
vb_map
;
if
(
_vbucket_map
.
Read
(
&
vb_map
)
!=
0
)
{
cntl
->
SetFailed
(
ENOMEM
,
"failed to read vbucket map"
);
break
;
}
if
(
vb_map
->
_version
==
0
)
{
cntl
->
SetFailed
(
ENODATA
,
"vbucket map is not initialize"
);
break
;
}
const
size_t
vb_index
=
Hash
(
key
,
vb_map
->
_vbucket
.
size
());
channel
=
SelectMasterChannel
(
vb_map
.
get
(),
vb_index
);
if
(
channel
==
nullptr
)
{
cntl
->
SetFailed
(
ENODATA
,
"failed to get mapped channel"
);
break
;
}
CouchbaseRequest
new_req
;
if
(
!
req
->
BuildNewWithVBucketId
(
&
new_req
,
vb_index
))
{
cntl
->
SetFailed
(
"failed to add vbucket id"
);
break
;
}
channel
->
CallMethod
(
nullptr
,
cntl
,
&
new_req
,
response
,
done
);
ClosureGuard
done_guard
(
done
);
std
::
string
key
;
policy
::
MemcacheBinaryCommand
command
;
// Do not support Flush/Version
if
(
req
->
ParseRequest
(
&
key
,
&
command
)
!=
0
)
{
cntl
->
SetFailed
(
"failed to parse key and command from request"
);
return
;
}
{
butil
::
DoublyBufferedData
<
VBucketServerMap
>::
ScopedPtr
vb_map
;
if
(
_vbucket_map
.
Read
(
&
vb_map
)
!=
0
)
{
cntl
->
SetFailed
(
ENOMEM
,
"failed to read vbucket map"
);
return
;
}
while
(
FLAGS_retry_during_rebalance
)
{
// TODO: retry in case of rebalance/failover
break
;
if
(
vb_map
->
_version
==
0
)
{
cntl
->
SetFailed
(
ENODATA
,
"vbucket map is not initialize"
);
return
;
}
const
size_t
vb_index
=
Hash
(
key
,
vb_map
->
_vbucket
.
size
());
channel
=
SelectMasterChannel
(
vb_map
.
get
(),
vb_index
);
if
(
channel
==
nullptr
)
{
cntl
->
SetFailed
(
ENODATA
,
"failed to get mapped channel"
);
return
;
}
return
;
}
while
(
false
);
if
(
cntl
->
FailedInline
())
{
if
(
done
)
{
done
->
Run
();
CouchbaseRequest
new_req
;
if
(
!
req
->
BuildNewWithVBucketId
(
&
new_req
,
vb_index
))
{
cntl
->
SetFailed
(
"failed to add vbucket id"
);
return
;
}
done_guard
.
release
();
channel
->
CallMethod
(
nullptr
,
cntl
,
&
new_req
,
response
,
done
);
}
return
;
}
Channel
*
CouchbaseChannel
::
SelectMasterChannel
(
...
...
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