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

#include <sandesh_session.h>

Inheritance diagram for SandeshSession:
Collaboration diagram for SandeshSession:

Public Member Functions

 SandeshSession (SslServer *client, SslSocket *socket, int task_instance, int writer_task_id, int reader_task_id)
 
virtual ~SandeshSession ()
 
virtual void Shutdown ()
 
virtual void OnRead (Buffer buffer)
 
virtual void WriteReady (const boost::system::error_code &ec)
 
virtual bool EnqueueBuffer (u_int8_t *buf, u_int32_t buf_len)
 
Sandesh::SandeshQueuesend_queue ()
 
Sandesh::SandeshBufferQueuesend_buffer_queue ()
 
SandeshWriterwriter ()
 
void SetConnection (SandeshConnection *connection)
 
SandeshConnectionconnection ()
 
void SetReceiveMsgCb (SandeshReceiveMsgCb cb)
 
virtual int GetSessionInstance () const
 
virtual void EnqueueClose ()
 
virtual boost::system::error_code SetSocketOptions ()
 
virtual std::string ToString () const
 
void set_stats_client (StatsClient *stats_client)
 
void increment_recv_msg ()
 
void increment_recv_msg_fail ()
 
void increment_recv_fail ()
 
void increment_send_msg ()
 
void increment_send_msg_fail ()
 
void increment_send_buffer_fail ()
 
void increment_wait_msgq_enqueue ()
 
void increment_wait_msgq_dequeue ()
 
void increment_write_ready_cb_error ()
 
const SandeshSessionStats & GetStats () const
 
void SetSendQueueWaterMark (Sandesh::QueueWaterMarkInfo &wm_info)
 
void ResetSendQueueWaterMark ()
 
SandeshLevel::type SendingLevel () const
 
- Public Member Functions inherited from SslSession
 SslSession (SslServer *server, SslSocket *socket, bool async_read_ready=true)
 
virtual Socketsocket () const
 
void TriggerSslHandShake (SslHandShakeCallbackHandler)
 
bool IsSslDisabled ()
 
bool IsSslHandShakeDelayed ()
 
bool IsSslHandShakeSuccess ()
 
bool IsSslHandShakeSuccessLocked ()
 
bool IsSslHandShakeInProgress ()
 
void SetSslHandShakeInProgress (bool state)
 
- Public Member Functions inherited from TcpSession
 TcpSession (TcpServer *server, Socket *socket, bool async_read_ready=true, size_t buffer_send_size=TcpSession::kDefaultWriteBufferSize)
 
virtual bool Send (const uint8_t *data, size_t size, size_t *sent)
 
virtual bool Connected (Endpoint remote)
 
virtual void Accepted ()
 
void ConnectFailed ()
 
void Close ()
 
NativeSocketType sock_descriptor ()
 
TcpServerserver ()
 
int32_t local_port () const
 
int32_t remote_port () const
 
void set_observer (EventObserver observer)
 
virtual void ReleaseBuffer (Buffer buffer)
 
bool IsEstablished () const
 
bool IsClosed () const
 
bool IsServerSession ()
 
Endpoint remote_endpoint () const
 
const std::string & remote_addr_string () const
 
Endpoint local_endpoint () const
 
const boost::system::error_code & close_reason () const
 
void set_read_on_connect (bool read)
 
void SessionEstablished (Endpoint remote, Direction direction)
 
virtual void AsyncReadStart ()
 
virtual void SetDeferReader (bool defer_reader)
 
virtual bool IsReaderDeferred () const
 
const io::SocketStatsGetSocketStats () const
 
void GetRxSocketStats (SocketIOStats *socket_stats) const
 
void GetTxSocketStats (SocketIOStats *socket_stats) const
 
void GetRxSocketStats (SocketIOStats &socket_stats) const
 
void GetTxSocketStats (SocketIOStats &socket_stats) const
 
int SetMd5SocketOption (uint32_t peer_ip, const std::string &md5_password)
 
int ClearMd5SocketOption (uint32_t peer_ip)
 
int SetDscpSocketOption (uint8_t value)
 
uint8_t GetDscpValue () const
 
const std::string & ToUVEKey () const
 
boost::system::error_code SetTcpNoDelay ()
 
boost::system::error_code SetTcpSendBufSize (uint32_t size)
 
boost::system::error_code SetTcpRecvBufSize (uint32_t size)
 

Static Public Member Functions

static SandeshDecodeCtrlSandesh (const std::string &msg, const SandeshHeader &header, const std::string &sandesh_name, const uint32_t &header_offset)
 
- Static Public Member Functions inherited from SslSession
static bool IsSocketErrorHard (const boost::system::error_code &ec)
 
- Static Public Member Functions inherited from TcpSession
static const uint8_t * BufferData (const Buffer &buffer)
 
static size_t BufferSize (const Buffer &buffer)
 
static bool IsSocketErrorHard (const boost::system::error_code &ec)
 

Protected Member Functions

virtual int reader_task_id () const
 
- Protected Member Functions inherited from SslSession
virtual ~SslSession ()
 
- Protected Member Functions inherited from TcpSession
void AsyncReadStartInternal (TcpSessionPtr session)
 
virtual ~TcpSession ()
 
void AsyncWriteInternal (TcpSessionPtr session)
 
bool established () const
 
EventObserver observer ()
 
boost::system::error_code SetSocketKeepaliveOptions (int keepalive_time, int keepalive_intvl, int keepalive_probes, int tcp_user_timeout_val=0)
 
void CloseInternal (const boost::system::error_code &ec, bool call_observer, bool notify_server=true)
 
void TriggerAsyncReadHandler ()
 

Private Member Functions

bool SendMsg (SandeshElement element)
 
bool SendBuffer (boost::shared_ptr< TMemoryBuffer > sbuffer)
 
bool SessionSendReady ()
 
void SetSendingLevel (size_t count, SandeshLevel::type level)
 
 DISALLOW_COPY_AND_ASSIGN (SandeshSession)
 

Private Attributes

int instance_
 
boost::scoped_ptr< SandeshWriterwriter_
 
boost::scoped_ptr< SandeshReaderreader_
 
boost::scoped_ptr
< Sandesh::SandeshQueue
send_queue_
 
boost::scoped_ptr
< Sandesh::SandeshBufferQueue
send_buffer_queue_
 
StatsClientstats_client_
 
SandeshConnectionconnection_
 
tbb::mutex conn_mutex_
 
tbb::mutex send_mutex_
 
int keepalive_idle_time_
 
int keepalive_interval_
 
int keepalive_probes_
 
int tcp_user_timeout_
 
int reader_task_id_
 
SandeshLevel::type sending_level_
 
SandeshSessionStats sstats_
 

Static Private Attributes

static const int kSessionKeepaliveIdleTime = 15
 
static const int kSessionKeepaliveInterval = 3
 
static const int kSessionKeepaliveProbes = 5
 
static const int kSessionTcpUserTimeout = 30000
 
static const int kQueueSize = 200 * 1024 * 1024
 

Friends

class SandeshSessionTest
 

Additional Inherited Members

- Public Types inherited from SslSession
typedef
boost::asio::ssl::stream
< boost::asio::ip::tcp::socket > 
SslSocket
 
- Public Types inherited from TcpSession
enum  Event {
  EVENT_NONE, ACCEPT, CONNECT_COMPLETE, CONNECT_FAILED,
  CLOSE
}
 
enum  Direction { ACTIVE, PASSIVE }
 
typedef
boost::asio::ip::tcp::socket 
Socket
 
typedef
boost::asio::ip::tcp::socket::native_handle_type 
NativeSocketType
 
typedef
boost::asio::ip::tcp::endpoint 
Endpoint
 
typedef boost::function< void(TcpSession
*, Event)> 
EventObserver
 
typedef boost::asio::const_buffer Buffer
 
- Static Public Attributes inherited from TcpSession
static const int kDefaultBufferSize = 16 * 1024
 
static const int kDefaultWriteBufferSize = 32 * 1024
 
- Protected Types inherited from TcpSession
typedef boost::intrusive_ptr
< TcpSession
TcpSessionPtr
 
typedef boost::asio::strand
< boost::asio::io_context::executor_type > 
Strand
 
- Static Protected Member Functions inherited from TcpSession
static void AsyncReadHandler (TcpSessionPtr session)
 
static void AsyncWriteHandler (TcpSessionPtr session, const boost::system::error_code &error, std::size_t bytes_transferred)
 
- Protected Attributes inherited from TcpSession
tbb::mutex mutex_
 
io::SocketStats stats_
 
boost::scoped_ptr< Strandio_strand_
 

Detailed Description

Definition at line 143 of file sandesh_session.h.

Constructor & Destructor Documentation

SandeshSession::SandeshSession ( SslServer client,
SslSocket socket,
int  task_instance,
int  writer_task_id,
int  reader_task_id 
)

Definition at line 281 of file sandesh_session.cc.

Here is the call graph for this function:

SandeshSession::~SandeshSession ( )
virtual

Definition at line 308 of file sandesh_session.cc.

Member Function Documentation

SandeshConnection* SandeshSession::connection ( )
inline

Definition at line 167 of file sandesh_session.h.

Sandesh * SandeshSession::DecodeCtrlSandesh ( const std::string &  msg,
const SandeshHeader &  header,
const std::string &  sandesh_name,
const uint32_t &  header_offset 
)
static

Definition at line 413 of file sandesh_session.cc.

Here is the call graph for this function:

SandeshSession::DISALLOW_COPY_AND_ASSIGN ( SandeshSession  )
private
bool SandeshSession::EnqueueBuffer ( u_int8_t *  buf,
u_int32_t  buf_len 
)
virtual

Definition at line 405 of file sandesh_session.cc.

Here is the call graph for this function:

void SandeshSession::EnqueueClose ( )
virtual

Definition at line 443 of file sandesh_session.cc.

Here is the call graph for this function:

virtual int SandeshSession::GetSessionInstance ( ) const
inlinevirtual

Reimplemented from TcpSession.

Definition at line 174 of file sandesh_session.h.

const SandeshSessionStats& SandeshSession::GetStats ( ) const
inline

Definition at line 211 of file sandesh_session.h.

void SandeshSession::increment_recv_fail ( )
inline

Definition at line 190 of file sandesh_session.h.

void SandeshSession::increment_recv_msg ( )
inline

Definition at line 184 of file sandesh_session.h.

void SandeshSession::increment_recv_msg_fail ( )
inline

Definition at line 187 of file sandesh_session.h.

void SandeshSession::increment_send_buffer_fail ( )
inline

Definition at line 199 of file sandesh_session.h.

void SandeshSession::increment_send_msg ( )
inline

Definition at line 193 of file sandesh_session.h.

void SandeshSession::increment_send_msg_fail ( )
inline

Definition at line 196 of file sandesh_session.h.

void SandeshSession::increment_wait_msgq_dequeue ( )
inline

Definition at line 205 of file sandesh_session.h.

void SandeshSession::increment_wait_msgq_enqueue ( )
inline

Definition at line 202 of file sandesh_session.h.

void SandeshSession::increment_write_ready_cb_error ( )
inline

Definition at line 208 of file sandesh_session.h.

void SandeshSession::OnRead ( Buffer  buffer)
virtual

Implements TcpSession.

Definition at line 365 of file sandesh_session.cc.

virtual int SandeshSession::reader_task_id ( ) const
inlineprotectedvirtual

Reimplemented from TcpSession.

Definition at line 219 of file sandesh_session.h.

void SandeshSession::ResetSendQueueWaterMark ( )

Definition at line 328 of file sandesh_session.cc.

Sandesh::SandeshBufferQueue* SandeshSession::send_buffer_queue ( )
inline

Definition at line 157 of file sandesh_session.h.

Sandesh::SandeshQueue* SandeshSession::send_queue ( )
inline

Definition at line 154 of file sandesh_session.h.

bool SandeshSession::SendBuffer ( boost::shared_ptr< TMemoryBuffer sbuffer)
private

Definition at line 394 of file sandesh_session.cc.

Here is the call graph for this function:

SandeshLevel::type SandeshSession::SendingLevel ( ) const

Definition at line 339 of file sandesh_session.cc.

bool SandeshSession::SendMsg ( SandeshElement  element)
private

Definition at line 369 of file sandesh_session.cc.

Here is the call graph for this function:

bool SandeshSession::SessionSendReady ( )
private

Definition at line 311 of file sandesh_session.cc.

Here is the call graph for this function:

void SandeshSession::set_stats_client ( StatsClient stats_client)
inline

Definition at line 180 of file sandesh_session.h.

void SandeshSession::SetConnection ( SandeshConnection connection)
inline

Definition at line 163 of file sandesh_session.h.

Here is the call graph for this function:

void SandeshSession::SetReceiveMsgCb ( SandeshReceiveMsgCb  cb)
inline

Definition at line 171 of file sandesh_session.h.

void SandeshSession::SetSendingLevel ( size_t  count,
SandeshLevel::type  level 
)
private

Definition at line 333 of file sandesh_session.cc.

void SandeshSession::SetSendQueueWaterMark ( Sandesh::QueueWaterMarkInfo wm_info)

Definition at line 316 of file sandesh_session.cc.

Here is the call graph for this function:

boost::system::error_code SandeshSession::SetSocketOptions ( )
virtual

Reimplemented from TcpSession.

Definition at line 356 of file sandesh_session.cc.

Here is the call graph for this function:

void SandeshSession::Shutdown ( void  )
virtual

Definition at line 343 of file sandesh_session.cc.

Here is the call graph for this function:

std::string SandeshSession::ToString ( ) const
virtual

Reimplemented from TcpSession.

Definition at line 350 of file sandesh_session.cc.

Here is the call graph for this function:

SandeshWriter* SandeshSession::writer ( )
inline

Definition at line 160 of file sandesh_session.h.

virtual void SandeshSession::WriteReady ( const boost::system::error_code &  ec)
inlinevirtual

Reimplemented from TcpSession.

Definition at line 150 of file sandesh_session.h.

Friends And Related Function Documentation

friend class SandeshSessionTest
friend

Definition at line 224 of file sandesh_session.h.

Member Data Documentation

tbb::mutex SandeshSession::conn_mutex_
private

Definition at line 245 of file sandesh_session.h.

SandeshConnection* SandeshSession::connection_
private

Definition at line 244 of file sandesh_session.h.

int SandeshSession::instance_
private

Definition at line 238 of file sandesh_session.h.

int SandeshSession::keepalive_idle_time_
private

Definition at line 247 of file sandesh_session.h.

int SandeshSession::keepalive_interval_
private

Definition at line 248 of file sandesh_session.h.

int SandeshSession::keepalive_probes_
private

Definition at line 249 of file sandesh_session.h.

const int SandeshSession::kQueueSize = 200 * 1024 * 1024
staticprivate

Definition at line 231 of file sandesh_session.h.

const int SandeshSession::kSessionKeepaliveIdleTime = 15
staticprivate

Definition at line 227 of file sandesh_session.h.

const int SandeshSession::kSessionKeepaliveInterval = 3
staticprivate

Definition at line 228 of file sandesh_session.h.

const int SandeshSession::kSessionKeepaliveProbes = 5
staticprivate

Definition at line 229 of file sandesh_session.h.

const int SandeshSession::kSessionTcpUserTimeout = 30000
staticprivate

Definition at line 230 of file sandesh_session.h.

boost::scoped_ptr<SandeshReader> SandeshSession::reader_
private

Definition at line 240 of file sandesh_session.h.

int SandeshSession::reader_task_id_
private

Definition at line 251 of file sandesh_session.h.

boost::scoped_ptr<Sandesh::SandeshBufferQueue> SandeshSession::send_buffer_queue_
private

Definition at line 242 of file sandesh_session.h.

tbb::mutex SandeshSession::send_mutex_
private

Definition at line 246 of file sandesh_session.h.

boost::scoped_ptr<Sandesh::SandeshQueue> SandeshSession::send_queue_
private

Definition at line 241 of file sandesh_session.h.

SandeshLevel::type SandeshSession::sending_level_
private

Definition at line 252 of file sandesh_session.h.

SandeshSessionStats SandeshSession::sstats_
private

Definition at line 255 of file sandesh_session.h.

StatsClient* SandeshSession::stats_client_
private

Definition at line 243 of file sandesh_session.h.

int SandeshSession::tcp_user_timeout_
private

Definition at line 250 of file sandesh_session.h.

boost::scoped_ptr<SandeshWriter> SandeshSession::writer_
private

Definition at line 239 of file sandesh_session.h.


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