diff --git a/.gitignore b/.gitignore index 378eac25..b36e6994 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ build + +.DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt index b86caf4a..c65270bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ include(CTest) option(BUILD_NANOMSG_TRANSPORT "Build nanomsg transport." OFF) option(BUILD_OFI_TRANSPORT "Build experimental OFI transport." OFF) option(BUILD_DDS_PLUGIN "Build DDS plugin." OFF) +option(BUILD_EXAMPLES "Build FairMQ examples." ON) ################################################################################ @@ -71,6 +72,10 @@ add_subdirectory(fairmq) if(BUILD_TESTING) add_subdirectory(test) endif() + +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() ################################################################################ @@ -178,5 +183,11 @@ else() set(dds_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_DDS_PLUGIN=ON${CR})") endif() message(STATUS " ${BWhite}dds_plugin${CR} ${dds_summary}") +if(BUILD_EXAMPLES) + set(examples_summary "${BGreen}YES${CR} (default, disable with ${BMagenta}-DBUILD_EXAMPLES=OFF${CR})") +else() + set(examples_summary "${BRed} NO${CR} (enable with ${BMagenta}-DBUILD_EXAMPLES=ON${CR})") +endif() +message(STATUS " ${BWhite}examples${CR} ${examples_summary}") message(STATUS " ") ################################################################################ diff --git a/README.md b/README.md index 33929832..2c2dc568 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ On command line: * `-DDISABLE_COLOR=ON` disables coloured console output. * `-DBUILD_TESTING=OFF` disables building of tests. + * `-DBUILD_ESXAMPLES=OFF` disables building of examples. * `-DBUILD_NANOMSG_TRANSPORT=ON` enables building of nanomsg transport. * `-DBUILD_OFI_TRANSPORT=ON` enables building of the experimental OFI transport. * `-DBUILD_DDS_PLUGIN=ON` enables building of the DDS plugin. diff --git a/examples/1-1/CMakeLists.txt b/examples/1-1/CMakeLists.txt new file mode 100644 index 00000000..a8afd2c9 --- /dev/null +++ b/examples/1-1/CMakeLists.txt @@ -0,0 +1,50 @@ +################################################################################ +# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +add_library(Example11Lib STATIC + "Sampler.cxx" + "Sampler.h" + "Sink.cxx" + "Sink.h" +) + +target_link_libraries(Example11Lib PUBLIC FairMQ) + +add_executable(fairmq-ex-1-1-sampler runSampler.cxx) +target_link_libraries(fairmq-ex-1-1-sampler PRIVATE Example11Lib) + +add_executable(fairmq-ex-1-1-sink runSink.cxx) +target_link_libraries(fairmq-ex-1-1-sink PRIVATE Example11Lib) + +add_custom_target(Example11 DEPENDS fairmq-ex-1-1-sampler fairmq-ex-1-1-sink) + +install( + TARGETS + fairmq-ex-1-1-sampler + fairmq-ex-1-1-sink + + LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} + RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} +) + +# configure run script with different executable paths for build and for install directories +set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-1.sh) +set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-1.sh_install) + +install( + PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-1.sh_install + DESTINATION ${PROJECT_INSTALL_BINDIR} + RENAME fairmq-start-ex-1-1.sh +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-1-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh) + +add_test(NAME Example-1-1 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh) +set_tests_properties(Example-1-1 PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ") diff --git a/examples/MQ/1-sampler-sink/README.md b/examples/1-1/README.md similarity index 100% rename from examples/MQ/1-sampler-sink/README.md rename to examples/1-1/README.md diff --git a/examples/MQ/1-sampler-sink/FairMQExample1Sampler.cxx b/examples/1-1/Sampler.cxx similarity index 87% rename from examples/MQ/1-sampler-sink/FairMQExample1Sampler.cxx rename to examples/1-1/Sampler.cxx index 11a924ee..4367f447 100644 --- a/examples/MQ/1-sampler-sink/FairMQExample1Sampler.cxx +++ b/examples/1-1/Sampler.cxx @@ -6,7 +6,7 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample1Sampler.cpp + * Sampler.cpp * * @since 2014-10-10 * @author A. Rybalchenko @@ -15,27 +15,28 @@ #include // this_thread::sleep_for #include -#include "FairMQExample1Sampler.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig +#include "Sampler.h" using namespace std; -FairMQExample1Sampler::FairMQExample1Sampler() +namespace example_1_1 +{ + +Sampler::Sampler() : fText() , fMaxIterations(0) , fNumIterations(0) { } -void FairMQExample1Sampler::InitTask() +void Sampler::InitTask() { // Get the fText and fMaxIterations values from the command line options (via fConfig) fText = fConfig->GetValue("text"); fMaxIterations = fConfig->GetValue("max-iterations"); } -bool FairMQExample1Sampler::ConditionalRun() +bool Sampler::ConditionalRun() { // create a copy of the data with new(), that will be deleted after the transfer is complete string* text = new string(fText); @@ -68,6 +69,8 @@ bool FairMQExample1Sampler::ConditionalRun() return true; } -FairMQExample1Sampler::~FairMQExample1Sampler() +Sampler::~Sampler() { } + +} // namespace example_1_1 diff --git a/examples/MQ/2-sampler-processor-sink/FairMQExample2Sampler.h b/examples/1-1/Sampler.h similarity index 68% rename from examples/MQ/2-sampler-processor-sink/FairMQExample2Sampler.h rename to examples/1-1/Sampler.h index 079d842f..7a3922ae 100644 --- a/examples/MQ/2-sampler-processor-sink/FairMQExample2Sampler.h +++ b/examples/1-1/Sampler.h @@ -1,37 +1,42 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample2Sampler.h + * Sampler.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE2SAMPLER_H_ -#define FAIRMQEXAMPLE2SAMPLER_H_ +#ifndef FAIRMQEXAMPLE11SAMPLER_H +#define FAIRMQEXAMPLE11SAMPLER_H #include #include "FairMQDevice.h" -class FairMQExample2Sampler : public FairMQDevice +namespace example_1_1 +{ + +class Sampler : public FairMQDevice { public: - FairMQExample2Sampler(); - virtual ~FairMQExample2Sampler(); + Sampler(); + virtual ~Sampler(); protected: std::string fText; uint64_t fMaxIterations; uint64_t fNumIterations; - virtual void InitTask(); - virtual bool ConditionalRun(); + void InitTask() override; + bool ConditionalRun() override; }; -#endif /* FAIRMQEXAMPLE2SAMPLER_H_ */ +} // namespace example_1_1 + +#endif /* FAIRMQEXAMPLE11SAMPLER_H */ diff --git a/examples/MQ/1-sampler-sink/FairMQExample1Sink.cxx b/examples/1-1/Sink.cxx similarity index 77% rename from examples/MQ/1-sampler-sink/FairMQExample1Sink.cxx rename to examples/1-1/Sink.cxx index 7a21fbb7..298fe1f7 100644 --- a/examples/MQ/1-sampler-sink/FairMQExample1Sink.cxx +++ b/examples/1-1/Sink.cxx @@ -1,39 +1,40 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample1Sink.cxx + * Sink.cxx * * @since 2014-10-10 * @author A. Rybalchenko */ -#include "FairMQExample1Sink.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig +#include "Sink.h" using namespace std; -FairMQExample1Sink::FairMQExample1Sink() +namespace example_1_1 +{ + +Sink::Sink() : fMaxIterations(0) , fNumIterations(0) { // register a handler for data arriving on "data" channel - OnData("data", &FairMQExample1Sink::HandleData); + OnData("data", &Sink::HandleData); } -void FairMQExample1Sink::InitTask() +void Sink::InitTask() { // Get the fMaxIterations value from the command line options (via fConfig) fMaxIterations = fConfig->GetValue("max-iterations"); } // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool FairMQExample1Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) { LOG(info) << "Received: \"" << string(static_cast(msg->GetData()), msg->GetSize()) << "\""; @@ -47,6 +48,8 @@ bool FairMQExample1Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) return true; } -FairMQExample1Sink::~FairMQExample1Sink() +Sink::~Sink() { } + +} // namespace example_1_1 diff --git a/examples/MQ/1-sampler-sink/FairMQExample1Sink.h b/examples/1-1/Sink.h similarity index 75% rename from examples/MQ/1-sampler-sink/FairMQExample1Sink.h rename to examples/1-1/Sink.h index 84281e0c..35563760 100644 --- a/examples/MQ/1-sampler-sink/FairMQExample1Sink.h +++ b/examples/1-1/Sink.h @@ -1,27 +1,30 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample1Sink.h + * Sink.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE1SINK_H_ -#define FAIRMQEXAMPLE1SINK_H_ +#ifndef FAIRMQEXAMPLE11SINK_H +#define FAIRMQEXAMPLE11SINK_H #include "FairMQDevice.h" -class FairMQExample1Sink : public FairMQDevice +namespace example_1_1 +{ + +class Sink : public FairMQDevice { public: - FairMQExample1Sink(); - virtual ~FairMQExample1Sink(); + Sink(); + virtual ~Sink(); protected: virtual void InitTask(); @@ -32,4 +35,6 @@ class FairMQExample1Sink : public FairMQDevice uint64_t fNumIterations; }; -#endif /* FAIRMQEXAMPLE1SINK_H_ */ +} // namespace example_1_1 + +#endif /* FAIRMQEXAMPLE11SINK_H */ diff --git a/examples/1-1/fairmq-start-ex-1-1.sh.in b/examples/1-1/fairmq-start-ex-1-1.sh.in new file mode 100755 index 00000000..eb3dad3e --- /dev/null +++ b/examples/1-1/fairmq-start-ex-1-1.sh.in @@ -0,0 +1,11 @@ +#!/bin/bash + +SAMPLER="fairmq-ex-1-1-sampler" +SAMPLER+=" --id sampler1" +SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://*:5555,rateLogging=0" +xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER & + +SINK="fairmq-ex-1-1-sink" +SINK+=" --id sink1" +SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://localhost:5555,rateLogging=0" +xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$SINK & diff --git a/examples/MQ/5-req-rep/runExample5Client.cxx b/examples/1-1/runSampler.cxx similarity index 89% rename from examples/MQ/5-req-rep/runExample5Client.cxx rename to examples/1-1/runSampler.cxx index 113c44d4..50cd13fb 100644 --- a/examples/MQ/5-req-rep/runExample5Client.cxx +++ b/examples/1-1/runSampler.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample5Client.h" +#include "Sampler.h" namespace bpo = boost::program_options; @@ -20,5 +20,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample5Client(); + return new example_1_1::Sampler(); } diff --git a/examples/MQ/6-multiple-channels/runExample6Sink.cxx b/examples/1-1/runSink.cxx similarity index 89% rename from examples/MQ/6-multiple-channels/runExample6Sink.cxx rename to examples/1-1/runSink.cxx index 6f06f72d..f92ba05c 100644 --- a/examples/MQ/6-multiple-channels/runExample6Sink.cxx +++ b/examples/1-1/runSink.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample6Sink.h" +#include "Sink.h" namespace bpo = boost::program_options; @@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample6Sink(); + return new example_1_1::Sink(); } diff --git a/examples/MQ/1-sampler-sink/testMQEx1.sh.in b/examples/1-1/test-ex-1-1.sh.in similarity index 61% rename from examples/MQ/1-sampler-sink/testMQEx1.sh.in rename to examples/1-1/test-ex-1-1.sh.in index 7c5569d1..ae654d2e 100755 --- a/examples/MQ/1-sampler-sink/testMQEx1.sh.in +++ b/examples/1-1/test-ex-1-1.sh.in @@ -1,26 +1,24 @@ #!/bin/bash -ex1config="@CMAKE_BINARY_DIR@/bin/config/ex1-sampler-sink.json" - # setup a trap to kill everything if the test fails/timeouts trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID;' TERM -SAMPLER="ex1-sampler" +SAMPLER="fairmq-ex-1-1-sampler" SAMPLER+=" --id sampler1" SAMPLER+=" --verbosity veryhigh" SAMPLER+=" --control static --color false" SAMPLER+=" --max-iterations 1" -SAMPLER+=" --mq-config $ex1config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/1-sampler-sink/$SAMPLER & +SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://*:5555,rateLogging=0" +@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & SAMPLER_PID=$! -SINK="ex1-sink" +SINK="fairmq-ex-1-1-sink" SINK+=" --id sink1" SINK+=" --verbosity veryhigh" SINK+=" --control static --color false" SINK+=" --max-iterations 1" -SINK+=" --mq-config $ex1config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/1-sampler-sink/$SINK & +SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://localhost:5555,rateLogging=0" +@CMAKE_CURRENT_BINARY_DIR@/$SINK & SINK_PID=$! # wait for sampler and sink to finish diff --git a/examples/1-n-1/CMakeLists.txt b/examples/1-n-1/CMakeLists.txt new file mode 100644 index 00000000..65731369 --- /dev/null +++ b/examples/1-n-1/CMakeLists.txt @@ -0,0 +1,62 @@ +################################################################################ +# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +add_library(Example1N1Lib STATIC + "Sampler.cxx" + "Sampler.h" + "Processor.cxx" + "Processor.h" + "Sink.cxx" + "Sink.h" +) + +target_link_libraries(Example1N1Lib PUBLIC FairMQ) + +add_executable(fairmq-ex-1-n-1-sampler runSampler.cxx) +target_link_libraries(fairmq-ex-1-n-1-sampler PRIVATE Example1N1Lib) + +add_executable(fairmq-ex-1-n-1-processor runProcessor.cxx) +target_link_libraries(fairmq-ex-1-n-1-processor PRIVATE Example1N1Lib) + +add_executable(fairmq-ex-1-n-1-sink runSink.cxx) +target_link_libraries(fairmq-ex-1-n-1-sink PRIVATE Example1N1Lib) + +add_custom_target(Example1N1 DEPENDS fairmq-ex-1-n-1-sampler fairmq-ex-1-n-1-processor fairmq-ex-1-n-1-sink) + +install( + TARGETS + fairmq-ex-1-n-1-sampler + fairmq-ex-1-n-1-processor + fairmq-ex-1-n-1-sink + + LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} + RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} +) + +# configure run script with different executable paths for build and for install directories +set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-n-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-n-1.sh) +set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-n-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-n-1.sh_install) + +install( + PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-n-1.sh_install + DESTINATION ${PROJECT_INSTALL_BINDIR} + RENAME fairmq-start-ex-1-n-1.sh +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-1-n-1.json ${CMAKE_CURRENT_BINARY_DIR}/ex-1-n-1.json) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-1-n-1.json + DESTINATION ${PROJECT_INSTALL_BINDIR} # TODO: install this in a more appropriate directory +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-1-n-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh) + +add_test(NAME Example-1-n-1 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh) +set_tests_properties(Example-1-n-1 PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ") diff --git a/examples/MQ/2-sampler-processor-sink/FairMQExample2Processor.cxx b/examples/1-n-1/Processor.cxx similarity index 80% rename from examples/MQ/2-sampler-processor-sink/FairMQExample2Processor.cxx rename to examples/1-n-1/Processor.cxx index c2c0f5f0..b74ba282 100644 --- a/examples/MQ/2-sampler-processor-sink/FairMQExample2Processor.cxx +++ b/examples/1-n-1/Processor.cxx @@ -1,24 +1,26 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#include "FairMQExample2Processor.h" -#include "FairMQLogger.h" +#include "Processor.h" #include using namespace std; -FairMQExample2Processor::FairMQExample2Processor() +namespace example_1_n_1 { - OnData("data1", &FairMQExample2Processor::HandleData); + +Processor::Processor() +{ + OnData("data1", &Processor::HandleData); } -bool FairMQExample2Processor::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool Processor::HandleData(FairMQMessagePtr& msg, int /*index*/) { LOG(info) << "Received data, processing..."; @@ -44,6 +46,8 @@ bool FairMQExample2Processor::HandleData(FairMQMessagePtr& msg, int /*index*/) return true; } -FairMQExample2Processor::~FairMQExample2Processor() +Processor::~Processor() { } + +} // namespace example_1_n_1 diff --git a/examples/MQ/2-sampler-processor-sink/FairMQExample2Processor.h b/examples/1-n-1/Processor.h similarity index 68% rename from examples/MQ/2-sampler-processor-sink/FairMQExample2Processor.h rename to examples/1-n-1/Processor.h index 4339f85a..87670831 100644 --- a/examples/MQ/2-sampler-processor-sink/FairMQExample2Processor.h +++ b/examples/1-n-1/Processor.h @@ -1,24 +1,29 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#ifndef FAIRMQEXAMPLE2PROCESSOR_H_ -#define FAIRMQEXAMPLE2PROCESSOR_H_ +#ifndef FAIRMQEXAMPLE1N1PROCESSOR_H_ +#define FAIRMQEXAMPLE1N1PROCESSOR_H_ #include "FairMQDevice.h" -class FairMQExample2Processor : public FairMQDevice +namespace example_1_n_1 +{ + +class Processor : public FairMQDevice { public: - FairMQExample2Processor(); - virtual ~FairMQExample2Processor(); + Processor(); + virtual ~Processor(); protected: bool HandleData(FairMQMessagePtr&, int); }; -#endif /* FAIRMQEXAMPLE2PROCESSOR_H_ */ +} // namespace example_1_n_1 + +#endif /* FAIRMQEXAMPLE1N1PROCESSOR_H_ */ diff --git a/examples/MQ/2-sampler-processor-sink/README.md b/examples/1-n-1/README.md similarity index 100% rename from examples/MQ/2-sampler-processor-sink/README.md rename to examples/1-n-1/README.md diff --git a/examples/MQ/2-sampler-processor-sink/FairMQExample2Sampler.cxx b/examples/1-n-1/Sampler.cxx similarity index 82% rename from examples/MQ/2-sampler-processor-sink/FairMQExample2Sampler.cxx rename to examples/1-n-1/Sampler.cxx index 471c9b29..dfae72b9 100644 --- a/examples/MQ/2-sampler-processor-sink/FairMQExample2Sampler.cxx +++ b/examples/1-n-1/Sampler.cxx @@ -1,12 +1,12 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample2Sampler.cpp + * Sampler.cpp * * @since 2014-10-10 * @author A. Rybalchenko @@ -15,27 +15,28 @@ #include // this_thread::sleep_for #include -#include "FairMQExample2Sampler.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig +#include "Sampler.h" using namespace std; -FairMQExample2Sampler::FairMQExample2Sampler() +namespace example_1_n_1 +{ + +Sampler::Sampler() : fText() , fMaxIterations(0) , fNumIterations(0) { } -void FairMQExample2Sampler::InitTask() +void Sampler::InitTask() { // Get the fText and fMaxIterations values from the command line options (via fConfig) fText = fConfig->GetValue("text"); fMaxIterations = fConfig->GetValue("max-iterations"); } -bool FairMQExample2Sampler::ConditionalRun() +bool Sampler::ConditionalRun() { // Initializing message with NewStaticMessage will avoid copy // but won't delete the data after the sending is completed. @@ -60,6 +61,8 @@ bool FairMQExample2Sampler::ConditionalRun() return true; } -FairMQExample2Sampler::~FairMQExample2Sampler() +Sampler::~Sampler() { } + +} // namespace example_1_n_1 diff --git a/examples/MQ/1-sampler-sink/FairMQExample1Sampler.h b/examples/1-n-1/Sampler.h similarity index 77% rename from examples/MQ/1-sampler-sink/FairMQExample1Sampler.h rename to examples/1-n-1/Sampler.h index 56631f3d..9d428110 100644 --- a/examples/MQ/1-sampler-sink/FairMQExample1Sampler.h +++ b/examples/1-n-1/Sampler.h @@ -6,24 +6,27 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample1Sampler.h + * Sampler.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE1SAMPLER_H_ -#define FAIRMQEXAMPLE1SAMPLER_H_ +#ifndef FAIRMQEXAMPLE1N1SAMPLER_H_ +#define FAIRMQEXAMPLE1N1SAMPLER_H_ #include #include "FairMQDevice.h" -class FairMQExample1Sampler : public FairMQDevice +namespace example_1_n_1 +{ + +class Sampler : public FairMQDevice { public: - FairMQExample1Sampler(); - virtual ~FairMQExample1Sampler(); + Sampler(); + virtual ~Sampler(); protected: std::string fText; @@ -34,4 +37,6 @@ class FairMQExample1Sampler : public FairMQDevice virtual bool ConditionalRun(); }; -#endif /* FAIRMQEXAMPLE1SAMPLER_H_ */ +} // namespace example_1_n_1 + +#endif /* FAIRMQEXAMPLE1N1SAMPLER_H_ */ diff --git a/examples/MQ/2-sampler-processor-sink/FairMQExample2Sink.cxx b/examples/1-n-1/Sink.cxx similarity index 77% rename from examples/MQ/2-sampler-processor-sink/FairMQExample2Sink.cxx rename to examples/1-n-1/Sink.cxx index 907f2f7e..14e7d665 100644 --- a/examples/MQ/2-sampler-processor-sink/FairMQExample2Sink.cxx +++ b/examples/1-n-1/Sink.cxx @@ -1,39 +1,40 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample2Sink.cxx + * Sink.cxx * * @since 2014-10-10 * @author A. Rybalchenko */ -#include "FairMQExample2Sink.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig +#include "Sink.h" using namespace std; -FairMQExample2Sink::FairMQExample2Sink() +namespace example_1_n_1 +{ + +Sink::Sink() : fMaxIterations(0) , fNumIterations(0) { // register a handler for data arriving on "data2" channel - OnData("data2", &FairMQExample2Sink::HandleData); + OnData("data2", &Sink::HandleData); } -void FairMQExample2Sink::InitTask() +void Sink::InitTask() { // Get the fMaxIterations value from the command line options (via fConfig) fMaxIterations = fConfig->GetValue("max-iterations"); } // handler is called whenever a message arrives on "data2", with a reference to the message and a sub-channel index (here 0) -bool FairMQExample2Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) { LOG(info) << "Received: \"" << string(static_cast(msg->GetData()), msg->GetSize()) << "\""; @@ -47,6 +48,8 @@ bool FairMQExample2Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) return true; } -FairMQExample2Sink::~FairMQExample2Sink() +Sink::~Sink() { } + +} // namespace example_1_n_1 diff --git a/examples/MQ/2-sampler-processor-sink/FairMQExample2Sink.h b/examples/1-n-1/Sink.h similarity index 74% rename from examples/MQ/2-sampler-processor-sink/FairMQExample2Sink.h rename to examples/1-n-1/Sink.h index c262ab37..85c97462 100644 --- a/examples/MQ/2-sampler-processor-sink/FairMQExample2Sink.h +++ b/examples/1-n-1/Sink.h @@ -1,27 +1,30 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample2Sink.h + * Sink.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE2SINK_H_ -#define FAIRMQEXAMPLE2SINK_H_ +#ifndef FAIRMQEXAMPLE1N1SINK_H +#define FAIRMQEXAMPLE1N1SINK_H #include "FairMQDevice.h" -class FairMQExample2Sink : public FairMQDevice +namespace example_1_n_1 +{ + +class Sink : public FairMQDevice { public: - FairMQExample2Sink(); - virtual ~FairMQExample2Sink(); + Sink(); + virtual ~Sink(); protected: virtual void InitTask(); @@ -32,4 +35,6 @@ class FairMQExample2Sink : public FairMQDevice uint64_t fNumIterations; }; -#endif /* FAIRMQEXAMPLE2SINK_H_ */ +} // namespace example_1_n_1 + +#endif /* FAIRMQEXAMPLE1N1SINK_H */ diff --git a/examples/MQ/2-sampler-processor-sink/ex2-sampler-processor-sink.json b/examples/1-n-1/ex-1-n-1.json similarity index 100% rename from examples/MQ/2-sampler-processor-sink/ex2-sampler-processor-sink.json rename to examples/1-n-1/ex-1-n-1.json diff --git a/examples/1-n-1/fairmq-start-ex-1-n-1.sh.in b/examples/1-n-1/fairmq-start-ex-1-n-1.sh.in new file mode 100755 index 00000000..806e7d94 --- /dev/null +++ b/examples/1-n-1/fairmq-start-ex-1-n-1.sh.in @@ -0,0 +1,25 @@ +#!/bin/bash + +ex2config="@EX_BIN_DIR@/ex-1-n-1.json" + +SAMPLER="fairmq-ex-1-n-1-sampler" +SAMPLER+=" --id sampler1" +SAMPLER+=" --mq-config $ex2config" +xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER & + +PROCESSOR1="fairmq-ex-1-n-1-processor" +PROCESSOR1+=" --id processor1" +PROCESSOR1+=" --mq-config $ex2config" +PROCESSOR1+=" --config-key processor" +xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$PROCESSOR1 & + +PROCESSOR2="fairmq-ex-1-n-1-processor" +PROCESSOR2+=" --id processor2" +PROCESSOR2+=" --mq-config $ex2config" +PROCESSOR2+=" --config-key processor" +xterm -geometry 80x23+500+330 -hold -e @EX_BIN_DIR@/$PROCESSOR2 & + +SINK="fairmq-ex-1-n-1-sink" +SINK+=" --id sink1" +SINK+=" --mq-config $ex2config" +xterm -geometry 80x23+1000+0 -hold -e @EX_BIN_DIR@/$SINK & diff --git a/examples/MQ/3-dds/runExample3Sink.cxx b/examples/1-n-1/runProcessor.cxx similarity index 87% rename from examples/MQ/3-dds/runExample3Sink.cxx rename to examples/1-n-1/runProcessor.cxx index 47490c69..be3e80fb 100644 --- a/examples/MQ/3-dds/runExample3Sink.cxx +++ b/examples/1-n-1/runProcessor.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample3Sink.h" +#include "Processor.h" namespace bpo = boost::program_options; @@ -17,5 +17,5 @@ void addCustomOptions(bpo::options_description& /*options*/) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample3Sink(); + return new example_1_n_1::Processor(); } diff --git a/examples/MQ/1-sampler-sink/runExample1Sampler.cxx b/examples/1-n-1/runSampler.cxx similarity index 89% rename from examples/MQ/1-sampler-sink/runExample1Sampler.cxx rename to examples/1-n-1/runSampler.cxx index 6421a4e3..1a6da621 100644 --- a/examples/MQ/1-sampler-sink/runExample1Sampler.cxx +++ b/examples/1-n-1/runSampler.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample1Sampler.h" +#include "Sampler.h" namespace bpo = boost::program_options; @@ -20,5 +20,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample1Sampler(); + return new example_1_n_1::Sampler(); } diff --git a/examples/MQ/4-copypush/runExample4Sink.cxx b/examples/1-n-1/runSink.cxx similarity index 89% rename from examples/MQ/4-copypush/runExample4Sink.cxx rename to examples/1-n-1/runSink.cxx index a7ba0380..75f0be2f 100644 --- a/examples/MQ/4-copypush/runExample4Sink.cxx +++ b/examples/1-n-1/runSink.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample4Sink.h" +#include "Sink.h" namespace bpo = boost::program_options; @@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample4Sink(); + return new example_1_n_1::Sink(); } diff --git a/examples/MQ/2-sampler-processor-sink/testMQEx2.sh.in b/examples/1-n-1/test-ex-1-n-1.sh.in similarity index 73% rename from examples/MQ/2-sampler-processor-sink/testMQEx2.sh.in rename to examples/1-n-1/test-ex-1-n-1.sh.in index 6f24be51..ea1d0b0e 100755 --- a/examples/MQ/2-sampler-processor-sink/testMQEx2.sh.in +++ b/examples/1-n-1/test-ex-1-n-1.sh.in @@ -1,44 +1,44 @@ #!/bin/bash -ex2config="@CMAKE_BINARY_DIR@/bin/config/ex2-sampler-processor-sink.json" +ex2config="@CMAKE_CURRENT_BINARY_DIR@/ex-1-n-1.json" # setup a trap to kill everything if the test fails/timeouts trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; kill -TERM $PROCESSOR1_PID; kill -TERM $PROCESSOR2_PID; wait $SAMPLER_PID; wait $SINK_PID; wait $PROCESSOR1_PID; wait $PROCESSOR2_PID;' TERM -SAMPLER="ex2-sampler" +SAMPLER="fairmq-ex-1-n-1-sampler" SAMPLER+=" --id sampler1" SAMPLER+=" --verbosity veryhigh" SAMPLER+=" --control static --color false" SAMPLER+=" --max-iterations 2" SAMPLER+=" --mq-config $ex2config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$SAMPLER & +@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & SAMPLER_PID=$! -PROCESSOR1="ex2-processor" +PROCESSOR1="fairmq-ex-1-n-1-processor" PROCESSOR1+=" --id processor1" PROCESSOR1+=" --verbosity veryhigh" PROCESSOR1+=" --control static --color false" PROCESSOR1+=" --mq-config $ex2config" PROCESSOR1+=" --config-key processor" -@CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$PROCESSOR1 & +@CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR1 & PROCESSOR1_PID=$! -PROCESSOR2="ex2-processor" +PROCESSOR2="fairmq-ex-1-n-1-processor" PROCESSOR2+=" --id processor2" PROCESSOR2+=" --verbosity veryhigh" PROCESSOR2+=" --control static --color false" PROCESSOR2+=" --mq-config $ex2config" PROCESSOR2+=" --config-key processor" -@CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$PROCESSOR2 & +@CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR2 & PROCESSOR2_PID=$! -SINK="ex2-sink" +SINK="fairmq-ex-1-n-1-sink" SINK+=" --id sink1" SINK+=" --verbosity veryhigh" SINK+=" --control static --color false" SINK+=" --max-iterations 2" SINK+=" --mq-config $ex2config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$SINK & +@CMAKE_CURRENT_BINARY_DIR@/$SINK & SINK_PID=$! # wait for sampler and sink to finish diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 00000000..fc0fb15a --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,17 @@ +################################################################################ +# Copyright (C) 2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +add_subdirectory(1-1) +add_subdirectory(1-n-1) +add_subdirectory(copypush) +add_subdirectory(dds) +add_subdirectory(multipart) +add_subdirectory(multiple-channels) +add_subdirectory(multiple-transports) +add_subdirectory(region) +add_subdirectory(req-rep) diff --git a/examples/MQ/1-sampler-sink/CMakeLists.txt b/examples/MQ/1-sampler-sink/CMakeLists.txt deleted file mode 100644 index d7e051ca..00000000 --- a/examples/MQ/1-sampler-sink/CMakeLists.txt +++ /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 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/1-sampler-sink/ex1-sampler-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex1-sampler-sink.json) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/1-sampler-sink/startMQEx1.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/1-sampler-sink/startMQEx1.sh) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/1-sampler-sink/testMQEx1.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/1-sampler-sink/testMQEx1.sh) - -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}/examples/MQ/1-sampler-sink - ${CMAKE_CURRENT_BINARY_DIR} -) - -set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} - ${ZeroMQ_INCLUDE_DIR} -) - -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) - -set(BIN_DESTINATION share/fairbase/examples/MQ/1-sampler-sink/bin) -set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/1-sampler-sink") - -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}) - -add_test(NAME MQ.ex1-sampler-sink COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/1-sampler-sink/testMQEx1.sh) -set_tests_properties(MQ.ex1-sampler-sink PROPERTIES TIMEOUT "30") -set_tests_properties(MQ.ex1-sampler-sink PROPERTIES RUN_SERIAL true) -set_tests_properties(MQ.ex1-sampler-sink PROPERTIES PASS_REGULAR_EXPRESSION " Received: \"Hello\"") - -install( - FILES ex1-sampler-sink.json - DESTINATION share/fairbase/examples/MQ/1-sampler-sink/config/ -) diff --git a/examples/MQ/1-sampler-sink/ex1-sampler-sink.json b/examples/MQ/1-sampler-sink/ex1-sampler-sink.json deleted file mode 100644 index 8f85d3ec..00000000 --- a/examples/MQ/1-sampler-sink/ex1-sampler-sink.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "fairMQOptions": { - "devices": [ - { - "id": "sampler1", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "push", - "method": "bind", - "address": "tcp://*:5555", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - }, - { - "id": "sink1", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5555", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - } - ] - } -} diff --git a/examples/MQ/1-sampler-sink/startMQEx1.sh.in b/examples/MQ/1-sampler-sink/startMQEx1.sh.in deleted file mode 100755 index 2fe46c85..00000000 --- a/examples/MQ/1-sampler-sink/startMQEx1.sh.in +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -ex1config="@CMAKE_BINARY_DIR@/bin/config/ex1-sampler-sink.json" - -SAMPLER="ex1-sampler" -SAMPLER+=" --id sampler1" -SAMPLER+=" --mq-config $ex1config" -xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/1-sampler-sink/$SAMPLER & - -SINK="ex1-sink" -SINK+=" --id sink1" -SINK+=" --mq-config $ex1config" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/1-sampler-sink/$SINK & diff --git a/examples/MQ/2-sampler-processor-sink/CMakeLists.txt b/examples/MQ/2-sampler-processor-sink/CMakeLists.txt deleted file mode 100644 index fa7d87b9..00000000 --- a/examples/MQ/2-sampler-processor-sink/CMakeLists.txt +++ /dev/null @@ -1,86 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/2-sampler-processor-sink/ex2-sampler-processor-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex2-sampler-processor-sink.json) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/2-sampler-processor-sink/startMQEx2.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/2-sampler-processor-sink/startMQEx2.sh) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/2-sampler-processor-sink/testMQEx2.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/2-sampler-processor-sink/testMQEx2.sh) - -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}/examples/MQ/2-sampler-processor-sink - ${CMAKE_CURRENT_BINARY_DIR} -) - -set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} - ${ZeroMQ_INCLUDE_DIR} -) - -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) - -set(BIN_DESTINATION share/fairbase/examples/MQ/2-sampler-processor-sink/bin) -set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/2-sampler-processor-sink") - -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}) - -add_test(NAME MQ.ex2-sampler-processor-sink COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/2-sampler-processor-sink/testMQEx2.sh) -set_tests_properties(MQ.ex2-sampler-processor-sink PROPERTIES TIMEOUT "30") -set_tests_properties(MQ.ex2-sampler-processor-sink PROPERTIES RUN_SERIAL true) -set_tests_properties(MQ.ex2-sampler-processor-sink PROPERTIES PASS_REGULAR_EXPRESSION "Received: ") - -install( - FILES ex2-sampler-processor-sink.json - DESTINATION share/fairbase/examples/MQ/2-sampler-processor-sink/config/ -) diff --git a/examples/MQ/2-sampler-processor-sink/startMQEx2.sh.in b/examples/MQ/2-sampler-processor-sink/startMQEx2.sh.in deleted file mode 100755 index c9ba93ed..00000000 --- a/examples/MQ/2-sampler-processor-sink/startMQEx2.sh.in +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -ex2config="@CMAKE_BINARY_DIR@/bin/config/ex2-sampler-processor-sink.json" - -SAMPLER="ex2-sampler" -SAMPLER+=" --id sampler1" -SAMPLER+=" --mq-config $ex2config" -xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$SAMPLER & - -PROCESSOR1="ex2-processor" -PROCESSOR1+=" --id processor1" -PROCESSOR1+=" --mq-config $ex2config" -PROCESSOR1+=" --config-key processor" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$PROCESSOR1 & - -PROCESSOR2="ex2-processor" -PROCESSOR2+=" --id processor2" -PROCESSOR2+=" --mq-config $ex2config" -PROCESSOR2+=" --config-key processor" -xterm -geometry 80x23+500+330 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$PROCESSOR2 & - -SINK="ex2-sink" -SINK+=" --id sink1" -SINK+=" --mq-config $ex2config" -xterm -geometry 80x23+1000+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$SINK & diff --git a/examples/MQ/3-dds/CMakeLists.txt b/examples/MQ/3-dds/CMakeLists.txt deleted file mode 100644 index a7dea325..00000000 --- a/examples/MQ/3-dds/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 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/3-dds/ex3-dds-topology.xml - ${CMAKE_BINARY_DIR}/bin/config/ex3-dds-topology.xml @ONLY) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/3-dds/ex3-dds-hosts.cfg - ${CMAKE_BINARY_DIR}/bin/config/ex3-dds-hosts.cfg COPYONLY) - -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}/examples/MQ/3-dds - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${SYSTEM_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${ZeroMQ_INCLUDE_DIR} -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${LINK_DIRECTORIES} - ${Boost_LIBRARY_DIRS} -) - -Link_Directories(${LINK_DIRECTORIES}) - -Set(SRCS - ${SRCS} - "FairMQExample3Sampler.cxx" - "FairMQExample3Processor.cxx" - "FairMQExample3Sink.cxx" -) - -Set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ -) - -set(LIBRARY_NAME FairMQExample3) - -GENERATE_LIBRARY() - -Set(Exe_Names - ${Exe_Names} - ex3-sampler - ex3-processor - ex3-sink -) - -Set(Exe_Source - ${Exe_Source} - runExample3Sampler.cxx - runExample3Processor.cxx - runExample3Sink.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -set(BIN_DESTINATION share/fairbase/examples/MQ/3-dds/bin) -set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/3-dds") - -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}) - -Install( - FILES ex3-dds-hosts.cfg ex3-dds-topology.xml - DESTINATION share/fairbase/examples/MQ/3-dds/config/ -) diff --git a/examples/MQ/4-copypush/CMakeLists.txt b/examples/MQ/4-copypush/CMakeLists.txt deleted file mode 100644 index 576cfca5..00000000 --- a/examples/MQ/4-copypush/CMakeLists.txt +++ /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 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/4-copypush/ex4-copypush.json ${CMAKE_BINARY_DIR}/bin/config/ex4-copypush.json) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/4-copypush/startMQEx4.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/4-copypush/startMQEx4.sh) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/4-copypush/testMQEx4.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/4-copypush/testMQEx4.sh) - -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}/examples/MQ/4-copypush - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} - ${ZeroMQ_INCLUDE_DIR} -) - -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) - -set(BIN_DESTINATION share/fairbase/examples/MQ/4-copypush/bin) -set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/4-copypush") - -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}) - -add_test(NAME MQ.ex4-copypush COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/4-copypush/testMQEx4.sh) -set_tests_properties(MQ.ex4-copypush PROPERTIES TIMEOUT "30") -set_tests_properties(MQ.ex4-copypush PROPERTIES RUN_SERIAL true) -set_tests_properties(MQ.ex4-copypush PROPERTIES PASS_REGULAR_EXPRESSION "Received message: ") - -Install( - FILES ex4-copypush.json - DESTINATION share/fairbase/examples/MQ/4-copypush/config/ -) diff --git a/examples/MQ/4-copypush/ex4-copypush.json b/examples/MQ/4-copypush/ex4-copypush.json deleted file mode 100644 index 68c8d349..00000000 --- a/examples/MQ/4-copypush/ex4-copypush.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "fairMQOptions": { - "devices": [ - { - "id": "sampler1", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "push", - "method": "bind", - "address": "tcp://*:5555", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - }, - { - "type": "push", - "method": "bind", - "address": "tcp://*:5556", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - }, - { - "id": "sink1", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5555", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - }, - { - "id": "sink2", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5556", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - } - ] - } -} diff --git a/examples/MQ/4-copypush/startMQEx4.sh.in b/examples/MQ/4-copypush/startMQEx4.sh.in deleted file mode 100755 index c5f92956..00000000 --- a/examples/MQ/4-copypush/startMQEx4.sh.in +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -ex4config="@CMAKE_BINARY_DIR@/bin/config/ex4-copypush.json" - -SAMPLER="ex4-sampler" -SAMPLER+=" --id sampler1" -SAMPLER+=" --mq-config $ex4config" -xterm -geometry 80x23+0+165 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SAMPLER & - -SINK1="ex4-sink" -SINK1+=" --id sink1" -SINK1+=" --mq-config $ex4config" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SINK1 & - -SINK2="ex4-sink" -SINK2+=" --id sink2" -SINK2+=" --mq-config $ex4config" -xterm -geometry 80x23+500+330 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SINK2 & diff --git a/examples/MQ/5-req-rep/CMakeLists.txt b/examples/MQ/5-req-rep/CMakeLists.txt deleted file mode 100644 index 4ecb58d4..00000000 --- a/examples/MQ/5-req-rep/CMakeLists.txt +++ /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 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/5-req-rep/ex5-req-rep.json ${CMAKE_BINARY_DIR}/bin/config/ex5-req-rep.json) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/5-req-rep/startMQEx5.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/5-req-rep/startMQEx5.sh) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/5-req-rep/testMQEx5.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/5-req-rep/testMQEx5.sh) - -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}/examples/MQ/5-req-rep - ${CMAKE_CURRENT_BINARY_DIR} -) - -set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} - ${ZeroMQ_INCLUDE_DIR} -) - -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) - -set(BIN_DESTINATION share/fairbase/examples/MQ/5-req-rep/bin) -set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/5-req-rep") - -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}) - -add_test(NAME MQ.ex5-req-rep COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/5-req-rep/testMQEx5.sh) -set_tests_properties(MQ.ex5-req-rep PROPERTIES TIMEOUT "30") -set_tests_properties(MQ.ex5-req-rep PROPERTIES RUN_SERIAL true) -set_tests_properties(MQ.ex5-req-rep PROPERTIES PASS_REGULAR_EXPRESSION "Received reply from server: ") - -install( - FILES ex5-req-rep.json - DESTINATION share/fairbase/examples/MQ/5-req-rep/config/ -) diff --git a/examples/MQ/5-req-rep/ex5-req-rep.json b/examples/MQ/5-req-rep/ex5-req-rep.json deleted file mode 100644 index be5dd46c..00000000 --- a/examples/MQ/5-req-rep/ex5-req-rep.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "fairMQOptions": { - "devices": [ - { - "id": "client", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "req", - "method": "connect", - "address": "tcp://localhost:5005", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - }, - { - "id": "server", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "rep", - "method": "bind", - "address": "tcp://*:5005", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - } - ] - } -} diff --git a/examples/MQ/5-req-rep/runExample5Server.cxx b/examples/MQ/5-req-rep/runExample5Server.cxx deleted file mode 100644 index 8d1bea3b..00000000 --- a/examples/MQ/5-req-rep/runExample5Server.cxx +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#include "runFairMQDevice.h" -#include "FairMQExample5Server.h" - -namespace bpo = boost::program_options; - -void addCustomOptions(bpo::options_description& options) -{ - options.add_options() - ("max-iterations", bpo::value()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); -} - -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) -{ - return new FairMQExample5Server(); -} diff --git a/examples/MQ/5-req-rep/startMQEx5.sh.in b/examples/MQ/5-req-rep/startMQEx5.sh.in deleted file mode 100755 index 4245392b..00000000 --- a/examples/MQ/5-req-rep/startMQEx5.sh.in +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -ex5config="@CMAKE_BINARY_DIR@/bin/config/ex5-req-rep.json" - -CLIENT="ex5-client" -CLIENT+=" --id client" -CLIENT+=" --mq-config $ex5config" -xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/5-req-rep/$CLIENT & - -SERVER="ex5-server" -SERVER+=" --id server" -SERVER+=" --mq-config $ex5config" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/5-req-rep/$SERVER & diff --git a/examples/MQ/6-multiple-channels/CMakeLists.txt b/examples/MQ/6-multiple-channels/CMakeLists.txt deleted file mode 100644 index 3f119841..00000000 --- a/examples/MQ/6-multiple-channels/CMakeLists.txt +++ /dev/null @@ -1,86 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/6-multiple-channels/ex6-multiple-channels.json ${CMAKE_BINARY_DIR}/bin/config/ex6-multiple-channels.json) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/6-multiple-channels/startMQEx6.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/6-multiple-channels/startMQEx6.sh) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/6-multiple-channels/testMQEx6.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/6-multiple-channels/testMQEx6.sh) - -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}/examples/MQ/6-multiple-channels - ${CMAKE_CURRENT_BINARY_DIR} -) - -set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} - ${ZeroMQ_INCLUDE_DIR} -) - -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) - -set(BIN_DESTINATION share/fairbase/examples/MQ/6-multiple-channels/bin) -set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/6-multiple-channels") - -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}) - -add_test(NAME MQ.ex6-multiple-channels COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/6-multiple-channels/testMQEx6.sh) -set_tests_properties(MQ.ex6-multiple-channels PROPERTIES TIMEOUT "30") -set_tests_properties(MQ.ex6-multiple-channels PROPERTIES RUN_SERIAL true) -set_tests_properties(MQ.ex6-multiple-channels PROPERTIES PASS_REGULAR_EXPRESSION "Received messages from both sources.") - -install( - FILES ex6-multiple-channels.json - DESTINATION share/fairbase/examples/MQ/6-multiple-channels/config/ -) diff --git a/examples/MQ/6-multiple-channels/ex6-multiple-channels.json b/examples/MQ/6-multiple-channels/ex6-multiple-channels.json deleted file mode 100644 index 5519ad6c..00000000 --- a/examples/MQ/6-multiple-channels/ex6-multiple-channels.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "fairMQOptions": { - "devices": [ - { - "id": "sampler1", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "push", - "method": "bind", - "address": "tcp://*:5555", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - }, - { - "name": "broadcast", - "sockets": [ - { - "type": "sub", - "method": "connect", - "address": "tcp://localhost:5005", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - }, - { - "id": "sink1", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:5555", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - }, - { - "name": "broadcast", - "sockets": [ - { - "type": "sub", - "method": "connect", - "address": "tcp://localhost:5005", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - }, - { - "id": "broadcaster1", - "channels": [ - { - "name": "broadcast", - "sockets": [ - { - "type": "pub", - "method": "bind", - "address": "tcp://*:5005", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - } - ] - } -} diff --git a/examples/MQ/6-multiple-channels/runExample6Broadcaster.cxx b/examples/MQ/6-multiple-channels/runExample6Broadcaster.cxx deleted file mode 100644 index a2966fa7..00000000 --- a/examples/MQ/6-multiple-channels/runExample6Broadcaster.cxx +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#include "runFairMQDevice.h" -#include "FairMQExample6Broadcaster.h" - -namespace bpo = boost::program_options; - -void addCustomOptions(bpo::options_description& /*options*/) -{ -} - -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) -{ - return new FairMQExample6Broadcaster(); -} diff --git a/examples/MQ/6-multiple-channels/startMQEx6.sh.in b/examples/MQ/6-multiple-channels/startMQEx6.sh.in deleted file mode 100755 index fd01594c..00000000 --- a/examples/MQ/6-multiple-channels/startMQEx6.sh.in +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -ex6config="@CMAKE_BINARY_DIR@/bin/config/ex6-multiple-channels.json" - -SAMPLER="ex6-sampler" -SAMPLER+=" --id sampler1" -SAMPLER+=" --mq-config $ex6config" -xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/6-multiple-channels/$SAMPLER & - -SINK="ex6-sink" -SINK+=" --id sink1" -SINK+=" --mq-config $ex6config" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/6-multiple-channels/$SINK & - -BROADCASTER="ex6-broadcaster" -BROADCASTER+=" --id broadcaster1" -BROADCASTER+=" --mq-config $ex6config" -xterm -geometry 80x23+250+330 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/6-multiple-channels/$BROADCASTER & diff --git a/examples/MQ/8-multipart/CMakeLists.txt b/examples/MQ/8-multipart/CMakeLists.txt deleted file mode 100644 index 996dcaef..00000000 --- a/examples/MQ/8-multipart/CMakeLists.txt +++ /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 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/8-multipart/ex8-multipart.json ${CMAKE_BINARY_DIR}/bin/config/ex8-multipart.json) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/8-multipart/startMQEx8.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/8-multipart/startMQEx8.sh) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/8-multipart/testMQEx8.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/8-multipart/testMQEx8.sh) - -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}/examples/MQ/8-multipart - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} - ${ZeroMQ_INCLUDE_DIR} -) - -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) - -set(BIN_DESTINATION share/fairbase/examples/MQ/8-multipart/bin) -set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/8-multipart") - -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}) - -add_test(NAME MQ.ex8-multipart COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/8-multipart/testMQEx8.sh) -set_tests_properties(MQ.ex8-multipart PROPERTIES TIMEOUT "30") -set_tests_properties(MQ.ex8-multipart PROPERTIES RUN_SERIAL true) -set_tests_properties(MQ.ex8-multipart PROPERTIES PASS_REGULAR_EXPRESSION "Received message with 2 parts") - -Install( - FILES ex8-multipart.json - DESTINATION share/fairbase/examples/MQ/8-multipart/config/ -) diff --git a/examples/MQ/8-multipart/ex8-multipart.json b/examples/MQ/8-multipart/ex8-multipart.json deleted file mode 100644 index 2a38c2fe..00000000 --- a/examples/MQ/8-multipart/ex8-multipart.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "fairMQOptions": { - "devices": [ - { - "id": "sampler1", - "channels": [ - { - "name": "data-out", - "sockets": [ - { - "type": "push", - "method": "connect", - "address": "tcp://localhost:5555", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - }, - { - "id": "sink1", - "channels": [ - { - "name": "data-in", - "sockets": [ - { - "type": "pull", - "method": "bind", - "address": "tcp://*:5555", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 0 - } - ] - } - ] - } - ] - } -} diff --git a/examples/MQ/8-multipart/runExample8Sampler.cxx b/examples/MQ/8-multipart/runExample8Sampler.cxx deleted file mode 100644 index 3f6d5cc8..00000000 --- a/examples/MQ/8-multipart/runExample8Sampler.cxx +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#include "runFairMQDevice.h" -#include "FairMQExample8Sampler.h" - -namespace bpo = boost::program_options; - -void addCustomOptions(bpo::options_description& options) -{ - options.add_options() - ("max-iterations", bpo::value()->default_value(5), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); -} - -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) -{ - return new FairMQExample8Sampler(); -} diff --git a/examples/MQ/8-multipart/startMQEx8.sh.in b/examples/MQ/8-multipart/startMQEx8.sh.in deleted file mode 100755 index 002c44b2..00000000 --- a/examples/MQ/8-multipart/startMQEx8.sh.in +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -ex8config="@CMAKE_BINARY_DIR@/bin/config/ex8-multipart.json" - -SAMPLER="ex8-sampler" -SAMPLER+=" --id sampler1" -SAMPLER+=" --mq-config $ex8config" -xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/8-multipart/$SAMPLER & - -SINK="ex8-sink" -SINK+=" --id sink1" -SINK+=" --mq-config $ex8config" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/8-multipart/$SINK & diff --git a/examples/MQ/multiple-transports/CMakeLists.txt b/examples/MQ/multiple-transports/CMakeLists.txt deleted file mode 100644 index 56ee625d..00000000 --- a/examples/MQ/multiple-transports/CMakeLists.txt +++ /dev/null @@ -1,86 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/multiple-transports/ex-multiple-transports.json ${CMAKE_BINARY_DIR}/bin/config/ex-multiple-transports.json) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/multiple-transports/startMTEx.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/multiple-transports/startMTEx.sh) -configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/multiple-transports/testMTEx.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/multiple-transports/testMTEx.sh) - -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}/examples/MQ/multiple-transports - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} - ${ZeroMQ_INCLUDE_DIR} -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} -) - -Link_Directories(${LINK_DIRECTORIES}) - -Set(SRCS - "FairMQExampleMTSampler1.cxx" - "FairMQExampleMTSampler2.cxx" - "FairMQExampleMTSink.cxx" -) - -Set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ -) - -Set(LIBRARY_NAME FairMQExampleMT) - -GENERATE_LIBRARY() - -Set(Exe_Names - ex-mt-sampler1 - ex-mt-sampler2 - ex-mt-sink -) - -Set(Exe_Source - runExampleMTSampler1.cxx - runExampleMTSampler2.cxx - runExampleMTSink.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -set(BIN_DESTINATION share/fairbase/examples/MQ/multiple-transports/bin) -set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/multiple-transports") - -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 FairMQExampleMT) - GENERATE_EXECUTABLE() -EndForEach(_file RANGE 0 ${_length}) - -add_test(NAME MQ.ex-multiple-transports COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/multiple-transports/testMTEx.sh) -set_tests_properties(MQ.ex-multiple-transports PROPERTIES TIMEOUT "30") -set_tests_properties(MQ.ex-multiple-transports PROPERTIES RUN_SERIAL true) -set_tests_properties(MQ.ex-multiple-transports PROPERTIES PASS_REGULAR_EXPRESSION "Received messages from both sources.") - -Install( - FILES ex-multiple-transports.json - DESTINATION share/fairbase/examples/MQ/multiple-transports/config/ -) diff --git a/examples/MQ/multiple-transports/runExampleMTSampler1.cxx b/examples/MQ/multiple-transports/runExampleMTSampler1.cxx deleted file mode 100644 index ccb5a986..00000000 --- a/examples/MQ/multiple-transports/runExampleMTSampler1.cxx +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#include "runFairMQDevice.h" -#include "FairMQExampleMTSampler1.h" - -namespace bpo = boost::program_options; - -void addCustomOptions(bpo::options_description& options) -{ - options.add_options() - ("max-iterations", bpo::value()->default_value(5), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); -} - -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) -{ - return new FairMQExampleMTSampler1(); -} diff --git a/examples/MQ/multiple-transports/runExampleMTSampler2.cxx b/examples/MQ/multiple-transports/runExampleMTSampler2.cxx deleted file mode 100644 index c200372a..00000000 --- a/examples/MQ/multiple-transports/runExampleMTSampler2.cxx +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#include "runFairMQDevice.h" -#include "FairMQExampleMTSampler2.h" - -namespace bpo = boost::program_options; - -void addCustomOptions(bpo::options_description& options) -{ - options.add_options() - ("max-iterations", bpo::value()->default_value(5), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); -} - -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) -{ - return new FairMQExampleMTSampler2(); -} diff --git a/examples/MQ/multiple-transports/startMTEx.sh.in b/examples/MQ/multiple-transports/startMTEx.sh.in deleted file mode 100755 index e039171d..00000000 --- a/examples/MQ/multiple-transports/startMTEx.sh.in +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -config="@CMAKE_BINARY_DIR@/bin/config/ex-multiple-transports.json" - -SAMPLER1="ex-mt-sampler1" -SAMPLER1+=" --id sampler1" -SAMPLER1+=" --severity debug" -SAMPLER1+=" --transport shmem" -SAMPLER1+=" --mq-config $config" -xterm -geometry 80x30+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SAMPLER1 & - -SAMPLER2="ex-mt-sampler2" -SAMPLER2+=" --id sampler2" -SAMPLER2+=" --severity debug" -SAMPLER2+=" --transport nanomsg" -SAMPLER2+=" --mq-config $config" -xterm -geometry 80x30+0+450 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SAMPLER2 & - -SINK="ex-mt-sink" -SINK+=" --id sink1" -SINK+=" --severity debug" -SINK+=" --transport shmem" -SINK+=" --mq-config $config" -xterm -geometry 80x30+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SINK & diff --git a/examples/MQ/multiple-transports/testMTEx.sh.in b/examples/MQ/multiple-transports/testMTEx.sh.in deleted file mode 100755 index 478bba7e..00000000 --- a/examples/MQ/multiple-transports/testMTEx.sh.in +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -config="@CMAKE_BINARY_DIR@/bin/config/ex-multiple-transports.json" -SESSION="$(@CMAKE_BINARY_DIR@/bin/uuidGen -h)" - -trap 'kill -TERM $SAMPLER1_PID; kill -TERM $SAMPLER2_PID; kill -TERM $SINK_PID; wait $SAMPLER1_PID; wait $SAMPLER2_PID; wait $SINK_PID; @CMAKE_BINARY_DIR@/bin/shmmonitor --cleanup --session $SESSION;' TERM - -SINK="ex-mt-sink" -SINK+=" --id sink1" -SINK+=" --verbosity veryhigh" -SINK+=" --session $SESSION" -SINK+=" --max-iterations 1" -SINK+=" --control static --color false" -SINK+=" --transport shmem" -SINK+=" --mq-config $config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SINK & -SINK_PID=$! - -SAMPLER1="ex-mt-sampler1" -SAMPLER1+=" --id sampler1" -SAMPLER1+=" --session $SESSION" -SAMPLER1+=" --verbosity veryhigh" -SAMPLER1+=" --max-iterations 1" -SAMPLER1+=" --control static --color false" -SAMPLER1+=" --transport shmem" -SAMPLER1+=" --mq-config $config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SAMPLER1 & -SAMPLER1_PID=$! - -SAMPLER2="ex-mt-sampler2" -SAMPLER2+=" --id sampler2" -SAMPLER2+=" --session $SESSION" -SAMPLER2+=" --verbosity veryhigh" -SAMPLER2+=" --max-iterations 1" -SAMPLER2+=" --control static --color false" -SAMPLER2+=" --transport nanomsg" -SAMPLER2+=" --mq-config $config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SAMPLER2 & -SAMPLER2_PID=$! - -wait $SAMPLER1_PID -wait $SAMPLER2_PID -wait $SINK_PID diff --git a/examples/advanced/Region/CMakeLists.txt b/examples/advanced/Region/CMakeLists.txt deleted file mode 100644 index 0c1c7c7d..00000000 --- a/examples/advanced/Region/CMakeLists.txt +++ /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 (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - -configure_file(${CMAKE_SOURCE_DIR}/examples/advanced/Region/ex-region.json ${CMAKE_BINARY_DIR}/bin/config/ex-region.json) -configure_file(${CMAKE_SOURCE_DIR}/examples/advanced/Region/startMQExRegion.sh.in ${CMAKE_BINARY_DIR}/bin/examples/advanced/Region/startMQExRegion.sh) -configure_file(${CMAKE_SOURCE_DIR}/examples/advanced/Region/testMQExRegion.sh.in ${CMAKE_BINARY_DIR}/bin/examples/advanced/Region/testMQExRegion.sh) - -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}/examples/advanced/Region - ${CMAKE_CURRENT_BINARY_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${Boost_INCLUDE_DIR} - ${ZeroMQ_INCLUDE_DIR} -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} -) - -Link_Directories(${LINK_DIRECTORIES}) - -Set(SRCS - "FairMQExampleRegionSampler.cxx" - "FairMQExampleRegionSink.cxx" -) - -Set(DEPENDENCIES - ${DEPENDENCIES} - FairMQ -) - -Set(LIBRARY_NAME FairMQExampleRegion) - -GENERATE_LIBRARY() - -Set(Exe_Names - ex-region-sampler - ex-region-sink -) - -Set(Exe_Source - runExampleRegionSampler.cxx - runExampleRegionSink.cxx -) - -list(LENGTH Exe_Names _length) -math(EXPR _length ${_length}-1) - -set(BIN_DESTINATION share/fairbase/examples/advanced/Region/bin) -set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/advanced/Region") - -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 FairMQExampleRegion) - GENERATE_EXECUTABLE() -EndForEach(_file RANGE 0 ${_length}) - -add_test(NAME MQ.ex-advanced-region COMMAND ${CMAKE_BINARY_DIR}/bin/examples/advanced/Region/testMQExRegion.sh) -set_tests_properties(MQ.ex-advanced-region PROPERTIES TIMEOUT "30") -set_tests_properties(MQ.ex-advanced-region PROPERTIES RUN_SERIAL true) -set_tests_properties(MQ.ex-advanced-region PROPERTIES PASS_REGULAR_EXPRESSION "Received ack") - -Install( - FILES ex-region.json - DESTINATION share/fairbase/examples/advanced/Region/config/ -) diff --git a/examples/advanced/Region/ex-region.json b/examples/advanced/Region/ex-region.json deleted file mode 100644 index 98113071..00000000 --- a/examples/advanced/Region/ex-region.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "fairMQOptions": { - "devices": [ - { - "id": "sampler1", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "push", - "method": "bind", - "address": "tcp://*:7777", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 1 - } - ] - } - ] - }, - { - "id": "sink1", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "pull", - "method": "connect", - "address": "tcp://localhost:7777", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 1 - } - ] - } - ] - } - ] - } -} diff --git a/examples/advanced/Region/runExampleRegionSink.cxx b/examples/advanced/Region/runExampleRegionSink.cxx deleted file mode 100644 index a9bcd83c..00000000 --- a/examples/advanced/Region/runExampleRegionSink.cxx +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#include "runFairMQDevice.h" -#include "FairMQExampleRegionSink.h" - -namespace bpo = boost::program_options; - -void addCustomOptions(bpo::options_description& options) -{ - options.add_options() - ("max-iterations", bpo::value()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); -} - -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) -{ - return new FairMQExampleRegionSink(); -} diff --git a/examples/advanced/Region/startMQExRegion.sh.in b/examples/advanced/Region/startMQExRegion.sh.in deleted file mode 100755 index 40789b90..00000000 --- a/examples/advanced/Region/startMQExRegion.sh.in +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -exRegionConfig="@CMAKE_BINARY_DIR@/bin/config/ex-region.json" - -msgSize="1000000" - -if [[ $1 =~ ^[0-9]+$ ]]; then - msgSize=$1 -fi - -SAMPLER="ex-region-sampler" -SAMPLER+=" --id sampler1" -SAMPLER+=" --severity debug" -SAMPLER+=" --msg-size $msgSize" -# SAMPLER+=" --rate 10" -SAMPLER+=" --transport shmem" -SAMPLER+=" --mq-config $exRegionConfig" -xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/advanced/Region/$SAMPLER & - -SINK="ex-region-sink" -SINK+=" --id sink1" -SINK+=" --severity debug" -SINK+=" --transport shmem" -SINK+=" --mq-config $exRegionConfig" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/advanced/Region/$SINK & diff --git a/examples/copypush/CMakeLists.txt b/examples/copypush/CMakeLists.txt new file mode 100644 index 00000000..455c89cb --- /dev/null +++ b/examples/copypush/CMakeLists.txt @@ -0,0 +1,51 @@ +################################################################################ +# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +add_library(ExampleCopyPushLib STATIC + "Sampler.cxx" + "Sampler.h" + "Sink.cxx" + "Sink.h" +) + +target_link_libraries(ExampleCopyPushLib PUBLIC FairMQ) + +add_executable(fairmq-ex-copypush-sampler runSampler.cxx) +target_link_libraries(fairmq-ex-copypush-sampler PRIVATE ExampleCopyPushLib) + + +add_executable(fairmq-ex-copypush-sink runSink.cxx) +target_link_libraries(fairmq-ex-copypush-sink PRIVATE ExampleCopyPushLib) + +add_custom_target(ExampleCopyPush DEPENDS fairmq-ex-copypush-sampler fairmq-ex-copypush-sink) + +install( + TARGETS + fairmq-ex-copypush-sampler + fairmq-ex-copypush-sink + + LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} + RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} +) + +# configure run script with different executable paths for build and for install directories +set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-copypush.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-copypush.sh) +set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-copypush.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-copypush.sh_install) + +install( + PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-copypush.sh_install + DESTINATION ${PROJECT_INSTALL_BINDIR} + RENAME fairmq-start-ex-copypush.sh +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-copypush.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh) + +add_test(NAME Example-CopyPush COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh) +set_tests_properties(Example-CopyPush PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message: ") diff --git a/examples/MQ/4-copypush/README.md b/examples/copypush/README.md similarity index 100% rename from examples/MQ/4-copypush/README.md rename to examples/copypush/README.md diff --git a/examples/MQ/4-copypush/FairMQExample4Sampler.cxx b/examples/copypush/Sampler.cxx similarity index 84% rename from examples/MQ/4-copypush/FairMQExample4Sampler.cxx rename to examples/copypush/Sampler.cxx index 517811e5..3575e4e7 100644 --- a/examples/MQ/4-copypush/FairMQExample4Sampler.cxx +++ b/examples/copypush/Sampler.cxx @@ -6,7 +6,7 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample4Sampler.cpp + * Sampler.cpp * * @since 2014-10-10 * @author A. Rybalchenko @@ -15,13 +15,14 @@ #include // this_thread::sleep_for #include -#include "FairMQExample4Sampler.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig +#include "Sampler.h" using namespace std; -FairMQExample4Sampler::FairMQExample4Sampler() +namespace example_copypush +{ + +Sampler::Sampler() : fNumDataChannels(0) , fCounter(0) , fMaxIterations(0) @@ -29,13 +30,13 @@ FairMQExample4Sampler::FairMQExample4Sampler() { } -void FairMQExample4Sampler::InitTask() +void Sampler::InitTask() { fNumDataChannels = fChannels.at("data").size(); fMaxIterations = fConfig->GetValue("max-iterations"); } -bool FairMQExample4Sampler::ConditionalRun() +bool Sampler::ConditionalRun() { // NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place). @@ -61,6 +62,8 @@ bool FairMQExample4Sampler::ConditionalRun() return true; } -FairMQExample4Sampler::~FairMQExample4Sampler() +Sampler::~Sampler() { } + +} // namespace example_copypush diff --git a/examples/MQ/4-copypush/FairMQExample4Sampler.h b/examples/copypush/Sampler.h similarity index 76% rename from examples/MQ/4-copypush/FairMQExample4Sampler.h rename to examples/copypush/Sampler.h index 40714205..66bbb1dd 100644 --- a/examples/MQ/4-copypush/FairMQExample4Sampler.h +++ b/examples/copypush/Sampler.h @@ -6,24 +6,27 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample4Sampler.h + * Sampler.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE4SAMPLER_H_ -#define FAIRMQEXAMPLE4SAMPLER_H_ +#ifndef FAIRMQEXAMPLECOPYPUSHSAMPLER_H +#define FAIRMQEXAMPLECOPYPUSHSAMPLER_H #include "FairMQDevice.h" #include // uint64_t -class FairMQExample4Sampler : public FairMQDevice +namespace example_copypush +{ + +class Sampler : public FairMQDevice { public: - FairMQExample4Sampler(); - virtual ~FairMQExample4Sampler(); + Sampler(); + virtual ~Sampler(); protected: virtual void InitTask(); @@ -35,4 +38,6 @@ class FairMQExample4Sampler : public FairMQDevice uint64_t fNumIterations; }; -#endif /* FAIRMQEXAMPLE4SAMPLER_H_ */ +} // namespace example_copypush + +#endif /* FAIRMQEXAMPLECOPYPUSHSAMPLER_H */ diff --git a/examples/MQ/4-copypush/FairMQExample4Sink.cxx b/examples/copypush/Sink.cxx similarity index 72% rename from examples/MQ/4-copypush/FairMQExample4Sink.cxx rename to examples/copypush/Sink.cxx index 6e513e2b..1b1d1f6d 100644 --- a/examples/MQ/4-copypush/FairMQExample4Sink.cxx +++ b/examples/copypush/Sink.cxx @@ -1,37 +1,36 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample4Sink.cxx + * Sink.cxx * * @since 2014-10-10 * @author A. Rybalchenko */ -#include "FairMQExample4Sink.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig +#include "Sink.h" -#include // uint64_t +namespace example_copypush +{ -FairMQExample4Sink::FairMQExample4Sink() +Sink::Sink() : fMaxIterations(0) , fNumIterations(0) { - OnData("data", &FairMQExample4Sink::HandleData); + OnData("data", &Sink::HandleData); } -void FairMQExample4Sink::InitTask() +void Sink::InitTask() { // Get the fMaxIterations value from the command line options (via fConfig) fMaxIterations = fConfig->GetValue("max-iterations"); } -bool FairMQExample4Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) { LOG(info) << "Received message: \"" << *(static_cast(msg->GetData())) << "\""; @@ -45,6 +44,8 @@ bool FairMQExample4Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) return true; } -FairMQExample4Sink::~FairMQExample4Sink() +Sink::~Sink() { } + +} // namespace example_copypush diff --git a/examples/MQ/4-copypush/FairMQExample4Sink.h b/examples/copypush/Sink.h similarity index 71% rename from examples/MQ/4-copypush/FairMQExample4Sink.h rename to examples/copypush/Sink.h index 60fa921d..acbf80a4 100644 --- a/examples/MQ/4-copypush/FairMQExample4Sink.h +++ b/examples/copypush/Sink.h @@ -1,27 +1,32 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample4Sink.h + * Sink.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE4SINK_H_ -#define FAIRMQEXAMPLE4SINK_H_ +#ifndef FAIRMQEXAMPLECOPYPUSHSINK_H +#define FAIRMQEXAMPLECOPYPUSHSINK_H #include "FairMQDevice.h" -class FairMQExample4Sink : public FairMQDevice +#include // uint64_t + +namespace example_copypush +{ + +class Sink : public FairMQDevice { public: - FairMQExample4Sink(); - virtual ~FairMQExample4Sink(); + Sink(); + virtual ~Sink(); protected: virtual void InitTask(); @@ -32,4 +37,6 @@ class FairMQExample4Sink : public FairMQDevice uint64_t fNumIterations; }; -#endif /* FAIRMQEXAMPLE4SINK_H_ */ +} // namespace example_copypush + +#endif /* FAIRMQEXAMPLECOPYPUSHSINK_H */ diff --git a/examples/copypush/fairmq-start-ex-copypush.sh.in b/examples/copypush/fairmq-start-ex-copypush.sh.in new file mode 100755 index 00000000..32ced02b --- /dev/null +++ b/examples/copypush/fairmq-start-ex-copypush.sh.in @@ -0,0 +1,16 @@ +#!/bin/bash + +SAMPLER="fairmq-ex-copypush-sampler" +SAMPLER+=" --id sampler1" +SAMPLER+=" --channel-config name=data,type=push,method=bind,rateLogging=0,address=tcp://*:5555,address=tcp://*:5556" +xterm -geometry 80x23+0+165 -hold -e @EX_BIN_DIR@/$SAMPLER & + +SINK1="fairmq-ex-copypush-sink" +SINK1+=" --id sink1" +SINK1+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5555" +xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$SINK1 & + +SINK2="fairmq-ex-copypush-sink" +SINK2+=" --id sink2" +SINK2+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5556" +xterm -geometry 80x23+500+330 -hold -e @EX_BIN_DIR@/$SINK2 & diff --git a/examples/MQ/2-sampler-processor-sink/runExample2Sink.cxx b/examples/copypush/runSampler.cxx similarity index 89% rename from examples/MQ/2-sampler-processor-sink/runExample2Sink.cxx rename to examples/copypush/runSampler.cxx index 50787a47..8c417e59 100644 --- a/examples/MQ/2-sampler-processor-sink/runExample2Sink.cxx +++ b/examples/copypush/runSampler.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample2Sink.h" +#include "Sampler.h" namespace bpo = boost::program_options; @@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample2Sink(); + return new example_copypush::Sampler(); } diff --git a/examples/MQ/1-sampler-sink/runExample1Sink.cxx b/examples/copypush/runSink.cxx similarity index 89% rename from examples/MQ/1-sampler-sink/runExample1Sink.cxx rename to examples/copypush/runSink.cxx index 4344bead..5afc6a47 100644 --- a/examples/MQ/1-sampler-sink/runExample1Sink.cxx +++ b/examples/copypush/runSink.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample1Sink.h" +#include "Sink.h" namespace bpo = boost::program_options; @@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample1Sink(); + return new example_copypush::Sink(); } diff --git a/examples/MQ/4-copypush/testMQEx4.sh.in b/examples/copypush/test-ex-copypush.sh.in similarity index 57% rename from examples/MQ/4-copypush/testMQEx4.sh.in rename to examples/copypush/test-ex-copypush.sh.in index 54f216e2..ee8612ae 100755 --- a/examples/MQ/4-copypush/testMQEx4.sh.in +++ b/examples/copypush/test-ex-copypush.sh.in @@ -1,35 +1,33 @@ #!/bin/bash -ex4config="@CMAKE_BINARY_DIR@/bin/config/ex4-copypush.json" - # setup a trap to kill everything if the test fails/timeouts trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK1_PID; kill -TERM $SINK2_PID; wait $SAMPLER_PID; wait $SINK1_PID; wait $SINK2_PID;' TERM -SAMPLER="ex4-sampler" +SAMPLER="fairmq-ex-copypush-sampler" SAMPLER+=" --id sampler1" SAMPLER+=" --verbosity veryhigh" SAMPLER+=" --control static --color false" SAMPLER+=" --max-iterations 1" -SAMPLER+=" --mq-config $ex4config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SAMPLER & +SAMPLER+=" --channel-config name=data,type=push,method=bind,rateLogging=0,address=tcp://*:5555,address=tcp://*:5556" +@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & SAMPLER_PID=$! -SINK1="ex4-sink" +SINK1="fairmq-ex-copypush-sink" SINK1+=" --id sink1" SINK1+=" --verbosity veryhigh" SINK1+=" --control static --color false" SINK1+=" --max-iterations 1" -SINK1+=" --mq-config $ex4config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SINK1 & +SINK1+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5555" +@CMAKE_CURRENT_BINARY_DIR@/$SINK1 & SINK1_PID=$! -SINK2="ex4-sink" +SINK2="fairmq-ex-copypush-sink" SINK2+=" --id sink2" SINK2+=" --verbosity veryhigh" SINK2+=" --control static --color false" SINK2+=" --max-iterations 1" -SINK2+=" --mq-config $ex4config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SINK2 & +SINK2+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5556" +@CMAKE_CURRENT_BINARY_DIR@/$SINK2 & SINK2_PID=$! # wait for everything to finish diff --git a/examples/dds/CMakeLists.txt b/examples/dds/CMakeLists.txt new file mode 100644 index 00000000..7274d20d --- /dev/null +++ b/examples/dds/CMakeLists.txt @@ -0,0 +1,60 @@ +################################################################################ +# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +add_library(ExampleDDSLib STATIC + "Sampler.cxx" + "Sampler.h" + "Processor.cxx" + "Processor.h" + "Sink.cxx" + "Sink.h" +) + +target_link_libraries(ExampleDDSLib PUBLIC FairMQ) + +add_executable(fairmq-ex-dds-sampler runSampler.cxx) +target_link_libraries(fairmq-ex-dds-sampler PRIVATE ExampleDDSLib) + +add_executable(fairmq-ex-dds-processor runProcessor.cxx) +target_link_libraries(fairmq-ex-dds-processor PRIVATE ExampleDDSLib) + +add_executable(fairmq-ex-dds-sink runSink.cxx) +target_link_libraries(fairmq-ex-dds-sink PRIVATE ExampleDDSLib) + +add_custom_target(ExampleDDS DEPENDS fairmq-ex-dds-sampler fairmq-ex-dds-processor fairmq-ex-dds-sink) + +install( + TARGETS + fairmq-ex-dds-sampler + fairmq-ex-dds-processor + fairmq-ex-dds-sink + + LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} + RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} +) + +# configure run script with different executable paths for build and for install directories +set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(DDS_PLUGIN_LIB_DIR ${CMAKE_BINARY_DIR}/fairmq/plugins/DDS) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-dds-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology.xml @ONLY) +set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}) +set(DDS_PLUGIN_LIB_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_LIBDIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-dds-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology.xml_install @ONLY) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-dds-hosts.cfg ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-hosts.cfg COPYONLY) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology.xml_install + DESTINATION ${PROJECT_INSTALL_BINDIR} + RENAME ex-dds-topology.xml +) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-hosts.cfg + DESTINATION ${PROJECT_INSTALL_BINDIR} +) diff --git a/examples/MQ/3-dds/FairMQExample3Processor.cxx b/examples/dds/Processor.cxx similarity index 81% rename from examples/MQ/3-dds/FairMQExample3Processor.cxx rename to examples/dds/Processor.cxx index 7af01b50..53a96c95 100644 --- a/examples/MQ/3-dds/FairMQExample3Processor.cxx +++ b/examples/dds/Processor.cxx @@ -1,22 +1,25 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#include "FairMQExample3Processor.h" +#include "Processor.h" #include "FairMQLogger.h" using namespace std; -FairMQExample3Processor::FairMQExample3Processor() +namespace example_dds { - OnData("data1", &FairMQExample3Processor::HandleData); + +Processor::Processor() +{ + OnData("data1", &Processor::HandleData); } -bool FairMQExample3Processor::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool Processor::HandleData(FairMQMessagePtr& msg, int /*index*/) { LOG(info) << "Received data, processing..."; @@ -42,6 +45,8 @@ bool FairMQExample3Processor::HandleData(FairMQMessagePtr& msg, int /*index*/) return true; } -FairMQExample3Processor::~FairMQExample3Processor() +Processor::~Processor() { } + +} // namespace example_dds diff --git a/examples/MQ/3-dds/FairMQExample3Processor.h b/examples/dds/Processor.h similarity index 74% rename from examples/MQ/3-dds/FairMQExample3Processor.h rename to examples/dds/Processor.h index f8b106ef..c8530fee 100644 --- a/examples/MQ/3-dds/FairMQExample3Processor.h +++ b/examples/dds/Processor.h @@ -6,19 +6,24 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#ifndef FAIRMQEXAMPLE2PROCESSOR_H_ -#define FAIRMQEXAMPLE2PROCESSOR_H_ +#ifndef FAIRMQEXAMPLEDDSPROCESSOR_H +#define FAIRMQEXAMPLEDDSPROCESSOR_H #include "FairMQDevice.h" -class FairMQExample3Processor : public FairMQDevice +namespace example_dds +{ + +class Processor : public FairMQDevice { public: - FairMQExample3Processor(); - virtual ~FairMQExample3Processor(); + Processor(); + virtual ~Processor(); protected: bool HandleData(FairMQMessagePtr&, int); }; -#endif /* FAIRMQEXAMPLE3PROCESSOR_H_ */ +} + +#endif /* FAIRMQEXAMPLEDDSPROCESSOR_H */ diff --git a/examples/MQ/3-dds/README.md b/examples/dds/README.md similarity index 100% rename from examples/MQ/3-dds/README.md rename to examples/dds/README.md diff --git a/examples/MQ/3-dds/FairMQExample3Sampler.cxx b/examples/dds/Sampler.cxx similarity index 82% rename from examples/MQ/3-dds/FairMQExample3Sampler.cxx rename to examples/dds/Sampler.cxx index 5b8521d2..e4fb3fa9 100644 --- a/examples/MQ/3-dds/FairMQExample3Sampler.cxx +++ b/examples/dds/Sampler.cxx @@ -6,7 +6,7 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample3Sampler.cpp + * Sampler.cpp * * @since 2014-10-10 * @author A. Rybalchenko @@ -15,17 +15,18 @@ #include // this_thread::sleep_for #include -#include "FairMQExample3Sampler.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig +#include "Sampler.h" using namespace std; -FairMQExample3Sampler::FairMQExample3Sampler() +namespace example_dds +{ + +Sampler::Sampler() { } -bool FairMQExample3Sampler::ConditionalRun() +bool Sampler::ConditionalRun() { std::this_thread::sleep_for(std::chrono::seconds(1)); @@ -45,6 +46,8 @@ bool FairMQExample3Sampler::ConditionalRun() return true; } -FairMQExample3Sampler::~FairMQExample3Sampler() +Sampler::~Sampler() { } + +} diff --git a/examples/MQ/6-multiple-channels/FairMQExample6Broadcaster.h b/examples/dds/Sampler.h similarity index 72% rename from examples/MQ/6-multiple-channels/FairMQExample6Broadcaster.h rename to examples/dds/Sampler.h index 1b920153..cb4556d4 100644 --- a/examples/MQ/6-multiple-channels/FairMQExample6Broadcaster.h +++ b/examples/dds/Sampler.h @@ -6,25 +6,30 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample6Broadcaster.h + * Sampler.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE6BROADCASTER_H_ -#define FAIRMQEXAMPLE6BROADCASTER_H_ +#ifndef FAIRMQEXAMPLEDDSSAMPLER_H +#define FAIRMQEXAMPLEDDSSAMPLER_H #include "FairMQDevice.h" -class FairMQExample6Broadcaster : public FairMQDevice +namespace example_dds +{ + +class Sampler : public FairMQDevice { public: - FairMQExample6Broadcaster(); - virtual ~FairMQExample6Broadcaster(); + Sampler(); + virtual ~Sampler(); protected: virtual bool ConditionalRun(); }; -#endif /* FAIRMQEXAMPLE6BROADCASTER_H_ */ +} // namespace example_dds + +#endif /* FAIRMQEXAMPLEDDSSAMPLER_H */ diff --git a/examples/MQ/3-dds/FairMQExample3Sink.cxx b/examples/dds/Sink.cxx similarity index 78% rename from examples/MQ/3-dds/FairMQExample3Sink.cxx rename to examples/dds/Sink.cxx index 329fc062..e4df0731 100644 --- a/examples/MQ/3-dds/FairMQExample3Sink.cxx +++ b/examples/dds/Sink.cxx @@ -6,25 +6,27 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample3Sink.cxx + * Sink.cxx * * @since 2014-10-10 * @author A. Rybalchenko */ -#include "FairMQExample3Sink.h" -#include "FairMQLogger.h" +#include "Sink.h" using namespace std; -FairMQExample3Sink::FairMQExample3Sink() +namespace example_dds +{ + +Sink::Sink() { // register a handler for data arriving on "data2" channel - OnData("data2", &FairMQExample3Sink::HandleData); + OnData("data2", &Sink::HandleData); } // handler is called whenever a message arrives on "data2", with a reference to the message and a sub-channel index (here 0) -bool FairMQExample3Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) { LOG(info) << "Received: \"" << string(static_cast(msg->GetData()), msg->GetSize()) << "\""; @@ -32,6 +34,8 @@ bool FairMQExample3Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) return true; } -FairMQExample3Sink::~FairMQExample3Sink() +Sink::~Sink() { } + +} // namespace example_dds diff --git a/examples/MQ/3-dds/FairMQExample3Sink.h b/examples/dds/Sink.h similarity index 72% rename from examples/MQ/3-dds/FairMQExample3Sink.h rename to examples/dds/Sink.h index 9a7e582e..88a345f9 100644 --- a/examples/MQ/3-dds/FairMQExample3Sink.h +++ b/examples/dds/Sink.h @@ -1,30 +1,35 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample3Sink.h + * Sink.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE3SINK_H_ -#define FAIRMQEXAMPLE3SINK_H_ +#ifndef FAIRMQEXAMPLEDDSSINK_H +#define FAIRMQEXAMPLEDDSSINK_H #include "FairMQDevice.h" -class FairMQExample3Sink : public FairMQDevice +namespace example_dds +{ + +class Sink : public FairMQDevice { public: - FairMQExample3Sink(); - virtual ~FairMQExample3Sink(); + Sink(); + virtual ~Sink(); protected: bool HandleData(FairMQMessagePtr&, int); }; -#endif /* FAIRMQEXAMPLE3SINK_H_ */ +} // namespace example_dds + +#endif /* FAIRMQEXAMPLEDDSSINK_H */ diff --git a/examples/MQ/3-dds/ex3-dds-hosts.cfg b/examples/dds/ex-dds-hosts.cfg similarity index 100% rename from examples/MQ/3-dds/ex3-dds-hosts.cfg rename to examples/dds/ex-dds-hosts.cfg diff --git a/examples/MQ/3-dds/ex3-dds-topology.xml b/examples/dds/ex-dds-topology.xml similarity index 63% rename from examples/MQ/3-dds/ex3-dds-topology.xml rename to examples/dds/ex-dds-topology.xml index dcfac5fb..a0ffff88 100644 --- a/examples/MQ/3-dds/ex3-dds-topology.xml +++ b/examples/dds/ex-dds-topology.xml @@ -8,7 +8,7 @@ - @CMAKE_BINARY_DIR@/bin/examples/MQ/3-dds/ex3-sampler --id sampler --color false --channel-config name=data1,type=push,method=bind -S "<@CMAKE_BINARY_DIR@/lib" -P dds + @EX_BIN_DIR@/fairmq-ex-dds-sampler --id sampler --color false --channel-config name=data1,type=push,method=bind -S "<@DDS_PLUGIN_LIB_DIR@/" -P dds SamplerWorker @@ -18,7 +18,7 @@ - @CMAKE_BINARY_DIR@/bin/examples/MQ/3-dds/ex3-processor --id processor_%taskIndex% --config-key processor --color false --channel-config name=data1,type=pull,method=connect name=data2,type=push,method=connect -S "<@CMAKE_BINARY_DIR@/lib" -P dds + @EX_BIN_DIR@/fairmq-ex-dds-processor --id processor_%taskIndex% --config-key processor --color false --channel-config name=data1,type=pull,method=connect name=data2,type=push,method=connect -S "<@DDS_PLUGIN_LIB_DIR@/" -P dds ProcessorWorker @@ -29,7 +29,7 @@ - @CMAKE_BINARY_DIR@/bin/examples/MQ/3-dds/ex3-sink --id sink --color false --channel-config name=data2,type=pull,method=bind -S "<@CMAKE_BINARY_DIR@/lib" -P dds + @EX_BIN_DIR@/fairmq-ex-dds-sink --id sink --color false --channel-config name=data2,type=pull,method=bind -S "<@DDS_PLUGIN_LIB_DIR@/" -P dds SinkWorker diff --git a/examples/MQ/8-multipart/runExample8Sink.cxx b/examples/dds/runProcessor.cxx similarity index 87% rename from examples/MQ/8-multipart/runExample8Sink.cxx rename to examples/dds/runProcessor.cxx index 95eb4b1a..ae5d09b7 100644 --- a/examples/MQ/8-multipart/runExample8Sink.cxx +++ b/examples/dds/runProcessor.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample8Sink.h" +#include "Processor.h" namespace bpo = boost::program_options; @@ -17,5 +17,5 @@ void addCustomOptions(bpo::options_description& /*options*/) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample8Sink(); + return new example_dds::Processor(); } diff --git a/examples/MQ/3-dds/runExample3Sampler.cxx b/examples/dds/runSampler.cxx similarity index 86% rename from examples/MQ/3-dds/runExample3Sampler.cxx rename to examples/dds/runSampler.cxx index 90473203..fff91f4b 100644 --- a/examples/MQ/3-dds/runExample3Sampler.cxx +++ b/examples/dds/runSampler.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample3Sampler.h" +#include "Sampler.h" namespace bpo = boost::program_options; @@ -17,5 +17,5 @@ void addCustomOptions(bpo::options_description& /*options*/) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample3Sampler(); + return new example_dds::Sampler(); } diff --git a/examples/MQ/3-dds/runExample3Processor.cxx b/examples/dds/runSink.cxx similarity index 86% rename from examples/MQ/3-dds/runExample3Processor.cxx rename to examples/dds/runSink.cxx index 6d4abf21..c4f73f9a 100644 --- a/examples/MQ/3-dds/runExample3Processor.cxx +++ b/examples/dds/runSink.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample3Processor.h" +#include "Sink.h" namespace bpo = boost::program_options; @@ -17,5 +17,5 @@ void addCustomOptions(bpo::options_description& /*options*/) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample3Processor(); + return new example_dds::Sink(); } diff --git a/examples/multipart/CMakeLists.txt b/examples/multipart/CMakeLists.txt new file mode 100644 index 00000000..33ad6f97 --- /dev/null +++ b/examples/multipart/CMakeLists.txt @@ -0,0 +1,50 @@ + ################################################################################ + # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # # + # This software is distributed under the terms of the # + # GNU Lesser General Public Licence (LGPL) version 3, # + # copied verbatim in the file "LICENSE" # + ################################################################################ + +add_library(ExampleMultipartLib STATIC + "Sampler.cxx" + "Sampler.h" + "Sink.cxx" + "Sink.h" +) + +target_link_libraries(ExampleMultipartLib PUBLIC FairMQ) + +add_executable(fairmq-ex-multipart-sampler runSampler.cxx) +target_link_libraries(fairmq-ex-multipart-sampler PRIVATE ExampleMultipartLib) + +add_executable(fairmq-ex-multipart-sink runSink.cxx) +target_link_libraries(fairmq-ex-multipart-sink PRIVATE ExampleMultipartLib) + +add_custom_target(ExampleMultipart DEPENDS fairmq-ex-multipart-sampler fairmq-ex-multipart-sink) + +install( + TARGETS + fairmq-ex-multipart-sampler + fairmq-ex-multipart-sink + + LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} + RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} +) + +# configure run script with different executable paths for build and for install directories +set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multipart.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multipart.sh) +set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multipart.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multipart.sh_install) + +install( + PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multipart.sh_install + DESTINATION ${PROJECT_INSTALL_BINDIR} + RENAME fairmq-start-ex-multipart.sh +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-multipart.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh) + +add_test(NAME Example-Multipart COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh) +set_tests_properties(Example-Multipart PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message with 2 parts") diff --git a/examples/MQ/8-multipart/FairMQEx8Header.h b/examples/multipart/Header.h similarity index 73% rename from examples/MQ/8-multipart/FairMQEx8Header.h rename to examples/multipart/Header.h index e2efd38d..c827dd81 100644 --- a/examples/MQ/8-multipart/FairMQEx8Header.h +++ b/examples/multipart/Header.h @@ -1,17 +1,22 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#ifndef FAIRMQEX8HEADER_H_ -#define FAIRMQEX8HEADER_H_ +#ifndef FAIRMQEXAMPLEMULTIPARTHEADER_H +#define FAIRMQEXAMPLEMULTIPARTHEADER_H -struct Ex8Header +namespace example_multipart +{ + +struct Header { int32_t stopFlag; }; -#endif /* FAIRMQEX8HEADER_H_ */ \ No newline at end of file +} + +#endif /* FAIRMQEXAMPLEMULTIPARTHEADER_H */ \ No newline at end of file diff --git a/examples/MQ/8-multipart/README.md b/examples/multipart/README.md similarity index 100% rename from examples/MQ/8-multipart/README.md rename to examples/multipart/README.md diff --git a/examples/MQ/8-multipart/FairMQExample8Sampler.cxx b/examples/multipart/Sampler.cxx similarity index 81% rename from examples/MQ/8-multipart/FairMQExample8Sampler.cxx rename to examples/multipart/Sampler.cxx index aa0e1ffe..8c61f36b 100644 --- a/examples/MQ/8-multipart/FairMQExample8Sampler.cxx +++ b/examples/multipart/Sampler.cxx @@ -1,12 +1,12 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample8Sampler.cpp + * Sampler.cpp * * @since 2014-10-10 * @author A. Rybalchenko @@ -15,27 +15,28 @@ #include // this_thread::sleep_for #include -#include "FairMQExample8Sampler.h" -#include "FairMQEx8Header.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" +#include "Sampler.h" +#include "Header.h" using namespace std; -FairMQExample8Sampler::FairMQExample8Sampler() +namespace example_multipart +{ + +Sampler::Sampler() : fMaxIterations(5) , fNumIterations(0) { } -void FairMQExample8Sampler::InitTask() +void Sampler::InitTask() { fMaxIterations = fConfig->GetValue("max-iterations"); } -bool FairMQExample8Sampler::ConditionalRun() +bool Sampler::ConditionalRun() { - Ex8Header header; + Header header; header.stopFlag = 0; // Set stopFlag to 1 for last message. @@ -54,7 +55,7 @@ bool FairMQExample8Sampler::ConditionalRun() LOG(info) << "Sending body of size: " << parts.At(1)->GetSize(); - Send(parts, "data-out"); + Send(parts, "data"); // Go out of the sending loop if the stopFlag was sent. if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) @@ -69,6 +70,8 @@ bool FairMQExample8Sampler::ConditionalRun() return true; } -FairMQExample8Sampler::~FairMQExample8Sampler() +Sampler::~Sampler() { } + +} // namespace example_multipart \ No newline at end of file diff --git a/examples/MQ/8-multipart/FairMQExample8Sampler.h b/examples/multipart/Sampler.h similarity index 72% rename from examples/MQ/8-multipart/FairMQExample8Sampler.h rename to examples/multipart/Sampler.h index 44327724..da059184 100644 --- a/examples/MQ/8-multipart/FairMQExample8Sampler.h +++ b/examples/multipart/Sampler.h @@ -1,27 +1,30 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample8Sampler.h + * Sampler.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE8SAMPLER_H_ -#define FAIRMQEXAMPLE8SAMPLER_H_ +#ifndef FAIRMQEXAMPLEDDSSAMPLER_H +#define FAIRMQEXAMPLEDDSSAMPLER_H #include "FairMQDevice.h" -class FairMQExample8Sampler : public FairMQDevice +namespace example_multipart +{ + +class Sampler : public FairMQDevice { public: - FairMQExample8Sampler(); - virtual ~FairMQExample8Sampler(); + Sampler(); + virtual ~Sampler(); protected: virtual void InitTask(); @@ -32,4 +35,6 @@ class FairMQExample8Sampler : public FairMQDevice uint64_t fNumIterations; }; -#endif /* FAIRMQEXAMPLE8SAMPLER_H_ */ +} // namespace example_multipart + +#endif /* FAIRMQEXAMPLEDDSSAMPLER_H */ diff --git a/examples/MQ/8-multipart/FairMQExample8Sink.cxx b/examples/multipart/Sink.cxx similarity index 70% rename from examples/MQ/8-multipart/FairMQExample8Sink.cxx rename to examples/multipart/Sink.cxx index c111c95d..82931238 100644 --- a/examples/MQ/8-multipart/FairMQExample8Sink.cxx +++ b/examples/multipart/Sink.cxx @@ -6,27 +6,29 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample8Sink.cxx + * Sink.cxx * * @since 2014-10-10 * @author A. Rybalchenko */ -#include "FairMQExample8Sink.h" -#include "FairMQEx8Header.h" -#include "FairMQLogger.h" +#include "Sink.h" +#include "Header.h" using namespace std; -FairMQExample8Sink::FairMQExample8Sink() +namespace example_multipart { - OnData("data-in", &FairMQExample8Sink::HandleData); + +Sink::Sink() +{ + OnData("data", &Sink::HandleData); } -bool FairMQExample8Sink::HandleData(FairMQParts& parts, int /*index*/) +bool Sink::HandleData(FairMQParts& parts, int /*index*/) { - Ex8Header header; - header.stopFlag = (static_cast(parts.At(0)->GetData()))->stopFlag; + Header header; + header.stopFlag = (static_cast(parts.At(0)->GetData()))->stopFlag; LOG(info) << "Received message with " << parts.Size() << " parts"; @@ -42,6 +44,8 @@ bool FairMQExample8Sink::HandleData(FairMQParts& parts, int /*index*/) return true; } -FairMQExample8Sink::~FairMQExample8Sink() +Sink::~Sink() { } + +} diff --git a/examples/MQ/8-multipart/FairMQExample8Sink.h b/examples/multipart/Sink.h similarity index 72% rename from examples/MQ/8-multipart/FairMQExample8Sink.h rename to examples/multipart/Sink.h index 7f48d12d..8496ba6a 100644 --- a/examples/MQ/8-multipart/FairMQExample8Sink.h +++ b/examples/multipart/Sink.h @@ -1,30 +1,34 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample8Sink.h + * Sink.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE8SINK_H_ -#define FAIRMQEXAMPLE8SINK_H_ +#ifndef FAIRMQEXAMPLEMULTIPARTSINK_H +#define FAIRMQEXAMPLEMULTIPARTSINK_H #include "FairMQDevice.h" -class FairMQExample8Sink : public FairMQDevice +namespace example_multipart +{ + +class Sink : public FairMQDevice { public: - FairMQExample8Sink(); - virtual ~FairMQExample8Sink(); + Sink(); + virtual ~Sink(); protected: bool HandleData(FairMQParts&, int); }; -#endif /* FAIRMQEXAMPLE8SINK_H_ */ +} +#endif /* FAIRMQEXAMPLEMULTIPARTSINK_H */ diff --git a/examples/MQ/8-multipart/ex8-multipart-multiple-endpoints.json b/examples/multipart/ex-multipart-multiple-endpoints.json similarity index 93% rename from examples/MQ/8-multipart/ex8-multipart-multiple-endpoints.json rename to examples/multipart/ex-multipart-multiple-endpoints.json index 92a99032..c0cf13b9 100644 --- a/examples/MQ/8-multipart/ex8-multipart-multiple-endpoints.json +++ b/examples/multipart/ex-multipart-multiple-endpoints.json @@ -5,7 +5,7 @@ "id": "sampler1", "channels": [ { - "name": "data-out", + "name": "data", "sockets": [ { "type": "push", @@ -23,7 +23,7 @@ "id": "sink1", "channels": [ { - "name": "data-in", + "name": "data", "sockets": [ { "type": "pull", @@ -41,7 +41,7 @@ "id": "sink2", "channels": [ { - "name": "data-in", + "name": "data", "sockets": [ { "type": "pull", diff --git a/examples/multipart/fairmq-start-ex-multipart.sh.in b/examples/multipart/fairmq-start-ex-multipart.sh.in new file mode 100755 index 00000000..297a6a5d --- /dev/null +++ b/examples/multipart/fairmq-start-ex-multipart.sh.in @@ -0,0 +1,11 @@ +#!/bin/bash + +SAMPLER="fairmq-ex-multipart-sampler" +SAMPLER+=" --id sampler1" +SAMPLER+=" --channel-config name=data,type=push,method=connect,rateLogging=0,address=tcp://127.0.0.1:5555" +xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER & + +SINK="fairmq-ex-multipart-sink" +SINK+=" --id sink1" +SINK+=" --channel-config name=data,type=pull,method=bind,rateLogging=0,address=tcp://127.0.0.1:5555" +xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$SINK & diff --git a/examples/MQ/multiple-transports/runExampleMTSink.cxx b/examples/multipart/runSampler.cxx similarity index 89% rename from examples/MQ/multiple-transports/runExampleMTSink.cxx rename to examples/multipart/runSampler.cxx index 9262813c..9347b549 100644 --- a/examples/MQ/multiple-transports/runExampleMTSink.cxx +++ b/examples/multipart/runSampler.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExampleMTSink.h" +#include "Sampler.h" namespace bpo = boost::program_options; @@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExampleMTSink(); + return new example_multipart::Sampler(); } diff --git a/examples/multipart/runSink.cxx b/examples/multipart/runSink.cxx new file mode 100644 index 00000000..80c9d57c --- /dev/null +++ b/examples/multipart/runSink.cxx @@ -0,0 +1,21 @@ +/******************************************************************************** + * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "runFairMQDevice.h" +#include "Sink.h" + +namespace bpo = boost::program_options; + +void addCustomOptions(bpo::options_description& /*options*/) +{ +} + +FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) +{ + return new example_multipart::Sink(); +} diff --git a/examples/MQ/8-multipart/testMQEx8.sh.in b/examples/multipart/test-ex-multipart.sh.in similarity index 56% rename from examples/MQ/8-multipart/testMQEx8.sh.in rename to examples/multipart/test-ex-multipart.sh.in index eb8a90cb..0b2975fa 100755 --- a/examples/MQ/8-multipart/testMQEx8.sh.in +++ b/examples/multipart/test-ex-multipart.sh.in @@ -1,24 +1,23 @@ #!/bin/bash -ex8config="@CMAKE_BINARY_DIR@/bin/config/ex8-multipart.json" # setup a trap to kill everything if the test fails/timeouts trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID;' TERM -SAMPLER="ex8-sampler" +SAMPLER="fairmq-ex-multipart-sampler" SAMPLER+=" --id sampler1" SAMPLER+=" --verbosity veryhigh" SAMPLER+=" --max-iterations 1" SAMPLER+=" --control static --color false" -SAMPLER+=" --mq-config $ex8config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/8-multipart/$SAMPLER & +SAMPLER+=" --channel-config name=data,type=push,method=connect,rateLogging=0,address=tcp://127.0.0.1:5555" +@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & SAMPLER_PID=$! -SINK="ex8-sink" +SINK="fairmq-ex-multipart-sink" SINK+=" --id sink1" SINK+=" --verbosity veryhigh" SINK+=" --control static --color false" -SINK+=" --mq-config $ex8config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/8-multipart/$SINK & +SINK+=" --channel-config name=data,type=pull,method=bind,rateLogging=0,address=tcp://127.0.0.1:5555" +@CMAKE_CURRENT_BINARY_DIR@/$SINK & SINK_PID=$! wait $SAMPLER_PID diff --git a/examples/MQ/6-multiple-channels/FairMQExample6Broadcaster.cxx b/examples/multiple-channels/Broadcaster.cxx similarity index 81% rename from examples/MQ/6-multiple-channels/FairMQExample6Broadcaster.cxx rename to examples/multiple-channels/Broadcaster.cxx index 818bb499..8f8423fe 100644 --- a/examples/MQ/6-multiple-channels/FairMQExample6Broadcaster.cxx +++ b/examples/multiple-channels/Broadcaster.cxx @@ -6,7 +6,7 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample6Broadcaster.cpp + * Broadcaster.cpp * * @since 2014-10-10 * @author A. Rybalchenko @@ -15,16 +15,18 @@ #include // this_thread::sleep_for #include -#include "FairMQExample6Broadcaster.h" -#include "FairMQLogger.h" +#include "Broadcaster.h" using namespace std; -FairMQExample6Broadcaster::FairMQExample6Broadcaster() +namespace example_multiple_channels +{ + +Broadcaster::Broadcaster() { } -bool FairMQExample6Broadcaster::ConditionalRun() +bool Broadcaster::ConditionalRun() { this_thread::sleep_for(chrono::seconds(1)); @@ -39,6 +41,8 @@ bool FairMQExample6Broadcaster::ConditionalRun() return true; } -FairMQExample6Broadcaster::~FairMQExample6Broadcaster() +Broadcaster::~Broadcaster() { } + +} diff --git a/examples/MQ/3-dds/FairMQExample3Sampler.h b/examples/multiple-channels/Broadcaster.h similarity index 67% rename from examples/MQ/3-dds/FairMQExample3Sampler.h rename to examples/multiple-channels/Broadcaster.h index 0c4900e9..6d29e86b 100644 --- a/examples/MQ/3-dds/FairMQExample3Sampler.h +++ b/examples/multiple-channels/Broadcaster.h @@ -1,30 +1,35 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample3Sampler.h + * Broadcaster.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE3SAMPLER_H_ -#define FAIRMQEXAMPLE3SAMPLER_H_ +#ifndef FAIRMQEXAMPLEMULTIPLECHANNELSBROADCASTER_H +#define FAIRMQEXAMPLEMULTIPLECHANNELSBROADCASTER_H #include "FairMQDevice.h" -class FairMQExample3Sampler : public FairMQDevice +namespace example_multiple_channels +{ + +class Broadcaster : public FairMQDevice { public: - FairMQExample3Sampler(); - virtual ~FairMQExample3Sampler(); + Broadcaster(); + virtual ~Broadcaster(); protected: virtual bool ConditionalRun(); }; -#endif /* FAIRMQEXAMPLE3SAMPLER_H_ */ +} + +#endif /* FAIRMQEXAMPLEMULTIPLECHANNELSBROADCASTER_H */ diff --git a/examples/multiple-channels/CMakeLists.txt b/examples/multiple-channels/CMakeLists.txt new file mode 100644 index 00000000..f4a4fb51 --- /dev/null +++ b/examples/multiple-channels/CMakeLists.txt @@ -0,0 +1,56 @@ + ################################################################################ + # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # # + # This software is distributed under the terms of the # + # GNU Lesser General Public Licence (LGPL) version 3, # + # copied verbatim in the file "LICENSE" # + ################################################################################ + +add_library(ExampleMultipleChannelsLib STATIC + "Sampler.cxx" + "Sampler.h" + "Broadcaster.cxx" + "Broadcaster.h" + "Sink.cxx" + "Sink.h" +) + +target_link_libraries(ExampleMultipleChannelsLib PUBLIC FairMQ) + +add_executable(fairmq-ex-multiple-channels-sampler runSampler.cxx) +target_link_libraries(fairmq-ex-multiple-channels-sampler PRIVATE ExampleMultipleChannelsLib) + +add_executable(fairmq-ex-multiple-channels-broadcaster runBroadcaster.cxx) +target_link_libraries(fairmq-ex-multiple-channels-broadcaster PRIVATE ExampleMultipleChannelsLib) + +add_executable(fairmq-ex-multiple-channels-sink runSink.cxx) +target_link_libraries(fairmq-ex-multiple-channels-sink PRIVATE ExampleMultipleChannelsLib) + +add_custom_target(ExampleMultipleChannels DEPENDS fairmq-ex-multiple-channels-sampler fairmq-ex-multiple-channels-broadcaster fairmq-ex-multiple-channels-sink) + +install( + TARGETS + fairmq-ex-multiple-channels-sampler + fairmq-ex-multiple-channels-broadcaster + fairmq-ex-multiple-channels-sink + + LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} + RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} +) + +# configure run script with different executable paths for build and for install directories +set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multiple-channels.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-channels.sh) +set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multiple-channels.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-channels.sh_install) + +install( + PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-channels.sh_install + DESTINATION ${PROJECT_INSTALL_BINDIR} + RENAME fairmq-start-ex-multiple-channels.sh +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-multiple-channels.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-channels.sh) + +add_test(NAME Example-Multiple-Channels COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-channels.sh) +set_tests_properties(Example-Multiple-Channels PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received messages from both sources.") diff --git a/examples/MQ/6-multiple-channels/README.md b/examples/multiple-channels/README.md similarity index 100% rename from examples/MQ/6-multiple-channels/README.md rename to examples/multiple-channels/README.md diff --git a/examples/MQ/6-multiple-channels/FairMQExample6Sampler.cxx b/examples/multiple-channels/Sampler.cxx similarity index 87% rename from examples/MQ/6-multiple-channels/FairMQExample6Sampler.cxx rename to examples/multiple-channels/Sampler.cxx index 30b39df5..ec22d958 100644 --- a/examples/MQ/6-multiple-channels/FairMQExample6Sampler.cxx +++ b/examples/multiple-channels/Sampler.cxx @@ -6,7 +6,7 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample6Sampler.cpp + * Sampler.cpp * * @since 2014-10-10 * @author A. Rybalchenko @@ -16,27 +16,28 @@ #include // this_thread::sleep_for #include -#include "FairMQExample6Sampler.h" +#include "Sampler.h" #include "FairMQPoller.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" using namespace std; -FairMQExample6Sampler::FairMQExample6Sampler() +namespace example_multiple_channels +{ + +Sampler::Sampler() : fText() , fMaxIterations(0) , fNumIterations(0) { } -void FairMQExample6Sampler::InitTask() +void Sampler::InitTask() { fText = fConfig->GetValue("text"); fMaxIterations = fConfig->GetValue("max-iterations"); } -void FairMQExample6Sampler::Run() +void Sampler::Run() { FairMQPollerPtr poller(NewPoller("data", "broadcast")); @@ -74,6 +75,8 @@ void FairMQExample6Sampler::Run() } } -FairMQExample6Sampler::~FairMQExample6Sampler() +Sampler::~Sampler() { } + +} diff --git a/examples/MQ/6-multiple-channels/FairMQExample6Sampler.h b/examples/multiple-channels/Sampler.h similarity index 75% rename from examples/MQ/6-multiple-channels/FairMQExample6Sampler.h rename to examples/multiple-channels/Sampler.h index 4775d9a4..8e975430 100644 --- a/examples/MQ/6-multiple-channels/FairMQExample6Sampler.h +++ b/examples/multiple-channels/Sampler.h @@ -6,24 +6,27 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample6Sampler.h + * Sampler.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE6SAMPLER_H_ -#define FAIRMQEXAMPLE6SAMPLER_H_ +#ifndef FAIRMQEXAMPLEMULTIPLECHANNELSSAMPLER_H +#define FAIRMQEXAMPLEMULTIPLECHANNELSSAMPLER_H #include #include "FairMQDevice.h" -class FairMQExample6Sampler : public FairMQDevice +namespace example_multiple_channels +{ + +class Sampler : public FairMQDevice { public: - FairMQExample6Sampler(); - virtual ~FairMQExample6Sampler(); + Sampler(); + virtual ~Sampler(); protected: std::string fText; @@ -34,4 +37,6 @@ class FairMQExample6Sampler : public FairMQDevice virtual void InitTask(); }; -#endif /* FAIRMQEXAMPLE6SAMPLER_H_ */ +} + +#endif /* FAIRMQEXAMPLEMULTIPLECHANNELSSAMPLER_H */ diff --git a/examples/MQ/6-multiple-channels/FairMQExample6Sink.cxx b/examples/multiple-channels/Sink.cxx similarity index 70% rename from examples/MQ/6-multiple-channels/FairMQExample6Sink.cxx rename to examples/multiple-channels/Sink.cxx index 3520908a..4b460e56 100644 --- a/examples/MQ/6-multiple-channels/FairMQExample6Sink.cxx +++ b/examples/multiple-channels/Sink.cxx @@ -1,41 +1,40 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample6Sink.cxx + * Sink.cxx * * @since 2014-10-10 * @author A. Rybalchenko */ -#include // unique_ptr - -#include "FairMQExample6Sink.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" +#include "Sink.h" using namespace std; -FairMQExample6Sink::FairMQExample6Sink() +namespace example_multiple_channels +{ + +Sink::Sink() : fReceivedData(false) , fReceivedBroadcast(false) , fMaxIterations(0) , fNumIterations(0) { - OnData("broadcast", &FairMQExample6Sink::HandleBroadcast); - OnData("data", &FairMQExample6Sink::HandleData); + OnData("broadcast", &Sink::HandleBroadcast); + OnData("data", &Sink::HandleData); } -void FairMQExample6Sink::InitTask() +void Sink::InitTask() { fMaxIterations = fConfig->GetValue("max-iterations"); } -bool FairMQExample6Sink::HandleBroadcast(FairMQMessagePtr& msg, int /*index*/) +bool Sink::HandleBroadcast(FairMQMessagePtr& msg, int /*index*/) { LOG(info) << "Received broadcast: \"" << string(static_cast(msg->GetData()), msg->GetSize()) << "\""; fReceivedBroadcast = true; @@ -43,7 +42,7 @@ bool FairMQExample6Sink::HandleBroadcast(FairMQMessagePtr& msg, int /*index*/) return CheckIterations(); } -bool FairMQExample6Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) { LOG(info) << "Received message: \"" << string(static_cast(msg->GetData()), msg->GetSize()) << "\""; fReceivedData = true; @@ -51,7 +50,7 @@ bool FairMQExample6Sink::HandleData(FairMQMessagePtr& msg, int /*index*/) return CheckIterations(); } -bool FairMQExample6Sink::CheckIterations() +bool Sink::CheckIterations() { if (fMaxIterations > 0) { @@ -65,6 +64,8 @@ bool FairMQExample6Sink::CheckIterations() return true; } -FairMQExample6Sink::~FairMQExample6Sink() +Sink::~Sink() { } + +} diff --git a/examples/MQ/6-multiple-channels/FairMQExample6Sink.h b/examples/multiple-channels/Sink.h similarity index 76% rename from examples/MQ/6-multiple-channels/FairMQExample6Sink.h rename to examples/multiple-channels/Sink.h index 5ceaf871..775de846 100644 --- a/examples/MQ/6-multiple-channels/FairMQExample6Sink.h +++ b/examples/multiple-channels/Sink.h @@ -1,27 +1,30 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample6Sink.h + * Sink.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE6SINK_H_ -#define FAIRMQEXAMPLE6SINK_H_ +#ifndef FAIRMQEXAMPLEMULTIPLECHANNELSSINK_H +#define FAIRMQEXAMPLEMULTIPLECHANNELSSINK_H #include "FairMQDevice.h" -class FairMQExample6Sink : public FairMQDevice +namespace example_multiple_channels +{ + +class Sink : public FairMQDevice { public: - FairMQExample6Sink(); - virtual ~FairMQExample6Sink(); + Sink(); + virtual ~Sink(); protected: bool HandleBroadcast(FairMQMessagePtr&, int); @@ -36,4 +39,6 @@ class FairMQExample6Sink : public FairMQDevice uint64_t fNumIterations; }; -#endif /* FAIRMQEXAMPLE6SINK_H_ */ +} + +#endif /* FAIRMQEXAMPLEMULTIPLECHANNELSSINK_H */ diff --git a/examples/multiple-channels/fairmq-start-ex-multiple-channels.sh.in b/examples/multiple-channels/fairmq-start-ex-multiple-channels.sh.in new file mode 100755 index 00000000..4e0d95ea --- /dev/null +++ b/examples/multiple-channels/fairmq-start-ex-multiple-channels.sh.in @@ -0,0 +1,18 @@ +#!/bin/bash + +SAMPLER="fairmq-ex-multiple-channels-sampler" +SAMPLER+=" --id sampler1" +SAMPLER+=" --channel-config name=data,type=push,method=bind,rateLogging=0,address=tcp://*:5555" +SAMPLER+=" name=broadcast,type=sub,method=connect,rateLogging=0,address=tcp://localhost:5005" +xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER & + +SINK="fairmq-ex-multiple-channels-sink" +SINK+=" --id sink1" +SINK+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5555" +SINK+=" name=broadcast,type=sub,method=connect,rateLogging=0,address=tcp://localhost:5005" +xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$SINK & + +BROADCASTER="fairmq-ex-multiple-channels-broadcaster" +BROADCASTER+=" --id broadcaster1" +BROADCASTER+=" --channel-config name=broadcast,type=pub,method=bind,rateLogging=0,address=tcp://*:5005" +xterm -geometry 80x23+250+330 -hold -e @EX_BIN_DIR@/$BROADCASTER & diff --git a/examples/MQ/2-sampler-processor-sink/runExample2Processor.cxx b/examples/multiple-channels/runBroadcaster.cxx similarity index 86% rename from examples/MQ/2-sampler-processor-sink/runExample2Processor.cxx rename to examples/multiple-channels/runBroadcaster.cxx index 395de86d..1b72785d 100644 --- a/examples/MQ/2-sampler-processor-sink/runExample2Processor.cxx +++ b/examples/multiple-channels/runBroadcaster.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample2Processor.h" +#include "Broadcaster.h" namespace bpo = boost::program_options; @@ -17,5 +17,5 @@ void addCustomOptions(bpo::options_description& /*options*/) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample2Processor(); + return new example_multiple_channels::Broadcaster(); } diff --git a/examples/MQ/2-sampler-processor-sink/runExample2Sampler.cxx b/examples/multiple-channels/runSampler.cxx similarity index 89% rename from examples/MQ/2-sampler-processor-sink/runExample2Sampler.cxx rename to examples/multiple-channels/runSampler.cxx index 6a575de4..a3902d7c 100644 --- a/examples/MQ/2-sampler-processor-sink/runExample2Sampler.cxx +++ b/examples/multiple-channels/runSampler.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample2Sampler.h" +#include "Sampler.h" namespace bpo = boost::program_options; @@ -20,5 +20,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample2Sampler(); + return new example_multiple_channels::Sampler(); } diff --git a/examples/multiple-channels/runSink.cxx b/examples/multiple-channels/runSink.cxx new file mode 100644 index 00000000..1ebf1067 --- /dev/null +++ b/examples/multiple-channels/runSink.cxx @@ -0,0 +1,23 @@ +/******************************************************************************** + * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "runFairMQDevice.h" +#include "Sink.h" + +namespace bpo = boost::program_options; + +void addCustomOptions(bpo::options_description& options) +{ + options.add_options() + ("max-iterations", bpo::value()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); +} + +FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) +{ + return new example_multiple_channels::Sink(); +} diff --git a/examples/MQ/6-multiple-channels/testMQEx6.sh.in b/examples/multiple-channels/test-ex-multiple-channels.sh.in similarity index 50% rename from examples/MQ/6-multiple-channels/testMQEx6.sh.in rename to examples/multiple-channels/test-ex-multiple-channels.sh.in index 120bab74..32caf3ca 100755 --- a/examples/MQ/6-multiple-channels/testMQEx6.sh.in +++ b/examples/multiple-channels/test-ex-multiple-channels.sh.in @@ -1,36 +1,37 @@ #!/bin/bash -ex6config="@CMAKE_BINARY_DIR@/bin/config/ex6-multiple-channels.json" # setup a trap to kill everything if the test fails/timeouts trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; kill -TERM $BROADCASTER_PID; wait $SAMPLER_PID; wait $SINK_PID; wait $BROADCASTER_PID;' TERM -SINK="ex6-sink" +SINK="fairmq-ex-multiple-channels-sink" SINK+=" --id sink1" SINK+=" --verbosity veryhigh" SINK+=" --max-iterations 1" SINK+=" --control static --color false" -SINK+=" --mq-config $ex6config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/6-multiple-channels/$SINK & +SINK+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5555" +SINK+=" name=broadcast,type=sub,method=connect,rateLogging=0,address=tcp://localhost:5005" +@CMAKE_CURRENT_BINARY_DIR@/$SINK & SINK_PID=$! sleep 1 -SAMPLER="ex6-sampler" +SAMPLER="fairmq-ex-multiple-channels-sampler" SAMPLER+=" --id sampler1" SAMPLER+=" --verbosity veryhigh" SAMPLER+=" --max-iterations 1" SAMPLER+=" --control static --color false" -SAMPLER+=" --mq-config $ex6config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/6-multiple-channels/$SAMPLER & +SAMPLER+=" --channel-config name=data,type=push,method=bind,rateLogging=0,address=tcp://*:5555" +SAMPLER+=" name=broadcast,type=sub,method=connect,rateLogging=0,address=tcp://localhost:5005" +@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & SAMPLER_PID=$! -BROADCASTER="ex6-broadcaster" +BROADCASTER="fairmq-ex-multiple-channels-broadcaster" BROADCASTER+=" --id broadcaster1" BROADCASTER+=" --verbosity veryhigh" BROADCASTER+=" --control static --color false" -BROADCASTER+=" --mq-config $ex6config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/6-multiple-channels/$BROADCASTER & +BROADCASTER+=" --channel-config name=broadcast,type=pub,method=bind,rateLogging=0,address=tcp://*:5005" +@CMAKE_CURRENT_BINARY_DIR@/$BROADCASTER & BROADCASTER_PID=$! wait $SAMPLER_PID diff --git a/examples/multiple-transports/CMakeLists.txt b/examples/multiple-transports/CMakeLists.txt new file mode 100644 index 00000000..fdc29356 --- /dev/null +++ b/examples/multiple-transports/CMakeLists.txt @@ -0,0 +1,56 @@ + ################################################################################ + # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # # + # This software is distributed under the terms of the # + # GNU Lesser General Public Licence (LGPL) version 3, # + # copied verbatim in the file "LICENSE" # + ################################################################################ + +add_library(ExampleMultipleTransportsLib STATIC + "Sampler1.cxx" + "Sampler1.h" + "Sampler2.cxx" + "Sampler2.h" + "Sink.cxx" + "Sink.h" +) + +target_link_libraries(ExampleMultipleTransportsLib PUBLIC FairMQ) + +add_executable(fairmq-ex-multiple-transports-sampler1 runSampler1.cxx) +target_link_libraries(fairmq-ex-multiple-transports-sampler1 PRIVATE ExampleMultipleTransportsLib) + +add_executable(fairmq-ex-multiple-transports-sampler2 runSampler2.cxx) +target_link_libraries(fairmq-ex-multiple-transports-sampler2 PRIVATE ExampleMultipleTransportsLib) + +add_executable(fairmq-ex-multiple-transports-sink runSink.cxx) +target_link_libraries(fairmq-ex-multiple-transports-sink PRIVATE ExampleMultipleTransportsLib) + +add_custom_target(ExampleMultipleTransports DEPENDS fairmq-ex-multiple-transports-sampler1 fairmq-ex-multiple-transports-sampler2 fairmq-ex-multiple-transports-sink) + +install( + TARGETS + fairmq-ex-multiple-transports-sampler1 + fairmq-ex-multiple-transports-sampler2 + fairmq-ex-multiple-transports-sink + + LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} + RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} +) + +# configure run script with different executable paths for build and for install directories +set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multiple-transports.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-transports.sh) +set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multiple-transports.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-transports.sh_install) + +install( + PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-transports.sh_install + DESTINATION ${PROJECT_INSTALL_BINDIR} + RENAME fairmq-start-ex-multiple-transports.sh +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-multiple-transports.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-transports.sh) + +add_test(NAME Example-Multiple-Transports COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-transports.sh) +set_tests_properties(Example-Multiple-Transports PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received messages from both sources.") diff --git a/examples/MQ/multiple-transports/README.md b/examples/multiple-transports/README.md similarity index 100% rename from examples/MQ/multiple-transports/README.md rename to examples/multiple-transports/README.md diff --git a/examples/MQ/multiple-transports/FairMQExampleMTSampler1.cxx b/examples/multiple-transports/Sampler1.cxx similarity index 75% rename from examples/MQ/multiple-transports/FairMQExampleMTSampler1.cxx rename to examples/multiple-transports/Sampler1.cxx index 35ebd1cb..67274ef5 100644 --- a/examples/MQ/multiple-transports/FairMQExampleMTSampler1.cxx +++ b/examples/multiple-transports/Sampler1.cxx @@ -1,35 +1,36 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#include "FairMQExampleMTSampler1.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" +#include "Sampler1.h" using namespace std; -FairMQExampleMTSampler1::FairMQExampleMTSampler1() +namespace example_multiple_transports +{ + +Sampler1::Sampler1() : fAckListener() , fMaxIterations(0) , fNumIterations(0) { } -void FairMQExampleMTSampler1::InitTask() +void Sampler1::InitTask() { fMaxIterations = fConfig->GetValue("max-iterations"); } -void FairMQExampleMTSampler1::PreRun() +void Sampler1::PreRun() { - fAckListener = thread(&FairMQExampleMTSampler1::ListenForAcks, this); + fAckListener = thread(&Sampler1::ListenForAcks, this); } -bool FairMQExampleMTSampler1::ConditionalRun() +bool Sampler1::ConditionalRun() { // Creates a message using the transport of channel data1 FairMQMessagePtr msg(NewMessageFor("data1", 0, 1000000)); @@ -50,12 +51,12 @@ bool FairMQExampleMTSampler1::ConditionalRun() return true; } -void FairMQExampleMTSampler1::PostRun() +void Sampler1::PostRun() { fAckListener.join(); } -void FairMQExampleMTSampler1::ListenForAcks() +void Sampler1::ListenForAcks() { uint64_t numAcks = 0; @@ -72,6 +73,8 @@ void FairMQExampleMTSampler1::ListenForAcks() LOG(info) << "Acknowledged " << numAcks << " messages"; } -FairMQExampleMTSampler1::~FairMQExampleMTSampler1() +Sampler1::~Sampler1() { } + +} // namespace example_multiple_transports diff --git a/examples/MQ/multiple-transports/FairMQExampleMTSampler1.h b/examples/multiple-transports/Sampler1.h similarity index 70% rename from examples/MQ/multiple-transports/FairMQExampleMTSampler1.h rename to examples/multiple-transports/Sampler1.h index cefa5d5d..26a13832 100644 --- a/examples/MQ/multiple-transports/FairMQExampleMTSampler1.h +++ b/examples/multiple-transports/Sampler1.h @@ -1,24 +1,26 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#ifndef FAIRMQEXAMPLEMTSAMPLER1_H_ -#define FAIRMQEXAMPLEMTSAMPLER1_H_ +#ifndef FAIRMQEXAMPLEMULTIPLETRANSPORTSSAMPLER1_H +#define FAIRMQEXAMPLEMULTIPLETRANSPORTSSAMPLER1_H -#include #include #include "FairMQDevice.h" -class FairMQExampleMTSampler1 : public FairMQDevice +namespace example_multiple_transports +{ + +class Sampler1 : public FairMQDevice { public: - FairMQExampleMTSampler1(); - virtual ~FairMQExampleMTSampler1(); + Sampler1(); + virtual ~Sampler1(); protected: virtual void InitTask(); @@ -32,4 +34,6 @@ class FairMQExampleMTSampler1 : public FairMQDevice uint64_t fNumIterations; }; -#endif /* FAIRMQEXAMPLEMTSAMPLER1_H_ */ +} // namespace example_multiple_transports + +#endif /* FAIRMQEXAMPLEMULTIPLETRANSPORTSSAMPLER1_H */ diff --git a/examples/MQ/multiple-transports/FairMQExampleMTSampler2.cxx b/examples/multiple-transports/Sampler2.cxx similarity index 78% rename from examples/MQ/multiple-transports/FairMQExampleMTSampler2.cxx rename to examples/multiple-transports/Sampler2.cxx index b70d955e..1ac30274 100644 --- a/examples/MQ/multiple-transports/FairMQExampleMTSampler2.cxx +++ b/examples/multiple-transports/Sampler2.cxx @@ -1,29 +1,30 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#include "FairMQExampleMTSampler2.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" +#include "Sampler2.h" using namespace std; -FairMQExampleMTSampler2::FairMQExampleMTSampler2() +namespace example_multiple_transports +{ + +Sampler2::Sampler2() : fMaxIterations(0) , fNumIterations(0) { } -void FairMQExampleMTSampler2::InitTask() +void Sampler2::InitTask() { fMaxIterations = fConfig->GetValue("max-iterations"); } -bool FairMQExampleMTSampler2::ConditionalRun() +bool Sampler2::ConditionalRun() { FairMQMessagePtr msg(NewMessage(1000)); @@ -43,6 +44,8 @@ bool FairMQExampleMTSampler2::ConditionalRun() return true; } -FairMQExampleMTSampler2::~FairMQExampleMTSampler2() +Sampler2::~Sampler2() { } + +} // namespace example_multiple_transports diff --git a/examples/MQ/multiple-transports/FairMQExampleMTSampler2.h b/examples/multiple-transports/Sampler2.h similarity index 67% rename from examples/MQ/multiple-transports/FairMQExampleMTSampler2.h rename to examples/multiple-transports/Sampler2.h index a1008e9f..df64e9e5 100644 --- a/examples/MQ/multiple-transports/FairMQExampleMTSampler2.h +++ b/examples/multiple-transports/Sampler2.h @@ -1,24 +1,24 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#ifndef FAIRMQEXAMPLEMTSAMPLER2_H_ -#define FAIRMQEXAMPLEMTSAMPLER2_H_ - -#include -#include +#ifndef FAIRMQEXAMPLEMULTIPLETRANSPORTSSAMPLER2_H +#define FAIRMQEXAMPLEMULTIPLETRANSPORTSSAMPLER2_H #include "FairMQDevice.h" -class FairMQExampleMTSampler2 : public FairMQDevice +namespace example_multiple_transports +{ + +class Sampler2 : public FairMQDevice { public: - FairMQExampleMTSampler2(); - virtual ~FairMQExampleMTSampler2(); + Sampler2(); + virtual ~Sampler2(); protected: virtual void InitTask(); @@ -29,4 +29,6 @@ class FairMQExampleMTSampler2 : public FairMQDevice uint64_t fNumIterations; }; -#endif /* FAIRMQEXAMPLEMTSAMPLER2_H_ */ +} // namespace example_multiple_transports + +#endif /* FAIRMQEXAMPLEMULTIPLETRANSPORTSSAMPLER2_H */ diff --git a/examples/MQ/multiple-transports/FairMQExampleMTSink.cxx b/examples/multiple-transports/Sink.cxx similarity index 76% rename from examples/MQ/multiple-transports/FairMQExampleMTSink.cxx rename to examples/multiple-transports/Sink.cxx index 1863c5bd..c0d1051c 100644 --- a/examples/MQ/multiple-transports/FairMQExampleMTSink.cxx +++ b/examples/multiple-transports/Sink.cxx @@ -1,24 +1,25 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExampleMTSink.cxx + * Sink.cxx * * @since 2014-10-10 * @author A. Rybalchenko */ -#include "FairMQExampleMTSink.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" +#include "Sink.h" using namespace std; -FairMQExampleMTSink::FairMQExampleMTSink() +namespace example_multiple_transports +{ + +Sink::Sink() : fMaxIterations(0) , fNumIterations1(0) , fNumIterations2(0) @@ -26,17 +27,17 @@ FairMQExampleMTSink::FairMQExampleMTSink() , fReceived2(false) { // register a handler for data arriving on "data" channel - OnData("data1", &FairMQExampleMTSink::HandleData1); - OnData("data2", &FairMQExampleMTSink::HandleData2); + OnData("data1", &Sink::HandleData1); + OnData("data2", &Sink::HandleData2); } -void FairMQExampleMTSink::InitTask() +void Sink::InitTask() { fMaxIterations = fConfig->GetValue("max-iterations"); } // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool FairMQExampleMTSink::HandleData1(FairMQMessagePtr& /*msg*/, int /*index*/) +bool Sink::HandleData1(FairMQMessagePtr& /*msg*/, int /*index*/) { fNumIterations1++; // Creates a message using the transport of channel ack @@ -51,14 +52,14 @@ bool FairMQExampleMTSink::HandleData1(FairMQMessagePtr& /*msg*/, int /*index*/) } // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool FairMQExampleMTSink::HandleData2(FairMQMessagePtr& /*msg*/, int /*index*/) +bool Sink::HandleData2(FairMQMessagePtr& /*msg*/, int /*index*/) { fNumIterations2++; // return true if want to be called again (otherwise go to IDLE state) return CheckIterations(); } -bool FairMQExampleMTSink::CheckIterations() +bool Sink::CheckIterations() { if (fMaxIterations > 0) { @@ -72,6 +73,8 @@ bool FairMQExampleMTSink::CheckIterations() return true; } -FairMQExampleMTSink::~FairMQExampleMTSink() +Sink::~Sink() { } + +} // namespace example_multiple_transports diff --git a/examples/MQ/multiple-transports/FairMQExampleMTSink.h b/examples/multiple-transports/Sink.h similarity index 73% rename from examples/MQ/multiple-transports/FairMQExampleMTSink.h rename to examples/multiple-transports/Sink.h index 7f7111f2..e849e62d 100644 --- a/examples/MQ/multiple-transports/FairMQExampleMTSink.h +++ b/examples/multiple-transports/Sink.h @@ -1,27 +1,30 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExampleMTSink.h + * Sink.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLEMTSINK_H_ -#define FAIRMQEXAMPLEMTSINK_H_ +#ifndef FAIRMQEXAMPLEMULTIPLETRANSPORTSSINK_H +#define FAIRMQEXAMPLEMULTIPLETRANSPORTSSINK_H #include "FairMQDevice.h" -class FairMQExampleMTSink : public FairMQDevice +namespace example_multiple_transports +{ + +class Sink : public FairMQDevice { public: - FairMQExampleMTSink(); - virtual ~FairMQExampleMTSink(); + Sink(); + virtual ~Sink(); protected: virtual void InitTask(); @@ -37,4 +40,6 @@ class FairMQExampleMTSink : public FairMQDevice bool fReceived2; }; -#endif /* FAIRMQEXAMPLEMTSINK_H_ */ +} // namespace example_multiple_transports + +#endif /* FAIRMQEXAMPLEMULTIPLETRANSPORTSSINK_H */ diff --git a/examples/MQ/multiple-transports/ex-multiple-transports.json b/examples/multiple-transports/ex-multiple-transports.json similarity index 100% rename from examples/MQ/multiple-transports/ex-multiple-transports.json rename to examples/multiple-transports/ex-multiple-transports.json diff --git a/examples/multiple-transports/fairmq-start-ex-multiple-transports.sh.in b/examples/multiple-transports/fairmq-start-ex-multiple-transports.sh.in new file mode 100755 index 00000000..3280d239 --- /dev/null +++ b/examples/multiple-transports/fairmq-start-ex-multiple-transports.sh.in @@ -0,0 +1,25 @@ +#!/bin/bash + +SAMPLER1="fairmq-ex-multiple-transports-sampler1" +SAMPLER1+=" --id sampler1" +SAMPLER1+=" --severity debug" +SAMPLER1+=" --transport shmem" +SAMPLER1+=" --channel-config name=data1,type=push,method=bind,address=tcp://127.0.0.1:5555" +SAMPLER1+=" name=ack,type=sub,method=bind,address=tcp://127.0.0.1:5557,transport=zeromq" +xterm -geometry 80x30+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER1 & + +SAMPLER2="fairmq-ex-multiple-transports-sampler2" +SAMPLER2+=" --id sampler2" +SAMPLER2+=" --severity debug" +SAMPLER2+=" --transport nanomsg" +SAMPLER2+=" --channel-config name=data2,type=push,method=bind,address=tcp://127.0.0.1:5556" +xterm -geometry 80x30+0+450 -hold -e @EX_BIN_DIR@/$SAMPLER2 & + +SINK="fairmq-ex-multiple-transports-sink" +SINK+=" --id sink1" +SINK+=" --severity debug" +SINK+=" --transport shmem" +SINK+=" --channel-config name=data1,type=pull,method=connect,address=tcp://127.0.0.1:5555" +SINK+=" name=data2,type=pull,method=connect,address=tcp://127.0.0.1:5556,transport=nanomsg" +SINK+=" name=ack,type=pub,method=connect,address=tcp://127.0.0.1:5557,transport=zeromq" +xterm -geometry 80x30+500+0 -hold -e @EX_BIN_DIR@/$SINK & diff --git a/examples/MQ/4-copypush/runExample4Sampler.cxx b/examples/multiple-transports/runSampler1.cxx similarity index 88% rename from examples/MQ/4-copypush/runExample4Sampler.cxx rename to examples/multiple-transports/runSampler1.cxx index b40202be..bd46785b 100644 --- a/examples/MQ/4-copypush/runExample4Sampler.cxx +++ b/examples/multiple-transports/runSampler1.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample4Sampler.h" +#include "Sampler1.h" namespace bpo = boost::program_options; @@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample4Sampler(); + return new example_multiple_transports::Sampler1(); } diff --git a/examples/multiple-transports/runSampler2.cxx b/examples/multiple-transports/runSampler2.cxx new file mode 100644 index 00000000..879d926d --- /dev/null +++ b/examples/multiple-transports/runSampler2.cxx @@ -0,0 +1,23 @@ +/******************************************************************************** + * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "runFairMQDevice.h" +#include "Sampler2.h" + +namespace bpo = boost::program_options; + +void addCustomOptions(bpo::options_description& options) +{ + options.add_options() + ("max-iterations", bpo::value()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); +} + +FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) +{ + return new example_multiple_transports::Sampler2(); +} diff --git a/examples/multiple-transports/runSink.cxx b/examples/multiple-transports/runSink.cxx new file mode 100644 index 00000000..658a2c71 --- /dev/null +++ b/examples/multiple-transports/runSink.cxx @@ -0,0 +1,23 @@ +/******************************************************************************** + * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "runFairMQDevice.h" +#include "Sink.h" + +namespace bpo = boost::program_options; + +void addCustomOptions(bpo::options_description& options) +{ + options.add_options() + ("max-iterations", bpo::value()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); +} + +FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) +{ + return new example_multiple_transports::Sink(); +} diff --git a/examples/multiple-transports/test-ex-multiple-transports.sh.in b/examples/multiple-transports/test-ex-multiple-transports.sh.in new file mode 100755 index 00000000..96539702 --- /dev/null +++ b/examples/multiple-transports/test-ex-multiple-transports.sh.in @@ -0,0 +1,44 @@ +#!/bin/bash +SESSION="$(@CMAKE_BINARY_DIR@/fairmq/uuidGen -h)" + +trap 'kill -TERM $SAMPLER1_PID; kill -TERM $SAMPLER2_PID; kill -TERM $SINK_PID; wait $SAMPLER1_PID; wait $SAMPLER2_PID; wait $SINK_PID; @CMAKE_BINARY_DIR@/fairmq/shmmonitor --cleanup --session $SESSION;' TERM + +SINK="fairmq-ex-multiple-transports-sink" +SINK+=" --id sink1" +SINK+=" --verbosity veryhigh" +SINK+=" --session $SESSION" +SINK+=" --max-iterations 1" +SINK+=" --control static --color false" +SINK+=" --transport shmem" +SINK+=" --channel-config name=data1,type=pull,method=connect,address=tcp://127.0.0.1:5555" +SINK+=" name=data2,type=pull,method=connect,address=tcp://127.0.0.1:5556,transport=nanomsg" +SINK+=" name=ack,type=pub,method=connect,address=tcp://127.0.0.1:5557,transport=zeromq" +@CMAKE_CURRENT_BINARY_DIR@/$SINK & +SINK_PID=$! + +SAMPLER1="fairmq-ex-multiple-transports-sampler1" +SAMPLER1+=" --id sampler1" +SAMPLER1+=" --session $SESSION" +SAMPLER1+=" --verbosity veryhigh" +SAMPLER1+=" --max-iterations 1" +SAMPLER1+=" --control static --color false" +SAMPLER1+=" --transport shmem" +SAMPLER1+=" --channel-config name=data1,type=push,method=bind,address=tcp://127.0.0.1:5555" +SAMPLER1+=" name=ack,type=sub,method=bind,address=tcp://127.0.0.1:5557,transport=zeromq" +@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER1 & +SAMPLER1_PID=$! + +SAMPLER2="fairmq-ex-multiple-transports-sampler2" +SAMPLER2+=" --id sampler2" +SAMPLER2+=" --session $SESSION" +SAMPLER2+=" --verbosity veryhigh" +SAMPLER2+=" --max-iterations 1" +SAMPLER2+=" --control static --color false" +SAMPLER2+=" --transport nanomsg" +SAMPLER2+=" --channel-config name=data2,type=push,method=bind,address=tcp://127.0.0.1:5556" +@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER2 & +SAMPLER2_PID=$! + +wait $SAMPLER1_PID +wait $SAMPLER2_PID +wait $SINK_PID diff --git a/examples/region/CMakeLists.txt b/examples/region/CMakeLists.txt new file mode 100644 index 00000000..a80a230e --- /dev/null +++ b/examples/region/CMakeLists.txt @@ -0,0 +1,51 @@ + ################################################################################ + # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # # + # This software is distributed under the terms of the # + # GNU Lesser General Public Licence (LGPL) version 3, # + # copied verbatim in the file "LICENSE" # + ################################################################################ + +add_library(ExampleRegionLib STATIC + "Sampler.cxx" + "Sampler.h" + "Sink.cxx" + "Sink.h" +) + +target_link_libraries(ExampleRegionLib PUBLIC FairMQ) + +add_executable(fairmq-ex-region-sampler runSampler.cxx) +target_link_libraries(fairmq-ex-region-sampler PRIVATE ExampleRegionLib) + + +add_executable(fairmq-ex-region-sink runSink.cxx) +target_link_libraries(fairmq-ex-region-sink PRIVATE ExampleRegionLib) + +add_custom_target(ExampleRegion DEPENDS fairmq-ex-region-sampler fairmq-ex-region-sink) + +install( + TARGETS + fairmq-ex-region-sampler + fairmq-ex-region-sink + + LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} + RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} +) + +# configure run script with different executable paths for build and for install directories +set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-region.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-region.sh) +set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-region.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-region.sh_install) + +install( + PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-region.sh_install + DESTINATION ${PROJECT_INSTALL_BINDIR} + RENAME fairmq-start-ex-region.sh +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-region.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-region.sh) + +add_test(NAME Example-Region COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-region.sh) +set_tests_properties(Example-Region PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received ack") diff --git a/examples/advanced/Region/FairMQExampleRegionSampler.cxx b/examples/region/Sampler.cxx similarity index 87% rename from examples/advanced/Region/FairMQExampleRegionSampler.cxx rename to examples/region/Sampler.cxx index 84e3ee8c..1fbf09d9 100644 --- a/examples/advanced/Region/FairMQExampleRegionSampler.cxx +++ b/examples/region/Sampler.cxx @@ -6,22 +6,22 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExampleRegionSampler.cpp + * Sampler.cpp * * @since 2014-10-10 * @author A. Rybalchenko */ -#include "FairMQExampleRegionSampler.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig +#include "Sampler.h" #include -#include using namespace std; -FairMQExampleRegionSampler::FairMQExampleRegionSampler() +namespace example_region +{ + +Sampler::Sampler() : fMsgSize(10000) , fMaxIterations(0) , fNumIterations(0) @@ -30,7 +30,7 @@ FairMQExampleRegionSampler::FairMQExampleRegionSampler() { } -void FairMQExampleRegionSampler::InitTask() +void Sampler::InitTask() { fMsgSize = fConfig->GetValue("msg-size"); fMaxIterations = fConfig->GetValue("max-iterations"); @@ -48,7 +48,7 @@ void FairMQExampleRegionSampler::InitTask() )); } -bool FairMQExampleRegionSampler::ConditionalRun() +bool Sampler::ConditionalRun() { FairMQMessagePtr msg(NewMessageFor("data", // channel 0, // sub-channel @@ -72,7 +72,7 @@ bool FairMQExampleRegionSampler::ConditionalRun() return true; } -void FairMQExampleRegionSampler::ResetTask() +void Sampler::ResetTask() { // if not all messages acknowledged, wait for a bit. But only once, since receiver could be already dead. if (fNumUnackedMsgs != 0) @@ -84,6 +84,8 @@ void FairMQExampleRegionSampler::ResetTask() fRegion.reset(); } -FairMQExampleRegionSampler::~FairMQExampleRegionSampler() +Sampler::~Sampler() { } + +} // namespace example_region diff --git a/examples/advanced/Region/FairMQExampleRegionSampler.h b/examples/region/Sampler.h similarity index 76% rename from examples/advanced/Region/FairMQExampleRegionSampler.h rename to examples/region/Sampler.h index 08716673..4056fb3d 100644 --- a/examples/advanced/Region/FairMQExampleRegionSampler.h +++ b/examples/region/Sampler.h @@ -6,25 +6,27 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExampleRegionSampler.h + * Sampler.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLEREGIONSAMPLER_H_ -#define FAIRMQEXAMPLEREGIONSAMPLER_H_ +#ifndef FAIRMQEXAMPLEREGIONSAMPLER_H +#define FAIRMQEXAMPLEREGIONSAMPLER_H -#include #include #include "FairMQDevice.h" -class FairMQExampleRegionSampler : public FairMQDevice +namespace example_region +{ + +class Sampler : public FairMQDevice { public: - FairMQExampleRegionSampler(); - virtual ~FairMQExampleRegionSampler(); + Sampler(); + virtual ~Sampler(); protected: virtual void InitTask(); @@ -39,4 +41,6 @@ class FairMQExampleRegionSampler : public FairMQDevice std::atomic fNumUnackedMsgs; }; -#endif /* FAIRMQEXAMPLEREGIONSAMPLER_H_ */ +} // namespace example_region + +#endif /* FAIRMQEXAMPLEREGIONSAMPLER_H */ diff --git a/examples/advanced/Region/FairMQExampleRegionSink.cxx b/examples/region/Sink.cxx similarity index 80% rename from examples/advanced/Region/FairMQExampleRegionSink.cxx rename to examples/region/Sink.cxx index b1309a42..e4ff0a7d 100644 --- a/examples/advanced/Region/FairMQExampleRegionSink.cxx +++ b/examples/region/Sink.cxx @@ -6,31 +6,32 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExampleRegionSink.cxx + * Sink.cxx * * @since 2014-10-10 * @author A. Rybalchenko */ -#include "FairMQExampleRegionSink.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig +#include "Sink.h" using namespace std; -FairMQExampleRegionSink::FairMQExampleRegionSink() +namespace example_region +{ + +Sink::Sink() : fMaxIterations(0) , fNumIterations(0) { } -void FairMQExampleRegionSink::InitTask() +void Sink::InitTask() { // Get the fMaxIterations value from the command line options (via fConfig) fMaxIterations = fConfig->GetValue("max-iterations"); } -void FairMQExampleRegionSink::Run() +void Sink::Run() { FairMQChannel& dataInChannel = fChannels.at("data").at(0); @@ -48,6 +49,8 @@ void FairMQExampleRegionSink::Run() } } -FairMQExampleRegionSink::~FairMQExampleRegionSink() +Sink::~Sink() { } + +} // namespace example_region diff --git a/examples/advanced/Region/FairMQExampleRegionSink.h b/examples/region/Sink.h similarity index 72% rename from examples/advanced/Region/FairMQExampleRegionSink.h rename to examples/region/Sink.h index a2e23603..7e372e7a 100644 --- a/examples/advanced/Region/FairMQExampleRegionSink.h +++ b/examples/region/Sink.h @@ -1,29 +1,32 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExampleRegionSink.h + * Sink.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLEREGIONSINK_H_ -#define FAIRMQEXAMPLEREGIONSINK_H_ +#ifndef FAIRMQEXAMPLEREGIONSINK_H +#define FAIRMQEXAMPLEREGIONSINK_H #include #include "FairMQDevice.h" -class FairMQExampleRegionSink : public FairMQDevice +namespace example_region +{ + +class Sink : public FairMQDevice { public: - FairMQExampleRegionSink(); - virtual ~FairMQExampleRegionSink(); + Sink(); + virtual ~Sink(); protected: virtual void Run(); @@ -34,4 +37,6 @@ class FairMQExampleRegionSink : public FairMQDevice uint64_t fNumIterations; }; -#endif /* FAIRMQEXAMPLEREGIONSINK_H_ */ +} // namespace example_region + +#endif /* FAIRMQEXAMPLEREGIONSINK_H */ diff --git a/examples/region/fairmq-start-ex-region.sh.in b/examples/region/fairmq-start-ex-region.sh.in new file mode 100755 index 00000000..ca668595 --- /dev/null +++ b/examples/region/fairmq-start-ex-region.sh.in @@ -0,0 +1,23 @@ +#!/bin/bash + +msgSize="1000000" + +if [[ $1 =~ ^[0-9]+$ ]]; then + msgSize=$1 +fi + +SAMPLER="fairmq-ex-region-sampler" +SAMPLER+=" --id sampler1" +SAMPLER+=" --severity debug" +SAMPLER+=" --msg-size $msgSize" +# SAMPLER+=" --rate 10" +SAMPLER+=" --transport shmem" +SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://127.0.0.1:7777" +xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER & + +SINK="fairmq-ex-region-sink" +SINK+=" --id sink1" +SINK+=" --severity debug" +SINK+=" --transport shmem" +SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://127.0.0.1:7777" +xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$SINK & diff --git a/examples/advanced/Region/runExampleRegionSampler.cxx b/examples/region/runSampler.cxx similarity index 88% rename from examples/advanced/Region/runExampleRegionSampler.cxx rename to examples/region/runSampler.cxx index edd9a0fb..6b8166da 100644 --- a/examples/advanced/Region/runExampleRegionSampler.cxx +++ b/examples/region/runSampler.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExampleRegionSampler.h" +#include "Sampler.h" namespace bpo = boost::program_options; @@ -20,5 +20,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExampleRegionSampler(); + return new example_region::Sampler(); } diff --git a/examples/region/runSink.cxx b/examples/region/runSink.cxx new file mode 100644 index 00000000..1ad8f4bd --- /dev/null +++ b/examples/region/runSink.cxx @@ -0,0 +1,23 @@ +/******************************************************************************** + * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "runFairMQDevice.h" +#include "Sink.h" + +namespace bpo = boost::program_options; + +void addCustomOptions(bpo::options_description& options) +{ + options.add_options() + ("max-iterations", bpo::value()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); +} + +FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) +{ + return new example_region::Sink(); +} diff --git a/examples/advanced/Region/testMQExRegion.sh.in b/examples/region/test-ex-region.sh.in similarity index 58% rename from examples/advanced/Region/testMQExRegion.sh.in rename to examples/region/test-ex-region.sh.in index 20db0b84..b063ca70 100755 --- a/examples/advanced/Region/testMQExRegion.sh.in +++ b/examples/region/test-ex-region.sh.in @@ -1,13 +1,12 @@ #!/bin/bash -exRegionConfig="@CMAKE_BINARY_DIR@/bin/config/ex-region.json" msgSize="1000000" -SESSION="$(@CMAKE_BINARY_DIR@/bin/uuidGen -h)" +SESSION="$(@CMAKE_BINARY_DIR@/fairmq/uuidGen -h)" # setup a trap to kill everything if the test fails/timeouts -trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID; @CMAKE_BINARY_DIR@/bin/shmmonitor --cleanup --session $SESSION' TERM +trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID; @CMAKE_BINARY_DIR@/fairmq/shmmonitor --cleanup --session $SESSION' TERM -SAMPLER="ex-region-sampler" +SAMPLER="fairmq-ex-region-sampler" SAMPLER+=" --id sampler1" SAMPLER+=" --severity debug" SAMPLER+=" --session $SESSION" @@ -15,19 +14,19 @@ SAMPLER+=" --control static --color false" SAMPLER+=" --max-iterations 1" SAMPLER+=" --msg-size $msgSize" SAMPLER+=" --transport shmem" -SAMPLER+=" --mq-config $exRegionConfig" -@CMAKE_BINARY_DIR@/bin/examples/advanced/Region/$SAMPLER & +SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://127.0.0.1:7777" +@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & SAMPLER_PID=$! -SINK="ex-region-sink" +SINK="fairmq-ex-region-sink" SINK+=" --id sink1" SINK+=" --session $SESSION" SINK+=" --verbosity veryhigh" SINK+=" --control static --color false" SINK+=" --max-iterations 1" SINK+=" --transport shmem" -SINK+=" --mq-config $exRegionConfig" -@CMAKE_BINARY_DIR@/bin/examples/advanced/Region/$SINK & +SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://127.0.0.1:7777" +@CMAKE_CURRENT_BINARY_DIR@/$SINK & SINK_PID=$! # wait for sampler and sink to finish diff --git a/examples/req-rep/CMakeLists.txt b/examples/req-rep/CMakeLists.txt new file mode 100644 index 00000000..df5b4991 --- /dev/null +++ b/examples/req-rep/CMakeLists.txt @@ -0,0 +1,51 @@ + ################################################################################ + # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # # + # This software is distributed under the terms of the # + # GNU Lesser General Public Licence (LGPL) version 3, # + # copied verbatim in the file "LICENSE" # + ################################################################################ + +add_library(ExampleReqRepLib STATIC + "Client.cxx" + "Client.h" + "Server.cxx" + "Server.h" +) + +target_link_libraries(ExampleReqRepLib PUBLIC FairMQ) + +add_executable(fairmq-ex-req-rep-client runClient.cxx) +target_link_libraries(fairmq-ex-req-rep-client PRIVATE ExampleReqRepLib) + + +add_executable(fairmq-ex-req-rep-server runServer.cxx) +target_link_libraries(fairmq-ex-req-rep-server PRIVATE ExampleReqRepLib) + +add_custom_target(ExampleReqRep DEPENDS fairmq-ex-req-rep-client fairmq-ex-req-rep-server) + +install( + TARGETS + fairmq-ex-req-rep-client + fairmq-ex-req-rep-server + + LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} + RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} +) + +# configure run script with different executable paths for build and for install directories +set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-req-rep.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-req-rep.sh) +set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-req-rep.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-req-rep.sh_install) + +install( + PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-req-rep.sh_install + DESTINATION ${PROJECT_INSTALL_BINDIR} + RENAME fairmq-start-ex-req-rep.sh +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-req-rep.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-req-rep.sh) + +add_test(NAME Example-ReqRep COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-req-rep.sh) +set_tests_properties(Example-ReqRep PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received reply from server: ") diff --git a/examples/MQ/5-req-rep/FairMQExample5Client.cxx b/examples/req-rep/Client.cxx similarity index 75% rename from examples/MQ/5-req-rep/FairMQExample5Client.cxx rename to examples/req-rep/Client.cxx index 1ba1939e..439041d1 100644 --- a/examples/MQ/5-req-rep/FairMQExample5Client.cxx +++ b/examples/req-rep/Client.cxx @@ -1,41 +1,41 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample5Client.cpp + * Client.cpp * * @since 2014-10-10 * @author A. Rybalchenko */ -#include // unique_ptr #include // this_thread::sleep_for #include -#include "FairMQExample5Client.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" +#include "Client.h" using namespace std; -FairMQExample5Client::FairMQExample5Client() +namespace example_req_rep +{ + +Client::Client() : fText() , fMaxIterations(0) , fNumIterations(0) { } -void FairMQExample5Client::InitTask() +void Client::InitTask() { fText = fConfig->GetValue("text"); fMaxIterations = fConfig->GetValue("max-iterations"); } -bool FairMQExample5Client::ConditionalRun() +bool Client::ConditionalRun() { string* text = new string(fText); @@ -44,19 +44,19 @@ bool FairMQExample5Client::ConditionalRun() // its size, // custom deletion function (called when transfer is done), // and pointer to the object managing the data buffer - FairMQMessagePtr request(NewMessage(const_cast(text->c_str()), // data + FairMQMessagePtr req(NewMessage(const_cast(text->c_str()), // data text->length(), // size [](void* /*data*/, void* object) { delete static_cast(object); }, // deletion callback text)); // object that manages the data - FairMQMessagePtr reply(NewMessage()); + FairMQMessagePtr rep(NewMessage()); LOG(info) << "Sending \"" << fText << "\" to server."; - if (Send(request, "data") > 0) + if (Send(req, "data") > 0) { - if (Receive(reply, "data") >= 0) + if (Receive(rep, "data") >= 0) { - LOG(info) << "Received reply from server: \"" << string(static_cast(reply->GetData()), reply->GetSize()) << "\""; + LOG(info) << "Received reply from server: \"" << string(static_cast(rep->GetData()), rep->GetSize()) << "\""; if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) { @@ -73,6 +73,8 @@ bool FairMQExample5Client::ConditionalRun() return false; } -FairMQExample5Client::~FairMQExample5Client() +Client::~Client() { } + +} // namespace example_req_rep diff --git a/examples/MQ/5-req-rep/FairMQExample5Client.h b/examples/req-rep/Client.h similarity index 73% rename from examples/MQ/5-req-rep/FairMQExample5Client.h rename to examples/req-rep/Client.h index df375ecb..3ea1b286 100644 --- a/examples/MQ/5-req-rep/FairMQExample5Client.h +++ b/examples/req-rep/Client.h @@ -1,29 +1,32 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample5Client.h + * Client.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE5CLIENT_H_ -#define FAIRMQEXAMPLE5CLIENT_H_ +#ifndef FAIRMQEXAMPLEREQREPCLIENT_H +#define FAIRMQEXAMPLEREQREPCLIENT_H #include #include "FairMQDevice.h" -class FairMQExample5Client : public FairMQDevice +namespace example_req_rep +{ + +class Client : public FairMQDevice { public: - FairMQExample5Client(); - virtual ~FairMQExample5Client(); + Client(); + virtual ~Client(); protected: std::string fText; @@ -34,4 +37,6 @@ class FairMQExample5Client : public FairMQDevice virtual void InitTask(); }; -#endif /* FAIRMQEXAMPLECLIENT_H_ */ +} // namespace example_req_rep + +#endif /* FAIRMQEXAMPLEREQREPCLIENT_H */ diff --git a/examples/MQ/5-req-rep/README.md b/examples/req-rep/README.md similarity index 100% rename from examples/MQ/5-req-rep/README.md rename to examples/req-rep/README.md diff --git a/examples/MQ/5-req-rep/FairMQExample5Server.cxx b/examples/req-rep/Server.cxx similarity index 70% rename from examples/MQ/5-req-rep/FairMQExample5Server.cxx rename to examples/req-rep/Server.cxx index cb81aa2c..11448bb1 100644 --- a/examples/MQ/5-req-rep/FairMQExample5Server.cxx +++ b/examples/req-rep/Server.cxx @@ -1,50 +1,51 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample5Server.cxx + * Server.cxx * * @since 2014-10-10 * @author A. Rybalchenko */ -#include "FairMQExample5Server.h" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig +#include "Server.h" using namespace std; -FairMQExample5Server::FairMQExample5Server() +namespace example_req_rep +{ + +Server::Server() : fMaxIterations(0) , fNumIterations(0) { - OnData("data", &FairMQExample5Server::HandleData); + OnData("data", &Server::HandleData); } -void FairMQExample5Server::InitTask() +void Server::InitTask() { // Get the fMaxIterations value from the command line options (via fConfig) fMaxIterations = fConfig->GetValue("max-iterations"); } -bool FairMQExample5Server::HandleData(FairMQMessagePtr& request, int /*index*/) +bool Server::HandleData(FairMQMessagePtr& req, int /*index*/) { - LOG(info) << "Received request from client: \"" << string(static_cast(request->GetData()), request->GetSize()) << "\""; + LOG(info) << "Received request from client: \"" << string(static_cast(req->GetData()), req->GetSize()) << "\""; - string* text = new string("Thank you for the \"" + string(static_cast(request->GetData()), request->GetSize()) + "\"!"); + string* text = new string("Thank you for the \"" + string(static_cast(req->GetData()), req->GetSize()) + "\"!"); LOG(info) << "Sending reply to client."; - FairMQMessagePtr reply(NewMessage(const_cast(text->c_str()), // data + FairMQMessagePtr rep(NewMessage(const_cast(text->c_str()), // data text->length(), // size [](void* /*data*/, void* object) { delete static_cast(object); }, // deletion callback text)); // object that manages the data - if (Send(reply, "data") > 0) + if (Send(rep, "data") > 0) { if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) { @@ -58,6 +59,8 @@ bool FairMQExample5Server::HandleData(FairMQMessagePtr& request, int /*index*/) return false; } -FairMQExample5Server::~FairMQExample5Server() +Server::~Server() { } + +} // namespace example_req_rep diff --git a/examples/MQ/5-req-rep/FairMQExample5Server.h b/examples/req-rep/Server.h similarity index 73% rename from examples/MQ/5-req-rep/FairMQExample5Server.h rename to examples/req-rep/Server.h index 7632e183..73d978ed 100644 --- a/examples/MQ/5-req-rep/FairMQExample5Server.h +++ b/examples/req-rep/Server.h @@ -1,27 +1,30 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** - * FairMQExample5Server.h + * Server.h * * @since 2014-10-10 * @author A. Rybalchenko */ -#ifndef FAIRMQEXAMPLE5SERVER_H_ -#define FAIRMQEXAMPLE5SERVER_H_ +#ifndef FAIRMQEXAMPLEREQREPSERVER_H +#define FAIRMQEXAMPLEREQREPSERVER_H #include "FairMQDevice.h" -class FairMQExample5Server : public FairMQDevice +namespace example_req_rep +{ + +class Server : public FairMQDevice { public: - FairMQExample5Server(); - virtual ~FairMQExample5Server(); + Server(); + virtual ~Server(); protected: virtual void InitTask(); @@ -32,4 +35,6 @@ class FairMQExample5Server : public FairMQDevice uint64_t fNumIterations; }; -#endif /* FAIRMQEXAMPLE5SERVER_H_ */ +} // namespace example_req_rep + +#endif /* FAIRMQEXAMPLEREQREPSERVER_H */ diff --git a/examples/req-rep/fairmq-start-ex-req-rep.sh.in b/examples/req-rep/fairmq-start-ex-req-rep.sh.in new file mode 100755 index 00000000..025cf92a --- /dev/null +++ b/examples/req-rep/fairmq-start-ex-req-rep.sh.in @@ -0,0 +1,11 @@ +#!/bin/bash + +CLIENT="fairmq-ex-req-rep-client" +CLIENT+=" --id client" +CLIENT+=" --channel-config name=data,type=req,method=connect,rateLogging=0,address=tcp://127.0.0.1:5005" +xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$CLIENT & + +SERVER="fairmq-ex-req-rep-server" +SERVER+=" --id server" +SERVER+=" --channel-config name=data,type=rep,method=bind,rateLogging=0,address=tcp://127.0.0.1:5005" +xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$SERVER & diff --git a/examples/MQ/6-multiple-channels/runExample6Sampler.cxx b/examples/req-rep/runClient.cxx similarity index 89% rename from examples/MQ/6-multiple-channels/runExample6Sampler.cxx rename to examples/req-rep/runClient.cxx index c628df10..acb417dc 100644 --- a/examples/MQ/6-multiple-channels/runExample6Sampler.cxx +++ b/examples/req-rep/runClient.cxx @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include "runFairMQDevice.h" -#include "FairMQExample6Sampler.h" +#include "Client.h" namespace bpo = boost::program_options; @@ -20,5 +20,5 @@ void addCustomOptions(bpo::options_description& options) FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { - return new FairMQExample6Sampler(); + return new example_req_rep::Client(); } diff --git a/examples/req-rep/runServer.cxx b/examples/req-rep/runServer.cxx new file mode 100644 index 00000000..21dc65ca --- /dev/null +++ b/examples/req-rep/runServer.cxx @@ -0,0 +1,23 @@ +/******************************************************************************** + * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "runFairMQDevice.h" +#include "Server.h" + +namespace bpo = boost::program_options; + +void addCustomOptions(bpo::options_description& options) +{ + options.add_options() + ("max-iterations", bpo::value()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); +} + +FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) +{ + return new example_req_rep::Server(); +} diff --git a/examples/MQ/5-req-rep/testMQEx5.sh.in b/examples/req-rep/test-ex-req-rep.sh.in similarity index 59% rename from examples/MQ/5-req-rep/testMQEx5.sh.in rename to examples/req-rep/test-ex-req-rep.sh.in index b644ae52..c078ee0e 100755 --- a/examples/MQ/5-req-rep/testMQEx5.sh.in +++ b/examples/req-rep/test-ex-req-rep.sh.in @@ -1,26 +1,24 @@ #!/bin/bash -ex5config="@CMAKE_BINARY_DIR@/bin/config/ex5-req-rep.json" - # setup a trap to kill everything if the test fails/timeouts trap 'kill -TERM $CLIENT_PID; kill -TERM $SERVER_PID; wait $CLIENT_PID; wait $SERVER_PID;' TERM -CLIENT="ex5-client" +CLIENT="fairmq-ex-req-rep-client" CLIENT+=" --id client" CLIENT+=" --verbosity veryhigh" CLIENT+=" --control static --color false" CLIENT+=" --max-iterations 1" -CLIENT+=" --mq-config $ex5config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/5-req-rep/$CLIENT & +CLIENT+=" --channel-config name=data,type=req,method=connect,rateLogging=0,address=tcp://127.0.0.1:5005" +@CMAKE_CURRENT_BINARY_DIR@/$CLIENT & CLIENT_PID=$! -SERVER="ex5-server" +SERVER="fairmq-ex-req-rep-server" SERVER+=" --id server" SERVER+=" --verbosity veryhigh" SERVER+=" --control static --color false" SERVER+=" --max-iterations 1" -SERVER+=" --mq-config $ex5config" -@CMAKE_BINARY_DIR@/bin/examples/MQ/5-req-rep/$SERVER & +SERVER+=" --channel-config name=data,type=rep,method=bind,rateLogging=0,address=tcp://127.0.0.1:5005" +@CMAKE_CURRENT_BINARY_DIR@/$SERVER & SERVER_PID=$! # wait for everything to finish diff --git a/fairmq/CMakeLists.txt b/fairmq/CMakeLists.txt index 0c931175..860676c3 100644 --- a/fairmq/CMakeLists.txt +++ b/fairmq/CMakeLists.txt @@ -179,10 +179,8 @@ endif() ################### # configure files # ################### -configure_file(${CMAKE_SOURCE_DIR}/fairmq/run/startMQBenchmark.sh.in ${CMAKE_BINARY_DIR}/bin/startMQBenchmark.sh) -configure_file(${CMAKE_SOURCE_DIR}/fairmq/run/benchmark.json ${CMAKE_BINARY_DIR}/bin/config/benchmark.json) -configure_file(${CMAKE_SOURCE_DIR}/fairmq/options/startConfigExample.sh.in - ${CMAKE_BINARY_DIR}/bin/startConfigExample.sh) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/run/startMQBenchmark.sh.in ${CMAKE_CURRENT_BINARY_DIR}/startMQBenchmark.sh) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/options/startConfigExample.sh.in ${CMAKE_CURRENT_BINARY_DIR}/startConfigExample.sh) ################################# diff --git a/fairmq/FairMQDevice.cxx b/fairmq/FairMQDevice.cxx index f0201ee8..bfe152f1 100644 --- a/fairmq/FairMQDevice.cxx +++ b/fairmq/FairMQDevice.cxx @@ -6,10 +6,7 @@ * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#include #include -#include -#include #include #include diff --git a/fairmq/FairMQDevice.h b/fairmq/FairMQDevice.h index 825e10ea..d4acae7d 100644 --- a/fairmq/FairMQDevice.h +++ b/fairmq/FairMQDevice.h @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include // unique_ptr diff --git a/fairmq/options/FairMQParser.cxx b/fairmq/options/FairMQParser.cxx index 48ce217c..bd2a0f74 100644 --- a/fairmq/options/FairMQParser.cxx +++ b/fairmq/options/FairMQParser.cxx @@ -31,8 +31,8 @@ FairMQMap ptreeToMQMap(const boost::property_tree::ptree& pt, const string& id, { // Create fair mq map FairMQMap channelMap; - //Helper::PrintPropertyTree(pt); - //Helper::PrintDeviceList(pt.get_child(rootNode)); + // boost::property_tree::json_parser::write_json(std::cout, pt); + // Helper::PrintDeviceList(pt.get_child(rootNode)); // Extract value from boost::property_tree Helper::DeviceParser(pt.get_child(rootNode), channelMap, id); @@ -93,8 +93,6 @@ void DeviceParser(const boost::property_tree::ptree& tree, FairMQMap& channelMap { string deviceIdKey; - LOG(debug) << "Looking for '" << deviceId << "' id/key in the provided config file..."; - // For each node in fairMQOptions for (const auto& p : tree) { @@ -122,7 +120,7 @@ void DeviceParser(const boost::property_tree::ptree& tree, FairMQMap& channelMap continue; } - LOG(debug) << "Found with following channels:"; + LOG(debug) << "Found following channels for device ID '" << deviceId << "' :"; ChannelParser(q.second, channelMap); } @@ -260,14 +258,6 @@ void SocketParser(const boost::property_tree::ptree& tree, vector } } -void PrintPropertyTree(const boost::property_tree::ptree& tree, int level) -{ - for (const auto& p : tree) { - cout << setw(level+1) << level << ": " << p.first << " " << p.second.get_value() << endl; - PrintPropertyTree(p.second.get_child(""), level + 1); - } -} - } // Helper namespace } // namespace parser diff --git a/fairmq/options/FairMQParser.h b/fairmq/options/FairMQParser.h index 12f87780..e910d5aa 100644 --- a/fairmq/options/FairMQParser.h +++ b/fairmq/options/FairMQParser.h @@ -41,7 +41,6 @@ void PrintDeviceList(const boost::property_tree::ptree& tree); void DeviceParser(const boost::property_tree::ptree& tree, FairMQMap& channelMap, const std::string& deviceId); void ChannelParser(const boost::property_tree::ptree& tree, FairMQMap& channelMap); void SocketParser(const boost::property_tree::ptree& tree, std::vector& channelList, const std::string& channelName, const FairMQChannel& commonChannel); -void PrintPropertyTree(const boost::property_tree::ptree& tree, int level = 0); } // Helper namespace diff --git a/fairmq/options/FairMQProgOptions.cxx b/fairmq/options/FairMQProgOptions.cxx index e2b3a161..0fa5ec1a 100644 --- a/fairmq/options/FairMQProgOptions.cxx +++ b/fairmq/options/FairMQProgOptions.cxx @@ -240,7 +240,7 @@ void FairMQProgOptions::InitOptionDescription() ("port-range-max", po::value()->default_value(32000), "End of the port range for dynamic initialization.") ("print-channels", po::value()->implicit_value(true), "Print registered channel endpoints in a machine-readable format (::)") ("shm-segment-size", po::value()->default_value(2000000000), "Shared memory: size of the shared memory segment (in bytes).") - ("shm-monitor", po::value()->default_value(false), "Shared memory: run monitor daemon.") + ("shm-monitor", po::value()->default_value(true), "Shared memory: run monitor daemon.") ("rate", po::value()->default_value(0.), "Rate for conditional run loop (Hz).") ("session", po::value()->default_value("default"), "Session name.") ; diff --git a/fairmq/options/FairMQSuboptParser.cxx b/fairmq/options/FairMQSuboptParser.cxx index cbc204ff..1b985dee 100644 --- a/fairmq/options/FairMQSuboptParser.cxx +++ b/fairmq/options/FairMQSuboptParser.cxx @@ -44,7 +44,6 @@ FairMQMap SUBOPT::UserParser(const vector& channelConfig, const string& ptree channelProperties; ptree socketsArray; - ptree socketProperties; string argString(token); char* subopts = &argString[0]; @@ -57,6 +56,12 @@ FairMQMap SUBOPT::UserParser(const vector& channelConfig, const string& channelName = value; channelProperties.put("name", channelName); } + else if (subopt == ADDRESS) + { + ptree socketProperties; + socketProperties.put(channelOptionKeys[subopt], value); + socketsArray.push_back(make_pair("", socketProperties)); + } else if (subopt >= 0 && value != nullptr) { channelProperties.put(channelOptionKeys[subopt], value); @@ -65,7 +70,6 @@ FairMQMap SUBOPT::UserParser(const vector& channelConfig, const string& if (channelName != "") { - socketsArray.push_back(make_pair("", socketProperties)); channelProperties.add_child("sockets", socketsArray); } else diff --git a/fairmq/run/benchmark.json b/fairmq/run/benchmark.json deleted file mode 100644 index 77640fc8..00000000 --- a/fairmq/run/benchmark.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "fairMQOptions": { - "devices": [ - { - "id": "bsampler1", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "push", - "method": "bind", - "address": "tcp://127.0.0.1:5555", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 1 - } - ] - } - ] - }, - { - "id": "sink1", - "channels": [ - { - "name": "data", - "sockets": [ - { - "type": "pull", - "method": "connect", - "address": "tcp://127.0.0.1:5555", - "sndBufSize": 1000, - "rcvBufSize": 1000, - "rateLogging": 1 - } - ] - } - ] - } - ] - } -} diff --git a/fairmq/run/startMQBenchmark.sh.in b/fairmq/run/startMQBenchmark.sh.in index 1781a2e6..4065dd02 100755 --- a/fairmq/run/startMQBenchmark.sh.in +++ b/fairmq/run/startMQBenchmark.sh.in @@ -70,10 +70,10 @@ SAMPLER+=" --msg-size $msgSize" SAMPLER+=" --same-msg $sameMsg" # SAMPLER+=" --msg-rate 1000" SAMPLER+=" --max-iterations $maxIterations" -SAMPLER+=" --mq-config @CMAKE_BINARY_DIR@/bin/config/benchmark.json" -xterm -geometry 90x50+0+0 -hold -e $affinitySamp @CMAKE_BINARY_DIR@/bin/$SAMPLER & +SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://127.0.01:5555" +xterm -geometry 90x50+0+0 -hold -e $affinitySamp @CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & echo "" -echo "started: xterm -geometry 90x50+0+0 -hold -e $affinitySamp @CMAKE_BINARY_DIR@/bin/$SAMPLER" +echo "started: xterm -geometry 90x50+0+0 -hold -e $affinitySamp @CMAKE_CURRENT_BINARY_DIR@/$SAMPLER" echo "pid: $!" SINK="sink" @@ -83,9 +83,9 @@ SINK+=" --id sink1" SINK+=" --transport $transport" SINK+=" --severity debug" SINK+=" --max-iterations $maxIterations" -SINK+=" --mq-config @CMAKE_BINARY_DIR@/bin/config/benchmark.json" -xterm -geometry 90x50+550+0 -hold -e $affinitySink @CMAKE_BINARY_DIR@/bin/$SINK & +SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://127.0.01:5555" +xterm -geometry 90x50+550+0 -hold -e $affinitySink @CMAKE_CURRENT_BINARY_DIR@/$SINK & echo "" -echo "started: xterm -geometry 90x50+550+0 -hold -e $affinitySink @CMAKE_BINARY_DIR@/bin/$SINK" +echo "started: xterm -geometry 90x50+550+0 -hold -e $affinitySink @CMAKE_CURRENT_BINARY_DIR@/$SINK" echo "pid: $!" echo ""