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

#include <config_etcd_client.h>

Collaboration diagram for ConfigEtcdPartition:

Classes

class  UUIDCacheEntry
 
struct  UUIDProcessRequestType
 

Public Types

typedef boost::shared_ptr
< WorkQueue< ObjectProcessReq * > > 
UUIDProcessWorkQType
 
typedef boost::ptr_map< string,
UUIDCacheEntry
UUIDCacheMap
 

Public Member Functions

 ConfigEtcdPartition (ConfigEtcdClient *client, size_t idx)
 
virtual ~ConfigEtcdPartition ()
 
UUIDCacheEntryGetUUIDCacheEntry (const string &uuid)
 
const UUIDCacheEntryGetUUIDCacheEntry (const string &uuid) const
 
UUIDCacheEntryGetUUIDCacheEntry (const string &uuid, const string &value_str, bool &is_new)
 
const UUIDCacheEntryGetUUIDCacheEntry (const string &uuid, const string &value_str, bool &is_new) const
 
void DeleteCacheMap (const string &uuid)
 
virtual int UUIDRetryTimeInMSec (const UUIDCacheEntry *obj) const
 
void FillUUIDToObjCacheInfo (const string &uuid, UUIDCacheMap::const_iterator uuid_iter, ConfigDBUUIDCacheEntry *entry) const
 
bool UUIDToObjCacheShow (const string &search_string, const string &last_uuid, uint32_t num_entries, vector< ConfigDBUUIDCacheEntry > *entries) const
 
int GetInstanceId () const
 
UUIDProcessWorkQType obj_process_queue ()
 
void Enqueue (ObjectProcessReq *req)
 
bool IsListOrMapPropEmpty (const string &uuid_key, const string &lookup_key)
 
virtual bool IsTaskTriggered () const
 

Static Public Attributes

static const uint32_t kMaxUUIDRetryTimePowOfTwo = 20
 
static const uint32_t kMinUUIDRetryTimeMSec = 100
 

Protected Member Functions

ConfigEtcdClientclient ()
 

Private Types

typedef map< string,
UUIDProcessRequestType * > 
UUIDProcessSet
 

Private Member Functions

bool RequestHandler (ObjectProcessReq *req)
 
void AddUUIDToProcessList (const string &oper, const string &uuid_key, const string &value_str)
 
bool ConfigReader ()
 
void ProcessUUIDUpdate (const string &uuid_key, const string &value_str)
 
void ProcessUUIDDelete (const string &uuid_key)
 
virtual bool GenerateAndPushJson (const string &uuid_key, Document &doc, bool add_change, UUIDCacheEntry *cache)
 
void RemoveObjReqEntry (string &uuid)
 

Private Attributes

UUIDProcessWorkQType obj_process_queue_
 
UUIDProcessSet uuid_process_set_
 
UUIDCacheMap uuid_cache_map_
 
boost::shared_ptr< TaskTriggerconfig_reader_
 
ConfigEtcdClientconfig_client_
 
int worker_id_
 

Friends

class ConfigEtcdClient
 

Detailed Description

Definition at line 40 of file config_etcd_client.h.

Member Typedef Documentation

typedef boost::ptr_map<string, UUIDCacheEntry> ConfigEtcdPartition::UUIDCacheMap

Definition at line 101 of file config_etcd_client.h.

Definition at line 154 of file config_etcd_client.h.

Definition at line 46 of file config_etcd_client.h.

Constructor & Destructor Documentation

ConfigEtcdPartition::ConfigEtcdPartition ( ConfigEtcdClient client,
size_t  idx 
)

Definition at line 537 of file config_etcd_client.cc.

Here is the call graph for this function:

ConfigEtcdPartition::~ConfigEtcdPartition ( )
virtual

Definition at line 551 of file config_etcd_client.cc.

Member Function Documentation

void ConfigEtcdPartition::AddUUIDToProcessList ( const string &  oper,
const string &  uuid_key,
const string &  value_str 
)
private

Add the UUID key/value pair to the process list.

Get UUID from uuid_key which contains the entire path and insert into uuid_process_set_

UUID not present in uuid_process_set_. If uuid_process_set_ is empty, trigger config_reader_ to process the uuids.

UUID already present in uuid_process_set_. If operation is DELETE preceeded by CREATE, remove from uuid_process_set_. For other cases (CREATE/UPDATE) replace the entry with the new value and oper.

Definition at line 568 of file config_etcd_client.cc.

Here is the call graph for this function:

ConfigEtcdClient* ConfigEtcdPartition::client ( )
inlineprotected

Definition at line 136 of file config_etcd_client.h.

bool ConfigEtcdPartition::ConfigReader ( )
private

Walk through the requests in uuid_process_set_ and process them. uuid_process_set_ contains the response from ETCD with the uuid key-value pairs. Config reader task should stop on reinit trigger

Max. UUIDs to be processed in one config reader task exectution is bound by kMaxRequestsToYield

Definition at line 1256 of file config_etcd_client.cc.

Here is the call graph for this function:

void ConfigEtcdPartition::DeleteCacheMap ( const string &  uuid)
inline

Definition at line 111 of file config_etcd_client.h.

void ConfigEtcdPartition::Enqueue ( ObjectProcessReq req)

Definition at line 555 of file config_etcd_client.cc.

void ConfigEtcdPartition::FillUUIDToObjCacheInfo ( const string &  uuid,
UUIDCacheMap::const_iterator  uuid_iter,
ConfigDBUUIDCacheEntry *  entry 
) const

Definition at line 615 of file config_etcd_client.cc.

Here is the call graph for this function:

bool ConfigEtcdPartition::GenerateAndPushJson ( const string &  uuid_key,
Document &  doc,
bool  add_change,
UUIDCacheEntry cache 
)
privatevirtual

Properties like perms2 has no importance to control-node/dns This property is present on each config object. Hence skipping such properties gives performance improvement.

Get the type string. This will be used as the key. Also remove this field from the document.

Handle prop_map and prop_list objects. Need to indicate in cache if they are NULL. To find if obj is prop_list or prop_map, we use the WrapperFieldNames defined in schema. Today they are present only for prop_list and prop_map. If that changes, logic here has to change to accommodate it.

Process parent_type. Need to change - to _.

Process parent_uuid. For creates/updates, check if parent fq_name is present. If not, enable retry.

Process bgpaas_session_attributes property. Value needs to be set to "".

For _refs, if attr is NULL, replace NULL with "". Also add fq_name to each _ref. Deletes do not need manipulation of _refs as previous create/update would have already formatted them.

Add ref_fq_name to the _ref ETCD gives ref_fq_name as well but needs to be formatted as a string. Get ref_fq_name from FQNameCache if present. If not re-format the ref_fq_name present in the document as a string and insert it back.

Definition at line 777 of file config_etcd_client.cc.

Here is the call graph for this function:

int ConfigEtcdPartition::GetInstanceId ( ) const
inline

Definition at line 124 of file config_etcd_client.h.

ConfigEtcdPartition::UUIDCacheEntry * ConfigEtcdPartition::GetUUIDCacheEntry ( const string &  uuid)

Definition at line 649 of file config_etcd_client.cc.

const UUIDCacheEntry* ConfigEtcdPartition::GetUUIDCacheEntry ( const string &  uuid) const
ConfigEtcdPartition::UUIDCacheEntry * ConfigEtcdPartition::GetUUIDCacheEntry ( const string &  uuid,
const string &  value_str,
bool &  is_new 
)

Cache entry not present. Create one.

Insert cache entry into UUIDCacheMap.

Indicate to calling function that cache has been newly created.

Cache entry already present. Update LastReadTimestamp.

Return the cache entry.

Definition at line 658 of file config_etcd_client.cc.

Here is the call graph for this function:

const UUIDCacheEntry* ConfigEtcdPartition::GetUUIDCacheEntry ( const string &  uuid,
const string &  value_str,
bool &  is_new 
) const
bool ConfigEtcdPartition::IsListOrMapPropEmpty ( const string &  uuid_key,
const string &  lookup_key 
)

Definition at line 1241 of file config_etcd_client.cc.

Here is the call graph for this function:

bool ConfigEtcdPartition::IsTaskTriggered ( ) const
virtual

Definition at line 1252 of file config_etcd_client.cc.

UUIDProcessWorkQType ConfigEtcdPartition::obj_process_queue ( )
inline

Definition at line 126 of file config_etcd_client.h.

void ConfigEtcdPartition::ProcessUUIDDelete ( const string &  uuid_key)
private

If FQName cache not present for the uuid, it is likely a redundant delete since we remove it from the FQName cache when a delete is processed. Ignore request.

Get the cache entry for the uuid. Assert if uuid is not present in the cache.

If retry timer is running, the original create/update for the UUID has not been processed. Stop the timer, and purge the FQName cache entry.

For CREATES, we could get here in erroneous cases as well. For instance, fq_name or type field not present in the update received. For such cases, only delete cache entry. Get the cached json_str and create a JSON Document. This will be sent to lower layers as a delete.

Fixup the JSON document and push it down to lower layers.

Delete the UUIDCacheEntry.

Purge FQName cache entry.

Definition at line 1007 of file config_etcd_client.cc.

Here is the call graph for this function:

void ConfigEtcdPartition::ProcessUUIDUpdate ( const string &  uuid_key,
const string &  value_str 
)
private

Create UUIDCacheEntry if not present. This will create a JSON document from the value_str and store in cache. The cache entry is then inserted in to the UUIDCacheMap. If cache entry already present, update the timestamp.

Get the cached json_str and create a JSON Document. This will be used to compare with the updated JSON value_str received. As part of the update, fields in cacheDoc that are present in the received update will be removed. Finally, it will contain the fields that are to be deleted.

Create a JSON Document from the received JSON value_str. This will be updated to capture newly created and updated fields. Properties that have not changed will be removed from the document.

If type or fq-name is not present in the db object, ignore the object and trigger delete of the object.

If cache is new, we can send the cacheDoc as is down to the IFMAP server to send as update. If not, we compare the cached version with the updated values and potentially generate two documents.

  1. One that contains thew newly added fields and the fields that were updated.
  2. One that contains the fields that were removed in the received update.

For BOTH creates and updates. Ignore if update is received in draft-mode state and delete from cache.

For new cache entries ONLY, populate fq_name and obj_type fields in the ObjCache. For updates/deletes, cache should already have the fq_name and obj_type fields populated.

For updates ONLY. If cache has the field and if it has not been updated remove from updDoc. Also, remove the field from cacheDoc. Skip fq_name and obj_type.

Now that the updates are ready, replace the json_str in the cache with the updated value_str.

Fixup the JSON document and push it down to lower layers. Send the creates and updates followed by the deleted fields. Deletes are only sent for UPDATES as there may be properties that were removed in the update. For CREATES, there is nothing to delete as they are just newly added to cache. When adding/updating properties, if there is an error, retry after a while.

Definition at line 1074 of file config_etcd_client.cc.

Here is the call graph for this function:

void ConfigEtcdPartition::RemoveObjReqEntry ( string &  uuid)
private

Definition at line 1305 of file config_etcd_client.cc.

Here is the call graph for this function:

bool ConfigEtcdPartition::RequestHandler ( ObjectProcessReq req)
private

Definition at line 559 of file config_etcd_client.cc.

Here is the call graph for this function:

int ConfigEtcdPartition::UUIDRetryTimeInMSec ( const UUIDCacheEntry obj) const
virtual

Definition at line 697 of file config_etcd_client.cc.

Here is the call graph for this function:

bool ConfigEtcdPartition::UUIDToObjCacheShow ( const string &  search_string,
const string &  last_uuid,
uint32_t  num_entries,
vector< ConfigDBUUIDCacheEntry > *  entries 
) const

Definition at line 626 of file config_etcd_client.cc.

Here is the call graph for this function:

Friends And Related Function Documentation

friend class ConfigEtcdClient
friend

Definition at line 141 of file config_etcd_client.h.

Member Data Documentation

ConfigEtcdClient* ConfigEtcdPartition::config_client_
private

Definition at line 175 of file config_etcd_client.h.

boost::shared_ptr<TaskTrigger> ConfigEtcdPartition::config_reader_
private

Definition at line 174 of file config_etcd_client.h.

const uint32_t ConfigEtcdPartition::kMaxUUIDRetryTimePowOfTwo = 20
static

Definition at line 98 of file config_etcd_client.h.

const uint32_t ConfigEtcdPartition::kMinUUIDRetryTimeMSec = 100
static

Definition at line 99 of file config_etcd_client.h.

UUIDProcessWorkQType ConfigEtcdPartition::obj_process_queue_
private

Definition at line 171 of file config_etcd_client.h.

UUIDCacheMap ConfigEtcdPartition::uuid_cache_map_
private

Definition at line 173 of file config_etcd_client.h.

UUIDProcessSet ConfigEtcdPartition::uuid_process_set_
private

Definition at line 172 of file config_etcd_client.h.

int ConfigEtcdPartition::worker_id_
private

Definition at line 176 of file config_etcd_client.h.


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