Zero Module Framework  1.0
A framework for running distributed modules using a ZMQ message bus
 All Classes Namespaces Files Functions Variables Friends Macros
zmf::discovery::PeerDiscoveryService Class Reference

Service class to recognize other modules and there states in the network. More...

#include <PeerDiscoveryService.hpp>

Inheritance diagram for zmf::discovery::PeerDiscoveryService:
zmf::discovery::IPeerDiscoveryService

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)
 

Detailed Description

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.

Author
Matthias Blohm
Jonas Grunert
Jan Strauss
Date
created on 6/25/15.

Constructor & Destructor Documentation

zmf::discovery::PeerDiscoveryService::PeerDiscoveryService ( zmf::data::ModuleUniqueId  instanceId)

Constructor initializes Poco::Logger and all flags with false

Parameters
instanceIdthe uniqueId of the own module
zmf::discovery::PeerDiscoveryService::~PeerDiscoveryService ( )

Destructor stops the service if necessary and makes sure that both threads terminated execution

Member Function Documentation

virtual const std::shared_ptr<zmf::discovery::PeerRegistry>& zmf::discovery::PeerDiscoveryService::getPeerRegistry ( )
inlinevirtual

Returns the current peer registry with all actual know modules

Returns
Peer registry where all known peers are registered

Implements zmf::discovery::IPeerDiscoveryService.

void zmf::discovery::PeerDiscoveryService::sendStateMulticast ( )
virtual

sends out a udp-multicast to the network with the current state of the own module

Implements zmf::discovery::IPeerDiscoveryService.

bool zmf::discovery::PeerDiscoveryService::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 
)
virtual

Starts the peer discovery service: State multicasting, peer discovery and module registry

Parameters
coreReference to the ZMF core
selfHandleModule handle for the module of this instance. Contains information about module and its state
multicastFrequencyFrequency to send out state multicasts (in milliseconds between multicasts)
udpPortUDP port for state multicast communication
peerDiscoveryWaitIf true the service will wait until all active modules discovered before it returns from the starting process
Returns
Returns true if start successful, false otherwise

source-address for receiving UDP-packets

destination-address for sending multicasts

preparing the UDP-Socket for multicasts

Implements zmf::discovery::IPeerDiscoveryService.

void zmf::discovery::PeerDiscoveryService::stop ( )
virtual

Stops the peer discovery service

Implements zmf::discovery::IPeerDiscoveryService.

void zmf::discovery::PeerDiscoveryService::updateSelfAdditionalState ( std::vector< uint8_t >  additionalState)
virtual

Called when there is a change in the additional state of own module, updates the selfAdditionalState_ variable

Parameters
additionalStateThe new additional state that the own module should be set to

Implements zmf::discovery::IPeerDiscoveryService.

void zmf::discovery::PeerDiscoveryService::updateSelfState ( zmf::data::ModuleState  state)
virtual

Called when there is a change in the lifecycle-state of the own module, updates the selfState_ variable

Parameters
stateThe new lifecycle-state that the own module has now

Implements zmf::discovery::IPeerDiscoveryService.


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