Adding a few integration points to the C++ TSocketPool.
- Adding ability to use a vector of TSocketPoolServers to construct a TSocketPool
- Ability to get back the list of TSocketPoolServers
This is especially useful in multithreaded client code that
will just keep around the list of servers, and create the pool
on every request. Since TSocketPool updates the failure stuff,
we need a way to get back the updated TSocketPoolServers
Reviewed By: aditya
Test Plan: just compiling the code
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665537 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/transport/TSocketPool.cpp b/lib/cpp/src/transport/TSocketPool.cpp
index 6398052..d1d5bcd 100644
--- a/lib/cpp/src/transport/TSocketPool.cpp
+++ b/lib/cpp/src/transport/TSocketPool.cpp
@@ -57,7 +57,7 @@
}
}
-TSocketPool::TSocketPool(const vector<pair<string, int> > servers) : TSocket(),
+TSocketPool::TSocketPool(const std::vector<pair<string, int> >& servers) : TSocket(),
numRetries_(1),
retryInterval_(60),
maxConsecutiveFailures_(1),
@@ -69,6 +69,16 @@
}
}
+TSocketPool::TSocketPool(const std::vector<TSocketPoolServer>& servers) : TSocket(),
+ servers_(servers),
+ numRetries_(1),
+ retryInterval_(60),
+ maxConsecutiveFailures_(1),
+ randomize_(true),
+ alwaysTryLast_(true)
+{
+}
+
TSocketPool::TSocketPool(const string& host, int port) : TSocket(),
numRetries_(1),
retryInterval_(60),
@@ -87,6 +97,10 @@
servers_.push_back(TSocketPoolServer(host, port));
}
+std::vector<TSocketPoolServer> TSocketPool::getServers() {
+ return servers_;
+}
+
void TSocketPool::setNumRetries(int numRetries) {
numRetries_ = numRetries;
}