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;
40 typedef boost::function<bool(SandeshClientSMImpl *)>
EvValidate;
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);
192 #endif // __SANDESH_CLIENT_SM_PRIV_H__
TcpServer::Endpoint GetCollector() const
TcpServer::Endpoint GetNextCollector()
bool CollectorUpdate(const std::vector< TcpServer::Endpoint > &collectors)
void IdleHoldTimerFired()
void SetCollectors(const std::vector< TcpServer::Endpoint > &collectors)
bool OnMessage(SandeshSession *session, const std::string &msg)
void ReleaseSandesh(const Ev &event)
const std::string last_event() const
const std::string & LastStateName() const
void unconsumed_event(const sc::event_base &event)
void UpdateEventDequeueFail(const sc::event_base &event)
const std::string & StateName() const
int idle_hold_time() const
bool StatisticsTimerExpired()
WorkQueue< EventContainer > work_queue_
void set_last_event(const std::string &event)
SandeshSession * session()
int GetConnectTime() const
bool ConnectTimerRunning()
friend class SandeshClientStateMachineTest
bool IdleHoldTimerRunning()
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
bool send_session(Sandesh *snh)
void UpdateEventEnqueue(const sc::event_base &event)
SandeshClientSMImpl(EventManager *evm, Mgr *mgr, int sm_task_instance, int sm_task_id, bool periodicuve)
boost::function< bool(StateMachine *)> EvValidate
void DeleteTcpSession(const Ev &event)
void StartStatisticsTimer()
void Enqueue(const Ev &event)
TcpServer::Endpoint active_
void UpdateEventStats(const sc::event_base &event, bool enqueue, bool fail)
static const int kStatisticsSendInterval
tbb::atomic< State > state_
DISALLOW_COPY_AND_ASSIGN(SandeshClientSMImpl)
void set_session(SandeshSession *session, bool enq)
bool IdleHoldTimerExpired()
bool send_session(Sandesh *snh)
bool ConnectTimerExpired()
bool SendSandeshUVE(Sandesh *snh)
void connect_attempts_clear()
TcpServer::Endpoint server()
void UpdateEventDequeue(const sc::event_base &event)
void TimerErrorHanlder(std::string name, std::string error)
bool DequeueEvent(EventContainer ec)
void set_collector_name(const std::string &cname)
void OnIdle(const Ev &event)
std::string collector_name()
void connect_attempts_inc()
void SetAdminState(bool down)
int statistics_timer_interval_
void StartConnectTimer(int seconds)
void set_state(State state)
boost::intrusive_ptr< const sc::event_base > event
static uint64_t UTCTimestampUsec()
static const int kIdleHoldTime
void reset_idle_hold_time()
void set_session(SandeshSession *session, bool enq=true)
void CancelConnectTimer()
std::string generator_key_
SandeshEventStatistics event_stats_
void UpdateEventEnqueueFail(const sc::event_base &event)
bool SendSandesh(Sandesh *snh)
void GetCollectors(std::vector< TcpServer::Endpoint > &collectors)
virtual ~SandeshClientSMImpl()
void CancelIdleHoldTimer()
void StartIdleHoldTimer()
void EnqueDelSession(SandeshSession *session)
void OnSessionEvent(TcpSession *session, TcpSession::Event event)
boost::asio::ip::tcp::endpoint Endpoint
void set_idle_hold_time(int idle_hold_time)
Timer * statistics_timer_
std::vector< TcpServer::Endpoint > collectors_
static const int kConnectInterval