Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <client-cache.h>
Public Types | |
typedef ThriftClient< T > | Client |
Public Member Functions | |
ClientCache (const std::string &service_name="") | |
ClientCache (uint32_t num_tries, uint64_t wait_ms, int32_t send_timeout_ms=0, int32_t recv_timeout_ms=0, const std::string &service_name="") | |
void | CloseConnections (const TNetworkAddress &address) |
std::string | DebugString () |
Helper method which returns a debug string. More... | |
void | TestShutdown () |
For testing only: shutdown all clients. More... | |
void | InitMetrics (MetricGroup *metrics, const std::string &key_prefix) |
Private Member Functions | |
Status | GetClient (const TNetworkAddress &address, T **iface) |
Status | ReopenClient (T **client) |
void | ReleaseClient (T **client) |
Return the client to the cache and set *client to NULL. More... | |
ThriftClientImpl * | MakeClient (const TNetworkAddress &address, ClientKey *client_key, const std::string service_name) |
Factory method to produce a new ThriftClient<T> for the wrapped cache. More... | |
Private Attributes | |
ClientCacheHelper | client_cache_helper_ |
ClientCacheHelper::ClientFactory | client_factory_ |
Function pointer, bound to MakeClient, which produces clients when the cache is empty. More... | |
Friends | |
class | ClientConnection< T > |
Generic cache of Thrift clients for a given service type. This class is thread-safe.
Definition at line 187 of file client-cache.h.
typedef ThriftClient<T> impala::ClientCache< T >::Client |
Definition at line 255 of file client-cache.h.
|
inline |
Definition at line 257 of file client-cache.h.
References impala::ClientCache< T >::client_factory_, and impala::ClientCache< T >::MakeClient().
|
inline |
Create a ClientCache where connections are tried num_tries times, with a pause of wait_ms between attempts. The underlying TSocket's send and receive timeouts of each connection can also be set. If num_tries == 0, retry connections indefinitely. A send/receive timeout of 0 means there is no timeout.
Definition at line 266 of file client-cache.h.
References impala::ClientCache< T >::client_factory_, and impala::ClientCache< T >::MakeClient().
|
inline |
Close all clients connected to the supplied address, (e.g., in case of failure) so that on their next use they will have to be Reopen'ed.
Definition at line 277 of file client-cache.h.
References impala::ClientCache< T >::client_cache_helper_, and impala::ClientCacheHelper::CloseConnections().
Referenced by impala::ImpalaServer::MembershipCallback().
|
inline |
Helper method which returns a debug string.
Definition at line 282 of file client-cache.h.
References impala::ClientCache< T >::client_cache_helper_, and impala::ClientCacheHelper::DebugString().
|
inlineprivate |
Obtains a pointer to a Thrift interface object (of type T), backed by a live transport which is already open. Returns Status::OK unless there was an error opening the transport.
Definition at line 313 of file client-cache.h.
References impala::ClientCache< T >::client_cache_helper_, impala::ClientCache< T >::client_factory_, and impala::ClientCacheHelper::GetClient().
|
inline |
Adds metrics for this cache to the supplied Metrics instance. The metrics have keys that are prefixed by the key_prefix argument (which should not end in a period). Must be called before the cache is used, otherwise the metrics might be wrong
Definition at line 295 of file client-cache.h.
References impala::ClientCache< T >::client_cache_helper_, and impala::ClientCacheHelper::InitMetrics().
|
inlineprivate |
Factory method to produce a new ThriftClient<T> for the wrapped cache.
Definition at line 333 of file client-cache.h.
References impala::ThriftClient< InterfaceType >::iface().
Referenced by impala::ClientCache< T >::ClientCache().
|
inlineprivate |
Return the client to the cache and set *client to NULL.
Definition at line 328 of file client-cache.h.
References impala::ClientCache< T >::client_cache_helper_, and impala::ClientCacheHelper::ReleaseClient().
|
inlineprivate |
Close and delete the underlying transport. Return a new client connecting to the same host/port. Returns an error status if a new connection cannot be established and *client will be unaffected in that case.
Definition at line 322 of file client-cache.h.
References impala::ClientCache< T >::client_cache_helper_, impala::ClientCache< T >::client_factory_, and impala::ClientCacheHelper::ReopenClient().
|
inline |
For testing only: shutdown all clients.
Definition at line 287 of file client-cache.h.
References impala::ClientCache< T >::client_cache_helper_, and impala::ClientCacheHelper::TestShutdown().
Referenced by impala::DataStreamTest::TearDown().
|
friend |
Definition at line 300 of file client-cache.h.
|
private |
Most operations in this class are thin wrappers around the equivalent in ClientCacheHelper, which is a non-templated cache to avoid inlining lots of code wherever this cache is used.
Definition at line 305 of file client-cache.h.
Referenced by impala::ClientCache< T >::CloseConnections(), impala::ClientCache< T >::DebugString(), impala::ClientCache< T >::GetClient(), impala::ClientCache< T >::InitMetrics(), impala::ClientCache< T >::ReleaseClient(), impala::ClientCache< T >::ReopenClient(), and impala::ClientCache< T >::TestShutdown().
|
private |
Function pointer, bound to MakeClient, which produces clients when the cache is empty.
Definition at line 308 of file client-cache.h.
Referenced by impala::ClientCache< T >::ClientCache(), impala::ClientCache< T >::GetClient(), and impala::ClientCache< T >::ReopenClient().