Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::ClientCache< T > Class Template Reference

#include <client-cache.h>

Collaboration diagram for impala::ClientCache< T >:

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...
 
ThriftClientImplMakeClient (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 >
 

Detailed Description

template<class T>
class impala::ClientCache< 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.

Member Typedef Documentation

template<class T>
typedef ThriftClient<T> impala::ClientCache< T >::Client

Definition at line 255 of file client-cache.h.

Constructor & Destructor Documentation

template<class T>
impala::ClientCache< T >::ClientCache ( const std::string &  service_name = "")
inline
template<class T>
impala::ClientCache< T >::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 = "" 
)
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().

Member Function Documentation

template<class T>
void impala::ClientCache< T >::CloseConnections ( const TNetworkAddress &  address)
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().

template<class T>
std::string impala::ClientCache< T >::DebugString ( )
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().

template<class T>
Status impala::ClientCache< T >::GetClient ( const TNetworkAddress &  address,
T **  iface 
)
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().

template<class T>
void impala::ClientCache< T >::InitMetrics ( MetricGroup metrics,
const std::string &  key_prefix 
)
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().

template<class T>
ThriftClientImpl* impala::ClientCache< T >::MakeClient ( const TNetworkAddress &  address,
ClientKey client_key,
const std::string  service_name 
)
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().

template<class T>
void impala::ClientCache< T >::ReleaseClient ( T **  client)
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().

template<class T>
Status impala::ClientCache< T >::ReopenClient ( T **  client)
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().

template<class T>
void impala::ClientCache< T >::TestShutdown ( )
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().

Friends And Related Function Documentation

template<class T>
friend class ClientConnection< T >
friend

Definition at line 300 of file client-cache.h.

Member Data Documentation

template<class T>
ClientCacheHelper impala::ClientCache< T >::client_cache_helper_
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().

template<class T>
ClientCacheHelper::ClientFactory impala::ClientCache< T >::client_factory_
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().


The documentation for this class was generated from the following file: