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