From d0c20d372932f84371af33cbeaf7fef13229d796 Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Mon, 9 Nov 2015 10:36:24 +0100 Subject: [PATCH] Rename /example to /examples and move MQ examples in it --- fairmq/CMakeLists.txt | 12 -- fairmq/examples/1-sampler-sink/CMakeLists.txt | 87 ----------- .../1-sampler-sink/FairMQExample1Sampler.cxx | 96 ------------ .../1-sampler-sink/FairMQExample1Sampler.h | 46 ------ .../1-sampler-sink/FairMQExample1Sink.cxx | 41 ----- .../1-sampler-sink/FairMQExample1Sink.h | 30 ---- fairmq/examples/1-sampler-sink/README.md | 8 - .../1-sampler-sink/ex1-sampler-sink.json | 41 ----- .../1-sampler-sink/runExample1Sampler.cxx | 92 ----------- .../1-sampler-sink/runExample1Sink.cxx | 79 ---------- .../2-sampler-processor-sink/CMakeLists.txt | 90 ----------- .../FairMQExample2Processor.cxx | 62 -------- .../FairMQExample2Processor.h | 41 ----- .../FairMQExample2Sampler.cxx | 96 ------------ .../FairMQExample2Sampler.h | 46 ------ .../FairMQExample2Sink.cxx | 44 ------ .../FairMQExample2Sink.h | 30 ---- .../2-sampler-processor-sink/README.md | 10 -- .../ex2-sampler-processor-sink.json | 102 ------------- .../runExample2Processor.cxx | 79 ---------- .../runExample2Sampler.cxx | 92 ----------- .../runExample2Sink.cxx | 79 ---------- fairmq/examples/3-dds/CMakeLists.txt | 101 ------------ .../3-dds/FairMQExample3Processor.cxx | 106 ------------- .../examples/3-dds/FairMQExample3Processor.h | 47 ------ .../examples/3-dds/FairMQExample3Sampler.cxx | 96 ------------ fairmq/examples/3-dds/FairMQExample3Sampler.h | 46 ------ fairmq/examples/3-dds/FairMQExample3Sink.cxx | 44 ------ fairmq/examples/3-dds/FairMQExample3Sink.h | 30 ---- fairmq/examples/3-dds/README.md | 127 --------------- fairmq/examples/3-dds/ex3-dds-hosts.cfg | 6 - fairmq/examples/3-dds/ex3-dds-topology.xml | 36 ----- fairmq/examples/3-dds/ex3-devices.json | 59 ------- .../examples/3-dds/runExample3Processor.cxx | 144 ------------------ fairmq/examples/3-dds/runExample3Sampler.cxx | 137 ----------------- fairmq/examples/3-dds/runExample3Sink.cxx | 134 ---------------- fairmq/examples/4-copypush/CMakeLists.txt | 88 ----------- .../4-copypush/FairMQExample4Sampler.cxx | 62 -------- .../4-copypush/FairMQExample4Sampler.h | 32 ---- .../4-copypush/FairMQExample4Sink.cxx | 42 ----- .../examples/4-copypush/FairMQExample4Sink.h | 30 ---- fairmq/examples/4-copypush/README.md | 4 - fairmq/examples/4-copypush/ex4-copypush.json | 68 --------- .../4-copypush/runExample4Sampler.cxx | 79 ---------- .../examples/4-copypush/runExample4Sink.cxx | 79 ---------- fairmq/examples/5-req-rep/CMakeLists.txt | 85 ----------- .../5-req-rep/FairMQExample5Client.cxx | 103 ------------- .../examples/5-req-rep/FairMQExample5Client.h | 46 ------ .../5-req-rep/FairMQExample5Server.cxx | 55 ------- .../examples/5-req-rep/FairMQExample5Server.h | 32 ---- fairmq/examples/5-req-rep/README.md | 4 - .../examples/5-req-rep/runExample5Client.cxx | 114 -------------- .../examples/5-req-rep/runExample5Server.cxx | 63 -------- .../6-multiple-channels/CMakeLists.txt | 90 ----------- .../FairMQExample6Broadcaster.cxx | 49 ------ .../FairMQExample6Broadcaster.h | 32 ---- .../FairMQExample6Sampler.cxx | 116 -------------- .../FairMQExample6Sampler.h | 46 ------ .../FairMQExample6Sink.cxx | 61 -------- .../6-multiple-channels/FairMQExample6Sink.h | 30 ---- fairmq/examples/6-multiple-channels/README.md | 8 - .../ex6-multiple-channels.json | 85 ----------- .../runExample6Broadcaster.cxx | 79 ---------- .../runExample6Sampler.cxx | 92 ----------- .../6-multiple-channels/runExample6Sink.cxx | 83 ---------- fairmq/examples/7-parameters/CMakeLists.txt | 96 ------------ .../7-parameters/FairMQExample7Client.cxx | 130 ---------------- .../7-parameters/FairMQExample7Client.h | 48 ------ .../7-parameters/FairMQExample7ContFact.cxx | 46 ------ .../7-parameters/FairMQExample7ContFact.h | 28 ---- .../7-parameters/FairMQExample7LinkDef.h | 17 --- .../7-parameters/FairMQExample7ParOne.cxx | 70 --------- .../7-parameters/FairMQExample7ParOne.h | 47 ------ fairmq/examples/7-parameters/README.md | 10 -- fairmq/examples/7-parameters/ex7-client.json | 23 --- .../examples/7-parameters/fill_parameters.C | 24 --- .../examples/7-parameters/read_parameters.C | 19 --- .../7-parameters/runExample7Client.cxx | 99 ------------ fairmq/examples/8-multipart/CMakeLists.txt | 87 ----------- .../8-multipart/FairMQExample8Sampler.cxx | 70 --------- .../8-multipart/FairMQExample8Sampler.h | 32 ---- .../8-multipart/FairMQExample8Sink.cxx | 57 ------- .../examples/8-multipart/FairMQExample8Sink.h | 30 ---- fairmq/examples/8-multipart/README.md | 13 -- .../examples/8-multipart/ex8-multipart.json | 40 ----- .../8-multipart/runExample8Sampler.cxx | 83 ---------- .../examples/8-multipart/runExample8Sink.cxx | 79 ---------- fairmq/examples/README.md | 33 ---- 88 files changed, 5354 deletions(-) delete mode 100644 fairmq/examples/1-sampler-sink/CMakeLists.txt delete mode 100644 fairmq/examples/1-sampler-sink/FairMQExample1Sampler.cxx delete mode 100644 fairmq/examples/1-sampler-sink/FairMQExample1Sampler.h delete mode 100644 fairmq/examples/1-sampler-sink/FairMQExample1Sink.cxx delete mode 100644 fairmq/examples/1-sampler-sink/FairMQExample1Sink.h delete mode 100644 fairmq/examples/1-sampler-sink/README.md delete mode 100644 fairmq/examples/1-sampler-sink/ex1-sampler-sink.json delete mode 100644 fairmq/examples/1-sampler-sink/runExample1Sampler.cxx delete mode 100644 fairmq/examples/1-sampler-sink/runExample1Sink.cxx delete mode 100644 fairmq/examples/2-sampler-processor-sink/CMakeLists.txt delete mode 100644 fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.cxx delete mode 100644 fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.h delete mode 100644 fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.cxx delete mode 100644 fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.h delete mode 100644 fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.cxx delete mode 100644 fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.h delete mode 100644 fairmq/examples/2-sampler-processor-sink/README.md delete mode 100644 fairmq/examples/2-sampler-processor-sink/ex2-sampler-processor-sink.json delete mode 100644 fairmq/examples/2-sampler-processor-sink/runExample2Processor.cxx delete mode 100644 fairmq/examples/2-sampler-processor-sink/runExample2Sampler.cxx delete mode 100644 fairmq/examples/2-sampler-processor-sink/runExample2Sink.cxx delete mode 100644 fairmq/examples/3-dds/CMakeLists.txt delete mode 100644 fairmq/examples/3-dds/FairMQExample3Processor.cxx delete mode 100644 fairmq/examples/3-dds/FairMQExample3Processor.h delete mode 100644 fairmq/examples/3-dds/FairMQExample3Sampler.cxx delete mode 100644 fairmq/examples/3-dds/FairMQExample3Sampler.h delete mode 100644 fairmq/examples/3-dds/FairMQExample3Sink.cxx delete mode 100644 fairmq/examples/3-dds/FairMQExample3Sink.h delete mode 100644 fairmq/examples/3-dds/README.md delete mode 100644 fairmq/examples/3-dds/ex3-dds-hosts.cfg delete mode 100644 fairmq/examples/3-dds/ex3-dds-topology.xml delete mode 100644 fairmq/examples/3-dds/ex3-devices.json delete mode 100644 fairmq/examples/3-dds/runExample3Processor.cxx delete mode 100644 fairmq/examples/3-dds/runExample3Sampler.cxx delete mode 100644 fairmq/examples/3-dds/runExample3Sink.cxx delete mode 100644 fairmq/examples/4-copypush/CMakeLists.txt delete mode 100644 fairmq/examples/4-copypush/FairMQExample4Sampler.cxx delete mode 100644 fairmq/examples/4-copypush/FairMQExample4Sampler.h delete mode 100644 fairmq/examples/4-copypush/FairMQExample4Sink.cxx delete mode 100644 fairmq/examples/4-copypush/FairMQExample4Sink.h delete mode 100644 fairmq/examples/4-copypush/README.md delete mode 100644 fairmq/examples/4-copypush/ex4-copypush.json delete mode 100644 fairmq/examples/4-copypush/runExample4Sampler.cxx delete mode 100644 fairmq/examples/4-copypush/runExample4Sink.cxx delete mode 100644 fairmq/examples/5-req-rep/CMakeLists.txt delete mode 100644 fairmq/examples/5-req-rep/FairMQExample5Client.cxx delete mode 100644 fairmq/examples/5-req-rep/FairMQExample5Client.h delete mode 100644 fairmq/examples/5-req-rep/FairMQExample5Server.cxx delete mode 100644 fairmq/examples/5-req-rep/FairMQExample5Server.h delete mode 100644 fairmq/examples/5-req-rep/README.md delete mode 100644 fairmq/examples/5-req-rep/runExample5Client.cxx delete mode 100644 fairmq/examples/5-req-rep/runExample5Server.cxx delete mode 100644 fairmq/examples/6-multiple-channels/CMakeLists.txt delete mode 100644 fairmq/examples/6-multiple-channels/FairMQExample6Broadcaster.cxx delete mode 100644 fairmq/examples/6-multiple-channels/FairMQExample6Broadcaster.h delete mode 100644 fairmq/examples/6-multiple-channels/FairMQExample6Sampler.cxx delete mode 100644 fairmq/examples/6-multiple-channels/FairMQExample6Sampler.h delete mode 100644 fairmq/examples/6-multiple-channels/FairMQExample6Sink.cxx delete mode 100644 fairmq/examples/6-multiple-channels/FairMQExample6Sink.h delete mode 100644 fairmq/examples/6-multiple-channels/README.md delete mode 100644 fairmq/examples/6-multiple-channels/ex6-multiple-channels.json delete mode 100644 fairmq/examples/6-multiple-channels/runExample6Broadcaster.cxx delete mode 100644 fairmq/examples/6-multiple-channels/runExample6Sampler.cxx delete mode 100644 fairmq/examples/6-multiple-channels/runExample6Sink.cxx delete mode 100644 fairmq/examples/7-parameters/CMakeLists.txt delete mode 100644 fairmq/examples/7-parameters/FairMQExample7Client.cxx delete mode 100644 fairmq/examples/7-parameters/FairMQExample7Client.h delete mode 100644 fairmq/examples/7-parameters/FairMQExample7ContFact.cxx delete mode 100644 fairmq/examples/7-parameters/FairMQExample7ContFact.h delete mode 100644 fairmq/examples/7-parameters/FairMQExample7LinkDef.h delete mode 100644 fairmq/examples/7-parameters/FairMQExample7ParOne.cxx delete mode 100644 fairmq/examples/7-parameters/FairMQExample7ParOne.h delete mode 100644 fairmq/examples/7-parameters/README.md delete mode 100644 fairmq/examples/7-parameters/ex7-client.json delete mode 100644 fairmq/examples/7-parameters/fill_parameters.C delete mode 100644 fairmq/examples/7-parameters/read_parameters.C delete mode 100644 fairmq/examples/7-parameters/runExample7Client.cxx delete mode 100644 fairmq/examples/8-multipart/CMakeLists.txt delete mode 100644 fairmq/examples/8-multipart/FairMQExample8Sampler.cxx delete mode 100644 fairmq/examples/8-multipart/FairMQExample8Sampler.h delete mode 100644 fairmq/examples/8-multipart/FairMQExample8Sink.cxx delete mode 100644 fairmq/examples/8-multipart/FairMQExample8Sink.h delete mode 100644 fairmq/examples/8-multipart/README.md delete mode 100644 fairmq/examples/8-multipart/ex8-multipart.json delete mode 100644 fairmq/examples/8-multipart/runExample8Sampler.cxx delete mode 100644 fairmq/examples/8-multipart/runExample8Sink.cxx delete mode 100644 fairmq/examples/README.md diff --git a/fairmq/CMakeLists.txt b/fairmq/CMakeLists.txt index 73068c76..1ee7ac64 100644 --- a/fairmq/CMakeLists.txt +++ b/fairmq/CMakeLists.txt @@ -9,18 +9,6 @@ configure_file(${CMAKE_SOURCE_DIR}/fairmq/options/ProgOptionTest/macro/bsampler-sink.json ${CMAKE_BINARY_DIR}/bin/config/bsampler-sink.json) add_subdirectory(logger) - -add_subdirectory(examples/1-sampler-sink) -add_subdirectory(examples/2-sampler-processor-sink) -If(DDS_FOUND) - add_subdirectory(examples/3-dds) -EndIf(DDS_FOUND) -add_subdirectory(examples/4-copypush) -add_subdirectory(examples/5-req-rep) -add_subdirectory(examples/6-multiple-channels) -add_subdirectory(examples/7-parameters) -add_subdirectory(examples/8-multipart) - add_subdirectory(test) Set(INCLUDE_DIRECTORIES diff --git a/fairmq/examples/1-sampler-sink/CMakeLists.txt b/fairmq/examples/1-sampler-sink/CMakeLists.txt deleted file mode 100644 index a1026905..00000000 --- a/fairmq/examples/1-sampler-sink/CMakeLists.txt +++ /dev/null @@ -1,87 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence version 3 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/1-sampler-sink/ex1-sampler-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex1-sampler-sink.json) - -Set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/fairmq - ${CMAKE_SOURCE_DIR}/fairmq/devices - ${CMAKE_SOURCE_DIR}/fairmq/tools - ${CMAKE_SOURCE_DIR}/fairmq/options - ${CMAKE_SOURCE_DIR}/fairmq/examples/1-sampler-sink - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} -) - -If(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/nanomsg - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${NANOMSG_INCLUDE_DIR} - ) -Else(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/zeromq - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -EndIf(NANOMSG_FOUND) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} -) - -Link_Directories(${LINK_DIRECTORIES}) - -Set(SRCS - "FairMQExample1Sampler.cxx" - "FairMQExample1Sink.cxx" -) - -Set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ -) - -Set(LIBRARY_NAME FairMQExample1) - -GENERATE_LIBRARY() - -Set(Exe_Names - ex1-sampler - ex1-sink -) - -Set(Exe_Source - runExample1Sampler.cxx - runExample1Sink.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -ForEach(_file RANGE 0 ${_length}) - list(GET Exe_Names ${_file} _name) - list(GET Exe_Source ${_file} _src) - set(EXE_NAME ${_name}) - set(SRCS ${_src}) - set(DEPENDENCIES FairMQExample1) - GENERATE_EXECUTABLE() -EndForEach(_file RANGE 0 ${_length}) diff --git a/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.cxx b/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.cxx deleted file mode 100644 index e03e5475..00000000 --- a/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample1Sampler.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include // unique_ptr - -#include - -#include "FairMQExample1Sampler.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample1Sampler::FairMQExample1Sampler() - : fText() -{ -} - -void FairMQExample1Sampler::CustomCleanup(void *data, void *object) -{ - delete (string*)object; -} - -void FairMQExample1Sampler::Run() -{ - while (CheckCurrentState(RUNNING)) - { - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - - string* text = new string(fText); - - unique_ptr msg(fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text)); - - LOG(INFO) << "Sending \"" << fText << "\""; - - fChannels.at("data-out").at(0).Send(msg); - } -} - -FairMQExample1Sampler::~FairMQExample1Sampler() -{ -} - -void FairMQExample1Sampler::SetProperty(const int key, const string& value) -{ - switch (key) - { - case Text: - fText = value; - break; - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -string FairMQExample1Sampler::GetProperty(const int key, const string& default_ /*= ""*/) -{ - switch (key) - { - case Text: - return fText; - break; - default: - return FairMQDevice::GetProperty(key, default_); - } -} - -void FairMQExample1Sampler::SetProperty(const int key, const int value) -{ - switch (key) - { - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -int FairMQExample1Sampler::GetProperty(const int key, const int default_ /*= 0*/) -{ - switch (key) - { - default: - return FairMQDevice::GetProperty(key, default_); - } -} diff --git a/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.h b/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.h deleted file mode 100644 index fd6665c3..00000000 --- a/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.h +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample1Sampler.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE1SAMPLER_H_ -#define FAIRMQEXAMPLE1SAMPLER_H_ - -#include - -#include "FairMQDevice.h" - -class FairMQExample1Sampler : public FairMQDevice -{ - public: - enum - { - Text = FairMQDevice::Last, - Last - }; - FairMQExample1Sampler(); - virtual ~FairMQExample1Sampler(); - - static void CustomCleanup(void* data, void* hint); - - virtual void SetProperty(const int key, const std::string& value); - virtual std::string GetProperty(const int key, const std::string& default_ = ""); - virtual void SetProperty(const int key, const int value); - virtual int GetProperty(const int key, const int default_ = 0); - - protected: - std::string fText; - - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE1SAMPLER_H_ */ diff --git a/fairmq/examples/1-sampler-sink/FairMQExample1Sink.cxx b/fairmq/examples/1-sampler-sink/FairMQExample1Sink.cxx deleted file mode 100644 index 551af399..00000000 --- a/fairmq/examples/1-sampler-sink/FairMQExample1Sink.cxx +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample1Sink.cxx - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include "FairMQExample1Sink.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample1Sink::FairMQExample1Sink() -{ -} - -void FairMQExample1Sink::Run() -{ - while (CheckCurrentState(RUNNING)) - { - unique_ptr msg(fTransportFactory->CreateMessage()); - - if (fChannels.at("data-in").at(0).Receive(msg) >= 0) - { - LOG(INFO) << "Received message: \"" - << string(static_cast(msg->GetData()), msg->GetSize()) - << "\""; - } - } -} - -FairMQExample1Sink::~FairMQExample1Sink() -{ -} diff --git a/fairmq/examples/1-sampler-sink/FairMQExample1Sink.h b/fairmq/examples/1-sampler-sink/FairMQExample1Sink.h deleted file mode 100644 index 34847903..00000000 --- a/fairmq/examples/1-sampler-sink/FairMQExample1Sink.h +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample1Sink.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE1SINK_H_ -#define FAIRMQEXAMPLE1SINK_H_ - -#include "FairMQDevice.h" - -class FairMQExample1Sink : public FairMQDevice -{ - public: - FairMQExample1Sink(); - virtual ~FairMQExample1Sink(); - - protected: - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE1SINK_H_ */ diff --git a/fairmq/examples/1-sampler-sink/README.md b/fairmq/examples/1-sampler-sink/README.md deleted file mode 100644 index 9108a03e..00000000 --- a/fairmq/examples/1-sampler-sink/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Example 1: Sampler -> Sink -=============== - -A simple topology of two devices - **Sampler** and **Sink**. **Sampler** sends data to **Sink** via the **PUSH-PULL** pattern. - -`runExample1Sampler.cxx` and `runExample1Sink.cxx` configure and run the devices in their main function. - -The executables take two required command line parameters: `--id` and `--config-json-file`. The value of `--id` should be a unique identifier and the value for `--config-json-file` a path to a config file. The config file for this example is `ex1-sampler-sink.json` and it contains configuration for the communication channels of the devices. The mapping between a specific device and the configuration (which can contain multiple devices) is done based on the **id**. diff --git a/fairmq/examples/1-sampler-sink/ex1-sampler-sink.json b/fairmq/examples/1-sampler-sink/ex1-sampler-sink.json deleted file mode 100644 index f41683a7..00000000 --- a/fairmq/examples/1-sampler-sink/ex1-sampler-sink.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "fairMQOptions": - { - "device": - { - "id": "sampler1", - "channel": - { - "name": "data-out", - "socket": - { - "type": "push", - "method": "bind", - "address": "tcp://*:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - }, - - "device": - { - "id": "sink1", - "channel": - { - "name": "data-in", - "socket": - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - } - } -} - diff --git a/fairmq/examples/1-sampler-sink/runExample1Sampler.cxx b/fairmq/examples/1-sampler-sink/runExample1Sampler.cxx deleted file mode 100644 index 8784142b..00000000 --- a/fairmq/examples/1-sampler-sink/runExample1Sampler.cxx +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample1Sampler.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "boost/program_options.hpp" - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample1Sampler.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -using namespace boost::program_options; - -int main(int argc, char** argv) -{ - FairMQExample1Sampler sampler; - sampler.CatchSignals(); - - FairMQProgOptions config; - - try - { - std::string text; - - options_description samplerOptions("Sampler options"); - samplerOptions.add_options() - ("text", value(&text)->default_value("Hello"), "Text to send out"); - - config.AddToCmdLineOptions(samplerOptions); - - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sampler.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sampler.SetTransport(transportFactory); - - sampler.SetProperty(FairMQExample1Sampler::Id, id); - sampler.SetProperty(FairMQExample1Sampler::Text, text); - - sampler.ChangeState("INIT_DEVICE"); - sampler.WaitForEndOfState("INIT_DEVICE"); - - sampler.ChangeState("INIT_TASK"); - sampler.WaitForEndOfState("INIT_TASK"); - - sampler.ChangeState("RUN"); - sampler.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/1-sampler-sink/runExample1Sink.cxx b/fairmq/examples/1-sampler-sink/runExample1Sink.cxx deleted file mode 100644 index 4080cf4b..00000000 --- a/fairmq/examples/1-sampler-sink/runExample1Sink.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample1Sink.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample1Sink.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -int main(int argc, char** argv) -{ - FairMQExample1Sink sink; - sink.CatchSignals(); - - FairMQProgOptions config; - - try - { - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sink.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sink.SetTransport(transportFactory); - - sink.SetProperty(FairMQExample1Sink::Id, id); - - sink.ChangeState("INIT_DEVICE"); - sink.WaitForEndOfState("INIT_DEVICE"); - - sink.ChangeState("INIT_TASK"); - sink.WaitForEndOfState("INIT_TASK"); - - sink.ChangeState("RUN"); - sink.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/2-sampler-processor-sink/CMakeLists.txt b/fairmq/examples/2-sampler-processor-sink/CMakeLists.txt deleted file mode 100644 index d2f4f46e..00000000 --- a/fairmq/examples/2-sampler-processor-sink/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence version 3 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/2-sampler-processor-sink/ex2-sampler-processor-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex2-sampler-processor-sink.json) - -Set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/fairmq - ${CMAKE_SOURCE_DIR}/fairmq/devices - ${CMAKE_SOURCE_DIR}/fairmq/tools - ${CMAKE_SOURCE_DIR}/fairmq/options - ${CMAKE_SOURCE_DIR}/fairmq/examples/2-sampler-processor-sink - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} -) - -If(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/nanomsg - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -Else(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/zeromq - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -EndIf(NANOMSG_FOUND) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} -) - -Link_Directories(${LINK_DIRECTORIES}) - -Set(SRCS - "FairMQExample2Sampler.cxx" - "FairMQExample2Processor.cxx" - "FairMQExample2Sink.cxx" -) - -Set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ -) - -Set(LIBRARY_NAME FairMQExample2) - -GENERATE_LIBRARY() - -Set(Exe_Names - ex2-sampler - ex2-processor - ex2-sink -) - -Set(Exe_Source - runExample2Sampler.cxx - runExample2Processor.cxx - runExample2Sink.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -ForEach(_file RANGE 0 ${_length}) - list(GET Exe_Names ${_file} _name) - list(GET Exe_Source ${_file} _src) - Set(EXE_NAME ${_name}) - Set(SRCS ${_src}) - Set(DEPENDENCIES FairMQExample2) - GENERATE_EXECUTABLE() -EndForEach(_file RANGE 0 ${_length}) diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.cxx b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.cxx deleted file mode 100644 index b539d514..00000000 --- a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample2Processor.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQExample2Processor.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample2Processor::FairMQExample2Processor() - : fText() -{ -} - -void FairMQExample2Processor::CustomCleanup(void *data, void *object) -{ - delete (string*)object; -} - -void FairMQExample2Processor::Run() -{ - // Check if we are still in the RUNNING state - while (CheckCurrentState(RUNNING)) - { - // Create empty message to hold the input - unique_ptr input(fTransportFactory->CreateMessage()); - - // Receive the message (blocks until received or interrupted (e.g. by state change)). - // Returns size of the received message or -1 if interrupted. - if (fChannels.at("data-in").at(0).Receive(input) >= 0) - { - LOG(INFO) << "Received data, processing..."; - - // Modify the received string - string* text = new string(static_cast(input->GetData()), input->GetSize()); - *text += " (modified by " + fId + ")"; - - // Create output message - unique_ptr msg(fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text)); - - // Send out the output message - fChannels.at("data-out").at(0).Send(msg); - } - } -} - -FairMQExample2Processor::~FairMQExample2Processor() -{ -} diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.h b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.h deleted file mode 100644 index 9f0f1157..00000000 --- a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.h +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample2Processor.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE2PROCESSOR_H_ -#define FAIRMQEXAMPLE2PROCESSOR_H_ - -#include - -#include "FairMQDevice.h" - -class FairMQExample2Processor : public FairMQDevice -{ - public: - enum - { - Text = FairMQDevice::Last, - Last - }; - FairMQExample2Processor(); - virtual ~FairMQExample2Processor(); - - static void CustomCleanup(void* data, void* hint); - - protected: - std::string fText; - - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE2PROCESSOR_H_ */ diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.cxx b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.cxx deleted file mode 100644 index 40f90be6..00000000 --- a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample2Sampler.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQExample2Sampler.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample2Sampler::FairMQExample2Sampler() - : fText() -{ -} - -void FairMQExample2Sampler::CustomCleanup(void *data, void *object) -{ - delete (string*)object; -} - -void FairMQExample2Sampler::Run() -{ - // Check if we are still in the RUNNING state - while (CheckCurrentState(RUNNING)) - { - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - - string* text = new string(fText); - - unique_ptr msg(fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text)); - - LOG(INFO) << "Sending \"" << fText << "\""; - - fChannels.at("data-out").at(0).Send(msg); - } -} - -FairMQExample2Sampler::~FairMQExample2Sampler() -{ -} - -void FairMQExample2Sampler::SetProperty(const int key, const string& value) -{ - switch (key) - { - case Text: - fText = value; - break; - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -string FairMQExample2Sampler::GetProperty(const int key, const string& default_ /*= ""*/) -{ - switch (key) - { - case Text: - return fText; - break; - default: - return FairMQDevice::GetProperty(key, default_); - } -} - -void FairMQExample2Sampler::SetProperty(const int key, const int value) -{ - switch (key) - { - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -int FairMQExample2Sampler::GetProperty(const int key, const int default_ /*= 0*/) -{ - switch (key) - { - default: - return FairMQDevice::GetProperty(key, default_); - } -} diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.h b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.h deleted file mode 100644 index 71dc3fca..00000000 --- a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.h +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample2Sampler.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE2SAMPLER_H_ -#define FAIRMQEXAMPLE2SAMPLER_H_ - -#include - -#include "FairMQDevice.h" - -class FairMQExample2Sampler : public FairMQDevice -{ - public: - enum - { - Text = FairMQDevice::Last, - Last - }; - FairMQExample2Sampler(); - virtual ~FairMQExample2Sampler(); - - static void CustomCleanup(void* data, void* hint); - - virtual void SetProperty(const int key, const std::string& value); - virtual std::string GetProperty(const int key, const std::string& default_ = ""); - virtual void SetProperty(const int key, const int value); - virtual int GetProperty(const int key, const int default_ = 0); - - protected: - std::string fText; - - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE2SAMPLER_H_ */ diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.cxx b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.cxx deleted file mode 100644 index cb4dbf52..00000000 --- a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.cxx +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample2Sink.cxx - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQExample2Sink.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample2Sink::FairMQExample2Sink() -{ -} - -void FairMQExample2Sink::Run() -{ - while (CheckCurrentState(RUNNING)) - { - unique_ptr msg(fTransportFactory->CreateMessage()); - - if (fChannels.at("data-in").at(0).Receive(msg) >= 0) - { - LOG(INFO) << "Received message: \"" - << string(static_cast(msg->GetData()), msg->GetSize()) - << "\""; - } - } -} - -FairMQExample2Sink::~FairMQExample2Sink() -{ -} diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.h b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.h deleted file mode 100644 index 228501a0..00000000 --- a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.h +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample2Sink.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE2SINK_H_ -#define FAIRMQEXAMPLE2SINK_H_ - -#include "FairMQDevice.h" - -class FairMQExample2Sink : public FairMQDevice -{ - public: - FairMQExample2Sink(); - virtual ~FairMQExample2Sink(); - - protected: - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE2SINK_H_ */ diff --git a/fairmq/examples/2-sampler-processor-sink/README.md b/fairmq/examples/2-sampler-processor-sink/README.md deleted file mode 100644 index 7835e919..00000000 --- a/fairmq/examples/2-sampler-processor-sink/README.md +++ /dev/null @@ -1,10 +0,0 @@ -Example 2: Sampler -> Processor -> 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. - -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. diff --git a/fairmq/examples/2-sampler-processor-sink/ex2-sampler-processor-sink.json b/fairmq/examples/2-sampler-processor-sink/ex2-sampler-processor-sink.json deleted file mode 100644 index 216b9f09..00000000 --- a/fairmq/examples/2-sampler-processor-sink/ex2-sampler-processor-sink.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "fairMQOptions": - { - "device": - { - "id": "sampler1", - "channel": - { - "name": "data-out", - "socket": - { - "type": "push", - "method": "bind", - "address": "tcp://*:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - }, - - "device": - { - "id": "processor1", - "channel": - { - "name": "data-in", - "socket": - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - }, - "channel": - { - "name": "data-out", - "socket": - { - "type": "push", - "method": "connect", - "address": "tcp://localhost:5556", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - }, - - "device": - { - "id": "processor2", - "channel": - { - "name": "data-in", - "socket": - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - }, - "channel": - { - "name": "data-out", - "socket": - { - "type": "push", - "method": "connect", - "address": "tcp://localhost:5556", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - }, - - "device": - { - "id": "sink1", - "channel": - { - "name": "data-in", - "socket": - { - "type": "pull", - "method": "bind", - "address": "tcp://*:5556", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - } - } -} diff --git a/fairmq/examples/2-sampler-processor-sink/runExample2Processor.cxx b/fairmq/examples/2-sampler-processor-sink/runExample2Processor.cxx deleted file mode 100644 index 3e72f0de..00000000 --- a/fairmq/examples/2-sampler-processor-sink/runExample2Processor.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample2Processor.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample2Processor.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -int main(int argc, char** argv) -{ - FairMQExample2Processor processor; - processor.CatchSignals(); - - FairMQProgOptions config; - - try - { - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - processor.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - processor.SetTransport(transportFactory); - - processor.SetProperty(FairMQExample2Processor::Id, id); - - processor.ChangeState("INIT_DEVICE"); - processor.WaitForEndOfState("INIT_DEVICE"); - - processor.ChangeState("INIT_TASK"); - processor.WaitForEndOfState("INIT_TASK"); - - processor.ChangeState("RUN"); - processor.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/2-sampler-processor-sink/runExample2Sampler.cxx b/fairmq/examples/2-sampler-processor-sink/runExample2Sampler.cxx deleted file mode 100644 index b76f3a42..00000000 --- a/fairmq/examples/2-sampler-processor-sink/runExample2Sampler.cxx +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample2Sampler.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "boost/program_options.hpp" - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample2Sampler.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -using namespace boost::program_options; - -int main(int argc, char** argv) -{ - FairMQExample2Sampler sampler; - sampler.CatchSignals(); - - FairMQProgOptions config; - - try - { - std::string text; - - options_description samplerOptions("Sampler options"); - samplerOptions.add_options() - ("text", value(&text)->default_value("Hello"), "Text to send out"); - - config.AddToCmdLineOptions(samplerOptions); - - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sampler.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sampler.SetTransport(transportFactory); - - sampler.SetProperty(FairMQExample2Sampler::Id, id); - sampler.SetProperty(FairMQExample2Sampler::Text, text); - - sampler.ChangeState("INIT_DEVICE"); - sampler.WaitForEndOfState("INIT_DEVICE"); - - sampler.ChangeState("INIT_TASK"); - sampler.WaitForEndOfState("INIT_TASK"); - - sampler.ChangeState("RUN"); - sampler.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/2-sampler-processor-sink/runExample2Sink.cxx b/fairmq/examples/2-sampler-processor-sink/runExample2Sink.cxx deleted file mode 100644 index 1f71b156..00000000 --- a/fairmq/examples/2-sampler-processor-sink/runExample2Sink.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample2Sink.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample2Sink.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -int main(int argc, char** argv) -{ - FairMQExample2Sink sink; - sink.CatchSignals(); - - FairMQProgOptions config; - - try - { - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sink.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sink.SetTransport(transportFactory); - - sink.SetProperty(FairMQExample2Sink::Id, id); - - sink.ChangeState("INIT_DEVICE"); - sink.WaitForEndOfState("INIT_DEVICE"); - - sink.ChangeState("INIT_TASK"); - sink.WaitForEndOfState("INIT_TASK"); - - sink.ChangeState("RUN"); - sink.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/3-dds/CMakeLists.txt b/fairmq/examples/3-dds/CMakeLists.txt deleted file mode 100644 index 654c2ab0..00000000 --- a/fairmq/examples/3-dds/CMakeLists.txt +++ /dev/null @@ -1,101 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence version 3 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/3-dds/ex3-devices.json ${CMAKE_BINARY_DIR}/bin/config/ex3-devices.json) -configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/3-dds/ex3-dds-topology.xml ${CMAKE_BINARY_DIR}/bin/config/ex3-dds-topology.xml) -configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/3-dds/ex3-dds-hosts.cfg ${CMAKE_BINARY_DIR}/bin/config/ex3-dds-hosts.cfg COPYONLY) - -add_definitions(-DENABLE_DDS) - -Set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/fairmq - ${CMAKE_SOURCE_DIR}/fairmq/devices - ${CMAKE_SOURCE_DIR}/fairmq/tools - ${CMAKE_SOURCE_DIR}/fairmq/options - ${CMAKE_SOURCE_DIR}/fairmq/examples/3-dds - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${DDS_INCLUDE_DIR} -) - -If(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/nanomsg - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${NANOMSG_INCLUDE_DIR} - ) -Else(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/zeromq - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -EndIf(NANOMSG_FOUND) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${LINK_DIRECTORIES} - ${Boost_LIBRARY_DIRS} - ${DDS_LIBRARY_DIR} -) - -Link_Directories(${LINK_DIRECTORIES}) - -Set(SRCS - ${SRCS} - "FairMQExample3Sampler.cxx" - "FairMQExample3Processor.cxx" - "FairMQExample3Sink.cxx" -) - -Set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ - dds-key-value-lib -) - -set(LIBRARY_NAME FairMQExample3) - -GENERATE_LIBRARY() - -Set(Exe_Names - ${Exe_Names} - ex3-sampler-dds - ex3-processor-dds - ex3-sink-dds -) - -Set(Exe_Source - ${Exe_Source} - runExample3Sampler.cxx - runExample3Processor.cxx - runExample3Sink.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -ForEach(_file RANGE 0 ${_length}) - list(GET Exe_Names ${_file} _name) - list(GET Exe_Source ${_file} _src) - set(EXE_NAME ${_name}) - set(SRCS ${_src}) - set(DEPENDENCIES FairMQExample3) - GENERATE_EXECUTABLE() -EndForEach(_file RANGE 0 ${_length}) diff --git a/fairmq/examples/3-dds/FairMQExample3Processor.cxx b/fairmq/examples/3-dds/FairMQExample3Processor.cxx deleted file mode 100644 index e1db6d48..00000000 --- a/fairmq/examples/3-dds/FairMQExample3Processor.cxx +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample3Processor.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQExample3Processor.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample3Processor::FairMQExample3Processor() - : fTaskIndex(0) -{ -} - -void FairMQExample3Processor::CustomCleanup(void *data, void *object) -{ - delete (string*)object; -} - -void FairMQExample3Processor::Run() -{ - // Check if we are still in the RUNNING state - while (CheckCurrentState(RUNNING)) - { - // Create empty message to hold the input - unique_ptr input(fTransportFactory->CreateMessage()); - - // Receive the message (blocks until received or interrupted (e.g. by state change)). - // Returns size of the received message or -1 if interrupted. - if (fChannels.at("data-in").at(0).Receive(input) >= 0) - { - LOG(INFO) << "Received data, processing..."; - - // Modify the received string - string* text = new string(static_cast(input->GetData()), input->GetSize()); - *text += " (modified by " + fId + to_string(fTaskIndex) + ")"; - - // Create output message - unique_ptr msg(fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text)); - - // Send out the output message - fChannels.at("data-out").at(0).Send(msg); - } - } -} - -void FairMQExample3Processor::SetProperty(const int key, const string& value) -{ - switch (key) - { - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -string FairMQExample3Processor::GetProperty(const int key, const string& default_ /*= ""*/) -{ - switch (key) - { - default: - return FairMQDevice::GetProperty(key, default_); - } -} - -void FairMQExample3Processor::SetProperty(const int key, const int value) -{ - switch (key) - { - case TaskIndex: - fTaskIndex = value; - break; - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -int FairMQExample3Processor::GetProperty(const int key, const int default_ /*= 0*/) -{ - switch (key) - { - case TaskIndex: - return fTaskIndex; - break; - default: - return FairMQDevice::GetProperty(key, default_); - } -} - -FairMQExample3Processor::~FairMQExample3Processor() -{ -} diff --git a/fairmq/examples/3-dds/FairMQExample3Processor.h b/fairmq/examples/3-dds/FairMQExample3Processor.h deleted file mode 100644 index 4350c8a6..00000000 --- a/fairmq/examples/3-dds/FairMQExample3Processor.h +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample3Processor.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE3PROCESSOR_H_ -#define FAIRMQEXAMPLE3PROCESSOR_H_ - -#include - -#include "FairMQDevice.h" - -class FairMQExample3Processor : public FairMQDevice -{ - public: - enum - { - Text = FairMQDevice::Last, - TaskIndex, - Last - }; - FairMQExample3Processor(); - virtual ~FairMQExample3Processor(); - - static void CustomCleanup(void* data, void* hint); - - virtual void SetProperty(const int key, const std::string& value); - virtual std::string GetProperty(const int key, const std::string& default_ = ""); - virtual void SetProperty(const int key, const int value); - virtual int GetProperty(const int key, const int default_ = 0); - - protected: - int fTaskIndex; - - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE3PROCESSOR_H_ */ diff --git a/fairmq/examples/3-dds/FairMQExample3Sampler.cxx b/fairmq/examples/3-dds/FairMQExample3Sampler.cxx deleted file mode 100644 index 86b0ecc1..00000000 --- a/fairmq/examples/3-dds/FairMQExample3Sampler.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample3Sampler.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQExample3Sampler.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample3Sampler::FairMQExample3Sampler() - : fText() -{ -} - -void FairMQExample3Sampler::CustomCleanup(void *data, void *object) -{ - delete (string*)object; -} - -void FairMQExample3Sampler::Run() -{ - // Check if we are still in the RUNNING state - while (CheckCurrentState(RUNNING)) - { - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - - string* text = new string(fText); - - unique_ptr msg(fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text)); - - LOG(INFO) << "Sending \"" << fText << "\""; - - fChannels.at("data-out").at(0).Send(msg); - } -} - -FairMQExample3Sampler::~FairMQExample3Sampler() -{ -} - -void FairMQExample3Sampler::SetProperty(const int key, const string& value) -{ - switch (key) - { - case Text: - fText = value; - break; - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -string FairMQExample3Sampler::GetProperty(const int key, const string& default_ /*= ""*/) -{ - switch (key) - { - case Text: - return fText; - break; - default: - return FairMQDevice::GetProperty(key, default_); - } -} - -void FairMQExample3Sampler::SetProperty(const int key, const int value) -{ - switch (key) - { - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -int FairMQExample3Sampler::GetProperty(const int key, const int default_ /*= 0*/) -{ - switch (key) - { - default: - return FairMQDevice::GetProperty(key, default_); - } -} diff --git a/fairmq/examples/3-dds/FairMQExample3Sampler.h b/fairmq/examples/3-dds/FairMQExample3Sampler.h deleted file mode 100644 index 51fd86c1..00000000 --- a/fairmq/examples/3-dds/FairMQExample3Sampler.h +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample3Sampler.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE3SAMPLER_H_ -#define FAIRMQEXAMPLE3SAMPLER_H_ - -#include - -#include "FairMQDevice.h" - -class FairMQExample3Sampler : public FairMQDevice -{ - public: - enum - { - Text = FairMQDevice::Last, - Last - }; - FairMQExample3Sampler(); - virtual ~FairMQExample3Sampler(); - - static void CustomCleanup(void* data, void* hint); - - virtual void SetProperty(const int key, const std::string& value); - virtual std::string GetProperty(const int key, const std::string& default_ = ""); - virtual void SetProperty(const int key, const int value); - virtual int GetProperty(const int key, const int default_ = 0); - - protected: - std::string fText; - - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE3SAMPLER_H_ */ diff --git a/fairmq/examples/3-dds/FairMQExample3Sink.cxx b/fairmq/examples/3-dds/FairMQExample3Sink.cxx deleted file mode 100644 index c51def8a..00000000 --- a/fairmq/examples/3-dds/FairMQExample3Sink.cxx +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample3Sink.cxx - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQExample3Sink.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample3Sink::FairMQExample3Sink() -{ -} - -void FairMQExample3Sink::Run() -{ - while (CheckCurrentState(RUNNING)) - { - unique_ptr msg(fTransportFactory->CreateMessage()); - - if (fChannels.at("data-in").at(0).Receive(msg) >= 0) - { - LOG(INFO) << "Received message: \"" - << string(static_cast(msg->GetData()), msg->GetSize()) - << "\""; - } - } -} - -FairMQExample3Sink::~FairMQExample3Sink() -{ -} diff --git a/fairmq/examples/3-dds/FairMQExample3Sink.h b/fairmq/examples/3-dds/FairMQExample3Sink.h deleted file mode 100644 index b4006dc2..00000000 --- a/fairmq/examples/3-dds/FairMQExample3Sink.h +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample3Sink.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE3SINK_H_ -#define FAIRMQEXAMPLE3SINK_H_ - -#include "FairMQDevice.h" - -class FairMQExample3Sink : public FairMQDevice -{ - public: - FairMQExample3Sink(); - virtual ~FairMQExample3Sink(); - - protected: - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE3SINK_H_ */ diff --git a/fairmq/examples/3-dds/README.md b/fairmq/examples/3-dds/README.md deleted file mode 100644 index 0f02b67f..00000000 --- a/fairmq/examples/3-dds/README.md +++ /dev/null @@ -1,127 +0,0 @@ -Example 3: 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 those of Example 2, but now it can be easily distributed on different computing nodes without the need for manual reconfiguration of the devices. - -This example is compiled only if the DDS is found by CMake. Custom DDS installation location can be given to CMake like this: - -```bash -cmake -DDDS_PATH="/path/to/dds/install/dir/" .. -``` - -The description below outlines the minimal steps needed to run the example with DDS. For more details please refer to DDS documentation on [DDS Website](http://dds.gsi.de/). - -##### 1. The devices that bind their sockets need to advertise their bound addresses to DDS by writing a property. - -In our example Sampler and Sink bind their sockets. The bound addresses are available after the initial validation. The following code takes the address value and gives it to DDS: - -```C++ -sampler.ChangeState("INIT_DEVICE"); -sampler.WaitForInitialValidation(); - -dds::key_value::CKeyValue ddsKeyValue; -ddsKeyValue.putValue("SamplerOutputAddress", sampler.fChannels.at("data-out").at(0).GetAddress()); - -sampler.WaitForEndOfState("INIT_DEVICE"); -``` - -Same approach for the Sink. - -##### 2. The devices that connect their sockets need to read the addresses from DDS. - -The Processors in our example need the addresses of Sampler and Sink. They receive these from DDS via properties (sent in the step above): - -```C++ -dds::key_value::CKeyValue ddsKeyValue; -// Sampler properties -dds::key_value::CKeyValue::valuesMap_t samplerValues; -{ - mutex keyMutex; - condition_variable keyCondition; - - LOG(INFO) << "Subscribing and waiting for sampler output address."; - ddsKeyValue.subscribe([&keyCondition](const string& /*_key*/, const string& /*_value*/) { keyCondition.notify_all(); }); - ddsKeyValue.getValues("SamplerOutputAddress", &samplerValues); - while (samplerValues.empty()) - { - unique_lock lock(keyMutex); - keyCondition.wait_until(lock, chrono::system_clock::now() + chrono::milliseconds(1000)); - ddsKeyValue.getValues("SamplerOutputAddress", &samplerValues); - } -} -// Sink properties -// ... same as above, but for sinkValues ... - -processor.fChannels.at("data-in").at(0).UpdateAddress(samplerValues.begin()->second); -processor.fChannels.at("data-out").at(0).UpdateAddress(sinkValues.begin()->second); -``` - -After this step each device will have the necessary connection information. - -##### 3. 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 one worker `wn0` with 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@ -echo "DBG: SSH ENV Script" -#source setup.sh -@bash_end@ - -wn0, username@localhost, , /tmp/, 12 -``` - -##### 4. Write DDS topology file that describes which tasks (processes) to run and their topology and configuration. - -Take a look at `ex3-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 defines, containing their executables and exchanged properties. The `
` 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. - -##### 5. Start DDS server. - -The DDS server is started with: - -```bash -dds-server start -s -``` - -##### 6. Submit DDS Agents (configured in the hosts file). - -Agents are submitted with: -```bash -dds-submit --rms ssh --ssh-rms-cfg ex3-dds-hosts.cfg -``` -The `--rms` option defines a destination resource management system. The `--ssh-rms-cfg` specifies an SSH plug-in resource definition file. - -##### 7. Set the topology file. - -Point DDS to the topology file: -```bash -dds-topology --set ex3-dds-topology.xml -``` - -##### 8. Activate the topology. - -```bash -dds-topology --activate -``` - -##### 9. 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. - -##### 10. Stop DDS server/topology. - -The execution of tasks can be stopped with: -```bash -dds-topology --stop -``` -Or by stopping the DDS server: -```bash -dds-server stop -``` - -For a more complete DDS documentation please refer to [DDS Website](http://dds.gsi.de/). diff --git a/fairmq/examples/3-dds/ex3-dds-hosts.cfg b/fairmq/examples/3-dds/ex3-dds-hosts.cfg deleted file mode 100644 index 0518fc21..00000000 --- a/fairmq/examples/3-dds/ex3-dds-hosts.cfg +++ /dev/null @@ -1,6 +0,0 @@ -@bash_begin@ -echo "DBG: SSH ENV Script" -#source setup.sh -@bash_end@ - -wn0, username@localhost, , /tmp/, 12 diff --git a/fairmq/examples/3-dds/ex3-dds-topology.xml b/fairmq/examples/3-dds/ex3-dds-topology.xml deleted file mode 100644 index b1f28d37..00000000 --- a/fairmq/examples/3-dds/ex3-dds-topology.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - @CMAKE_BINARY_DIR@/bin/ex3-sampler-dds --id sampler --config-json-file @CMAKE_BINARY_DIR@/bin/config/ex3-devices.json - - SamplerOutputAddress - - - - - @CMAKE_BINARY_DIR@/bin/ex3-processor-dds --id processor --index %taskIndex% --config-json-file @CMAKE_BINARY_DIR@/bin/config/ex3-devices.json - - SamplerOutputAddress - SinkInputAddress - - - - - @CMAKE_BINARY_DIR@/bin/ex3-sink-dds --id sink --config-json-file @CMAKE_BINARY_DIR@/bin/config/ex3-devices.json - - SinkInputAddress - - - -
- Sampler - Sink - - Processor - -
- -
diff --git a/fairmq/examples/3-dds/ex3-devices.json b/fairmq/examples/3-dds/ex3-devices.json deleted file mode 100644 index 0cb27af7..00000000 --- a/fairmq/examples/3-dds/ex3-devices.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "fairMQOptions": - { - "device": - { - "id": "sampler", - "channel": - { - "name": "data-out", - "socket": - { - "type": "push", - "method": "bind", - "address": "" - } - } - }, - - "device": - { - "id": "processor", - "channel": - { - "name": "data-in", - "socket": - { - "type": "pull", - "method": "connect", - "address": "" - } - }, - "channel": - { - "name": "data-out", - "socket": - { - "type": "push", - "method": "connect", - "address": "" - } - } - }, - - "device": - { - "id": "sink", - "channel": - { - "name": "data-in", - "socket": - { - "type": "pull", - "method": "bind", - "address": "" - } - } - } - } -} diff --git a/fairmq/examples/3-dds/runExample3Processor.cxx b/fairmq/examples/3-dds/runExample3Processor.cxx deleted file mode 100644 index c3ab7a73..00000000 --- a/fairmq/examples/3-dds/runExample3Processor.cxx +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample2Processor.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include -#include -#include - -#include "boost/program_options.hpp" -#include // for DDS - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample3Processor.h" -#include "FairMQTools.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -#include "KeyValue.h" // DDS - -using namespace boost::program_options; - -int main(int argc, char** argv) -{ - FairMQExample3Processor processor; - processor.CatchSignals(); - - FairMQProgOptions config; - - try - { - int ddsTaskIndex = 0; - - options_description processorOptions("Processor options"); - processorOptions.add_options() - ("index", value(&ddsTaskIndex)->default_value(0), "DDS task index"); - - config.AddToCmdLineOptions(processorOptions); - - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - processor.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - - // Waiting for DDS properties - dds::key_value::CKeyValue ddsKeyValue; - // Sampler properties - dds::key_value::CKeyValue::valuesMap_t samplerValues; - { - mutex keyMutex; - condition_variable keyCondition; - - LOG(INFO) << "Subscribing and waiting for sampler output address."; - ddsKeyValue.subscribe([&keyCondition](const string& /*_key*/, const string& /*_value*/) { keyCondition.notify_all(); }); - ddsKeyValue.getValues("SamplerOutputAddress", &samplerValues); - while (samplerValues.empty()) - { - unique_lock lock(keyMutex); - keyCondition.wait_until(lock, chrono::system_clock::now() + chrono::milliseconds(1000)); - ddsKeyValue.getValues("SamplerOutputAddress", &samplerValues); - } - } - // Sink properties - dds::key_value::CKeyValue::valuesMap_t sinkValues; - { - mutex keyMutex; - condition_variable keyCondition; - - LOG(INFO) << "Subscribing and waiting for sink input address."; - ddsKeyValue.subscribe([&keyCondition](const string& /*_key*/, const string& /*_value*/) { keyCondition.notify_all(); }); - ddsKeyValue.getValues("SinkInputAddress", &sinkValues); - while (sinkValues.empty()) - { - unique_lock lock(keyMutex); - keyCondition.wait_until(lock, chrono::system_clock::now() + chrono::milliseconds(1000)); - ddsKeyValue.getValues("SinkInputAddress", &sinkValues); - } - } - - processor.fChannels.at("data-in").at(0).UpdateAddress(samplerValues.begin()->second); - processor.fChannels.at("data-out").at(0).UpdateAddress(sinkValues.begin()->second); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - processor.SetTransport(transportFactory); - - processor.SetProperty(FairMQExample3Processor::Id, id); - processor.SetProperty(FairMQExample3Processor::TaskIndex, ddsTaskIndex); - - processor.ChangeState("INIT_DEVICE"); - processor.WaitForEndOfState("INIT_DEVICE"); - - processor.ChangeState("INIT_TASK"); - processor.WaitForEndOfState("INIT_TASK"); - - processor.ChangeState("RUN"); - processor.WaitForEndOfState("RUN"); - - processor.ChangeState("RESET_TASK"); - processor.WaitForEndOfState("RESET_TASK"); - - processor.ChangeState("RESET_DEVICE"); - processor.WaitForEndOfState("RESET_DEVICE"); - - processor.ChangeState("END"); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/3-dds/runExample3Sampler.cxx b/fairmq/examples/3-dds/runExample3Sampler.cxx deleted file mode 100644 index e13731a7..00000000 --- a/fairmq/examples/3-dds/runExample3Sampler.cxx +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample2Sampler.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include -#include -#include -#include - -#include "boost/program_options.hpp" -#include // for DDS - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample3Sampler.h" -#include "FairMQTools.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -#include "KeyValue.h" // DDS - -using namespace boost::program_options; - -int main(int argc, char** argv) -{ - FairMQExample3Sampler sampler; - sampler.CatchSignals(); - - FairMQProgOptions config; - - try - { - std::string text; // text to be sent for processing. - std::string interfaceName; // name of the network interface to use for communication. - - options_description samplerOptions("Sampler options"); - samplerOptions.add_options() - ("text", value(&text)->default_value("Hello"), "Text to send out") - ("network-interface", value(&interfaceName)->default_value("eth0"), "Name of the network interface to use (e.g. eth0, ib0, wlan0, en0...)"); - - config.AddToCmdLineOptions(samplerOptions); - - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sampler.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sampler.SetTransport(transportFactory); - - sampler.SetProperty(FairMQExample3Sampler::Id, id); - sampler.SetProperty(FairMQExample3Sampler::Text, text); - - // Get the IP of the current host and store it for binding. - map IPs; - FairMQ::tools::getHostIPs(IPs); - stringstream ss; - // Check if ib0 (infiniband) interface is available, otherwise try eth0 or wlan0. - if (IPs.count(interfaceName)) - { - ss << "tcp://" << IPs[interfaceName] << ":1"; - } - else - { - LOG(INFO) << ss.str(); - LOG(ERROR) << "Could not find provided network interface: \"" << interfaceName << "\"!, exiting."; - exit(EXIT_FAILURE); - } - string initialOutputAddress = ss.str(); - - // Configure the found host IP for the channel. - // TCP port will be chosen randomly during the initialization (binding). - sampler.fChannels.at("data-out").at(0).UpdateAddress(initialOutputAddress); - - sampler.ChangeState("INIT_DEVICE"); - sampler.WaitForInitialValidation(); - - // Advertise the bound addresses via DDS property - LOG(INFO) << "Giving sampler output address to DDS."; - dds::key_value::CKeyValue ddsKeyValue; - ddsKeyValue.putValue("SamplerOutputAddress", sampler.fChannels.at("data-out").at(0).GetAddress()); - - sampler.WaitForEndOfState("INIT_DEVICE"); - - sampler.ChangeState("INIT_TASK"); - sampler.WaitForEndOfState("INIT_TASK"); - - sampler.ChangeState("RUN"); - sampler.WaitForEndOfState("RUN"); - - sampler.ChangeState("RESET_TASK"); - sampler.WaitForEndOfState("RESET_TASK"); - - sampler.ChangeState("RESET_DEVICE"); - sampler.WaitForEndOfState("RESET_DEVICE"); - - sampler.ChangeState("END"); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/3-dds/runExample3Sink.cxx b/fairmq/examples/3-dds/runExample3Sink.cxx deleted file mode 100644 index e4ede527..00000000 --- a/fairmq/examples/3-dds/runExample3Sink.cxx +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample2Sink.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include -#include -#include -#include - -#include "boost/program_options.hpp" -#include // for DDS - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample3Sink.h" -#include "FairMQTools.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -#include "KeyValue.h" // DDS - -using namespace boost::program_options; - -int main(int argc, char** argv) -{ - FairMQExample3Sink sink; - sink.CatchSignals(); - - FairMQProgOptions config; - - try - { - std::string interfaceName; // name of the network interface to use for communication. - - options_description sinkOptions("Sink options"); - sinkOptions.add_options() - ("network-interface", value(&interfaceName)->default_value("eth0"), "Name of the network interface to use (e.g. eth0, ib0, wlan0, en0...)"); - - config.AddToCmdLineOptions(sinkOptions); - - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sink.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sink.SetTransport(transportFactory); - - sink.SetProperty(FairMQExample3Sink::Id, id); - - // Get the IP of the current host and store it for binding. - map IPs; - FairMQ::tools::getHostIPs(IPs); - stringstream ss; - // Check if ib0 (infiniband) interface is available, otherwise try eth0 or wlan0. - if (IPs.count(interfaceName)) - { - ss << "tcp://" << IPs[interfaceName] << ":1"; - } - else - { - LOG(INFO) << ss.str(); - LOG(ERROR) << "Could not find provided network interface: \"" << interfaceName << "\"!, exiting."; - exit(EXIT_FAILURE); - } - string initialInputAddress = ss.str(); - - // Configure the found host IP for the channel. - // TCP port will be chosen randomly during the initialization (binding). - sink.fChannels.at("data-in").at(0).UpdateAddress(initialInputAddress); - - sink.ChangeState("INIT_DEVICE"); - sink.WaitForInitialValidation(); - - // Advertise the bound address via DDS property - LOG(INFO) << "Giving sink input address to DDS."; - dds::key_value::CKeyValue ddsKeyValue; - ddsKeyValue.putValue("SinkInputAddress", sink.fChannels.at("data-in").at(0).GetAddress()); - - sink.WaitForEndOfState("INIT_DEVICE"); - - sink.ChangeState("INIT_TASK"); - sink.WaitForEndOfState("INIT_TASK"); - - sink.ChangeState("RUN"); - sink.WaitForEndOfState("RUN"); - - sink.ChangeState("RESET_TASK"); - sink.WaitForEndOfState("RESET_TASK"); - - sink.ChangeState("RESET_DEVICE"); - sink.WaitForEndOfState("RESET_DEVICE"); - - sink.ChangeState("END"); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/4-copypush/CMakeLists.txt b/fairmq/examples/4-copypush/CMakeLists.txt deleted file mode 100644 index 2f05bc86..00000000 --- a/fairmq/examples/4-copypush/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence version 3 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/4-copypush/ex4-copypush.json ${CMAKE_BINARY_DIR}/bin/config/ex4-copypush.json) - -Set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/fairmq - ${CMAKE_SOURCE_DIR}/fairmq/devices - ${CMAKE_SOURCE_DIR}/fairmq/tools - ${CMAKE_SOURCE_DIR}/fairmq/options - ${CMAKE_SOURCE_DIR}/fairmq/examples/4-copypush - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} -) - -If(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/nanomsg - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -Else(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/zeromq - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -EndIf(NANOMSG_FOUND) - - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} -) - -Link_Directories(${LINK_DIRECTORIES}) - -Set(SRCS - "FairMQExample4Sampler.cxx" - "FairMQExample4Sink.cxx" -) - -Set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ -) - -Set(LIBRARY_NAME FairMQExample4) - -GENERATE_LIBRARY() - -Set(Exe_Names - ex4-sampler - ex4-sink -) - -Set(Exe_Source - runExample4Sampler.cxx - runExample4Sink.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -ForEach(_file RANGE 0 ${_length}) - list(GET Exe_Names ${_file} _name) - list(GET Exe_Source ${_file} _src) - Set(EXE_NAME ${_name}) - Set(SRCS ${_src}) - Set(DEPENDENCIES FairMQExample4) - GENERATE_EXECUTABLE() -EndForEach(_file RANGE 0 ${_length}) diff --git a/fairmq/examples/4-copypush/FairMQExample4Sampler.cxx b/fairmq/examples/4-copypush/FairMQExample4Sampler.cxx deleted file mode 100644 index 8bcad499..00000000 --- a/fairmq/examples/4-copypush/FairMQExample4Sampler.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample4Sampler.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include // unique_ptr - -#include -#include - -#include "FairMQExample4Sampler.h" -#include "FairMQLogger.h" - -FairMQExample4Sampler::FairMQExample4Sampler() -{ -} - -void FairMQExample4Sampler::Run() -{ - uint64_t counter = 0; - - while (CheckCurrentState(RUNNING)) - { - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - - uint64_t* number = new uint64_t(counter); - - std::unique_ptr msg(fTransportFactory->CreateMessage(number, sizeof(uint64_t))); - - LOG(INFO) << "Sending \"" << counter << "\""; - - if (fChannels.at("data-out").size() > 1) - { - for (int i = 1; i < fChannels.at("data-out").size(); ++i) - { - std::unique_ptr msgCopy(fTransportFactory->CreateMessage()); - msgCopy->Copy(msg); - fChannels.at("data-out").at(i).Send(msgCopy); - } - fChannels.at("data-out").at(0).Send(msg); - } - else - { - fChannels.at("data-out").at(0).Send(msg); - } - - ++counter; - } -} - -FairMQExample4Sampler::~FairMQExample4Sampler() -{ -} diff --git a/fairmq/examples/4-copypush/FairMQExample4Sampler.h b/fairmq/examples/4-copypush/FairMQExample4Sampler.h deleted file mode 100644 index 2f7ff53e..00000000 --- a/fairmq/examples/4-copypush/FairMQExample4Sampler.h +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample4Sampler.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE4SAMPLER_H_ -#define FAIRMQEXAMPLE4SAMPLER_H_ - -#include - -#include "FairMQDevice.h" - -class FairMQExample4Sampler : public FairMQDevice -{ - public: - FairMQExample4Sampler(); - virtual ~FairMQExample4Sampler(); - - protected: - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE4SAMPLER_H_ */ diff --git a/fairmq/examples/4-copypush/FairMQExample4Sink.cxx b/fairmq/examples/4-copypush/FairMQExample4Sink.cxx deleted file mode 100644 index 2444cade..00000000 --- a/fairmq/examples/4-copypush/FairMQExample4Sink.cxx +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample4Sink.cxx - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include - -#include -#include - -#include "FairMQExample4Sink.h" -#include "FairMQLogger.h" - -FairMQExample4Sink::FairMQExample4Sink() -{ -} - -void FairMQExample4Sink::Run() -{ - while (CheckCurrentState(RUNNING)) - { - std::unique_ptr msg(fTransportFactory->CreateMessage()); - - if (fChannels.at("data-in").at(0).Receive(msg) >= 0) - { - LOG(INFO) << "Received message: \"" << *(static_cast(msg->GetData())) << "\""; - } - } -} - -FairMQExample4Sink::~FairMQExample4Sink() -{ -} diff --git a/fairmq/examples/4-copypush/FairMQExample4Sink.h b/fairmq/examples/4-copypush/FairMQExample4Sink.h deleted file mode 100644 index 799ca84f..00000000 --- a/fairmq/examples/4-copypush/FairMQExample4Sink.h +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample4Sink.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE4SINK_H_ -#define FAIRMQEXAMPLE4SINK_H_ - -#include "FairMQDevice.h" - -class FairMQExample4Sink : public FairMQDevice -{ - public: - FairMQExample4Sink(); - virtual ~FairMQExample4Sink(); - - protected: - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE4SINK_H_ */ diff --git a/fairmq/examples/4-copypush/README.md b/fairmq/examples/4-copypush/README.md deleted file mode 100644 index 8ba7321d..00000000 --- a/fairmq/examples/4-copypush/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Example 4: Copy & Push -=============== - -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-PATTERN** pattern, this ensures that all receivers are connected and no data is lost, but requires additional sockets. diff --git a/fairmq/examples/4-copypush/ex4-copypush.json b/fairmq/examples/4-copypush/ex4-copypush.json deleted file mode 100644 index b5907cdb..00000000 --- a/fairmq/examples/4-copypush/ex4-copypush.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "fairMQOptions": - { - "device": - { - "id": "sampler1", - "channel": - { - "name": "data-out", - "socket": - { - "type": "push", - "method": "bind", - "address": "tcp://*:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - }, - "socket": - { - "type": "push", - "method": "bind", - "address": "tcp://*:5556", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - }, - - "device": - { - "id": "sink1", - "channel": - { - "name": "data-in", - "socket": - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - }, - - "device": - { - "id": "sink2", - "channel": - { - "name": "data-in", - "socket": - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5556", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - } - } -} - diff --git a/fairmq/examples/4-copypush/runExample4Sampler.cxx b/fairmq/examples/4-copypush/runExample4Sampler.cxx deleted file mode 100644 index ddfd7002..00000000 --- a/fairmq/examples/4-copypush/runExample4Sampler.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample4Sampler.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample4Sampler.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -int main(int argc, char** argv) -{ - FairMQExample4Sampler sampler; - sampler.CatchSignals(); - - FairMQProgOptions config; - - try - { - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sampler.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sampler.SetTransport(transportFactory); - - sampler.SetProperty(FairMQExample4Sampler::Id, id); - - sampler.ChangeState("INIT_DEVICE"); - sampler.WaitForEndOfState("INIT_DEVICE"); - - sampler.ChangeState("INIT_TASK"); - sampler.WaitForEndOfState("INIT_TASK"); - - sampler.ChangeState("RUN"); - sampler.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/4-copypush/runExample4Sink.cxx b/fairmq/examples/4-copypush/runExample4Sink.cxx deleted file mode 100644 index 9c5cab08..00000000 --- a/fairmq/examples/4-copypush/runExample4Sink.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample4Sink.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample4Sink.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -int main(int argc, char** argv) -{ - FairMQExample4Sink sink; - sink.CatchSignals(); - - FairMQProgOptions config; - - try - { - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sink.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sink.SetTransport(transportFactory); - - sink.SetProperty(FairMQExample4Sink::Id, id); - - sink.ChangeState("INIT_DEVICE"); - sink.WaitForEndOfState("INIT_DEVICE"); - - sink.ChangeState("INIT_TASK"); - sink.WaitForEndOfState("INIT_TASK"); - - sink.ChangeState("RUN"); - sink.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/5-req-rep/CMakeLists.txt b/fairmq/examples/5-req-rep/CMakeLists.txt deleted file mode 100644 index fbfd0368..00000000 --- a/fairmq/examples/5-req-rep/CMakeLists.txt +++ /dev/null @@ -1,85 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence version 3 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -Set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/fairmq - ${CMAKE_SOURCE_DIR}/fairmq/devices - ${CMAKE_SOURCE_DIR}/fairmq/tools - ${CMAKE_SOURCE_DIR}/fairmq/options - ${CMAKE_SOURCE_DIR}/fairmq/examples/5-req-rep - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} -) - -If(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/nanomsg - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -Else(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/zeromq - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -EndIf(NANOMSG_FOUND) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} -) - -Link_Directories(${LINK_DIRECTORIES}) - -set(SRCS - "FairMQExample5Client.cxx" - "FairMQExample5Server.cxx" -) - -set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ -) - -set(LIBRARY_NAME FairMQExample5) - -GENERATE_LIBRARY() - -set(Exe_Names - ex5-client - ex5-server -) - -set(Exe_Source - runExample5Client.cxx - runExample5Server.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -ForEach(_file RANGE 0 ${_length}) - list(GET Exe_Names ${_file} _name) - list(GET Exe_Source ${_file} _src) - set(EXE_NAME ${_name}) - set(SRCS ${_src}) - set(DEPENDENCIES FairMQExample5) - GENERATE_EXECUTABLE() -EndForEach(_file RANGE 0 ${_length}) diff --git a/fairmq/examples/5-req-rep/FairMQExample5Client.cxx b/fairmq/examples/5-req-rep/FairMQExample5Client.cxx deleted file mode 100644 index 4968c5bc..00000000 --- a/fairmq/examples/5-req-rep/FairMQExample5Client.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample5Client.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQExample5Client.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample5Client::FairMQExample5Client() - : fText() -{ -} - -FairMQExample5Client::~FairMQExample5Client() -{ -} - -void FairMQExample5Client::CustomCleanup(void *data, void *hint) -{ - delete (string*)hint; -} - -void FairMQExample5Client::Run() -{ - while (CheckCurrentState(RUNNING)) - { - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - - string* text = new string(fText); - - unique_ptr request(fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text)); - unique_ptr reply(fTransportFactory->CreateMessage()); - - LOG(INFO) << "Sending \"" << fText << "\" to server."; - - if (fChannels.at("data").at(0).Send(request) > 0) - { - if (fChannels.at("data").at(0).Receive(reply) >= 0) - { - LOG(INFO) << "Received reply from server: \"" << string(static_cast(reply->GetData()), reply->GetSize()) << "\""; - } - } - } -} - - -void FairMQExample5Client::SetProperty(const int key, const string& value) -{ - switch (key) - { - case Text: - fText = value; - break; - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -string FairMQExample5Client::GetProperty(const int key, const string& default_ /*= ""*/) -{ - switch (key) - { - case Text: - return fText; - break; - default: - return FairMQDevice::GetProperty(key, default_); - } -} - -void FairMQExample5Client::SetProperty(const int key, const int value) -{ - switch (key) - { - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -int FairMQExample5Client::GetProperty(const int key, const int default_ /*= 0*/) -{ - switch (key) - { - default: - return FairMQDevice::GetProperty(key, default_); - } -} diff --git a/fairmq/examples/5-req-rep/FairMQExample5Client.h b/fairmq/examples/5-req-rep/FairMQExample5Client.h deleted file mode 100644 index 53964b52..00000000 --- a/fairmq/examples/5-req-rep/FairMQExample5Client.h +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample5Client.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE5CLIENT_H_ -#define FAIRMQEXAMPLE5CLIENT_H_ - -#include - -#include "FairMQDevice.h" - -class FairMQExample5Client : public FairMQDevice -{ - public: - enum - { - Text = FairMQDevice::Last, - Last - }; - FairMQExample5Client(); - virtual ~FairMQExample5Client(); - - static void CustomCleanup(void* data, void* hint); - - virtual void SetProperty(const int key, const std::string& value); - virtual std::string GetProperty(const int key, const std::string& default_ = ""); - virtual void SetProperty(const int key, const int value); - virtual int GetProperty(const int key, const int default_ = 0); - - protected: - std::string fText; - - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLECLIENT_H_ */ diff --git a/fairmq/examples/5-req-rep/FairMQExample5Server.cxx b/fairmq/examples/5-req-rep/FairMQExample5Server.cxx deleted file mode 100644 index 72c33c1f..00000000 --- a/fairmq/examples/5-req-rep/FairMQExample5Server.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample5Server.cxx - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQExample5Server.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample5Server::FairMQExample5Server() -{ -} - -void FairMQExample5Server::CustomCleanup(void *data, void *hint) -{ - delete (string*)hint; -} - -void FairMQExample5Server::Run() -{ - while (CheckCurrentState(RUNNING)) - { - unique_ptr request(fTransportFactory->CreateMessage()); - - if (fChannels.at("data").at(0).Receive(request) >= 0) - { - LOG(INFO) << "Received request from client: \"" << string(static_cast(request->GetData()), request->GetSize()) << "\""; - - string* text = new string("Thank you for the \"" + string(static_cast(request->GetData()), request->GetSize()) + "\"!"); - - LOG(INFO) << "Sending reply to client."; - - unique_ptr reply(fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text)); - - fChannels.at("data").at(0).Send(reply); - } - } -} - -FairMQExample5Server::~FairMQExample5Server() -{ -} diff --git a/fairmq/examples/5-req-rep/FairMQExample5Server.h b/fairmq/examples/5-req-rep/FairMQExample5Server.h deleted file mode 100644 index 8f9a607b..00000000 --- a/fairmq/examples/5-req-rep/FairMQExample5Server.h +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample5Server.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE5SERVER_H_ -#define FAIRMQEXAMPLE5SERVER_H_ - -#include "FairMQDevice.h" - -class FairMQExample5Server : public FairMQDevice -{ - public: - FairMQExample5Server(); - virtual ~FairMQExample5Server(); - - static void CustomCleanup(void *data, void* hint); - - protected: - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE5SERVER_H_ */ diff --git a/fairmq/examples/5-req-rep/README.md b/fairmq/examples/5-req-rep/README.md deleted file mode 100644 index 783e892c..00000000 --- a/fairmq/examples/5-req-rep/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Example 5: Request & Reply -=============== - -This topology contains two devices that communicate with each other via the **REQUEST-REPLY** pettern. Bidirectional communication via a single socket. diff --git a/fairmq/examples/5-req-rep/runExample5Client.cxx b/fairmq/examples/5-req-rep/runExample5Client.cxx deleted file mode 100644 index 087861ac..00000000 --- a/fairmq/examples/5-req-rep/runExample5Client.cxx +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExampleClient.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "boost/program_options.hpp" - -#include "FairMQLogger.h" -#include "FairMQExample5Client.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -using namespace std; - -typedef struct DeviceOptions -{ - DeviceOptions() : - text() {} - - string text; -} DeviceOptions_t; - -inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) -{ - if (_options == NULL) - throw runtime_error("Internal error: options' container is empty."); - - namespace bpo = boost::program_options; - bpo::options_description desc("Options"); - desc.add_options() - ("text,t", bpo::value()->default_value("something"), "Text to send to server") - ("help", "Print help messages"); - - bpo::variables_map vm; - bpo::store(bpo::parse_command_line(_argc, _argv, desc), vm); - - if (vm.count("help")) - { - LOG(INFO) << "EPN" << endl << desc; - return false; - } - - bpo::notify(vm); - - if ( vm.count("text") ) - _options->text = vm["text"].as(); - - return true; -} - -int main(int argc, char** argv) -{ - FairMQExample5Client client; - client.CatchSignals(); - - DeviceOptions_t options; - try - { - if (!parse_cmd_line(argc, argv, &options)) - return 0; - } - catch (exception& e) - { - LOG(ERROR) << e.what(); - return 1; - } - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - client.SetTransport(transportFactory); - - client.SetProperty(FairMQExample5Client::Id, "client"); - client.SetProperty(FairMQExample5Client::Text, options.text); - client.SetProperty(FairMQExample5Client::NumIoThreads, 1); - - FairMQChannel requestChannel("req", "connect", "tcp://localhost:5005"); - requestChannel.UpdateSndBufSize(10000); - requestChannel.UpdateRcvBufSize(10000); - requestChannel.UpdateRateLogging(1); - - client.fChannels["data"].push_back(requestChannel); - - client.ChangeState("INIT_DEVICE"); - client.WaitForEndOfState("INIT_DEVICE"); - - client.ChangeState("INIT_TASK"); - client.WaitForEndOfState("INIT_TASK"); - - client.ChangeState("RUN"); - client.InteractiveStateLoop(); - - return 0; -} diff --git a/fairmq/examples/5-req-rep/runExample5Server.cxx b/fairmq/examples/5-req-rep/runExample5Server.cxx deleted file mode 100644 index 541d7216..00000000 --- a/fairmq/examples/5-req-rep/runExample5Server.cxx +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExampleServer.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "FairMQLogger.h" -#include "FairMQExample5Server.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -using namespace std; - -int main(int argc, char** argv) -{ - FairMQExample5Server server; - server.CatchSignals(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - server.SetTransport(transportFactory); - - server.SetProperty(FairMQExample5Server::Id, "server"); - server.SetProperty(FairMQExample5Server::NumIoThreads, 1); - - FairMQChannel replyChannel("rep", "bind", "tcp://*:5005"); - replyChannel.UpdateSndBufSize(10000); - replyChannel.UpdateRcvBufSize(10000); - replyChannel.UpdateRateLogging(1); - - server.fChannels["data"].push_back(replyChannel); - - server.ChangeState("INIT_DEVICE"); - server.WaitForEndOfState("INIT_DEVICE"); - - server.ChangeState("INIT_TASK"); - server.WaitForEndOfState("INIT_TASK"); - - server.ChangeState("RUN"); - server.InteractiveStateLoop(); - - return 0; -} diff --git a/fairmq/examples/6-multiple-channels/CMakeLists.txt b/fairmq/examples/6-multiple-channels/CMakeLists.txt deleted file mode 100644 index 64ac1f52..00000000 --- a/fairmq/examples/6-multiple-channels/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence version 3 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/6-multiple-channels/ex6-multiple-channels.json ${CMAKE_BINARY_DIR}/bin/config/ex6-multiple-channels.json) - -Set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/fairmq - ${CMAKE_SOURCE_DIR}/fairmq/devices - ${CMAKE_SOURCE_DIR}/fairmq/tools - ${CMAKE_SOURCE_DIR}/fairmq/options - ${CMAKE_SOURCE_DIR}/fairmq/examples/6-multiple-channels - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} -) - -If(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/nanomsg - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -Else(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/zeromq - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -EndIf(NANOMSG_FOUND) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} -) - -Link_Directories(${LINK_DIRECTORIES}) - -Set(SRCS - "FairMQExample6Sampler.cxx" - "FairMQExample6Sink.cxx" - "FairMQExample6Broadcaster.cxx" -) - -Set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ -) - -Set(LIBRARY_NAME FairMQExample6) - -GENERATE_LIBRARY() - -Set(Exe_Names - ex6-sampler - ex6-sink - ex6-broadcaster -) - -Set(Exe_Source - runExample6Sampler.cxx - runExample6Sink.cxx - runExample6Broadcaster.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -ForEach(_file RANGE 0 ${_length}) - list(GET Exe_Names ${_file} _name) - list(GET Exe_Source ${_file} _src) - set(EXE_NAME ${_name}) - set(SRCS ${_src}) - set(DEPENDENCIES FairMQExample6) - GENERATE_EXECUTABLE() -EndForEach(_file RANGE 0 ${_length}) diff --git a/fairmq/examples/6-multiple-channels/FairMQExample6Broadcaster.cxx b/fairmq/examples/6-multiple-channels/FairMQExample6Broadcaster.cxx deleted file mode 100644 index 5130d8f1..00000000 --- a/fairmq/examples/6-multiple-channels/FairMQExample6Broadcaster.cxx +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample6Broadcaster.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include // unique_ptr -#include - -#include - -#include "FairMQExample6Broadcaster.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample6Broadcaster::FairMQExample6Broadcaster() -{ -} - -void FairMQExample6Broadcaster::CustomCleanup(void *data, void *object) -{ - delete (string*)object; -} - -void FairMQExample6Broadcaster::Run() -{ - while (CheckCurrentState(RUNNING)) - { - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - - string* text = new string("OK"); - unique_ptr msg(fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text)); - LOG(INFO) << "Sending \"" << "OK" << "\""; - fChannels.at("broadcast-out").at(0).Send(msg); - } -} - -FairMQExample6Broadcaster::~FairMQExample6Broadcaster() -{ -} diff --git a/fairmq/examples/6-multiple-channels/FairMQExample6Broadcaster.h b/fairmq/examples/6-multiple-channels/FairMQExample6Broadcaster.h deleted file mode 100644 index cbd5198d..00000000 --- a/fairmq/examples/6-multiple-channels/FairMQExample6Broadcaster.h +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample6Broadcaster.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE6BROADCASTER_H_ -#define FAIRMQEXAMPLE6BROADCASTER_H_ - -#include "FairMQDevice.h" - -class FairMQExample6Broadcaster : public FairMQDevice -{ - public: - FairMQExample6Broadcaster(); - virtual ~FairMQExample6Broadcaster(); - - static void CustomCleanup(void* data, void* hint); - - protected: - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE6BROADCASTER_H_ */ diff --git a/fairmq/examples/6-multiple-channels/FairMQExample6Sampler.cxx b/fairmq/examples/6-multiple-channels/FairMQExample6Sampler.cxx deleted file mode 100644 index d54b074d..00000000 --- a/fairmq/examples/6-multiple-channels/FairMQExample6Sampler.cxx +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample6Sampler.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include // unique_ptr - -#include - -#include "FairMQExample6Sampler.h" -#include "FairMQPoller.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample6Sampler::FairMQExample6Sampler() - : fText() -{ -} - -void FairMQExample6Sampler::CustomCleanup(void *data, void *object) -{ - delete (string*)object; -} - -void FairMQExample6Sampler::Run() -{ - std::unique_ptr poller(fTransportFactory->CreatePoller(fChannels, { "data-out", "broadcast-in" })); - - while (CheckCurrentState(RUNNING)) - { - poller->Poll(-1); - - if (poller->CheckInput("broadcast-in", 0)) - { - unique_ptr msg(fTransportFactory->CreateMessage()); - - if (fChannels.at("broadcast-in").at(0).Receive(msg) > 0) - { - LOG(INFO) << "Received broadcast: \"" - << string(static_cast(msg->GetData()), msg->GetSize()) - << "\""; - } - } // if (poller->CheckInput("broadcast-in", 0)) - - if (poller->CheckOutput("data-out", 0)) - { - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - - string* text = new string(fText); - - unique_ptr msg(fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text)); - - LOG(INFO) << "Sending \"" << fText << "\""; - - fChannels.at("data-out").at(0).Send(msg); - } // if (poller->CheckOutput("data-out", 0)) - } // while (CheckCurrentState(RUNNING)) -} - -FairMQExample6Sampler::~FairMQExample6Sampler() -{ -} - -void FairMQExample6Sampler::SetProperty(const int key, const string& value) -{ - switch (key) - { - case Text: - fText = value; - break; - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -string FairMQExample6Sampler::GetProperty(const int key, const string& default_ /*= ""*/) -{ - switch (key) - { - case Text: - return fText; - break; - default: - return FairMQDevice::GetProperty(key, default_); - } -} - -void FairMQExample6Sampler::SetProperty(const int key, const int value) -{ - switch (key) - { - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -int FairMQExample6Sampler::GetProperty(const int key, const int default_ /*= 0*/) -{ - switch (key) - { - default: - return FairMQDevice::GetProperty(key, default_); - } -} diff --git a/fairmq/examples/6-multiple-channels/FairMQExample6Sampler.h b/fairmq/examples/6-multiple-channels/FairMQExample6Sampler.h deleted file mode 100644 index bbdfd9ba..00000000 --- a/fairmq/examples/6-multiple-channels/FairMQExample6Sampler.h +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample6Sampler.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE6SAMPLER_H_ -#define FAIRMQEXAMPLE6SAMPLER_H_ - -#include - -#include "FairMQDevice.h" - -class FairMQExample6Sampler : public FairMQDevice -{ - public: - enum - { - Text = FairMQDevice::Last, - Last - }; - FairMQExample6Sampler(); - virtual ~FairMQExample6Sampler(); - - static void CustomCleanup(void* data, void* hint); - - virtual void SetProperty(const int key, const std::string& value); - virtual std::string GetProperty(const int key, const std::string& default_ = ""); - virtual void SetProperty(const int key, const int value); - virtual int GetProperty(const int key, const int default_ = 0); - - protected: - std::string fText; - - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE6SAMPLER_H_ */ diff --git a/fairmq/examples/6-multiple-channels/FairMQExample6Sink.cxx b/fairmq/examples/6-multiple-channels/FairMQExample6Sink.cxx deleted file mode 100644 index f28ee077..00000000 --- a/fairmq/examples/6-multiple-channels/FairMQExample6Sink.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample6Sink.cxx - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include "FairMQExample6Sink.h" -#include "FairMQPoller.h" -#include "FairMQLogger.h" - -using namespace std; - -FairMQExample6Sink::FairMQExample6Sink() -{ -} - -void FairMQExample6Sink::Run() -{ - std::unique_ptr poller(fTransportFactory->CreatePoller(fChannels, { "data-in", "broadcast-in" })); - - while (CheckCurrentState(RUNNING)) - { - poller->Poll(-1); - - if (poller->CheckInput("broadcast-in", 0)) - { - unique_ptr msg(fTransportFactory->CreateMessage()); - - if (fChannels.at("broadcast-in").at(0).Receive(msg) > 0) - { - LOG(INFO) << "Received broadcast: \"" - << string(static_cast(msg->GetData()), msg->GetSize()) - << "\""; - } - } - - if (poller->CheckInput("data-in", 0)) - { - unique_ptr msg(fTransportFactory->CreateMessage()); - - if (fChannels.at("data-in").at(0).Receive(msg) > 0) - { - LOG(INFO) << "Received message: \"" - << string(static_cast(msg->GetData()), msg->GetSize()) - << "\""; - } - } - } -} - -FairMQExample6Sink::~FairMQExample6Sink() -{ -} diff --git a/fairmq/examples/6-multiple-channels/FairMQExample6Sink.h b/fairmq/examples/6-multiple-channels/FairMQExample6Sink.h deleted file mode 100644 index c0b5b5ed..00000000 --- a/fairmq/examples/6-multiple-channels/FairMQExample6Sink.h +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample6Sink.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE6SINK_H_ -#define FAIRMQEXAMPLE6SINK_H_ - -#include "FairMQDevice.h" - -class FairMQExample6Sink : public FairMQDevice -{ - public: - FairMQExample6Sink(); - virtual ~FairMQExample6Sink(); - - protected: - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE6SINK_H_ */ diff --git a/fairmq/examples/6-multiple-channels/README.md b/fairmq/examples/6-multiple-channels/README.md deleted file mode 100644 index ab3a8173..00000000 --- a/fairmq/examples/6-multiple-channels/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Example 6: Multiple Channels -=============== - -This example demonstrates how to work with multiple channels and multiplex between them. - -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 `FairMQPoller`. diff --git a/fairmq/examples/6-multiple-channels/ex6-multiple-channels.json b/fairmq/examples/6-multiple-channels/ex6-multiple-channels.json deleted file mode 100644 index 7479f2bd..00000000 --- a/fairmq/examples/6-multiple-channels/ex6-multiple-channels.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "fairMQOptions": - { - "device": - { - "id": "sampler1", - "channel": - { - "name": "data-out", - "socket": - { - "type": "push", - "method": "bind", - "address": "tcp://*:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - }, - "channel": - { - "name": "broadcast-in", - "socket": - { - "type": "sub", - "method": "connect", - "address": "tcp://localhost:5005", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - }, - - "device": - { - "id": "sink1", - "channel": - { - "name": "data-in", - "socket": - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - }, - "channel": - { - "name": "broadcast-in", - "socket": - { - "type": "sub", - "method": "connect", - "address": "tcp://localhost:5005", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - }, - - "device": - { - "id": "broadcaster1", - "channel": - { - "name": "broadcast-out", - "socket": - { - "type": "pub", - "method": "bind", - "address": "tcp://*:5005", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - } - } -} - diff --git a/fairmq/examples/6-multiple-channels/runExample6Broadcaster.cxx b/fairmq/examples/6-multiple-channels/runExample6Broadcaster.cxx deleted file mode 100644 index 0f719a28..00000000 --- a/fairmq/examples/6-multiple-channels/runExample6Broadcaster.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample6Broadcaster.cxx - * - * @since 2013-04-23 - * @author A. Rybalchenko - */ - -#include - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample6Broadcaster.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -int main(int argc, char** argv) -{ - FairMQExample6Broadcaster broadcaster; - broadcaster.CatchSignals(); - - FairMQProgOptions config; - - try - { - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - broadcaster.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - broadcaster.SetTransport(transportFactory); - - broadcaster.SetProperty(FairMQExample6Broadcaster::Id, id); - - broadcaster.ChangeState("INIT_DEVICE"); - broadcaster.WaitForEndOfState("INIT_DEVICE"); - - broadcaster.ChangeState("INIT_TASK"); - broadcaster.WaitForEndOfState("INIT_TASK"); - - broadcaster.ChangeState("RUN"); - broadcaster.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/6-multiple-channels/runExample6Sampler.cxx b/fairmq/examples/6-multiple-channels/runExample6Sampler.cxx deleted file mode 100644 index 11759ebc..00000000 --- a/fairmq/examples/6-multiple-channels/runExample6Sampler.cxx +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample6Sampler.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "boost/program_options.hpp" - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample6Sampler.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -using namespace boost::program_options; - -int main(int argc, char** argv) -{ - FairMQExample6Sampler sampler; - sampler.CatchSignals(); - - FairMQProgOptions config; - - try - { - std::string text; - - options_description samplerOptions("Sampler options"); - samplerOptions.add_options() - ("text", value(&text)->default_value("Hello"), "Text to send out"); - - config.AddToCmdLineOptions(samplerOptions); - - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sampler.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sampler.SetTransport(transportFactory); - - sampler.SetProperty(FairMQExample6Sampler::Id, id); - sampler.SetProperty(FairMQExample6Sampler::Text, text); - - sampler.ChangeState("INIT_DEVICE"); - sampler.WaitForEndOfState("INIT_DEVICE"); - - sampler.ChangeState("INIT_TASK"); - sampler.WaitForEndOfState("INIT_TASK"); - - sampler.ChangeState("RUN"); - sampler.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/6-multiple-channels/runExample6Sink.cxx b/fairmq/examples/6-multiple-channels/runExample6Sink.cxx deleted file mode 100644 index 4c8b1447..00000000 --- a/fairmq/examples/6-multiple-channels/runExample6Sink.cxx +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample6Sink.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "boost/program_options.hpp" - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample6Sink.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -using namespace boost::program_options; - -int main(int argc, char** argv) -{ - FairMQExample6Sink sink; - sink.CatchSignals(); - - FairMQProgOptions config; - - try - { - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sink.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sink.SetTransport(transportFactory); - - sink.SetProperty(FairMQExample6Sink::Id, id); - - sink.ChangeState("INIT_DEVICE"); - sink.WaitForEndOfState("INIT_DEVICE"); - - sink.ChangeState("INIT_TASK"); - sink.WaitForEndOfState("INIT_TASK"); - - sink.ChangeState("RUN"); - sink.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/7-parameters/CMakeLists.txt b/fairmq/examples/7-parameters/CMakeLists.txt deleted file mode 100644 index 4129b047..00000000 --- a/fairmq/examples/7-parameters/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence version 3 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/7-parameters/ex7-client.json ${CMAKE_BINARY_DIR}/bin/config/ex7-client.json) - -Set(INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq - ${CMAKE_SOURCE_DIR}/fairmq/devices - ${CMAKE_SOURCE_DIR}/fairmq/tools - ${CMAKE_SOURCE_DIR}/fairmq/options - ${CMAKE_SOURCE_DIR}/fairmq/examples/7-parameters - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} -) - -If(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/nanomsg - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -Else(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/zeromq - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -EndIf(NANOMSG_FOUND) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} - ${ROOT_LIBRARY_DIR} -) - -Link_Directories(${LINK_DIRECTORIES}) - -set(SRCS - "FairMQExample7ParOne.cxx" - "FairMQExample7ContFact.cxx" -) - -Set(NO_DICT_SRCS - "FairMQExample7Client.cxx" -) - -set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ - Base - MCStack -) - -set(LINKDEF "FairMQExample7LinkDef.h") - -set(LIBRARY_NAME FairMQExample7) - -GENERATE_LIBRARY() - -set(Exe_Names - ex7-client -) - -set(Exe_Source - runExample7Client.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -ForEach(_file RANGE 0 ${_length}) - list(GET Exe_Names ${_file} _name) - list(GET Exe_Source ${_file} _src) - set(EXE_NAME ${_name}) - set(SRCS ${_src}) - set(DEPENDENCIES FairMQExample7) - GENERATE_EXECUTABLE() -EndForEach(_file RANGE 0 ${_length}) diff --git a/fairmq/examples/7-parameters/FairMQExample7Client.cxx b/fairmq/examples/7-parameters/FairMQExample7Client.cxx deleted file mode 100644 index 26ae81aa..00000000 --- a/fairmq/examples/7-parameters/FairMQExample7Client.cxx +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample7Client.cpp - * - * @since 2015-10-26 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQLogger.h" -#include "FairMQExample7Client.h" -#include "FairMQExample7ParOne.h" - -#include "TMessage.h" -#include "Rtypes.h" - -using namespace std; - -FairMQExample7Client::FairMQExample7Client() : - fRunId(0), - fParameterName() -{ -} - -FairMQExample7Client::~FairMQExample7Client() -{ -} - -void FairMQExample7Client::CustomCleanup(void *data, void *hint) -{ - delete (string*)hint; -} - -// special class to expose protected TMessage constructor -class FairMQExample7TMessage : public TMessage -{ - public: - FairMQExample7TMessage(void* buf, Int_t len) - : TMessage(buf, len) - { - ResetBit(kIsOwner); - } -}; - -void FairMQExample7Client::Run() -{ - int runId = 2001; - - while (CheckCurrentState(RUNNING)) - { - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - - string* reqStr = new string(fParameterName + "," + to_string(runId)); - - LOG(INFO) << "Requesting parameter \"" << fParameterName << "\" for Run ID " << runId << "."; - - unique_ptr req(fTransportFactory->CreateMessage(const_cast(reqStr->c_str()), reqStr->length(), CustomCleanup, reqStr)); - unique_ptr rep(fTransportFactory->CreateMessage()); - - if (fChannels.at("data").at(0).Send(req) > 0) - { - if (fChannels.at("data").at(0).Receive(rep) > 0) - { - FairMQExample7TMessage tmsg(rep->GetData(), rep->GetSize()); - FairMQExample7ParOne* par = (FairMQExample7ParOne*)(tmsg.ReadObject(tmsg.GetClass())); - LOG(INFO) << "Received parameter from the server:"; - par->print(); - } - } - - runId++; - if (runId == 2101) - { - runId = 2001; - } - } -} - - -void FairMQExample7Client::SetProperty(const int key, const string& value) -{ - switch (key) - { - case ParameterName: - fParameterName = value; - break; - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -string FairMQExample7Client::GetProperty(const int key, const string& default_ /*= ""*/) -{ - switch (key) - { - case ParameterName: - return fParameterName; - break; - default: - return FairMQDevice::GetProperty(key, default_); - } -} - -void FairMQExample7Client::SetProperty(const int key, const int value) -{ - switch (key) - { - default: - FairMQDevice::SetProperty(key, value); - break; - } -} - -int FairMQExample7Client::GetProperty(const int key, const int default_ /*= 0*/) -{ - switch (key) - { - default: - return FairMQDevice::GetProperty(key, default_); - } -} diff --git a/fairmq/examples/7-parameters/FairMQExample7Client.h b/fairmq/examples/7-parameters/FairMQExample7Client.h deleted file mode 100644 index b9f8233c..00000000 --- a/fairmq/examples/7-parameters/FairMQExample7Client.h +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample7Client.h - * - * @since 2015-10-26 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE7CLIENT_H_ -#define FAIRMQEXAMPLE7CLIENT_H_ - -#include - -#include "FairMQDevice.h" - -class FairMQExample7Client : public FairMQDevice -{ - public: - enum - { - ParameterName = FairMQDevice::Last, - Last - }; - FairMQExample7Client(); - virtual ~FairMQExample7Client(); - - static void CustomCleanup(void* data, void* hint); - - virtual void SetProperty(const int key, const std::string& value); - virtual std::string GetProperty(const int key, const std::string& default_ = ""); - virtual void SetProperty(const int key, const int value); - virtual int GetProperty(const int key, const int default_ = 0); - - protected: - virtual void Run(); - - private: - int fRunId; - std::string fParameterName; -}; - -#endif /* FAIRMQEXAMPLE7CLIENT_H_ */ diff --git a/fairmq/examples/7-parameters/FairMQExample7ContFact.cxx b/fairmq/examples/7-parameters/FairMQExample7ContFact.cxx deleted file mode 100644 index 96737a8b..00000000 --- a/fairmq/examples/7-parameters/FairMQExample7ContFact.cxx +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -#include - -#include "FairRuntimeDb.h" - -#include "FairMQExample7ContFact.h" -#include "FairMQExample7ParOne.h" - -static FairMQExample7ContFact gFairMQExample7ContFact; - -FairMQExample7ContFact::FairMQExample7ContFact() -{ - fName = "FairMQExample7ContFact"; - fTitle = "Factory for parameter containers in FairMQ Example 7"; - setAllContainers(); - FairRuntimeDb::instance()->addContFactory(this); -} - -void FairMQExample7ContFact::setAllContainers() -{ - FairContainer* container = new FairContainer("FairMQExample7ParOne", "FairMQExample7ParOne Parameters", "TestDefaultContext"); - container->addContext("TestNonDefaultContext"); - - containers->Add(container); -} - -FairParSet* FairMQExample7ContFact::createContainer(FairContainer* container) -{ - const char* name = container->GetName(); - FairParSet* p = NULL; - - if (strcmp(name, "FairMQExample7ParOne") == 0) - { - p = new FairMQExample7ParOne(container->getConcatName().Data(), container->GetTitle(), container->getContext()); - } - - return p; -} - -ClassImp(FairMQExample7ContFact); diff --git a/fairmq/examples/7-parameters/FairMQExample7ContFact.h b/fairmq/examples/7-parameters/FairMQExample7ContFact.h deleted file mode 100644 index ce137739..00000000 --- a/fairmq/examples/7-parameters/FairMQExample7ContFact.h +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -#ifndef FAIRMQEXAMPLE7CONTFACT_H_ -#define FAIRMQEXAMPLE7CONTFACT_H_ - -#include "FairContFact.h" - -class FairContainer; - -class FairMQExample7ContFact : public FairContFact -{ - private: - void setAllContainers(); - - public: - FairMQExample7ContFact(); - ~FairMQExample7ContFact() {} - - FairParSet* createContainer(FairContainer*); - ClassDef(FairMQExample7ContFact,0) -}; - -#endif /* FAIRMQEXAMPLE7CONTFACT_H_ */ diff --git a/fairmq/examples/7-parameters/FairMQExample7LinkDef.h b/fairmq/examples/7-parameters/FairMQExample7LinkDef.h deleted file mode 100644 index 75459473..00000000 --- a/fairmq/examples/7-parameters/FairMQExample7LinkDef.h +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class FairMQExample7ContFact+; -#pragma link C++ class FairMQExample7ParOne+; - -#endif diff --git a/fairmq/examples/7-parameters/FairMQExample7ParOne.cxx b/fairmq/examples/7-parameters/FairMQExample7ParOne.cxx deleted file mode 100644 index 761c62f7..00000000 --- a/fairmq/examples/7-parameters/FairMQExample7ParOne.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -#include "FairMQExample7ParOne.h" - -#include "FairParamList.h" -#include "FairDetParIo.h" - -#include "FairLogger.h" -#include "TString.h" - -FairMQExample7ParOne::FairMQExample7ParOne(const char* name, const char* title, const char* context) : - FairParGenericSet(name, title, context), - fParameterValue(0) -{ - detName = "TutorialDet"; -} - -FairMQExample7ParOne::~FairMQExample7ParOne() -{ - clear(); -} - -void FairMQExample7ParOne::clear() -{ - status = kFALSE; - resetInputVersions(); -} - -void FairMQExample7ParOne::print() -{ - LOG(INFO) << "Print" << FairLogger::endl; - LOG(INFO) << "fParameterValue: " << fParameterValue << FairLogger::endl; -} - -void FairMQExample7ParOne::putParams(FairParamList* list) -{ - LOG(INFO) << "FairMQExample7ParOne::putParams()" << FairLogger::endl; - - if (!list) - { - return; - } - - list->add("Example7ParameterValue", fParameterValue); -} - - -Bool_t FairMQExample7ParOne::getParams(FairParamList* list) -{ - LOG(INFO) << "FairMQExample7ParOne::getParams()" << FairLogger::endl; - - if (!list) - { - return kFALSE; - } - - if (!list->fill("Example7ParameterValue", &fParameterValue)) - { - return kFALSE; - } - - return kTRUE; -} - -ClassImp(FairMQExample7ParOne) diff --git a/fairmq/examples/7-parameters/FairMQExample7ParOne.h b/fairmq/examples/7-parameters/FairMQExample7ParOne.h deleted file mode 100644 index 09b61ae7..00000000 --- a/fairmq/examples/7-parameters/FairMQExample7ParOne.h +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -#ifndef FAIRMQEXAMPLE7PARONE_H_ -#define FAIRMQEXAMPLE7PARONE_H_ - -#include "FairParGenericSet.h" - -#include "TObject.h" - -class FairParamList; - -class FairMQExample7ParOne : public FairParGenericSet -{ - public: - /** Standard constructor **/ - FairMQExample7ParOne(const char* name = "FairMQExample7ParOne", - const char* title = "FairMQ Example 7 Parameter One", - const char* context = "Default"); - - /** Destructor **/ - virtual ~FairMQExample7ParOne(); - - virtual void print(); - - /** Reset all parameters **/ - virtual void clear(); - - void putParams(FairParamList* list); - Bool_t getParams(FairParamList* list); - - inline void SetValue(const Int_t& val) { fParameterValue = val; } - - private: - Int_t fParameterValue; // - - FairMQExample7ParOne(const FairMQExample7ParOne&); - FairMQExample7ParOne& operator=(const FairMQExample7ParOne&); - - ClassDef(FairMQExample7ParOne,1); -}; - -#endif // FAIRMQEXAMPLE7PARONE_H_ diff --git a/fairmq/examples/7-parameters/README.md b/fairmq/examples/7-parameters/README.md deleted file mode 100644 index da70156e..00000000 --- a/fairmq/examples/7-parameters/README.md +++ /dev/null @@ -1,10 +0,0 @@ -Example 7: Communicating with ParameterMQServer -=============== - -This example shows how to communicate with the ParameterMQServer, that retrieves parameters from FairRuntimeDb. - -The `fill_parameters.C` ROOT macro can be used to generate the parameter file for the server to read from. The generated file will contain paramters with the name `FairMQExample7ParOne` for run IDs 2000-2099. - -FairMQExample7Client device requests parameter data from ParameterMQServer via REQ-REP pattern. The request contains parameter name and run ID. - -The parameter name can be configured via command line (`--parameter-name`, default is `FairMQExample7ParOne`) and the run ID is hardcoded for this example. diff --git a/fairmq/examples/7-parameters/ex7-client.json b/fairmq/examples/7-parameters/ex7-client.json deleted file mode 100644 index 3d7890f6..00000000 --- a/fairmq/examples/7-parameters/ex7-client.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "fairMQOptions": - { - "device": - { - "id": "parmq-client", - "channel": - { - "name": "data", - "socket": - { - "type": "req", - "method": "connect", - "address": "tcp://localhost:5005", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - } - } -} - diff --git a/fairmq/examples/7-parameters/fill_parameters.C b/fairmq/examples/7-parameters/fill_parameters.C deleted file mode 100644 index c8afb163..00000000 --- a/fairmq/examples/7-parameters/fill_parameters.C +++ /dev/null @@ -1,24 +0,0 @@ -{ - FairRuntimeDb *rtdb = FairRuntimeDb::instance(); - - Bool_t kParameterMerged = kTRUE; - FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); - parOut->open("mqexample7_param.root"); - rtdb->setOutput(parOut); - //rtdb->saveOutput(); - //rtdb->print(); - - FairMQExample7ParOne *par = rtdb->getContainer("FairMQExample7ParOne"); - - for(Int_t i = 0; i < 100; i++) - { - rtdb->addRun(2000 + i); - - par->SetValue(1983 + i); - par->setChanged(); - - rtdb->saveOutput(); - } - - rtdb->print(); -} diff --git a/fairmq/examples/7-parameters/read_parameters.C b/fairmq/examples/7-parameters/read_parameters.C deleted file mode 100644 index 55e1a63a..00000000 --- a/fairmq/examples/7-parameters/read_parameters.C +++ /dev/null @@ -1,19 +0,0 @@ -{ - FairRuntimeDb *rtdb = FairRuntimeDb::instance(); - - Bool_t kParameterMerged = kTRUE; - FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); - parOut->open("mqexample7_param.root"); - rtdb->setFirstInput(parOut); - //rtdb->saveOutput(); - //rtdb->print(); - - FairMQExample7ParOne *par = rtdb->getContainer("FairMQExample7ParOne"); - - for(Int_t i = 0; i < 100; i++) - { - rtdb->initContainers(2000+i); - - par->print(); - } -} diff --git a/fairmq/examples/7-parameters/runExample7Client.cxx b/fairmq/examples/7-parameters/runExample7Client.cxx deleted file mode 100644 index 42700d70..00000000 --- a/fairmq/examples/7-parameters/runExample7Client.cxx +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample7Client.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample7Client.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -using namespace std; -using namespace boost::program_options; - -int main(int argc, char** argv) -{ - FairMQExample7Client client; - client.CatchSignals(); - - FairMQProgOptions config; - - try - { - string parameterName; - - options_description clientOptions("Parameter Client options"); - clientOptions.add_options() - ("parameter-name", value(¶meterName)->default_value("FairMQExample7ParOne"), "Parameter Name"); - - config.AddToCmdLineOptions(clientOptions); - - if (config.ParseAll(argc, argv)) - { - return 0; - } - - string file = config.GetValue("config-json-file"); - string id = config.GetValue("id"); - - config.UserParser(file, id); - - client.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - client.SetTransport(transportFactory); - - client.SetProperty(FairMQExample7Client::Id, "client"); - client.SetProperty(FairMQExample7Client::ParameterName, parameterName); - client.SetProperty(FairMQExample7Client::NumIoThreads, 1); - - FairMQChannel requestChannel("req", "connect", "tcp://localhost:5005"); - requestChannel.UpdateSndBufSize(10000); - requestChannel.UpdateRcvBufSize(10000); - requestChannel.UpdateRateLogging(0); - - client.fChannels["data"].push_back(requestChannel); - - client.ChangeState("INIT_DEVICE"); - client.WaitForEndOfState("INIT_DEVICE"); - - client.ChangeState("INIT_TASK"); - client.WaitForEndOfState("INIT_TASK"); - - client.ChangeState("RUN"); - client.InteractiveStateLoop(); - } - catch (exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/8-multipart/CMakeLists.txt b/fairmq/examples/8-multipart/CMakeLists.txt deleted file mode 100644 index 7bf6be7f..00000000 --- a/fairmq/examples/8-multipart/CMakeLists.txt +++ /dev/null @@ -1,87 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence version 3 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/8-multipart/ex8-multipart.json ${CMAKE_BINARY_DIR}/bin/config/ex8-multipart.json) - -Set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/fairmq - ${CMAKE_SOURCE_DIR}/fairmq/devices - ${CMAKE_SOURCE_DIR}/fairmq/tools - ${CMAKE_SOURCE_DIR}/fairmq/options - ${CMAKE_SOURCE_DIR}/fairmq/examples/8-multipart - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} -) - -If(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/nanomsg - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -Else(NANOMSG_FOUND) - Set(INCLUDE_DIRECTORIES - ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/zeromq - ) - Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${ZMQ_INCLUDE_DIR} - ) -EndIf(NANOMSG_FOUND) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} -) - -Link_Directories(${LINK_DIRECTORIES}) - -Set(SRCS - "FairMQExample8Sampler.cxx" - "FairMQExample8Sink.cxx" -) - -Set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ -) - -Set(LIBRARY_NAME FairMQExample8) - -GENERATE_LIBRARY() - -Set(Exe_Names - ex8-sampler - ex8-sink -) - -Set(Exe_Source - runExample8Sampler.cxx - runExample8Sink.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -ForEach(_file RANGE 0 ${_length}) - list(GET Exe_Names ${_file} _name) - list(GET Exe_Source ${_file} _src) - Set(EXE_NAME ${_name}) - Set(SRCS ${_src}) - Set(DEPENDENCIES FairMQExample8) - GENERATE_EXECUTABLE() -EndForEach(_file RANGE 0 ${_length}) diff --git a/fairmq/examples/8-multipart/FairMQExample8Sampler.cxx b/fairmq/examples/8-multipart/FairMQExample8Sampler.cxx deleted file mode 100644 index 5cc47996..00000000 --- a/fairmq/examples/8-multipart/FairMQExample8Sampler.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample8Sampler.cpp - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQExample8Sampler.h" -#include "FairMQLogger.h" - -using namespace std; - -struct Ex8Header { - int32_t stopFlag; -}; - -FairMQExample8Sampler::FairMQExample8Sampler() -{ -} - -void FairMQExample8Sampler::Run() -{ - int counter = 0; - - // Check if we are still in the RUNNING state. - while (CheckCurrentState(RUNNING)) - { - Ex8Header* header = new Ex8Header; - // Set stopFlag to 1 for the first 4 messages, and to 0 for the 5th. - counter < 5 ? header->stopFlag = 0 : header->stopFlag = 1; - - // Create message part with the header. - unique_ptr headerPart(fTransportFactory->CreateMessage(header, sizeof(Ex8Header))); - // Create message part with the body of 1000 bytes size. - unique_ptr dataPart(fTransportFactory->CreateMessage(1000)); - - LOG(INFO) << "Sending header with stopFlag: " << header->stopFlag; - - // Schedule the header part for sending. - fChannels.at("data-out").at(0).SendPart(headerPart); - // Add body part (final part). `Send()` will send/queue all parts. - fChannels.at("data-out").at(0).Send(dataPart); - - // Go out of the sending loop if the stopFlag was sent. - if (counter == 5) - { - break; - } - - counter++; - // Wait a second to keep the output readable. - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - } - - LOG(INFO) << "Going out of RUNNING state."; -} - -FairMQExample8Sampler::~FairMQExample8Sampler() -{ -} diff --git a/fairmq/examples/8-multipart/FairMQExample8Sampler.h b/fairmq/examples/8-multipart/FairMQExample8Sampler.h deleted file mode 100644 index 479a057e..00000000 --- a/fairmq/examples/8-multipart/FairMQExample8Sampler.h +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample8Sampler.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE8SAMPLER_H_ -#define FAIRMQEXAMPLE8SAMPLER_H_ - -#include - -#include "FairMQDevice.h" - -class FairMQExample8Sampler : public FairMQDevice -{ - public: - FairMQExample8Sampler(); - virtual ~FairMQExample8Sampler(); - - protected: - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE8SAMPLER_H_ */ diff --git a/fairmq/examples/8-multipart/FairMQExample8Sink.cxx b/fairmq/examples/8-multipart/FairMQExample8Sink.cxx deleted file mode 100644 index 0dc83784..00000000 --- a/fairmq/examples/8-multipart/FairMQExample8Sink.cxx +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample8Sink.cxx - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#include -#include - -#include "FairMQExample8Sink.h" -#include "FairMQLogger.h" - -using namespace std; - -struct Ex8Header { - int32_t stopFlag; -}; - -FairMQExample8Sink::FairMQExample8Sink() -{ -} - -void FairMQExample8Sink::Run() -{ - while (CheckCurrentState(RUNNING)) - { - unique_ptr headerPart(fTransportFactory->CreateMessage()); - unique_ptr bodyPart(fTransportFactory->CreateMessage()); - - if (fChannels.at("data-in").at(0).Receive(headerPart) >= 0) - { - if (fChannels.at("data-in").at(0).Receive(bodyPart) >= 0) - { - Ex8Header header; - header.stopFlag = (static_cast(headerPart->GetData()))->stopFlag; - LOG(INFO) << "Received header with stopFlag: " << header.stopFlag; - if (header.stopFlag == 1) - { - LOG(INFO) << "Flag is 0, exiting Run()"; - break; - } - } - } - } -} - -FairMQExample8Sink::~FairMQExample8Sink() -{ -} diff --git a/fairmq/examples/8-multipart/FairMQExample8Sink.h b/fairmq/examples/8-multipart/FairMQExample8Sink.h deleted file mode 100644 index e71851b2..00000000 --- a/fairmq/examples/8-multipart/FairMQExample8Sink.h +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQExample8Sink.h - * - * @since 2014-10-10 - * @author A. Rybalchenko - */ - -#ifndef FAIRMQEXAMPLE8SINK_H_ -#define FAIRMQEXAMPLE8SINK_H_ - -#include "FairMQDevice.h" - -class FairMQExample8Sink : public FairMQDevice -{ - public: - FairMQExample8Sink(); - virtual ~FairMQExample8Sink(); - - protected: - virtual void Run(); -}; - -#endif /* FAIRMQEXAMPLE8SINK_H_ */ diff --git a/fairmq/examples/8-multipart/README.md b/fairmq/examples/8-multipart/README.md deleted file mode 100644 index 841cfcd9..00000000 --- a/fairmq/examples/8-multipart/README.md +++ /dev/null @@ -1,13 +0,0 @@ -Example 8: Sending Multipart messages -=============== - -A topology of two devices - Sampler and Sink, communicating with PUSH-PULL pattern. - -The Sampler sends a multipart message to the Sink, consisting of two message parts - header and body. - -Each message part is a regular FairMQMessage. To combine them into a multi-part message, simply send all but the last part with `SendPart()` and the last part with `Send()` as shown in the example. - -The ZeroMQ transport guarantees delivery of both parts together. Meaning that when the Receive call of the Sink receives the first part, following parts have arrived too. - -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 Sink will exit its `Run()` method. - diff --git a/fairmq/examples/8-multipart/ex8-multipart.json b/fairmq/examples/8-multipart/ex8-multipart.json deleted file mode 100644 index 075aae96..00000000 --- a/fairmq/examples/8-multipart/ex8-multipart.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "fairMQOptions": - { - "device": - { - "id": "sampler1", - "channel": - { - "name": "data-out", - "socket": - { - "type": "push", - "method": "bind", - "address": "tcp://*:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - }, - - "device": - { - "id": "sink1", - "channel": - { - "name": "data-in", - "socket": - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5555", - "sndBufSize": "1000", - "rcvBufSize": "1000", - "rateLogging": "0" - } - } - } - } -} diff --git a/fairmq/examples/8-multipart/runExample8Sampler.cxx b/fairmq/examples/8-multipart/runExample8Sampler.cxx deleted file mode 100644 index 3dbeca4a..00000000 --- a/fairmq/examples/8-multipart/runExample8Sampler.cxx +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample8Sampler.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "boost/program_options.hpp" - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample8Sampler.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -using namespace boost::program_options; - -int main(int argc, char** argv) -{ - FairMQExample8Sampler sampler; - sampler.CatchSignals(); - - FairMQProgOptions config; - - try - { - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sampler.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sampler.SetTransport(transportFactory); - - sampler.SetProperty(FairMQExample8Sampler::Id, id); - - sampler.ChangeState("INIT_DEVICE"); - sampler.WaitForEndOfState("INIT_DEVICE"); - - sampler.ChangeState("INIT_TASK"); - sampler.WaitForEndOfState("INIT_TASK"); - - sampler.ChangeState("RUN"); - sampler.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/8-multipart/runExample8Sink.cxx b/fairmq/examples/8-multipart/runExample8Sink.cxx deleted file mode 100644 index 70e1f253..00000000 --- a/fairmq/examples/8-multipart/runExample8Sink.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * runExample8Sink.cxx - * - * @since 2013-04-23 - * @author D. Klein, A. Rybalchenko - */ - -#include - -#include "FairMQLogger.h" -#include "FairMQParser.h" -#include "FairMQProgOptions.h" -#include "FairMQExample8Sink.h" - -#ifdef NANOMSG -#include "FairMQTransportFactoryNN.h" -#else -#include "FairMQTransportFactoryZMQ.h" -#endif - -int main(int argc, char** argv) -{ - FairMQExample8Sink sink; - sink.CatchSignals(); - - FairMQProgOptions config; - - try - { - if (config.ParseAll(argc, argv)) - { - return 0; - } - - std::string filename = config.GetValue("config-json-file"); - std::string id = config.GetValue("id"); - - config.UserParser(filename, id); - - sink.fChannels = config.GetFairMQMap(); - - LOG(INFO) << "PID: " << getpid(); - -#ifdef NANOMSG - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); -#else - FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); -#endif - - sink.SetTransport(transportFactory); - - sink.SetProperty(FairMQExample8Sink::Id, id); - - sink.ChangeState("INIT_DEVICE"); - sink.WaitForEndOfState("INIT_DEVICE"); - - sink.ChangeState("INIT_TASK"); - sink.WaitForEndOfState("INIT_TASK"); - - sink.ChangeState("RUN"); - sink.InteractiveStateLoop(); - } - catch (std::exception& e) - { - LOG(ERROR) << e.what(); - LOG(INFO) << "Command line options are the following: "; - config.PrintHelp(); - return 1; - } - - return 0; -} diff --git a/fairmq/examples/README.md b/fairmq/examples/README.md deleted file mode 100644 index c69b4fc2..00000000 --- a/fairmq/examples/README.md +++ /dev/null @@ -1,33 +0,0 @@ -FairMQ Examples -=============== - -Set of simple FairMQ examples. - -Example 1: Sampler -> Sink --------------------------- -A simple topology of two devices - **Sampler** and **Sink**. **Sampler** sends data to **Sink** with the **PUSH-PULL** pattern. - - -Example 2: Sampler -> Processor -> 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. - - -Example 3: 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 those of Example 2, but now it can be easily distributed on different computing nodes without the need for manual reconfiguration of the devices. - - -Example 4: Copy & Push ----------------------- -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 countrary to the **PUB-PATTERN** pattern, this insures that all receivers are connected and no data is lost, but requires additional sockets. - - -Example 5: Request & Reply --------------------------- -This topology contains two devices that communicate with each other via the **REQUEST-REPLY** pettern. Bidirectional communication via a single socket. - - -Example 6: Multiple Channels ----------------------------- -This example demonstrates how to work with multiple channels and multiplex between them.