OpenSDN source code
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)
 
ConfigEtcdPartition * GetPartition (const string &uuid)
 
const ConfigEtcdPartition * GetPartition (const string &uuid) const
 
const ConfigEtcdPartition * GetPartition (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
 
ConfigClientManager * mgr ()
 
const ConfigClientManager * mgr () const
 

Static Public Member Functions

static void set_watch_disable (bool disable)
 

Protected Types

typedef pair< string, string > UUIDValueType
 
typedef list< UUIDValueType > UUIDValueList
 
- 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
 
PartitionList & partitions ()
 
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
 
EventManager * event_manager ()
 

Private Member Functions

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

Private Attributes

boost::scoped_ptr< EtcdIf > eqlif_
 
int num_workers_
 
PartitionList partitions_
 
boost::scoped_ptr< TaskTrigger > uuid_reader_
 
std::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 185 of file config_etcd_client.h.

Member Typedef Documentation

◆ PartitionList

Definition at line 187 of file config_etcd_client.h.

◆ UUIDValueList

Definition at line 224 of file config_etcd_client.h.

◆ UUIDValueType

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

Definition at line 223 of file config_etcd_client.h.

Constructor & Destructor Documentation

◆ ConfigEtcdClient()

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

Definition at line 84 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ ~ConfigEtcdClient()

ConfigEtcdClient::~ConfigEtcdClient ( )
virtual

Definition at line 109 of file config_etcd_client.cc.

Here is the call graph for this function:

Member Function Documentation

◆ BulkDataSync()

bool ConfigEtcdClient::BulkDataSync ( )
protectedvirtual

Definition at line 246 of file config_etcd_client.cc.

◆ BulkSyncDone()

void ConfigEtcdClient::BulkSyncDone ( )

Definition at line 254 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ EnqueueDBSyncRequest()

void ConfigEtcdClient::EnqueueDBSyncRequest ( const UUIDValueList &  uuid_list)
protected

Definition at line 379 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ EnqueueUUIDRequest()

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 297 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ GetPartition() [1/3]

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

Definition at line 275 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ GetPartition() [2/3]

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

Definition at line 281 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ GetPartition() [3/3]

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

Definition at line 287 of file config_etcd_client.cc.

◆ HandleEtcdConnectionStatus()

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

Definition at line 216 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ HashUUID()

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

Definition at line 292 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ InitDatabase()

void ConfigEtcdClient::InitDatabase ( )
virtual

Implements ConfigDbClient.

Definition at line 200 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ InitRetry()

bool ConfigEtcdClient::InitRetry ( )
private

Definition at line 238 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ IsListOrMapPropEmpty()

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

Definition at line 533 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ IsTaskTriggered()

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 505 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ num_workers()

int ConfigEtcdClient::num_workers ( ) const
inlineprotected

Definition at line 230 of file config_etcd_client.h.

◆ partitions()

PartitionList& ConfigEtcdClient::partitions ( )
inlineprotected

Definition at line 231 of file config_etcd_client.h.

◆ PostShutdown()

void ConfigEtcdClient::PostShutdown ( )
protectedvirtual

Implements ConfigDbClient.

Definition at line 267 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ ProcessResponse()

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 165 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ set_watch_disable()

static void ConfigEtcdClient::set_watch_disable ( bool  disable)
inlinestatic

Definition at line 219 of file config_etcd_client.h.

◆ StartWatcher()

void ConfigEtcdClient::StartWatcher ( )
virtual

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

Reimplemented from ConfigDbClient.

Definition at line 113 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ UUIDReader()

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 387 of file config_etcd_client.cc.

Here is the call graph for this function:

◆ UUIDToObjCacheShow()

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 523 of file config_etcd_client.cc.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ ConfigEtcdPartition

friend class ConfigEtcdPartition
friend

Definition at line 235 of file config_etcd_client.h.

Member Data Documentation

◆ bulk_sync_status_

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

Definition at line 252 of file config_etcd_client.h.

◆ disable_watch_

bool ConfigEtcdClient::disable_watch_
staticprivate

Definition at line 246 of file config_etcd_client.h.

◆ eqlif_

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

Definition at line 248 of file config_etcd_client.h.

◆ num_workers_

int ConfigEtcdClient::num_workers_
private

Definition at line 249 of file config_etcd_client.h.

◆ partitions_

PartitionList ConfigEtcdClient::partitions_
private

Definition at line 250 of file config_etcd_client.h.

◆ uuid_reader_

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

Definition at line 251 of file config_etcd_client.h.


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