MCPcopy Create free account
hub / github.com/apache/impala / QueueOutboundCall

Method QueueOutboundCall

be/src/kudu/rpc/connection.cc:466–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464};
465
466void Connection::QueueOutboundCall(shared_ptr<OutboundCall> call) {
467 DCHECK(call);
468 DCHECK_EQ(direction_, CLIENT);
469 DCHECK(reactor_thread_->IsCurrentThread());
470
471 if (PREDICT_FALSE(!shutdown_status_.ok())) {
472 // Already shutdown
473 call->SetFailed(shutdown_status_,
474 negotiation_complete_ ? Phase::REMOTE_CALL
475 : Phase::CONNECTION_NEGOTIATION);
476 return;
477 }
478
479 // At this point the call has a serialized request, but no call header, since we haven't
480 // yet assigned a call ID.
481 DCHECK(!call->call_id_assigned());
482
483 // We shouldn't reach this point if 'call' was requested to be cancelled.
484 DCHECK(!call->cancellation_requested());
485
486 // Assign the call ID.
487 int32_t call_id = GetNextCallId();
488 call->set_call_id(call_id);
489
490 // Serialize the actual bytes to be put on the wire.
491 TransferPayload tmp_slices;
492 call->SerializeTo(&tmp_slices);
493
494 call->SetQueued();
495
496 // Test cancellation when 'call_' is in 'ON_OUTBOUND_QUEUE' state.
497 MaybeInjectCancellation(call);
498
499 scoped_car car(car_pool_.make_scoped_ptr(car_pool_.Construct()));
500 car->conn = this;
501 car->call = call;
502
503 // Set up the timeout timer.
504 const MonoDelta &timeout = call->controller()->timeout();
505 if (timeout.Initialized()) {
506 reactor_thread_->RegisterTimeout(&car->timeout_timer);
507 car->timeout_timer.set<CallAwaitingResponse, // NOLINT(*)
508 &CallAwaitingResponse::HandleTimeout>(car.get());
509
510 // For calls with a timeout of at least 500ms, we actually run the timeout
511 // handler in two stages. The first timeout fires with a timeout 10% less
512 // than the user-specified one. It then schedules a second timeout for the
513 // remaining amount of time.
514 //
515 // The purpose of this two-stage timeout is to be more robust when the client
516 // has some process-wide pause, such as lock contention in tcmalloc, or a
517 // reactor callback that blocks in glog. Consider the following case:
518 //
519 // T = 0s user issues an RPC with 5 second timeout
520 // T = 0.5s - 6s process is blocked
521 // T = 6s process unblocks, and the timeout fires (1s late)
522 //
523 // Without the two-stage timeout, we would determine that the call had timed out,

Callers

nothing calls this directly

Calls 15

moveFunction · 0.85
SetFailedMethod · 0.80
call_id_assignedMethod · 0.80
set_call_idMethod · 0.80
SerializeToMethod · 0.80
SetQueuedMethod · 0.80
make_scoped_ptrMethod · 0.80
ConstructMethod · 0.80
timeoutMethod · 0.80
controllerMethod · 0.80
RegisterTimeoutMethod · 0.80

Tested by

no test coverage detected