MADARA  3.1.8
MulticastTransportReadThread.h
Go to the documentation of this file.
1 #ifndef _MADARA_MULTICAST_TRANSPORT_READ_THREAD_H_
2 #define _MADARA_MULTICAST_TRANSPORT_READ_THREAD_H_
3 
12 #include <string>
13 
22 
23 #include "ace/Task.h"
24 #include "ace/Mutex.h"
25 #include "ace/Barrier.h"
26 #include "ace/Atomic_Op_T.h"
27 #include "ace/Thread_Mutex.h"
28 #include "ace/SOCK_Dgram_Mcast.h"
29 
30 #include "ace/Synch.h"
31 
32 namespace madara
33 {
34  namespace transport
35  {
42  {
43  public:
58  const TransportSettings & settings,
59  const std::string & id,
60  const ACE_INET_Addr & address,
61  ACE_SOCK_Dgram & write_socket,
62  ACE_SOCK_Dgram_Mcast & read_socket,
63  BandwidthMonitor & send_monitor,
64  BandwidthMonitor & receive_monitor,
65  PacketScheduler & packet_scheduler);
66 
72 
76  void cleanup (void);
77 
81  void run (void);
82 
91  void rebroadcast (
92  const char * print_prefix,
93  MessageHeader * header,
94  const knowledge::KnowledgeMap& records);
95 
96  private:
99 
102 
105 
107  ACE_INET_Addr address_;
108 
110  ACE_SOCK_Dgram_Mcast & read_socket_;
111 
113  ACE_SOCK_Dgram & write_socket_;
114 
115 #ifndef _MADARA_NO_KARL_
118 #endif // _MADARA_NO_KARL_
119 
122 
125 
128 
131  };
132  }
133 }
134 
135 #endif // _MADARA_MULTICAST_TRANSPORT_READ_THREAD_H_
MulticastTransportReadThread(const TransportSettings &settings, const std::string &id, const ACE_INET_Addr &address, ACE_SOCK_Dgram &write_socket, ACE_SOCK_Dgram_Mcast &read_socket, BandwidthMonitor &send_monitor, BandwidthMonitor &receive_monitor, PacketScheduler &packet_scheduler)
Constructor.
PacketScheduler & packet_scheduler_
scheduler for mimicking target network conditions
void run(void)
The main loop internals for the read thread.
This class stores variables and their values for use by any entity needing state information in a thr...
Provides scheduler for dropping packets.
const std::string id_
host:port identifier of this process
Thread for reading knowledge updates through a Multicast datagram socket.
knowledge::ThreadSafeContext * context_
knowledge context
void init(knowledge::KnowledgeBase &knowledge)
Initializes MADARA context-related items.
Holds basic transport settings.
Compiled, optimized KaRL logic.
ACE_SOCK_Dgram & write_socket_
underlying socket for sending
Abstract base class for implementing threads.
Definition: BaseThread.h:38
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:44
BandwidthMonitor & receive_monitor_
monitor for receiving bandwidth usage
::std::map< std::string, KnowledgeRecord > KnowledgeMap
madara::knowledge::CompiledExpression on_data_received_
data received rules, defined in Transport settings
static constexpr struct madara::knowledge::tags::string_t string
Container for quality-of-service settings.
void rebroadcast(const char *print_prefix, MessageHeader *header, const knowledge::KnowledgeMap &records)
Sends a rebroadcast packet.
Provides monitoring capability of a transport&#39;s bandwidth.
const QoSTransportSettings settings_
quality-of-service transport settings
Provides functions and classes for the distributed knowledge base.
ACE_SOCK_Dgram_Mcast & read_socket_
The multicast socket we are reading from.
BandwidthMonitor & send_monitor_
monitor for sending bandwidth usage
Copyright (c) 2015 Carnegie Mellon University.
void cleanup(void)
Cleanup function called by thread manager.
Defines a robust message header which is the default for KaRL messages.
Definition: MessageHeader.h:56
ACE_INET_Addr address_
The multicast address we are subscribing to.
madara::utility::ScopedArray< char > buffer_
buffer for receiving