Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多线程Write()支持 #31

Open
gaodq opened this issue Mar 12, 2018 · 2 comments
Open

多线程Write()支持 #31

gaodq opened this issue Mar 12, 2018 · 2 comments

Comments

@gaodq
Copy link

gaodq commented Mar 12, 2018

CmdRequest cmd;
BuildWriteRequest(key, value, &cmd);
CmdResponse response;
Status s = DoCommand(cmd, &response);
if (!s.ok()) {
return s;
}

这里是不是可以支持一下多线程写,像leveldb那样的多个写合并到一个中

@baotiao
Copy link
Contributor

baotiao commented Mar 12, 2018

we have support batch writes when we writing log entries and when apply the log entries to state machine

@gaodq
Copy link
Author

gaodq commented Mar 13, 2018

Status FloydImpl::ExecuteCommand(const CmdRequest& request,
CmdResponse *response) {
// Append entry local
std::vector<const Entry*> entries;
Entry entry;
BuildLogEntry(request, context_->current_term, &entry);
entries.push_back(&entry);
response->set_type(request.type());
response->set_code(StatusCode::kError);
uint64_t last_log_index = raft_log_->Append(entries);

I mean before writing to log, entries at L618 will always contain only one item. I suppose we can merge multi threads' write operation into entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants