OpenSDN source code
|
#include <state_machine.h>
Classes | |
struct | EventContainer |
Public Types | |
enum | State { IDLE = 0, ACTIVE = 1, CONNECT = 2, OPENSENT = 3, OPENCONFIRM = 4, ESTABLISHED = 5 } |
typedef boost::function< void(void)> | EventCB |
Public Member Functions | |
StateMachine (BgpPeer *peer) | |
virtual | ~StateMachine () |
void | Initialize () |
void | Shutdown (int subcode) |
void | SetAdminState (bool down, int subcode) |
bool | IsQueueEmpty () const |
template<typename Ev , int code> | |
void | OnIdle (const Ev &event) |
template<typename Ev > | |
void | OnIdleCease (const Ev &event) |
template<typename Ev , int code> | |
void | OnIdleError (const Ev &event) |
void | OnIdleNotification (const fsm::EvBgpNotification &event) |
int | GetConnectTime () const |
virtual void | StartConnectTimer (int seconds) |
void | CancelConnectTimer () |
bool | ConnectTimerRunning () |
virtual void | StartOpenTimer (int seconds) |
void | CancelOpenTimer () |
bool | OpenTimerRunning () |
int | GetConfiguredHoldTime () const |
virtual void | StartHoldTimer () |
void | CancelHoldTimer () |
bool | HoldTimerRunning () |
virtual void | StartIdleHoldTimer () |
void | CancelIdleHoldTimer () |
bool | IdleHoldTimerRunning () |
void | StartSession () |
virtual void | DeleteSession (BgpSession *session) |
void | AssignSession (bool active) |
virtual void | OnSessionEvent (TcpSession *session, TcpSession::Event event) |
bool | PassiveOpen (BgpSession *session) |
void | OnMessage (BgpSession *session, BgpProto::BgpMessage *msg, size_t msgsize=0) |
void | OnMessageError (BgpSession *session, const ParseErrorContext *context) |
void | SendNotification (BgpSession *session, int code, int subcode=0, const std::string &data=std::string()) |
bool | ProcessNotificationEvent (BgpSession *session) |
void | SetDataCollectionKey (BgpPeerInfo *peer_info) const |
const std::string & | StateName () const |
const std::string & | LastStateName () const |
BgpPeer * | peer () |
BgpSession * | active_session () |
void | set_active_session (BgpSession *session) |
BgpSession * | passive_session () |
void | set_passive_session (BgpSession *session) |
int | connect_attempts () const |
void | connect_attempts_inc () |
void | connect_attempts_clear () |
int | hold_time () const |
void | reset_hold_time () |
void | set_hold_time (int hold_time) |
virtual int | keepalive_time_msecs () const |
int | idle_hold_time () const |
void | reset_idle_hold_time () |
void | set_idle_hold_time (int idle_hold_time) |
void | set_state (State state) |
State | get_state () const |
const std::string | last_state_change_at () const |
const uint64_t | last_state_change_usecs_at () const |
void | set_last_event (const std::string &event) |
const std::string & | last_event () const |
void | set_last_notification_in (int code, int subcode, const std::string &reason) |
void | set_last_notification_out (int code, int subcode, const std::string &reason) |
const std::string | last_notification_out_error () const |
const std::string | last_notification_in_error () const |
void | reset_last_info () |
void | LogEvent (std::string event_name, std::string msg, SandeshLevel::type log_level=SandeshLevel::SYS_DEBUG) |
bool | HoldTimerExpired () |
virtual bool | IsCloseGraceful () const |
virtual bool | IsRouterTypeBGPaaS () const |
virtual bool | IsPeerCloseInProgress () const |
Static Public Attributes | |
static const int | kOpenTime = 15 |
static const int | kConnectInterval = 30 |
static const int | kHoldTime = 90 |
static const int | kOpenSentHoldTime = 240 |
static const int | kIdleHoldTime |
static const int | kMaxIdleHoldTime = 100 * 1000 |
static const int | kJitter = 10 |
Protected Member Functions | |
virtual void | OnNotificationMessage (BgpSession *session, BgpProto::BgpMessage *msg) |
virtual const int | GetIdleHoldTimeMSecs () const |
Private Member Functions | |
bool | ConnectTimerExpired () |
void | FireConnectTimer () |
bool | OpenTimerExpired () |
void | FireOpenTimer () |
void | FireHoldTimer () |
bool | IdleHoldTimerExpired () |
void | FireIdleHoldTimer () |
void | TimerErrorHanlder (std::string name, std::string error) |
void | DeleteAllTimers () |
void | BGPPeerInfoSend (const BgpPeerInfoData &peer_info) |
template<typename Ev > | |
bool | Enqueue (const Ev &event) |
bool | DequeueEvent (EventContainer ec) |
void | DequeueEventDone (bool done) |
void | UpdateFlapCount () |
void | PeerClose (int code, int subcode) |
DISALLOW_COPY_AND_ASSIGN (StateMachine) | |
Private Attributes | |
WorkQueue< EventContainer > | work_queue_ |
BgpPeer * | peer_ |
BgpSession * | active_session_ |
BgpSession * | passive_session_ |
Timer * | connect_timer_ |
Timer * | open_timer_ |
Timer * | hold_timer_ |
Timer * | idle_hold_timer_ |
int | hold_time_ |
int | idle_hold_time_ |
int | attempts_ |
unsigned int | seed_ |
bool | deleted_ |
State | state_ |
State | last_state_ |
std::string | last_event_ |
uint64_t | last_event_at_ |
uint64_t | last_state_change_at_ |
std::pair< int, int > | last_notification_in_ |
std::string | last_notification_in_error_ |
uint64_t | last_notification_in_at_ |
std::pair< int, int > | last_notification_out_ |
std::string | last_notification_out_error_ |
uint64_t | last_notification_out_at_ |
Friends | |
class | StateMachineTest |
class | StateMachineUnitTest |
Definition at line 75 of file state_machine.h.
typedef boost::function<void(void)> StateMachine::EventCB |
Definition at line 77 of file state_machine.h.
enum StateMachine::State |
Enumerator | |
---|---|
IDLE | |
ACTIVE | |
CONNECT | |
OPENSENT | |
OPENCONFIRM | |
ESTABLISHED |
Definition at line 87 of file state_machine.h.
|
explicit |
|
virtual |
BgpSession * StateMachine::active_session | ( | ) |
Definition at line 1360 of file state_machine.cc.
void StateMachine::AssignSession | ( | bool | active | ) |
|
private |
Definition at line 1720 of file state_machine.cc.
void StateMachine::CancelConnectTimer | ( | ) |
void StateMachine::CancelHoldTimer | ( | ) |
void StateMachine::CancelIdleHoldTimer | ( | ) |
void StateMachine::CancelOpenTimer | ( | ) |
|
inline |
Definition at line 152 of file state_machine.h.
|
inline |
Definition at line 154 of file state_machine.h.
|
inline |
Definition at line 153 of file state_machine.h.
|
private |
bool StateMachine::ConnectTimerRunning | ( | ) |
|
private |
|
virtual |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
Definition at line 168 of file state_machine.h.
int StateMachine::GetConfiguredHoldTime | ( | ) | const |
int StateMachine::GetConnectTime | ( | ) | const |
Definition at line 1209 of file state_machine.cc.
|
inlineprotectedvirtual |
Definition at line 191 of file state_machine.h.
|
inline |
Definition at line 156 of file state_machine.h.
bool StateMachine::HoldTimerExpired | ( | ) |
bool StateMachine::HoldTimerRunning | ( | ) |
|
inline |
Definition at line 161 of file state_machine.h.
|
private |
bool StateMachine::IdleHoldTimerRunning | ( | ) |
void StateMachine::Initialize | ( | ) |
|
virtual |
|
virtual |
bool StateMachine::IsQueueEmpty | ( | ) | const |
|
virtual |
|
inlinevirtual |
Definition at line 159 of file state_machine.h.
|
inline |
Definition at line 172 of file state_machine.h.
const std::string StateMachine::last_notification_in_error | ( | ) | const |
const std::string StateMachine::last_notification_out_error | ( | ) | const |
const std::string StateMachine::last_state_change_at | ( | ) | const |
const uint64_t StateMachine::last_state_change_usecs_at | ( | ) | const |
Definition at line 1590 of file state_machine.cc.
const string & StateMachine::LastStateName | ( | ) | const |
Definition at line 1582 of file state_machine.cc.
void StateMachine::LogEvent | ( | std::string | event_name, |
std::string | msg, | ||
SandeshLevel::type | log_level = SandeshLevel::SYS_DEBUG |
||
) |
void StateMachine::OnIdle | ( | const Ev & | event | ) |
void StateMachine::OnIdleCease | ( | const Ev & | event | ) |
void StateMachine::OnIdleError | ( | const Ev & | event | ) |
void StateMachine::OnIdleNotification | ( | const fsm::EvBgpNotification & | event | ) |
void StateMachine::OnMessage | ( | BgpSession * | session, |
BgpProto::BgpMessage * | msg, | ||
size_t | msgsize = 0 |
||
) |
void StateMachine::OnMessageError | ( | BgpSession * | session, |
const ParseErrorContext * | context | ||
) |
|
protectedvirtual |
|
virtual |
|
private |
bool StateMachine::OpenTimerRunning | ( | ) |
BgpSession * StateMachine::passive_session | ( | ) |
Definition at line 1364 of file state_machine.cc.
bool StateMachine::PassiveOpen | ( | BgpSession * | session | ) |
|
inline |
Definition at line 146 of file state_machine.h.
|
private |
bool StateMachine::ProcessNotificationEvent | ( | BgpSession * | session | ) |
void StateMachine::reset_hold_time | ( | ) |
|
inline |
Definition at line 162 of file state_machine.h.
void StateMachine::reset_last_info | ( | ) |
void StateMachine::SendNotification | ( | BgpSession * | session, |
int | code, | ||
int | subcode = 0 , |
||
const std::string & | data = std::string() |
||
) |
void StateMachine::set_active_session | ( | BgpSession * | session | ) |
void StateMachine::set_hold_time | ( | int | hold_time | ) |
|
inline |
void StateMachine::set_last_event | ( | const std::string & | event | ) |
void StateMachine::set_last_notification_in | ( | int | code, |
int | subcode, | ||
const std::string & | reason | ||
) |
void StateMachine::set_last_notification_out | ( | int | code, |
int | subcode, | ||
const std::string & | reason | ||
) |
void StateMachine::set_passive_session | ( | BgpSession * | session | ) |
void StateMachine::set_state | ( | State | state | ) |
void StateMachine::SetAdminState | ( | bool | down, |
int | subcode | ||
) |
void StateMachine::SetDataCollectionKey | ( | BgpPeerInfo * | peer_info | ) | const |
void StateMachine::Shutdown | ( | int | subcode | ) |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
void StateMachine::StartSession | ( | ) |
const string & StateMachine::StateName | ( | ) | const |
Definition at line 1578 of file state_machine.cc.
|
inlineprivate |
Definition at line 210 of file state_machine.h.
|
private |
|
friend |
Definition at line 194 of file state_machine.h.
|
friend |
Definition at line 195 of file state_machine.h.
|
private |
Definition at line 222 of file state_machine.h.
|
private |
Definition at line 230 of file state_machine.h.
|
private |
Definition at line 224 of file state_machine.h.
|
private |
Definition at line 232 of file state_machine.h.
|
private |
Definition at line 228 of file state_machine.h.
|
private |
Definition at line 226 of file state_machine.h.
|
private |
Definition at line 229 of file state_machine.h.
|
private |
Definition at line 227 of file state_machine.h.
|
static |
Definition at line 80 of file state_machine.h.
|
static |
Definition at line 81 of file state_machine.h.
|
static |
Definition at line 83 of file state_machine.h.
|
static |
Definition at line 85 of file state_machine.h.
|
static |
Definition at line 84 of file state_machine.h.
|
static |
Definition at line 82 of file state_machine.h.
|
static |
Definition at line 79 of file state_machine.h.
|
private |
Definition at line 235 of file state_machine.h.
|
private |
Definition at line 236 of file state_machine.h.
|
private |
Definition at line 238 of file state_machine.h.
|
private |
Definition at line 240 of file state_machine.h.
|
private |
Definition at line 239 of file state_machine.h.
|
private |
Definition at line 241 of file state_machine.h.
|
private |
Definition at line 243 of file state_machine.h.
|
private |
Definition at line 242 of file state_machine.h.
|
private |
Definition at line 234 of file state_machine.h.
|
private |
Definition at line 237 of file state_machine.h.
|
private |
Definition at line 225 of file state_machine.h.
|
private |
Definition at line 223 of file state_machine.h.
|
private |
Definition at line 221 of file state_machine.h.
|
private |
Definition at line 231 of file state_machine.h.
|
private |
Definition at line 233 of file state_machine.h.
|
private |
Definition at line 220 of file state_machine.h.