Skip to content

多线程Write()支持 #31

Description

@gaodq

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

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

Activity

  1. baotiao commented on Mar 12, 2018

    @baotiao
    Contributor

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

  2. gaodq commented on Mar 13, 2018

    @gaodq
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions