Commit 3d7bcc67 authored by root's avatar root Committed by caidaojin

little change

parent 45222e8d
...@@ -375,49 +375,39 @@ void CouchbaseChannel::CallMethod(const google::protobuf::MethodDescriptor* meth ...@@ -375,49 +375,39 @@ void CouchbaseChannel::CallMethod(const google::protobuf::MethodDescriptor* meth
const CouchbaseRequest* req = reinterpret_cast<const CouchbaseRequest*>(request); const CouchbaseRequest* req = reinterpret_cast<const CouchbaseRequest*>(request);
Controller* cntl = static_cast<Controller*>(controller); Controller* cntl = static_cast<Controller*>(controller);
Channel* channel = nullptr; Channel* channel = nullptr;
do { ClosureGuard done_guard(done);
std::string key; std::string key;
policy::MemcacheBinaryCommand command; policy::MemcacheBinaryCommand command;
// Do not support Flush/Version // Do not support Flush/Version
if (req->ParseRequest(&key, &command) != 0) { if (req->ParseRequest(&key, &command) != 0) {
cntl->SetFailed("failed to parse key and command from request"); cntl->SetFailed("failed to parse key and command from request");
break; return;
} }
{ {
butil::DoublyBufferedData<VBucketServerMap>::ScopedPtr vb_map; butil::DoublyBufferedData<VBucketServerMap>::ScopedPtr vb_map;
if(_vbucket_map.Read(&vb_map) != 0) { if(_vbucket_map.Read(&vb_map) != 0) {
cntl->SetFailed(ENOMEM, "failed to read vbucket map"); cntl->SetFailed(ENOMEM, "failed to read vbucket map");
break; return;
} }
if (vb_map->_version == 0) { if (vb_map->_version == 0) {
cntl->SetFailed(ENODATA, "vbucket map is not initialize"); cntl->SetFailed(ENODATA, "vbucket map is not initialize");
break; return;
} }
const size_t vb_index = Hash(key, vb_map->_vbucket.size()); const size_t vb_index = Hash(key, vb_map->_vbucket.size());
channel = SelectMasterChannel(vb_map.get(), vb_index); channel = SelectMasterChannel(vb_map.get(), vb_index);
if (channel == nullptr) { if (channel == nullptr) {
cntl->SetFailed(ENODATA,"failed to get mapped channel"); cntl->SetFailed(ENODATA,"failed to get mapped channel");
break; return;
} }
CouchbaseRequest new_req; CouchbaseRequest new_req;
if (!req->BuildNewWithVBucketId(&new_req, vb_index)) { if (!req->BuildNewWithVBucketId(&new_req, vb_index)) {
cntl->SetFailed("failed to add vbucket id"); cntl->SetFailed("failed to add vbucket id");
break; return;
} }
done_guard.release();
channel->CallMethod(nullptr, cntl, &new_req, response, done); channel->CallMethod(nullptr, cntl, &new_req, response, done);
} }
while(FLAGS_retry_during_rebalance) {
// TODO: retry in case of rebalance/failover
break;
}
return; return;
} while (false);
if (cntl->FailedInline()) {
if (done) {
done->Run();
}
}
} }
Channel* CouchbaseChannel::SelectMasterChannel( Channel* CouchbaseChannel::SelectMasterChannel(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment