Line data Source code
1 : /* 2 : * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #ifndef vnsw_agent_segment_health_check_hpp 7 : #define vnsw_agent_segment_health_check_hpp 8 : 9 : #include "diag/diag.h" 10 : #include "diag/diag_types.h" 11 : #include "pkt/control_interface.h" 12 : 13 : class HealthCheckInstanceService; 14 : 15 : class SegmentHealthCheckPkt: public DiagEntry { 16 : public: 17 : enum Status { 18 : SUCCESS, 19 : FAILURE 20 : }; 21 : static const int kBufferSize = 1024; 22 : 23 : SegmentHealthCheckPkt(HealthCheckInstanceService *service, 24 : DiagTable *diag_table); 25 : virtual ~SegmentHealthCheckPkt(); 26 : 27 : virtual void SendRequest(); 28 : void RequestTimedOut(uint32_t seqno); 29 : virtual void HandleReply(DiagPktHandler *handler); 30 : virtual void Retry(); 31 0 : virtual bool IsDone() { 32 : /* Keep sending health-check packets until this object is removed. 33 : * We remove this object when an explicit delete request is received 34 : */ 35 0 : return false; 36 : } 37 0 : virtual bool ResendOnTimerExpiry() { return false; } 38 0 : void set_service(HealthCheckInstanceService *svc) { 39 0 : service_ = svc; 40 0 : } 41 : void StopDelayTimer(); 42 : void UpdateService(HealthCheckInstanceService *service); 43 : 44 : private: 45 : void FillDiagHeader(AgentDiagPktData *data) const; 46 : void Notify(Status status); 47 : bool RetryHandler(); 48 : int GetTimeout(const HealthCheckInstanceService *svc) const; 49 : int GetDelay(const HealthCheckInstanceService *svc) const; 50 : 51 : HealthCheckInstanceService *service_; 52 : Status state_; 53 : int delay_msecs_; //delay/interval in milliseconds 54 : Timer *delay_timer_; // 55 : }; 56 : 57 : #endif