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