MADARA  3.1.8
madara::transport::UdpRegistryServer Class Reference

UDP-based server that handles a registry of UDP endpoints, which makes it ideal for any NAT-protected agents. More...

#include <UdpRegistryServer.h>

Inheritance diagram for madara::transport::UdpRegistryServer:
Collaboration diagram for madara::transport::UdpRegistryServer:

Public Types

enum  { RELIABLE = 0 }
 
enum  { ERROR_UDP_NOT_STARTED = -1 }
 
typedef std::vector< std::string > HostsVector
 Used to define a vector of hosts to contact. More...
 

Public Member Functions

 UdpRegistryServer (const std::string &id, madara::knowledge::ThreadSafeContext &context, TransportSettings &config, bool launch_transport)
 Constructor. More...
 
virtual ~UdpRegistryServer ()
 Destructor. More...
 
int check_transport (void)
 all subclasses should call this method at the beginning of send_data More...
 
void close (void)
 Closes this transport. More...
 
void invalidate_transport (void)
 Invalidates a transport to indicate it is shutting down. More...
 
long prep_send (const madara::knowledge::KnowledgeRecords &orig_updates, const char *print_prefix)
 Preps a message for sending. More...
 
long read (void)
 
int reliability (void) const
 Accesses reliability setting. More...
 
int reliability (const int &setting)
 Accesses reliability setting. More...
 
long send_data (const madara::knowledge::KnowledgeRecords &updates)
 Sends a list of knowledge updates to listeners. More...
 
TransportSettingssettings (void)
 Getter for the transport settings. More...
 
int setup (void)
 all subclasses should call this method at the end of its setup More...
 
int validate_transport (void)
 Validates a transport to indicate it is not shutting down. More...
 

Static Public Attributes

static const int PROFILES = 1
 

Protected Attributes

madara::utility::ScopedArray< char > buffer_
 buffer for sending More...
 
madara::knowledge::ThreadSafeContextcontext_
 
HostsVector hosts
 
const std::string id_
 host:port identifier of this process More...
 
volatile bool is_valid_
 
ACE_Thread_Mutex mutex_
 
madara::expression::ExpressionTree on_data_received_
 data received rules, defined in Transport settings More...
 
PacketScheduler packet_scheduler_
 scheduler for dropping packets to simulate network issues More...
 
BandwidthMonitor receive_monitor_
 monitor for receiving bandwidth usage More...
 
BandwidthMonitor send_monitor_
 monitor for sending bandwidth usage More...
 
QoSTransportSettings settings_
 
volatile bool shutting_down_
 
Condition valid_setup_
 

Private Attributes

std::map< std::string, ACE_INET_Addr > clients_
 registry clients More...
 
knowledge::containers::Map endpoints_
 
knowledge::KnowledgeBase knowledge_
 knowledge base for threads to use More...
 
ACE_SOCK_Dgram read_socket_
 The socket we are reading from. More...
 
threads::Threader read_threads_
 threads for reading knowledge updates More...
 
std::map< std::string, ACE_INET_Addr > servers_
 registry servers More...
 
ACE_SOCK_Dgram write_socket_
 underlying socket for sending More...
 

Detailed Description

UDP-based server that handles a registry of UDP endpoints, which makes it ideal for any NAT-protected agents.

Definition at line 28 of file UdpRegistryServer.h.

Member Typedef Documentation

typedef std::vector<std::string> madara::transport::Base::HostsVector
inherited

Used to define a vector of hosts to contact.

Definition at line 68 of file Transport.h.

Member Enumeration Documentation

anonymous enum
Enumerator
RELIABLE 

Definition at line 32 of file UdpRegistryServer.h.

anonymous enum
Enumerator
ERROR_UDP_NOT_STARTED 

Definition at line 36 of file UdpRegistryServer.h.

Constructor & Destructor Documentation

madara::transport::UdpRegistryServer::UdpRegistryServer ( const std::string &  id,
madara::knowledge::ThreadSafeContext context,
TransportSettings config,
bool  launch_transport 
)

Constructor.

Parameters
idunique identifer - usually a combination of host:port
contextknowledge context
configtransport configuration settings
launch_transportwhether or not to launch this transport

Definition at line 14 of file UdpRegistryServer.cpp.

madara::transport::UdpRegistryServer::~UdpRegistryServer ( )
virtual

Destructor.

Definition at line 31 of file UdpRegistryServer.cpp.

Member Function Documentation

int madara::transport::Base::check_transport ( void  )
inlineinherited

all subclasses should call this method at the beginning of send_data

Definition at line 19 of file Transport.inl.

void madara::transport::UdpRegistryServer::close ( void  )
virtual

Closes this transport.

Reimplemented from madara::transport::Base.

Definition at line 37 of file UdpRegistryServer.cpp.

void madara::transport::Base::invalidate_transport ( void  )
inlineinherited

Invalidates a transport to indicate it is shutting down.

Definition at line 34 of file Transport.inl.

long madara::transport::Base::prep_send ( const madara::knowledge::KnowledgeRecords orig_updates,
const char *  print_prefix 
)
inherited

Preps a message for sending.

Parameters
orig_updatesupdates before send filtering is applied
print_prefixprefix to include before every log message, e.g., "MyTransport::svc"
Returns
-1 Transport is shutting down
-2 Transport is invalid
-3 Unable to allocate send buffer
0 No message to send > 0 size of buffered message

filter the updates according to the filters specified by the user in QoSTransportSettings (if applicable)

size = buffer[0] (unsigned 64 bit) transport id = buffer[8] (8 byte) domain = buffer[16] (32 byte domain name) originator = buffer[48] (64 byte originator host:port) type = buffer[112] (unsigned 32 bit type of message–usually MULTIASSIGN) updates = buffer[116] (unsigned 32 bit number of updates) quality = buffer[120] (unsigned 32 bit quality of message) clock = buffer[124] (unsigned 64 bit clock for this message) ttl = buffer[132] (the new knowledge starts here) knowledge = buffer[133] (the new knowledge starts here)

Definition at line 815 of file Transport.cpp.

long madara::transport::UdpRegistryServer::read ( void  )
int madara::transport::UdpRegistryServer::reliability ( void  ) const

Accesses reliability setting.

If this returns zero, it doesn't make much sense.

Returns
whether we are using reliable dissemination or not

Definition at line 63 of file UdpRegistryServer.cpp.

int madara::transport::UdpRegistryServer::reliability ( const int &  setting)

Accesses reliability setting.

If this returns zero, it doesn't make much sense.

Returns
whether we are using reliable dissemination or not

Definition at line 69 of file UdpRegistryServer.cpp.

long madara::transport::UdpRegistryServer::send_data ( const madara::knowledge::KnowledgeRecords updates)
virtual

Sends a list of knowledge updates to listeners.

Parameters
updateslisting of all updates that must be sent
Returns
result of write operation or -1 if we are shutting down

Implements madara::transport::Base.

Definition at line 260 of file UdpRegistryServer.cpp.

madara::transport::TransportSettings & madara::transport::Base::settings ( void  )
inlineinherited

Getter for the transport settings.

Returns
the current transport settings

Definition at line 45 of file Transport.inl.

int madara::transport::UdpRegistryServer::setup ( void  )
virtual

all subclasses should call this method at the end of its setup

Reimplemented from madara::transport::Base.

Definition at line 75 of file UdpRegistryServer.cpp.

int madara::transport::Base::validate_transport ( void  )
inlineinherited

Validates a transport to indicate it is not shutting down.

Definition at line 6 of file Transport.inl.

Member Data Documentation

madara::utility::ScopedArray<char> madara::transport::Base::buffer_
protectedinherited

buffer for sending

Definition at line 209 of file Transport.h.

std::map<std::string, ACE_INET_Addr> madara::transport::UdpRegistryServer::clients_
private

registry clients

Definition at line 93 of file UdpRegistryServer.h.

madara::knowledge::ThreadSafeContext& madara::transport::Base::context_
protectedinherited

Definition at line 191 of file Transport.h.

knowledge::containers::Map madara::transport::UdpRegistryServer::endpoints_
private

Definition at line 95 of file UdpRegistryServer.h.

HostsVector madara::transport::Base::hosts
protectedinherited

Definition at line 181 of file Transport.h.

const std::string madara::transport::Base::id_
protectedinherited

host:port identifier of this process

Definition at line 186 of file Transport.h.

volatile bool madara::transport::Base::is_valid_
protectedinherited

Definition at line 179 of file Transport.h.

knowledge::KnowledgeBase madara::transport::UdpRegistryServer::knowledge_
private

knowledge base for threads to use

Definition at line 84 of file UdpRegistryServer.h.

ACE_Thread_Mutex madara::transport::Base::mutex_
protectedinherited

Definition at line 182 of file Transport.h.

madara::expression::ExpressionTree madara::transport::Base::on_data_received_
protectedinherited

data received rules, defined in Transport settings

Definition at line 195 of file Transport.h.

PacketScheduler madara::transport::Base::packet_scheduler_
protectedinherited

scheduler for dropping packets to simulate network issues

Definition at line 206 of file Transport.h.

const int madara::transport::UdpRegistryServer::PROFILES = 1
static

Definition at line 40 of file UdpRegistryServer.h.

ACE_SOCK_Dgram madara::transport::UdpRegistryServer::read_socket_
private

The socket we are reading from.

Definition at line 101 of file UdpRegistryServer.h.

threads::Threader madara::transport::UdpRegistryServer::read_threads_
private

threads for reading knowledge updates

Definition at line 87 of file UdpRegistryServer.h.

BandwidthMonitor madara::transport::Base::receive_monitor_
protectedinherited

monitor for receiving bandwidth usage

Definition at line 203 of file Transport.h.

BandwidthMonitor madara::transport::Base::send_monitor_
protectedinherited

monitor for sending bandwidth usage

Definition at line 200 of file Transport.h.

std::map<std::string, ACE_INET_Addr> madara::transport::UdpRegistryServer::servers_
private

registry servers

Definition at line 90 of file UdpRegistryServer.h.

QoSTransportSettings madara::transport::Base::settings_
protectedinherited

Definition at line 188 of file Transport.h.

volatile bool madara::transport::Base::shutting_down_
protectedinherited

Definition at line 180 of file Transport.h.

Condition madara::transport::Base::valid_setup_
protectedinherited

Definition at line 183 of file Transport.h.

ACE_SOCK_Dgram madara::transport::UdpRegistryServer::write_socket_
private

underlying socket for sending

Definition at line 98 of file UdpRegistryServer.h.


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