MADARA  3.1.8
UdpRegistryClientReadThread.h
Go to the documentation of this file.
1 #ifndef _MADARA_UDP_REGISTRY_CLIENT_READ_THREAD_H_
2 #define _MADARA_UDP_REGISTRY_CLIENT_READ_THREAD_H_
3 
4 #include <string>
5 
14 
15 #include "ace/Task.h"
16 #include "ace/Mutex.h"
17 #include "ace/Barrier.h"
18 #include "ace/Atomic_Op_T.h"
19 #include "ace/Thread_Mutex.h"
20 
21 #include "ace/Synch.h"
22 #include "ace/INET_Addr.h"
23 #include "ace/SOCK_Dgram.h"
24 
25 namespace madara
26 {
27  namespace transport
28  {
35  {
36  public:
50  const TransportSettings & settings,
51  const std::string & id,
52  std::map <std::string, ACE_INET_Addr> & addresses,
53  ACE_SOCK_Dgram & socket,
54  BandwidthMonitor & send_monitor,
55  BandwidthMonitor & receive_monitor,
56  PacketScheduler & packet_scheduler);
57 
63 
67  void cleanup (void);
68 
72  void run (void);
73 
82  void rebroadcast (
83  const char * print_prefix,
84  MessageHeader * header,
85  const knowledge::KnowledgeMap & records);
86 
87  private:
90 
93 
96 
98  std::map <std::string, ACE_INET_Addr> addresses_;
99 
101  ACE_SOCK_Dgram & socket_;
102 
103 #ifndef _MADARA_NO_KARL_
106 #endif // _MADARA_NO_KARL_
107 
110 
113 
116 
119  };
120  }
121 }
122 
123 #endif // _MADARA_UDP_REGISTRY_CLIENT_READ_THREAD_H_
Thread for reading knowledge and registry updates through a UDP socket.
knowledge::ThreadSafeContext * context_
knowledge context
PacketScheduler & packet_scheduler_
scheduler for mimicking target network conditions
madara::utility::ScopedArray< char > buffer_
buffer for sending
UdpRegistryClientReadThread(const TransportSettings &settings, const std::string &id, std::map< std::string, ACE_INET_Addr > &addresses, ACE_SOCK_Dgram &socket, BandwidthMonitor &send_monitor, BandwidthMonitor &receive_monitor, PacketScheduler &packet_scheduler)
Constructor.
void init(knowledge::KnowledgeBase &knowledge)
Initializes MADARA context-related items.
std::map< std::string, ACE_INET_Addr > addresses_
internet addresses of our peers
void run(void)
The main loop internals for the read thread.
void rebroadcast(const char *print_prefix, MessageHeader *header, const knowledge::KnowledgeMap &records)
Sends a rebroadcast packet to all peers.
This class stores variables and their values for use by any entity needing state information in a thr...
Provides scheduler for dropping packets.
Holds basic transport settings.
Compiled, optimized KaRL logic.
const QoSTransportSettings settings_
Transport settings.
madara::knowledge::CompiledExpression on_data_received_
data received rules, defined in Transport settings
Abstract base class for implementing threads.
Definition: BaseThread.h:38
void cleanup(void)
Cleanup function called by thread manager.
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:44
::std::map< std::string, KnowledgeRecord > KnowledgeMap
static constexpr struct madara::knowledge::tags::string_t string
ACE_SOCK_Dgram & socket_
The socket we are writing to and reading from.
Container for quality-of-service settings.
const std::string id_
host:port identifier of this process
Provides monitoring capability of a transport&#39;s bandwidth.
Provides functions and classes for the distributed knowledge base.
Copyright (c) 2015 Carnegie Mellon University.
BandwidthMonitor & send_monitor_
monitor for sending bandwidth usage
Defines a robust message header which is the default for KaRL messages.
Definition: MessageHeader.h:56
BandwidthMonitor & receive_monitor_
monitor for receiving bandwidth usage