OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConfigEtcdClient Class Reference

#include <config_etcd_client.h>

Inheritance diagram for ConfigEtcdClient:
Collaboration diagram for ConfigEtcdClient:

Classes

class  EtcdWatcher
 

Public Types

typedef vector
< ConfigEtcdPartition * > 
PartitionList
 
- Public Types inherited from ConfigDbClient
typedef std::pair< std::string,
std::string > 
ObjTypeFQNPair
 

Public Member Functions

 ConfigEtcdClient (ConfigClientManager *mgr, EventManager *evm, const ConfigClientOptions &options, int num_workers)
 
virtual ~ConfigEtcdClient ()
 
virtual void InitDatabase ()
 
void BulkSyncDone ()
 
void EnqueueUUIDRequest (string oper, string obj_type, string uuid_str)
 
ConfigEtcdPartitionGetPartition (const string &uuid)
 
const ConfigEtcdPartitionGetPartition (const string &uuid) const
 
const ConfigEtcdPartitionGetPartition (int worker_id) const
 
void StartWatcher ()
 
virtual bool UUIDToObjCacheShow (const string &search_string, int inst_num, const string &last_uuid, uint32_t num_entries, vector< ConfigDBUUIDCacheEntry > *entries) const
 
virtual bool IsListOrMapPropEmpty (const string &uuid_key, const string &lookup_key)
 
bool IsTaskTriggered () const
 
virtual void ProcessResponse (EtcdResponse resp)
 
- Public Member Functions inherited from ConfigDbClient
 ConfigDbClient (ConfigClientManager *mgr, EventManager *evm, const ConfigClientOptions &options)
 
virtual ~ConfigDbClient ()
 
const std::string & config_db_user () const
 
const std::string & config_db_password () const
 
const std::vector< std::string > & config_db_ips () const
 
int GetFirstConfigDbPort () const
 
virtual void EnqueueUUIDRequest (std::string uuid_str, std::string obj_type, std::string oper)=0
 
virtual bool UUIDToObjCacheShow (const std::string &search_string, int inst_num, const std::string &last_uuid, uint32_t num_entries, std::vector< ConfigDBUUIDCacheEntry > *entries) const =0
 
virtual bool IsListOrMapPropEmpty (const std::string &uuid_key, const std::string &lookup_key)=0
 
virtual void AddFQNameCache (const std::string &uuid, const std::string &obj_type, const std::string &fq_name)
 
virtual std::string FindFQName (const std::string &uuid) const
 
virtual void InvalidateFQNameCache (const std::string &uuid)
 
virtual void PurgeFQNameCache (const std::string &uuid)
 
virtual void ClearFQNameCache ()
 
ObjTypeFQNPair UUIDToFQName (const std::string &uuid_str, bool deleted_ok=true) const
 
virtual bool UUIDToFQNameShow (const std::string &search_string, const std::string &last_uuid, uint32_t num_entries, std::vector< ConfigDBFQNameCacheEntry > *entries) const
 
virtual std::string uuid_str (const std::string &uuid)
 
virtual std::string GetUUID (const std::string &key) const
 
virtual void InitConnectionInfo ()
 
virtual void UpdateConnectionInfo (bool success, bool force)
 
virtual void GetConnectionInfo (ConfigDBConnInfo &status) const
 
ConfigClientManagermgr ()
 
const ConfigClientManagermgr () const
 

Static Public Member Functions

static void set_watch_disable (bool disable)
 

Protected Types

typedef pair< string, string > UUIDValueType
 
typedef list< UUIDValueTypeUUIDValueList
 
- Protected Types inherited from ConfigDbClient
typedef std::map< std::string,
FQNameCacheType
FQNameCacheMap
 

Protected Member Functions

virtual bool BulkDataSync ()
 
void EnqueueDBSyncRequest (const UUIDValueList &uuid_list)
 
virtual int HashUUID (const std::string &uuid_str) const
 
int num_workers () const
 
PartitionListpartitions ()
 
virtual void PostShutdown ()
 
- Protected Member Functions inherited from ConfigDbClient
virtual void FillFQNameCacheInfo (const std::string &uuid, FQNameCacheMap::const_iterator it, ConfigDBFQNameCacheEntry *entry) const
 
virtual const int GetMaxRequestsToYield () const
 
virtual const uint64_t GetInitRetryTimeUSec () const
 
virtual uint32_t GetNumReadRequestToBunch () const
 
EventManagerevent_manager ()
 

Private Member Functions

bool InitRetry ()
 
bool UUIDReader ()
 
void HandleEtcdConnectionStatus (bool success, bool force_update=false)
 

Private Attributes

boost::scoped_ptr< EtcdIfeqlif_
 
int num_workers_
 
PartitionList partitions_
 
boost::scoped_ptr< TaskTriggeruuid_reader_
 
tbb::atomic< long > bulk_sync_status_
 

Static Private Attributes

static bool disable_watch_
 

Friends

class ConfigEtcdPartition
 

Additional Inherited Members

- Static Public Attributes inherited from ConfigDbClient
static const uint64_t kInitRetryTimeUSec = 5000000
 
static const int kMaxRequestsToYield = 512
 
static const int kNumEntriesToRead = 4096
 

Detailed Description

Definition at line 183 of file config_etcd_client.h.

Member Typedef Documentation

Definition at line 185 of file config_etcd_client.h.

Definition at line 222 of file config_etcd_client.h.

typedef pair<string, string> ConfigEtcdClient::UUIDValueType
protected

Definition at line 221 of file config_etcd_client.h.

Constructor & Destructor Documentation

ConfigEtcdClient::ConfigEtcdClient ( ConfigClientManager mgr,
EventManager evm,
const ConfigClientOptions options,
int  num_workers 
)

Definition at line 83 of file config_etcd_client.cc.

Here is the call graph for this function:

ConfigEtcdClient::~ConfigEtcdClient ( )
virtual

Definition at line 108 of file config_etcd_client.cc.

Here is the call graph for this function:

Member Function Documentation

bool ConfigEtcdClient::BulkDataSync ( )
protectedvirtual

Definition at line 245 of file config_etcd_client.cc.

void ConfigEtcdClient::BulkSyncDone ( )

Definition at line 253 of file config_etcd_client.cc.

Here is the call graph for this function:

void ConfigEtcdClient::EnqueueDBSyncRequest ( const UUIDValueList uuid_list)
protected

Definition at line 378 of file config_etcd_client.cc.

Here is the call graph for this function:

void ConfigEtcdClient::EnqueueUUIDRequest ( string  oper,
string  obj_type,
string  uuid_str 
)

uuid contains the entire config path For instance /contrail/virtual_network/<uuid> We form the request with the entire path so that testing code can utilize it to form various requests for the same uuid. However, when the request is processed later by the appropriate Partition, the path will be trimmed and only the uuid string will be used. Same is the case for the FQName cache. It will use the trimmed uuid as the key since it is invoked from the Partitions later.

Definition at line 296 of file config_etcd_client.cc.

Here is the call graph for this function:

ConfigEtcdPartition * ConfigEtcdClient::GetPartition ( const string &  uuid)

Definition at line 274 of file config_etcd_client.cc.

Here is the call graph for this function:

const ConfigEtcdPartition * ConfigEtcdClient::GetPartition ( const string &  uuid) const

Definition at line 280 of file config_etcd_client.cc.

Here is the call graph for this function:

const ConfigEtcdPartition * ConfigEtcdClient::GetPartition ( int  worker_id) const

Definition at line 286 of file config_etcd_client.cc.

void ConfigEtcdClient::HandleEtcdConnectionStatus ( bool  success,
bool  force_update = false 
)
private

Definition at line 215 of file config_etcd_client.cc.

Here is the call graph for this function:

int ConfigEtcdClient::HashUUID ( const std::string &  uuid_str) const
protectedvirtual

Definition at line 291 of file config_etcd_client.cc.

void ConfigEtcdClient::InitDatabase ( )
virtual

Implements ConfigDbClient.

Definition at line 199 of file config_etcd_client.cc.

Here is the call graph for this function:

bool ConfigEtcdClient::InitRetry ( )
private

Definition at line 237 of file config_etcd_client.cc.

Here is the call graph for this function:

bool ConfigEtcdClient::IsListOrMapPropEmpty ( const string &  uuid_key,
const string &  lookup_key 
)
virtual

Definition at line 532 of file config_etcd_client.cc.

Here is the call graph for this function:

bool ConfigEtcdClient::IsTaskTriggered ( ) const
virtual

Walk the partitions and check if ConfigReader task has been triggered in any of them. If so, return true.

Reimplemented from ConfigDbClient.

Definition at line 504 of file config_etcd_client.cc.

Here is the call graph for this function:

int ConfigEtcdClient::num_workers ( ) const
inlineprotected

Definition at line 228 of file config_etcd_client.h.

PartitionList& ConfigEtcdClient::partitions ( )
inlineprotected

Definition at line 229 of file config_etcd_client.h.

void ConfigEtcdClient::PostShutdown ( )
protectedvirtual

Implements ConfigDbClient.

Definition at line 266 of file config_etcd_client.cc.

Here is the call graph for this function:

void ConfigEtcdClient::ProcessResponse ( EtcdResponse  resp)
virtual

If reinit is triggerred, don't consume the message. Also, stop etcd watch.

To stqrt consuming the message, we should have finished bulk sync in case we started it.

Check for errors and enqueue UUID update/delete request. Also update FQName cache.

Definition at line 164 of file config_etcd_client.cc.

Here is the call graph for this function:

static void ConfigEtcdClient::set_watch_disable ( bool  disable)
inlinestatic

Definition at line 217 of file config_etcd_client.h.

void ConfigEtcdClient::StartWatcher ( )
virtual

If reinit is triggerred, Don't start the ETCD watcher.

Reimplemented from ConfigDbClient.

Definition at line 112 of file config_etcd_client.cc.

Here is the call graph for this function:

bool ConfigEtcdClient::UUIDReader ( )
private

Ensure that UUIDReader task aborts on reinit trigger.

Get number of UUIDs to read at a time

Read num_entries UUIDs at a time

Process read response

Got UUID data for given ObjType

Parse the json string to get uuid and value

Process the UUID response in parallel by assigning the UUIDs to partitions.

Get the next key to read for the current ObjType

If we read less than what we sought, it means there are no more entries for current obj-type. We move to next obj-type.

ObjType not found. Continue reading next ObjType

RPC failure. Connection down. Retry after a while

Definition at line 386 of file config_etcd_client.cc.

Here is the call graph for this function:

bool ConfigEtcdClient::UUIDToObjCacheShow ( const string &  search_string,
int  inst_num,
const string &  last_uuid,
uint32_t  num_entries,
vector< ConfigDBUUIDCacheEntry > *  entries 
) const
virtual

Definition at line 522 of file config_etcd_client.cc.

Here is the call graph for this function:

Friends And Related Function Documentation

friend class ConfigEtcdPartition
friend

Definition at line 233 of file config_etcd_client.h.

Member Data Documentation

tbb::atomic<long> ConfigEtcdClient::bulk_sync_status_
private

Definition at line 250 of file config_etcd_client.h.

bool ConfigEtcdClient::disable_watch_
staticprivate

Definition at line 244 of file config_etcd_client.h.

boost::scoped_ptr<EtcdIf> ConfigEtcdClient::eqlif_
private

Definition at line 246 of file config_etcd_client.h.

int ConfigEtcdClient::num_workers_
private

Definition at line 247 of file config_etcd_client.h.

PartitionList ConfigEtcdClient::partitions_
private

Definition at line 248 of file config_etcd_client.h.

boost::scoped_ptr<TaskTrigger> ConfigEtcdClient::uuid_reader_
private

Definition at line 249 of file config_etcd_client.h.


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