OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SandeshStateMachine Class Reference

#include <sandesh_state_machine.h>

Inheritance diagram for SandeshStateMachine:
Collaboration diagram for SandeshStateMachine:

Classes

struct  EventContainer
 

Public Member Functions

 SandeshStateMachine (const char *prefix, SandeshConnection *connection)
 
 ~SandeshStateMachine ()
 
void Initialize ()
 
void SetAdminState (bool down)
 
void SetDeferDequeue (bool defer)
 
template<class Ev >
void OnIdle (const Ev &event)
 
template<class Ev >
void ReleaseSandesh (const Ev &event)
 
template<class Ev >
void DeleteTcpSession (const Ev &event)
 
template<class Ev >
void ProcessMessage (const Ev &event)
 
void StartIdleHoldTimer ()
 
void CancelIdleHoldTimer ()
 
bool IdleHoldTimerRunning ()
 
void IdleHoldTimerFired ()
 
void OnSessionEvent (TcpSession *session, TcpSession::Event event)
 
void PassiveOpen (SandeshSession *session)
 
void SandeshUVESend (SandeshUVE *usnh)
 
bool OnSandeshMessage (SandeshSession *session, const std::string &msg)
 
void ResourceUpdate (bool rsc)
 
const std::string & StateName () const
 
const std::string & LastStateName () const
 
SandeshConnectionconnection ()
 
void DeleteSession (SandeshSession *session)
 
void set_session (SandeshSession *session)
 
void clear_session ()
 
SandeshSessionsession ()
 
void set_state (ssm::SsmState state)
 
ssm::SsmState get_state () const
 
bool get_resource () const
 
void set_resource (bool r)
 
int idle_hold_time () const
 
void reset_idle_hold_time ()
 
void set_idle_hold_time (int idle_hold_time)
 
void set_last_event (const std::string &event)
 
const std::string last_event () const
 
void reset_last_info ()
 
void Shutdown (void)
 
void unconsumed_event (const sc::event_base &event)
 
const char * prefix ()
 
void SetGeneratorKey (const std::string &generator)
 
const std::string & generator_key () const
 
void SetQueueWaterMarkInfo (Sandesh::QueueWaterMarkInfo &wm)
 
void ResetQueueWaterMarkInfo ()
 
bool GetQueueCount (uint64_t &queue_count) const
 
bool GetMessageDropLevel (std::string &drop_level) const
 
bool GetStatistics (SandeshStateMachineStats &sm_stats, SandeshGeneratorBasicStats &basic_msg_stats)
 
bool GetBasicStatistics (SandeshStateMachineStats *sm_stats, SandeshGeneratorBasicStats *basic_msg_stats)
 
bool GetStatistics (SandeshStateMachineStats &sm_stats, SandeshGeneratorStats &detail_msg_stats)
 
bool GetDetailStatistics (SandeshStateMachineStats *sm_stats, SandeshGeneratorStats *detail_msg_stats)
 
size_t GetMaxQueueCount () const
 

Static Public Attributes

static const int kIdleHoldTime = 5000
 
static const int kQueueSize = 200 * 1024 * 1024
 

Private Types

typedef WorkQueue< EventContainerEventQueue
 

Private Member Functions

void TimerErrorHandler (std::string name, std::string error)
 
bool IdleHoldTimerExpired ()
 
template<typename Ev >
void Enqueue (const Ev &event)
 
bool DequeueEvent (EventContainer ec)
 
bool LogEvent (const sc::event_base *event)
 
void UpdateRxMsgStats (const std::string &msg_name, size_t msg_size)
 
void UpdateRxMsgFailStats (const std::string &msg_name, size_t msg_size, SandeshRxDropReason::type dreason)
 
void UpdateEventDequeue (const sc::event_base &event)
 
void UpdateEventDequeueFail (const sc::event_base &event)
 
void UpdateEventEnqueue (const sc::event_base &event)
 
void UpdateEventEnqueueFail (const sc::event_base &event)
 
void UpdateEventStats (const sc::event_base &event, bool enqueue, bool fail)
 
void GetEventStatistics (SandeshStateMachineStats *sm_stats)
 
void GetDetailMessageStatistics (SandeshGeneratorStats *detail_msg_stats)
 
void GetBasicMessageStatistics (SandeshGeneratorBasicStats *basic_msg_stats)
 
void SetSandeshMessageDropLevel (size_t queue_count, SandeshLevel::type level, boost::function< void(void)> cb)
 
void SetDeferSessionReader (bool defer_reader)
 
bool IsValid () const
 
 DISALLOW_COPY_AND_ASSIGN (SandeshStateMachine)
 

Private Attributes

const char * prefix_
 
tbb::mutex smutex_
 
EventQueue work_queue_
 
SandeshConnectionconnection_
 
SandeshSessionsession_
 
Timeridle_hold_timer_
 
int idle_hold_time_
 
bool deleted_
 
tbb::atomic< ssm::SsmStatestate_
 
bool resource_
 
ssm::SsmState last_state_
 
uint64_t state_since_
 
std::string last_event_
 
uint64_t last_event_at_
 
std::string generator_key_
 
SandeshEventStatistics event_stats_
 
SandeshMessageStatistics message_stats_
 
SandeshMessageBuilderbuilder_
 
SandeshLevel::type message_drop_level_
 

Friends

class SandeshServerStateMachineTest
 
class SandeshClientStateMachineTest
 
class WorkQueue< EventContainer >
 
bool GetEvSandeshMessageRecvSize (EventContainer *ec, size_t *msg_size)
 

Detailed Description

Definition at line 57 of file sandesh_state_machine.h.

Member Typedef Documentation

Constructor & Destructor Documentation

SandeshStateMachine::SandeshStateMachine ( const char *  prefix,
SandeshConnection connection 
)

Definition at line 381 of file sandesh_state_machine.cc.

SandeshStateMachine::~SandeshStateMachine ( )

Definition at line 403 of file sandesh_state_machine.cc.

Here is the call graph for this function:

Member Function Documentation

void SandeshStateMachine::CancelIdleHoldTimer ( )

Definition at line 509 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::clear_session ( )

Definition at line 447 of file sandesh_state_machine.cc.

Here is the call graph for this function:

SandeshConnection* SandeshStateMachine::connection ( )
inline

Definition at line 102 of file sandesh_state_machine.h.

void SandeshStateMachine::DeleteSession ( SandeshSession session)

Definition at line 467 of file sandesh_state_machine.cc.

Here is the call graph for this function:

template<class Ev >
void SandeshStateMachine::DeleteTcpSession ( const Ev &  event)

Definition at line 491 of file sandesh_state_machine.cc.

Here is the call graph for this function:

bool SandeshStateMachine::DequeueEvent ( SandeshStateMachine::EventContainer  ec)
private

Definition at line 790 of file sandesh_state_machine.cc.

Here is the call graph for this function:

SandeshStateMachine::DISALLOW_COPY_AND_ASSIGN ( SandeshStateMachine  )
private
template<typename Ev >
void SandeshStateMachine::Enqueue ( const Ev &  event)
private

Definition at line 842 of file sandesh_state_machine.cc.

Here is the call graph for this function:

const std::string& SandeshStateMachine::generator_key ( ) const
inline

Definition at line 147 of file sandesh_state_machine.h.

bool SandeshStateMachine::get_resource ( ) const
inline

Definition at line 116 of file sandesh_state_machine.h.

ssm::SsmState SandeshStateMachine::get_state ( ) const
inline

Definition at line 114 of file sandesh_state_machine.h.

void SandeshStateMachine::GetBasicMessageStatistics ( SandeshGeneratorBasicStats *  basic_msg_stats)
private

Definition at line 575 of file sandesh_state_machine.cc.

Here is the call graph for this function:

bool SandeshStateMachine::GetBasicStatistics ( SandeshStateMachineStats *  sm_stats,
SandeshGeneratorBasicStats *  basic_msg_stats 
)

Definition at line 609 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::GetDetailMessageStatistics ( SandeshGeneratorStats *  detail_msg_stats)
private

Definition at line 563 of file sandesh_state_machine.cc.

Here is the call graph for this function:

bool SandeshStateMachine::GetDetailStatistics ( SandeshStateMachineStats *  sm_stats,
SandeshGeneratorStats *  detail_msg_stats 
)

Definition at line 591 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::GetEventStatistics ( SandeshStateMachineStats *  sm_stats)
private

Definition at line 548 of file sandesh_state_machine.cc.

Here is the call graph for this function:

size_t SandeshStateMachine::GetMaxQueueCount ( ) const
inline

Definition at line 162 of file sandesh_state_machine.h.

Here is the call graph for this function:

bool SandeshStateMachine::GetMessageDropLevel ( std::string &  drop_level) const

Definition at line 539 of file sandesh_state_machine.cc.

Here is the call graph for this function:

bool SandeshStateMachine::GetQueueCount ( uint64_t &  queue_count) const

Definition at line 531 of file sandesh_state_machine.cc.

Here is the call graph for this function:

bool SandeshStateMachine::GetStatistics ( SandeshStateMachineStats &  sm_stats,
SandeshGeneratorBasicStats &  basic_msg_stats 
)

Definition at line 622 of file sandesh_state_machine.cc.

Here is the call graph for this function:

bool SandeshStateMachine::GetStatistics ( SandeshStateMachineStats &  sm_stats,
SandeshGeneratorStats &  detail_msg_stats 
)

Definition at line 604 of file sandesh_state_machine.cc.

Here is the call graph for this function:

int SandeshStateMachine::idle_hold_time ( ) const
inline

Definition at line 119 of file sandesh_state_machine.h.

bool SandeshStateMachine::IdleHoldTimerExpired ( )
private

Definition at line 627 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::IdleHoldTimerFired ( )

Definition at line 520 of file sandesh_state_machine.cc.

Here is the call graph for this function:

bool SandeshStateMachine::IdleHoldTimerRunning ( )

Definition at line 513 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::Initialize ( )

Definition at line 427 of file sandesh_state_machine.cc.

Here is the call graph for this function:

bool SandeshStateMachine::IsValid ( ) const
private

Definition at line 587 of file sandesh_state_machine.cc.

const std::string SandeshStateMachine::last_event ( ) const
inline

Definition at line 130 of file sandesh_state_machine.h.

const string & SandeshStateMachine::LastStateName ( ) const

Definition at line 750 of file sandesh_state_machine.cc.

bool SandeshStateMachine::LogEvent ( const sc::event_base *  event)
private

Definition at line 754 of file sandesh_state_machine.cc.

template<class Ev >
void SandeshStateMachine::OnIdle ( const Ev &  event)

Definition at line 481 of file sandesh_state_machine.cc.

Here is the call graph for this function:

bool SandeshStateMachine::OnSandeshMessage ( SandeshSession session,
const std::string &  msg 
)

Definition at line 671 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::OnSessionEvent ( TcpSession session,
TcpSession::Event  event 
)

Definition at line 632 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::PassiveOpen ( SandeshSession session)

Definition at line 652 of file sandesh_state_machine.cc.

Here is the call graph for this function:

const char* SandeshStateMachine::prefix ( )
inline

Definition at line 142 of file sandesh_state_machine.h.

template<class Ev >
void SandeshStateMachine::ProcessMessage ( const Ev &  event)
template<class Ev >
void SandeshStateMachine::ReleaseSandesh ( const Ev &  event)
void SandeshStateMachine::reset_idle_hold_time ( )
inline

Definition at line 120 of file sandesh_state_machine.h.

void SandeshStateMachine::reset_last_info ( )
inline

Definition at line 134 of file sandesh_state_machine.h.

void SandeshStateMachine::ResetQueueWaterMarkInfo ( )

Definition at line 909 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::ResourceUpdate ( bool  rsc)

Definition at line 735 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::SandeshUVESend ( SandeshUVE usnh)
SandeshSession * SandeshStateMachine::session ( )

Definition at line 476 of file sandesh_state_machine.cc.

void SandeshStateMachine::set_idle_hold_time ( int  idle_hold_time)
inline

Definition at line 121 of file sandesh_state_machine.h.

Here is the call graph for this function:

void SandeshStateMachine::set_last_event ( const std::string &  event)
inline

Definition at line 125 of file sandesh_state_machine.h.

Here is the call graph for this function:

void SandeshStateMachine::set_resource ( bool  r)
inline

Definition at line 117 of file sandesh_state_machine.h.

void SandeshStateMachine::set_session ( SandeshSession session)

Definition at line 459 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::set_state ( ssm::SsmState  state)
inline

Definition at line 109 of file sandesh_state_machine.h.

Here is the call graph for this function:

void SandeshStateMachine::SetAdminState ( bool  down)

Definition at line 435 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::SetDeferDequeue ( bool  defer)

Definition at line 948 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::SetDeferSessionReader ( bool  defer_reader)
private

Definition at line 875 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::SetGeneratorKey ( const std::string &  generator)
inline

Definition at line 144 of file sandesh_state_machine.h.

void SandeshStateMachine::SetQueueWaterMarkInfo ( Sandesh::QueueWaterMarkInfo wm)

Definition at line 882 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::SetSandeshMessageDropLevel ( size_t  queue_count,
SandeshLevel::type  level,
boost::function< void(void)>  cb 
)
private

Definition at line 860 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::Shutdown ( void  )

Definition at line 431 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::StartIdleHoldTimer ( )

Definition at line 499 of file sandesh_state_machine.cc.

Here is the call graph for this function:

const string & SandeshStateMachine::StateName ( ) const

Definition at line 746 of file sandesh_state_machine.cc.

void SandeshStateMachine::TimerErrorHandler ( std::string  name,
std::string  error 
)
private

Definition at line 527 of file sandesh_state_machine.cc.

void SandeshStateMachine::unconsumed_event ( const sc::event_base &  event)

Definition at line 814 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::UpdateEventDequeue ( const sc::event_base &  event)
private

Definition at line 769 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::UpdateEventDequeueFail ( const sc::event_base &  event)
private

Definition at line 777 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::UpdateEventEnqueue ( const sc::event_base &  event)
private

Definition at line 765 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::UpdateEventEnqueueFail ( const sc::event_base &  event)
private

Definition at line 773 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::UpdateEventStats ( const sc::event_base &  event,
bool  enqueue,
bool  fail 
)
private

Definition at line 781 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::UpdateRxMsgFailStats ( const std::string &  msg_name,
size_t  msg_size,
SandeshRxDropReason::type  dreason 
)
private

Definition at line 665 of file sandesh_state_machine.cc.

Here is the call graph for this function:

void SandeshStateMachine::UpdateRxMsgStats ( const std::string &  msg_name,
size_t  msg_size 
)
private

Definition at line 659 of file sandesh_state_machine.cc.

Here is the call graph for this function:

Friends And Related Function Documentation

bool GetEvSandeshMessageRecvSize ( SandeshStateMachine::EventContainer ec,
size_t *  msg_size 
)
friend

Definition at line 914 of file sandesh_state_machine.cc.

friend class SandeshClientStateMachineTest
friend

Definition at line 166 of file sandesh_state_machine.h.

friend class SandeshServerStateMachineTest
friend

Definition at line 165 of file sandesh_state_machine.h.

friend class WorkQueue< EventContainer >
friend

Definition at line 175 of file sandesh_state_machine.h.

Member Data Documentation

SandeshMessageBuilder* SandeshStateMachine::builder_
private

Definition at line 221 of file sandesh_state_machine.h.

SandeshConnection* SandeshStateMachine::connection_
private

Definition at line 206 of file sandesh_state_machine.h.

bool SandeshStateMachine::deleted_
private

Definition at line 210 of file sandesh_state_machine.h.

SandeshEventStatistics SandeshStateMachine::event_stats_
private

Definition at line 219 of file sandesh_state_machine.h.

std::string SandeshStateMachine::generator_key_
private

Definition at line 218 of file sandesh_state_machine.h.

int SandeshStateMachine::idle_hold_time_
private

Definition at line 209 of file sandesh_state_machine.h.

Timer* SandeshStateMachine::idle_hold_timer_
private

Definition at line 208 of file sandesh_state_machine.h.

const int SandeshStateMachine::kIdleHoldTime = 5000
static

Definition at line 60 of file sandesh_state_machine.h.

const int SandeshStateMachine::kQueueSize = 200 * 1024 * 1024
static

Definition at line 61 of file sandesh_state_machine.h.

std::string SandeshStateMachine::last_event_
private

Definition at line 215 of file sandesh_state_machine.h.

uint64_t SandeshStateMachine::last_event_at_
private

Definition at line 216 of file sandesh_state_machine.h.

ssm::SsmState SandeshStateMachine::last_state_
private

Definition at line 213 of file sandesh_state_machine.h.

SandeshLevel::type SandeshStateMachine::message_drop_level_
private

Definition at line 222 of file sandesh_state_machine.h.

SandeshMessageStatistics SandeshStateMachine::message_stats_
private

Definition at line 220 of file sandesh_state_machine.h.

const char* SandeshStateMachine::prefix_
private

Definition at line 202 of file sandesh_state_machine.h.

bool SandeshStateMachine::resource_
private

Definition at line 212 of file sandesh_state_machine.h.

SandeshSession* SandeshStateMachine::session_
private

Definition at line 207 of file sandesh_state_machine.h.

tbb::mutex SandeshStateMachine::smutex_
mutableprivate

Definition at line 203 of file sandesh_state_machine.h.

tbb::atomic<ssm::SsmState> SandeshStateMachine::state_
private

Definition at line 211 of file sandesh_state_machine.h.

uint64_t SandeshStateMachine::state_since_
private

Definition at line 214 of file sandesh_state_machine.h.

EventQueue SandeshStateMachine::work_queue_
private

Definition at line 205 of file sandesh_state_machine.h.


The documentation for this class was generated from the following files: