11 namespace madara {
namespace transport {
39 for (
size_t i = 1; i <
addresses_.size (); ++i)
42 "UdpRegistryClient::setup:" \
43 " adding server %s:%d to registry lookup list\n",
44 addresses_[i].address ().to_string ().c_str (),
59 const char * print_prefix =
"UdpRegistryClient::register";
62 uint64_t bytes_sent = 0;
70 strncpy (header.
domain, this->settings_.write_domain.c_str (),
71 sizeof (header.
domain) - 1);
87 " Sending register of size %d to %s:%d\n",
88 print_prefix, (int)result,
89 server.address ().to_string ().c_str (),
96 bytes_sent += actual_sent;
100 " Sent register of size %d to %s\n",
101 print_prefix, (int)actual_sent,
102 server.address ().to_string ().c_str (), server.port ());
112 " ERROR: no servers available for sending. Failed to register.\n");
124 std::vector <std::string>
hosts;
128 for (
auto &host : hosts)
131 auto addr = ip::address::from_string (addr_parts.first);
132 addresses_.emplace_back (addr, addr_parts.second);
135 "UdpRegistryClient::send_data:" \
137 addresses_.back ().address ().to_string ().c_str (),
knowledge::KnowledgeBase knowledge_
knowledge base for threads to use
QoSTransportSettings settings_
int setup(void) override
all subclasses should call this method at the end of its setup
std::pair< std::string, uint16_t > parse_address(std::string addr)
knowledge::containers::Map endpoints_
int validate_transport(void)
Validates a transport to indicate it is not shutting down.
std::vector< udp::endpoint > servers_
registry servers
void keys(std::vector< std::string > &curkeys) const
Returns the keys within the map.
This class stores variables and their values for use by any entity needing state information in a thr...
std::vector< std::string > sync_keys(void)
Syncs the keys from the knowledge base.
long send_buffer(const udp::endpoint &target, const char *buf, size_t size)
Holds basic transport settings.
#define madara_logger_log(logger, level,...)
Fast version of the madara::logger::log method.
T * get_ptr(void)
get the underlying pointer
std::string write_domain
All class members are accessible to users for easy setup.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, bool sync=true)
Sets the variable name that this refers to.
bool no_sending
if true, never send over transport
void add(uint64_t size)
Adds a message to the monitor.
void send_register(void)
Sends register messages to all servers.
std::vector< udp::endpoint > addresses_
holds all multicast addresses we are sending to
long send_data(const madara::knowledge::VariableReferenceMap &updates) override
Sends a list of knowledge updates to listeners.
std::map< const char *, VariableReference, VariableReferenceMapCompare > VariableReferenceMap
a map of variable references
uint32_t queue_length
Length of the buffer used to store history of events.
UdpRegistryClient(const std::string &id, madara::knowledge::ThreadSafeContext &context, TransportSettings &config, bool launch_transport)
Constructor.
int setup() override
all subclasses should call this method at the end of its setup
uint64_t get_clock(void) const
Atomically gets the Lamport clock.
Copyright (c) 2015 Carnegie Mellon University.
madara::utility::ScopedArray< char > buffer_
buffer for sending
logger::Logger & get_logger(void) const
Gets the logger used for information printing.
UDP-based transport for knowledge.
long send_data(const madara::knowledge::VariableReferenceMap &updates) override
Sends a list of knowledge updates to listeners.
BandwidthMonitor send_monitor_
monitor for sending bandwidth usage
madara::knowledge::ThreadSafeContext & context_