Explorar o código

HDFS-10739: libhdfs++: In RpcEngine replace vector with deque for pending requests. Contributed by Anatoli Shein.

James %!s(int64=8) %!d(string=hai) anos
pai
achega
b1ed72e098

+ 0 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_connection.cc

@@ -445,7 +445,6 @@ void RpcConnection::SendRpcRequests(const std::vector<std::shared_ptr<Request> >
     Status status = Status::ResourceUnavailable("RpcConnection closed before send.");
     engine_->AsyncRpcCommsError(status, shared_from_this(), requests);
   } else {
-    pending_requests_.reserve(pending_requests_.size() + requests.size());
     for (auto r: requests) {
       if (r->method_name() != SASL_METHOD_NAME)
         pending_requests_.push_back(r);

+ 3 - 2
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.h

@@ -41,6 +41,7 @@
 #include <memory>
 #include <unordered_map>
 #include <vector>
+#include <deque>
 #include <mutex>
 #include <future>
 
@@ -234,10 +235,10 @@ class RpcConnection : public std::enable_shared_from_this<RpcConnection> {
   // The request being sent over the wire; will also be in requests_on_fly_
   std::shared_ptr<Request> request_over_the_wire_;
   // Requests to be sent over the wire
-  std::vector<std::shared_ptr<Request>> pending_requests_;
+  std::deque<std::shared_ptr<Request>> pending_requests_;
   // Requests to be sent over the wire during authentication; not retried if
   //   there is a connection error
-  std::vector<std::shared_ptr<Request>> auth_requests_;
+  std::deque<std::shared_ptr<Request>> auth_requests_;
   // Requests that are waiting for responses
   typedef std::unordered_map<int, std::shared_ptr<Request>> RequestOnFlyMap;
   RequestOnFlyMap requests_on_fly_;