RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Datacratic::ActiveEndpoint Struct Reference

#include <active_endpoint.h>

Inheritance diagram for Datacratic::ActiveEndpoint:
Datacratic::EndpointBase Datacratic::Epoller Datacratic::AsyncEventSource Datacratic::ActiveEndpointT< SocketTransport > Datacratic::ActiveEndpointT< Transport > Datacratic::RemoteOutput

List of all members.

Classes

struct  ConnectManager

Public Types

typedef boost::function< void(const
std::shared_ptr< TransportBase > &)> 
OnNewConnection
typedef boost::function< void(std::string)> OnConnectionError

Public Member Functions

 ActiveEndpoint (const std::string &name)
int init (int port, const std::string &hostname, int connections=0, int threads=1, bool synchronous=true, bool throwIfAnyConnectionError=true, OnConnectionError onEachConnectionError=doNothingOnConnectionError, double timeout=1.0)
int createConnections (int num_connections, bool synchronous, bool throwIfAnyConnectionError, OnConnectionError onEachConnectionError, double timeout=1.0)
virtual void newConnection (OnNewConnection onNewConnection, OnConnectionError onConnectionError, double timeout=1.0)
virtual void getConnection (OnNewConnection onNewConnection, OnConnectionError onConnectionError, double timeout)
virtual int doConnect (const std::shared_ptr< TransportBase > &transport, const ACE_INET_Addr &addr, double timeout, bool block)
virtual std::shared_ptr
< TransportBase
makeNewTransport ()
virtual void closePeer ()
virtual std::string hostname () const
virtual int port () const
int numActiveConnections () const
int numInactiveConnections () const
virtual void dumpState () const
void shutdown ()

Static Public Member Functions

static void throwExceptionOnConnectionError (const std::string &error)
static void doNothingOnConnectionError (const std::string &error)

Protected Member Functions

virtual void notifyNewTransport (const std::shared_ptr< TransportBase > &transport)
virtual void notifyTransportOpen (const std::shared_ptr< TransportBase > &transport)
virtual void notifyCloseTransport (const std::shared_ptr< TransportBase > &transport)
virtual void notifyRecycleTransport (const std::shared_ptr< TransportBase > &transport)

Protected Attributes

Connections active
Connections inactive
int port_
std::string hostname_
ACE_INET_Addr addr
std::shared_ptr< Connectorconnector

Detailed Description

An endpoint that actively creates a given type of connection.

Definition at line 44 of file active_endpoint.h.


Member Function Documentation

int Datacratic::ActiveEndpoint::createConnections ( int  num_connections,
bool  synchronous,
bool  throwIfAnyConnectionError,
OnConnectionError  onEachConnectionError,
double  timeout = 1.0 
)

Pre-seed with the given number of connections in the connection pool.

Definition at line 63 of file active_endpoint.cc.

virtual int Datacratic::ActiveEndpoint::doConnect ( const std::shared_ptr< TransportBase > &  transport,
const ACE_INET_Addr &  addr,
double  timeout,
bool  block 
) [inline, virtual]

Method to cause the connection to actually happen.

Definition at line 113 of file active_endpoint.h.

void Datacratic::ActiveEndpoint::doNothingOnConnectionError ( const std::string &  error) [static]

Do nothing on a connection error.

Definition at line 30 of file active_endpoint.cc.

void Datacratic::ActiveEndpoint::dumpState ( ) const [virtual]

Dump the state of the endpoint for debugging.

Reimplemented from Datacratic::EndpointBase.

Definition at line 267 of file active_endpoint.cc.

void Datacratic::ActiveEndpoint::getConnection ( OnNewConnection  onNewConnection,
OnConnectionError  onConnectionError,
double  timeout 
) [virtual]

Return a connection, either from the pool or by creating a new connection.

Definition at line 135 of file active_endpoint.cc.

virtual std::string Datacratic::ActiveEndpoint::hostname ( ) const [inline, virtual]

What host are we connected to?

Implements Datacratic::EndpointBase.

Definition at line 132 of file active_endpoint.h.

int Datacratic::ActiveEndpoint::init ( int  port,
const std::string &  hostname,
int  connections = 0,
int  threads = 1,
bool  synchronous = true,
bool  throwIfAnyConnectionError = true,
OnConnectionError  onEachConnectionError = doNothingOnConnectionError,
double  timeout = 1.0 
)

Initialize the endpoint. This will pre-create the given number of connections to the given hostname:port and the given number of threads to service them.

Returns the number of connections that were created.

Definition at line 36 of file active_endpoint.cc.

virtual void Datacratic::ActiveEndpoint::newConnection ( OnNewConnection  onNewConnection,
OnConnectionError  onConnectionError,
double  timeout = 1.0 
) [inline, virtual]

Create a new connection.

Definition at line 92 of file active_endpoint.h.

void Datacratic::ActiveEndpoint::notifyCloseTransport ( const std::shared_ptr< TransportBase > &  transport) [protected, virtual]

Tell the endpoint that a connection has been closed. Removes it from the active/inactive connections.

Reimplemented from Datacratic::EndpointBase.

Reimplemented in Datacratic::RemoteOutput.

Definition at line 231 of file active_endpoint.cc.

void Datacratic::ActiveEndpoint::notifyNewTransport ( const std::shared_ptr< TransportBase > &  transport) [protected, virtual]

Tell the endpoint that a new transport has been created.

Reimplemented from Datacratic::EndpointBase.

Definition at line 200 of file active_endpoint.cc.

void Datacratic::ActiveEndpoint::notifyRecycleTransport ( const std::shared_ptr< TransportBase > &  transport) [protected, virtual]

Tell the endpoint that a connection has been recycled. Moves it from active to inactive.

Reimplemented from Datacratic::EndpointBase.

Definition at line 247 of file active_endpoint.cc.

void Datacratic::ActiveEndpoint::notifyTransportOpen ( const std::shared_ptr< TransportBase > &  transport) [protected, virtual]

Tell the endpoint that a connection has been opened.

Definition at line 207 of file active_endpoint.cc.

virtual int Datacratic::ActiveEndpoint::port ( ) const [inline, virtual]

What port are we listening on?

Implements Datacratic::EndpointBase.

Definition at line 138 of file active_endpoint.h.

Shutdown everything in the bid manager. Opposite of init(). Will implicitly call notifyFinished() and wait for all threads to exit before returning.

Reimplemented from Datacratic::EndpointBase.

Reimplemented in Datacratic::RemoteOutput.

Definition at line 191 of file active_endpoint.cc.

void Datacratic::ActiveEndpoint::throwExceptionOnConnectionError ( const std::string &  error) [static]

Default function that will throw an exception on a connection error.

Definition at line 23 of file active_endpoint.cc.


The documentation for this struct was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator