Repository: impala Updated Branches: refs/heads/master 91d109d6e -> 3fc42ded0
KUDU-2256: Add GetTransferSize() to RpcContext This changes adds GetTransferSize() to RpcContext to retrieve the payload size of the inbound call. This makes it easier to track the memory of incoming RPCs in the handler methods. To test this I added a CHECK to one of the handler methods in CalculatorService. Change-Id: Iab2519bad1815aeccaa119f1605638bfd3604382 Reviewed-on: http://gerrit.cloudera.org:8080/8998 Tested-by: Kudu Jenkins Reviewed-by: Todd Lipcon <[email protected]> Reviewed-on: http://gerrit.cloudera.org:8080/9019 Reviewed-by: Michael Ho <[email protected]> Tested-by: Impala Public Jenkins Project: http://git-wip-us.apache.org/repos/asf/impala/repo Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/888a16ca Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/888a16ca Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/888a16ca Branch: refs/heads/master Commit: 888a16cad5faf381898ee50d25c49f35111f9142 Parents: 91d109d Author: Lars Volker <[email protected]> Authored: Wed Jan 10 12:28:13 2018 -0800 Committer: Impala Public Jenkins <[email protected]> Committed: Tue Jan 16 21:43:46 2018 +0000 ---------------------------------------------------------------------- be/src/kudu/rpc/rpc-test-base.h | 1 + be/src/kudu/rpc/rpc_context.cc | 4 ++++ be/src/kudu/rpc/rpc_context.h | 6 ++++++ 3 files changed, 11 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/impala/blob/888a16ca/be/src/kudu/rpc/rpc-test-base.h ---------------------------------------------------------------------- diff --git a/be/src/kudu/rpc/rpc-test-base.h b/be/src/kudu/rpc/rpc-test-base.h index 204f98d..a30e8dc 100644 --- a/be/src/kudu/rpc/rpc-test-base.h +++ b/be/src/kudu/rpc/rpc-test-base.h @@ -247,6 +247,7 @@ class CalculatorService : public CalculatorServiceIf { } void Add(const AddRequestPB *req, AddResponsePB *resp, RpcContext *context) override { + CHECK_GT(context->GetTransferSize(), 0); resp->set_result(req->x() + req->y()); context->RespondSuccess(); } http://git-wip-us.apache.org/repos/asf/impala/blob/888a16ca/be/src/kudu/rpc/rpc_context.cc ---------------------------------------------------------------------- diff --git a/be/src/kudu/rpc/rpc_context.cc b/be/src/kudu/rpc/rpc_context.cc index d6d872e..274966b 100644 --- a/be/src/kudu/rpc/rpc_context.cc +++ b/be/src/kudu/rpc/rpc_context.cc @@ -142,6 +142,10 @@ const rpc::RequestIdPB* RpcContext::request_id() const { return call_->header().has_request_id() ? &call_->header().request_id() : nullptr; } +size_t RpcContext::GetTransferSize() const { + return call_->GetTransferSize(); +} + Status RpcContext::AddOutboundSidecar(unique_ptr<RpcSidecar> car, int* idx) { return call_->AddOutboundSidecar(std::move(car), idx); } http://git-wip-us.apache.org/repos/asf/impala/blob/888a16ca/be/src/kudu/rpc/rpc_context.h ---------------------------------------------------------------------- diff --git a/be/src/kudu/rpc/rpc_context.h b/be/src/kudu/rpc/rpc_context.h index ac895fc..938576c 100644 --- a/be/src/kudu/rpc/rpc_context.h +++ b/be/src/kudu/rpc/rpc_context.h @@ -17,6 +17,7 @@ #ifndef KUDU_RPC_RPC_CONTEXT_H #define KUDU_RPC_RPC_CONTEXT_H +#include <stddef.h> #include <string> #include "kudu/gutil/gscoped_ptr.h" @@ -203,6 +204,11 @@ class RpcContext { // Returns this call's request id, if it is set. const rpc::RequestIdPB* request_id() const; + // Returns the size of the transfer buffer that backs 'call_'. If the + // transfer buffer no longer exists (e.g. GetTransferSize() is called after + // DiscardTransfer()), returns 0. + size_t GetTransferSize() const; + // Panic the server. This logs a fatal error with the given message, and // also includes the current RPC request, requestor, trace information, etc, // to make it easier to debug.
