Node

The DataStorm Node class is the main entry point to the DataStorm service. The application must first create a DataStorm node to be able to create topics.

On this page:

Creation

You would typically create a node in your main function as follows:

C++
DataStorm::Node node(argc, argv);

where argc and argv represent the command-line arguments passed to main. Providing argc and argv allows the Node constructor to extract configuration properties from the command line. For example, you can turn on tracing by executing your application with:

myapp --DataStorm.Trace.Node=1

You can also specify your config file by setting Ice.Config on the command-line:

myapp --Ice.Config=myapp.cfg


Overall, node provides the following constructors:

C++
template<class... T> Node(int& argc, const char* argv[], T&&... iceArgs);
template<class... T> Node(int& argc, const wchar_t* argv[], T&&... iceArgs); // only on Windows
template<class... T> Node(T&&... iceArgs);

Node(std::shared_ptr<Ice::Communicator> communicator);


The first 3 constructors create an internal communicator using the supplied parameters. See Communicator Initialization in the Ice Manual for a description of these parameters.

The last constructor accepts an Ice communicator created by the application. The node uses the given Ice communicator for its communications.

Destruction

The node destructor releases the resources allocated by the node. If the node created an Ice communicator, it is destroyed by the destructor. If writers or readers are still active when the node is destroyed, they will no longer publish or receive samples after the node is destroyed.

Shutdown

The node class provides a shutdown method to unblock threads that might be waiting for samples to be received or for writers or readers to connect. These methods will raise NodeShutdownException when shutdown is called. The node also provides isShutdown and waitForShutdown methods to check if the node has been shutdown or wait for shutdown to be called. 

Session

The node maintains publisher and subscriber sessions with other DataStorm nodes in order to exchange information and data. Only session identifiers are exposed to the application. These identifiers can be used to get the Ice connection associated with the session. This can be useful to print information on the peer that sent a sample or that connected to a reader or writer. The node class provides the following method in order to get the Ice connection:

C++
std::shared_ptr<Ice::Connection> getSessionConnection(const std::string& ident) const;

Session identifiers can be obtained from samples using the getSession method.