0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Public Attributes | List of all members
Hypertable::Event Class Reference

Network communication event. More...

#include <Event.h>

Collaboration diagram for Hypertable::Event:
Collaboration graph
[legend]

Public Types

enum  Type {
  CONNECTION_ESTABLISHED, DISCONNECT, MESSAGE, ERROR,
  TIMER
}
 Enumeration for event types. More...
 

Public Member Functions

 Event (Type type_, const InetAddr &addr_, int error_=Error::OK)
 Constructor initializing with InetAddr. More...
 
 Event (Type type_, const sockaddr_in &addr_, const String &proxy_, int error_=Error::OK)
 Constructor initializing with InetAddr and proxy name. More...
 
 Event (Type type_, int error_=Error::OK)
 Constructor initializing with empty address. More...
 
 Event (Type type_, const String &proxy_, int error_=0)
 Constructor initialized with proxy name. More...
 
 ~Event ()
 Destructor. More...
 
void load_message_header (const uint8_t *buf, size_t len)
 Loads header object from serialized message buffer. More...
 
void set_proxy (const String &p)
 Sets the address proxy name from which this event was generated. More...
 
ClockT::time_point deadline ()
 Deadline for request. More...
 
String to_str () const
 Generates a one-line string representation of the event. More...
 
void display ()
 Displays a one-line string representation of the event to stdout. More...
 

Public Attributes

Type type
 Type of event. More...
 
InetAddr addr
 Remote address from which event was generated. More...
 
const char * proxy
 Address proxy name. More...
 
char * proxy_buf {}
 Pointer to allocated proxy name buffer. More...
 
char proxy_buf_static [32]
 Static proxy name buffer. More...
 
InetAddr local_addr
 Local address to which event was delivered. More...
 
int error {}
 Error code associated with this event. More...
 
CommHeader header
 Comm layer header for MESSAGE events. More...
 
const uint8_t * payload {}
 Points to a buffer containing the message payload. More...
 
size_t payload_len {}
 Length of the message. More...
 
uint64_t group_id {}
 Thread group to which this message belongs. More...
 
ClockT::time_point arrival_time {}
 time (seconds since epoch) when message arrived More...
 
bool payload_aligned {}
 Flag indicating if payload was allocated with posix_memalign. More...
 

Detailed Description

Network communication event.

Objects of this type get passed up to the application through dispatch handlers (see DispatchHandler).

Definition at line 54 of file Event.h.

Constructor & Destructor Documentation

Hypertable::Event::Event ( Type  type_,
const InetAddr addr_,
int  error_ = Error::OK 
)
inline

Constructor initializing with InetAddr.

Parameters
type_Type of event
addr_Remote address from which event originated
error_Error code associated with this event

Definition at line 74 of file Event.h.

Hypertable::Event::Event ( Type  type_,
const sockaddr_in &  addr_,
const String proxy_,
int  error_ = Error::OK 
)
inline

Constructor initializing with InetAddr and proxy name.

Parameters
type_Type of event
addr_Remote address from which event originated
proxy_Proxy name
error_Error code associated with this event

Definition at line 86 of file Event.h.

Hypertable::Event::Event ( Type  type_,
int  error_ = Error::OK 
)
inline

Constructor initializing with empty address.

Parameters
type_Type of event
error_Error code associated with this event

Definition at line 97 of file Event.h.

Hypertable::Event::Event ( Type  type_,
const String proxy_,
int  error_ = 0 
)
inline

Constructor initialized with proxy name.

Parameters
type_Type of event
proxy_Proxy name
error_Error code associated with this event

Definition at line 108 of file Event.h.

Hypertable::Event::~Event ( )
inline

Destructor.

Deallocates message payload buffer and proxy name buffer

Definition at line 115 of file Event.h.

Member Function Documentation

ClockT::time_point Hypertable::Event::deadline ( )
inline

Deadline for request.

Returns
Absolute deadline

Definition at line 157 of file Event.h.

void Hypertable::Event::display ( )
inline

Displays a one-line string representation of the event to stdout.

See also
to_str

Definition at line 224 of file Event.h.

void Hypertable::Event::load_message_header ( const uint8_t *  buf,
size_t  len 
)
inline

Loads header object from serialized message buffer.

This method also sets the group_id member.

Parameters
bufBuffer containing serialized header
lenLength of buffer

Definition at line 130 of file Event.h.

void Hypertable::Event::set_proxy ( const String p)
inline

Sets the address proxy name from which this event was generated.

If the proxy name is less than 32 characters, then it is copied into proxy_buf_static, otherwise a buffer is allocated to hold it. proxy is set to point to whichever buffer is chosen.

Definition at line 140 of file Event.h.

String Event::to_str ( ) const

Generates a one-line string representation of the event.

For example:

  Event: type=MESSAGE id=2 gid=0 header_len=16 total_len=20 \
  from=127.0.0.1:15861 ...

Definition at line 48 of file Event.cc.

Member Data Documentation

InetAddr Hypertable::Event::addr

Remote address from which event was generated.

Definition at line 168 of file Event.h.

ClockT::time_point Hypertable::Event::arrival_time {}

time (seconds since epoch) when message arrived

Definition at line 208 of file Event.h.

int Hypertable::Event::error {}

Error code associated with this event.

DISCONNECT and ERROR events set this value

Definition at line 185 of file Event.h.

uint64_t Hypertable::Event::group_id {}

Thread group to which this message belongs.

Used to serialize messages destined for the same object. This value is created in the constructor and is the combination of the socked descriptor from which the message was read and the gid field in the message header:

group_id = ((uint64_t)sd << 32) | header->gid;

If the gid is zero, then the group_id member is also set to zero

Definition at line 205 of file Event.h.

CommHeader Hypertable::Event::header

Comm layer header for MESSAGE events.

Definition at line 188 of file Event.h.

InetAddr Hypertable::Event::local_addr

Local address to which event was delivered.

Definition at line 180 of file Event.h.

const uint8_t* Hypertable::Event::payload {}

Points to a buffer containing the message payload.

Definition at line 191 of file Event.h.

bool Hypertable::Event::payload_aligned {}

Flag indicating if payload was allocated with posix_memalign.

Definition at line 211 of file Event.h.

size_t Hypertable::Event::payload_len {}

Length of the message.

Definition at line 194 of file Event.h.

const char* Hypertable::Event::proxy

Address proxy name.

Definition at line 171 of file Event.h.

char* Hypertable::Event::proxy_buf {}

Pointer to allocated proxy name buffer.

Definition at line 174 of file Event.h.

char Hypertable::Event::proxy_buf_static[32]

Static proxy name buffer.

Definition at line 177 of file Event.h.

Type Hypertable::Event::type

Type of event.

Can take one of values CONNECTION_ESTABLISHED, DISCONNECT, MESSAGE, ERROR, or TIMER

Definition at line 165 of file Event.h.


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