kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject [1/3] kudu git commit: KUDU-1887: Add RpcContext::DiscardTransfer()
Date Thu, 09 Mar 2017 00:00:52 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 72895966c -> 937064f91


KUDU-1887: Add RpcContext::DiscardTransfer()

DiscardTransfer() allows RPC handlers to release the memory backing an
inbound call, without being forced to respond to the RPC at the same
time.

Change-Id: I79e83a7b903d77e8309c3cdcfee6dbb85b5db4bb
Reviewed-on: http://gerrit.cloudera.org:8080/6212
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/62553e0b
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/62553e0b
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/62553e0b

Branch: refs/heads/master
Commit: 62553e0b6dcbdc9822680afd35bba07855d1059a
Parents: 7289596
Author: Henry Robinson <henry@cloudera.com>
Authored: Mon Feb 20 08:48:36 2017 -0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Wed Mar 8 18:37:26 2017 +0000

----------------------------------------------------------------------
 src/kudu/rpc/inbound_call.cc | 5 +++++
 src/kudu/rpc/inbound_call.h  | 7 ++++++-
 src/kudu/rpc/rpc-test-base.h | 2 ++
 src/kudu/rpc/rpc_context.cc  | 4 ++++
 src/kudu/rpc/rpc_context.h   | 8 ++++++++
 5 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/62553e0b/src/kudu/rpc/inbound_call.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/inbound_call.cc b/src/kudu/rpc/inbound_call.cc
index 03e7da4..f837dbc 100644
--- a/src/kudu/rpc/inbound_call.cc
+++ b/src/kudu/rpc/inbound_call.cc
@@ -300,6 +300,7 @@ vector<uint32_t> InboundCall::GetRequiredFeatures() const {
 }
 
 Status InboundCall::GetInboundSidecar(int idx, Slice* sidecar) const {
+  DCHECK(transfer_) << "Sidecars have been discarded";
   if (idx < 0 || idx >= header_.sidecar_offsets_size()) {
     return Status::InvalidArgument(strings::Substitute(
             "Index $0 does not reference a valid sidecar", idx));
@@ -308,5 +309,9 @@ Status InboundCall::GetInboundSidecar(int idx, Slice* sidecar) const {
   return Status::OK();
 }
 
+void InboundCall::DiscardTransfer() {
+  transfer_.reset();
+}
+
 } // namespace rpc
 } // namespace kudu

http://git-wip-us.apache.org/repos/asf/kudu/blob/62553e0b/src/kudu/rpc/inbound_call.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/inbound_call.h b/src/kudu/rpc/inbound_call.h
index ea6eade..20b36ff 100644
--- a/src/kudu/rpc/inbound_call.h
+++ b/src/kudu/rpc/inbound_call.h
@@ -78,7 +78,8 @@ class InboundCall {
   Status ParseFrom(gscoped_ptr<InboundTransfer> transfer);
 
   // Return the serialized request parameter protobuf.
-  const Slice &serialized_request() const {
+  const Slice& serialized_request() const {
+    DCHECK(transfer_) << "Transfer discarded before parameter parsing";
     return serialized_request_;
   }
 
@@ -190,6 +191,10 @@ class InboundCall {
   // returns an error.
   Status GetInboundSidecar(int idx, Slice* sidecar) const;
 
+  // Releases the buffer that contains the request + sidecar data. It is an error to
+  // access sidecars or serialized_request() after this method is called.
+  void DiscardTransfer();
+
  private:
   friend class RpczStore;
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/62553e0b/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 75ef792..ac22628 100644
--- a/src/kudu/rpc/rpc-test-base.h
+++ b/src/kudu/rpc/rpc-test-base.h
@@ -184,6 +184,8 @@ class GenericCalculatorService : public ServiceIf {
     resp.set_size2(sidecar2.size());
     resp.set_data2(reinterpret_cast<const char*>(sidecar2.data()), sidecar2.size());
 
+    // Drop the sidecars etc, just to confirm that it's safe to do so.
+    incoming->DiscardTransfer();
     incoming->RespondSuccess(resp);
   }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/62553e0b/src/kudu/rpc/rpc_context.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc_context.cc b/src/kudu/rpc/rpc_context.cc
index e93e093..06fd8c5 100644
--- a/src/kudu/rpc/rpc_context.cc
+++ b/src/kudu/rpc/rpc_context.cc
@@ -155,6 +155,10 @@ const RemoteUser& RpcContext::remote_user() const {
   return call_->remote_user();
 }
 
+void RpcContext::DiscardTransfer() {
+  call_->DiscardTransfer();
+}
+
 const Sockaddr& RpcContext::remote_address() const {
   return call_->remote_address();
 }

http://git-wip-us.apache.org/repos/asf/kudu/blob/62553e0b/src/kudu/rpc/rpc_context.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc_context.h b/src/kudu/rpc/rpc_context.h
index 12e8907..3bb4e33 100644
--- a/src/kudu/rpc/rpc_context.h
+++ b/src/kudu/rpc/rpc_context.h
@@ -162,6 +162,14 @@ class RpcContext {
   // Return the identity of remote user who made this call.
   const RemoteUser& remote_user() const;
 
+  // Discards the memory associated with the inbound call's payload. All previously
+  // obtained sidecar slices will be invalidated by this call. It is an error to call
+  // GetInboundSidecar() after this method. request_pb() remains valid.
+  // This is useful in the case where the server wishes to delay responding to an RPC
+  // (perhaps to control the rate of RPC requests), but knows that the RPC payload itself
+  // won't be processed any further.
+  void DiscardTransfer();
+
   // Return the remote IP address and port which sent the current RPC call.
   const Sockaddr& remote_address() const;
 


Mime
View raw message