OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
qos_index.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include "cmn/agent.h"
6 #include "cmn/agent_cmn.h"
7 #include <sandesh/sandesh_types.h>
8 #include <sandesh/sandesh.h>
12 #include "qos_index.h"
13 #include "resource_manager/resource_manager_types.h"
15 
18  Resource::QOS_INDEX), uuid_(uuid) {
19 
20 }
21 
22 void QosIndexResourceKey::Backup(ResourceData *data, uint16_t op){
23  IndexResourceData *index_data = static_cast<IndexResourceData *>(data);
24  if (op == ResourceBackupReq::DEL) {
25  rm()->backup_mgr()->
26  sandesh_maps().DeleteQosResourceEntry(index_data->index());
27  } else {
28  QosIndexResource backup_data;
29  backup_data.set_uuid(UuidToString(uuid_));
30  backup_data.set_time_stamp(UTCTimestampUsec());
31  rm()->backup_mgr()->
32  sandesh_maps().AddQosResourceEntry(index_data->index(),
33  backup_data);
34  }
36  TriggerBackup();
37 
38 }
39 bool QosIndexResourceKey::IsLess(const ResourceKey &rhs) const {
40  const QosIndexResourceKey *vm_key =
41  static_cast<const QosIndexResourceKey *>(&rhs);
42  return uuid_ < vm_key->uuid_;
43 }
QosBackUpResourceTable & qos_index_table()
Definition: sandesh_map.h:289
virtual bool IsLess(const ResourceKey &rhs) const
Definition: qos_index.cc:39
boost::uuids::uuid uuid
static std::string UuidToString(const boost::uuids::uuid &id)
Definition: string_util.h:138
QosIndexResourceKey(ResourceManager *rm, const boost::uuids::uuid &uuid_)
Definition: qos_index.cc:16
ResourceManager * rm()
ResourceBackupManager * backup_mgr()
boost::uuids::uuid uuid_
Definition: qos_index.h:26
static uint64_t UTCTimestampUsec()
Definition: time_util.h:13
ResourceSandeshMaps & sandesh_maps()
uint32_t index() const
virtual void Backup(ResourceData *data, uint16_t op)
Definition: qos_index.cc:22