OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
diag_proto.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_diag_proto_hpp
6 #define vnsw_agent_diag_proto_hpp
7 
8 #include <pkt/pkt_handler.h>
9 #include <pkt/proto.h>
10 #include <pkt/proto_handler.h>
11 #include <oper/health_check.h>
12 
14 class SegmentHealthCheckPktStatsResp;
15 
16 class DiagProto : public Proto {
17 public:
18  // map from interface id to segment health check service packet object
19  typedef std::map<uint32_t, SegmentHealthCheckPkt *> SessionMap;
20  typedef std::pair<uint32_t, SegmentHealthCheckPkt *> SessionPair;
21 
27  };
28 
29  struct DiagStats {
30  uint64_t requests_sent;
32  uint64_t replies_sent;
33  uint64_t replies_received;
34  DiagStats() { Reset(); }
35  void Reset() {
37  replies_received = 0;
38  }
39  };
40  typedef std::map<uint32_t, DiagStats> DiagStatsMap;
41  typedef std::pair<uint32_t, DiagStats> DiagStatsPair;
42 
43  DiagProto(Agent *agent, boost::asio::io_context &io);
44  virtual ~DiagProto() {}
45 
46  ProtoHandler *AllocProtoHandler(boost::shared_ptr<PktInfo> info,
47  boost::asio::io_context &io);
51  void IncrementDiagStats(uint32_t itf_id, DiagStatsType type);
52  const DiagStatsMap &stats() const { return stats_; }
53  void FillSandeshHealthCheckResponse(SegmentHealthCheckPktStatsResp *resp);
54 
55 private:
57  /* lock for stats_ field for access between
58  * health-check (which sends first health check packet),
59  * timer-task (which sends periodic health check packets),
60  * Diag task (which receives health-check requests/replies and sends
61  * health-check replies)
62  * Introspect (which reads stats for filling introspect response)
63  */
64  tbb::mutex stats_mutex_;
67 };
68 
69 #endif
uint64_t requests_received
Definition: diag_proto.h:31
SessionMap session_map_
Definition: diag_proto.h:56
void IncrementDiagStats(uint32_t itf_id, DiagStatsType type)
Definition: diag_proto.cc:93
const DiagStatsMap & stats() const
Definition: diag_proto.h:52
std::map< uint32_t, SegmentHealthCheckPkt * > SessionMap
Definition: diag_proto.h:19
uint64_t replies_sent
Definition: diag_proto.h:32
std::map< uint32_t, DiagStats > DiagStatsMap
Definition: diag_proto.h:40
uint64_t requests_sent
Definition: diag_proto.h:30
std::pair< uint32_t, SegmentHealthCheckPkt * > SessionPair
Definition: diag_proto.h:20
uint8_t type
Definition: load_balance.h:109
std::pair< uint32_t, DiagStats > DiagStatsPair
Definition: diag_proto.h:41
Definition: agent.h:358
void FillSandeshHealthCheckResponse(SegmentHealthCheckPktStatsResp *resp)
Definition: diag_proto.cc:118
DISALLOW_COPY_AND_ASSIGN(DiagProto)
virtual ~DiagProto()
Definition: diag_proto.h:44
tbb::mutex stats_mutex_
Definition: diag_proto.h:64
bool SegmentHealthCheckProcess(HealthCheckTable::HealthCheckServiceAction action, HealthCheckInstanceService *service)
Definition: diag_proto.cc:29
uint64_t replies_received
Definition: diag_proto.h:33
DiagProto(Agent *agent, boost::asio::io_context &io)
Definition: diag_proto.cc:16
DiagStatsMap stats_
Definition: diag_proto.h:65
ProtoHandler * AllocProtoHandler(boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
Definition: diag_proto.cc:24