Zero Module Framework
1.0
A framework for running distributed modules using a ZMQ message bus
|
Service class to recognize other modules and there states in the network. More...
#include <PeerDiscoveryService.hpp>
Public Member Functions | |
PeerDiscoveryService (zmf::data::ModuleUniqueId instanceId) | |
~PeerDiscoveryService () | |
bool | start (std::shared_ptr< config::IConfigurationProvider > config, IPeerDiscoveryCoreInterface *const core, std::shared_ptr< zmf::data::ModuleHandle > selfHandle, uint32_t multicastFrequency, uint16_t udpPort, bool peerDiscoveryWait, bool disableEqualModuleInterconnect) |
void | stop () |
void | sendStateMulticast () |
virtual const std::shared_ptr < zmf::discovery::PeerRegistry > & | getPeerRegistry () |
virtual void | updateSelfState (zmf::data::ModuleState state) |
virtual void | updateSelfAdditionalState (std::vector< uint8_t > additionalState) |
Service class to recognize other modules and there states in the network.
The PeerDiscoveryService Class regularly sends out udp-multicasts to the network and receives those of other module instances. In doing so it recognizes other modules with their current lifecycleState and adds them to the PeerRegistryClass, where all known module instances are listed and updated. At the same time the service lets all other instances know of the current state of its own module so that they can update their registries in the same way. The PeerDiscoveryService is a main component of the ZMF-framework and thus started and stopped with the ZMF-instance.
zmf::discovery::PeerDiscoveryService::PeerDiscoveryService | ( | zmf::data::ModuleUniqueId | instanceId | ) |
Constructor initializes Poco::Logger and all flags with false
instanceId | the uniqueId of the own module |
zmf::discovery::PeerDiscoveryService::~PeerDiscoveryService | ( | ) |
Destructor stops the service if necessary and makes sure that both threads terminated execution
|
inlinevirtual |
Returns the current peer registry with all actual know modules
Implements zmf::discovery::IPeerDiscoveryService.
|
virtual |
sends out a udp-multicast to the network with the current state of the own module
Implements zmf::discovery::IPeerDiscoveryService.
|
virtual |
Starts the peer discovery service: State multicasting, peer discovery and module registry
core | Reference to the ZMF core |
selfHandle | Module handle for the module of this instance. Contains information about module and its state |
multicastFrequency | Frequency to send out state multicasts (in milliseconds between multicasts) |
udpPort | UDP port for state multicast communication |
peerDiscoveryWait | If true the service will wait until all active modules discovered before it returns from the starting process |
source-address for receiving UDP-packets
destination-address for sending multicasts
preparing the UDP-Socket for multicasts
Implements zmf::discovery::IPeerDiscoveryService.
|
virtual |
Stops the peer discovery service
Implements zmf::discovery::IPeerDiscoveryService.
|
virtual |
Called when there is a change in the additional state of own module, updates the selfAdditionalState_ variable
additionalState | The new additional state that the own module should be set to |
Implements zmf::discovery::IPeerDiscoveryService.
|
virtual |
Called when there is a change in the lifecycle-state of the own module, updates the selfState_ variable
state | The new lifecycle-state that the own module has now |
Implements zmf::discovery::IPeerDiscoveryService.