LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-analytics/contrail-collector - viz_message.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 7 10 70.0 %
Date: 2026-11-09 02:10:49 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef __VIZ_MESSAGE_H__
       7             : #define __VIZ_MESSAGE_H__
       8             : 
       9             : #include <string>
      10             : #include <boost/uuid/uuid.hpp>
      11             : #include <boost/ptr_container/ptr_map.hpp>
      12             : #include <pugixml/pugixml.hpp>
      13             : 
      14             : #include <sandesh/sandesh_types.h>
      15             : 
      16             : #define VIZD_ASSERT(condition) assert((condition));
      17             : 
      18             : class SandeshMessage;
      19             : 
      20             : /* message format used to store in the cassandra */
      21             : struct VizMsg {
      22          11 :     VizMsg(const SandeshMessage *msg,
      23          11 :            boost::uuids::uuid unm) :
      24          11 :         msg(msg),
      25          11 :         unm(unm) {}
      26          11 :     ~VizMsg() {}
      27             : 
      28             :     const SandeshMessage *msg;
      29             :     boost::uuids::uuid unm; /* uuid key for this message in the global table */
      30             :     std::string keyword_doc_;
      31             : };
      32             : 
      33             : class SandeshStats;
      34             : class SandeshLogLevelStats;
      35             : class SandeshMessageInfo;
      36             : 
      37             : struct VizMsgStats {
      38           0 :     VizMsgStats() : messages(0), bytes(0), last_msg_timestamp(0) {}
      39             : 
      40             :     void Update(const VizMsg *vmsg);
      41             :     template <typename K, typename T> void Get(const K &key, T *stats) const;
      42             : 
      43             :     uint64_t messages;
      44             :     uint64_t bytes;
      45             :     uint64_t last_msg_timestamp;
      46             : };
      47             : 
      48             : struct VizMsgStatistics {
      49           9 :     VizMsgStatistics() {}
      50             : 
      51             :     void Update(const VizMsg *vmsg);
      52             :     void Get(std::vector<SandeshStats> *ssv) const;
      53             :     void Get(std::vector<SandeshLogLevelStats> *lsv) const;
      54             :     void Get(std::vector<SandeshMessageInfo> *sms);
      55             : 
      56             :     typedef boost::ptr_map<std::string, VizMsgStats> TypeMap;
      57             :     TypeMap type_map;
      58             : 
      59             :     typedef boost::ptr_map<std::string, VizMsgStats> LevelMap;
      60             :     LevelMap level_map;
      61             : 
      62             :     typedef std::pair<std::string, std::string> TypeLevelKey;
      63             :     typedef boost::ptr_map<TypeLevelKey, VizMsgStats> TypeLevelMap;
      64             :     TypeLevelMap type_level_map;
      65             : };
      66             : 
      67             : /* generic message for ruleeng processing */
      68             : struct RuleMsg {
      69             : public:
      70             :     RuleMsg(const VizMsg *vmsgp);
      71             :     ~RuleMsg();
      72             : 
      73             :     int field_value(const std::string& field_id, std::string& type,
      74             :         std::string& value) const;
      75             : 
      76             :     struct RuleMsgPredicate {
      77           7 :         RuleMsgPredicate(const std::string &name) : tmp_(name) { }
      78             :         bool operator()(pugi::xml_attribute attr) const {
      79             :             return (strcmp(attr.name(), tmp_.c_str()) == 0);
      80             :         }
      81           0 :         bool operator()(pugi::xml_node node) const {
      82           0 :             return (strcmp(node.name(), tmp_.c_str()) == 0); 
      83             :         }
      84             :         std::string tmp_;
      85             :     };
      86             : 
      87             :     SandeshHeader hdr;
      88             :     std::string messagetype;
      89             : 
      90             : private:
      91             :     int field_value_recur(const std::string& field_id, std::string& type,
      92             :         std::string& value, pugi::xml_node doc) const;
      93             : 
      94             :     pugi::xml_node message_node_;
      95             : };
      96             : 
      97             : #endif // __VIZ_MESSAGE_H__
      98             : 

Generated by: LCOV version 1.14