coral
A C++ library for distributed co-simulation
Classes | Public Member Functions | List of all members
coral::master::ProviderCluster Class Reference

A common communication interface to a cluster of slave providers. More...

#include "coral/master/cluster.hpp"

Classes

struct  SlaveType
 Information about a slave type. More...
 

Public Member Functions

 ProviderCluster (const coral::net::ip::Address &networkInterface, coral::net::ip::Port discoveryPort)
 Constructor. More...
 
 ~ProviderCluster () CORAL_NOEXCEPT
 Destructor.
 
 ProviderCluster (ProviderCluster &&) CORAL_NOEXCEPT
 Move constructor.
 
ProviderClusteroperator= (ProviderCluster &&) CORAL_NOEXCEPT
 Move assignment operator.
 
std::vector< SlaveTypeGetSlaveTypes (std::chrono::milliseconds timeout)
 Returns the slave types which are offered by all slave providers discovered so far. More...
 
coral::net::SlaveLocator InstantiateSlave (const std::string &slaveProviderID, const std::string &slaveTypeUUID, std::chrono::milliseconds timeout)
 Requests that a slave be spawned by a specific slave provider. More...
 

Detailed Description

A common communication interface to a cluster of slave providers.

This class represents a common interface to several slave providers in a network. It can be used to get information about the available slave types and to instantiate slaves on specific providers.

Slave providers are discovered automatically by listening for UDP broadcast messages that they broadcast periodically.

Remarks
When an object of this class is created, it will spawn a background thread that performs the actual communication with the slave providers. To ensure that there is a one-to-one relationship between an object of this class and its underlying communication thread, the objects are noncopyable (but movable), and will attempt to shut down the thread on destruction.

Constructor & Destructor Documentation

coral::master::ProviderCluster::ProviderCluster ( const coral::net::ip::Address networkInterface,
coral::net::ip::Port  discoveryPort 
)

Constructor.

Parameters
[in]networkInterfaceThe name or IP address of the network interface that should be used, or "*" for all available interfaces.
[in]discoveryPortThe UDP port used for discovering other entities such as slave providers.

Member Function Documentation

std::vector<SlaveType> coral::master::ProviderCluster::GetSlaveTypes ( std::chrono::milliseconds  timeout)

Returns the slave types which are offered by all slave providers discovered so far.

Warning
After an object of this class has been constructed, it may take some time for it to discover all slave providers.
Parameters
[in]timeoutThe communications timeout used to detect loss of communication with slave providers. A negative value means no timeout.
coral::net::SlaveLocator coral::master::ProviderCluster::InstantiateSlave ( const std::string slaveProviderID,
const std::string slaveTypeUUID,
std::chrono::milliseconds  timeout 
)

Requests that a slave be spawned by a specific slave provider.

timeout specifies how long the slave provider should wait for the slave to start up before assuming it has crashed or frozen. The function will wait twice as long as this for the slave provider to report that the slave has been successfully instantiated before it assumes that the slave provider itself has crashed or the connection has been lost. In both cases, an exception is thrown.

Parameters
[in]slaveProviderIDThe ID of the slave provider that should instantiate the slave.
[in]slaveTypeUUIDThe UUID that identifies the type of the slave that is to be instantiated.
[in]timeoutHow much time the slave gets to start up. A negative value means no limit.
Returns
An object that contains the information needed to connect to the slave, which can be passed to Execution::Reconstitute().

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