kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject kudu git commit: KUDU-2256: Add GetTransferSize() to RpcContext
Date Fri, 12 Jan 2018 05:22:28 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 56107ac80 -> 35fc7b7e5


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 <todd@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/35fc7b7e
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/35fc7b7e
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/35fc7b7e

Branch: refs/heads/master
Commit: 35fc7b7e558fabaac0a126b45cd513a52d60d15b
Parents: 56107ac
Author: Lars Volker <lv@cloudera.com>
Authored: Wed Jan 10 12:28:13 2018 -0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Fri Jan 12 05:20:08 2018 +0000

----------------------------------------------------------------------
 src/kudu/rpc/rpc-test-base.h | 1 +
 src/kudu/rpc/rpc_context.cc  | 4 ++++
 src/kudu/rpc/rpc_context.h   | 6 ++++++
 3 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/35fc7b7e/src/kudu/rpc/rpc-test-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc-test-base.h b/src/kudu/rpc/rpc-test-base.h
index cc2480e..53de6bc 100644
--- a/src/kudu/rpc/rpc-test-base.h
+++ b/src/kudu/rpc/rpc-test-base.h
@@ -248,6 +248,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/kudu/blob/35fc7b7e/src/kudu/rpc/rpc_context.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc_context.cc b/src/kudu/rpc/rpc_context.cc
index 7af981b..3e33cbb 100644
--- a/src/kudu/rpc/rpc_context.cc
+++ b/src/kudu/rpc/rpc_context.cc
@@ -139,6 +139,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/kudu/blob/35fc7b7e/src/kudu/rpc/rpc_context.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc_context.h b/src/kudu/rpc/rpc_context.h
index 42f096e..201cc84 100644
--- a/src/kudu/rpc/rpc_context.h
+++ b/src/kudu/rpc/rpc_context.h
@@ -18,6 +18,7 @@
 #define KUDU_RPC_RPC_CONTEXT_H
 
 #include <memory>
+#include <stddef.h>
 #include <string>
 
 #include <glog/logging.h>
@@ -208,6 +209,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.


Mime
View raw message