MCPcopy Create free account
hub / github.com/apache/kvrocks / Send

Method Send

src/cluster/batch_sender.cc:68–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66void BatchSender::SetPrefixLogData(const std::string &prefix_logdata) { prefix_logdata_ = prefix_logdata; }
67
68Status BatchSender::Send() {
69 if (pending_entries_ == 0) {
70 return Status::OK();
71 }
72
73 // rate limit
74 if (bytes_per_sec_ > 0) {
75 auto single_burst = rate_limiter_->GetSingleBurstBytes();
76 auto left = static_cast<int64_t>(write_batch_.GetDataSize());
77 while (left > 0) {
78 auto request_size = std::min(left, single_burst);
79 rate_limiter_->Request(request_size, rocksdb::Env::IOPriority::IO_HIGH, nullptr);
80 left -= request_size;
81 }
82 }
83
84 auto s = sendApplyBatchCmd(dst_fd_, write_batch_);
85 if (!s.IsOK()) {
86 return s.Prefixed("failed to send APPLYBATCH command");
87 }
88
89 sent_bytes_ += write_batch_.GetDataSize();
90 sent_batches_num_++;
91 pending_entries_ = 0;
92 write_batch_.Clear();
93 return Status::OK();
94}
95
96Status BatchSender::sendApplyBatchCmd(int fd, const rocksdb::WriteBatch &write_batch) {
97 if (fd <= 0) {

Callers 1

sendMigrationBatchMethod · 0.80

Calls 4

RequestMethod · 0.80
IsOKMethod · 0.45
PrefixedMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected