11 #ifndef __SANDESH_CLIENT_SM_PRIV_H__
12 #define __SANDESH_CLIENT_SM_PRIV_H__
14 #include <boost/asio.hpp>
15 #include <boost/statechart/state_machine.hpp>
16 #include <tbb/mutex.h>
17 #include <tbb/atomic.h>
24 namespace sc = boost::statechart;
43 public sc::state_machine<SandeshClientSMImpl, scm::Idle> {
50 int sm_task_id,
bool periodicuve);
62 void SetCollectors(
const std::vector<TcpServer::Endpoint>& collectors);
63 void GetCollectors(std::vector<TcpServer::Endpoint>& collectors);
77 template <
class Ev>
void OnIdle(
const Ev &event);
93 bool CollectorUpdate(
const std::vector<TcpServer::Endpoint> &collectors);
121 tbb::mutex::scoped_lock lock(
mutex_);
126 tbb::mutex::scoped_lock lock(
mutex_);
130 tbb::mutex::scoped_lock lock(
mutex_);
146 boost::intrusive_ptr<const sc::event_base>
event;
156 template <
typename Ev>
void Enqueue(
const Ev &event);
162 void UpdateEventStats(
const sc::event_base &event,
bool enqueue,
bool fail);
void GetCollectors(std::vector< TcpServer::Endpoint > &collectors)
int statistics_timer_interval_
void UpdateEventStats(const sc::event_base &event, bool enqueue, bool fail)
void UpdateEventDequeueFail(const sc::event_base &event)
bool send_session(Sandesh *snh)
void UpdateEventEnqueueFail(const sc::event_base &event)
int idle_hold_time() const
friend class SandeshClientStateMachineTest
void reset_idle_hold_time()
bool CollectorUpdate(const std::vector< TcpServer::Endpoint > &collectors)
void OnSessionEvent(TcpSession *session, TcpSession::Event event)
std::vector< TcpServer::Endpoint > collectors_
std::string generator_key_
void Enqueue(const Ev &event)
bool StatisticsTimerExpired()
static const int kIdleHoldTime
void set_last_event(const std::string &event)
virtual ~SandeshClientSMImpl()
void ReleaseSandesh(const Ev &event)
TcpServer::Endpoint GetNextCollector()
void CancelIdleHoldTimer()
void EnqueDelSession(SandeshSession *session)
const std::string last_event() const
void SetAdminState(bool down)
void DeleteTcpSession(const Ev &event)
bool ConnectTimerRunning()
bool OnMessage(SandeshSession *session, const std::string &msg)
void StartConnectTimer(int seconds)
Timer * statistics_timer_
DISALLOW_COPY_AND_ASSIGN(SandeshClientSMImpl)
void IdleHoldTimerFired()
bool ConnectTimerExpired()
bool SendSandeshUVE(Sandesh *snh)
void SetCollectors(const std::vector< TcpServer::Endpoint > &collectors)
WorkQueue< EventContainer > work_queue_
TcpServer::Endpoint GetCollector() const
bool IdleHoldTimerRunning()
void set_idle_hold_time(int idle_hold_time)
bool SendSandesh(Sandesh *snh)
void TimerErrorHanlder(std::string name, std::string error)
SandeshEventStatistics event_stats_
static const int kStatisticsSendInterval
void UpdateEventDequeue(const sc::event_base &event)
void connect_attempts_clear()
bool IdleHoldTimerExpired()
bool DequeueEvent(EventContainer ec)
void set_state(State state)
void CancelConnectTimer()
TcpServer::Endpoint active_
const std::string & LastStateName() const
static const int kConnectInterval
void OnIdle(const Ev &event)
void StartIdleHoldTimer()
std::string collector_name()
void StartStatisticsTimer()
const std::string & StateName() const
void unconsumed_event(const sc::event_base &event)
void UpdateEventEnqueue(const sc::event_base &event)
int GetConnectTime() const
void set_collector_name(const std::string &cname)
void connect_attempts_inc()
void set_session(SandeshSession *session, bool enq=true)
SandeshClientSMImpl(EventManager *evm, Mgr *mgr, int sm_task_instance, int sm_task_id, bool periodicuve)
virtual void SendUVE(int count, const std::string &stateName, const std::string &server, const TcpServer::Endpoint &server_ip, const std::vector< TcpServer::Endpoint > &collectors)=0
tbb::atomic< State > state_
SandeshSession * session()
TcpServer::Endpoint server()
bool send_session(Sandesh *snh)
void set_session(SandeshSession *session, bool enq)
boost::asio::ip::tcp::endpoint Endpoint
boost::function< bool(SandeshClientSMImpl *)> EvValidate
boost::function< bool(StateMachine *)> EvValidate
boost::intrusive_ptr< const sc::event_base > event
static uint64_t UTCTimestampUsec()