OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agent_uve_base.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef vnsw_agent_uve_base_h
6 #define vnsw_agent_uve_base_h
7 
8 #include "nodeinfo_types.h"
9 #include <base/connection_info.h>
10 #include <uve/vn_uve_table_base.h>
11 #include <uve/vm_uve_table_base.h>
13 #include <uve/prouter_uve_table.h>
15 #include <boost/scoped_ptr.hpp>
16 
18 
19 /* Structure used to build and carry tags of different types across APIs */
20 struct UveTagData {
21  enum FillType {
23  SET,
25  };
26  std::string application;
27  std::string tier;
28  std::string site;
29  std::string deployment;
30  /* Semi-colon separated list of labels. This format is imposed by analytics
31  * module as it expects labels in semi-colon separated string */
32  std::string labels;
33  std::set<string> label_set;
34  std::vector<string> label_vector;
35  /* Semi-colon separated list of custom-tags. This format is imposed by
36  * analytics module as it expects custom-tags in semi-colon separated
37  * string */
38  std::string custom_tags;
39  std::set<string> custom_tag_set;
40  std::vector<string> custom_tag_vector;
42  void Reset() {
44  if (fill_type == SET) {
45  label_set.clear();
46  custom_tag_set.clear();
47  } else if (fill_type == VECTOR) {
48  label_vector.clear();
49  custom_tag_vector.clear();
50  }
51  }
54 };
55 
56 //The class to drive UVE module initialization for agent.
57 //Defines objects required for statistics collection from vrouter and
58 //objects required for sending UVE information to collector.
59 class AgentUveBase {
60 public:
61  /* Number of UVEs to be sent each time, the timer callback is Run */
62  static const uint32_t kUveCountPerTimer = 64;
63  /* The interval at which timer is fired */
64  static const uint32_t kDefaultInterval = (30 * 1000); // time in millisecs
65  /* When timer is Run, we send atmost 'kUveCountPerTimer' UVEs. If there
66  * are more UVEs to be sent, we reschedule timer at the following shorter
67  * interval*/
68  static const uint32_t kIncrementalInterval = (1000); // time in millisecs
69 
70  static const uint64_t kBandwidthInterval = (1000000); // time in microseconds
71 
72  AgentUveBase(Agent *agent, uint64_t intvl,
73  uint32_t default_intvl, uint32_t incremental_intvl);
74  virtual ~AgentUveBase();
75 
76  virtual void Shutdown();
77  uint64_t bandwidth_intvl() const { return bandwidth_intvl_; }
78  VnUveTableBase* vn_uve_table() const { return vn_uve_table_.get(); }
79  VmUveTableBase* vm_uve_table() const { return vm_uve_table_.get(); }
80  Agent* agent() const { return agent_; }
82  return vrouter_uve_entry_.get();
83  }
85  return prouter_uve_table_.get();
86  }
88  return interface_uve_table_.get();
89  }
91  return vrouter_stats_collector_.get();
92  }
93 
94  void Init();
95  virtual void InitDone();
96  virtual void RegisterDBClients();
97  static AgentUveBase *GetInstance() {return singleton_;}
98  uint8_t ExpectedConnections(uint8_t &num_c_nodes, uint8_t &num_d_servers);
99  uint32_t default_interval() const { return default_interval_; }
100  uint32_t incremental_interval() const { return incremental_interval_; }
101  void BuildTagNamesFromList(const TagList &tl, UveTagData *info) const;
102  void BuildTagIdsFromList(const TagList &tl, UveTagData *info) const;
103 protected:
104  boost::scoped_ptr<VnUveTableBase> vn_uve_table_;
105  boost::scoped_ptr<VmUveTableBase> vm_uve_table_;
106  boost::scoped_ptr<VrouterUveEntryBase> vrouter_uve_entry_;
107  boost::scoped_ptr<ProuterUveTable> prouter_uve_table_;
108  boost::scoped_ptr<InterfaceUveTable> interface_uve_table_;
112 
113 private:
114  std::string IntegerToHexString(uint32_t value) const;
115  friend class UveTest;
117  const std::vector<process::ConnectionInfo> &c,
118  process::ProcessState::type &state, std::string &message);
119  void UpdateMessage(const process::ConnectionInfo &info,
120  std::string &message);
121  bool HasSelfConfiguration() const;
122 
124  uint64_t bandwidth_intvl_; //in microseconds
128 protected:
129  boost::scoped_ptr<VrouterStatsCollector> vrouter_stats_collector_;
130 };
131 
132 #endif //vnsw_agent_uve_base_h
VnUveTableBase * vn_uve_table() const
std::string application
std::vector< string > label_vector
uint32_t incremental_interval() const
VrouterUveEntryBase * vrouter_uve_entry() const
uint64_t bandwidth_intvl_
FillType fill_type
uint32_t default_interval() const
std::string tier
std::string custom_tags
uint32_t default_interval_
AgentUveBase(Agent *agent, uint64_t intvl, uint32_t default_intvl, uint32_t incremental_intvl)
virtual ~AgentUveBase()
boost::scoped_ptr< InterfaceUveTable > interface_uve_table_
static const uint32_t kUveCountPerTimer
std::string site
static AgentUveBase * GetInstance()
void BuildTagIdsFromList(const TagList &tl, UveTagData *info) const
boost::scoped_ptr< ProuterUveTable > prouter_uve_table_
Agent * agent() const
bool HasSelfConfiguration() const
std::string IntegerToHexString(uint32_t value) const
void BuildTagNamesFromList(const TagList &tl, UveTagData *info) const
VrouterStatsCollector * vrouter_stats_collector() const
boost::scoped_ptr< VrouterStatsCollector > vrouter_stats_collector_
boost::scoped_ptr< VmUveTableBase > vm_uve_table_
VmUveTableBase * vm_uve_table() const
uint8_t type
Definition: load_balance.h:109
Definition: agent.h:358
uint64_t bandwidth_intvl() const
static const uint32_t kDefaultInterval
static const uint64_t kBandwidthInterval
process::ConnectionStateManager * connection_state_manager_
void UpdateMessage(const process::ConnectionInfo &info, std::string &message)
virtual void Shutdown()
std::string deployment
virtual void RegisterDBClients()
static const uint32_t kIncrementalInterval
std::vector< string > custom_tag_vector
uint32_t incremental_interval_
std::set< string > custom_tag_set
boost::scoped_ptr< VrouterUveEntryBase > vrouter_uve_entry_
virtual void InitDone()
void VrouterAgentProcessState(const std::vector< process::ConnectionInfo > &c, process::ProcessState::type &state, std::string &message)
InterfaceUveTable * interface_uve_table() const
UveTagData(FillType type)
ProuterUveTable * prouter_uve_table() const
DISALLOW_COPY_AND_ASSIGN(AgentUveBase)
boost::scoped_ptr< VnUveTableBase > vn_uve_table_
friend class UveTest
std::string labels
void Reset()
static AgentUveBase * singleton_
uint8_t ExpectedConnections(uint8_t &num_c_nodes, uint8_t &num_d_servers)
std::set< string > label_set
std::vector< int > TagList
Definition: agent.h:202