mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 13:11:36 +00:00
docs: replace the Markdown docs with links to the site
- Remove docs/*.md and docs/images/ - Rewrite README.md: description, install, first steps and links to the site - Replace the READMEs of the examples, fairmq/shmem, fairmq/devices and fairmq/tools with links to the site pages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
1-1: Sampler -> Sink
|
||||
====================
|
||||
# Example 1-1: sampler and sink
|
||||
|
||||
A simple topology of two devices - **Sampler** and **Sink**. **Sampler** sends data to **Sink** via the **PUSH-PULL** pattern.
|
||||
Two devices: a sampler sends a text message on a push channel, and a sink receives it on a pull channel.
|
||||
|
||||
`sampler.cxx` and `sink.cxx` configure and run the devices.
|
||||
|
||||
The executables take two command line parameters: `--id` and `--channel-config`. The value of `--id` should be a unique identifier and the value for `--channel-config` is the configuration of the communication channel. .
|
||||
|
||||
For this and the following example, all the commands needed to start the device are contained in the `fairmq-start-ex-*.sh` script (that can also be used for starting the example).
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/1-1/>
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
1-n-1: Sampler -> Processor(s) -> Sink
|
||||
======================================
|
||||
# Example 1-n-1: sampler, processors and sink
|
||||
|
||||
A simple topology of three devices - **Sampler**, **Processor** and **Sink**. **Sampler** sends data to one or more **Processor**s, who modify the data and send it to one **Sink**. Transport with the **PUSH-PULL** pattern.
|
||||
A sampler sends messages to several processors, and the processors send the results to one sink. A JSON file configures the channels.
|
||||
|
||||
The communication channels for this example are configured via a JSON file. The matching between device and config entry is done either via id, or the config key. For this example both processor devices share same configuration, and can therefore use same setting from the JSON file. But since their ID still has to be unique, additional command line argument must be used to allow them to share configuration. This parameter is `--config-key`.
|
||||
|
||||
In this example the Sampler is configured to **bind** its output and the Sink is configured to also **bind** its input. This allows us run any number of processors with the same configuration, because they all connect to same Sampler and Sink addresses. Furthermore, it allows adding of processors dynamically during run-time. The PUSH and PULL sockets will handle the data distribution to/from the new devices according to their distribution strategies ([Round-robin output for PUSH](http://api.zeromq.org/4-0:zmq-socket#toc14) and [Fair-queued input for PULL](http://api.zeromq.org/4-0:zmq-socket#toc15)).
|
||||
|
||||
The Sampler sends out a simple text string (its content configurable with `--text` command line parameter, defaul is "Hello"). Each Processor modifies the string by appending its ID to it and send it to the Sink.
|
||||
|
||||
The provided configuration file contains two Processors. To add more Processors, you can either extend the configuration file, or create a separate file only for new processors. Or combine JSON config with `--channel-config` from other examples.
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/1-n-1/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Built-in devices
|
||||
==========================
|
||||
# Example builtin-devices: a topology of built-in devices
|
||||
|
||||
This example demonstrates use of generic devices that are provided with FairMQ - BenchmarkSampler, Merger, Multiplier, Proxy, Sink, Splitter. They are all connected in one topology and transfer some dummy buffers generated by the BenchmarkSampler.
|
||||
The built-in devices fairmq-bsampler, fairmq-splitter, fairmq-proxy, fairmq-merger, fairmq-multiplier and fairmq-sink in one topology, without own code.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/builtin-devices/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Copy & Push
|
||||
===========
|
||||
# Example copypush: one message to several receivers
|
||||
|
||||
A topology consisting of one **Sampler** and two **Sink**s. The **Sampler** uses the `Copy` method to send the same data to both sinks with the **PUSH-PULL** pattern. In contrary to the **PUB-SUB** pattern, this ensures that all receivers are connected and no data is lost, but requires additional sockets.
|
||||
A sampler sends the same data to two sinks. It makes a copy of each message for each sub-channel of a push channel.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/copypush/>
|
||||
|
||||
@@ -1,122 +1,6 @@
|
||||
DDS Example
|
||||
===========
|
||||
# Example dds: run with DDS
|
||||
|
||||
This example demonstrates usage of the Dynamic Deployment System ([DDS](http://dds.gsi.de/)) to dynamically deploy and configure a topology of devices. The topology is similar to the one in Example 1-n-1, but now it can be easily distributed on different computing nodes without the need for manual addresses reconfiguration of the devices.
|
||||
A sampler, ten processors and a sink in a DDS topology without channel addresses; the start script needs DDS and a DDS plugin for FairMQ.
|
||||
|
||||
The description below outlines the minimal steps needed to run the example with DDS. For general DDS help please refer to DDS documentation on [DDS Website](http://dds.gsi.de/).
|
||||
|
||||
##### 1. The device handles the channel addresses and ports configuration via DDS Plugin.
|
||||
|
||||
It is sufficient to provide the `-S "<@FAIRMQ_INSTALL_DIR@/lib" -P dds` (`<` prepends the following path to the default plugin search paths; put in the path which points to the library dir of your FairRoot installation) command line arguments to let the devices be configured dynamically. No code changes in the device are necessary. See the XML topology file for example of using the command line arguments.
|
||||
|
||||
##### 2a. Write DDS hosts file that contains a list of worker nodes to run the topology on (When deploying using the SSH plug-in).
|
||||
|
||||
We run this example on the local machine for simplicity. The file below defines 3 workers - sampler, processor and sink - with a total of 12 DDS agents (thus able to accept 12 tasks). The parameters for each worker node are:
|
||||
- user-chosen worker ID (must be unique)
|
||||
- a host name with or without a login, in a form: login@host.fqdn (password-less SSH access to these hosts must be possible)
|
||||
- additional SSH params (can be empty)
|
||||
- a remote working directory (most exist on the worker nodes)
|
||||
- number of DDS Agents for this worker
|
||||
|
||||
```bash
|
||||
@bash_begin@
|
||||
#source setup.sh
|
||||
@bash_end@
|
||||
|
||||
sampler, username@localhost, , /path/to/dds-work-dir/, 1
|
||||
processor, username@localhost, , /path/to/dds-work-dir/, 10
|
||||
sink, username@localhost, , /path/to/dds-work-dir/, 1
|
||||
```
|
||||
|
||||
##### 2b. Skip (When deploying using the localhost plug-in).
|
||||
|
||||
If you want to deploy on a single host DDS 1.6+ provides a localhost rms plug-in. You do not need a hosts file in that case.
|
||||
|
||||
##### 3. Write DDS topology file that describes which tasks (processes) to run and their topology and configuration.
|
||||
|
||||
Take a look at `ex-dds-topology.xml`. It consists of a definition part (properties, tasks, collections and more) and execution part (main). In our example Sampler, Processor and Sink tasks are defined, containing their executables and exchanged properties. The `<main>` of the topology uses the defined tasks. Besides one Sampler and one Sink task, a group containing Processor task is defined. The group has a multiplicity of 10, meaninig 10 Processors will be executed. Each of the Processors will receive the properties with Sampler and Sink addresses.
|
||||
|
||||
The configuration of the channel connection addresses is done by the DDS plugin via the channel names. The task property names must correspond to the channel names (data1, data2), with binding channels writing the properties and connecting channel reading the properties.
|
||||
|
||||
**If you chose step 2b earlier**, then modify the provided `ex-dds-topology.xml` in the top that the following lines read as following:
|
||||
```xml
|
||||
<declrequirement name="SamplerWorker" type="wnname" value=".*"/>
|
||||
<declrequirement name="ProcessorWorker" type="wnname" value=".*"/>
|
||||
<declrequirement name="SinkWorker" type="wnname" value=".*"/>
|
||||
```
|
||||
|
||||
Note that the attributes `value` contain a different value.
|
||||
|
||||
##### 4. Start DDS session.
|
||||
|
||||
First you need to initialize DDS environment:
|
||||
|
||||
```bash
|
||||
source DDS_env.sh # this script is located in the DDS installation directory
|
||||
```
|
||||
|
||||
The DDS session is started with:
|
||||
|
||||
```bash
|
||||
dds-session start
|
||||
```
|
||||
|
||||
##### 5. Submit DDS Agents (configured in the hosts file).
|
||||
|
||||
Agents are submitted with:
|
||||
```bash
|
||||
dds-submit --rms ssh --config ex-dds-hosts.cfg
|
||||
```
|
||||
The `--rms` option defines a destination resource management system. The `--config` specifies an SSH plug-in resource definition file.
|
||||
|
||||
**If you chose step 2b earlier**, run the following command instead:
|
||||
|
||||
```bash
|
||||
dds-submit --rms localhost -n 12
|
||||
```
|
||||
|
||||
##### 6. Activate the topology.
|
||||
|
||||
```bash
|
||||
dds-topology --activate ex-dds-topology.xml
|
||||
```
|
||||
|
||||
##### 7. Run
|
||||
|
||||
After activation, agents will execute the defined tasks on the worker nodes. Output of the tasks will be stored in the directory that was specified in the hosts file (or in the system temporary directory when using the localhost plugin).
|
||||
|
||||
##### 8. (optional) Use example command UI to check state of the devices
|
||||
|
||||
A simple utility (fairmq-dds-command-ui) is included with FairMQ to send commands to devices and receive replies from them. The utility uses the DDS intercom library to query state/config of devices and allows changing their state. To let the device listen to the commands from the utility, start the device with `-S "<@FAIRMQ_INSTALL_DIR@/lib" -P dds` cmd option (see example XML topology).
|
||||
|
||||
To see it in action, start the fairmq-dds-command-ui while the topology is running. Run the utility with `-h` to see everything that it can do.
|
||||
|
||||
The utility requires a session parameter to connect to appropriate DDS session. The session value is given when starting dds-session.
|
||||
|
||||
By default the command UI sends commands to all tasks. This can be further refined by giving a specific topology path via `-p` argument.
|
||||
Given our topology file, here are some examples of valid paths:
|
||||
```bash
|
||||
# get state of all devices
|
||||
./fairmq/plugins/DDS/fairmq-dds-command-ui -s 937ffbca-b524-44d8-9898-1d69aedc3751 -c c
|
||||
# get state of sampler
|
||||
./fairmq/plugins/DDS/fairmq-dds-command-ui -s 937ffbca-b524-44d8-9898-1d69aedc3751 -c c -p main/Sampler
|
||||
# get state of sink
|
||||
./fairmq/plugins/DDS/fairmq-dds-command-ui -s 937ffbca-b524-44d8-9898-1d69aedc3751 -c c -p main/Sink
|
||||
# get state all processors
|
||||
./fairmq/plugins/DDS/fairmq-dds-command-ui -s 937ffbca-b524-44d8-9898-1d69aedc3751 -c c -p main/ProcessorGroup/Processor
|
||||
# get state of a specific processor
|
||||
./fairmq/plugins/DDS/fairmq-dds-command-ui -s 937ffbca-b524-44d8-9898-1d69aedc3751 -c c -p main/ProcessorGroup/Processor_9
|
||||
```
|
||||
|
||||
##### 9. Stop DDS session/topology.
|
||||
|
||||
The execution of tasks can be stopped with:
|
||||
```bash
|
||||
dds-topology --stop
|
||||
```
|
||||
Or by stopping the DDS session:
|
||||
```bash
|
||||
dds-session stop
|
||||
```
|
||||
|
||||
For general DDS documentation please refer to [DDS Website](http://dds.gsi.de/).
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/dds/>
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
Sending Multipart messages
|
||||
==========================
|
||||
# Example multipart: several parts in one message
|
||||
|
||||
A topology of two devices - Sampler and Sink, communicating with PUSH-PULL pattern.
|
||||
A sampler sends a header and six data parts as one multipart message, and a sink receives all parts in one handler call.
|
||||
|
||||
The Sampler sends a multipart message to the Sink, consisting of two message parts - header and body.
|
||||
|
||||
Each message part is a regular fair::mq::Message. To combine them into a multi-part message use `fair::mq::Parts`. Add messages to `fair::mq::Parts` with `AddPart` method.
|
||||
|
||||
All parts are guaranteed to be delivered together. The Receive call in the sink will recive the entire parts structure.
|
||||
|
||||
The header contains a simple data structure with one integer. The integer in this structure is used as a stop flag for the sink. As long as its value is 0, the Sink will keep processing the data. Once its value is 1, the data handler method of the Sink will return false, which will exit the RUNNING state of the device.
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/multipart/>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
Multiple Channels
|
||||
=================
|
||||
# Example multiple-channels: data and broadcast
|
||||
|
||||
This example demonstrates how to work with multiple channels and multiplex between them.
|
||||
A sampler and a sink use a data channel and a broadcast channel. The sampler polls both channels, and the sink has one handler for each.
|
||||
|
||||
A topology of three devices - **Sampler**, **Sink** and **Broadcaster**. The Sampler sends data to the Sink via the PUSH-PULL pattern. The Broadcaster device sends a message to both Sampler and Sink containing a string "OK" every second. The Broadcaster sends the message via PUB pattern. Both Sampler and Sink, besides doing their PUSH-PULL job, listen via SUB to the Broadcaster.
|
||||
|
||||
The multiplexing between their data channels and the broadcast channels happens with `fair::mq::Poller`.
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/multiple-channels/>
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
Multiple Transports example
|
||||
===========================
|
||||
# Example multiple-transports: zeromq and shmem
|
||||
|
||||
This example demonstrates use of multiple transports (zeromq/shmem) within the same topology and/or device. It is a simple topology consisting of two samplers and a sink. The devices are connected via 3 channels:
|
||||
Two samplers and a sink use the shmem and the zeromq transport at the same time, with a transport for each channel.
|
||||
|
||||

|
||||
|
||||
Each device has main transport that it uses. By default it is ZeroMQ, and can be overriden via the `--transport` cmd option. The device will initialize additional transports if any of the channels have them configured (e.g. as an option to `--channel-config`).
|
||||
|
||||
In this example sampler1 and sink are started with `--transport shmem`, making shared memory their main transport, sampler2 with `--transport zeromq`. Additionally, the ack channel is configured to use zeromq as its transport.
|
||||
|
||||
The main two things that a transport does is transfer of data and allocation of memory for the messages. By default, new messages are created via the main device transport. If a message has been created with one transport and is to be transferred with another, it has to be copied into a new message of the target transport. This happens automatically behind the scenes. To avoid this copy the device can create messages via `NewMessageFor(const string& channelName, int subChannelIndex, ...)` method, that creates the messages via the transport of the given channel (check sampler1 and sink for an example) or as the channel directly to create a message.
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/multiple-transports/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
N-M
|
||||
==========================
|
||||
# Example n-m: n senders to m receivers
|
||||
|
||||
A topology consisting of three layers of devices: synchronizer -> sender(s) -> receiver(s). Senders distribute data to receivers based on the data id contained in the message from the synchronizer (same id goes to the same receiver from every sender). The senders send the data in a non-blocking fashion - if queue is full or receiver is down, data is discarded. Two configurations are provided - one using push/pull channels between senders/receivers, another using pair channels. In push/pull case there is only one receiving channel on the receiver device. In pair case there are as many receiver (sub-)channels as there are senders.
|
||||
Three senders send each timeframe to one of four receivers, and the receiver collects the parts of all senders; with push/pull or pair channels.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/n-m/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
QC
|
||||
==
|
||||
# Example qc: quality control on demand
|
||||
|
||||
A topology consisting of 4 devices - Sampler, QCDispatcher, QCTask and Sink. The data flows from Sampler through QCDispatcher to Sink. On demand - by setting the corresponding configuration property - the QCDispatcher device will duplicate the data to the QCTask device. The property is set by the topology controller, in this example this is the `fairmq-dds-command-ui` utility.
|
||||
A dispatcher forwards data from a sampler to a sink, and also to a QC task when a controller sets the property qc to active; the start script needs DDS.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/qc/>
|
||||
|
||||
@@ -1,27 +1,6 @@
|
||||
# Readout example
|
||||
# Example readout: a readout chain
|
||||
|
||||
This examples shows two possible topologies (out of many) for a node connected to a detector readout (followed by a processing node).
|
||||
A readout node passes region messages over shmem channels and sends them to a receiver over zeromq, with or without a processor.
|
||||
|
||||
## Setup without new data generation
|
||||
|
||||
```
|
||||
|------------------------------- Readout Node ---------------------------| |- Processing Node -|
|
||||
| Readout --> Builder --> Sender | --> | Receiver |
|
||||
| [# shared memory segment (unused in this topology) ##################] | zmq | |
|
||||
| [# shmem unmanaged region (readout writes here, others read) ########] | | |
|
||||
|------------------------------------------------------------------------| |-------------------|
|
||||
```
|
||||
|
||||
The devices one the Readout Node communicate via shared memory transport. Readout device writes into shared memory unmanaged region. The data is then forwarded through Builder to Sender process, which sends it out via zeromq transport.
|
||||
|
||||
## Setup with generating new data on the Readout node
|
||||
|
||||
```
|
||||
|------------------------------- Readout Node ---------------------------| |- Processing Node -|
|
||||
| Readout --> Builder --> Processor --> Sender | --> | Receiver |
|
||||
| [# shared memory segment (used between Proccessor and Sender) #######] | zmq | |
|
||||
| [# shmem unmanaged region (readout writes here, builder & proc read) ] | | |
|
||||
|------------------------------------------------------------------------| |-------------------|
|
||||
```
|
||||
|
||||
In this topology one more device is added - Processor. It examines the arriving data and creates new data in shared memory. This data is not part of the unmanaged region, but lives in the general shared memory segment (unused in the previous setup). This new data is then forwarded to Sender and the Readout device is notified that the corresponding data piece in the unmanaged region is no longer used.
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/readout/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
Region example
|
||||
==============
|
||||
# Example region: unmanaged regions
|
||||
|
||||
This example demonstrates the use of a more advanced feature - UnmanagedRegion, that can be used to create a buffer through one of FairMQ transports. The contents of this buffer are managed by the user, who can also create messages out of sub-buffers of the created buffer. Such feature can be interesting in environments that have special requirements by the hardware that writes the data, to keep the transfer efficient (e.g. shared memory).
|
||||
A sampler sends messages from an unmanaged region and counts the acknowledgements; a larger topology shares the region data with four sinks.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/region/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Request & Reply example
|
||||
=======================
|
||||
# Example req-rep: request and reply
|
||||
|
||||
This topology contains two devices that communicate with each other via the **REQ-REP** pettern. Bidirectional communication via a single socket.
|
||||
A client sends a request on a req socket and waits for the reply. A server answers on a rep socket of the same channel.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/req-rep/>
|
||||
|
||||
Reference in New Issue
Block a user