OpenSDN source code
|
#include <config_etcd_client.h>
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 () |
UUIDCacheEntry * | GetUUIDCacheEntry (const string &uuid) |
const UUIDCacheEntry * | GetUUIDCacheEntry (const string &uuid) const |
UUIDCacheEntry * | GetUUIDCacheEntry (const string &uuid, const string &value_str, bool &is_new) |
const UUIDCacheEntry * | GetUUIDCacheEntry (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 | |
ConfigEtcdClient * | client () |
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< TaskTrigger > | config_reader_ |
ConfigEtcdClient * | config_client_ |
int | worker_id_ |
Friends | |
class | ConfigEtcdClient |
Definition at line 40 of file config_etcd_client.h.
typedef boost::ptr_map<string, UUIDCacheEntry> ConfigEtcdPartition::UUIDCacheMap |
Definition at line 101 of file config_etcd_client.h.
|
private |
Definition at line 154 of file config_etcd_client.h.
typedef boost::shared_ptr<WorkQueue<ObjectProcessReq *> > ConfigEtcdPartition::UUIDProcessWorkQType |
Definition at line 46 of file config_etcd_client.h.
ConfigEtcdPartition::ConfigEtcdPartition | ( | ConfigEtcdClient * | client, |
size_t | idx | ||
) |
|
virtual |
Definition at line 551 of file config_etcd_client.cc.
|
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.
|
inlineprotected |
Definition at line 136 of file config_etcd_client.h.
|
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.
|
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 |
|
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.
|
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.
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 | ||
) |
|
virtual |
Definition at line 1252 of file config_etcd_client.cc.
|
inline |
Definition at line 126 of file config_etcd_client.h.
|
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.
|
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.
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.
|
private |
|
private |
|
virtual |
bool ConfigEtcdPartition::UUIDToObjCacheShow | ( | const string & | search_string, |
const string & | last_uuid, | ||
uint32_t | num_entries, | ||
vector< ConfigDBUUIDCacheEntry > * | entries | ||
) | const |
|
friend |
Definition at line 141 of file config_etcd_client.h.
|
private |
Definition at line 175 of file config_etcd_client.h.
|
private |
Definition at line 174 of file config_etcd_client.h.
|
static |
Definition at line 98 of file config_etcd_client.h.
|
static |
Definition at line 99 of file config_etcd_client.h.
|
private |
Definition at line 171 of file config_etcd_client.h.
|
private |
Definition at line 173 of file config_etcd_client.h.
|
private |
Definition at line 172 of file config_etcd_client.h.
|
private |
Definition at line 176 of file config_etcd_client.h.