MCPcopy Create free account
hub / github.com/baidu/tera / DoQuotaScanRpcRetry

Method DoQuotaScanRpcRetry

src/tabletnode/remote_tabletnode.cc:415–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

413}
414
415bool RemoteTabletNode::DoQuotaScanRpcRetry(RpcTask* rpc) {
416 CHECK(rpc->rpc_type == RPC_SCAN);
417 ScanRpc* scan_rpc = (ScanRpc*)rpc;
418 std::string table_name = scan_rpc->request->table_name();
419 if (!quota_entry_->CheckAndConsume(table_name,
420 quota::OpTypeAmountList{std::make_pair(kQuotaScanReqs, 1)})) {
421 if ((quota_retry_rpc_schedule_->GetPendingTaskCount() <
422 FLAGS_tera_quota_max_retry_queue_length) &&
423 (++scan_rpc->retry_time < FLAGS_tera_quota_scan_max_retry_times)) {
424 quota_retry_rpc_schedule_->EnqueueRpc(table_name, rpc);
425 scan_thread_pool_->DelayTask(FLAGS_tera_quota_scan_retry_delay_interval, // default 100ms
426 std::bind(&RemoteTabletNode::DoQuotaRetryScheduleRpc, this,
427 quota_retry_rpc_schedule_.get()));
428 } else {
429 scan_rpc->response->set_sequence_id(scan_rpc->request->sequence_id());
430 scan_rpc->response->set_status(kQuotaLimited);
431 scan_quota_reject_counter.Inc();
432 VLOG(20) << "quota_entry check failed for ScanTablet";
433 scan_rpc->done->Run();
434 delete rpc;
435 }
436 return false;
437 }
438 return true;
439}
440
441void RemoteTabletNode::DoQuotaRetryScheduleRpc(RpcSchedule* rpc_schedule) {
442 RpcTask* rpc = NULL;

Callers

nothing calls this directly

Calls 7

GetPendingTaskCountMethod · 0.80
EnqueueRpcMethod · 0.80
DelayTaskMethod · 0.80
IncMethod · 0.80
CheckAndConsumeMethod · 0.45
getMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected