0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
AsyncComm

Network communication library. More...

Namespaces

 Hypertable::PollEvent
 Polling event constants (mechanism-independent).
 

Classes

class  Hypertable::ApplicationHandler
 Base clase for application handlers. More...
 
class  Hypertable::ApplicationQueue
 Application queue. More...
 
class  Hypertable::ApplicationQueue::GroupState
 Tracks group execution state. More...
 
class  Hypertable::ApplicationQueue::RequestRec
 Request record. More...
 
class  Hypertable::ApplicationQueue::ApplicationQueueState
 Application queue state shared among worker threads. More...
 
class  Hypertable::ApplicationQueue::Worker
 Application queue worker thread function (functor) More...
 
class  Hypertable::ApplicationQueueInterface
 Abstract interface for application queue. More...
 
class  Hypertable::Comm
 Entry point to AsyncComm service. More...
 
class  Hypertable::CommAddress
 Address abstraction to hold either proxy name or IPv4:port address. More...
 
class  Hypertable::CommAddressHash
 Hash function (functor) for CommAddress objets. More...
 
class  Hypertable::CommAddressMap< TypeT, addr >
 Parameterized hash map for mapping CommAddress to arbitrary type. More...
 
class  Hypertable::CommBuf
 Message buffer for holding data to be transmitted over a network. More...
 
class  Hypertable::CommHeader
 Header for messages transmitted via AsyncComm. More...
 
struct  Hypertable::Config::CommPolicy
 Config policy for Comm layer. More...
 
struct  Hypertable::Config::GenericServerPolicy
 Config policy for generic Comm layer server. More...
 
class  Hypertable::ConnectionHandlerFactory
 Abstract class for creating default application dispatch handlers. More...
 
class  Hypertable::ConnectionInitializer
 Driver interface for connection initialization handshake in ConnectionManager. More...
 
class  Hypertable::ConnectionManager
 Establishes and maintains a set of TCP connections. More...
 
class  Hypertable::ConnectionManager::ConnectionState
 Per-connection state. More...
 
struct  Hypertable::ConnectionManager::LtConnectionState
 StringWeakOrdering for connection retry heap. More...
 
class  Hypertable::ConnectionManager::SharedImpl
 Connection manager state shared between Connection manager objects. More...
 
class  Hypertable::DispatchHandler
 Abstract base class for application dispatch handlers registered with AsyncComm. More...
 
class  Hypertable::DispatchHandlerSynchronizer
 DispatchHandler class used to synchronize with response messages. More...
 
class  Hypertable::Event
 Network communication event. More...
 
struct  Hypertable::ExpireTimer
 State record for timer. More...
 
struct  Hypertable::LtTimerHeap
 Comparison function (functor) for timer heap. More...
 
class  Hypertable::HandlerMap
 Data structure for mapping socket addresses to I/O handlers. More...
 
class  Hypertable::IOHandler
 Base class for socket descriptor I/O handlers. More...
 
class  Hypertable::IOHandlerAccept
 I/O handler for accept (listen) sockets. More...
 
class  Hypertable::IOHandlerData
 I/O handler for TCP sockets. More...
 
class  Hypertable::IOHandlerDatagram
 I/O handler for datagram (UDP) sockets. More...
 
class  Hypertable::IOHandlerRaw
 I/O handler for raw sockets. More...
 
class  Hypertable::PollTimeout
 Maintains next timeout for event polling loop. More...
 
class  Hypertable::Protocol
 Abstract base class for server protocol drivers. More...
 
class  Hypertable::ProxyAddressInfo
 Holds address and hostname associated with a proxy name. More...
 
class  Hypertable::ProxyMap
 Maps a set of proxy names to their associated IP addresses. More...
 
class  Hypertable::RawSocketHandler
 Abstract base class for application raw socket handlers registered with AsyncComm. More...
 
struct  Hypertable::PollDescriptorT
 Socket descriptor poll state for use with POSIX poll() More...
 
class  Hypertable::Reactor
 Manages reactor (polling thread) state including poll interest, request cache, and timers. More...
 
class  Hypertable::ReactorFactory
 Static class used to setup and manage I/O reactors. More...
 
class  Hypertable::ReactorRunner
 Thread functor class for reacting to I/O events. More...
 
class  Hypertable::RequestCache
 Class used to hold pending request callback handlers. More...
 
class  Hypertable::RequestCache::CacheNode
 Internal cache node structure. More...
 
class  Hypertable::ResponseCallback
 This class is used to generate and deliver standard responses back to a client. More...
 

Typedefs

typedef std::shared_ptr
< ApplicationQueue
Hypertable::ApplicationQueuePtr
 Shared smart pointer to ApplicationQueue object. More...
 
typedef std::shared_ptr
< ApplicationQueueInterface > 
Hypertable::ApplicationQueueInterfacePtr
 Smart pointer to ApplicationQueueInterface. More...
 
typedef std::chrono::fast_clock Hypertable::ClockT
 Clock used for AsyncComm timing needs. More...
 
typedef std::set< CommAddress > Hypertable::CommAddressSet
 Set of CommAddress objects. More...
 
typedef std::shared_ptr< CommBuf > Hypertable::CommBufPtr
 Smart pointer to CommBuf. More...
 
typedef Cons< DefaultPolicy,
CommPolicy > 
Hypertable::Config::DefaultCommPolicy
 Default comm layer config policy. More...
 
typedef Cons
< GenericServerPolicy,
DefaultCommPolicy > 
Hypertable::Config::DefaultServerPolicy
 Default comm layer server policy. More...
 
typedef std::shared_ptr
< ConnectionHandlerFactory > 
Hypertable::ConnectionHandlerFactoryPtr
 Smart pointer to ConnectionHandlerFactory. More...
 
typedef std::shared_ptr
< ConnectionInitializer > 
Hypertable::ConnectionInitializerPtr
 Smart pointer to ConnectionInitializer. More...
 
typedef std::shared_ptr
< ConnectionManager > 
Hypertable::ConnectionManagerPtr
 Smart pointer to ConnectionManager. More...
 
typedef std::shared_ptr
< DispatchHandler > 
Hypertable::DispatchHandlerPtr
 Smart pointer to DispatchHandler. More...
 
typedef std::shared_ptr
< DispatchHandlerSynchronizer > 
Hypertable::DispatchHandlerSynchronizerPtr
 Shared smart pointer to DispatchHandlerSynchronizer. More...
 
typedef std::shared_ptr< Event > Hypertable::EventPtr
 Smart pointer to Event. More...
 
typedef std::shared_ptr
< HandlerMap > 
Hypertable::HandlerMapPtr
 Smart pointer to HandlerMap. More...
 
typedef std::unordered_map
< String, ProxyAddressInfo > 
Hypertable::ProxyMapT
 Forward mapping hash type from proxy name to ProxyAddressInfo. More...
 
typedef std::shared_ptr< Reactor > Hypertable::ReactorPtr
 Shared smart pointer to Reactor. More...
 
typedef std::unordered_map
< uint32_t, CacheNode * > 
Hypertable::RequestCache::IdHandlerMap
 RequestID-to-CacheNode map. More...
 

Enumerations

enum  Hypertable::CommAddress::AddressType { Hypertable::CommAddress::NONE =0, Hypertable::CommAddress::PROXY, Hypertable::CommAddress::INET }
 Enumeration for address type. More...
 
enum  Hypertable::CommHeader::Flags {
  Hypertable::CommHeader::FLAGS_BIT_REQUEST = 0x0001, Hypertable::CommHeader::FLAGS_BIT_IGNORE_RESPONSE = 0x0002, Hypertable::CommHeader::FLAGS_BIT_URGENT = 0x0004, Hypertable::CommHeader::FLAGS_BIT_PROFILE = 0x0008,
  Hypertable::CommHeader::FLAGS_BIT_PROXY_MAP_UPDATE = 0x4000, Hypertable::CommHeader::FLAGS_BIT_PAYLOAD_CHECKSUM = 0x8000
}
 Enumeration constants for bits in flags field. More...
 
enum  Hypertable::CommHeader::FlagMask {
  Hypertable::CommHeader::FLAGS_MASK_REQUEST = 0xFFFE, Hypertable::CommHeader::FLAGS_MASK_IGNORE_RESPONSE = 0xFFFD, Hypertable::CommHeader::FLAGS_MASK_URGENT = 0xFFFB, Hypertable::CommHeader::FLAGS_MASK_PROFILE = 0xFFF7,
  Hypertable::CommHeader::FLAGS_MASK_PROXY_MAP_UPDATE = 0xBFFF, Hypertable::CommHeader::FLAGS_MASK_PAYLOAD_CHECKSUM = 0x7FFF
}
 Enumeration constants for flags field bitmaks. More...
 
enum  Hypertable::ConnectionManager::State { Hypertable::ConnectionManager::State::DISCONNECTED = 0, Hypertable::ConnectionManager::State::CONNECTED, Hypertable::ConnectionManager::State::READY, Hypertable::ConnectionManager::State::DECOMMISSIONED }
 
enum  Hypertable::Event::Type {
  Hypertable::Event::CONNECTION_ESTABLISHED, Hypertable::Event::DISCONNECT, Hypertable::Event::MESSAGE, Hypertable::Event::ERROR,
  Hypertable::Event::TIMER
}
 Enumeration for event types. More...
 
enum  Hypertable::PollEvent::Flags {
  Hypertable::PollEvent::READ = 0x01, Hypertable::PollEvent::PRI = 0x02, Hypertable::PollEvent::WRITE = 0x04, Hypertable::PollEvent::ERROR = 0x08,
  Hypertable::PollEvent::HUP = 0x10, Hypertable::PollEvent::REMOVE = 0x1000, Hypertable::PollEvent::RDHUP = 0x2000
}
 Enumeration for poll interest constants. More...
 
enum  Hypertable::Reactor::Priority { Hypertable::Reactor::Priority::HIGH = 0, Hypertable::Reactor::Priority::NORMAL }
 Enumeration for reactor priority. More...
 

Functions

void Hypertable::Config::init_comm_options ()
 Initializes Comm-layer options. More...
 
void Hypertable::Config::init_comm ()
 This method initializes the Comm-layer. More...
 
void Hypertable::Config::init_generic_server_options ()
 Initializes generic server options. More...
 
void Hypertable::Config::init_generic_server ()
 Initializes generic server by writing the pidfile. More...
 
 Hypertable::RequestCache::CacheNode::CacheNode (uint32_t id, IOHandler *handler, DispatchHandler *dh)
 
 Hypertable::RequestCache::RequestCache ()
 Constructor. More...
 
void Hypertable::RequestCache::insert (uint32_t id, IOHandler *handler, DispatchHandler *dh, ClockT::time_point &expire)
 Inserts pending request callback handler into cache. More...
 
bool Hypertable::RequestCache::remove (uint32_t id, DispatchHandler *&handler)
 Removes a request from the cache. More...
 
bool Hypertable::RequestCache::get_next_timeout (ClockT::time_point &now, IOHandler *&handlerp, DispatchHandler *&dh, ClockT::time_point *next_timeout)
 Removes next request that has timed out. More...
 
void Hypertable::RequestCache::purge_requests (IOHandler *handler, int32_t error)
 Purges all requests assocated with handler. More...
 

Variables

CacheNode * Hypertable::RequestCache::CacheNode::prev
 
CacheNode * Hypertable::RequestCache::CacheNode::next
 Doubly-linked list pointers. More...
 
ClockT::time_point Hypertable::RequestCache::CacheNode::expire
 Absolute expiration time. More...
 
uint32_t Hypertable::RequestCache::CacheNode::id
 Request ID. More...
 
IOHandler * Hypertable::RequestCache::CacheNode::handler
 IOHandler associated with this request. More...
 
DispatchHandler * Hypertable::RequestCache::CacheNode::dh
 Callback handler to which MESSAGE, TIMEOUT, ERROR, and DISCONNECT events are delivered. More...
 
IdHandlerMap Hypertable::RequestCache::m_id_map
 RequestID-to-CacheNode map. More...
 
CacheNode * Hypertable::RequestCache::m_head
 Head of doubly-linked list. More...
 
CacheNode * Hypertable::RequestCache::m_tail {}
 Tail of doubly-linked list. More...
 

Detailed Description

Network communication library.

The AsyncComm module is designed for maximally efficient network programming by 1) providing an asynchronous API to facilitate multiprogramming, and 2) using the most efficient polling mechanism for each supported system (epoll on Linux, kqueue on OSX and FreeBSD, and port_associate on Solaris).

Typedef Documentation

typedef std::shared_ptr<ApplicationQueueInterface> Hypertable::ApplicationQueueInterfacePtr

Smart pointer to ApplicationQueueInterface.

Definition at line 60 of file ApplicationQueueInterface.h.

Shared smart pointer to ApplicationQueue object.

Definition at line 488 of file ApplicationQueue.h.

Clock used for AsyncComm timing needs.

Definition at line 38 of file Clock.h.

typedef std::set<CommAddress> Hypertable::CommAddressSet

Set of CommAddress objects.

Definition at line 212 of file CommAddress.h.

typedef std::shared_ptr<CommBuf> Hypertable::CommBufPtr

Smart pointer to CommBuf.

Definition at line 305 of file CommBuf.h.

typedef std::shared_ptr<ConnectionHandlerFactory> Hypertable::ConnectionHandlerFactoryPtr

Smart pointer to ConnectionHandlerFactory.

Definition at line 53 of file ConnectionHandlerFactory.h.

typedef std::shared_ptr<ConnectionInitializer> Hypertable::ConnectionInitializerPtr

Smart pointer to ConnectionInitializer.

Definition at line 67 of file ConnectionInitializer.h.

typedef std::shared_ptr<ConnectionManager> Hypertable::ConnectionManagerPtr

Smart pointer to ConnectionManager.

Definition at line 410 of file ConnectionManager.h.

typedef Cons<DefaultPolicy, CommPolicy> Hypertable::Config::DefaultCommPolicy

Default comm layer config policy.

Definition at line 84 of file Config.h.

typedef Cons<GenericServerPolicy, DefaultCommPolicy> Hypertable::Config::DefaultServerPolicy

Default comm layer server policy.

Definition at line 87 of file Config.h.

typedef std::shared_ptr<DispatchHandler> Hypertable::DispatchHandlerPtr

Smart pointer to DispatchHandler.

Definition at line 64 of file DispatchHandler.h.

typedef std::shared_ptr<DispatchHandlerSynchronizer> Hypertable::DispatchHandlerSynchronizerPtr

Shared smart pointer to DispatchHandlerSynchronizer.

Definition at line 127 of file DispatchHandlerSynchronizer.h.

typedef std::shared_ptr<Event> Hypertable::EventPtr

Smart pointer to Event.

Definition at line 228 of file Event.h.

typedef std::shared_ptr<HandlerMap> Hypertable::HandlerMapPtr

Smart pointer to HandlerMap.

Definition at line 437 of file HandlerMap.h.

typedef std::unordered_map<uint32_t, CacheNode *> Hypertable::RequestCache::IdHandlerMap
private

RequestID-to-CacheNode map.

Definition at line 68 of file RequestCache.h.

typedef std::unordered_map<String, ProxyAddressInfo> Hypertable::ProxyMapT

Forward mapping hash type from proxy name to ProxyAddressInfo.

Definition at line 57 of file ProxyMap.h.

typedef std::shared_ptr<Reactor> Hypertable::ReactorPtr

Shared smart pointer to Reactor.

Definition at line 295 of file Reactor.h.

Enumeration Type Documentation

Enumeration for address type.

Enumerator
NONE 

Uninitialized.

PROXY 

Proxy name type.

INET 

IPv4:port address type.

Definition at line 57 of file CommAddress.h.

Enumeration constants for flags field bitmaks.

Enumerator
FLAGS_MASK_REQUEST 

Request message bit.

FLAGS_MASK_IGNORE_RESPONSE 

Response should be ignored bit.

FLAGS_MASK_URGENT 

Request is urgent bit.

FLAGS_MASK_PROFILE 

Request should be profiled.

FLAGS_MASK_PROXY_MAP_UPDATE 

ProxyMap update message bit.

FLAGS_MASK_PAYLOAD_CHECKSUM 

Payload checksumming is enabled bit.

Definition at line 61 of file CommHeader.h.

Enumeration for poll interest constants.

Enumerator
READ 

Data available to read.

PRI 

Urgent data available to read.

WRITE 

Writing can be performed without blocking.

ERROR 

Error condition

HUP 

Hang up.

REMOVE 
RDHUP 

Stream socket peer closed connection.

Definition at line 40 of file PollEvent.h.

Enumeration constants for bits in flags field.

Enumerator
FLAGS_BIT_REQUEST 

Request message.

FLAGS_BIT_IGNORE_RESPONSE 

Response should be ignored.

FLAGS_BIT_URGENT 

Request is urgent.

FLAGS_BIT_PROFILE 

Request should be profiled.

FLAGS_BIT_PROXY_MAP_UPDATE 

ProxyMap update message.

FLAGS_BIT_PAYLOAD_CHECKSUM 

Payload checksumming is enabled.

Definition at line 50 of file CommHeader.h.

Enumeration for reactor priority.

Enumerator
HIGH 
NORMAL 

Definition at line 73 of file Reactor.h.

Enumerator
DISCONNECTED 
CONNECTED 
READY 
DECOMMISSIONED 

Definition at line 62 of file ConnectionManager.h.

Enumeration for event types.

Enumerator
CONNECTION_ESTABLISHED 

Connection established event.

DISCONNECT 

Connection disconnected event.

MESSAGE 

Request/response message event.

ERROR 

Error event

TIMER 

Timer event

Definition at line 60 of file Event.h.

Function Documentation

Hypertable::RequestCache::CacheNode::CacheNode ( uint32_t  id,
IOHandler handler,
DispatchHandler dh 
)
inline

Definition at line 56 of file RequestCache.h.

bool RequestCache::get_next_timeout ( ClockT::time_point now,
IOHandler *&  handlerp,
DispatchHandler *&  dh,
ClockT::time_point next_timeout 
)

Removes next request that has timed out.

This method finds the first request starting from the head of the list and removes it and returns it's associated handler information if it has timed out. During the search, it physically removes any cache nodes corresponding to requests that have been purged.

Parameters
nowCurrent time
handlerpReturn parameter to hold pointer to associated IOHandler of timed out request
dhRemoved dispatch handler
next_timeoutPointer to variable to hold expiration time of next request after timed out request, set to 0 if cache is empty
Returns
true if pointer to timed out dispatch handler was removed, false otherwise

Definition at line 103 of file RequestCache.cc.

void Hypertable::Config::init_comm ( )

This method initializes the Comm-layer.

It determines the reactor count from the reactors property, if specified, otherwise sets the reactor count to the number of CPU cores as returned by System::get_processor_count(). It then calls ReactorFactory::initialize.

Definition at line 44 of file Config.cc.

void Hypertable::Config::init_comm_options ( )

Initializes Comm-layer options.

This method adds the following options:

  • workers
  • reactors
  • timeout (aliased to Hypertable.Request.Timeout)

Definition at line 36 of file Config.cc.

void Hypertable::Config::init_generic_server ( )

Initializes generic server by writing the pidfile.

Definition at line 65 of file Config.cc.

void Hypertable::Config::init_generic_server_options ( )

Initializes generic server options.

This method adds the following options:

  • port
  • pidfile

Definition at line 58 of file Config.cc.

void RequestCache::insert ( uint32_t  id,
IOHandler handler,
DispatchHandler dh,
ClockT::time_point expire 
)

Inserts pending request callback handler into cache.

Parameters
idRequest ID
handlerIOHandler associated with
dhCallback handler to which MESSAGE, TIMEOUT, DISCONNECT events are delivered
expireAbsolute expiration time of request

Definition at line 43 of file RequestCache.cc.

void RequestCache::purge_requests ( IOHandler handler,
int32_t  error 
)

Purges all requests assocated with handler.

This method walks the entire cache and purges all requests whose handler is equal to handler. For each purged request, an ERROR event with error code error is delivered via the request's dispatch handler.

Parameters
handlerIOHandler of requests to purge
errorError code to be delivered with ERROR event

Definition at line 140 of file RequestCache.cc.

bool RequestCache::remove ( uint32_t  id,
DispatchHandler *&  handler 
)

Removes a request from the cache.

Parameters
idRequest ID
handlerRemoved dispatch handler
Returns
true if removed, false if not found

Definition at line 70 of file RequestCache.cc.

Hypertable::RequestCache::RequestCache ( )
inline

Constructor.

Definition at line 73 of file RequestCache.h.

Variable Documentation

DispatchHandler* Hypertable::RequestCache::CacheNode::dh

Callback handler to which MESSAGE, TIMEOUT, ERROR, and DISCONNECT events are delivered.

Definition at line 64 of file RequestCache.h.

ClockT::time_point Hypertable::RequestCache::CacheNode::expire

Absolute expiration time.

Definition at line 59 of file RequestCache.h.

IOHandler* Hypertable::RequestCache::CacheNode::handler

IOHandler associated with this request.

Definition at line 61 of file RequestCache.h.

uint32_t Hypertable::RequestCache::CacheNode::id

Request ID.

Definition at line 60 of file RequestCache.h.

CacheNode* Hypertable::RequestCache::m_head
private

Head of doubly-linked list.

Definition at line 122 of file RequestCache.h.

IdHandlerMap Hypertable::RequestCache::m_id_map
private

RequestID-to-CacheNode map.

Definition at line 121 of file RequestCache.h.

CacheNode* Hypertable::RequestCache::m_tail {}
private

Tail of doubly-linked list.

Definition at line 123 of file RequestCache.h.

CacheNode * Hypertable::RequestCache::CacheNode::next

Doubly-linked list pointers.

Definition at line 58 of file RequestCache.h.

CacheNode* Hypertable::RequestCache::CacheNode::prev

Definition at line 58 of file RequestCache.h.