OpenSDN source code
sandesh_map.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #include <fstream>
7 #include <dirent.h>
8 #include <cctype>
9 #include <stdlib.h>
10 #include <cmn/agent.h>
11 #include <boost/filesystem.hpp>
12 #include <boost/functional/hash.hpp>
13 #include <boost/algorithm/string.hpp>
14 #include "init/agent_param.h"
15 #include <base/timer.h>
16 #include <sandesh/sandesh_types.h>
17 #include <sandesh/sandesh.h>
28 #include <oper/nexthop.h>
29 
31  const std::string &name,
32  const std::string &file_name) :
33  backup_manager_(manager), agent_(manager->agent()), name_(name),
34  last_modified_time_(UTCTimestampUsec()) {
35 
36  if (!agent_->isMockMode()) {
38  }
39  else {
40  backup_dir_ = "/tmp/" + agent_->AgentGUID() +
42  }
43 
46  file_name_str_ = backup_dir_ + "/" + file_name;
47  file_name_prefix_ = file_name + "-";
48  boost::filesystem::path dir(backup_dir_.c_str());
49  if (!boost::filesystem::exists(backup_dir_))
50  boost::filesystem::create_directory(backup_dir_);
52  name,
54  GetTaskId(kAgentResourceBackUpTask));
55 }
56 
58  timer_->Cancel();
60 }
61 
63  // Check for Update required otherwise wait for fallback time.
65  if (WriteToFile()) {
67  fall_back_count_ = 0;
68  return false;
69  }
70  }
72  return true;
73 }
74 
77  boost::bind(&BackUpResourceTable::TimerExpiry, this));
78 }
79 
80 // Don't Update the file if there is any activity seen with in
81 // backup_idle_timeout_ and start the fallback count so that
82 // after 6th itteration file can be updated.
83 // if write to file fails trigger the timer.
85  if (timer_->running() == false)
86  //Start Fallback timer.
87  StartTimer();
89 }
90 
92  uint64_t current_time_stamp = UTCTimestampUsec();
93  // dont update the file if the frequent updates are seen with in 10sec.
94  if (current_time_stamp - last_modified_time_ <
96  return false;
97  }
98  return true;
99 }
100 
104 }
105 
106 // Write the content to file temprory file and rename the file
107 static const std::string TempFilePath(const std::string &file_name) {
108  std::stringstream temp_file_stream;
109  temp_file_stream << file_name << ".tmp";
110  std::ofstream output;
111  // Trunctate the file as it is a fresh write for the modified Map
112  output.open(temp_file_stream.str().c_str(),
113  std::ofstream::binary | std::ofstream::trunc);
114  if (!output.good()) {
115  LOG(ERROR, "File open failed" << temp_file_stream.str());
116  output.close();
117  return std::string();
118  }
119 
120  output.close();
121  return temp_file_stream.str();
122 }
123 
124 // Rename the Temp file
125 static bool RenameFile(const std::string &file_tmp_name,
126  const std::string &file_name) {
127  boost::system::error_code ec;
128  boost::filesystem::path tmp_file_path(file_tmp_name.c_str());
129  boost::filesystem::path backup_file_path(file_name.c_str());
130  boost::filesystem::rename(tmp_file_path, backup_file_path, ec);
131  if (ec.failed()) {
132  LOG(ERROR, "Resource backup mgr Rename file failed" << ec);
133  return false;
134  }
135  return true;
136 }
137 
138 // Calulate the Hash value for the stored file
139 // This hash sum will be validated while reading the content.
140 bool BackUpResourceTable::CalculateHashSum(const std::string &file_name,
141  uint32_t *hashsum) {
142  std::unique_ptr<uint8_t> buffer;
143  uint32_t size = ResourceBackupManager::ReadResourceDataFromFile(file_name,
144  &(buffer));
145  if (size && buffer.get()) {
146  *hashsum = (uint32_t)boost::hash_range(buffer.get(),
147  buffer.get()+size);
148  return true;
149  }
150  return false;
151 }
152 
153 // Type T1 is Final output sandesh structure writes in to file
154 // Type T2 index map for the specific table
155 // Write the Map to file
156 // Calculate the hashsum and append that to file name
157 // so that validated while reading file
158 template <typename T1, typename T2>
160  const T2& index_map) {
161  uint32_t write_buff_size = 0;
162  int error = 0;
163 
164  const std::string temp_file = TempFilePath(file_name_str());
165  if (temp_file.empty()) {
166  LOG(ERROR, "Temp file is not created");
167  return false;
168  }
169 
170  sandesh_data->set_index_map(index_map);
171  sandesh_data->set_time_stamp(UTCTimestampUsec());
172  write_buff_size = sandesh_data->WriteBinaryToFile(temp_file, &error);
173  if (error != 0) {
174  LOG(ERROR, "Sandesh Write Binary failed " << write_buff_size);
175  return false;
176  }
177 
178  uint32_t hashsum;
179  if (CalculateHashSum(temp_file, &hashsum)) {
180  // remove the file with existing hashsum extention.
181  std::string file = FindFile(backup_dir(), file_name_prefix());
182  if (!file.empty()) {
183  std::string file_path = backup_dir_ + "/" + file;
184  std::remove(file_path.c_str());
185  }
186  // rename the tmp file to new file by appending hashsum
187  std::stringstream file_path;
188  file_path << file_name_str() << "-" << hashsum;
189  return RenameFile(temp_file, file_path.str());
190  }
191 
192  return false;
193 }
194 
195 // TODO final file format needs to be defined along with 3rd backup file.
196 // function needs to be enhanced with 3rd backup file.
197 // Find the file with the prefix.
198 const std::string
199 BackUpResourceTable::FindFile(const std::string &root,
200  const std::string & file_prefix) {
201  DIR *dir_path;
202  struct dirent *dir;
203  if ((dir_path = opendir(root.c_str())) == NULL) {
204  return std::string();
205  }
206  while ((dir = readdir(dir_path)) != NULL) {
207  std::string file_name = dir->d_name;
208  // Match with the file prefix name if is not there return empty string
209  // Check Start of the file_name matches with prefix name.
210  if (!file_name.find(file_prefix)) {
211  // check for file format filename-hashvalue(digits)
212  // example name contrail_interface_resource-12345678
213  std::string tmpstr(file_name.c_str());
214  std::vector<string> tokens;
215  boost::split(tokens, tmpstr, boost::is_any_of("-"));
216  // split the string check after file prefix hashsum is number.
217  std::string token;
218  if (tokens.size()) {
219  // TODO file format changes this needs to be revisited.
220  token = tokens[tokens.size() - 1];
221  }
222 
223  bool found = true;
224  for (int i =0; token[i] != '\0'; i++) {
225  if (!isdigit(token[i])) {
226  found = false;
227  break;
228  }
229  }
230 
231  if (found) {
232  closedir(dir_path);
233  return file_name;
234  }
235  }
236  }
237  closedir(dir_path);
238  return std::string();
239 }
240 
241 // Read Map from the file.
242 // First read the file to a buffer
243 // verify that hash sum matches
244 template <typename T>
246  const std::string &root) {
247  // Find the File with prefix name
248  const std::string file_name = FindFile(root, file_name_prefix());
249  int error = 0;
250  if (file_name.empty()) {
251  LOG(DEBUG, "File name with prefix not found ");
252  return;
253  }
254  // Make the complete file path with hash value
255  std::stringstream file_path;
256  file_path << root << "/"<< file_name;
257  if (!boost::filesystem::exists( file_path.str().c_str())) {
258  LOG(DEBUG, "File path not found " << file_path.str());
259  return;
260  }
261  std::unique_ptr<uint8_t> buffer;
262  uint32_t size = ResourceBackupManager::ReadResourceDataFromFile(file_path.str(),
263  &(buffer));
264  if (buffer.get()) {
265  if (size) {
266  uint32_t hashsum = (uint32_t)boost::hash_range(buffer.get(),
267  buffer.get()+size);
268  std::stringstream hash_value;
269  hash_value << hashsum;
270  // Check for hashsum present.
271  if (std::string::npos !=
272  file_name.find(hash_value.str())) {
273  sandesh_data->ReadBinary(buffer.get(), size, &error);
274  if (error != 0) {
275  LOG(ERROR, "Sandesh Read Binary failed ");
276  }
277  }
278  }
279  }
280 }
281 
283 (ResourceBackupManager *manager) :
284  BackUpResourceTable(manager, "VrfMplsBackUpResourceTable",
285  "contrail_vrf_resource") {
286 }
287 
289 }
290 
292  VrfMplsResourceMapSandesh sandesh_data;
293  return WriteMapToFile<VrfMplsResourceMapSandesh, Map> (&sandesh_data, map_);
294 }
295 
297  VrfMplsResourceMapSandesh sandesh_data;
298  ReadMapFromFile<VrfMplsResourceMapSandesh>(&sandesh_data,
299  backup_dir());
300  map_ = sandesh_data.get_index_map();
301 }
302 
304  for (MapIter it = map_.begin(); it != map_.end(); it++) {
305  uint32_t index = it->first;
306  VrfMplsResource sandesh_key = it->second;
307  VrfNHKey *vrf_nh_key = new VrfNHKey(sandesh_key.get_name(), false,
308  sandesh_key.get_bridge_nh());
310  backup_manager()->resource_manager(),
311  vrf_nh_key));
313  (backup_manager()->resource_manager(),
314  index));
315  EnqueueRestore(key, data);
316  }
317 }
318 
320 (ResourceBackupManager *manager) :
321  BackUpResourceTable(manager, "VlanMplsBackUpResourceTable",
322  "contrail_vlan_resource") {
323 }
324 
326 }
327 
329  VlanMplsResourceMapSandesh sandesh_data;
330  return WriteMapToFile<VlanMplsResourceMapSandesh, Map>
331  (&sandesh_data, map_);
332 }
333 
335  VlanMplsResourceMapSandesh sandesh_data;
336  ReadMapFromFile<VlanMplsResourceMapSandesh>(&sandesh_data,
337  backup_dir());
338  map_ = sandesh_data.get_index_map();
339 }
340 
342  for (MapIter it = map_.begin(); it != map_.end(); it++) {
343  uint32_t index = it->first;
344  VlanMplsResource sandesh_key = it->second;
345  VlanNHKey *vlan_nh_key = new VlanNHKey(
346  StringToUuid(sandesh_key.get_uuid()),
347  sandesh_key.get_tag());
349  backup_manager()->resource_manager(),
350  vlan_nh_key));
352  (backup_manager()->resource_manager(),
353  index));
354  EnqueueRestore(key, data);
355  }
356 }
357 
359 (ResourceBackupManager *manager) :
360  BackUpResourceTable(manager, "RouteMplsBackUpResourceTable",
361  "contrail_route_resource") {
362 }
363 
365 }
366 
368  RouteMplsResourceMapSandesh sandesh_data;
369  return WriteMapToFile<RouteMplsResourceMapSandesh, Map> (&sandesh_data, map_);
370 }
371 
373  RouteMplsResourceMapSandesh sandesh_data;
374  ReadMapFromFile<RouteMplsResourceMapSandesh>(&sandesh_data, backup_dir());
375  map_ = sandesh_data.get_index_map();
376 }
377 
379  for (MapIter it = map_.begin(); it != map_.end(); it++) {
380  uint32_t index = it->first;
381  RouteMplsResource sandesh_key = it->second;
383  (backup_manager()->resource_manager(),
384  sandesh_key.get_vrf_name(),
385  sandesh_key.get_route_prefix()));
387  (backup_manager()->resource_manager(),
388  index));
389  EnqueueRestore(key, data);
390  }
391 }
392 
394 (ResourceBackupManager *manager) :
395  BackUpResourceTable(manager, "InterfaceMplsBackUpResourceTable",
396  "contrail_interface_resource") {
397 }
398 
400 }
401 
403  InterfaceIndexResourceMapSandesh sandesh_data;
404  return WriteMapToFile<InterfaceIndexResourceMapSandesh, Map>
405  (&sandesh_data, map_);
406 }
407 
409  InterfaceIndexResourceMapSandesh sandesh_data;
410  ReadMapFromFile<InterfaceIndexResourceMapSandesh>
411  (&sandesh_data, backup_dir());
412  map_ = sandesh_data.get_index_map();
413 }
414 
416  for (MapIter it = map_.begin(); it != map_.end(); it++) {
417  uint32_t index = it->first;
418  InterfaceIndexResource sandesh_key = it->second;
419  MacAddress mac = MacAddress::FromString(sandesh_key.get_mac());
420  std::string type = sandesh_key.get_type();
421  InterfaceNHKey *itf_nh_key = NULL;
422  InterfaceKey *itf_key = NULL;
423  if (type == "vmi") {
424  //Vm interface
426  StringToUuid(sandesh_key.get_uuid()),
427  sandesh_key.get_name());
428  } else {
429  //Inet interface
430  itf_key = new InetInterfaceKey(sandesh_key.get_name());
431  }
432  itf_nh_key = new InterfaceNHKey(itf_key, sandesh_key.get_policy(),
433  sandesh_key.get_flags(), mac);
435  backup_manager()->resource_manager(),
436  itf_nh_key));
438  (backup_manager()->resource_manager(),
439  index));
440  EnqueueRestore(key, data);
441  }
442 }
443 // Vm interface backup.
445 (ResourceBackupManager *manager) :
446  BackUpResourceTable(manager, "VmInterfaceBackUpResourceTable",
447  "contrail_vm_interface_resource") {
448 }
449 
451 }
452 
454  VmInterfaceIndexResourceMapSandesh sandesh_data;
455  return WriteMapToFile<VmInterfaceIndexResourceMapSandesh, Map>
456  (&sandesh_data, map_);
457 }
458 
460  VmInterfaceIndexResourceMapSandesh sandesh_data;
461  ReadMapFromFile<VmInterfaceIndexResourceMapSandesh>
462  (&sandesh_data, backup_dir());
463  map_ = sandesh_data.get_index_map();
464 }
465 
467  for (MapIter it = map_.begin(); it != map_.end(); it++) {
468  uint32_t index = it->first;
469  VmInterfaceIndexResource sandesh_key = it->second;
470 
472  backup_manager()->resource_manager(),
473  StringToUuid(sandesh_key.get_uuid()),
474  sandesh_key.get_interface_name()));
476  (backup_manager()->resource_manager(),
477  index));
478  EnqueueRestore(key, data);
479  }
480 }
481 // Vrf backup.
483 (ResourceBackupManager *manager) :
484  BackUpResourceTable(manager, "VrfBackUpResourceTable",
485  "contrail_vrf_index_resource") {
486 }
487 
489 }
490 
492  VrfIndexResourceMapSandesh sandesh_data;
493  return WriteMapToFile<VrfIndexResourceMapSandesh, Map>
494  (&sandesh_data, map_);
495 }
496 
498  VrfIndexResourceMapSandesh sandesh_data;
499  ReadMapFromFile<VrfIndexResourceMapSandesh>
500  (&sandesh_data, backup_dir());
501  map_ = sandesh_data.get_index_map();
502 }
503 
505  for (MapIter it = map_.begin(); it != map_.end(); it++) {
506  uint32_t index = it->first;
507  VrfIndexResource sandesh_key = it->second;
508 
510  backup_manager()->resource_manager(),
511  sandesh_key.get_vrf_name()));
513  (backup_manager()->resource_manager(),
514  index));
515  EnqueueRestore(key, data);
516  }
517 }
518 
519 // Qos id backup.
521 (ResourceBackupManager *manager) :
522  BackUpResourceTable(manager, "QosBackUpResourceTable",
523  "contrail_qos_resource") {
524 }
525 
527 }
528 
530  QosIndexResourceMapSandesh sandesh_data;
531  return WriteMapToFile<QosIndexResourceMapSandesh, Map>
532  (&sandesh_data, map_);
533 }
534 
536  QosIndexResourceMapSandesh sandesh_data;
537  ReadMapFromFile<QosIndexResourceMapSandesh>
538  (&sandesh_data, backup_dir());
539  map_ = sandesh_data.get_index_map();
540 }
541 
543  for (MapIter it = map_.begin(); it != map_.end(); it++) {
544  uint32_t index = it->first;
545  QosIndexResource sandesh_key = it->second;
546 
548  backup_manager()->resource_manager(),
549  StringToUuid(sandesh_key.get_uuid())));
551  (backup_manager()->resource_manager(),
552  index));
553  EnqueueRestore(key, data);
554  }
555 }
556 
557 // bgp as service id backup.
559 (ResourceBackupManager *manager) :
560  BackUpResourceTable(manager, "BgpAsServiceBackUpResourceTable",
561  "contrail_bgp_as_service_resource") {
562 }
563 
565 }
566 
568  BgpAsServiceIndexResourceMapSandesh sandesh_data;
569  return WriteMapToFile<BgpAsServiceIndexResourceMapSandesh, Map>
570  (&sandesh_data, map_);
571 }
572 
574  BgpAsServiceIndexResourceMapSandesh sandesh_data;
575  ReadMapFromFile<BgpAsServiceIndexResourceMapSandesh>
576  (&sandesh_data, backup_dir());
577  map_ = sandesh_data.get_index_map();
578 }
579 
581  for (MapIter it = map_.begin(); it != map_.end(); it++) {
582  uint32_t index = it->first;
583  BgpAsServiceIndexResource sandesh_key = it->second;
584 
586  backup_manager()->resource_manager(),
587  StringToUuid(sandesh_key.get_uuid())));
589  (backup_manager()->resource_manager(),
590  index));
591  EnqueueRestore(key, data);
592  }
593 }
594 
595 // Mirror backup.
597 (ResourceBackupManager *manager) :
598  BackUpResourceTable(manager, "MirrorBackUpResourceTable",
599  "contrail_mirror_index_resource") {
600 }
601 
603 }
604 
606  MirrorIndexResourceMapSandesh sandesh_data;
607  return WriteMapToFile<MirrorIndexResourceMapSandesh, Map>
608  (&sandesh_data, map_);
609 }
610 
612  MirrorIndexResourceMapSandesh sandesh_data;
613  ReadMapFromFile<MirrorIndexResourceMapSandesh>
614  (&sandesh_data, backup_dir());
615  map_ = sandesh_data.get_index_map();
616 }
617 
619  for (MapIter it = map_.begin(); it != map_.end(); it++) {
620  uint32_t index = it->first;
621  MirrorIndexResource sandesh_key = it->second;
622 
624  backup_manager()->resource_manager(),
625  sandesh_key.get_analyzer_name()));
627  (backup_manager()->resource_manager(),
628  index));
629  EnqueueRestore(key, data);
630  }
631 }
632 
634  backup_manager_(manager), agent_(manager->agent()),
635  interface_mpls_index_table_(manager), vrf_mpls_index_table_(manager),
636  vlan_mpls_index_table_(manager), route_mpls_index_table_(manager),
637  vm_interface_index_table_(manager), vrf_index_table_ (manager),
638  qos_index_table_ (manager), bgp_as_service_index_table_(manager),
639  mirror_index_table_(manager) {
640 }
641 
643 }
644 
655 }
656 
661  agent_->resource_manager()->EnqueueRestore(key, data);
662 }
663 
674  EndOfBackup();
675 }
676 
677 void InterfaceIndexResourceMapSandesh::Process(SandeshContext*) {
678 
679 }
680 
681 void VrfMplsResourceMapSandesh::Process(SandeshContext*) {
682 
683 }
684 
685 void VlanMplsResourceMapSandesh::Process(SandeshContext*) {
686 
687 }
688 
689 void RouteMplsResourceMapSandesh::Process(SandeshContext*) {
690 
691 }
692 
693 void VmInterfaceIndexResourceMapSandesh::Process(SandeshContext*) {
694 
695 }
696 
697 void VrfIndexResourceMapSandesh::Process(SandeshContext*) {
698 
699 }
700 
701 void QosIndexResourceMapSandesh::Process(SandeshContext*) {
702 
703 }
704 void BgpAsServiceIndexResourceMapSandesh::Process(SandeshContext*) {
705 
706 }
707 
708 void MirrorIndexResourceMapSandesh::Process(SandeshContext*) {
709 
710 }
711 
713  InterfaceIndexResource data ) {
715  data));
716 }
718  interface_mpls_index_table_.map().erase(index);
719 }
720 
722  VrfMplsResource data) {
723  vrf_mpls_index_table_.map().insert(VrfMplsResourcePair(index, data));
724 }
725 
727  vrf_mpls_index_table_.map().erase(index);
728 }
729 
731  VlanMplsResource data) {
732  vlan_mpls_index_table_.map().insert(VlanMplsResourcePair(index, data));
733 }
734 
736  vlan_mpls_index_table_.map().erase(index);
737 }
738 
740  RouteMplsResource data) {
741  route_mpls_index_table_.map().insert(RouteMplsResourcePair(index, data));
742 }
743 
745  route_mpls_index_table_.map().erase(index);
746 }
747 
749  VmInterfaceIndexResource data ) {
751  (index, data));
752 }
754  vm_interface_index_table_.map().erase(index);
755 }
756 
758  VrfIndexResource data ) {
760  (index, data));
761 }
763  vrf_index_table_.map().erase(index);
764 }
765 
767  QosIndexResource data ) {
769  (index, data));
770 }
772  qos_index_table_.map().erase(index);
773 }
774 
776 (uint32_t index, BgpAsServiceIndexResource data ) {
778  (index, data));
779 }
780 
782  bgp_as_service_index_table_.map().erase(index);
783 }
784 
786  MirrorIndexResource data ) {
788  (index, data));
789 }
790 
792  mirror_index_table_.map().erase(index);
793 }
#define kAgentResourceBackUpTask
Definition: agent.h:343
std::size_t hash_value(BgpAttr const &attr)
Definition: bgp_attr.cc:1295
uint64_t restart_backup_idle_timeout() const
Definition: agent_param.h:479
const std::string & restart_backup_dir() const
Definition: agent_param.h:482
ResourceManager * resource_manager() const
Definition: agent.cc:1025
AgentParam * params() const
Definition: agent.h:1227
EventManager * event_manager() const
Definition: agent.h:1106
std::string AgentGUID() const
Definition: agent.cc:158
TaskScheduler * task_scheduler() const
Definition: agent.h:1123
bool isMockMode() const
Definition: agent.cc:154
bool WriteMapToFile(T1 *sandesh_data, const T2 &index_map)
Definition: sandesh_map.cc:159
const std::string & file_name_str()
Definition: sandesh_map.h:45
virtual bool WriteToFile()=0
static const std::string FindFile(const std::string &root, const std::string &file_ext)
Definition: sandesh_map.cc:199
virtual ~BackUpResourceTable()
Definition: sandesh_map.cc:57
uint32_t backup_idle_timeout_
Definition: sandesh_map.h:59
uint64_t last_modified_time_
Definition: sandesh_map.h:60
void ReadMapFromFile(T *sandesh_data, const std::string &root)
Definition: sandesh_map.cc:245
std::string file_name_prefix_
Definition: sandesh_map.h:63
void EnqueueRestore(ResourceManager::KeyPtr key, ResourceManager::DataPtr data)
Definition: sandesh_map.cc:101
const std::string & backup_dir()
Definition: sandesh_map.h:40
std::string file_name_str_
Definition: sandesh_map.h:62
static const uint8_t kFallBackCount
Definition: sandesh_map.h:21
std::string backup_dir_
Definition: sandesh_map.h:52
static bool CalculateHashSum(const std::string &file_name, uint32_t *hashsum)
Definition: sandesh_map.cc:140
BackUpResourceTable(ResourceBackupManager *manager, const std::string &name, const std::string &file_name)
Definition: sandesh_map.cc:30
uint8_t fall_back_count_
Definition: sandesh_map.h:61
ResourceBackupManager * backup_manager()
Definition: sandesh_map.h:32
const std::string & file_name_prefix()
Definition: sandesh_map.h:46
BgpAsServiceBackUpResourceTable(ResourceBackupManager *manager)
Definition: sandesh_map.cc:559
boost::asio::io_context * io_service()
Definition: event_manager.h:43
InterfaceMplsBackUpResourceTable(ResourceBackupManager *manager)
Definition: sandesh_map.cc:394
static MacAddress FromString(const std::string &str, boost::system::error_code *error=NULL)
Definition: mac_address.cc:72
MirrorBackUpResourceTable(ResourceBackupManager *manager)
Definition: sandesh_map.cc:597
virtual ~MirrorBackUpResourceTable()
Definition: sandesh_map.cc:602
virtual ~QosBackUpResourceTable()
Definition: sandesh_map.cc:526
QosBackUpResourceTable(ResourceBackupManager *manager)
Definition: sandesh_map.cc:521
Map::iterator MapIter
Definition: sandesh_map.h:168
static uint32_t ReadResourceDataFromFile(const std::string &file_name, std::unique_ptr< uint8_t > *buf)
ResourceManager * resource_manager()
void EnqueueRestore(KeyPtr key, DataPtr data)
boost::shared_ptr< ResourceKey > KeyPtr
boost::shared_ptr< ResourceData > DataPtr
void DeleteBgpAsServiceResourceEntry(uint32_t index)
Definition: sandesh_map.cc:781
void DeleteVrfResourceEntry(uint32_t index)
Definition: sandesh_map.cc:762
pair< uint32_t, VlanMplsResource > VlanMplsResourcePair
Definition: sandesh_map.h:217
void AddRouteMplsResourceEntry(uint32_t index, RouteMplsResource data)
Definition: sandesh_map.cc:739
pair< uint32_t, RouteMplsResource > RouteMplsResourcePair
Definition: sandesh_map.h:220
pair< uint32_t, InterfaceIndexResource > InterfaceMplsResourcePair
Definition: sandesh_map.h:219
BgpAsServiceBackUpResourceTable bgp_as_service_index_table_
Definition: sandesh_map.h:312
QosBackUpResourceTable qos_index_table_
Definition: sandesh_map.h:311
void AddVlanMplsResourceEntry(uint32_t index, VlanMplsResource data)
Definition: sandesh_map.cc:730
virtual ~ResourceSandeshMaps()
Definition: sandesh_map.cc:642
pair< uint32_t, BgpAsServiceIndexResource > BgpAsServiceIndexResourcePair
Definition: sandesh_map.h:226
void DeleteVrfMplsResourceEntry(uint32_t index)
Definition: sandesh_map.cc:726
void DeleteQosResourceEntry(uint32_t index)
Definition: sandesh_map.cc:771
void AddVrfMplsResourceEntry(uint32_t index, VrfMplsResource data)
Definition: sandesh_map.cc:721
void AddMirrorResourceEntry(uint32_t index, MirrorIndexResource data)
Definition: sandesh_map.cc:785
void AddBgpAsServiceResourceEntry(uint32_t index, BgpAsServiceIndexResource data)
Definition: sandesh_map.cc:776
VrfBackUpResourceTable vrf_index_table_
Definition: sandesh_map.h:310
pair< uint32_t, VmInterfaceIndexResource > VmInterfaceIndexResourcePair
Definition: sandesh_map.h:222
VrfMplsBackUpResourceTable vrf_mpls_index_table_
Definition: sandesh_map.h:306
pair< uint32_t, VrfMplsResource > VrfMplsResourcePair
Definition: sandesh_map.h:216
void AddInterfaceMplsResourceEntry(uint32_t index, InterfaceIndexResource data)
Definition: sandesh_map.cc:712
VmInterfaceBackUpResourceTable vm_interface_index_table_
Definition: sandesh_map.h:309
VlanMplsBackUpResourceTable vlan_mpls_index_table_
Definition: sandesh_map.h:307
MirrorBackUpResourceTable mirror_index_table_
Definition: sandesh_map.h:313
void DeleteMirrorResourceEntry(uint32_t index)
Definition: sandesh_map.cc:791
RouteMplsBackUpResourceTable route_mpls_index_table_
Definition: sandesh_map.h:308
void AddVmInterfaceResourceEntry(uint32_t index, VmInterfaceIndexResource data)
Definition: sandesh_map.cc:748
void DeleteVlanMplsResourceEntry(uint32_t index)
Definition: sandesh_map.cc:735
InterfaceMplsBackUpResourceTable interface_mpls_index_table_
Definition: sandesh_map.h:305
void DeleteInterfaceMplsResourceEntry(uint32_t index)
Definition: sandesh_map.cc:717
void AddVrfResourceEntry(uint32_t index, VrfIndexResource data)
Definition: sandesh_map.cc:757
pair< uint32_t, QosIndexResource > QosIndexResourcePair
Definition: sandesh_map.h:224
ResourceSandeshMaps(ResourceBackupManager *manager)
Definition: sandesh_map.cc:633
pair< uint32_t, VrfIndexResource > VrfIndexResourcePair
Definition: sandesh_map.h:223
void DeleteRouteMplsResourceEntry(uint32_t index)
Definition: sandesh_map.cc:744
pair< uint32_t, MirrorIndexResource > MirrorIndexResourcePair
Definition: sandesh_map.h:227
void DeleteVmInterfaceResourceEntry(uint32_t index)
Definition: sandesh_map.cc:753
void AddQosResourceEntry(uint32_t index, QosIndexResource data)
Definition: sandesh_map.cc:766
RouteMplsBackUpResourceTable(ResourceBackupManager *manager)
Definition: sandesh_map.cc:359
static bool DeleteTimer(Timer *Timer)
Definition: timer.cc:222
static Timer * CreateTimer(boost::asio::io_context &service, const std::string &name, int task_id=Timer::GetTimerTaskId(), int task_instance=Timer::GetTimerInstanceId(), bool delete_on_completion=false)
Definition: timer.cc:201
bool Cancel()
Definition: timer.cc:150
bool running() const
Definition: timer.h:90
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
Definition: timer.cc:108
VlanMplsBackUpResourceTable(ResourceBackupManager *manager)
Definition: sandesh_map.cc:320
virtual ~VlanMplsBackUpResourceTable()
Definition: sandesh_map.cc:325
VmInterfaceBackUpResourceTable(ResourceBackupManager *manager)
Definition: sandesh_map.cc:445
virtual ~VrfBackUpResourceTable()
Definition: sandesh_map.cc:488
Map::iterator MapIter
Definition: sandesh_map.h:152
VrfBackUpResourceTable(ResourceBackupManager *manager)
Definition: sandesh_map.cc:483
VrfMplsBackUpResourceTable(ResourceBackupManager *manager)
Definition: sandesh_map.cc:283
virtual ~VrfMplsBackUpResourceTable()
Definition: sandesh_map.cc:288
uint8_t type
Definition: load_balance.h:2
#define LOG(_Level, _Msg)
Definition: logging.h:35
static const std::string TempFilePath(const std::string &file_name)
Definition: sandesh_map.cc:107
static bool RenameFile(const std::string &file_tmp_name, const std::string &file_name)
Definition: sandesh_map.cc:125
static boost::uuids::uuid StringToUuid(const std::string &str)
Definition: string_util.h:146
@ ADD_DEL_CHANGE
Definition: agent_db.h:101
static uint64_t UTCTimestampUsec()
Definition: time_util.h:14