mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 17:41:45 +00:00
Compare commits
185 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
49d8a1b4dd | ||
|
f14f507584 | ||
|
8dd0b25c06 | ||
|
7edf436919 | ||
|
0e5978b160 | ||
|
71b1866d7b | ||
|
6699711e17 | ||
|
120760da0a | ||
|
d03a504ccd | ||
|
cf004f69b2 | ||
|
cfa18ccfce | ||
|
e332e20dbd | ||
|
3ab10ced7a | ||
|
1b30f3ac14 | ||
|
35c7959c53 | ||
|
5ea8ffeb34 | ||
|
04ee1db8e5 | ||
|
4a15a38dd4 | ||
|
0f5e1b6815 | ||
|
5e6ad47223 | ||
|
6932f88c84 | ||
|
5e97d85956 | ||
|
fdbf289364 | ||
|
266843cda5 | ||
|
b126ede45a | ||
|
12e6a874db | ||
|
73109fe6d3 | ||
|
3b2d2a0ac8 | ||
|
72a45f78b3 | ||
|
b63f31d0e0 | ||
|
70a583d08d | ||
|
fe9b87e4e2 | ||
|
2ac27905e7 | ||
|
690e8a0370 | ||
|
1f0c94f898 | ||
|
62ed4e5f80 | ||
|
f1d6b18668 | ||
|
c0153a6b55 | ||
|
86a1dd38a2 | ||
|
be8ab06cc1 | ||
|
b0f73017e2 | ||
|
b83655d5da | ||
|
9c27051cdc | ||
|
65f9519917 | ||
|
b5545c1575 | ||
|
3eca8e9def | ||
|
beb7766fca | ||
|
bf909f94dc | ||
|
1140c4c6ab | ||
|
a6da208e79 | ||
|
ba3a82b1df | ||
|
e8cc104344 | ||
|
d5d5c27958 | ||
|
5a7dcd9fc1 | ||
|
78b1c188bf | ||
|
66bc7ba762 | ||
|
88bc1f7a06 | ||
|
f70201610b | ||
|
fc7f6f1116 | ||
|
8125489776 | ||
|
6dd0a44308 | ||
|
afe2dcaa02 | ||
|
aeab9e5407 | ||
|
539e5602a6 | ||
|
beb510ded8 | ||
|
d1c51e0f1f | ||
|
f885b4618e | ||
|
3364da9541 | ||
|
7aec6f91de | ||
|
9e2a002942 | ||
|
52c6264faf | ||
|
79489bb501 | ||
|
c60dd9965c | ||
|
79ca436b74 | ||
|
36d4f3c937 | ||
|
bdf895ae9e | ||
|
42986e664c | ||
|
dd47b34e06 | ||
|
a59c902c74 | ||
|
dabc48c21a | ||
|
236d5a8608 | ||
|
5a782e8726 | ||
|
5008fa4732 | ||
|
b5bb476b0d | ||
|
ea7ae04025 | ||
|
02692e7002 | ||
|
53a4d17f8b | ||
|
20544e1f18 | ||
|
b32e04db60 | ||
|
0d03c76a75 | ||
|
2916a491b9 | ||
|
b56e32eb11 | ||
|
4b516de81a | ||
|
361fb0cba5 | ||
|
df574c6466 | ||
|
dbdabd23a4 | ||
|
ccbf0be572 | ||
|
7a67719a3c | ||
|
f4a54ff550 | ||
|
d22023bcb5 | ||
|
a15d59c725 | ||
|
8cfc04721e | ||
|
e9318dd234 | ||
|
c8fc5ad33f | ||
|
59e32437a2 | ||
|
a3afadb824 | ||
|
9992811822 | ||
|
4218c185a4 | ||
|
5a49c5b9b1 | ||
|
960b612d80 | ||
|
e1a113aabe | ||
|
5721ea9510 | ||
|
330687772f | ||
|
7cbd154344 | ||
|
036561ab38 | ||
|
274ba5ec00 | ||
|
c5efd3e4a6 | ||
|
0a5820c07f | ||
|
5788daa410 | ||
|
46014118f0 | ||
|
adc4688f9b | ||
|
c3127f22e5 | ||
|
926ee743ed | ||
|
c7b1304a2c | ||
|
32764e1b12 | ||
|
96348b8462 | ||
|
cd83efadea | ||
|
38eb9d22e4 | ||
|
a20ac7af08 | ||
|
24aabdb854 | ||
|
539b088ade | ||
|
b05782af16 | ||
|
3a8f34efaa | ||
|
8160edfd04 | ||
|
3d4cd02812 | ||
|
0ae53fd7d9 | ||
|
a545bee3b1 | ||
|
f00519b99b | ||
|
41fc27d504 | ||
|
811d1b8973 | ||
|
ced67d8952 | ||
|
8123a6ecab | ||
|
beff0af51b | ||
|
21835cc104 | ||
|
334d81a1ab | ||
|
c1719eb285 | ||
|
fcd1022997 | ||
|
e221242f9a | ||
|
e853d121bf | ||
|
14d6d717a3 | ||
|
119cbe37f1 | ||
|
0e72a9bf54 | ||
|
3785fd9ff9 | ||
|
278cd62049 | ||
|
6c63b01cfe | ||
|
66acde2a69 | ||
|
19ab8bba3b | ||
|
be524d838a | ||
|
92af823135 | ||
|
50dacbcdde | ||
|
264a178424 | ||
|
1c8ad03f3c | ||
|
25658370fa | ||
|
f42945b3a3 | ||
|
9544de0647 | ||
|
d608abf31c | ||
|
15de80cfd3 | ||
|
f2da29a650 | ||
|
c180300303 | ||
|
9f8a3553ba | ||
|
692ec4e997 | ||
|
b6d9c949ae | ||
|
b6791856f9 | ||
|
a1e0814a92 | ||
|
38bb14e556 | ||
|
7187953604 | ||
|
c290c16896 | ||
|
fd2bac3e22 | ||
|
8e3f25851c | ||
|
ce937ca03e | ||
|
684e711b8b | ||
|
5b5fecc994 | ||
|
462a93b58b | ||
|
a2cff5b7bb | ||
|
b2e027478e |
@@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
Checks: '*,-google-*,-fuchsia-*,-cert-*,-llvm-header-guard,-readability-named-parameter,-misc-non-private-member-variables-in-classes,-*-magic-numbers,-llvm-include-order,-hicpp-no-array-decay,-performance-unnecessary-value-param,-cppcoreguidelines-pro-bounds-array-to-pointer-decay'
|
Checks: '*,-google-*,-fuchsia-*,-cert-*,-llvm-header-guard,-readability-named-parameter,-misc-non-private-member-variables-in-classes,-*-magic-numbers,-llvm-include-order,-hicpp-no-array-decay,-performance-unnecessary-value-param,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-modernize-use-trailing-return-type,-readability-redundant-member-init'
|
||||||
HeaderFilterRegex: '/(fairmq/)'
|
HeaderFilterRegex: '/(fairmq/)'
|
||||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -4,3 +4,6 @@
|
|||||||
[submodule "extern/asio"]
|
[submodule "extern/asio"]
|
||||||
path = extern/asio
|
path = extern/asio
|
||||||
url = https://github.com/chriskohlhoff/asio
|
url = https://github.com/chriskohlhoff/asio
|
||||||
|
[submodule "extern/PicoSHA2"]
|
||||||
|
path = extern/PicoSHA2
|
||||||
|
url = https://github.com/okdshin/PicoSHA2
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
|
||||||
cmake_policy(VERSION 3.11...3.15)
|
cmake_policy(VERSION 3.12...3.15)
|
||||||
|
|
||||||
# Project ######################################################################
|
# Project ######################################################################
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
||||||
@@ -18,7 +18,7 @@ get_git_version()
|
|||||||
project(FairMQ VERSION ${PROJECT_VERSION} LANGUAGES CXX)
|
project(FairMQ VERSION ${PROJECT_VERSION} LANGUAGES CXX)
|
||||||
message(STATUS "${BWhite}${PROJECT_NAME}${CR} ${PROJECT_GIT_VERSION} from ${PROJECT_DATE}")
|
message(STATUS "${BWhite}${PROJECT_NAME}${CR} ${PROJECT_GIT_VERSION} from ${PROJECT_DATE}")
|
||||||
|
|
||||||
if(BUILD_OFI_TRANSPORT OR BUILD_SDK)
|
if(BUILD_OFI_TRANSPORT OR BUILD_SDK OR BUILD_PMIX_PLUGIN)
|
||||||
set(PROJECT_MIN_CXX_STANDARD 14)
|
set(PROJECT_MIN_CXX_STANDARD 14)
|
||||||
else()
|
else()
|
||||||
set(PROJECT_MIN_CXX_STANDARD 11)
|
set(PROJECT_MIN_CXX_STANDARD 11)
|
||||||
@@ -31,28 +31,30 @@ include(CTest)
|
|||||||
|
|
||||||
|
|
||||||
# Build options ################################################################
|
# Build options ################################################################
|
||||||
fairmq_build_option(BUILD_FAIRMQ "Build FairMQ library and devices."
|
fairmq_build_option(BUILD_FAIRMQ "Build FairMQ library and devices."
|
||||||
DEFAULT ON)
|
DEFAULT ON)
|
||||||
fairmq_build_option(BUILD_TESTING "Build tests."
|
fairmq_build_option(BUILD_TESTING "Build tests."
|
||||||
DEFAULT OFF REQUIRES "BUILD_FAIRMQ")
|
DEFAULT OFF REQUIRES "BUILD_FAIRMQ")
|
||||||
fairmq_build_option(BUILD_NANOMSG_TRANSPORT "Build nanomsg transport."
|
fairmq_build_option(BUILD_OFI_TRANSPORT "Build experimental OFI transport."
|
||||||
DEFAULT OFF REQUIRES "BUILD_FAIRMQ")
|
DEFAULT OFF REQUIRES "BUILD_FAIRMQ")
|
||||||
fairmq_build_option(BUILD_OFI_TRANSPORT "Build experimental OFI transport."
|
fairmq_build_option(BUILD_SDK_COMMANDS "Build the FairMQ SDK commands."
|
||||||
DEFAULT OFF REQUIRES "BUILD_FAIRMQ")
|
DEFAULT OFF)
|
||||||
fairmq_build_option(BUILD_SDK_COMMANDS "Build the FairMQ SDK commands."
|
fairmq_build_option(BUILD_DDS_PLUGIN "Build DDS plugin."
|
||||||
DEFAULT OFF)
|
DEFAULT OFF REQUIRES "BUILD_FAIRMQ;BUILD_SDK_COMMANDS")
|
||||||
fairmq_build_option(BUILD_DDS_PLUGIN "Build DDS plugin."
|
fairmq_build_option(BUILD_PMIX_PLUGIN "Build PMIx plugin."
|
||||||
DEFAULT OFF REQUIRES "BUILD_FAIRMQ;BUILD_SDK_COMMANDS")
|
DEFAULT OFF REQUIRES "BUILD_FAIRMQ;BUILD_SDK_COMMANDS")
|
||||||
fairmq_build_option(BUILD_PMIX_PLUGIN "Build PMIx plugin."
|
fairmq_build_option(BUILD_EXAMPLES "Build FairMQ examples."
|
||||||
DEFAULT OFF REQUIRES "BUILD_FAIRMQ")
|
DEFAULT ON REQUIRES "BUILD_FAIRMQ")
|
||||||
fairmq_build_option(BUILD_EXAMPLES "Build FairMQ examples."
|
fairmq_build_option(BUILD_SDK "Build the FairMQ controller SDK."
|
||||||
DEFAULT ON REQUIRES "BUILD_FAIRMQ")
|
DEFAULT OFF REQUIRES "BUILD_DDS_PLUGIN;BUILD_SDK_COMMANDS")
|
||||||
fairmq_build_option(BUILD_SDK "Build the FairMQ controller SDK."
|
fairmq_build_option(BUILD_DOCS "Build FairMQ documentation."
|
||||||
DEFAULT OFF REQUIRES "BUILD_DDS_PLUGIN;BUILD_SDK_COMMANDS")
|
DEFAULT OFF)
|
||||||
fairmq_build_option(BUILD_DOCS "Build FairMQ documentation."
|
fairmq_build_option(FAST_BUILD "Fast production build. Not recommended for development."
|
||||||
DEFAULT OFF)
|
DEFAULT OFF)
|
||||||
fairmq_build_option(FAST_BUILD "Fast production build. Not recommended for development."
|
fairmq_build_option(USE_EXTERNAL_GTEST "Do not use bundled GTest. Not recommended."
|
||||||
DEFAULT OFF)
|
DEFAULT OFF)
|
||||||
|
fairmq_build_option(FAIRMQ_DEBUG_MODE "Compile in debug mode (may decrease performance)."
|
||||||
|
DEFAULT OFF)
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
@@ -65,11 +67,6 @@ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
|||||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
find_package2(PRIVATE nanomsg REQUIRED)
|
|
||||||
set(PROJECT_nanomsg_VERSION 1.1.3) # Once upstream releases 1.1.5, we should bump again and use version check
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
if(BUILD_OFI_TRANSPORT)
|
||||||
find_package2(PRIVATE asiofi REQUIRED
|
find_package2(PRIVATE asiofi REQUIRED
|
||||||
VERSION 0.3.1
|
VERSION 0.3.1
|
||||||
@@ -79,12 +76,6 @@ if(BUILD_OFI_TRANSPORT)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
find_package2(PRIVATE msgpack REQUIRED
|
|
||||||
VERSION 3.1.0
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_SDK_COMMANDS)
|
if(BUILD_SDK_COMMANDS)
|
||||||
find_package2(PRIVATE Flatbuffers REQUIRED)
|
find_package2(PRIVATE Flatbuffers REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
@@ -105,7 +96,7 @@ endif()
|
|||||||
|
|
||||||
if(BUILD_FAIRMQ OR BUILD_SDK)
|
if(BUILD_FAIRMQ OR BUILD_SDK)
|
||||||
find_package2(PUBLIC FairLogger REQUIRED
|
find_package2(PUBLIC FairLogger REQUIRED
|
||||||
VERSION 1.2.0
|
VERSION 1.6.0
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(dep IN LISTS FairLogger_PACKAGE_DEPENDENCIES)
|
foreach(dep IN LISTS FairLogger_PACKAGE_DEPENDENCIES)
|
||||||
@@ -157,10 +148,14 @@ if(BUILD_FAIRMQ)
|
|||||||
find_package2(PRIVATE ZeroMQ REQUIRED
|
find_package2(PRIVATE ZeroMQ REQUIRED
|
||||||
VERSION 4.1.4
|
VERSION 4.1.4
|
||||||
)
|
)
|
||||||
|
build_bundled(PicoSHA2 extern/PicoSHA2)
|
||||||
|
find_package2(PRIVATE PicoSHA2 REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
find_package2(PRIVATE GTest VERSION 1.7.0)
|
if(USE_EXTERNAL_GTEST)
|
||||||
|
find_package2(PRIVATE GTest VERSION 1.7.0)
|
||||||
|
endif()
|
||||||
if(NOT GTest_FOUND)
|
if(NOT GTest_FOUND)
|
||||||
build_bundled(GTest extern/googletest)
|
build_bundled(GTest extern/googletest)
|
||||||
find_package2(PRIVATE GTest REQUIRED)
|
find_package2(PRIVATE GTest REQUIRED)
|
||||||
@@ -215,9 +210,6 @@ endif()
|
|||||||
if(BUILD_PMIX_PLUGIN)
|
if(BUILD_PMIX_PLUGIN)
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS pmix_plugin)
|
list(APPEND PROJECT_PACKAGE_COMPONENTS pmix_plugin)
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS nanomsg_transport)
|
|
||||||
endif()
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
if(BUILD_OFI_TRANSPORT)
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS ofi_transport)
|
list(APPEND PROJECT_PACKAGE_COMPONENTS ofi_transport)
|
||||||
endif()
|
endif()
|
||||||
@@ -320,16 +312,10 @@ if(PROJECT_PACKAGE_DEPENDENCIES)
|
|||||||
endif()
|
endif()
|
||||||
elseif(${dep} STREQUAL GTest)
|
elseif(${dep} STREQUAL GTest)
|
||||||
get_filename_component(prefix ${GTEST_INCLUDE_DIRS}/.. ABSOLUTE)
|
get_filename_component(prefix ${GTEST_INCLUDE_DIRS}/.. ABSOLUTE)
|
||||||
elseif(${dep} STREQUAL msgpack)
|
|
||||||
get_target_property(msgpack_include msgpackc-cxx INTERFACE_INCLUDE_DIRECTORIES)
|
|
||||||
get_filename_component(prefix ${msgpack_include}/.. ABSOLUTE)
|
|
||||||
elseif(${dep} STREQUAL asiofi)
|
elseif(${dep} STREQUAL asiofi)
|
||||||
set(prefix ${asiofi_ROOT})
|
set(prefix ${asiofi_ROOT})
|
||||||
elseif(${dep} STREQUAL OFI)
|
elseif(${dep} STREQUAL OFI)
|
||||||
get_filename_component(prefix ${${dep}_INCLUDE_DIRS}/.. ABSOLUTE)
|
get_filename_component(prefix ${${dep}_INCLUDE_DIRS}/.. ABSOLUTE)
|
||||||
elseif(${dep} STREQUAL nanomsg)
|
|
||||||
get_target_property(nn_include nanomsg INTERFACE_INCLUDE_DIRECTORIES)
|
|
||||||
get_filename_component(prefix ${nn_include}/.. ABSOLUTE)
|
|
||||||
elseif(${dep} STREQUAL DDS)
|
elseif(${dep} STREQUAL DDS)
|
||||||
set(prefix "${DDS_INSTALL_PREFIX}")
|
set(prefix "${DDS_INSTALL_PREFIX}")
|
||||||
elseif(${dep} STREQUAL Boost)
|
elseif(${dep} STREQUAL Boost)
|
||||||
@@ -378,12 +364,6 @@ else()
|
|||||||
set(tests_summary "${BRed} NO${CR} (enable with ${BMagenta}-DBUILD_TESTING=ON${CR})")
|
set(tests_summary "${BRed} NO${CR} (enable with ${BMagenta}-DBUILD_TESTING=ON${CR})")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS " ${BWhite}tests${CR} ${tests_summary}")
|
message(STATUS " ${BWhite}tests${CR} ${tests_summary}")
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
set(nn_summary "${BGreen}YES${CR} (disable with ${BMagenta}-DBUILD_NANOMSG_TRANSPORT=OFF${CR})")
|
|
||||||
else()
|
|
||||||
set(nn_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_NANOMSG_TRANSPORT=ON${CR})")
|
|
||||||
endif()
|
|
||||||
message(STATUS " ${BWhite}nanomsg_transport${CR} ${nn_summary}")
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
if(BUILD_OFI_TRANSPORT)
|
||||||
set(ofi_summary "${BGreen}YES${CR} EXPERIMENTAL (requires C++14) (disable with ${BMagenta}-DBUILD_OFI_TRANSPORT=OFF${CR})")
|
set(ofi_summary "${BGreen}YES${CR} EXPERIMENTAL (requires C++14) (disable with ${BMagenta}-DBUILD_OFI_TRANSPORT=OFF${CR})")
|
||||||
else()
|
else()
|
||||||
@@ -397,9 +377,9 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
message(STATUS " ${BWhite}dds_plugin${CR} ${dds_summary}")
|
message(STATUS " ${BWhite}dds_plugin${CR} ${dds_summary}")
|
||||||
if(BUILD_PMIX_PLUGIN)
|
if(BUILD_PMIX_PLUGIN)
|
||||||
set(pmix_summary "${BGreen}YES${CR} (disable with ${BMagenta}-DBUILD_PMIX_PLUGIN=OFF${CR})")
|
set(pmix_summary "${BGreen}YES${CR} EXPERIMENTAL (requires C++14) (disable with ${BMagenta}-DBUILD_PMIX_PLUGIN=OFF${CR})")
|
||||||
else()
|
else()
|
||||||
set(pmix_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_PMIX_PLUGIN=ON${CR})")
|
set(pmix_summary "${BRed} NO${CR} EXPERIMENTAL (requires C++14) (default, enable with ${BMagenta}-DBUILD_PMIX_PLUGIN=ON${CR})")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS " ${BWhite}pmix_plugin${CR} ${pmix_summary}")
|
message(STATUS " ${BWhite}pmix_plugin${CR} ${pmix_summary}")
|
||||||
if(BUILD_EXAMPLES)
|
if(BUILD_EXAMPLES)
|
||||||
@@ -451,4 +431,10 @@ message(STATUS " ${Cyan}INSTALL PREFIX${CR} ${BGreen}${CMAKE_INSTALL_PREFIX
|
|||||||
message(STATUS " ")
|
message(STATUS " ")
|
||||||
message(STATUS " ${Cyan}RUN STATIC ANALYSIS ${static_ana_summary}")
|
message(STATUS " ${Cyan}RUN STATIC ANALYSIS ${static_ana_summary}")
|
||||||
message(STATUS " ")
|
message(STATUS " ")
|
||||||
|
if(FAIRMQ_DEBUG_MODE)
|
||||||
|
message(STATUS " ${Cyan}DEBUG_MODE${CR} ${BGreen}${FAIRMQ_DEBUG_MODE}${CR} (disable with ${BMagenta}-DFAIRMQ_DEBUG_MODE=OFF${CR})")
|
||||||
|
else()
|
||||||
|
message(STATUS " ${Cyan}DEBUG_MODE${CR} ${BRed}${FAIRMQ_DEBUG_MODE}${CR} (enable with ${BMagenta}-DFAIRMQ_DEBUG_MODE=ON${CR})")
|
||||||
|
endif()
|
||||||
|
message(STATUS " ")
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@@ -4,8 +4,10 @@ Eulisse, Giulio
|
|||||||
Karabowicz, Radoslaw
|
Karabowicz, Radoslaw
|
||||||
Kretz, Matthias <kretz@kde.org>
|
Kretz, Matthias <kretz@kde.org>
|
||||||
Krzewicki, Mikolaj
|
Krzewicki, Mikolaj
|
||||||
|
Lebedev, Andrey
|
||||||
Mrnjavac, Teo <teo.m@cern.ch>
|
Mrnjavac, Teo <teo.m@cern.ch>
|
||||||
Neskovic, Gvozden
|
Neskovic, Gvozden
|
||||||
Richter, Matthias
|
Richter, Matthias
|
||||||
|
Tacke, Christian
|
||||||
Uhlig, Florian
|
Uhlig, Florian
|
||||||
Wenzel, Sandro
|
Wenzel, Sandro
|
||||||
|
23
COPYRIGHT
23
COPYRIGHT
@@ -23,6 +23,10 @@ Files: extern/asio
|
|||||||
Copyright: 2003-2019, Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
Copyright: 2003-2019, Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||||
License: BSL-1.0
|
License: BSL-1.0
|
||||||
|
|
||||||
|
Files: extern/PicoSHA2
|
||||||
|
Copyright: 2017 okdshin
|
||||||
|
License: MIT
|
||||||
|
|
||||||
License: LGPL-3.0-only
|
License: LGPL-3.0-only
|
||||||
[see LICENSE file]
|
[see LICENSE file]
|
||||||
|
|
||||||
@@ -102,3 +106,22 @@ License: BSL-1.0
|
|||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
DEALINGS IN THE SOFTWARE.
|
DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
License: MIT
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
@@ -26,13 +26,13 @@ Set(configure_options "${configure_options};-DCTEST_USE_LAUNCHERS=${CTEST_USE_LA
|
|||||||
|
|
||||||
Set(configure_options "${configure_options};-DDISABLE_COLOR=ON")
|
Set(configure_options "${configure_options};-DDISABLE_COLOR=ON")
|
||||||
Set(configure_options "${configure_options};-DCMAKE_PREFIX_PATH=$ENV{SIMPATH}")
|
Set(configure_options "${configure_options};-DCMAKE_PREFIX_PATH=$ENV{SIMPATH}")
|
||||||
Set(configure_options "${configure_options};-DBUILD_NANOMSG_TRANSPORT=ON")
|
|
||||||
# Set(configure_options "${configure_options};-DBUILD_OFI_TRANSPORT=ON")
|
# Set(configure_options "${configure_options};-DBUILD_OFI_TRANSPORT=ON")
|
||||||
Set(configure_options "${configure_options};-DBUILD_DDS_PLUGIN=ON")
|
Set(configure_options "${configure_options};-DBUILD_DDS_PLUGIN=ON")
|
||||||
Set(configure_options "${configure_options};-DBUILD_SDK=ON")
|
Set(configure_options "${configure_options};-DBUILD_SDK=ON")
|
||||||
Set(configure_options "${configure_options};-DBUILD_SDK_COMMANDS=ON")
|
Set(configure_options "${configure_options};-DBUILD_SDK_COMMANDS=ON")
|
||||||
Set(configure_options "${configure_options};-DFAST_BUILD=ON")
|
Set(configure_options "${configure_options};-DFAST_BUILD=ON")
|
||||||
Set(configure_options "${configure_options};-DCOTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES=-j$ENV{number_of_processors}")
|
Set(configure_options "${configure_options};-DCOTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES=-j$ENV{number_of_processors}")
|
||||||
|
Set(configure_options "${configure_options};-DBoost_NO_BOOST_CMAKE=ON")
|
||||||
|
|
||||||
Set(EXTRA_FLAGS $ENV{EXTRA_FLAGS})
|
Set(EXTRA_FLAGS $ENV{EXTRA_FLAGS})
|
||||||
If(EXTRA_FLAGS)
|
If(EXTRA_FLAGS)
|
||||||
|
11
Jenkinsfile
vendored
11
Jenkinsfile
vendored
@@ -8,11 +8,15 @@ def jobMatrix(String prefix, List specs, Closure callback) {
|
|||||||
def nodes = [:]
|
def nodes = [:]
|
||||||
for (spec in specs) {
|
for (spec in specs) {
|
||||||
def label = specToLabel(spec)
|
def label = specToLabel(spec)
|
||||||
|
def node_tag = label
|
||||||
|
if (spec.os =~ /macOS/) {
|
||||||
|
node_tag = spec.os
|
||||||
|
}
|
||||||
def fairsoft = spec.fairsoft
|
def fairsoft = spec.fairsoft
|
||||||
def os = spec.os
|
def os = spec.os
|
||||||
def compiler = spec.compiler
|
def compiler = spec.compiler
|
||||||
nodes["${prefix}/${label}"] = {
|
nodes["${prefix}/${label}"] = {
|
||||||
node(label) {
|
node(node_tag) {
|
||||||
githubNotify(context: "${prefix}/${label}", description: 'Building ...', status: 'PENDING')
|
githubNotify(context: "${prefix}/${label}", description: 'Building ...', status: 'PENDING')
|
||||||
try {
|
try {
|
||||||
deleteDir()
|
deleteDir()
|
||||||
@@ -29,7 +33,7 @@ def jobMatrix(String prefix, List specs, Closure callback) {
|
|||||||
echo "module load compiler/gcc/9.1.0" >> Dart.cfg
|
echo "module load compiler/gcc/9.1.0" >> Dart.cfg
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
if (os =~ /MacOS/) {
|
if (os =~ /[Mm]acOS/) {
|
||||||
sh "echo \"export EXTRA_FLAGS='-DCMAKE_CXX_COMPILER=clang++'\" >> Dart.cfg"
|
sh "echo \"export EXTRA_FLAGS='-DCMAKE_CXX_COMPILER=clang++'\" >> Dart.cfg"
|
||||||
} else {
|
} else {
|
||||||
sh "echo \"export EXTRA_FLAGS='-DCMAKE_CXX_COMPILER=g++'\" >> Dart.cfg"
|
sh "echo \"export EXTRA_FLAGS='-DCMAKE_CXX_COMPILER=g++'\" >> Dart.cfg"
|
||||||
@@ -71,8 +75,7 @@ pipeline{
|
|||||||
script {
|
script {
|
||||||
def build_jobs = jobMatrix('build', [
|
def build_jobs = jobMatrix('build', [
|
||||||
[os: 'Debian8', arch: 'x86_64', compiler: 'gcc9.1.0', fairsoft: 'fairmq_dev'],
|
[os: 'Debian8', arch: 'x86_64', compiler: 'gcc9.1.0', fairsoft: 'fairmq_dev'],
|
||||||
[os: 'MacOS10.13', arch: 'x86_64', compiler: 'AppleLLVM10.0.0', fairsoft: 'fairmq_dev'],
|
[os: 'macOS10.15', arch: 'x86_64', compiler: 'AppleLLVM11.0.3', fairsoft: 'fairmq_dev'],
|
||||||
[os: 'MacOS10.14', arch: 'x86_64', compiler: 'AppleLLVM10.0.0', fairsoft: 'fairmq_dev'],
|
|
||||||
]) { spec, label ->
|
]) { spec, label ->
|
||||||
sh './Dart.sh alfa_ci Dart.cfg'
|
sh './Dart.sh alfa_ci Dart.cfg'
|
||||||
}
|
}
|
||||||
|
10
README.md
10
README.md
@@ -21,7 +21,7 @@ FairMQ is designed to help implementing large-scale data processing workflows ne
|
|||||||
The core of FairMQ provides an abstract asynchronous message passing API with scalability protocols
|
The core of FairMQ provides an abstract asynchronous message passing API with scalability protocols
|
||||||
inspired by [ZeroMQ](https://github.com/zeromq/libzmq) (e.g. PUSH/PULL, PUB/SUB).
|
inspired by [ZeroMQ](https://github.com/zeromq/libzmq) (e.g. PUSH/PULL, PUB/SUB).
|
||||||
FairMQ provides multiple implementations for its API (so-called "transports",
|
FairMQ provides multiple implementations for its API (so-called "transports",
|
||||||
e.g. `zeromq`, `shmem`, `nanomsg`, and `ofi` (in development)) to cover a variety of use cases
|
e.g. `zeromq`, `shmem` and `ofi` (in development)) to cover a variety of use cases
|
||||||
(e.g. inter-thread, inter-process, inter-node communication) and machines (e.g. Ethernet, Infiniband).
|
(e.g. inter-thread, inter-process, inter-node communication) and machines (e.g. Ethernet, Infiniband).
|
||||||
In addition to this core functionality FairMQ provides a framework for creating "devices" - actors which
|
In addition to this core functionality FairMQ provides a framework for creating "devices" - actors which
|
||||||
are communicating through message passing. FairMQ does not only allow the user to use different transport but also to mix them; i.e: A Device can communicate using different transport on different channels at the same time. Device execution is modelled as a simple state machine that
|
are communicating through message passing. FairMQ does not only allow the user to use different transport but also to mix them; i.e: A Device can communicate using different transport on different channels at the same time. Device execution is modelled as a simple state machine that
|
||||||
@@ -47,7 +47,7 @@ cmake --build fairmq_build --target install
|
|||||||
|
|
||||||
Please consult the [manpages of your CMake version](https://cmake.org/cmake/help/latest/manual/cmake.1.html) for more options.
|
Please consult the [manpages of your CMake version](https://cmake.org/cmake/help/latest/manual/cmake.1.html) for more options.
|
||||||
|
|
||||||
If dependencies are not installed in standard system directories, you can hint the installation location via `-DCMAKE_PREFIX_PATH=...` or per dependency via `-D{DEPENDENCY}_ROOT=...`. `{DEPENDENCY}` can be `GTEST`, `BOOST`, `FAIRLOGGER`, `ZEROMQ`, `MSGPACK`, `NANOMSG`, `OFI`, `PMIX`, `ASIO`, `ASIOFI` or `DDS` (`*_ROOT` variables can also be environment variables).
|
If dependencies are not installed in standard system directories, you can hint the installation location via `-DCMAKE_PREFIX_PATH=...` or per dependency via `-D{DEPENDENCY}_ROOT=...`. `{DEPENDENCY}` can be `GTEST`, `BOOST`, `FAIRLOGGER`, `ZEROMQ`, `OFI`, `PMIX`, `ASIO`, `ASIOFI` or `DDS` (`*_ROOT` variables can also be environment variables).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ If your project shares a dependency with FairMQ or if you want to omit a certain
|
|||||||
Optionally, you can require certain FairMQ package components and a minimum version:
|
Optionally, you can require certain FairMQ package components and a minimum version:
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
find_package(FairMQ 1.1.0 COMPONENTS nanomsg_transport dds_plugin)
|
find_package(FairMQ 1.1.0 COMPONENTS dds_plugin)
|
||||||
```
|
```
|
||||||
|
|
||||||
When building FairMQ, CMake will print a summary table of all available package components.
|
When building FairMQ, CMake will print a summary table of all available package components.
|
||||||
@@ -101,8 +101,6 @@ When building FairMQ, CMake will print a summary table of all available package
|
|||||||
* [Doxygen](http://www.doxygen.org/)
|
* [Doxygen](http://www.doxygen.org/)
|
||||||
* [FairLogger](https://github.com/FairRootGroup/FairLogger)
|
* [FairLogger](https://github.com/FairRootGroup/FairLogger)
|
||||||
* [GTest](https://github.com/google/googletest) (optionally bundled)
|
* [GTest](https://github.com/google/googletest) (optionally bundled)
|
||||||
* [Msgpack](https://msgpack.org/index.html)
|
|
||||||
* [nanomsg](http://nanomsg.org/)
|
|
||||||
* [PMIx](https://pmix.org/)
|
* [PMIx](https://pmix.org/)
|
||||||
* [ZeroMQ](http://zeromq.org/)
|
* [ZeroMQ](http://zeromq.org/)
|
||||||
|
|
||||||
@@ -117,7 +115,6 @@ On command line:
|
|||||||
* `-DDISABLE_COLOR=ON` disables coloured console output.
|
* `-DDISABLE_COLOR=ON` disables coloured console output.
|
||||||
* `-DBUILD_TESTING=OFF` disables building of tests.
|
* `-DBUILD_TESTING=OFF` disables building of tests.
|
||||||
* `-DBUILD_EXAMPLES=OFF` disables building of examples.
|
* `-DBUILD_EXAMPLES=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_OFI_TRANSPORT=ON` enables building of the experimental OFI transport.
|
||||||
* `-DBUILD_DDS_PLUGIN=ON` enables building of the DDS plugin.
|
* `-DBUILD_DDS_PLUGIN=ON` enables building of the DDS plugin.
|
||||||
* `-DBUILD_PMIX_PLUGIN=ON` enables building of the PMIx plugin.
|
* `-DBUILD_PMIX_PLUGIN=ON` enables building of the PMIx plugin.
|
||||||
@@ -182,4 +179,3 @@ After the `find_package(FairMQ)` call the following CMake variables are defined:
|
|||||||
1. [DDS](docs/Plugins.md#731-dds)
|
1. [DDS](docs/Plugins.md#731-dds)
|
||||||
2. [PMIx](docs/Plugins.md#732-pmix)
|
2. [PMIx](docs/Plugins.md#732-pmix)
|
||||||
8. [Controller SDK](docs/SDK.md)
|
8. [Controller SDK](docs/SDK.md)
|
||||||
|
|
||||||
|
@@ -143,15 +143,17 @@ macro(set_fairmq_defaults)
|
|||||||
set(PROJECT_EXPORT_SET ${PROJECT_NAME}Targets)
|
set(PROJECT_EXPORT_SET ${PROJECT_NAME}Targets)
|
||||||
|
|
||||||
# Configure build types
|
# Configure build types
|
||||||
set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" "RelWithDebInfo" "Nightly" "Profile" "Experimental" "AdressSan" "ThreadSan")
|
set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" "RelWithDebInfo" "Nightly" "Profile" "Experimental" "AddressSan" "ThreadSan")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wshadow -Wall -Wextra")
|
set(_warnings "-Wshadow -Wall -Wextra -Wpedantic")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g ${_warnings}")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -Wshadow -Wall -Wextra -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ${_warnings} -DNDEBUG")
|
||||||
set(CMAKE_CXX_FLAGS_NIGHTLY "-O2 -g -Wshadow -Wall -Wextra")
|
set(CMAKE_CXX_FLAGS_NIGHTLY "-O2 -g ${_warnings}")
|
||||||
set(CMAKE_CXX_FLAGS_PROFILE "-g3 -Wshadow -Wall -Wextra -fno-inline -ftest-coverage -fprofile-arcs")
|
set(CMAKE_CXX_FLAGS_PROFILE "-g3 ${_warnings} -fno-inline -ftest-coverage -fprofile-arcs")
|
||||||
set(CMAKE_CXX_FLAGS_EXPERIMENTAL "-O2 -g -Wshadow -Wall -Wextra -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_EXPERIMENTAL "-O2 -g ${_warnings} -DNDEBUG")
|
||||||
set(CMAKE_CXX_FLAGS_ADRESSSAN "-O2 -g -Wshadow -Wall -Wextra -fsanitize=address -fno-omit-frame-pointer")
|
set(CMAKE_CXX_FLAGS_ADDRESSSAN "-O2 -g ${_warnings} -fsanitize=address -fno-omit-frame-pointer")
|
||||||
set(CMAKE_CXX_FLAGS_THREADSAN "-O2 -g -Wshadow -Wall -Wextra -fsanitize=thread")
|
set(CMAKE_CXX_FLAGS_THREADSAN "-O2 -g ${_warnings} -fsanitize=thread")
|
||||||
|
unset(_warnings)
|
||||||
|
|
||||||
if(CMAKE_GENERATOR STREQUAL "Ninja" AND
|
if(CMAKE_GENERATOR STREQUAL "Ninja" AND
|
||||||
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) OR
|
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) OR
|
||||||
@@ -496,6 +498,8 @@ function(build_bundled package bundle)
|
|||||||
set(${package}_BUILD_INCLUDE_DIR ${${package}_SOURCE_DIR}/asio/include CACHE PATH "Bundled ${package} build-interface include dir")
|
set(${package}_BUILD_INCLUDE_DIR ${${package}_SOURCE_DIR}/asio/include CACHE PATH "Bundled ${package} build-interface include dir")
|
||||||
set(${package}_INSTALL_INCLUDE_DIR ${PROJECT_INSTALL_INCDIR}/bundled CACHE PATH "Bundled ${package} install-interface include dir")
|
set(${package}_INSTALL_INCLUDE_DIR ${PROJECT_INSTALL_INCDIR}/bundled CACHE PATH "Bundled ${package} install-interface include dir")
|
||||||
set(${package}_ROOT ${${package}_SOURCE_DIR}/asio)
|
set(${package}_ROOT ${${package}_SOURCE_DIR}/asio)
|
||||||
|
elseif(${package} STREQUAL PicoSHA2)
|
||||||
|
set(${package}_ROOT ${${package}_SOURCE_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
string(TOUPPER ${package} package_upper)
|
string(TOUPPER ${package} package_upper)
|
||||||
@@ -522,7 +526,7 @@ macro(fairmq_build_option option description)
|
|||||||
if(${__requires_condition__})
|
if(${__requires_condition__})
|
||||||
else()
|
else()
|
||||||
if(${option})
|
if(${option})
|
||||||
message(WARNING "Cannot enable build option ${option}, depending option is not set: ${__requires_condition__}")
|
message(FATAL_ERROR "Cannot enable build option ${option}, depending option is not set: ${__requires_condition__}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@@ -6,28 +6,35 @@
|
|||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
# The "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix" part in all
|
||||||
|
# the PATH_SUFFIXES is here to be able to find Debian's
|
||||||
|
# libpmix-dev package. It installs everything below
|
||||||
|
# /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix
|
||||||
|
|
||||||
|
|
||||||
find_path(PMIx_INCLUDE_DIR
|
find_path(PMIx_INCLUDE_DIR
|
||||||
NAMES pmix.h
|
NAMES pmix.h
|
||||||
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
||||||
PATH_SUFFIXES include
|
PATH_SUFFIXES include lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix/include
|
||||||
)
|
)
|
||||||
|
|
||||||
find_path(PMIx_LIBRARY_DIR
|
find_path(PMIx_LIBRARY_DIR
|
||||||
NAMES libpmix.dylib libpmix.so
|
NAMES libpmix.dylib libpmix.so
|
||||||
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
||||||
PATH_SUFFIXES lib lib64
|
PATH_SUFFIXES lib lib64 lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix/lib
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(PMIx_LIBRARY_SHARED
|
find_library(PMIx_LIBRARY_SHARED
|
||||||
NAMES libpmix.dylib libpmix.so
|
NAMES libpmix.dylib libpmix.so
|
||||||
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
||||||
PATH_SUFFIXES lib lib64
|
PATH_SUFFIXES lib lib64 lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix/lib
|
||||||
)
|
)
|
||||||
|
|
||||||
find_file(PMIx_VERSION_FILE
|
find_file(PMIx_VERSION_FILE
|
||||||
NAMES pmix_version.h
|
NAMES pmix_version.h
|
||||||
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
||||||
PATH_SUFFIXES include
|
PATH_SUFFIXES include lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix/include
|
||||||
)
|
)
|
||||||
|
|
||||||
file(READ "${PMIx_VERSION_FILE}" __version_raw)
|
file(READ "${PMIx_VERSION_FILE}" __version_raw)
|
||||||
|
21
cmake/FindPicoSHA2.cmake
Normal file
21
cmake/FindPicoSHA2.cmake
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
################################################################################
|
||||||
|
# Copyright (C) 2020 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" #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
find_path(PicoSHA2_INCLUDE_DIR NAMES picosha2.h)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(PicoSHA2
|
||||||
|
REQUIRED_VARS PicoSHA2_INCLUDE_DIR
|
||||||
|
)
|
||||||
|
|
||||||
|
if(PicoSHA2_FOUND)
|
||||||
|
add_library(PicoSHA2 INTERFACE IMPORTED)
|
||||||
|
set_target_properties(PicoSHA2 PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${PicoSHA2_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
endif()
|
@@ -18,7 +18,7 @@ Topology configuration is currently happening via setup scripts. This is very ru
|
|||||||
|
|
||||||
## 1.2 Communication Patterns
|
## 1.2 Communication Patterns
|
||||||
|
|
||||||
FairMQ devices communicate via the communication patterns offered by ZeroMQ (or nanomsg): PUSH-PULL, PUB-SUB, REQ-REP, PAIR, [more info here](http://api.zeromq.org/4-0:zmq-socket). Each transport may provide further patterns.
|
FairMQ devices communicate via the communication patterns offered by ZeroMQ: PUSH-PULL, PUB-SUB, REQ-REP, PAIR, [more info here](http://api.zeromq.org/4-0:zmq-socket). Each transport may provide further patterns.
|
||||||
|
|
||||||
## 1.3 State Machine
|
## 1.3 State Machine
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# 2. Transport Interface
|
# 2. Transport Interface
|
||||||
|
|
||||||
The communication layer is available through the transport interface. Three interface implementations are currently available. Main implementation uses the [ZeroMQ](http://zeromq.org) library. Alternative implementation relies on the [nanomsg](http://nanomsg.org) library. Third transport implementation is using shared memory via boost::interprocess & ZeroMQ combination.
|
The communication layer is available through the transport interface. Three interface implementations are currently available. Main implementation uses the [ZeroMQ](http://zeromq.org) library. Second transport implementation is using shared memory via boost::interprocess & ZeroMQ combination.
|
||||||
|
|
||||||
Here is an overview to give an idea how the interface is implemented:
|
Here is an overview to give an idea how the interface is implemented:
|
||||||
|
|
||||||
@@ -10,20 +10,20 @@ Here is an overview to give an idea how the interface is implemented:
|
|||||||
|
|
||||||
Currently, the transports have been tested to work with these communication patterns:
|
Currently, the transports have been tested to work with these communication patterns:
|
||||||
|
|
||||||
| | zeromq | nanomsg | shmem |
|
| | zeromq | shmem |
|
||||||
| ------------- |--------| ------- | ----- |
|
| ------------- |--------| ----- |
|
||||||
| PAIR | yes | yes | yes |
|
| PAIR | yes | yes |
|
||||||
| PUSH/PULL | yes | yes | yes |
|
| PUSH/PULL | yes | yes |
|
||||||
| PUB/SUB | yes | yes | no |
|
| PUB/SUB | yes | no |
|
||||||
| REQ/REP | yes | yes | yes |
|
| REQ/REP | yes | yes |
|
||||||
|
|
||||||
The next table shows the supported address types for each transport implementation:
|
The next table shows the supported address types for each transport implementation:
|
||||||
|
|
||||||
| | zeromq | nanomsg | shmem | comment |
|
| | zeromq | shmem | comment |
|
||||||
| ----------- | ------ | ------- | ----- | --------------------------------------------- |
|
| ----------- | ------ | ----- | --------------------------------------------- |
|
||||||
| `inproc://` | yes | yes | yes | in process: useful for unit testing |
|
| `inproc://` | yes | yes | in process: useful for unit testing |
|
||||||
| `ipc://` | yes | yes | yes | inter process comm: useful on single machine |
|
| `ipc://` | yes | yes | inter process comm: useful on single machine |
|
||||||
| `tcp://` | yes | yes | yes | useful for any communication, local or remote |
|
| `tcp://` | yes | yes | useful for any communication, local or remote |
|
||||||
|
|
||||||
## 2.1 Message
|
## 2.1 Message
|
||||||
|
|
||||||
|
@@ -34,11 +34,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-1-1.sh.in ${CMAKE_CURRENT_BIN
|
|||||||
add_test(NAME Example.1-1.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh zeromq)
|
add_test(NAME Example.1-1.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh zeromq)
|
||||||
set_tests_properties(Example.1-1.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
set_tests_properties(Example.1-1.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
add_test(NAME Example.1-1.nanomsg COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh nanomsg)
|
|
||||||
set_tests_properties(Example.1-1.nanomsg PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_test(NAME Example.1-1.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh shmem)
|
add_test(NAME Example.1-1.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh shmem)
|
||||||
set_tests_properties(Example.1-1.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
set_tests_properties(Example.1-1.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
||||||
|
|
||||||
|
@@ -17,8 +17,7 @@ Sampler::Sampler()
|
|||||||
: fText()
|
: fText()
|
||||||
, fMaxIterations(0)
|
, fMaxIterations(0)
|
||||||
, fNumIterations(0)
|
, fNumIterations(0)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
void Sampler::InitTask()
|
void Sampler::InitTask()
|
||||||
{
|
{
|
||||||
@@ -32,25 +31,22 @@ bool Sampler::ConditionalRun()
|
|||||||
// create a copy of the data with new(), that will be deleted after the transfer is complete
|
// create a copy of the data with new(), that will be deleted after the transfer is complete
|
||||||
string* text = new string(fText);
|
string* text = new string(fText);
|
||||||
|
|
||||||
// create message object with a pointer to the data buffer,
|
// create message object with a pointer to the data buffer, its size,
|
||||||
// its size,
|
|
||||||
// custom deletion function (called when transfer is done),
|
// custom deletion function (called when transfer is done),
|
||||||
// and pointer to the object managing the data buffer
|
// and pointer to the object managing the data buffer
|
||||||
FairMQMessagePtr msg(NewMessage(const_cast<char*>(text->c_str()),
|
FairMQMessagePtr msg(NewMessage(
|
||||||
text->length(),
|
const_cast<char*>(text->c_str()),
|
||||||
[](void* /*data*/, void* object) { delete static_cast<string*>(object); },
|
text->length(),
|
||||||
text));
|
[](void* /*data*/, void* object) { delete static_cast<string*>(object); },
|
||||||
|
text));
|
||||||
|
|
||||||
LOG(info) << "Sending \"" << fText << "\"";
|
LOG(info) << "Sending \"" << fText << "\"";
|
||||||
|
|
||||||
// in case of error or transfer interruption, return false to go to IDLE state
|
// in case of error or transfer interruption, return false to go to the Ready state
|
||||||
// successfull transfer will return number of bytes transfered (can be 0 if sending an empty message).
|
// successfull transfer will return number of bytes transfered (can be 0 if sending an empty message).
|
||||||
if (Send(msg, "data") < 0)
|
if (Send(msg, "data") < 0) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
||||||
else if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations)
|
|
||||||
{
|
|
||||||
LOG(info) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
|
LOG(info) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -58,8 +54,6 @@ bool Sampler::ConditionalRun()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sampler::~Sampler()
|
Sampler::~Sampler() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace example_1_1
|
} // namespace example_1_1
|
||||||
|
@@ -33,23 +33,22 @@ void Sink::InitTask()
|
|||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
}
|
}
|
||||||
|
|
||||||
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
|
// handler is called whenever a message arrives on "data", with a reference to the message and a
|
||||||
|
// sub-channel index (here 0)
|
||||||
bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received: \"" << string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
LOG(info) << "Received: \"" << string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||||
|
|
||||||
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations)
|
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
||||||
{
|
|
||||||
LOG(info) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
|
LOG(info) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if want to be called again (otherwise return false go to IDLE state)
|
// return true if you want the handler to be called again (otherwise return false go to the
|
||||||
|
// Ready state)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sink::~Sink()
|
Sink::~Sink() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace example_1_1
|
} // namespace example_1_1
|
||||||
|
@@ -42,11 +42,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-1-n-1.sh.in ${CMAKE_CURRENT_B
|
|||||||
add_test(NAME Example.1-n-1.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh zeromq)
|
add_test(NAME Example.1-n-1.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh zeromq)
|
||||||
set_tests_properties(Example.1-n-1.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
set_tests_properties(Example.1-n-1.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
add_test(NAME Example.1-n-1.nanomsg COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh nanomsg)
|
|
||||||
set_tests_properties(Example.1-n-1.nanomsg PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_test(NAME Example.1-n-1.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh shmem)
|
add_test(NAME Example.1-n-1.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh shmem)
|
||||||
set_tests_properties(Example.1-n-1.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
set_tests_properties(Example.1-n-1.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
||||||
|
|
||||||
|
@@ -13,9 +13,9 @@ add_subdirectory(copypush)
|
|||||||
add_subdirectory(dds)
|
add_subdirectory(dds)
|
||||||
add_subdirectory(multipart)
|
add_subdirectory(multipart)
|
||||||
add_subdirectory(multiple-channels)
|
add_subdirectory(multiple-channels)
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
add_subdirectory(multiple-transports)
|
||||||
add_subdirectory(multiple-transports)
|
add_subdirectory(n-m)
|
||||||
endif()
|
add_subdirectory(qc)
|
||||||
add_subdirectory(readout)
|
add_subdirectory(readout)
|
||||||
add_subdirectory(region)
|
add_subdirectory(region)
|
||||||
add_subdirectory(req-rep)
|
add_subdirectory(req-rep)
|
||||||
|
@@ -6,41 +6,50 @@ Set of FairMQ examples. More examples that combine FairMQ with FairRoot can be f
|
|||||||
|
|
||||||
A simple topology of two devices - **Sampler** and **Sink**. **Sampler** sends data to **Sink** with the **PUSH-PULL** pattern.
|
A simple topology of two devices - **Sampler** and **Sink**. **Sampler** sends data to **Sink** with the **PUSH-PULL** pattern.
|
||||||
|
|
||||||
|
|
||||||
## 1-n-1
|
## 1-n-1
|
||||||
|
|
||||||
A simple topology of three device types - **Sampler**, **Processor** and **Sink**. **Sampler** sends data to one or more **Processor**s, who modify the data and send it to one **Sink**. Transport with the **PUSH-PULL** pattern. The example also shows the configuration via JSON files, as oposed to `--channel-config` that is used by other examples.
|
A simple topology of three device types - **Sampler**, **Processor** and **Sink**. **Sampler** sends data to one or more **Processor**s, who modify the data and send it to one **Sink**. Transport with the **PUSH-PULL** pattern. The example also shows the configuration via JSON files, as oposed to `--channel-config` that is used by other examples.
|
||||||
|
|
||||||
|
## Built-in devices
|
||||||
|
|
||||||
## DDS
|
Usage of generic devies provided with FairMQ.
|
||||||
|
|
||||||
This example demonstrates usage of the Dynamic Deployment System ([DDS](http://dds.gsi.de/)) to dynamically deploy and configure a topology of devices. The topology is similar to those of Example 2, but now it can be easily distributed on different computing nodes without the need for manual reconfiguration of the devices.
|
|
||||||
|
|
||||||
|
|
||||||
## Copy & Push
|
## Copy & Push
|
||||||
|
|
||||||
A topology consisting of one **Sampler** and two **Sink**s. The **Sampler** uses the `Copy` method to send the same data to both sinks with the **PUSH-PULL** pattern. In countrary to the **PUB-SUB** pattern, this ensures that all receivers are connected and no data is lost, but requires additional channels to be configured.
|
A topology consisting of one **Sampler** and two **Sink**s. The **Sampler** uses the `Copy` method to send the same data to both sinks with the **PUSH-PULL** pattern. In countrary to the **PUB-SUB** pattern, this ensures that all receivers are connected and no data is lost, but requires additional channels to be configured.
|
||||||
|
|
||||||
|
## DDS
|
||||||
|
|
||||||
## Request & Reply
|
This example demonstrates usage of the Dynamic Deployment System ([DDS](http://dds.gsi.de/)) to dynamically deploy and configure a topology of devices. The topology is similar to those of Example 2, but now it can be easily distributed on different computing nodes without the need for manual reconfiguration of the devices.
|
||||||
|
|
||||||
This topology contains two devices that communicate with each other via the **REQ-REP** pettern. Bidirectional communication via a single socket.
|
## Multipart
|
||||||
|
|
||||||
|
This example shows how to send a multipart message from one device to the other. (two parts message parts - header and body).
|
||||||
|
|
||||||
## Multiple Channels
|
## Multiple Channels
|
||||||
|
|
||||||
This example demonstrates how to work with multiple channels and multiplex between them.
|
This example demonstrates how to work with multiple channels and multiplex between them.
|
||||||
|
|
||||||
|
## Multiple Transports
|
||||||
|
|
||||||
## Sending Multipart messages
|
This examples shows how to combine different channel transports (zeromq/shmem) inside of one device and/or topology.
|
||||||
|
|
||||||
This example shows how to send a multipart message from one device to the other. (two parts message parts - header and body).
|
## n-m
|
||||||
|
|
||||||
|
A topology consisting of three layers of devices: synchronizer -> n * senders -> m * receivers.
|
||||||
|
|
||||||
## Multiple Transports example
|
## QC
|
||||||
|
|
||||||
This examples shows how to combine different channel transports (zeromq/nanomsg/shmem) inside of one device and/or topology.
|
A topology consisting of 4 devices - Sampler, QCDispatcher, QCTask and Sink. The data flows from Sampler through QCDispatcher to Sink. On demand - by setting the corresponding configuration property - the QCDispatcher device will duplicate the data to the QCTask device. The property is set by the topology controller, in this example this is the `fairmq-dds-command-ui` utility.
|
||||||
|
|
||||||
## Region example
|
## Readout
|
||||||
|
|
||||||
|
Two example topologies of setups to be distributed to two kinds of nodes - detector readout node and processing node. Detector readout node contains readout process, data builder and data sender (and optionally an additional processor), while processing node contains data receiver devices. communication within readout nodes is done via unmanaged region through shared memory transport.
|
||||||
|
|
||||||
|
## Region
|
||||||
|
|
||||||
This example demonstrates the use of a more advanced feature - UnmanagedRegion, that can be used to create a buffer through one of FairMQ transports. The contents of this buffer are managed by the user, who can also create messages out of sub-buffers of the created buffer. Such feature can be interesting in environments that have special requirements by the hardware that writes the data, to keep the transfer efficient (e.g. shared memory).
|
This example demonstrates the use of a more advanced feature - UnmanagedRegion, that can be used to create a buffer through one of FairMQ transports. The contents of this buffer are managed by the user, who can also create messages out of sub-buffers of the created buffer. Such feature can be interesting in environments that have special requirements by the hardware that writes the data, to keep the transfer efficient (e.g. shared memory).
|
||||||
|
|
||||||
|
## Request & Reply
|
||||||
|
|
||||||
|
This topology contains two devices that communicate with each other via the **REQ-REP** pettern. Bidirectional communication via a single socket.
|
||||||
|
@@ -17,22 +17,12 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-builtin-devices.sh.in ${CMAKE
|
|||||||
add_test(NAME Example.BuiltinDevices.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh zeromq)
|
add_test(NAME Example.BuiltinDevices.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh zeromq)
|
||||||
set_tests_properties(Example.BuiltinDevices.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
set_tests_properties(Example.BuiltinDevices.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
add_test(NAME Example.BuiltinDevices.nanomsg COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh nanomsg)
|
|
||||||
set_tests_properties(Example.BuiltinDevices.nanomsg PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_test(NAME Example.BuiltinDevices.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh shmem)
|
add_test(NAME Example.BuiltinDevices.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh shmem)
|
||||||
set_tests_properties(Example.BuiltinDevices.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
set_tests_properties(Example.BuiltinDevices.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
||||||
|
|
||||||
add_test(NAME Example.BuiltinDevices.multipart.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh zeromq true 2)
|
add_test(NAME Example.BuiltinDevices.multipart.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh zeromq true 2)
|
||||||
set_tests_properties(Example.BuiltinDevices.multipart.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
set_tests_properties(Example.BuiltinDevices.multipart.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
add_test(NAME Example.BuiltinDevices.multipart.nanomsg COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh nanomsg true 2)
|
|
||||||
set_tests_properties(Example.BuiltinDevices.multipart.nanomsg PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_test(NAME Example.BuiltinDevices.multipart.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh shmem true 2)
|
add_test(NAME Example.BuiltinDevices.multipart.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh shmem true 2)
|
||||||
set_tests_properties(Example.BuiltinDevices.multipart.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
set_tests_properties(Example.BuiltinDevices.multipart.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
||||||
|
|
||||||
|
@@ -35,11 +35,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-copypush.sh.in ${CMAKE_CURREN
|
|||||||
add_test(NAME Example.CopyPush.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh zeromq)
|
add_test(NAME Example.CopyPush.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh zeromq)
|
||||||
set_tests_properties(Example.CopyPush.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message: ")
|
set_tests_properties(Example.CopyPush.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message: ")
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
add_test(NAME Example.CopyPush.nanomsg COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh nanomsg)
|
|
||||||
set_tests_properties(Example.CopyPush.nanomsg PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message: ")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_test(NAME Example.CopyPush.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh shmem)
|
add_test(NAME Example.CopyPush.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh shmem)
|
||||||
set_tests_properties(Example.CopyPush.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message: ")
|
set_tests_properties(Example.CopyPush.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message: ")
|
||||||
|
|
||||||
|
@@ -7,12 +7,12 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
add_library(ExampleDDSLib STATIC
|
add_library(ExampleDDSLib STATIC
|
||||||
"Sampler.cxx"
|
"Sampler.cxx"
|
||||||
"Sampler.h"
|
"Sampler.h"
|
||||||
"Processor.cxx"
|
"Processor.cxx"
|
||||||
"Processor.h"
|
"Processor.h"
|
||||||
"Sink.cxx"
|
"Sink.cxx"
|
||||||
"Sink.h"
|
"Sink.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(ExampleDDSLib PUBLIC FairMQ)
|
target_link_libraries(ExampleDDSLib PUBLIC FairMQ)
|
||||||
@@ -28,7 +28,8 @@ 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)
|
add_custom_target(ExampleDDS DEPENDS fairmq-ex-dds-sampler fairmq-ex-dds-processor fairmq-ex-dds-sink)
|
||||||
|
|
||||||
set(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/fairmq/plugins/DDS)
|
list(JOIN Boost_LIBRARY_DIRS ":" LIB_DIR)
|
||||||
|
set(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/fairmq/sdk)
|
||||||
set(DATA_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
set(DATA_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-dds-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology.xml @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-dds-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology.xml @ONLY)
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-dds-topology-infinite.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology-infinite.xml @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-dds-topology-infinite.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology-infinite.xml @ONLY)
|
||||||
@@ -38,23 +39,24 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-dds.sh.in ${CMAKE_CUR
|
|||||||
|
|
||||||
# test
|
# test
|
||||||
if(DDS_FOUND)
|
if(DDS_FOUND)
|
||||||
add_test(NAME Example.DDS.localhost COMMAND ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-dds.sh localhost)
|
add_test(NAME Example.DDS.localhost COMMAND ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-dds.sh localhost)
|
||||||
set_tests_properties(Example.DDS.localhost PROPERTIES
|
set_tests_properties(Example.DDS.localhost PROPERTIES
|
||||||
TIMEOUT 15
|
TIMEOUT 15
|
||||||
|
RUN_SERIAL true
|
||||||
PASS_REGULAR_EXPRESSION "Example successful"
|
PASS_REGULAR_EXPRESSION "Example successful"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# install
|
# install
|
||||||
|
|
||||||
install(
|
install(
|
||||||
TARGETS
|
TARGETS
|
||||||
fairmq-ex-dds-sampler
|
fairmq-ex-dds-sampler
|
||||||
fairmq-ex-dds-processor
|
fairmq-ex-dds-processor
|
||||||
fairmq-ex-dds-sink
|
fairmq-ex-dds-sink
|
||||||
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# configure run script with different executable paths for build and for install directories
|
# configure run script with different executable paths for build and for install directories
|
||||||
@@ -66,30 +68,30 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-ex-dds-env.sh ${CMAKE_CURRENT_
|
|||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-dds.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-dds.sh_install @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-dds.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-dds.sh_install @ONLY)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology.xml_install
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology.xml_install
|
||||||
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
||||||
RENAME ex-dds-topology.xml
|
RENAME ex-dds-topology.xml
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology-infinite.xml_install
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology-infinite.xml_install
|
||||||
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
||||||
RENAME ex-dds-topology-infinite.xml
|
RENAME ex-dds-topology-infinite.xml
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-hosts.cfg
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-hosts.cfg
|
||||||
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-ex-dds-env.sh_install
|
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-ex-dds-env.sh_install
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
RENAME fairmq-ex-dds-env.sh
|
RENAME fairmq-ex-dds-env.sh
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-dds.sh_install
|
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-dds.sh_install
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
RENAME fairmq-start-ex-dds.sh
|
RENAME fairmq-start-ex-dds.sh
|
||||||
)
|
)
|
||||||
|
@@ -9,3 +9,8 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
export PATH=@BIN_DIR@:$PATH
|
export PATH=@BIN_DIR@:$PATH
|
||||||
|
|
||||||
|
OS=$(uname -s 2>&1)
|
||||||
|
if [ "$OS" == "Darwin" ]; then
|
||||||
|
export DYLD_LIBRARY_PATH=@LIB_DIR@:$DYLD_LIBRARY_PATH
|
||||||
|
fi
|
||||||
|
@@ -39,12 +39,12 @@ fi
|
|||||||
echo "...waiting for ${requiredNofSlots} idle slots..."
|
echo "...waiting for ${requiredNofSlots} idle slots..."
|
||||||
dds-info --idle-count --wait ${requiredNofSlots}
|
dds-info --idle-count --wait ${requiredNofSlots}
|
||||||
|
|
||||||
topologyFile=@DATA_DIR@/ex-dds-topology.xml
|
export FAIRMQ_DDS_TOPO_FILE=@DATA_DIR@/ex-dds-topology.xml
|
||||||
echo "TOPOLOGY FILE: ${topologyFile}"
|
echo "TOPOLOGY FILE: ${FAIRMQ_DDS_TOPO_FILE}"
|
||||||
echo "TOPOLOGY NAME: $(dds-topology --disable-validation --topology-name ${topologyFile})"
|
echo "TOPOLOGY NAME: $(dds-topology --disable-validation --topology-name ${FAIRMQ_DDS_TOPO_FILE})"
|
||||||
|
|
||||||
dds-info --active-topology
|
dds-info --active-topology
|
||||||
dds-topology --activate ${topologyFile}
|
dds-topology --activate ${FAIRMQ_DDS_TOPO_FILE}
|
||||||
dds-info --active-topology
|
dds-info --active-topology
|
||||||
echo "...waiting for ${requiredNofSlots} executing slots..."
|
echo "...waiting for ${requiredNofSlots} executing slots..."
|
||||||
dds-info --executing-count --wait ${requiredNofSlots}
|
dds-info --executing-count --wait ${requiredNofSlots}
|
||||||
@@ -52,21 +52,20 @@ dds-info --executing-count --wait ${requiredNofSlots}
|
|||||||
echo "------------------------"
|
echo "------------------------"
|
||||||
echo "...waiting for Topology to finish..."
|
echo "...waiting for Topology to finish..."
|
||||||
# TODO Retrieve number of devices from DDS topology API instead of having the user pass it explicitely
|
# TODO Retrieve number of devices from DDS topology API instead of having the user pass it explicitely
|
||||||
fairmq-dds-command-ui -w "IDLE" -n ${requiredNofSlots}
|
fairmq-dds-command-ui -w "IDLE"
|
||||||
fairmq-dds-command-ui -c i -w "INITIALIZING DEVICE" -n ${requiredNofSlots}
|
fairmq-dds-command-ui -c i
|
||||||
fairmq-dds-command-ui -c k -w "INITIALIZED" -n ${requiredNofSlots}
|
fairmq-dds-command-ui -c k
|
||||||
fairmq-dds-command-ui -c b -w "BOUND" -n ${requiredNofSlots}
|
fairmq-dds-command-ui -c b
|
||||||
fairmq-dds-command-ui -c x -w "DEVICE READY" -n ${requiredNofSlots}
|
fairmq-dds-command-ui -c x
|
||||||
fairmq-dds-command-ui -c j -w "READY" -n ${requiredNofSlots}
|
fairmq-dds-command-ui -c j
|
||||||
fairmq-dds-command-ui -c r
|
fairmq-dds-command-ui -c r
|
||||||
sampler_and_sink="main/(Sampler|Sink)"
|
sampler_and_sink="main/(Sampler|Sink).*"
|
||||||
# processors="main/ProcessorGroup/Processor"
|
fairmq-dds-command-ui -w "RUNNING->READY" -p $sampler_and_sink
|
||||||
fairmq-dds-command-ui -p $sampler_and_sink -w "RUNNING->READY" -n 2
|
|
||||||
echo "...$sampler_and_sink are READY, sending shutdown..."
|
echo "...$sampler_and_sink are READY, sending shutdown..."
|
||||||
fairmq-dds-command-ui -c s -w "RUNNING->READY" -n ${requiredNofSlots}
|
fairmq-dds-command-ui -c s
|
||||||
fairmq-dds-command-ui -c t -w "DEVICE READY" -n ${requiredNofSlots}
|
fairmq-dds-command-ui -c t
|
||||||
fairmq-dds-command-ui -c d -w "IDLE" -n ${requiredNofSlots}
|
fairmq-dds-command-ui -c d
|
||||||
fairmq-dds-command-ui -c q -w "EXITING" -n ${requiredNofSlots}
|
fairmq-dds-command-ui -c q
|
||||||
echo "...waiting for ${requiredNofSlots} idle slots..."
|
echo "...waiting for ${requiredNofSlots} idle slots..."
|
||||||
dds-info --idle-count --wait ${requiredNofSlots}
|
dds-info --idle-count --wait ${requiredNofSlots}
|
||||||
echo "------------------------"
|
echo "------------------------"
|
||||||
|
@@ -34,11 +34,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-multipart.sh.in ${CMAKE_CURRE
|
|||||||
add_test(NAME Example.Multipart.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh zeromq)
|
add_test(NAME Example.Multipart.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh zeromq)
|
||||||
set_tests_properties(Example.Multipart.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message with 7 parts")
|
set_tests_properties(Example.Multipart.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message with 7 parts")
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
add_test(NAME Example.Multipart.nanomsg COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh nanomsg)
|
|
||||||
set_tests_properties(Example.Multipart.nanomsg PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message with 7 parts")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_test(NAME Example.Multipart.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh shmem)
|
add_test(NAME Example.Multipart.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh shmem)
|
||||||
set_tests_properties(Example.Multipart.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message with 7 parts")
|
set_tests_properties(Example.Multipart.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message with 7 parts")
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ SAMPLER+=" --verbosity veryhigh"
|
|||||||
SAMPLER+=" --session $SESSION"
|
SAMPLER+=" --session $SESSION"
|
||||||
SAMPLER+=" --max-iterations 1"
|
SAMPLER+=" --max-iterations 1"
|
||||||
SAMPLER+=" --control static --color false"
|
SAMPLER+=" --control static --color false"
|
||||||
SAMPLER+=" --channel-config name=data,type=pair,method=connect,rateLogging=0,address=tcp://127.0.0.1:5555"
|
SAMPLER+=" --channel-config name=data,type=pair,method=connect,rateLogging=0,address=tcp://127.0.0.1:5555,linger=1000"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||||
SAMPLER_PID=$!
|
SAMPLER_PID=$!
|
||||||
|
|
||||||
|
@@ -39,11 +39,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-multiple-channels.sh.in ${CMA
|
|||||||
add_test(NAME Example.MultipleChannels.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-channels.sh zeromq)
|
add_test(NAME Example.MultipleChannels.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-channels.sh zeromq)
|
||||||
set_tests_properties(Example.MultipleChannels.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received messages from both sources.")
|
set_tests_properties(Example.MultipleChannels.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received messages from both sources.")
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
add_test(NAME Example.MultipleChannels.nanomsg COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-channels.sh nanomsg)
|
|
||||||
set_tests_properties(Example.MultipleChannels.nanomsg PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received messages from both sources.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# install
|
# install
|
||||||
|
|
||||||
install(
|
install(
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
Multiple Transports example
|
Multiple Transports example
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
This example demonstrates use of multiple transports (zeromq/nanomsg/shmem) within the same topology and/or device. It is a simple topology consisting of two samplers and a sink. The devices are connected via 3 channels:
|
This example demonstrates use of multiple transports (zeromq/shmem) within the same topology and/or device. It is a simple topology consisting of two samplers and a sink. The devices are connected via 3 channels:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Each device has main transport that it uses. By default it is ZeroMQ, and can be overriden via the `--transport` cmd option. The device will initialize additional transports if any of the channels have them configured (e.g. as an option to `--channel-config`).
|
Each device has main transport that it uses. By default it is ZeroMQ, and can be overriden via the `--transport` cmd option. The device will initialize additional transports if any of the channels have them configured (e.g. as an option to `--channel-config`).
|
||||||
|
|
||||||
In this example sampler1 and sink are started with `--transport shmem`, making shared memory their main transport, sampler2 with `--transport nanomsg`. Additionally, the ack channel is configured to use zeromq as its transport.
|
In this example sampler1 and sink are started with `--transport shmem`, making shared memory their main transport, sampler2 with `--transport zeromq`. Additionally, the ack channel is configured to use zeromq as its transport.
|
||||||
|
|
||||||
The main two things that a transport does is transfer of data and allocation of memory for the messages. By default, new messages are created via the main device transport. If a message has been created with one transport and is to be transferred with another, it has to be copied into a new message of the target transport. This happens automatically behind the scenes. To avoid this copy the device can create messages via `NewMessageFor(const string& channelName, int subChannelIndex, ...)` method, that creates the messages via the transport of the given channel (check sampler1 and sink for an example) or as the channel directly to create a message.
|
The main two things that a transport does is transfer of data and allocation of memory for the messages. By default, new messages are created via the main device transport. If a message has been created with one transport and is to be transferred with another, it has to be copied into a new message of the target transport. This happens automatically behind the scenes. To avoid this copy the device can create messages via `NewMessageFor(const string& channelName, int subChannelIndex, ...)` method, that creates the messages via the transport of the given channel (check sampler1 and sink for an example) or as the channel directly to create a message.
|
||||||
|
@@ -13,7 +13,7 @@ xterm -geometry 80x30+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER1 &
|
|||||||
SAMPLER2="fairmq-ex-multiple-transports-sampler2"
|
SAMPLER2="fairmq-ex-multiple-transports-sampler2"
|
||||||
SAMPLER2+=" --id sampler2"
|
SAMPLER2+=" --id sampler2"
|
||||||
SAMPLER2+=" --severity debug"
|
SAMPLER2+=" --severity debug"
|
||||||
SAMPLER2+=" --transport nanomsg"
|
SAMPLER2+=" --transport shmem"
|
||||||
SAMPLER2+=" --channel-config name=data2,type=push,method=bind,address=tcp://127.0.0.1:5556"
|
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 &
|
xterm -geometry 80x30+0+450 -hold -e @EX_BIN_DIR@/$SAMPLER2 &
|
||||||
|
|
||||||
@@ -22,6 +22,6 @@ SINK+=" --id sink1"
|
|||||||
SINK+=" --severity debug"
|
SINK+=" --severity debug"
|
||||||
SINK+=" --transport shmem"
|
SINK+=" --transport shmem"
|
||||||
SINK+=" --channel-config name=data1,type=pull,method=connect,address=tcp://127.0.0.1:5555"
|
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=data2,type=pull,method=connect,address=tcp://127.0.0.1:5556,transport=shmem"
|
||||||
SINK+=" name=ack,type=pub,method=connect,address=tcp://127.0.0.1:5557,transport=zeromq"
|
SINK+=" name=ack,type=pub,method=connect,address=tcp://127.0.0.1:5557,transport=zeromq"
|
||||||
xterm -geometry 80x30+500+225 -hold -e @EX_BIN_DIR@/$SINK &
|
xterm -geometry 80x30+500+225 -hold -e @EX_BIN_DIR@/$SINK &
|
||||||
|
@@ -14,7 +14,7 @@ SINK+=" --max-iterations 1"
|
|||||||
SINK+=" --control static --color false"
|
SINK+=" --control static --color false"
|
||||||
SINK+=" --transport shmem"
|
SINK+=" --transport shmem"
|
||||||
SINK+=" --channel-config name=data1,type=pull,method=connect,address=tcp://127.0.0.1:5555"
|
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=data2,type=pull,method=connect,address=tcp://127.0.0.1:5556,transport=zeromq"
|
||||||
SINK+=" name=ack,type=pub,method=connect,address=tcp://127.0.0.1:5557,transport=zeromq"
|
SINK+=" name=ack,type=pub,method=connect,address=tcp://127.0.0.1:5557,transport=zeromq"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
||||||
SINK_PID=$!
|
SINK_PID=$!
|
||||||
@@ -37,7 +37,7 @@ SAMPLER2+=" --session $SESSION"
|
|||||||
SAMPLER2+=" --verbosity veryhigh"
|
SAMPLER2+=" --verbosity veryhigh"
|
||||||
SAMPLER2+=" --max-iterations 1"
|
SAMPLER2+=" --max-iterations 1"
|
||||||
SAMPLER2+=" --control static --color false"
|
SAMPLER2+=" --control static --color false"
|
||||||
SAMPLER2+=" --transport nanomsg"
|
SAMPLER2+=" --transport zeromq"
|
||||||
SAMPLER2+=" --channel-config name=data2,type=push,method=bind,address=tcp://127.0.0.1:5556"
|
SAMPLER2+=" --channel-config name=data2,type=push,method=bind,address=tcp://127.0.0.1:5556"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER2 &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER2 &
|
||||||
SAMPLER2_PID=$!
|
SAMPLER2_PID=$!
|
||||||
|
99
examples/n-m/CMakeLists.txt
Normal file
99
examples/n-m/CMakeLists.txt
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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_executable(fairmq-ex-n-m-synchronizer runSynchronizer.cxx)
|
||||||
|
target_link_libraries(fairmq-ex-n-m-synchronizer PRIVATE FairMQ)
|
||||||
|
|
||||||
|
add_executable(fairmq-ex-n-m-sender runSender.cxx)
|
||||||
|
target_link_libraries(fairmq-ex-n-m-sender PRIVATE FairMQ)
|
||||||
|
|
||||||
|
add_executable(fairmq-ex-n-m-receiver runReceiver.cxx)
|
||||||
|
target_link_libraries(fairmq-ex-n-m-receiver PRIVATE FairMQ)
|
||||||
|
|
||||||
|
add_custom_target(ExampleNM DEPENDS fairmq-ex-n-m-synchronizer fairmq-ex-n-m-sender fairmq-ex-n-m-receiver)
|
||||||
|
|
||||||
|
list(JOIN Boost_LIBRARY_DIRS ":" LIB_DIR)
|
||||||
|
set(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/fairmq/sdk)
|
||||||
|
set(DATA_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-n-m-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-n-m-topology.xml @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-n-m-pair-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-n-m-pair-topology.xml @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-ex-n-m-env.sh ${CMAKE_CURRENT_BINARY_DIR}/fairmq-ex-n-m-env.sh @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-n-m.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m.sh @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-n-m-pair.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-pair.sh @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-n-m-dds.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-dds.sh @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-n-m-pair-dds.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-pair-dds.sh @ONLY)
|
||||||
|
|
||||||
|
# test
|
||||||
|
if(DDS_FOUND)
|
||||||
|
add_test(NAME Example.N-M.localhost COMMAND ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-dds.sh localhost)
|
||||||
|
set_tests_properties(Example.N-M.localhost PROPERTIES TIMEOUT 15 RUN_SERIAL true PASS_REGULAR_EXPRESSION "Example successful")
|
||||||
|
add_test(NAME Example.N-M-pair.localhost COMMAND ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-pair-dds.sh localhost)
|
||||||
|
set_tests_properties(Example.N-M-pair.localhost PROPERTIES TIMEOUT 15 RUN_SERIAL true PASS_REGULAR_EXPRESSION "Example successful")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# install
|
||||||
|
install(
|
||||||
|
TARGETS
|
||||||
|
fairmq-ex-n-m-synchronizer
|
||||||
|
fairmq-ex-n-m-sender
|
||||||
|
fairmq-ex-n-m-receiver
|
||||||
|
|
||||||
|
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# configure run script with different executable paths for build and for install directories
|
||||||
|
set(BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
||||||
|
set(DATA_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_DATADIR})
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-n-m-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-n-m-topology.xml_install @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-n-m-pair-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-n-m-pair-topology.xml_install @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-ex-n-m-env.sh ${CMAKE_CURRENT_BINARY_DIR}/fairmq-ex-n-m-env.sh_install @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-n-m.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m.sh_install @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-n-m-pair.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-pair.sh_install @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-n-m-dds.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-dds.sh_install @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-n-m-pair-dds.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-pair-dds.sh_install @ONLY)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-n-m-topology.xml_install
|
||||||
|
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
||||||
|
RENAME ex-n-m-topology.xml
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-n-m-pair-topology.xml_install
|
||||||
|
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
||||||
|
RENAME ex-n-m-pair-topology.xml
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-ex-n-m-env.sh_install
|
||||||
|
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
|
RENAME fairmq-ex-n-m-env.sh
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m.sh_install
|
||||||
|
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
|
RENAME fairmq-start-ex-n-m.sh
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-pair.sh_install
|
||||||
|
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
|
RENAME fairmq-start-ex-n-m-pair.sh
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-dds.sh_install
|
||||||
|
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
|
RENAME fairmq-start-ex-n-m-dds.sh
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-n-m-pair-dds.sh_install
|
||||||
|
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
|
RENAME fairmq-start-ex-n-m-pair-dds.sh
|
||||||
|
)
|
@@ -5,31 +5,20 @@
|
|||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
* copied verbatim in the file "LICENSE" *
|
* copied verbatim in the file "LICENSE" *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
#ifndef FAIR_MQ_EXAMPLE_N_M_HEADER_H
|
||||||
|
#define FAIR_MQ_EXAMPLE_N_M_HEADER_H
|
||||||
|
|
||||||
#include "FairMQUnmanagedRegionNN.h"
|
#include <cstdint>
|
||||||
#include "FairMQLogger.h"
|
|
||||||
|
|
||||||
using namespace std;
|
namespace example_n_m
|
||||||
|
|
||||||
FairMQUnmanagedRegionNN::FairMQUnmanagedRegionNN(const size_t size, FairMQRegionCallback callback, const std::string& /*path = "" */, int /*flags = 0 */)
|
|
||||||
: fBuffer(malloc(size))
|
|
||||||
, fSize(size)
|
|
||||||
, fCallback(callback)
|
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
void* FairMQUnmanagedRegionNN::GetData() const
|
struct Header
|
||||||
{
|
{
|
||||||
return fBuffer;
|
std::uint16_t id;
|
||||||
}
|
int senderIndex;
|
||||||
|
};
|
||||||
|
|
||||||
size_t FairMQUnmanagedRegionNN::GetSize() const
|
} // namespace example_n_m
|
||||||
{
|
|
||||||
return fSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
FairMQUnmanagedRegionNN::~FairMQUnmanagedRegionNN()
|
#endif /* FAIR_MQ_EXAMPLE_N_M_HEADER_H */
|
||||||
{
|
|
||||||
LOG(debug) << "destroying region";
|
|
||||||
free(fBuffer);
|
|
||||||
}
|
|
4
examples/n-m/README.md
Normal file
4
examples/n-m/README.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
N-M
|
||||||
|
==========================
|
||||||
|
|
||||||
|
A topology consisting of three layers of devices: synchronizer -> sender(s) -> receiver(s). Senders distribute data to receivers based on the data id contained in the message from the synchronizer (same id goes to the same receiver from every sender). The senders send the data in a non-blocking fashion - if queue is full or receiver is down, data is discarded. Two configurations are provided - one using push/pull channels between senders/receivers, another using pair channels. In push/pull case there is only one receiving channel on the receiver device. In pair case there are as many receiver (sub-)channels as there are senders.
|
44
examples/n-m/ex-n-m-pair-topology.xml
Normal file
44
examples/n-m/ex-n-m-pair-topology.xml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<topology name="myTopology">
|
||||||
|
|
||||||
|
<var name="numSenders" value="3" />
|
||||||
|
<var name="numReceivers" value="4" />
|
||||||
|
|
||||||
|
<property name="fmqchan_sync" />
|
||||||
|
<property name="fmqchan_data" />
|
||||||
|
|
||||||
|
<decltask name="Synchronizer">
|
||||||
|
<exe reachable="true">fairmq-ex-n-m-synchronizer --id sync --rate 100 --color false -P dds --channel-config name=sync,type=pub,method=bind</exe>
|
||||||
|
<env reachable="false">fairmq-ex-n-m-env.sh</env>
|
||||||
|
<properties>
|
||||||
|
<name access="write">fmqchan_sync</name>
|
||||||
|
</properties>
|
||||||
|
</decltask>
|
||||||
|
|
||||||
|
<decltask name="Sender">
|
||||||
|
<exe reachable="true">fairmq-ex-n-m-sender --id sender%taskIndex% --timeframe-size 100000 --num-receivers ${numReceivers} --color false -P dds --channel-config name=sync,type=sub,method=connect name=data,type=pair,method=connect,numSockets=${numReceivers} --dds-i data:%taskIndex%</exe>
|
||||||
|
<env reachable="false">fairmq-ex-n-m-env.sh</env>
|
||||||
|
<properties>
|
||||||
|
<name access="read">fmqchan_sync</name>
|
||||||
|
<name access="read">fmqchan_data</name>
|
||||||
|
</properties>
|
||||||
|
</decltask>
|
||||||
|
|
||||||
|
<decltask name="Receiver">
|
||||||
|
<exe reachable="true">fairmq-ex-n-m-receiver --id receiver%taskIndex% --num-senders ${numSenders} --color false -P dds --max-timeframes 10 --channel-config name=data,type=pair,method=bind,numSockets=${numSenders}</exe>
|
||||||
|
<env reachable="false">fairmq-ex-n-m-env.sh</env>
|
||||||
|
<properties>
|
||||||
|
<name access="write">fmqchan_data</name>
|
||||||
|
</properties>
|
||||||
|
</decltask>
|
||||||
|
|
||||||
|
<main name="main">
|
||||||
|
<task>Synchronizer</task>
|
||||||
|
<group name="Senders" n="${numSenders}">
|
||||||
|
<task>Sender</task>
|
||||||
|
</group>
|
||||||
|
<group name="Receivers" n="${numReceivers}">
|
||||||
|
<task>Receiver</task>
|
||||||
|
</group>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
</topology>
|
44
examples/n-m/ex-n-m-topology.xml
Normal file
44
examples/n-m/ex-n-m-topology.xml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<topology name="myTopology">
|
||||||
|
|
||||||
|
<var name="numSenders" value="3" />
|
||||||
|
<var name="numReceivers" value="4" />
|
||||||
|
|
||||||
|
<property name="fmqchan_sync" />
|
||||||
|
<property name="fmqchan_data" />
|
||||||
|
|
||||||
|
<decltask name="Synchronizer">
|
||||||
|
<exe reachable="true">fairmq-ex-n-m-synchronizer --id sync --rate 100 --color false -P dds --channel-config name=sync,type=pub,method=bind</exe>
|
||||||
|
<env reachable="false">fairmq-ex-n-m-env.sh</env>
|
||||||
|
<properties>
|
||||||
|
<name access="write">fmqchan_sync</name>
|
||||||
|
</properties>
|
||||||
|
</decltask>
|
||||||
|
|
||||||
|
<decltask name="Sender">
|
||||||
|
<exe reachable="true">fairmq-ex-n-m-sender --id sender%taskIndex% --timeframe-size 100000 --num-receivers ${numReceivers} --color false -P dds --channel-config name=sync,type=sub,method=connect name=data,type=push,method=connect,numSockets=${numReceivers}</exe>
|
||||||
|
<env reachable="false">fairmq-ex-n-m-env.sh</env>
|
||||||
|
<properties>
|
||||||
|
<name access="read">fmqchan_sync</name>
|
||||||
|
<name access="read">fmqchan_data</name>
|
||||||
|
</properties>
|
||||||
|
</decltask>
|
||||||
|
|
||||||
|
<decltask name="Receiver">
|
||||||
|
<exe reachable="true">fairmq-ex-n-m-receiver --id receiver%taskIndex% --num-senders ${numSenders} --color false -P dds --max-timeframes 10 --channel-config name=data,type=pull,method=bind</exe>
|
||||||
|
<env reachable="false">fairmq-ex-n-m-env.sh</env>
|
||||||
|
<properties>
|
||||||
|
<name access="write">fmqchan_data</name>
|
||||||
|
</properties>
|
||||||
|
</decltask>
|
||||||
|
|
||||||
|
<main name="main">
|
||||||
|
<task>Synchronizer</task>
|
||||||
|
<group name="Senders" n="${numSenders}">
|
||||||
|
<task>Sender</task>
|
||||||
|
</group>
|
||||||
|
<group name="Receivers" n="${numReceivers}">
|
||||||
|
<task>Receiver</task>
|
||||||
|
</group>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
</topology>
|
16
examples/n-m/fairmq-ex-n-m-env.sh
Executable file
16
examples/n-m/fairmq-ex-n-m-env.sh
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Copyright (C) 2019 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" #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
export PATH=@BIN_DIR@:$PATH
|
||||||
|
|
||||||
|
OS=$(uname -s 2>&1)
|
||||||
|
if [ "$OS" == "Darwin" ]; then
|
||||||
|
export DYLD_LIBRARY_PATH=@LIB_DIR@:$DYLD_LIBRARY_PATH
|
||||||
|
fi
|
76
examples/n-m/fairmq-start-ex-n-m-dds.sh.in
Executable file
76
examples/n-m/fairmq-start-ex-n-m-dds.sh.in
Executable file
@@ -0,0 +1,76 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Copyright (C) 2019 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" #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
dds-session stop $1
|
||||||
|
echo "CLEANUP PERFORMED"
|
||||||
|
}
|
||||||
|
|
||||||
|
source @DDS_INSTALL_PREFIX@/DDS_env.sh
|
||||||
|
export PATH=@BIN_DIR@:$PATH
|
||||||
|
|
||||||
|
exec 5>&1
|
||||||
|
output=$(dds-session start | tee >(cat - >&5))
|
||||||
|
export DDS_SESSION_ID=$(echo ${output} | grep "DDS session ID: " | cut -d' ' -f4)
|
||||||
|
echo "SESSION ID: ${DDS_SESSION_ID}"
|
||||||
|
|
||||||
|
trap "cleanup ${DDS_SESSION_ID}" EXIT
|
||||||
|
|
||||||
|
requiredNofSlots=8
|
||||||
|
dds-submit -r localhost --slots ${requiredNofSlots}
|
||||||
|
echo "...waiting for ${requiredNofSlots} idle slots..."
|
||||||
|
dds-info --idle-count --wait ${requiredNofSlots}
|
||||||
|
|
||||||
|
export FAIRMQ_DDS_TOPO_FILE=@DATA_DIR@/ex-n-m-topology.xml
|
||||||
|
echo "TOPOLOGY FILE: ${FAIRMQ_DDS_TOPO_FILE}"
|
||||||
|
echo "TOPOLOGY NAME: $(dds-topology --disable-validation --topology-name ${FAIRMQ_DDS_TOPO_FILE})"
|
||||||
|
|
||||||
|
dds-info --active-topology
|
||||||
|
dds-topology --activate ${FAIRMQ_DDS_TOPO_FILE}
|
||||||
|
dds-info --active-topology
|
||||||
|
echo "...waiting for ${requiredNofSlots} executing slots..."
|
||||||
|
dds-info --executing-count --wait ${requiredNofSlots}
|
||||||
|
|
||||||
|
echo "------------------------"
|
||||||
|
echo "...waiting for Topology to finish..."
|
||||||
|
# TODO Retrieve number of devices from DDS topology API instead of having the user pass it explicitely
|
||||||
|
fairmq-dds-command-ui -w "IDLE"
|
||||||
|
fairmq-dds-command-ui -c i
|
||||||
|
fairmq-dds-command-ui -c k
|
||||||
|
fairmq-dds-command-ui -c b
|
||||||
|
fairmq-dds-command-ui -c x
|
||||||
|
fairmq-dds-command-ui -c j
|
||||||
|
fairmq-dds-command-ui -c r
|
||||||
|
receivers="main/Receivers.*"
|
||||||
|
fairmq-dds-command-ui -w "RUNNING->READY" -p $receivers
|
||||||
|
echo "All receivers transitioned from RUNNING to READY"
|
||||||
|
fairmq-dds-command-ui -c s
|
||||||
|
fairmq-dds-command-ui -c t
|
||||||
|
fairmq-dds-command-ui -c d
|
||||||
|
fairmq-dds-command-ui -c q
|
||||||
|
echo "...waiting for ${requiredNofSlots} idle slots..."
|
||||||
|
dds-info --idle-count --wait ${requiredNofSlots}
|
||||||
|
echo "------------------------"
|
||||||
|
|
||||||
|
dds-info --active-topology
|
||||||
|
dds-topology --stop
|
||||||
|
dds-info --active-topology
|
||||||
|
|
||||||
|
dds-agent-cmd getlog -a
|
||||||
|
logDir="${wrkDir}/logs"
|
||||||
|
for file in $(find "${logDir}" -name "*.tar.gz"); do tar -xf ${file} -C "${logDir}" ; done
|
||||||
|
echo "AGENT LOG FILES IN: ${logDir}"
|
||||||
|
|
||||||
|
# This string is used by ctest to detect success
|
||||||
|
echo "Example successful :)"
|
||||||
|
|
||||||
|
# Cleanup function is called by EXIT trap
|
76
examples/n-m/fairmq-start-ex-n-m-pair-dds.sh.in
Executable file
76
examples/n-m/fairmq-start-ex-n-m-pair-dds.sh.in
Executable file
@@ -0,0 +1,76 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Copyright (C) 2019 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" #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
dds-session stop $1
|
||||||
|
echo "CLEANUP PERFORMED"
|
||||||
|
}
|
||||||
|
|
||||||
|
source @DDS_INSTALL_PREFIX@/DDS_env.sh
|
||||||
|
export PATH=@BIN_DIR@:$PATH
|
||||||
|
|
||||||
|
exec 5>&1
|
||||||
|
output=$(dds-session start | tee >(cat - >&5))
|
||||||
|
export DDS_SESSION_ID=$(echo ${output} | grep "DDS session ID: " | cut -d' ' -f4)
|
||||||
|
echo "SESSION ID: ${DDS_SESSION_ID}"
|
||||||
|
|
||||||
|
trap "cleanup ${DDS_SESSION_ID}" EXIT
|
||||||
|
|
||||||
|
requiredNofSlots=8
|
||||||
|
dds-submit -r localhost --slots ${requiredNofSlots}
|
||||||
|
echo "...waiting for ${requiredNofSlots} idle slots..."
|
||||||
|
dds-info --idle-count --wait ${requiredNofSlots}
|
||||||
|
|
||||||
|
export FAIRMQ_DDS_TOPO_FILE=@DATA_DIR@/ex-n-m-pair-topology.xml
|
||||||
|
echo "TOPOLOGY FILE: ${FAIRMQ_DDS_TOPO_FILE}"
|
||||||
|
echo "TOPOLOGY NAME: $(dds-topology --disable-validation --topology-name ${FAIRMQ_DDS_TOPO_FILE})"
|
||||||
|
|
||||||
|
dds-info --active-topology
|
||||||
|
dds-topology --activate ${FAIRMQ_DDS_TOPO_FILE}
|
||||||
|
dds-info --active-topology
|
||||||
|
echo "...waiting for ${requiredNofSlots} executing slots..."
|
||||||
|
dds-info --executing-count --wait ${requiredNofSlots}
|
||||||
|
|
||||||
|
echo "------------------------"
|
||||||
|
echo "...waiting for Topology to finish..."
|
||||||
|
# TODO Retrieve number of devices from DDS topology API instead of having the user pass it explicitely
|
||||||
|
fairmq-dds-command-ui -w "IDLE"
|
||||||
|
fairmq-dds-command-ui -c i
|
||||||
|
fairmq-dds-command-ui -c k
|
||||||
|
fairmq-dds-command-ui -c b
|
||||||
|
fairmq-dds-command-ui -c x
|
||||||
|
fairmq-dds-command-ui -c j
|
||||||
|
fairmq-dds-command-ui -c r
|
||||||
|
receivers="main/Receivers.*"
|
||||||
|
fairmq-dds-command-ui -w "RUNNING->READY" -p $receivers
|
||||||
|
echo "All receivers transitioned from RUNNING to READY"
|
||||||
|
fairmq-dds-command-ui -c s
|
||||||
|
fairmq-dds-command-ui -c t
|
||||||
|
fairmq-dds-command-ui -c d
|
||||||
|
fairmq-dds-command-ui -c q
|
||||||
|
echo "...waiting for ${requiredNofSlots} idle slots..."
|
||||||
|
dds-info --idle-count --wait ${requiredNofSlots}
|
||||||
|
echo "------------------------"
|
||||||
|
|
||||||
|
dds-info --active-topology
|
||||||
|
dds-topology --stop
|
||||||
|
dds-info --active-topology
|
||||||
|
|
||||||
|
dds-agent-cmd getlog -a
|
||||||
|
logDir="${wrkDir}/logs"
|
||||||
|
for file in $(find "${logDir}" -name "*.tar.gz"); do tar -xf ${file} -C "${logDir}" ; done
|
||||||
|
echo "AGENT LOG FILES IN: ${logDir}"
|
||||||
|
|
||||||
|
# This string is used by ctest to detect success
|
||||||
|
echo "Example successful :)"
|
||||||
|
|
||||||
|
# Cleanup function is called by EXIT trap
|
60
examples/n-m/fairmq-start-ex-n-m-pair.sh.in
Executable file
60
examples/n-m/fairmq-start-ex-n-m-pair.sh.in
Executable file
@@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export PATH=@BIN_DIR@:$PATH
|
||||||
|
|
||||||
|
SYNC="fairmq-ex-n-m-synchronizer"
|
||||||
|
SYNC+=" --id Sync"
|
||||||
|
SYNC+=" --channel-config name=sync,type=pub,method=bind,address=tcp://localhost:8010"
|
||||||
|
SYNC+=" --rate 100"
|
||||||
|
xterm -geometry 80x25+0+0 -hold -e $SYNC &
|
||||||
|
|
||||||
|
SENDER0="fairmq-ex-n-m-sender"
|
||||||
|
SENDER0+=" --id Sender1"
|
||||||
|
SENDER0+=" --channel-config name=sync,type=sub,method=connect,address=tcp://localhost:8010"
|
||||||
|
SENDER0+=" name=data,type=pair,method=connect,address=tcp://localhost:8021,address=tcp://localhost:8022,address=tcp://localhost:8023,address=tcp://localhost:8024"
|
||||||
|
SENDER0+=" --sender-index 0"
|
||||||
|
SENDER0+=" --subtimeframe-size 1000000"
|
||||||
|
SENDER0+=" --num-receivers 4"
|
||||||
|
xterm -geometry 80x25+500+0 -hold -e $SENDER0 &
|
||||||
|
|
||||||
|
SENDER1="fairmq-ex-n-m-sender"
|
||||||
|
SENDER1+=" --id Sender2"
|
||||||
|
SENDER1+=" --channel-config name=sync,type=sub,method=connect,address=tcp://localhost:8010"
|
||||||
|
SENDER1+=" name=data,type=pair,method=connect,address=tcp://localhost:8031,address=tcp://localhost:8032,address=tcp://localhost:8033,address=tcp://localhost:8034"
|
||||||
|
SENDER1+=" --sender-index 1"
|
||||||
|
SENDER1+=" --subtimeframe-size 1000000"
|
||||||
|
SENDER1+=" --num-receivers 4"
|
||||||
|
xterm -geometry 80x25+500+350 -hold -e $SENDER1 &
|
||||||
|
|
||||||
|
SENDER2="fairmq-ex-n-m-sender"
|
||||||
|
SENDER2+=" --id Sender3"
|
||||||
|
SENDER2+=" --channel-config name=sync,type=sub,method=connect,address=tcp://localhost:8010"
|
||||||
|
SENDER2+=" name=data,type=pair,method=connect,address=tcp://localhost:8041,address=tcp://localhost:8042,address=tcp://localhost:8043,address=tcp://localhost:8044"
|
||||||
|
SENDER2+=" --sender-index 2"
|
||||||
|
SENDER2+=" --subtimeframe-size 1000000"
|
||||||
|
SENDER2+=" --num-receivers 4"
|
||||||
|
xterm -geometry 80x25+500+700 -hold -e $SENDER2 &
|
||||||
|
|
||||||
|
RECEIVER0="fairmq-ex-n-m-receiver"
|
||||||
|
RECEIVER0+=" --id Receiver1"
|
||||||
|
RECEIVER0+=" --channel-config name=data,type=pair,method=bind,address=tcp://localhost:8021,address=tcp://localhost:8031,address=tcp://localhost:8041"
|
||||||
|
RECEIVER0+=" --num-senders 3"
|
||||||
|
xterm -geometry 80x25+1000+0 -hold -e $RECEIVER0 &
|
||||||
|
|
||||||
|
RECEIVER1="fairmq-ex-n-m-receiver"
|
||||||
|
RECEIVER1+=" --id Receiver2"
|
||||||
|
RECEIVER1+=" --channel-config name=data,type=pair,method=bind,address=tcp://localhost:8022,address=tcp://localhost:8032,address=tcp://localhost:8042"
|
||||||
|
RECEIVER1+=" --num-senders 3"
|
||||||
|
xterm -geometry 80x25+1000+350 -hold -e $RECEIVER1 &
|
||||||
|
|
||||||
|
RECEIVER2="fairmq-ex-n-m-receiver"
|
||||||
|
RECEIVER2+=" --id Receiver3"
|
||||||
|
RECEIVER2+=" --channel-config name=data,type=pair,method=bind,address=tcp://localhost:8023,address=tcp://localhost:8033,address=tcp://localhost:8043"
|
||||||
|
RECEIVER2+=" --num-senders 3"
|
||||||
|
xterm -geometry 80x25+1000+700 -hold -e $RECEIVER2 &
|
||||||
|
|
||||||
|
RECEIVER3="fairmq-ex-n-m-receiver"
|
||||||
|
RECEIVER3+=" --id Receiver4"
|
||||||
|
RECEIVER3+=" --channel-config name=data,type=pair,method=bind,address=tcp://localhost:8024,address=tcp://localhost:8034,address=tcp://localhost:8044"
|
||||||
|
RECEIVER3+=" --num-senders 3"
|
||||||
|
xterm -geometry 80x25+1000+1050 -hold -e $RECEIVER3 &
|
60
examples/n-m/fairmq-start-ex-n-m.sh.in
Executable file
60
examples/n-m/fairmq-start-ex-n-m.sh.in
Executable file
@@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export PATH=@BIN_DIR@:$PATH
|
||||||
|
|
||||||
|
SYNC="fairmq-ex-n-m-synchronizer"
|
||||||
|
SYNC+=" --id Sync"
|
||||||
|
SYNC+=" --channel-config name=sync,type=pub,method=bind,address=tcp://localhost:8010"
|
||||||
|
SYNC+=" --rate 100"
|
||||||
|
xterm -geometry 80x25+0+0 -hold -e $SYNC &
|
||||||
|
|
||||||
|
SENDER0="fairmq-ex-n-m-sender"
|
||||||
|
SENDER0+=" --id Sender1"
|
||||||
|
SENDER0+=" --channel-config name=sync,type=sub,method=connect,address=tcp://localhost:8010"
|
||||||
|
SENDER0+=" name=data,type=push,method=connect,address=tcp://localhost:8021,address=tcp://localhost:8022,address=tcp://localhost:8023,address=tcp://localhost:8024"
|
||||||
|
SENDER0+=" --sender-index 0"
|
||||||
|
SENDER0+=" --subtimeframe-size 1000000"
|
||||||
|
SENDER0+=" --num-receivers 4"
|
||||||
|
xterm -geometry 80x25+500+0 -hold -e $SENDER0 &
|
||||||
|
|
||||||
|
SENDER1="fairmq-ex-n-m-sender"
|
||||||
|
SENDER1+=" --id Sender2"
|
||||||
|
SENDER1+=" --channel-config name=sync,type=sub,method=connect,address=tcp://localhost:8010"
|
||||||
|
SENDER1+=" name=data,type=push,method=connect,address=tcp://localhost:8021,address=tcp://localhost:8022,address=tcp://localhost:8023,address=tcp://localhost:8024"
|
||||||
|
SENDER1+=" --sender-index 1"
|
||||||
|
SENDER1+=" --subtimeframe-size 1000000"
|
||||||
|
SENDER1+=" --num-receivers 4"
|
||||||
|
xterm -geometry 80x25+500+350 -hold -e $SENDER1 &
|
||||||
|
|
||||||
|
SENDER2="fairmq-ex-n-m-sender"
|
||||||
|
SENDER2+=" --id Sender3"
|
||||||
|
SENDER2+=" --channel-config name=sync,type=sub,method=connect,address=tcp://localhost:8010"
|
||||||
|
SENDER2+=" name=data,type=push,method=connect,address=tcp://localhost:8021,address=tcp://localhost:8022,address=tcp://localhost:8023,address=tcp://localhost:8024"
|
||||||
|
SENDER2+=" --sender-index 2"
|
||||||
|
SENDER2+=" --subtimeframe-size 1000000"
|
||||||
|
SENDER2+=" --num-receivers 4"
|
||||||
|
xterm -geometry 80x25+500+700 -hold -e $SENDER2 &
|
||||||
|
|
||||||
|
RECEIVER0="fairmq-ex-n-m-receiver"
|
||||||
|
RECEIVER0+=" --id Receiver1"
|
||||||
|
RECEIVER0+=" --channel-config name=data,type=pull,method=bind,address=tcp://localhost:8021"
|
||||||
|
RECEIVER0+=" --num-senders 3"
|
||||||
|
xterm -geometry 80x25+1000+0 -hold -e $RECEIVER0 &
|
||||||
|
|
||||||
|
RECEIVER1="fairmq-ex-n-m-receiver"
|
||||||
|
RECEIVER1+=" --id Receiver2"
|
||||||
|
RECEIVER1+=" --channel-config name=data,type=pull,method=bind,address=tcp://localhost:8022"
|
||||||
|
RECEIVER1+=" --num-senders 3"
|
||||||
|
xterm -geometry 80x25+1000+350 -hold -e $RECEIVER1 &
|
||||||
|
|
||||||
|
RECEIVER2="fairmq-ex-n-m-receiver"
|
||||||
|
RECEIVER2+=" --id Receiver3"
|
||||||
|
RECEIVER2+=" --channel-config name=data,type=pull,method=bind,address=tcp://localhost:8023"
|
||||||
|
RECEIVER2+=" --num-senders 3"
|
||||||
|
xterm -geometry 80x25+1000+700 -hold -e $RECEIVER2 &
|
||||||
|
|
||||||
|
RECEIVER3="fairmq-ex-n-m-receiver"
|
||||||
|
RECEIVER3+=" --id Receiver4"
|
||||||
|
RECEIVER3+=" --channel-config name=data,type=pull,method=bind,address=tcp://localhost:8024"
|
||||||
|
RECEIVER3+=" --num-senders 3"
|
||||||
|
xterm -geometry 80x25+1000+1050 -hold -e $RECEIVER3 &
|
119
examples/n-m/runReceiver.cxx
Normal file
119
examples/n-m/runReceiver.cxx
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
* Copyright (C) 2020 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 "Header.h"
|
||||||
|
|
||||||
|
#include <FairMQDevice.h>
|
||||||
|
#include <runFairMQDevice.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <chrono>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace example_n_m;
|
||||||
|
namespace bpo = boost::program_options;
|
||||||
|
|
||||||
|
struct TFBuffer
|
||||||
|
{
|
||||||
|
FairMQParts parts;
|
||||||
|
chrono::steady_clock::time_point start;
|
||||||
|
chrono::steady_clock::time_point end;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Receiver : public FairMQDevice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Receiver()
|
||||||
|
: fBuffer()
|
||||||
|
, fDiscardedSet()
|
||||||
|
, fNumSenders(0)
|
||||||
|
, fBufferTimeoutInMs(5000)
|
||||||
|
, fMaxTimeframes(0)
|
||||||
|
, fTimeframeCounter(0)
|
||||||
|
{
|
||||||
|
OnData("data", &Receiver::HandleData);
|
||||||
|
}
|
||||||
|
|
||||||
|
~Receiver() = default;
|
||||||
|
|
||||||
|
void InitTask() override
|
||||||
|
{
|
||||||
|
fNumSenders = GetConfig()->GetValue<int>("num-senders");
|
||||||
|
fBufferTimeoutInMs = GetConfig()->GetValue<int>("buffer-timeout");
|
||||||
|
fMaxTimeframes = GetConfig()->GetValue<int>("max-timeframes");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool HandleData(FairMQParts& parts, int /* index */)
|
||||||
|
{
|
||||||
|
Header& h = *(static_cast<Header*>(parts.At(0)->GetData()));
|
||||||
|
// LOG(info) << "Received sub-time frame #" << h.id << " from Sender" << h.senderIndex;
|
||||||
|
|
||||||
|
if (fDiscardedSet.find(h.id) == fDiscardedSet.end()) {
|
||||||
|
if (fBuffer.find(h.id) == fBuffer.end()) {
|
||||||
|
// if this is the first part with this ID, save the receive time.
|
||||||
|
fBuffer[h.id].start = chrono::steady_clock::now();
|
||||||
|
}
|
||||||
|
// if the received ID has not previously been discarded, store the data part in the buffer
|
||||||
|
fBuffer[h.id].parts.AddPart(move(parts.At(1)));
|
||||||
|
} else {
|
||||||
|
// if received ID has been previously discarded.
|
||||||
|
LOG(debug) << "Received part from an already discarded timeframe with id " << h.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fBuffer[h.id].parts.Size() == fNumSenders) {
|
||||||
|
LOG(info) << "Successfully completed timeframe #" << h.id;
|
||||||
|
fBuffer.erase(h.id);
|
||||||
|
|
||||||
|
if (fMaxTimeframes > 0 && ++fTimeframeCounter >= fMaxTimeframes) {
|
||||||
|
LOG(info) << "Reached configured maximum number of timeframes (" << fMaxTimeframes << "). Exiting RUNNING state.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiscardIncompleteTimeframes()
|
||||||
|
{
|
||||||
|
auto it = fBuffer.begin();
|
||||||
|
while (it != fBuffer.end()) {
|
||||||
|
if (chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - (it->second).start).count() > fBufferTimeoutInMs) {
|
||||||
|
LOG(debug) << "Timeframe #" << it->first << " incomplete after " << fBufferTimeoutInMs << " milliseconds, discarding";
|
||||||
|
fDiscardedSet.insert(it->first);
|
||||||
|
fBuffer.erase(it++);
|
||||||
|
LOG(debug) << "Number of discarded timeframes: " << fDiscardedSet.size();
|
||||||
|
} else {
|
||||||
|
// LOG(info) << "Timeframe #" << it->first << " within timeout, buffering...";
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unordered_map<uint16_t, TFBuffer> fBuffer;
|
||||||
|
unordered_set<uint16_t> fDiscardedSet;
|
||||||
|
|
||||||
|
int fNumSenders;
|
||||||
|
int fBufferTimeoutInMs;
|
||||||
|
int fMaxTimeframes;
|
||||||
|
int fTimeframeCounter;
|
||||||
|
};
|
||||||
|
|
||||||
|
void addCustomOptions(bpo::options_description& options)
|
||||||
|
{
|
||||||
|
options.add_options()
|
||||||
|
("buffer-timeout", bpo::value<int>()->default_value(1000), "Buffer timeout in milliseconds")
|
||||||
|
("num-senders", bpo::value<int>()->required(), "Number of senders")
|
||||||
|
("max-timeframes", bpo::value<int>()->default_value(0), "Maximum number of timeframes to receive (0 - unlimited)");
|
||||||
|
}
|
||||||
|
|
||||||
|
FairMQDevice* getDevice(const FairMQProgOptions& /* config */) { return new Receiver(); }
|
79
examples/n-m/runSender.cxx
Normal file
79
examples/n-m/runSender.cxx
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
* Copyright (C) 2020 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 "Header.h"
|
||||||
|
|
||||||
|
#include <FairMQDevice.h>
|
||||||
|
#include <runFairMQDevice.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace example_n_m;
|
||||||
|
namespace bpo = boost::program_options;
|
||||||
|
|
||||||
|
class Sender : public FairMQDevice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Sender()
|
||||||
|
: fNumReceivers(0)
|
||||||
|
, fIndex(0)
|
||||||
|
, fSubtimeframeSize(10000)
|
||||||
|
{}
|
||||||
|
|
||||||
|
~Sender() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void InitTask() override
|
||||||
|
{
|
||||||
|
fIndex = GetConfig()->GetProperty<int>("sender-index");
|
||||||
|
fSubtimeframeSize = GetConfig()->GetProperty<int>("subtimeframe-size");
|
||||||
|
fNumReceivers = GetConfig()->GetProperty<int>("num-receivers");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Run() override
|
||||||
|
{
|
||||||
|
FairMQChannel& dataInChannel = fChannels.at("sync").at(0);
|
||||||
|
|
||||||
|
while (!NewStatePending()) {
|
||||||
|
Header h;
|
||||||
|
FairMQMessagePtr id(NewMessage());
|
||||||
|
if (dataInChannel.Receive(id) > 0) {
|
||||||
|
h.id = *(static_cast<uint16_t*>(id->GetData()));
|
||||||
|
h.senderIndex = fIndex;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FairMQParts parts;
|
||||||
|
parts.AddPart(NewSimpleMessage(h));
|
||||||
|
parts.AddPart(NewMessage(fSubtimeframeSize));
|
||||||
|
|
||||||
|
uint64_t currentDataId = h.id;
|
||||||
|
int direction = currentDataId % fNumReceivers;
|
||||||
|
|
||||||
|
if (Send(parts, "data", direction, 0) < 0) {
|
||||||
|
LOG(debug) << "Failed to queue Subtimeframe #" << currentDataId << " to Receiver[" << direction << "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int fNumReceivers;
|
||||||
|
unsigned int fIndex;
|
||||||
|
int fSubtimeframeSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
void addCustomOptions(bpo::options_description& options)
|
||||||
|
{
|
||||||
|
options.add_options()
|
||||||
|
("sender-index", bpo::value<int>()->default_value(0), "Sender Index")
|
||||||
|
("subtimeframe-size", bpo::value<int>()->default_value(1000), "Subtimeframe size in bytes")
|
||||||
|
("num-receivers", bpo::value<int>()->required(), "Number of EPNs");
|
||||||
|
}
|
||||||
|
FairMQDevice* getDevice(const FairMQProgOptions& /* config */) { return new Sender(); }
|
46
examples/n-m/runSynchronizer.cxx
Normal file
46
examples/n-m/runSynchronizer.cxx
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
* Copyright (C) 2020 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 <FairMQDevice.h>
|
||||||
|
#include <runFairMQDevice.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
namespace bpo = boost::program_options;
|
||||||
|
|
||||||
|
class Synchronizer : public FairMQDevice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Synchronizer()
|
||||||
|
: fTimeframeId(0)
|
||||||
|
{}
|
||||||
|
~Synchronizer() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool ConditionalRun() override
|
||||||
|
{
|
||||||
|
FairMQMessagePtr msg(NewSimpleMessage(fTimeframeId));
|
||||||
|
|
||||||
|
if (Send(msg, "sync") > 0) {
|
||||||
|
if (++fTimeframeId == UINT16_MAX - 1) {
|
||||||
|
fTimeframeId = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t fTimeframeId;
|
||||||
|
};
|
||||||
|
|
||||||
|
void addCustomOptions(bpo::options_description& /* options */) {}
|
||||||
|
FairMQDevice* getDevice(const FairMQProgOptions& /* config */) { return new Synchronizer(); }
|
71
examples/qc/CMakeLists.txt
Normal file
71
examples/qc/CMakeLists.txt
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
################################################################################
|
||||||
|
# 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_executable(fairmq-ex-qc-sampler runSampler.cxx)
|
||||||
|
target_link_libraries(fairmq-ex-qc-sampler PRIVATE FairMQ)
|
||||||
|
|
||||||
|
add_executable(fairmq-ex-qc-dispatcher runQCDispatcher.cxx)
|
||||||
|
target_link_libraries(fairmq-ex-qc-dispatcher PRIVATE FairMQ)
|
||||||
|
|
||||||
|
add_executable(fairmq-ex-qc-task runQCTask.cxx)
|
||||||
|
target_link_libraries(fairmq-ex-qc-task PRIVATE FairMQ)
|
||||||
|
|
||||||
|
add_executable(fairmq-ex-qc-sink runSink.cxx)
|
||||||
|
target_link_libraries(fairmq-ex-qc-sink PRIVATE FairMQ)
|
||||||
|
|
||||||
|
add_custom_target(ExampleQC DEPENDS fairmq-ex-qc-sampler fairmq-ex-qc-dispatcher fairmq-ex-qc-task fairmq-ex-qc-sink)
|
||||||
|
|
||||||
|
list(JOIN Boost_LIBRARY_DIRS ":" LIB_DIR)
|
||||||
|
set(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/fairmq/sdk)
|
||||||
|
set(DATA_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-qc-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-qc-topology.xml @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-ex-qc-env.sh ${CMAKE_CURRENT_BINARY_DIR}/fairmq-ex-qc-env.sh @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-qc.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-qc.sh @ONLY)
|
||||||
|
|
||||||
|
# test
|
||||||
|
if(DDS_FOUND)
|
||||||
|
add_test(NAME Example.QC.localhost COMMAND ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-qc.sh localhost)
|
||||||
|
set_tests_properties(Example.QC.localhost PROPERTIES TIMEOUT 15 RUN_SERIAL true PASS_REGULAR_EXPRESSION "Example successful")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# install
|
||||||
|
install(
|
||||||
|
TARGETS
|
||||||
|
fairmq-ex-qc-sampler
|
||||||
|
fairmq-ex-qc-dispatcher
|
||||||
|
fairmq-ex-qc-task
|
||||||
|
fairmq-ex-qc-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(BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
||||||
|
set(DATA_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_DATADIR})
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-qc-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-qc-topology.xml_install @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-ex-qc-env.sh ${CMAKE_CURRENT_BINARY_DIR}/fairmq-ex-qc-env.sh_install @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-qc.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-qc.sh_install @ONLY)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-qc-topology.xml_install
|
||||||
|
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
||||||
|
RENAME ex-qc-topology.xml
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-ex-qc-env.sh_install
|
||||||
|
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
|
RENAME fairmq-ex-qc-env.sh
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-qc.sh_install
|
||||||
|
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
|
RENAME fairmq-start-ex-qc.sh
|
||||||
|
)
|
4
examples/qc/README.md
Normal file
4
examples/qc/README.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
QC
|
||||||
|
==
|
||||||
|
|
||||||
|
A topology consisting of 4 devices - Sampler, QCDispatcher, QCTask and Sink. The data flows from Sampler through QCDispatcher to Sink. On demand - by setting the corresponding configuration property - the QCDispatcher device will duplicate the data to the QCTask device. The property is set by the topology controller, in this example this is the `fairmq-dds-command-ui` utility.
|
48
examples/qc/ex-qc-topology.xml
Normal file
48
examples/qc/ex-qc-topology.xml
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<topology name="ExampleQC">
|
||||||
|
|
||||||
|
<property name="fmqchan_data1" />
|
||||||
|
<property name="fmqchan_data2" />
|
||||||
|
<property name="fmqchan_qc" />
|
||||||
|
|
||||||
|
<decltask name="Sampler">
|
||||||
|
<exe>fairmq-ex-qc-sampler --color false --channel-config name=data1,type=push,method=bind -P dds --max-iterations 1000</exe>
|
||||||
|
<env reachable="false">fairmq-ex-qc-env.sh</env>
|
||||||
|
<properties>
|
||||||
|
<name access="write">fmqchan_data1</name>
|
||||||
|
</properties>
|
||||||
|
</decltask>
|
||||||
|
|
||||||
|
<decltask name="QCDispatcher">
|
||||||
|
<exe>fairmq-ex-qc-dispatcher --color false --channel-config name=data1,type=pull,method=connect name=data2,type=push,method=connect name=qc,type=push,method=connect -P dds</exe>
|
||||||
|
<env reachable="false">fairmq-ex-qc-env.sh</env>
|
||||||
|
<properties>
|
||||||
|
<name access="read">fmqchan_data1</name>
|
||||||
|
<name access="read">fmqchan_data2</name>
|
||||||
|
<name access="read">fmqchan_qc</name>
|
||||||
|
</properties>
|
||||||
|
</decltask>
|
||||||
|
|
||||||
|
<decltask name="QCTask">
|
||||||
|
<exe>fairmq-ex-qc-task --color false --channel-config name=qc,type=pull,method=bind -P dds</exe>
|
||||||
|
<env reachable="false">fairmq-ex-qc-env.sh</env>
|
||||||
|
<properties>
|
||||||
|
<name access="write">fmqchan_qc</name>
|
||||||
|
</properties>
|
||||||
|
</decltask>
|
||||||
|
|
||||||
|
<decltask name="Sink">
|
||||||
|
<exe>fairmq-ex-qc-sink --color false --channel-config name=data2,type=pull,method=bind -P dds --max-iterations 1000</exe>
|
||||||
|
<env reachable="false">fairmq-ex-qc-env.sh</env>
|
||||||
|
<properties>
|
||||||
|
<name access="write">fmqchan_data2</name>
|
||||||
|
</properties>
|
||||||
|
</decltask>
|
||||||
|
|
||||||
|
<main name="main">
|
||||||
|
<task>Sampler</task>
|
||||||
|
<task>QCDispatcher</task>
|
||||||
|
<task>QCTask</task>
|
||||||
|
<task>Sink</task>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
</topology>
|
16
examples/qc/fairmq-ex-qc-env.sh
Executable file
16
examples/qc/fairmq-ex-qc-env.sh
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Copyright (C) 2019 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" #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
export PATH=@BIN_DIR@:$PATH
|
||||||
|
|
||||||
|
OS=$(uname -s 2>&1)
|
||||||
|
if [ "$OS" == "Darwin" ]; then
|
||||||
|
export DYLD_LIBRARY_PATH=@LIB_DIR@:$DYLD_LIBRARY_PATH
|
||||||
|
fi
|
82
examples/qc/fairmq-start-ex-qc.sh.in
Executable file
82
examples/qc/fairmq-start-ex-qc.sh.in
Executable file
@@ -0,0 +1,82 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Copyright (C) 2019 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" #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# fairmq-start-ex-qc.sh -> submit agents with localhost plugin
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
dds-session stop $1
|
||||||
|
echo "CLEANUP PERFORMED"
|
||||||
|
}
|
||||||
|
|
||||||
|
source @DDS_INSTALL_PREFIX@/DDS_env.sh
|
||||||
|
export PATH=@BIN_DIR@:$PATH
|
||||||
|
|
||||||
|
exec 5>&1
|
||||||
|
output=$(dds-session start | tee >(cat - >&5))
|
||||||
|
export DDS_SESSION_ID=$(echo ${output} | grep "DDS session ID: " | cut -d' ' -f4)
|
||||||
|
echo "SESSION ID: ${DDS_SESSION_ID}"
|
||||||
|
|
||||||
|
trap "cleanup ${DDS_SESSION_ID}" EXIT
|
||||||
|
|
||||||
|
requiredNofSlots=4
|
||||||
|
dds-submit -r localhost --slots ${requiredNofSlots}
|
||||||
|
echo "...waiting for ${requiredNofSlots} idle slots..."
|
||||||
|
dds-info --idle-count --wait ${requiredNofSlots}
|
||||||
|
|
||||||
|
export FAIRMQ_DDS_TOPO_FILE=@DATA_DIR@/ex-qc-topology.xml
|
||||||
|
echo "TOPOLOGY FILE: ${FAIRMQ_DDS_TOPO_FILE}"
|
||||||
|
echo "TOPOLOGY NAME: $(dds-topology --disable-validation --topology-name ${FAIRMQ_DDS_TOPO_FILE})"
|
||||||
|
|
||||||
|
dds-info --active-topology
|
||||||
|
dds-topology --activate ${FAIRMQ_DDS_TOPO_FILE}
|
||||||
|
dds-info --active-topology
|
||||||
|
echo "...waiting for ${requiredNofSlots} executing slots..."
|
||||||
|
dds-info --executing-count --wait ${requiredNofSlots}
|
||||||
|
|
||||||
|
echo "------------------------"
|
||||||
|
echo "...waiting for Topology to finish..."
|
||||||
|
# TODO Retrieve number of devices from DDS topology API instead of having the user pass it explicitely
|
||||||
|
fairmq-dds-command-ui -w "IDLE"
|
||||||
|
fairmq-dds-command-ui -c i
|
||||||
|
fairmq-dds-command-ui -c k
|
||||||
|
fairmq-dds-command-ui -c b
|
||||||
|
fairmq-dds-command-ui -c x
|
||||||
|
fairmq-dds-command-ui -c j
|
||||||
|
allexceptqctasks="main/(Sampler|QCDispatcher|Sink).*"
|
||||||
|
fairmq-dds-command-ui -c r -p $allexceptqctasks
|
||||||
|
qctask="main/QCTask.*"
|
||||||
|
qcdispatcher="main/QCDispatcher.*"
|
||||||
|
fairmq-dds-command-ui -c p --property-key qc --property-value active -p $qcdispatcher
|
||||||
|
fairmq-dds-command-ui -c r -p $qctask
|
||||||
|
fairmq-dds-command-ui -w "RUNNING->READY" -p $qctask
|
||||||
|
echo "...$qctask received data and transitioned to READY, sending shutdown..."
|
||||||
|
fairmq-dds-command-ui -c s
|
||||||
|
fairmq-dds-command-ui -c t
|
||||||
|
fairmq-dds-command-ui -c d
|
||||||
|
fairmq-dds-command-ui -c q
|
||||||
|
echo "...waiting for ${requiredNofSlots} idle slots..."
|
||||||
|
dds-info --idle-count --wait ${requiredNofSlots}
|
||||||
|
echo "------------------------"
|
||||||
|
|
||||||
|
dds-info --active-topology
|
||||||
|
dds-topology --stop
|
||||||
|
dds-info --active-topology
|
||||||
|
|
||||||
|
dds-agent-cmd getlog -a
|
||||||
|
logDir="${wrkDir}/logs"
|
||||||
|
for file in $(find "${logDir}" -name "*.tar.gz"); do tar -xf ${file} -C "${logDir}" ; done
|
||||||
|
echo "AGENT LOG FILES IN: ${logDir}"
|
||||||
|
|
||||||
|
# This string is used by ctest to detect success
|
||||||
|
echo "Example successful :)"
|
||||||
|
|
||||||
|
# Cleanup function is called by EXIT trap
|
59
examples/qc/runQCDispatcher.cxx
Normal file
59
examples/qc/runQCDispatcher.cxx
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
* 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 "FairMQDevice.h"
|
||||||
|
|
||||||
|
class QCDispatcher : public FairMQDevice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QCDispatcher()
|
||||||
|
: fDoQC(false)
|
||||||
|
{
|
||||||
|
OnData("data1", &QCDispatcher::HandleData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitTask() override
|
||||||
|
{
|
||||||
|
GetConfig()->Subscribe<std::string>("qcdevice", [&](const std::string& key, std::string value) {
|
||||||
|
if (key == "qc") {
|
||||||
|
if (value == "active") {
|
||||||
|
fDoQC.store(true);
|
||||||
|
} else if (value == "inactive") {
|
||||||
|
fDoQC.store(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool HandleData(FairMQMessagePtr& msg, int)
|
||||||
|
{
|
||||||
|
if (fDoQC.load() == true) {
|
||||||
|
FairMQMessagePtr msgCopy(NewMessage());
|
||||||
|
msgCopy->Copy(*msg);
|
||||||
|
if (Send(msg, "qc") < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Send(msg, "data2") < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetTask() override { GetConfig()->Unsubscribe<std::string>("qcdevice"); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::atomic<bool> fDoQC;
|
||||||
|
};
|
||||||
|
|
||||||
|
void addCustomOptions(boost::program_options::options_description& /*options*/) {}
|
||||||
|
FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new QCDispatcher(); }
|
26
examples/qc/runQCTask.cxx
Normal file
26
examples/qc/runQCTask.cxx
Normal file
@@ -0,0 +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, *
|
||||||
|
* copied verbatim in the file "LICENSE" *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include "runFairMQDevice.h"
|
||||||
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
|
class QCTask : public FairMQDevice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QCTask()
|
||||||
|
{
|
||||||
|
OnData("qc", [](FairMQMessagePtr& /*msg*/, int) {
|
||||||
|
LOG(info) << "received data";
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace bpo = boost::program_options;
|
||||||
|
void addCustomOptions(bpo::options_description& /*options*/) {}
|
||||||
|
FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new QCTask(); }
|
36
examples/qc/runSampler.cxx
Normal file
36
examples/qc/runSampler.cxx
Normal file
@@ -0,0 +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, *
|
||||||
|
* copied verbatim in the file "LICENSE" *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include "runFairMQDevice.h"
|
||||||
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
|
#include <thread> // this_thread::sleep_for
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
class Sampler : public FairMQDevice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Sampler() {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool ConditionalRun()
|
||||||
|
{
|
||||||
|
FairMQMessagePtr msg(NewMessage(1000));
|
||||||
|
|
||||||
|
if (Send(msg, "data1") < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace bpo = boost::program_options;
|
||||||
|
void addCustomOptions(bpo::options_description&) {}
|
||||||
|
FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new Sampler(); }
|
@@ -6,30 +6,20 @@
|
|||||||
* copied verbatim in the file "LICENSE" *
|
* copied verbatim in the file "LICENSE" *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include "FairMQUnmanagedRegionZMQ.h"
|
#include "runFairMQDevice.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
using namespace std;
|
#include <string>
|
||||||
|
|
||||||
FairMQUnmanagedRegionZMQ::FairMQUnmanagedRegionZMQ(const size_t size, FairMQRegionCallback callback, const std::string& /* path = "" */, int /* flags = 0 */)
|
class Sink : public FairMQDevice
|
||||||
: fBuffer(malloc(size))
|
|
||||||
, fSize(size)
|
|
||||||
, fCallback(callback)
|
|
||||||
{
|
{
|
||||||
}
|
public:
|
||||||
|
Sink() { OnData("data2", &Sink::HandleData); }
|
||||||
|
|
||||||
void* FairMQUnmanagedRegionZMQ::GetData() const
|
protected:
|
||||||
{
|
bool HandleData(FairMQMessagePtr& /*msg*/, int /*index*/) { return true; }
|
||||||
return fBuffer;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
size_t FairMQUnmanagedRegionZMQ::GetSize() const
|
namespace bpo = boost::program_options;
|
||||||
{
|
void addCustomOptions(bpo::options_description&) {}
|
||||||
return fSize;
|
FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new Sink(); }
|
||||||
}
|
|
||||||
|
|
||||||
FairMQUnmanagedRegionZMQ::~FairMQUnmanagedRegionZMQ()
|
|
||||||
{
|
|
||||||
LOG(debug) << "destroying region";
|
|
||||||
free(fBuffer);
|
|
||||||
}
|
|
@@ -37,10 +37,10 @@ class Readout : public FairMQDevice
|
|||||||
fRegion = FairMQUnmanagedRegionPtr(NewUnmanagedRegionFor("rb",
|
fRegion = FairMQUnmanagedRegionPtr(NewUnmanagedRegionFor("rb",
|
||||||
0,
|
0,
|
||||||
10000000,
|
10000000,
|
||||||
[this](void* /*data*/, size_t /*size*/, void* /*hint*/) { // callback to be called when message buffers no longer needed by transport
|
[this](const std::vector<fair::mq::RegionBlock>& blocks) { // callback to be called when message buffers no longer needed by transport
|
||||||
--fNumUnackedMsgs;
|
fNumUnackedMsgs -= blocks.size();
|
||||||
if (fMaxIterations > 0) {
|
if (fMaxIterations > 0) {
|
||||||
LOG(debug) << "Received ack";
|
LOG(debug) << "Received " << blocks.size() << " acks";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
@@ -32,15 +32,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-region.sh.in ${CMAKE_
|
|||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-region.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-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.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-region.sh zeromq)
|
add_test(NAME Example.Region.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-region.sh zeromq)
|
||||||
set_tests_properties(Example.Region.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received ack")
|
set_tests_properties(Example.Region.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received [0-9*] acks")
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
add_test(NAME Example.Region.nanomsg COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-region.sh nanomsg)
|
|
||||||
set_tests_properties(Example.Region.nanomsg PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received ack")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_test(NAME Example.Region.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-region.sh shmem)
|
add_test(NAME Example.Region.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-region.sh shmem)
|
||||||
set_tests_properties(Example.Region.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received ack")
|
set_tests_properties(Example.Region.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received [0-9*] acks")
|
||||||
|
|
||||||
# install
|
# install
|
||||||
|
|
||||||
|
@@ -23,28 +23,41 @@ namespace example_region
|
|||||||
|
|
||||||
Sampler::Sampler()
|
Sampler::Sampler()
|
||||||
: fMsgSize(10000)
|
: fMsgSize(10000)
|
||||||
|
, fLinger(100)
|
||||||
, fMaxIterations(0)
|
, fMaxIterations(0)
|
||||||
, fNumIterations(0)
|
, fNumIterations(0)
|
||||||
, fRegion(nullptr)
|
, fRegion(nullptr)
|
||||||
, fNumUnackedMsgs(0)
|
, fNumUnackedMsgs(0)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
void Sampler::InitTask()
|
void Sampler::InitTask()
|
||||||
{
|
{
|
||||||
fMsgSize = fConfig->GetProperty<int>("msg-size");
|
fMsgSize = fConfig->GetProperty<int>("msg-size");
|
||||||
|
fLinger = fConfig->GetProperty<uint32_t>("region-linger");
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
|
|
||||||
|
fChannels.at("data").at(0).Transport()->SubscribeToRegionEvents([](FairMQRegionInfo info) {
|
||||||
|
LOG(info) << "Region event: " << info.event
|
||||||
|
<< ", managed: " << info.managed
|
||||||
|
<< ", id: " << info.id
|
||||||
|
<< ", ptr: " << info.ptr
|
||||||
|
<< ", size: " << info.size
|
||||||
|
<< ", flags: " << info.flags;
|
||||||
|
});
|
||||||
|
|
||||||
fRegion = FairMQUnmanagedRegionPtr(NewUnmanagedRegionFor("data",
|
fRegion = FairMQUnmanagedRegionPtr(NewUnmanagedRegionFor("data",
|
||||||
0,
|
0,
|
||||||
10000000,
|
10000000,
|
||||||
[this](void* /*data*/, size_t /*size*/, void* /*hint*/) { // callback to be called when message buffers no longer needed by transport
|
[this](const std::vector<fair::mq::RegionBlock>& blocks) { // callback to be called when message buffers no longer needed by transport
|
||||||
--fNumUnackedMsgs;
|
lock_guard<mutex> lock(fMtx);
|
||||||
|
fNumUnackedMsgs -= blocks.size();
|
||||||
|
|
||||||
if (fMaxIterations > 0) {
|
if (fMaxIterations > 0) {
|
||||||
LOG(debug) << "Received ack";
|
LOG(info) << "Received " << blocks.size() << " acks";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
fRegion->SetLinger(fLinger);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sampler::ConditionalRun()
|
bool Sampler::ConditionalRun()
|
||||||
@@ -61,27 +74,31 @@ bool Sampler::ConditionalRun()
|
|||||||
// LOG(info) << "check: " << static_cast<char*>(fRegion->GetData())[3];
|
// LOG(info) << "check: " << static_cast<char*>(fRegion->GetData())[3];
|
||||||
// std::this_thread::sleep_for(std::chrono::seconds(1));
|
// std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
|
||||||
|
lock_guard<mutex> lock(fMtx);
|
||||||
if (Send(msg, "data", 0) > 0) {
|
if (Send(msg, "data", 0) > 0) {
|
||||||
++fNumUnackedMsgs;
|
|
||||||
|
|
||||||
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
||||||
LOG(info) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
|
LOG(info) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++fNumUnackedMsgs;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sampler::ResetTask()
|
void Sampler::ResetTask()
|
||||||
{
|
{
|
||||||
// if not all messages acknowledged, wait for a bit. But only once, since receiver could be already dead.
|
// On destruction UnmanagedRegion will try to TODO
|
||||||
if (fNumUnackedMsgs != 0) {
|
|
||||||
LOG(debug) << "waiting for all acknowledgements... (" << fNumUnackedMsgs << ")";
|
|
||||||
this_thread::sleep_for(chrono::milliseconds(500));
|
|
||||||
LOG(debug) << "done, still unacked: " << fNumUnackedMsgs;
|
|
||||||
}
|
|
||||||
fRegion.reset();
|
fRegion.reset();
|
||||||
|
{
|
||||||
|
lock_guard<mutex> lock(fMtx);
|
||||||
|
if (fNumUnackedMsgs != 0) {
|
||||||
|
LOG(info) << "Done, still not acknowledged: " << fNumUnackedMsgs;
|
||||||
|
} else {
|
||||||
|
LOG(info) << "All acknowledgements received.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fChannels.at("data").at(0).Transport()->UnsubscribeFromRegionEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
Sampler::~Sampler()
|
Sampler::~Sampler()
|
||||||
|
@@ -15,7 +15,8 @@
|
|||||||
#ifndef FAIRMQEXAMPLEREGIONSAMPLER_H
|
#ifndef FAIRMQEXAMPLEREGIONSAMPLER_H
|
||||||
#define FAIRMQEXAMPLEREGIONSAMPLER_H
|
#define FAIRMQEXAMPLEREGIONSAMPLER_H
|
||||||
|
|
||||||
#include <atomic>
|
#include <mutex>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
@@ -35,10 +36,12 @@ class Sampler : public FairMQDevice
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int fMsgSize;
|
int fMsgSize;
|
||||||
|
uint32_t fLinger;
|
||||||
uint64_t fMaxIterations;
|
uint64_t fMaxIterations;
|
||||||
uint64_t fNumIterations;
|
uint64_t fNumIterations;
|
||||||
FairMQUnmanagedRegionPtr fRegion;
|
FairMQUnmanagedRegionPtr fRegion;
|
||||||
std::atomic<uint64_t> fNumUnackedMsgs;
|
std::mutex fMtx;
|
||||||
|
uint64_t fNumUnackedMsgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace example_region
|
} // namespace example_region
|
||||||
|
@@ -29,6 +29,14 @@ void Sink::InitTask()
|
|||||||
{
|
{
|
||||||
// Get the fMaxIterations value from the command line options (via fConfig)
|
// Get the fMaxIterations value from the command line options (via fConfig)
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
|
fChannels.at("data").at(0).Transport()->SubscribeToRegionEvents([](FairMQRegionInfo info) {
|
||||||
|
LOG(info) << "Region event: " << info.event
|
||||||
|
<< ", managed: " << info.managed
|
||||||
|
<< ", id: " << info.id
|
||||||
|
<< ", ptr: " << info.ptr
|
||||||
|
<< ", size: " << info.size
|
||||||
|
<< ", flags: " << info.flags;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sink::Run()
|
void Sink::Run()
|
||||||
@@ -50,6 +58,11 @@ void Sink::Run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sink::ResetTask()
|
||||||
|
{
|
||||||
|
fChannels.at("data").at(0).Transport()->UnsubscribeFromRegionEvents();
|
||||||
|
}
|
||||||
|
|
||||||
Sink::~Sink()
|
Sink::~Sink()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ class Sink : public FairMQDevice
|
|||||||
protected:
|
protected:
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
virtual void InitTask();
|
virtual void InitTask();
|
||||||
|
virtual void ResetTask();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t fMaxIterations;
|
uint64_t fMaxIterations;
|
||||||
|
@@ -15,6 +15,7 @@ void addCustomOptions(bpo::options_description& options)
|
|||||||
{
|
{
|
||||||
options.add_options()
|
options.add_options()
|
||||||
("msg-size", bpo::value<int>()->default_value(1000), "Message size in bytes")
|
("msg-size", bpo::value<int>()->default_value(1000), "Message size in bytes")
|
||||||
|
("region-linger", bpo::value<uint32_t>()->default_value(100), "Linger period for regions")
|
||||||
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,9 +19,11 @@ SAMPLER+=" --id sampler1"
|
|||||||
SAMPLER+=" --transport $transport"
|
SAMPLER+=" --transport $transport"
|
||||||
SAMPLER+=" --severity debug"
|
SAMPLER+=" --severity debug"
|
||||||
SAMPLER+=" --session $SESSION"
|
SAMPLER+=" --session $SESSION"
|
||||||
|
SAMPLER+=" --verbosity veryhigh"
|
||||||
SAMPLER+=" --control static --color false"
|
SAMPLER+=" --control static --color false"
|
||||||
SAMPLER+=" --max-iterations 1"
|
SAMPLER+=" --max-iterations 1"
|
||||||
SAMPLER+=" --msg-size $msgSize"
|
SAMPLER+=" --msg-size $msgSize"
|
||||||
|
SAMPLER+=" --region-linger 500"
|
||||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://127.0.0.1:7777"
|
SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://127.0.0.1:7777"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||||
SAMPLER_PID=$!
|
SAMPLER_PID=$!
|
||||||
|
@@ -35,11 +35,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-req-rep.sh.in ${CMAKE_CURRENT
|
|||||||
add_test(NAME Example.ReqRep.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-req-rep.sh zeromq)
|
add_test(NAME Example.ReqRep.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-req-rep.sh zeromq)
|
||||||
set_tests_properties(Example.ReqRep.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received reply from server: ")
|
set_tests_properties(Example.ReqRep.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received reply from server: ")
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
add_test(NAME Example.ReqRep.nanomsg COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-req-rep.sh nanomsg)
|
|
||||||
set_tests_properties(Example.ReqRep.nanomsg PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received reply from server: ")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_test(NAME Example.ReqRep.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-req-rep.sh shmem)
|
add_test(NAME Example.ReqRep.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-req-rep.sh shmem)
|
||||||
set_tests_properties(Example.ReqRep.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received reply from server: ")
|
set_tests_properties(Example.ReqRep.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received reply from server: ")
|
||||||
|
|
||||||
|
1
extern/PicoSHA2
vendored
Submodule
1
extern/PicoSHA2
vendored
Submodule
Submodule extern/PicoSHA2 added at 599843c396
@@ -6,16 +6,6 @@
|
|||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
####################
|
|
||||||
# external plugins #
|
|
||||||
####################
|
|
||||||
if(BUILD_DDS_PLUGIN)
|
|
||||||
add_subdirectory(plugins/DDS)
|
|
||||||
endif()
|
|
||||||
if(BUILD_PMIX_PLUGIN)
|
|
||||||
add_subdirectory(plugins/PMIx)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_FAIRMQ OR BUILD_SDK)
|
if(BUILD_FAIRMQ OR BUILD_SDK)
|
||||||
###########
|
###########
|
||||||
# Version #
|
# Version #
|
||||||
@@ -180,43 +170,29 @@ if(BUILD_FAIRMQ)
|
|||||||
PluginManager.h
|
PluginManager.h
|
||||||
PluginServices.h
|
PluginServices.h
|
||||||
runFairMQDevice.h
|
runFairMQDevice.h
|
||||||
|
shmem/Monitor.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FAIRMQ_PRIVATE_HEADER_FILES
|
set(FAIRMQ_PRIVATE_HEADER_FILES
|
||||||
devices/FairMQBenchmarkSampler.h
|
|
||||||
devices/FairMQMerger.h
|
|
||||||
devices/FairMQMultiplier.h
|
|
||||||
devices/FairMQProxy.h
|
|
||||||
devices/FairMQSink.h
|
|
||||||
devices/FairMQSplitter.h
|
|
||||||
plugins/Builtin.h
|
plugins/Builtin.h
|
||||||
plugins/config/Config.h
|
plugins/config/Config.h
|
||||||
plugins/Control.h
|
plugins/Control.h
|
||||||
shmem/FairMQMessageSHM.h
|
shmem/Message.h
|
||||||
shmem/FairMQPollerSHM.h
|
shmem/Poller.h
|
||||||
shmem/FairMQUnmanagedRegionSHM.h
|
shmem/UnmanagedRegion.h
|
||||||
shmem/FairMQSocketSHM.h
|
shmem/Socket.h
|
||||||
shmem/FairMQTransportFactorySHM.h
|
shmem/TransportFactory.h
|
||||||
shmem/Common.h
|
shmem/Common.h
|
||||||
shmem/Manager.h
|
shmem/Manager.h
|
||||||
shmem/Region.h
|
shmem/Region.h
|
||||||
zeromq/FairMQMessageZMQ.h
|
zeromq/Context.h
|
||||||
zeromq/FairMQPollerZMQ.h
|
zeromq/Message.h
|
||||||
zeromq/FairMQUnmanagedRegionZMQ.h
|
zeromq/Poller.h
|
||||||
zeromq/FairMQSocketZMQ.h
|
zeromq/UnmanagedRegion.h
|
||||||
zeromq/FairMQTransportFactoryZMQ.h
|
zeromq/Socket.h
|
||||||
|
zeromq/TransportFactory.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
set(FAIRMQ_PRIVATE_HEADER_FILES ${FAIRMQ_PRIVATE_HEADER_FILES}
|
|
||||||
nanomsg/FairMQMessageNN.h
|
|
||||||
nanomsg/FairMQPollerNN.h
|
|
||||||
nanomsg/FairMQUnmanagedRegionNN.h
|
|
||||||
nanomsg/FairMQSocketNN.h
|
|
||||||
nanomsg/FairMQTransportFactoryNN.h
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
if(BUILD_OFI_TRANSPORT)
|
||||||
set(FAIRMQ_PRIVATE_HEADER_FILES ${FAIRMQ_PRIVATE_HEADER_FILES}
|
set(FAIRMQ_PRIVATE_HEADER_FILES ${FAIRMQ_PRIVATE_HEADER_FILES}
|
||||||
ofi/Context.h
|
ofi/Context.h
|
||||||
@@ -239,11 +215,6 @@ if(BUILD_FAIRMQ)
|
|||||||
FairMQPoller.cxx
|
FairMQPoller.cxx
|
||||||
FairMQSocket.cxx
|
FairMQSocket.cxx
|
||||||
FairMQTransportFactory.cxx
|
FairMQTransportFactory.cxx
|
||||||
devices/FairMQBenchmarkSampler.cxx
|
|
||||||
devices/FairMQMerger.cxx
|
|
||||||
devices/FairMQMultiplier.cxx
|
|
||||||
devices/FairMQProxy.cxx
|
|
||||||
devices/FairMQSplitter.cxx
|
|
||||||
Plugin.cxx
|
Plugin.cxx
|
||||||
PluginManager.cxx
|
PluginManager.cxx
|
||||||
PluginServices.cxx
|
PluginServices.cxx
|
||||||
@@ -253,31 +224,10 @@ if(BUILD_FAIRMQ)
|
|||||||
SuboptParser.cxx
|
SuboptParser.cxx
|
||||||
plugins/config/Config.cxx
|
plugins/config/Config.cxx
|
||||||
plugins/Control.cxx
|
plugins/Control.cxx
|
||||||
shmem/FairMQMessageSHM.cxx
|
|
||||||
shmem/FairMQPollerSHM.cxx
|
|
||||||
shmem/FairMQUnmanagedRegionSHM.cxx
|
|
||||||
shmem/FairMQSocketSHM.cxx
|
|
||||||
shmem/FairMQTransportFactorySHM.cxx
|
|
||||||
shmem/Manager.cxx
|
|
||||||
shmem/Region.cxx
|
|
||||||
zeromq/FairMQMessageZMQ.cxx
|
|
||||||
zeromq/FairMQPollerZMQ.cxx
|
|
||||||
zeromq/FairMQUnmanagedRegionZMQ.cxx
|
|
||||||
zeromq/FairMQSocketZMQ.cxx
|
|
||||||
zeromq/FairMQTransportFactoryZMQ.cxx
|
|
||||||
MemoryResources.cxx
|
MemoryResources.cxx
|
||||||
|
shmem/Monitor.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
set(FAIRMQ_SOURCE_FILES ${FAIRMQ_SOURCE_FILES}
|
|
||||||
nanomsg/FairMQMessageNN.cxx
|
|
||||||
nanomsg/FairMQPollerNN.cxx
|
|
||||||
nanomsg/FairMQUnmanagedRegionNN.cxx
|
|
||||||
nanomsg/FairMQSocketNN.cxx
|
|
||||||
nanomsg/FairMQTransportFactoryNN.cxx
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
if(BUILD_OFI_TRANSPORT)
|
||||||
set(FAIRMQ_SOURCE_FILES ${FAIRMQ_SOURCE_FILES}
|
set(FAIRMQ_SOURCE_FILES ${FAIRMQ_SOURCE_FILES}
|
||||||
ofi/Context.cxx
|
ofi/Context.cxx
|
||||||
@@ -318,8 +268,8 @@ if(BUILD_FAIRMQ)
|
|||||||
# preprocessor definitions #
|
# preprocessor definitions #
|
||||||
############################
|
############################
|
||||||
target_compile_definitions(${_target} PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
|
target_compile_definitions(${_target} PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
if(FAIRMQ_DEBUG_MODE)
|
||||||
target_compile_definitions(${_target} PRIVATE BUILD_NANOMSG_TRANSPORT)
|
target_compile_definitions(${_target} PUBLIC FAIRMQ_DEBUG_MODE)
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_OFI_TRANSPORT)
|
if(BUILD_OFI_TRANSPORT)
|
||||||
target_compile_definitions(${_target} PRIVATE BUILD_OFI_TRANSPORT)
|
target_compile_definitions(${_target} PRIVATE BUILD_OFI_TRANSPORT)
|
||||||
@@ -341,16 +291,13 @@ if(BUILD_FAIRMQ)
|
|||||||
##################
|
##################
|
||||||
# link libraries #
|
# link libraries #
|
||||||
##################
|
##################
|
||||||
if(BUILD_NANOMSG_TRANSPORT)
|
|
||||||
set(NANOMSG_DEPS nanomsg msgpackc-cxx)
|
|
||||||
endif()
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
if(BUILD_OFI_TRANSPORT)
|
||||||
set(OFI_DEPS
|
set(OFI_DEPS
|
||||||
asiofi::asiofi
|
asiofi::asiofi
|
||||||
Boost::container
|
Boost::container
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(optional_deps ${NANOMSG_DEPS} ${OFI_DEPS})
|
set(optional_deps ${OFI_DEPS})
|
||||||
if(optional_deps)
|
if(optional_deps)
|
||||||
list(REMOVE_DUPLICATES optional_deps)
|
list(REMOVE_DUPLICATES optional_deps)
|
||||||
endif()
|
endif()
|
||||||
@@ -373,7 +320,7 @@ if(BUILD_FAIRMQ)
|
|||||||
|
|
||||||
PRIVATE # only libFairMQ links against private dependencies
|
PRIVATE # only libFairMQ links against private dependencies
|
||||||
libzmq
|
libzmq
|
||||||
${NANOMSG_DEPS}
|
PicoSHA2
|
||||||
${OFI_DEPS}
|
${OFI_DEPS}
|
||||||
)
|
)
|
||||||
set_target_properties(${_target} PROPERTIES
|
set_target_properties(${_target} PROPERTIES
|
||||||
@@ -420,12 +367,17 @@ if(BUILD_FAIRMQ)
|
|||||||
|
|
||||||
add_executable(fairmq-shmmonitor shmem/Monitor.cxx shmem/Monitor.h shmem/runMonitor.cxx)
|
add_executable(fairmq-shmmonitor shmem/Monitor.cxx shmem/Monitor.h shmem/runMonitor.cxx)
|
||||||
target_compile_definitions(fairmq-shmmonitor PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
|
target_compile_definitions(fairmq-shmmonitor PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
|
||||||
|
if(FAIRMQ_DEBUG_MODE)
|
||||||
|
target_compile_definitions(fairmq-shmmonitor PUBLIC FAIRMQ_DEBUG_MODE)
|
||||||
|
endif()
|
||||||
target_link_libraries(fairmq-shmmonitor PUBLIC
|
target_link_libraries(fairmq-shmmonitor PUBLIC
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
$<$<PLATFORM_ID:Linux>:rt>
|
$<$<PLATFORM_ID:Linux>:rt>
|
||||||
Boost::boost
|
Boost::boost
|
||||||
Boost::date_time
|
Boost::date_time
|
||||||
Boost::program_options
|
Boost::program_options
|
||||||
|
FairLogger::FairLogger
|
||||||
|
PicoSHA2
|
||||||
)
|
)
|
||||||
target_include_directories(fairmq-shmmonitor PUBLIC
|
target_include_directories(fairmq-shmmonitor PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
|
||||||
@@ -473,3 +425,13 @@ endif()
|
|||||||
if(BUILD_SDK)
|
if(BUILD_SDK)
|
||||||
add_subdirectory(sdk)
|
add_subdirectory(sdk)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
####################
|
||||||
|
# external plugins #
|
||||||
|
####################
|
||||||
|
if(BUILD_DDS_PLUGIN)
|
||||||
|
add_subdirectory(plugins/DDS)
|
||||||
|
endif()
|
||||||
|
if(BUILD_PMIX_PLUGIN)
|
||||||
|
add_subdirectory(plugins/PMIx)
|
||||||
|
endif()
|
||||||
|
@@ -8,10 +8,14 @@
|
|||||||
|
|
||||||
#include "DeviceRunner.h"
|
#include "DeviceRunner.h"
|
||||||
|
|
||||||
#include <exception>
|
#include <fairmq/tools/Strings.h>
|
||||||
#include <fairmq/Tools.h>
|
#include <fairmq/tools/Version.h>
|
||||||
#include <fairmq/Version.h>
|
#include <fairmq/Version.h>
|
||||||
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace fair::mq;
|
using namespace fair::mq;
|
||||||
|
|
||||||
@@ -52,7 +56,9 @@ bool DeviceRunner::HandleGeneralOptions(const fair::mq::ProgOptions& config, boo
|
|||||||
fair::Logger::SetConsoleSeverity("nolog");
|
fair::Logger::SetConsoleSeverity("nolog");
|
||||||
} else {
|
} else {
|
||||||
fair::Logger::SetConsoleColor(color);
|
fair::Logger::SetConsoleColor(color);
|
||||||
fair::Logger::SetConsoleSeverity(severity);
|
if (severity != "") {
|
||||||
|
fair::Logger::SetConsoleSeverity(severity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (printLogo) {
|
if (printLogo) {
|
||||||
@@ -75,7 +81,7 @@ void DeviceRunner::SubscribeForConfigChange()
|
|||||||
fair::Logger::SetConsoleColor(val);
|
fair::Logger::SetConsoleColor(val);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fConfig.Subscribe<string>("device-runner", [&](const std::string& key, const std::string val) {
|
fConfig.Subscribe<string>("device-runner", [&](const std::string& key, const std::string& val) {
|
||||||
if (key == "severity") {
|
if (key == "severity") {
|
||||||
fair::Logger::SetConsoleSeverity(val);
|
fair::Logger::SetConsoleSeverity(val);
|
||||||
} else if (key == "file-severity") {
|
} else if (key == "file-severity") {
|
||||||
@@ -150,8 +156,8 @@ auto DeviceRunner::Run() -> int
|
|||||||
|
|
||||||
// Handle --version
|
// Handle --version
|
||||||
if (fConfig.Count("version")) {
|
if (fConfig.Count("version")) {
|
||||||
cout << "FairMQ version: " << FAIRMQ_GIT_VERSION << endl;
|
LOGV(info, verylow) << "FairMQ version: " << FAIRMQ_GIT_VERSION;
|
||||||
cout << "User device version: " << fDevice->GetVersion() << endl;
|
LOGV(info, verylow) << "User device version: " << fDevice->GetVersion();
|
||||||
fDevice->ChangeState(fair::mq::Transition::End);
|
fDevice->ChangeState(fair::mq::Transition::End);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
#include <fairmq/PluginManager.h>
|
#include <fairmq/PluginManager.h>
|
||||||
#include <fairmq/ProgOptions.h>
|
#include <fairmq/ProgOptions.h>
|
||||||
#include <FairMQDevice.h>
|
#include <FairMQDevice.h>
|
||||||
#include <FairMQLogger.h>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@@ -7,11 +7,15 @@
|
|||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include "FairMQChannel.h"
|
#include "FairMQChannel.h"
|
||||||
|
|
||||||
#include <fairmq/tools/Strings.h>
|
#include <fairmq/tools/Strings.h>
|
||||||
#include <fairmq/Properties.h>
|
#include <fairmq/Properties.h>
|
||||||
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp> // join/split
|
#include <boost/algorithm/string.hpp> // join/split
|
||||||
|
|
||||||
|
#include <cstddef> // size_t
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <random>
|
#include <random>
|
||||||
@@ -20,7 +24,7 @@ using namespace std;
|
|||||||
using namespace fair::mq;
|
using namespace fair::mq;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T GetPropertyOrDefault(const fair::mq::Properties& m, const string& k, const T& ifNotFound) noexcept
|
T GetPropertyOrDefault(const fair::mq::Properties& m, const string& k, const T& ifNotFound)
|
||||||
{
|
{
|
||||||
if (m.count(k)) {
|
if (m.count(k)) {
|
||||||
return boost::any_cast<T>(m.at(k));
|
return boost::any_cast<T>(m.at(k));
|
||||||
@@ -77,31 +81,30 @@ FairMQChannel::FairMQChannel(const string& name, const string& type, const strin
|
|||||||
, fPortRangeMin(DefaultPortRangeMin)
|
, fPortRangeMin(DefaultPortRangeMin)
|
||||||
, fPortRangeMax(DefaultPortRangeMax)
|
, fPortRangeMax(DefaultPortRangeMax)
|
||||||
, fAutoBind(DefaultAutoBind)
|
, fAutoBind(DefaultAutoBind)
|
||||||
, fIsValid(false)
|
, fValid(false)
|
||||||
, fMultipart(false)
|
, fMultipart(false)
|
||||||
, fModified(true)
|
{
|
||||||
, fReset(false)
|
// LOG(warn) << "Constructing channel '" << fName << "'";
|
||||||
, fMtx()
|
}
|
||||||
{}
|
|
||||||
|
|
||||||
FairMQChannel::FairMQChannel(const string& name, int index, const fair::mq::Properties& properties)
|
FairMQChannel::FairMQChannel(const string& name, int index, const fair::mq::Properties& properties)
|
||||||
: FairMQChannel(tools::ToString(name, "[", index, "]"), "unspecified", "unspecified", "unspecified", nullptr)
|
: FairMQChannel(tools::ToString(name, "[", index, "]"), "unspecified", "unspecified", "unspecified", nullptr)
|
||||||
{
|
{
|
||||||
string prefix(tools::ToString("chans.", name, ".", index, "."));
|
string prefix(tools::ToString("chans.", name, ".", index, "."));
|
||||||
|
|
||||||
fType = GetPropertyOrDefault(properties, string(prefix + "type"), fType);
|
fType = GetPropertyOrDefault(properties, string(prefix + "type"), std::string(DefaultType));
|
||||||
fMethod = GetPropertyOrDefault(properties, string(prefix + "method"), fMethod);
|
fMethod = GetPropertyOrDefault(properties, string(prefix + "method"), std::string(DefaultMethod));
|
||||||
fAddress = GetPropertyOrDefault(properties, string(prefix + "address"), fAddress);
|
fAddress = GetPropertyOrDefault(properties, string(prefix + "address"), std::string(DefaultAddress));
|
||||||
fTransportType = TransportTypes.at(GetPropertyOrDefault(properties, string(prefix + "transport"), TransportNames.at(fTransportType)));
|
fTransportType = TransportType(GetPropertyOrDefault(properties, string(prefix + "transport"), std::string(DefaultTransportName)));
|
||||||
fSndBufSize = GetPropertyOrDefault(properties, string(prefix + "sndBufSize"), fSndBufSize);
|
fSndBufSize = GetPropertyOrDefault(properties, string(prefix + "sndBufSize"), DefaultSndBufSize);
|
||||||
fRcvBufSize = GetPropertyOrDefault(properties, string(prefix + "rcvBufSize"), fRcvBufSize);
|
fRcvBufSize = GetPropertyOrDefault(properties, string(prefix + "rcvBufSize"), DefaultRcvBufSize);
|
||||||
fSndKernelSize = GetPropertyOrDefault(properties, string(prefix + "sndKernelSize"), fSndKernelSize);
|
fSndKernelSize = GetPropertyOrDefault(properties, string(prefix + "sndKernelSize"), DefaultSndKernelSize);
|
||||||
fRcvKernelSize = GetPropertyOrDefault(properties, string(prefix + "rcvKernelSize"), fRcvKernelSize);
|
fRcvKernelSize = GetPropertyOrDefault(properties, string(prefix + "rcvKernelSize"), DefaultRcvKernelSize);
|
||||||
fLinger = GetPropertyOrDefault(properties, string(prefix + "linger"), fLinger);
|
fLinger = GetPropertyOrDefault(properties, string(prefix + "linger"), DefaultLinger);
|
||||||
fRateLogging = GetPropertyOrDefault(properties, string(prefix + "rateLogging"), fRateLogging);
|
fRateLogging = GetPropertyOrDefault(properties, string(prefix + "rateLogging"), DefaultRateLogging);
|
||||||
fPortRangeMin = GetPropertyOrDefault(properties, string(prefix + "portRangeMin"), fPortRangeMin);
|
fPortRangeMin = GetPropertyOrDefault(properties, string(prefix + "portRangeMin"), DefaultPortRangeMin);
|
||||||
fPortRangeMax = GetPropertyOrDefault(properties, string(prefix + "portRangeMax"), fPortRangeMax);
|
fPortRangeMax = GetPropertyOrDefault(properties, string(prefix + "portRangeMax"), DefaultPortRangeMax);
|
||||||
fAutoBind = GetPropertyOrDefault(properties, string(prefix + "autoBind"), fAutoBind);
|
fAutoBind = GetPropertyOrDefault(properties, string(prefix + "autoBind"), DefaultAutoBind);
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQChannel::FairMQChannel(const FairMQChannel& chan)
|
FairMQChannel::FairMQChannel(const FairMQChannel& chan)
|
||||||
@@ -125,14 +128,16 @@ FairMQChannel::FairMQChannel(const FairMQChannel& chan, const string& newName)
|
|||||||
, fPortRangeMin(chan.fPortRangeMin)
|
, fPortRangeMin(chan.fPortRangeMin)
|
||||||
, fPortRangeMax(chan.fPortRangeMax)
|
, fPortRangeMax(chan.fPortRangeMax)
|
||||||
, fAutoBind(chan.fAutoBind)
|
, fAutoBind(chan.fAutoBind)
|
||||||
, fIsValid(false)
|
, fValid(false)
|
||||||
, fMultipart(chan.fMultipart)
|
, fMultipart(chan.fMultipart)
|
||||||
, fModified(chan.fModified)
|
|
||||||
, fReset(false)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FairMQChannel& FairMQChannel::operator=(const FairMQChannel& chan)
|
FairMQChannel& FairMQChannel::operator=(const FairMQChannel& chan)
|
||||||
{
|
{
|
||||||
|
if (this == &chan) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
fTransportFactory = nullptr;
|
fTransportFactory = nullptr;
|
||||||
fTransportType = chan.fTransportType;
|
fTransportType = chan.fTransportType;
|
||||||
fSocket = nullptr;
|
fSocket = nullptr;
|
||||||
@@ -149,349 +154,18 @@ FairMQChannel& FairMQChannel::operator=(const FairMQChannel& chan)
|
|||||||
fPortRangeMin = chan.fPortRangeMin;
|
fPortRangeMin = chan.fPortRangeMin;
|
||||||
fPortRangeMax = chan.fPortRangeMax;
|
fPortRangeMax = chan.fPortRangeMax;
|
||||||
fAutoBind = chan.fAutoBind;
|
fAutoBind = chan.fAutoBind;
|
||||||
fIsValid = false;
|
fValid = false;
|
||||||
fMultipart = chan.fMultipart;
|
fMultipart = chan.fMultipart;
|
||||||
fModified = chan.fModified;
|
|
||||||
fReset = false;
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQSocket & FairMQChannel::GetSocket() const
|
|
||||||
{
|
|
||||||
assert(fSocket);
|
|
||||||
return *fSocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
string FairMQChannel::GetName() const
|
|
||||||
{
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fName;
|
|
||||||
}
|
|
||||||
|
|
||||||
string FairMQChannel::GetPrefix() const
|
|
||||||
{
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
string prefix = fName;
|
|
||||||
prefix = prefix.erase(fName.rfind('['));
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
string FairMQChannel::GetIndex() const
|
|
||||||
{
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
string indexStr = fName;
|
|
||||||
indexStr.erase(indexStr.rfind(']'));
|
|
||||||
indexStr.erase(0, indexStr.rfind('[') + 1);
|
|
||||||
return indexStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
string FairMQChannel::GetType() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fType;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetType: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
string FairMQChannel::GetMethod() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fMethod;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetMethod: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
string FairMQChannel::GetAddress() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fAddress;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetAddress: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
string FairMQChannel::GetTransportName() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return TransportNames.at(fTransportType);
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetTransportName: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transport FairMQChannel::GetTransportType() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fTransportType;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetTransportType: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int FairMQChannel::GetSndBufSize() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fSndBufSize;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetSndBufSize: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int FairMQChannel::GetRcvBufSize() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fRcvBufSize;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetRcvBufSize: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int FairMQChannel::GetSndKernelSize() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fSndKernelSize;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetSndKernelSize: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int FairMQChannel::GetRcvKernelSize() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fRcvKernelSize;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetRcvKernelSize: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int FairMQChannel::GetLinger() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fLinger;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetLinger: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int FairMQChannel::GetRateLogging() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fRateLogging;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetRateLogging: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int FairMQChannel::GetPortRangeMin() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fPortRangeMin;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetPortRangeMin: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int FairMQChannel::GetPortRangeMax() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fPortRangeMax;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetPortRangeMax: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FairMQChannel::GetAutoBind() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fAutoBind;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::GetAutoBind: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateType(const string& type)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fType = type;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateType: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateMethod(const string& method)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fMethod = method;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateMethod: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateAddress(const string& address)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fAddress = address;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateAddress: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateTransport(const string& transport)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fTransportType = TransportTypes.at(transport);
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateTransport: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateSndBufSize(const int sndBufSize)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fSndBufSize = sndBufSize;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateSndBufSize: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateRcvBufSize(const int rcvBufSize)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fRcvBufSize = rcvBufSize;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateRcvBufSize: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateSndKernelSize(const int sndKernelSize)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fSndKernelSize = sndKernelSize;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateSndKernelSize: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateRcvKernelSize(const int rcvKernelSize)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fRcvKernelSize = rcvKernelSize;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateRcvKernelSize: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateLinger(const int duration)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fLinger = duration;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateLinger: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateRateLogging(const int rateLogging)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fRateLogging = rateLogging;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateRateLogging: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdatePortRangeMin(const int minPort)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fPortRangeMin = minPort;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdatePortRangeMin: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdatePortRangeMax(const int maxPort)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fPortRangeMax = maxPort;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdatePortRangeMax: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateAutoBind(const bool autobind)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fAutoBind = autobind;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateAutoBind: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto FairMQChannel::SetModified(const bool modified) -> void
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fModified = modified;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::SetModified: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQChannel::UpdateName(const string& name)
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
fName = name;
|
|
||||||
fModified = true;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::UpdateName: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FairMQChannel::IsValid() const
|
|
||||||
try {
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
return fIsValid;
|
|
||||||
} catch (exception& e) {
|
|
||||||
LOG(error) << "Exception caught in FairMQChannel::IsValid: " << e.what();
|
|
||||||
throw ChannelConfigurationError(tools::ToString("failed to acquire lock: ", e.what()));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FairMQChannel::Validate()
|
bool FairMQChannel::Validate()
|
||||||
try {
|
try {
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << "Validating channel '" << fName << "'... ";
|
ss << "Validating channel '" << fName << "'... ";
|
||||||
|
|
||||||
if (fIsValid) {
|
if (fValid) {
|
||||||
ss << "ALREADY VALID";
|
ss << "ALREADY VALID";
|
||||||
LOG(debug) << ss.str();
|
LOG(debug) << ss.str();
|
||||||
return true;
|
return true;
|
||||||
@@ -524,7 +198,7 @@ try {
|
|||||||
} else {
|
} else {
|
||||||
vector<string> endpoints;
|
vector<string> endpoints;
|
||||||
boost::algorithm::split(endpoints, fAddress, boost::algorithm::is_any_of(";"));
|
boost::algorithm::split(endpoints, fAddress, boost::algorithm::is_any_of(";"));
|
||||||
for (const auto endpoint : endpoints) {
|
for (const auto& endpoint : endpoints) {
|
||||||
string address;
|
string address;
|
||||||
if (endpoint[0] == '@' || endpoint[0] == '+' || endpoint[0] == '>') {
|
if (endpoint[0] == '@' || endpoint[0] == '+' || endpoint[0] == '>') {
|
||||||
address = endpoint.substr(1);
|
address = endpoint.substr(1);
|
||||||
@@ -626,7 +300,7 @@ try {
|
|||||||
throw ChannelConfigurationError(tools::ToString("invalid socket rate logging interval (cannot be negative): '", fRateLogging, "'"));
|
throw ChannelConfigurationError(tools::ToString("invalid socket rate logging interval (cannot be negative): '", fRateLogging, "'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
fIsValid = true;
|
fValid = true;
|
||||||
ss << "VALID";
|
ss << "VALID";
|
||||||
LOG(debug) << ss.str();
|
LOG(debug) << ss.str();
|
||||||
return true;
|
return true;
|
||||||
@@ -637,8 +311,6 @@ try {
|
|||||||
|
|
||||||
void FairMQChannel::Init()
|
void FairMQChannel::Init()
|
||||||
{
|
{
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
|
|
||||||
fSocket = fTransportFactory->CreateSocket(fType, fName);
|
fSocket = fTransportFactory->CreateSocket(fType, fName);
|
||||||
|
|
||||||
// set linger duration (how long socket should wait for outstanding transfers before shutdown)
|
// set linger duration (how long socket should wait for outstanding transfers before shutdown)
|
||||||
@@ -659,19 +331,22 @@ void FairMQChannel::Init()
|
|||||||
|
|
||||||
bool FairMQChannel::ConnectEndpoint(const string& endpoint)
|
bool FairMQChannel::ConnectEndpoint(const string& endpoint)
|
||||||
{
|
{
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
|
|
||||||
return fSocket->Connect(endpoint);
|
return fSocket->Connect(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQChannel::BindEndpoint(string& endpoint)
|
bool FairMQChannel::BindEndpoint(string& endpoint)
|
||||||
{
|
{
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
|
|
||||||
// try to bind to the configured port. If it fails, try random one (if AutoBind is on).
|
// try to bind to the configured port. If it fails, try random one (if AutoBind is on).
|
||||||
if (fSocket->Bind(endpoint)) {
|
if (fSocket->Bind(endpoint)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
// auto-bind only implemented for TCP
|
||||||
|
size_t protocolPos = endpoint.find(':');
|
||||||
|
string protocol = endpoint.substr(0, protocolPos);
|
||||||
|
if (protocol != "tcp") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (fAutoBind) {
|
if (fAutoBind) {
|
||||||
// number of attempts when choosing a random port
|
// number of attempts when choosing a random port
|
||||||
int numAttempts = 0;
|
int numAttempts = 0;
|
||||||
@@ -701,10 +376,3 @@ bool FairMQChannel::BindEndpoint(string& endpoint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQChannel::ResetChannel()
|
|
||||||
{
|
|
||||||
lock_guard<mutex> lock(fMtx);
|
|
||||||
fIsValid = false;
|
|
||||||
// TODO: implement channel resetting
|
|
||||||
}
|
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
#include <FairMQUnmanagedRegion.h>
|
#include <FairMQUnmanagedRegion.h>
|
||||||
#include <FairMQSocket.h>
|
#include <FairMQSocket.h>
|
||||||
#include <fairmq/Transports.h>
|
#include <fairmq/Transports.h>
|
||||||
#include <FairMQLogger.h>
|
|
||||||
#include <FairMQParts.h>
|
#include <FairMQParts.h>
|
||||||
#include <fairmq/Properties.h>
|
#include <fairmq/Properties.h>
|
||||||
#include <FairMQMessage.h>
|
#include <FairMQMessage.h>
|
||||||
@@ -24,9 +23,14 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility> // std::move
|
#include <utility> // std::move
|
||||||
#include <cstddef> // size_t
|
|
||||||
#include <cstdint> // int64_t
|
#include <cstdint> // int64_t
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class FairMQChannel FairMQChannel.h <FairMQChannel.h>
|
||||||
|
* @brief Wrapper class for FairMQSocket and related methods
|
||||||
|
*
|
||||||
|
* The class is not thread-safe.
|
||||||
|
*/
|
||||||
class FairMQChannel
|
class FairMQChannel
|
||||||
{
|
{
|
||||||
friend class FairMQDevice;
|
friend class FairMQDevice;
|
||||||
@@ -68,23 +72,20 @@ class FairMQChannel
|
|||||||
FairMQChannel(const FairMQChannel&, const std::string& name);
|
FairMQChannel(const FairMQChannel&, const std::string& name);
|
||||||
|
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
FairMQChannel(FairMQChannel&&) = delete;
|
// FairMQChannel(FairMQChannel&&) = delete;
|
||||||
|
|
||||||
/// Assignment operator
|
/// Assignment operator
|
||||||
FairMQChannel& operator=(const FairMQChannel&);
|
FairMQChannel& operator=(const FairMQChannel&);
|
||||||
|
|
||||||
/// Move assignment operator
|
/// Move assignment operator
|
||||||
FairMQChannel& operator=(FairMQChannel&&) = delete;
|
// FairMQChannel& operator=(FairMQChannel&&) = delete;
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~FairMQChannel()
|
virtual ~FairMQChannel() { /* LOG(warn) << "Destroying channel '" << fName << "'"; */ }
|
||||||
{
|
|
||||||
// LOG(debug) << "Destroying channel " << fName;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ChannelConfigurationError : std::runtime_error { using std::runtime_error::runtime_error; };
|
struct ChannelConfigurationError : std::runtime_error { using std::runtime_error::runtime_error; };
|
||||||
|
|
||||||
FairMQSocket& GetSocket() const;
|
FairMQSocket& GetSocket() const { assert(fSocket); return *fSocket; }
|
||||||
|
|
||||||
bool Bind(const std::string& address)
|
bool Bind(const std::string& address)
|
||||||
{
|
{
|
||||||
@@ -102,139 +103,142 @@ class FairMQChannel
|
|||||||
|
|
||||||
/// Get channel name
|
/// Get channel name
|
||||||
/// @return Returns full channel name (e.g. "data[0]")
|
/// @return Returns full channel name (e.g. "data[0]")
|
||||||
std::string GetChannelName() const __attribute__((deprecated("Use GetName()"))) { return GetName(); }
|
std::string GetName() const { return fName; }
|
||||||
std::string GetName() const ;
|
|
||||||
|
|
||||||
/// Get channel prefix
|
/// Get channel prefix
|
||||||
/// @return Returns channel prefix (e.g. "data" in "data[0]")
|
/// @return Returns channel prefix (e.g. "data" in "data[0]")
|
||||||
std::string GetChannelPrefix() const __attribute__((deprecated("Use GetPrefix()"))) { return GetPrefix(); }
|
std::string GetPrefix() const
|
||||||
std::string GetPrefix() const;
|
{
|
||||||
|
std::string prefix = fName;
|
||||||
|
prefix = prefix.erase(fName.rfind('['));
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
/// Get channel index
|
/// Get channel index
|
||||||
/// @return Returns channel index (e.g. 0 in "data[0]")
|
/// @return Returns channel index (e.g. 0 in "data[0]")
|
||||||
std::string GetChannelIndex() const __attribute__((deprecated("Use GetIndex()"))) { return GetIndex(); }
|
std::string GetIndex() const
|
||||||
std::string GetIndex() const;
|
{
|
||||||
|
std::string indexStr = fName;
|
||||||
|
indexStr.erase(indexStr.rfind(']'));
|
||||||
|
indexStr.erase(0, indexStr.rfind('[') + 1);
|
||||||
|
return indexStr;
|
||||||
|
}
|
||||||
|
|
||||||
/// Get socket type
|
/// Get socket type
|
||||||
/// @return Returns socket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
|
/// @return Returns socket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
|
||||||
std::string GetType() const;
|
std::string GetType() const { return fType; }
|
||||||
|
|
||||||
/// Get socket method
|
/// Get socket method
|
||||||
/// @return Returns socket method (bind/connect)
|
/// @return Returns socket method (bind/connect)
|
||||||
std::string GetMethod() const;
|
std::string GetMethod() const { return fMethod; }
|
||||||
|
|
||||||
/// Get socket address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
|
/// Get socket address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
|
||||||
/// @return Returns socket address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
|
/// @return Returns socket address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
|
||||||
std::string GetAddress() const;
|
std::string GetAddress() const { return fAddress; }
|
||||||
|
|
||||||
/// Get channel transport name ("default", "zeromq", "nanomsg" or "shmem")
|
/// Get channel transport name ("default", "zeromq" or "shmem")
|
||||||
/// @return Returns channel transport name (e.g. "default", "zeromq", "nanomsg" or "shmem")
|
/// @return Returns channel transport name (e.g. "default", "zeromq" or "shmem")
|
||||||
std::string GetTransportName() const;
|
std::string GetTransportName() const { return fair::mq::TransportName(fTransportType); }
|
||||||
|
|
||||||
/// Get channel transport type
|
/// Get channel transport type
|
||||||
/// @return Returns channel transport type
|
/// @return Returns channel transport type
|
||||||
fair::mq::Transport GetTransportType() const;
|
fair::mq::Transport GetTransportType() const { return fTransportType; }
|
||||||
|
|
||||||
/// Get socket send buffer size (in number of messages)
|
/// Get socket send buffer size (in number of messages)
|
||||||
/// @return Returns socket send buffer size (in number of messages)
|
/// @return Returns socket send buffer size (in number of messages)
|
||||||
int GetSndBufSize() const;
|
int GetSndBufSize() const { return fSndBufSize; }
|
||||||
|
|
||||||
/// Get socket receive buffer size (in number of messages)
|
/// Get socket receive buffer size (in number of messages)
|
||||||
/// @return Returns socket receive buffer size (in number of messages)
|
/// @return Returns socket receive buffer size (in number of messages)
|
||||||
int GetRcvBufSize() const;
|
int GetRcvBufSize() const { return fRcvBufSize; }
|
||||||
|
|
||||||
/// Get socket kernel transmit send buffer size (in bytes)
|
/// Get socket kernel transmit send buffer size (in bytes)
|
||||||
/// @return Returns socket kernel transmit send buffer size (in bytes)
|
/// @return Returns socket kernel transmit send buffer size (in bytes)
|
||||||
int GetSndKernelSize() const;
|
int GetSndKernelSize() const { return fSndKernelSize; }
|
||||||
|
|
||||||
/// Get socket kernel transmit receive buffer size (in bytes)
|
/// Get socket kernel transmit receive buffer size (in bytes)
|
||||||
/// @return Returns socket kernel transmit receive buffer size (in bytes)
|
/// @return Returns socket kernel transmit receive buffer size (in bytes)
|
||||||
int GetRcvKernelSize() const;
|
int GetRcvKernelSize() const { return fRcvKernelSize; }
|
||||||
|
|
||||||
/// Get linger duration (in milliseconds)
|
/// Get linger duration (in milliseconds)
|
||||||
/// @return Returns linger duration (in milliseconds)
|
/// @return Returns linger duration (in milliseconds)
|
||||||
int GetLinger() const;
|
int GetLinger() const { return fLinger; }
|
||||||
|
|
||||||
/// Get socket rate logging interval (in seconds)
|
/// Get socket rate logging interval (in seconds)
|
||||||
/// @return Returns socket rate logging interval (in seconds)
|
/// @return Returns socket rate logging interval (in seconds)
|
||||||
int GetRateLogging() const;
|
int GetRateLogging() const { return fRateLogging; }
|
||||||
|
|
||||||
/// Get start of the port range for automatic binding
|
/// Get start of the port range for automatic binding
|
||||||
/// @return start of the port range
|
/// @return start of the port range
|
||||||
int GetPortRangeMin() const;
|
int GetPortRangeMin() const { return fPortRangeMin; }
|
||||||
|
|
||||||
/// Get end of the port range for automatic binding
|
/// Get end of the port range for automatic binding
|
||||||
/// @return end of the port range
|
/// @return end of the port range
|
||||||
int GetPortRangeMax() const;
|
int GetPortRangeMax() const { return fPortRangeMax; }
|
||||||
|
|
||||||
/// Set automatic binding (pick random port if bind fails)
|
/// Set automatic binding (pick random port if bind fails)
|
||||||
/// @return true/false, true if automatic binding is enabled
|
/// @return true/false, true if automatic binding is enabled
|
||||||
bool GetAutoBind() const;
|
bool GetAutoBind() const { return fAutoBind; }
|
||||||
|
|
||||||
/// Set socket type
|
|
||||||
/// @param type Socket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
|
|
||||||
void UpdateType(const std::string& type);
|
|
||||||
|
|
||||||
/// Set socket method
|
|
||||||
/// @param method Socket method (bind/connect)
|
|
||||||
void UpdateMethod(const std::string& method);
|
|
||||||
|
|
||||||
/// Set socket address
|
|
||||||
/// @param Socket address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
|
|
||||||
void UpdateAddress(const std::string& address);
|
|
||||||
|
|
||||||
/// Set channel transport
|
|
||||||
/// @param transport transport string ("default", "zeromq", "nanomsg" or "shmem")
|
|
||||||
void UpdateTransport(const std::string& transport);
|
|
||||||
|
|
||||||
/// Set socket send buffer size
|
|
||||||
/// @param sndBufSize Socket send buffer size (in number of messages)
|
|
||||||
void UpdateSndBufSize(const int sndBufSize);
|
|
||||||
|
|
||||||
/// Set socket receive buffer size
|
|
||||||
/// @param rcvBufSize Socket receive buffer size (in number of messages)
|
|
||||||
void UpdateRcvBufSize(const int rcvBufSize);
|
|
||||||
|
|
||||||
/// Set socket kernel transmit send buffer size (in bytes)
|
|
||||||
/// @param sndKernelSize Socket send buffer size (in bytes)
|
|
||||||
void UpdateSndKernelSize(const int sndKernelSize);
|
|
||||||
|
|
||||||
/// Set socket kernel transmit receive buffer size (in bytes)
|
|
||||||
/// @param rcvKernelSize Socket receive buffer size (in bytes)
|
|
||||||
void UpdateRcvKernelSize(const int rcvKernelSize);
|
|
||||||
|
|
||||||
/// Set linger duration (in milliseconds)
|
|
||||||
/// @param duration linger duration (in milliseconds)
|
|
||||||
void UpdateLinger(const int duration);
|
|
||||||
|
|
||||||
/// Set socket rate logging interval (in seconds)
|
|
||||||
/// @param rateLogging Socket rate logging interval (in seconds)
|
|
||||||
void UpdateRateLogging(const int rateLogging);
|
|
||||||
|
|
||||||
/// Set start of the port range for automatic binding
|
|
||||||
/// @param minPort start of the port range
|
|
||||||
void UpdatePortRangeMin(const int minPort);
|
|
||||||
|
|
||||||
/// Set end of the port range for automatic binding
|
|
||||||
/// @param maxPort end of the port range
|
|
||||||
void UpdatePortRangeMax(const int maxPort);
|
|
||||||
|
|
||||||
/// Set automatic binding (pick random port if bind fails)
|
|
||||||
/// @param autobind true/false, true to enable automatic binding
|
|
||||||
void UpdateAutoBind(const bool autobind);
|
|
||||||
|
|
||||||
/// Set channel name
|
/// Set channel name
|
||||||
/// @param name Arbitrary channel name
|
/// @param name Arbitrary channel name
|
||||||
void UpdateChannelName(const std::string& name) __attribute__((deprecated("Use UpdateName()"))) { UpdateName(name); }
|
void UpdateName(const std::string& name) { fName = name; Invalidate(); }
|
||||||
void UpdateName(const std::string& name);
|
|
||||||
|
/// Set socket type
|
||||||
|
/// @param type Socket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
|
||||||
|
void UpdateType(const std::string& type) { fType = type; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set socket method
|
||||||
|
/// @param method Socket method (bind/connect)
|
||||||
|
void UpdateMethod(const std::string& method) { fMethod = method; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set socket address
|
||||||
|
/// @param Socket address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
|
||||||
|
void UpdateAddress(const std::string& address) { fAddress = address; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set channel transport
|
||||||
|
/// @param transport transport string ("default", "zeromq" or "shmem")
|
||||||
|
void UpdateTransport(const std::string& transport) { fTransportType = fair::mq::TransportType(transport); Invalidate(); }
|
||||||
|
|
||||||
|
/// Set socket send buffer size
|
||||||
|
/// @param sndBufSize Socket send buffer size (in number of messages)
|
||||||
|
void UpdateSndBufSize(const int sndBufSize) { fSndBufSize = sndBufSize; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set socket receive buffer size
|
||||||
|
/// @param rcvBufSize Socket receive buffer size (in number of messages)
|
||||||
|
void UpdateRcvBufSize(const int rcvBufSize) { fRcvBufSize = rcvBufSize; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set socket kernel transmit send buffer size (in bytes)
|
||||||
|
/// @param sndKernelSize Socket send buffer size (in bytes)
|
||||||
|
void UpdateSndKernelSize(const int sndKernelSize) { fSndKernelSize = sndKernelSize; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set socket kernel transmit receive buffer size (in bytes)
|
||||||
|
/// @param rcvKernelSize Socket receive buffer size (in bytes)
|
||||||
|
void UpdateRcvKernelSize(const int rcvKernelSize) { fRcvKernelSize = rcvKernelSize; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set linger duration (in milliseconds)
|
||||||
|
/// @param duration linger duration (in milliseconds)
|
||||||
|
void UpdateLinger(const int duration) { fLinger = duration; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set socket rate logging interval (in seconds)
|
||||||
|
/// @param rateLogging Socket rate logging interval (in seconds)
|
||||||
|
void UpdateRateLogging(const int rateLogging) { fRateLogging = rateLogging; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set start of the port range for automatic binding
|
||||||
|
/// @param minPort start of the port range
|
||||||
|
void UpdatePortRangeMin(const int minPort) { fPortRangeMin = minPort; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set end of the port range for automatic binding
|
||||||
|
/// @param maxPort end of the port range
|
||||||
|
void UpdatePortRangeMax(const int maxPort) { fPortRangeMax = maxPort; Invalidate(); }
|
||||||
|
|
||||||
|
/// Set automatic binding (pick random port if bind fails)
|
||||||
|
/// @param autobind true/false, true to enable automatic binding
|
||||||
|
void UpdateAutoBind(const bool autobind) { fAutoBind = autobind; Invalidate(); }
|
||||||
|
|
||||||
/// Checks if the configured channel settings are valid (checks the validity parameter, without running full validation (as oposed to ValidateChannel()))
|
/// Checks if the configured channel settings are valid (checks the validity parameter, without running full validation (as oposed to ValidateChannel()))
|
||||||
/// @return true if channel settings are valid, false otherwise.
|
/// @return true if channel settings are valid, false otherwise.
|
||||||
bool IsValid() const;
|
bool IsValid() const { return fValid; }
|
||||||
|
|
||||||
/// Validates channel configuration
|
|
||||||
/// @return true if channel settings are valid, false otherwise.
|
|
||||||
bool ValidateChannel() __attribute__((deprecated("Use Validate()"))) { return Validate(); }
|
|
||||||
|
|
||||||
/// Validates channel configuration
|
/// Validates channel configuration
|
||||||
/// @return true if channel settings are valid, false otherwise.
|
/// @return true if channel settings are valid, false otherwise.
|
||||||
@@ -246,13 +250,13 @@ class FairMQChannel
|
|||||||
|
|
||||||
bool BindEndpoint(std::string& endpoint);
|
bool BindEndpoint(std::string& endpoint);
|
||||||
|
|
||||||
/// Resets the channel (requires validation to be used again).
|
/// invalidates the channel (requires validation to be used again).
|
||||||
void ResetChannel();
|
void Invalidate() { fValid = false; }
|
||||||
|
|
||||||
/// Sends a message to the socket queue.
|
/// Sends a message to the socket queue.
|
||||||
/// @param msg Constant reference of unique_ptr to a FairMQMessage
|
/// @param msg Constant reference of unique_ptr to a FairMQMessage
|
||||||
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
||||||
/// @return Number of bytes that have been queued. -2 If queueing was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been queued, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int Send(FairMQMessagePtr& msg, int sndTimeoutInMs = -1)
|
int Send(FairMQMessagePtr& msg, int sndTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
CheckSendCompatibility(msg);
|
CheckSendCompatibility(msg);
|
||||||
@@ -262,7 +266,7 @@ class FairMQChannel
|
|||||||
/// Receives a message from the socket queue.
|
/// Receives a message from the socket queue.
|
||||||
/// @param msg Constant reference of unique_ptr to a FairMQMessage
|
/// @param msg Constant reference of unique_ptr to a FairMQMessage
|
||||||
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
||||||
/// @return Number of bytes that have been received. -2 if reading from the queue was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been received, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int Receive(FairMQMessagePtr& msg, int rcvTimeoutInMs = -1)
|
int Receive(FairMQMessagePtr& msg, int rcvTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
CheckReceiveCompatibility(msg);
|
CheckReceiveCompatibility(msg);
|
||||||
@@ -272,7 +276,7 @@ class FairMQChannel
|
|||||||
/// Send a vector of messages
|
/// Send a vector of messages
|
||||||
/// @param msgVec message vector reference
|
/// @param msgVec message vector reference
|
||||||
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
||||||
/// @return Number of bytes that have been queued. -2 If queueing was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been queued, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Send(std::vector<FairMQMessagePtr>& msgVec, int sndTimeoutInMs = -1)
|
int64_t Send(std::vector<FairMQMessagePtr>& msgVec, int sndTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
CheckSendCompatibility(msgVec);
|
CheckSendCompatibility(msgVec);
|
||||||
@@ -282,7 +286,7 @@ class FairMQChannel
|
|||||||
/// Receive a vector of messages
|
/// Receive a vector of messages
|
||||||
/// @param msgVec message vector reference
|
/// @param msgVec message vector reference
|
||||||
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
||||||
/// @return Number of bytes that have been received. -2 if reading from the queue was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been received, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Receive(std::vector<FairMQMessagePtr>& msgVec, int rcvTimeoutInMs = -1)
|
int64_t Receive(std::vector<FairMQMessagePtr>& msgVec, int rcvTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
CheckReceiveCompatibility(msgVec);
|
CheckReceiveCompatibility(msgVec);
|
||||||
@@ -292,7 +296,7 @@ class FairMQChannel
|
|||||||
/// Send FairMQParts
|
/// Send FairMQParts
|
||||||
/// @param parts FairMQParts reference
|
/// @param parts FairMQParts reference
|
||||||
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
||||||
/// @return Number of bytes that have been queued. -2 If queueing was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been queued, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Send(FairMQParts& parts, int sndTimeoutInMs = -1)
|
int64_t Send(FairMQParts& parts, int sndTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return Send(parts.fParts, sndTimeoutInMs);
|
return Send(parts.fParts, sndTimeoutInMs);
|
||||||
@@ -301,7 +305,7 @@ class FairMQChannel
|
|||||||
/// Receive FairMQParts
|
/// Receive FairMQParts
|
||||||
/// @param parts FairMQParts reference
|
/// @param parts FairMQParts reference
|
||||||
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
||||||
/// @return Number of bytes that have been received. -2 if reading from the queue was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been received, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Receive(FairMQParts& parts, int rcvTimeoutInMs = -1)
|
int64_t Receive(FairMQParts& parts, int rcvTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return Receive(parts.fParts, rcvTimeoutInMs);
|
return Receive(parts.fParts, rcvTimeoutInMs);
|
||||||
@@ -312,10 +316,7 @@ class FairMQChannel
|
|||||||
unsigned long GetMessagesTx() const { return fSocket->GetMessagesTx(); }
|
unsigned long GetMessagesTx() const { return fSocket->GetMessagesTx(); }
|
||||||
unsigned long GetMessagesRx() const { return fSocket->GetMessagesRx(); }
|
unsigned long GetMessagesRx() const { return fSocket->GetMessagesRx(); }
|
||||||
|
|
||||||
auto Transport() -> FairMQTransportFactory*
|
auto Transport() -> FairMQTransportFactory* { return fTransportFactory.get(); };
|
||||||
{
|
|
||||||
return fTransportFactory.get();
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
FairMQMessagePtr NewMessage(Args&&... args)
|
FairMQMessagePtr NewMessage(Args&&... args)
|
||||||
@@ -335,9 +336,10 @@ class FairMQChannel
|
|||||||
return Transport()->NewStaticMessage(data);
|
return Transport()->NewStaticMessage(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQUnmanagedRegionPtr NewUnmanagedRegion(const size_t size, FairMQRegionCallback callback = nullptr, const std::string& path = "", int flags = 0)
|
template<typename... Args>
|
||||||
|
FairMQUnmanagedRegionPtr NewUnmanagedRegion(Args&&... args)
|
||||||
{
|
{
|
||||||
return Transport()->CreateUnmanagedRegion(size, callback, path, flags);
|
return Transport()->CreateUnmanagedRegion(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr fair::mq::Transport DefaultTransportType = fair::mq::Transport::DEFAULT;
|
static constexpr fair::mq::Transport DefaultTransportType = fair::mq::Transport::DEFAULT;
|
||||||
@@ -375,13 +377,9 @@ class FairMQChannel
|
|||||||
int fPortRangeMax;
|
int fPortRangeMax;
|
||||||
bool fAutoBind;
|
bool fAutoBind;
|
||||||
|
|
||||||
bool fIsValid;
|
bool fValid;
|
||||||
|
|
||||||
bool fMultipart;
|
bool fMultipart;
|
||||||
bool fModified;
|
|
||||||
bool fReset;
|
|
||||||
|
|
||||||
mutable std::mutex fMtx;
|
|
||||||
|
|
||||||
void CheckSendCompatibility(FairMQMessagePtr& msg)
|
void CheckSendCompatibility(FairMQMessagePtr& msg)
|
||||||
{
|
{
|
||||||
@@ -438,8 +436,6 @@ class FairMQChannel
|
|||||||
fTransportFactory = factory;
|
fTransportFactory = factory;
|
||||||
fTransportType = factory->GetType();
|
fTransportType = factory->GetType();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SetModified(const bool modified) -> void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQCHANNEL_H_ */
|
#endif /* FAIRMQCHANNEL_H_ */
|
||||||
|
@@ -299,10 +299,15 @@ void FairMQDevice::InitWrapper()
|
|||||||
// if binding address is not specified, try getting it from the configured network interface
|
// if binding address is not specified, try getting it from the configured network interface
|
||||||
if (subChannel.fAddress == "unspecified" || subChannel.fAddress == "") {
|
if (subChannel.fAddress == "unspecified" || subChannel.fAddress == "") {
|
||||||
// if the configured network interface is default, get its name from the default route
|
// if the configured network interface is default, get its name from the default route
|
||||||
if (networkInterface == "default") {
|
try {
|
||||||
networkInterface = tools::getDefaultRouteNetworkInterface();
|
if (networkInterface == "default") {
|
||||||
|
networkInterface = tools::getDefaultRouteNetworkInterface();
|
||||||
|
}
|
||||||
|
subChannel.fAddress = "tcp://" + tools::getInterfaceIP(networkInterface) + ":1";
|
||||||
|
} catch(const tools::DefaultRouteDetectionError& e) {
|
||||||
|
LOG(debug) << "binding on tcp://*:1";
|
||||||
|
subChannel.fAddress = "tcp://*:1";
|
||||||
}
|
}
|
||||||
subChannel.fAddress = "tcp://" + tools::getInterfaceIP(networkInterface) + ":1";
|
|
||||||
}
|
}
|
||||||
// fill the uninitialized list
|
// fill the uninitialized list
|
||||||
fUninitializedBindingChannels.push_back(&subChannel);
|
fUninitializedBindingChannels.push_back(&subChannel);
|
||||||
@@ -385,7 +390,6 @@ void FairMQDevice::AttachChannels(vector<FairMQChannel*>& chans)
|
|||||||
if ((*itr)->Validate()) {
|
if ((*itr)->Validate()) {
|
||||||
(*itr)->Init();
|
(*itr)->Init();
|
||||||
if (AttachChannel(**itr)) {
|
if (AttachChannel(**itr)) {
|
||||||
(*itr)->SetModified(false);
|
|
||||||
// remove the channel from the uninitialized container
|
// remove the channel from the uninitialized container
|
||||||
itr = chans.erase(itr);
|
itr = chans.erase(itr);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
#include <algorithm> // find
|
#include <algorithm> // find
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iostream>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -129,7 +128,7 @@ class FairMQDevice
|
|||||||
/// @param chan channel name
|
/// @param chan channel name
|
||||||
/// @param i channel index
|
/// @param i channel index
|
||||||
/// @param sndTimeoutInMs send timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
/// @param sndTimeoutInMs send timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
||||||
/// @return Number of bytes that have been queued. -2 If queueing was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been queued, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int Send(FairMQMessagePtr& msg, const std::string& channel, const int index = 0, int sndTimeoutInMs = -1)
|
int Send(FairMQMessagePtr& msg, const std::string& channel, const int index = 0, int sndTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return GetChannel(channel, index).Send(msg, sndTimeoutInMs);
|
return GetChannel(channel, index).Send(msg, sndTimeoutInMs);
|
||||||
@@ -140,7 +139,7 @@ class FairMQDevice
|
|||||||
/// @param chan channel name
|
/// @param chan channel name
|
||||||
/// @param i channel index
|
/// @param i channel index
|
||||||
/// @param rcvTimeoutInMs receive timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
/// @param rcvTimeoutInMs receive timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
||||||
/// @return Number of bytes that have been received. -2 if reading from the queue was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been received, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int Receive(FairMQMessagePtr& msg, const std::string& channel, const int index = 0, int rcvTimeoutInMs = -1)
|
int Receive(FairMQMessagePtr& msg, const std::string& channel, const int index = 0, int rcvTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return GetChannel(channel, index).Receive(msg, rcvTimeoutInMs);
|
return GetChannel(channel, index).Receive(msg, rcvTimeoutInMs);
|
||||||
@@ -151,7 +150,7 @@ class FairMQDevice
|
|||||||
/// @param chan channel name
|
/// @param chan channel name
|
||||||
/// @param i channel index
|
/// @param i channel index
|
||||||
/// @param sndTimeoutInMs send timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
/// @param sndTimeoutInMs send timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
||||||
/// @return Number of bytes that have been queued. -2 If queueing was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been queued, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Send(FairMQParts& parts, const std::string& channel, const int index = 0, int sndTimeoutInMs = -1)
|
int64_t Send(FairMQParts& parts, const std::string& channel, const int index = 0, int sndTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return GetChannel(channel, index).Send(parts.fParts, sndTimeoutInMs);
|
return GetChannel(channel, index).Send(parts.fParts, sndTimeoutInMs);
|
||||||
@@ -162,7 +161,7 @@ class FairMQDevice
|
|||||||
/// @param chan channel name
|
/// @param chan channel name
|
||||||
/// @param i channel index
|
/// @param i channel index
|
||||||
/// @param rcvTimeoutInMs receive timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
/// @param rcvTimeoutInMs receive timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
||||||
/// @return Number of bytes that have been received. -2 if reading from the queue was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been received, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Receive(FairMQParts& parts, const std::string& channel, const int index = 0, int rcvTimeoutInMs = -1)
|
int64_t Receive(FairMQParts& parts, const std::string& channel, const int index = 0, int rcvTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return GetChannel(channel, index).Receive(parts.fParts, rcvTimeoutInMs);
|
return GetChannel(channel, index).Receive(parts.fParts, rcvTimeoutInMs);
|
||||||
@@ -217,15 +216,17 @@ class FairMQDevice
|
|||||||
}
|
}
|
||||||
|
|
||||||
// creates unamanaged region with the default device transport
|
// creates unamanaged region with the default device transport
|
||||||
FairMQUnmanagedRegionPtr NewUnmanagedRegion(const size_t size, FairMQRegionCallback callback = nullptr)
|
template<typename... Args>
|
||||||
|
FairMQUnmanagedRegionPtr NewUnmanagedRegion(Args&&... args)
|
||||||
{
|
{
|
||||||
return Transport()->CreateUnmanagedRegion(size, callback);
|
return Transport()->CreateUnmanagedRegion(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates unmanaged region with the transport of the specified channel
|
// creates unmanaged region with the transport of the specified channel
|
||||||
FairMQUnmanagedRegionPtr NewUnmanagedRegionFor(const std::string& channel, int index, const size_t size, FairMQRegionCallback callback = nullptr, const std::string& path = "", int flags = 0)
|
template<typename... Args>
|
||||||
|
FairMQUnmanagedRegionPtr NewUnmanagedRegionFor(const std::string& channel, int index, Args&&... args)
|
||||||
{
|
{
|
||||||
return GetChannel(channel, index).NewUnmanagedRegion(size, callback, path, flags);
|
return GetChannel(channel, index).NewUnmanagedRegion(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...Ts>
|
template<typename ...Ts>
|
||||||
@@ -272,7 +273,7 @@ class FairMQDevice
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a transport to the device if it doesn't exist
|
/// Adds a transport to the device if it doesn't exist
|
||||||
/// @param transport Transport string ("zeromq"/"nanomsg"/"shmem")
|
/// @param transport Transport string ("zeromq"/"shmem")
|
||||||
std::shared_ptr<FairMQTransportFactory> AddTransport(const fair::mq::Transport transport);
|
std::shared_ptr<FairMQTransportFactory> AddTransport(const fair::mq::Transport transport);
|
||||||
|
|
||||||
/// Assigns config to the device
|
/// Assigns config to the device
|
||||||
@@ -361,10 +362,10 @@ class FairMQDevice
|
|||||||
void PrintRegisteredChannels()
|
void PrintRegisteredChannels()
|
||||||
{
|
{
|
||||||
if (fChannelRegistry.size() < 1) {
|
if (fChannelRegistry.size() < 1) {
|
||||||
std::cout << "no channels registered." << std::endl;
|
LOGV(info, verylow) << "no channels registered.";
|
||||||
} else {
|
} else {
|
||||||
for (const auto& c : fChannelRegistry) {
|
for (const auto& c : fChannelRegistry) {
|
||||||
std::cout << c.first << ":" << c.second.first << ":" << c.second.second << std::endl;
|
LOGV(info, verylow) << c.first << ":" << c.second.first << ":" << c.second.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,7 +388,7 @@ class FairMQDevice
|
|||||||
int GetInitTimeoutInS() const { return fConfig->GetProperty<int>("init-timeout", DefaultInitTimeout); }
|
int GetInitTimeoutInS() const { return fConfig->GetProperty<int>("init-timeout", DefaultInitTimeout); }
|
||||||
|
|
||||||
/// Sets the default transport for the device
|
/// Sets the default transport for the device
|
||||||
/// @param transport Transport string ("zeromq"/"nanomsg"/"shmem")
|
/// @param transport Transport string ("zeromq"/"shmem")
|
||||||
void SetTransport(const std::string& transport) { fConfig->SetProperty("transport", transport); }
|
void SetTransport(const std::string& transport) { fConfig->SetProperty("transport", transport); }
|
||||||
/// Gets the default transport name
|
/// Gets the default transport name
|
||||||
std::string GetTransportName() const { return fConfig->GetProperty<std::string>("transport", DefaultTransportName); }
|
std::string GetTransportName() const { return fConfig->GetProperty<std::string>("transport", DefaultTransportName); }
|
||||||
|
@@ -11,17 +11,33 @@
|
|||||||
|
|
||||||
#include <cstddef> // for size_t
|
#include <cstddef> // for size_t
|
||||||
#include <memory> // unique_ptr
|
#include <memory> // unique_ptr
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <fairmq/Transports.h>
|
#include <fairmq/Transports.h>
|
||||||
|
|
||||||
using fairmq_free_fn = void(void* data, void* hint);
|
using fairmq_free_fn = void(void* data, void* hint);
|
||||||
class FairMQTransportFactory;
|
class FairMQTransportFactory;
|
||||||
|
|
||||||
|
namespace fair
|
||||||
|
{
|
||||||
|
namespace mq
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Alignment
|
||||||
|
{
|
||||||
|
size_t alignment;
|
||||||
|
explicit operator size_t() const { return alignment; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace mq */
|
||||||
|
} /* namespace fair */
|
||||||
|
|
||||||
class FairMQMessage
|
class FairMQMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQMessage() = default;
|
FairMQMessage() = default;
|
||||||
FairMQMessage(FairMQTransportFactory* factory):fTransport{factory} {}
|
FairMQMessage(FairMQTransportFactory* factory) : fTransport(factory) {}
|
||||||
|
|
||||||
virtual void Rebuild() = 0;
|
virtual void Rebuild() = 0;
|
||||||
virtual void Rebuild(const size_t size) = 0;
|
virtual void Rebuild(const size_t size) = 0;
|
||||||
virtual void Rebuild(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) = 0;
|
virtual void Rebuild(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) = 0;
|
||||||
@@ -33,7 +49,7 @@ class FairMQMessage
|
|||||||
|
|
||||||
virtual fair::mq::Transport GetType() const = 0;
|
virtual fair::mq::Transport GetType() const = 0;
|
||||||
FairMQTransportFactory* GetTransport() { return fTransport; }
|
FairMQTransportFactory* GetTransport() { return fTransport; }
|
||||||
//void SetTransport(FairMQTransportFactory* transport) { fTransport = transport; }
|
void SetTransport(FairMQTransportFactory* transport) { fTransport = transport; }
|
||||||
|
|
||||||
virtual void Copy(const FairMQMessage& msg) = 0;
|
virtual void Copy(const FairMQMessage& msg) = 0;
|
||||||
|
|
||||||
@@ -53,6 +69,7 @@ namespace mq
|
|||||||
using Message = FairMQMessage;
|
using Message = FairMQMessage;
|
||||||
using MessagePtr = FairMQMessagePtr;
|
using MessagePtr = FairMQMessagePtr;
|
||||||
struct MessageError : std::runtime_error { using std::runtime_error::runtime_error; };
|
struct MessageError : std::runtime_error { using std::runtime_error::runtime_error; };
|
||||||
|
struct MessageBadAlloc : std::runtime_error { using std::runtime_error::runtime_error; };
|
||||||
|
|
||||||
} /* namespace mq */
|
} /* namespace mq */
|
||||||
} /* namespace fair */
|
} /* namespace fair */
|
||||||
|
@@ -31,8 +31,8 @@ namespace fair
|
|||||||
namespace mq
|
namespace mq
|
||||||
{
|
{
|
||||||
|
|
||||||
using PollerPtr = std::unique_ptr<FairMQPoller>;
|
using Poller = FairMQPoller;
|
||||||
|
using PollerPtr = FairMQPollerPtr;
|
||||||
struct PollerError : std::runtime_error { using std::runtime_error::runtime_error; };
|
struct PollerError : std::runtime_error { using std::runtime_error::runtime_error; };
|
||||||
|
|
||||||
} /* namespace mq */
|
} /* namespace mq */
|
||||||
|
@@ -9,20 +9,38 @@
|
|||||||
#ifndef FAIRMQSOCKET_H_
|
#ifndef FAIRMQSOCKET_H_
|
||||||
#define FAIRMQSOCKET_H_
|
#define FAIRMQSOCKET_H_
|
||||||
|
|
||||||
|
#include "FairMQMessage.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <ostream>
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "FairMQMessage.h"
|
|
||||||
class FairMQTransportFactory;
|
class FairMQTransportFactory;
|
||||||
|
|
||||||
|
namespace fair
|
||||||
|
{
|
||||||
|
namespace mq
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class TransferResult : int
|
||||||
|
{
|
||||||
|
error = -1,
|
||||||
|
timeout = -2,
|
||||||
|
interrupted = -3
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mq
|
||||||
|
} // namespace fair
|
||||||
|
|
||||||
class FairMQSocket
|
class FairMQSocket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQSocket() {}
|
FairMQSocket() {}
|
||||||
FairMQSocket(FairMQTransportFactory* fac): fTransport(fac) {}
|
FairMQSocket(FairMQTransportFactory* fac) : fTransport(fac) {}
|
||||||
|
|
||||||
virtual std::string GetId() = 0;
|
virtual std::string GetId() const = 0;
|
||||||
|
|
||||||
virtual bool Bind(const std::string& address) = 0;
|
virtual bool Bind(const std::string& address) = 0;
|
||||||
virtual bool Connect(const std::string& address) = 0;
|
virtual bool Connect(const std::string& address) = 0;
|
||||||
@@ -37,6 +55,10 @@ class FairMQSocket
|
|||||||
virtual void SetOption(const std::string& option, const void* value, size_t valueSize) = 0;
|
virtual void SetOption(const std::string& option, const void* value, size_t valueSize) = 0;
|
||||||
virtual void GetOption(const std::string& option, void* value, size_t* valueSize) = 0;
|
virtual void GetOption(const std::string& option, void* value, size_t* valueSize) = 0;
|
||||||
|
|
||||||
|
/// If the backend supports it, fills the unsigned integer @a events with the ZMQ_EVENTS value
|
||||||
|
/// DISCLAIMER: this API is experimental and unsupported and might be dropped / refactored in
|
||||||
|
/// the future.
|
||||||
|
virtual void Events(uint32_t* events) = 0;
|
||||||
virtual void SetLinger(const int value) = 0;
|
virtual void SetLinger(const int value) = 0;
|
||||||
virtual int GetLinger() const = 0;
|
virtual int GetLinger() const = 0;
|
||||||
virtual void SetSndBufSize(const int value) = 0;
|
virtual void SetSndBufSize(const int value) = 0;
|
||||||
@@ -54,7 +76,7 @@ class FairMQSocket
|
|||||||
virtual unsigned long GetMessagesRx() const = 0;
|
virtual unsigned long GetMessagesRx() const = 0;
|
||||||
|
|
||||||
FairMQTransportFactory* GetTransport() { return fTransport; }
|
FairMQTransportFactory* GetTransport() { return fTransport; }
|
||||||
void SetTransport(FairMQTransportFactory* transport) { fTransport=transport; }
|
void SetTransport(FairMQTransportFactory* transport) { fTransport = transport; }
|
||||||
|
|
||||||
virtual ~FairMQSocket() {};
|
virtual ~FairMQSocket() {};
|
||||||
|
|
||||||
|
@@ -7,69 +7,57 @@
|
|||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include <FairMQTransportFactory.h>
|
#include <FairMQTransportFactory.h>
|
||||||
#include <zeromq/FairMQTransportFactoryZMQ.h>
|
#include <fairmq/shmem/TransportFactory.h>
|
||||||
#include <shmem/FairMQTransportFactorySHM.h>
|
#include <fairmq/zeromq/TransportFactory.h>
|
||||||
#ifdef BUILD_NANOMSG_TRANSPORT
|
|
||||||
#include <nanomsg/FairMQTransportFactoryNN.h>
|
|
||||||
#endif /* BUILD_NANOMSG_TRANSPORT */
|
|
||||||
#ifdef BUILD_OFI_TRANSPORT
|
#ifdef BUILD_OFI_TRANSPORT
|
||||||
#include <fairmq/ofi/TransportFactory.h>
|
#include <fairmq/ofi/TransportFactory.h>
|
||||||
#endif
|
#endif
|
||||||
#include <FairMQLogger.h>
|
#include <FairMQLogger.h>
|
||||||
#include <fairmq/tools/Unique.h>
|
#include <fairmq/Tools.h>
|
||||||
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
FairMQTransportFactory::FairMQTransportFactory(const std::string& id)
|
using namespace std;
|
||||||
|
|
||||||
|
FairMQTransportFactory::FairMQTransportFactory(const string& id)
|
||||||
: fkId(id)
|
: fkId(id)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
auto FairMQTransportFactory::CreateTransportFactory(const std::string& type, const std::string& id, const fair::mq::ProgOptions* config) -> std::shared_ptr<FairMQTransportFactory>
|
auto FairMQTransportFactory::CreateTransportFactory(const string& type,
|
||||||
|
const string& id,
|
||||||
|
const fair::mq::ProgOptions* config)
|
||||||
|
-> shared_ptr<FairMQTransportFactory>
|
||||||
{
|
{
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
auto finalId = id;
|
auto finalId = id;
|
||||||
|
|
||||||
// Generate uuid if empty
|
// Generate uuid if empty
|
||||||
if (finalId == "")
|
if (finalId == "") {
|
||||||
{
|
|
||||||
finalId = fair::mq::tools::Uuid();
|
finalId = fair::mq::tools::Uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "zeromq")
|
if (type == "zeromq") {
|
||||||
{
|
return make_shared<fair::mq::zmq::TransportFactory>(finalId, config);
|
||||||
return make_shared<FairMQTransportFactoryZMQ>(finalId, config);
|
} else if (type == "shmem") {
|
||||||
|
return make_shared<fair::mq::shmem::TransportFactory>(finalId, config);
|
||||||
}
|
}
|
||||||
else if (type == "shmem")
|
|
||||||
{
|
|
||||||
return make_shared<FairMQTransportFactorySHM>(finalId, config);
|
|
||||||
}
|
|
||||||
#ifdef BUILD_NANOMSG_TRANSPORT
|
|
||||||
else if (type == "nanomsg")
|
|
||||||
{
|
|
||||||
return make_shared<FairMQTransportFactoryNN>(finalId, config);
|
|
||||||
}
|
|
||||||
#endif /* BUILD_NANOMSG_TRANSPORT */
|
|
||||||
#ifdef BUILD_OFI_TRANSPORT
|
#ifdef BUILD_OFI_TRANSPORT
|
||||||
else if (type == "ofi")
|
else if (type == "ofi") {
|
||||||
{
|
|
||||||
return make_shared<fair::mq::ofi::TransportFactory>(finalId, config);
|
return make_shared<fair::mq::ofi::TransportFactory>(finalId, config);
|
||||||
}
|
}
|
||||||
#endif /* BUILD_OFI_TRANSPORT */
|
#endif /* BUILD_OFI_TRANSPORT */
|
||||||
else
|
else {
|
||||||
{
|
LOG(error) << "Unavailable transport requested: "
|
||||||
LOG(error) << "Unavailable transport requested: " << "\"" << type << "\"" << ". Available are: "
|
<< "\"" << type << "\""
|
||||||
<< "\"zeromq\""
|
<< ". Available are: "
|
||||||
|
<< "\"zeromq\","
|
||||||
<< "\"shmem\""
|
<< "\"shmem\""
|
||||||
#ifdef BUILD_NANOMSG_TRANSPORT
|
|
||||||
<< ", \"nanomsg\""
|
|
||||||
#endif /* BUILD_NANOMSG_TRANSPORT */
|
|
||||||
#ifdef BUILD_OFI_TRANSPORT
|
#ifdef BUILD_OFI_TRANSPORT
|
||||||
<< ", and \"ofi\""
|
<< ", and \"ofi\""
|
||||||
#endif /* BUILD_OFI_TRANSPORT */
|
#endif /* BUILD_OFI_TRANSPORT */
|
||||||
<< ". Exiting.";
|
<< ". Exiting.";
|
||||||
exit(EXIT_FAILURE);
|
throw fair::mq::TransportFactoryError(fair::mq::tools::ToString("Unavailable transport requested: ", type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
#ifndef FAIRMQTRANSPORTFACTORY_H_
|
#ifndef FAIRMQTRANSPORTFACTORY_H_
|
||||||
#define FAIRMQTRANSPORTFACTORY_H_
|
#define FAIRMQTRANSPORTFACTORY_H_
|
||||||
|
|
||||||
#include <FairMQLogger.h>
|
|
||||||
#include <FairMQMessage.h>
|
#include <FairMQMessage.h>
|
||||||
#include <FairMQPoller.h>
|
#include <FairMQPoller.h>
|
||||||
#include <FairMQSocket.h>
|
#include <FairMQSocket.h>
|
||||||
@@ -18,7 +17,7 @@
|
|||||||
#include <fairmq/Transports.h>
|
#include <fairmq/Transports.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory> // shared_ptr
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -47,13 +46,22 @@ class FairMQTransportFactory
|
|||||||
fair::mq::ChannelResource* GetMemoryResource() { return &fMemoryResource; }
|
fair::mq::ChannelResource* GetMemoryResource() { return &fMemoryResource; }
|
||||||
operator fair::mq::ChannelResource*() { return &fMemoryResource; }
|
operator fair::mq::ChannelResource*() { return &fMemoryResource; }
|
||||||
|
|
||||||
/// @brief Create empty FairMQMessage
|
/// @brief Create empty FairMQMessage (for receiving)
|
||||||
/// @return pointer to FairMQMessage
|
/// @return pointer to FairMQMessage
|
||||||
virtual FairMQMessagePtr CreateMessage() = 0;
|
virtual FairMQMessagePtr CreateMessage() = 0;
|
||||||
|
/// @brief Create empty FairMQMessage (for receiving), align received buffer to specified alignment
|
||||||
|
/// @param alignment alignment to align received buffer to
|
||||||
|
/// @return pointer to FairMQMessage
|
||||||
|
virtual FairMQMessagePtr CreateMessage(fair::mq::Alignment alignment) = 0;
|
||||||
/// @brief Create new FairMQMessage of specified size
|
/// @brief Create new FairMQMessage of specified size
|
||||||
/// @param size message size
|
/// @param size message size
|
||||||
/// @return pointer to FairMQMessage
|
/// @return pointer to FairMQMessage
|
||||||
virtual FairMQMessagePtr CreateMessage(const size_t size) = 0;
|
virtual FairMQMessagePtr CreateMessage(const size_t size) = 0;
|
||||||
|
/// @brief Create new FairMQMessage of specified size and alignment
|
||||||
|
/// @param size message size
|
||||||
|
/// @param alignment message alignment
|
||||||
|
/// @return pointer to FairMQMessage
|
||||||
|
virtual FairMQMessagePtr CreateMessage(const size_t size, fair::mq::Alignment alignment) = 0;
|
||||||
/// @brief Create new FairMQMessage with user provided buffer and size
|
/// @brief Create new FairMQMessage with user provided buffer and size
|
||||||
/// @param data pointer to user provided buffer
|
/// @param data pointer to user provided buffer
|
||||||
/// @param size size of the user provided buffer
|
/// @param size size of the user provided buffer
|
||||||
@@ -61,20 +69,51 @@ class FairMQTransportFactory
|
|||||||
/// @param obj optional helper pointer that can be used in the callback
|
/// @param obj optional helper pointer that can be used in the callback
|
||||||
/// @return pointer to FairMQMessage
|
/// @return pointer to FairMQMessage
|
||||||
virtual FairMQMessagePtr CreateMessage(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) = 0;
|
virtual FairMQMessagePtr CreateMessage(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) = 0;
|
||||||
|
/// @brief create a message with the buffer located within the corresponding unmanaged region
|
||||||
|
/// @param unmanagedRegion the unmanaged region that this message buffer belongs to
|
||||||
|
/// @param data message buffer (must be within the region - checked at runtime by the transport)
|
||||||
|
/// @param size size of the message
|
||||||
|
/// @param hint optional parameter, returned to the user in the FairMQRegionCallback
|
||||||
virtual FairMQMessagePtr CreateMessage(FairMQUnmanagedRegionPtr& unmanagedRegion, void* data, const size_t size, void* hint = 0) = 0;
|
virtual FairMQMessagePtr CreateMessage(FairMQUnmanagedRegionPtr& unmanagedRegion, void* data, const size_t size, void* hint = 0) = 0;
|
||||||
|
|
||||||
/// Create a socket
|
/// @brief Create a socket
|
||||||
virtual FairMQSocketPtr CreateSocket(const std::string& type, const std::string& name) = 0;
|
virtual FairMQSocketPtr CreateSocket(const std::string& type, const std::string& name) = 0;
|
||||||
|
|
||||||
/// Create a poller for a single channel (all subchannels)
|
/// @brief Create a poller for a single channel (all subchannels)
|
||||||
virtual FairMQPollerPtr CreatePoller(const std::vector<FairMQChannel>& channels) const = 0;
|
virtual FairMQPollerPtr CreatePoller(const std::vector<FairMQChannel>& channels) const = 0;
|
||||||
/// Create a poller for specific channels
|
/// @brief Create a poller for specific channels
|
||||||
virtual FairMQPollerPtr CreatePoller(const std::vector<FairMQChannel*>& channels) const = 0;
|
virtual FairMQPollerPtr CreatePoller(const std::vector<FairMQChannel*>& channels) const = 0;
|
||||||
/// Create a poller for specific channels (all subchannels)
|
/// @brief Create a poller for specific channels (all subchannels)
|
||||||
virtual FairMQPollerPtr CreatePoller(const std::unordered_map<std::string, std::vector<FairMQChannel>>& channelsMap, const std::vector<std::string>& channelList) const = 0;
|
virtual FairMQPollerPtr CreatePoller(const std::unordered_map<std::string, std::vector<FairMQChannel>>& channelsMap, const std::vector<std::string>& channelList) const = 0;
|
||||||
|
|
||||||
virtual FairMQUnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, FairMQRegionCallback callback = nullptr, const std::string& path = "", int flags = 0) const = 0;
|
/// @brief Create new UnmanagedRegion
|
||||||
|
/// @param size size of the region
|
||||||
|
/// @param callback callback to be called when a message belonging to this region is no longer needed by the transport
|
||||||
|
/// @param path optional parameter to pass to the underlying transport
|
||||||
|
/// @param flags optional parameter to pass to the underlying transport
|
||||||
|
/// @return pointer to UnmanagedRegion
|
||||||
|
virtual FairMQUnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, FairMQRegionCallback callback = nullptr, const std::string& path = "", int flags = 0) = 0;
|
||||||
|
virtual FairMQUnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, FairMQRegionBulkCallback callback = nullptr, const std::string& path = "", int flags = 0) = 0;
|
||||||
|
/// @brief Create new UnmanagedRegion
|
||||||
|
/// @param size size of the region
|
||||||
|
/// @param userFlags flags to be stored with the region, have no effect on the transport, but can be retrieved from the region by the user
|
||||||
|
/// @param callback callback to be called when a message belonging to this region is no longer needed by the transport
|
||||||
|
/// @param path optional parameter to pass to the underlying transport
|
||||||
|
/// @param flags optional parameter to pass to the underlying transport
|
||||||
|
/// @return pointer to UnmanagedRegion
|
||||||
|
virtual FairMQUnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, const int64_t userFlags, FairMQRegionCallback callback = nullptr, const std::string& path = "", int flags = 0) = 0;
|
||||||
|
virtual FairMQUnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, const int64_t userFlags, FairMQRegionBulkCallback callback = nullptr, const std::string& path = "", int flags = 0) = 0;
|
||||||
|
|
||||||
|
/// @brief Subscribe to region events (creation, destruction, ...)
|
||||||
|
/// @param callback the callback that is called when a region event occurs
|
||||||
|
virtual void SubscribeToRegionEvents(FairMQRegionEventCallback callback) = 0;
|
||||||
|
/// @brief Check if there is an active subscription to region events
|
||||||
|
/// @return true/false
|
||||||
|
virtual bool SubscribedToRegionEvents() = 0;
|
||||||
|
/// @brief Unsubscribe from region events
|
||||||
|
virtual void UnsubscribeFromRegionEvents() = 0;
|
||||||
|
|
||||||
|
virtual std::vector<FairMQRegionInfo> GetRegionInfo() = 0;
|
||||||
|
|
||||||
/// Get transport type
|
/// Get transport type
|
||||||
virtual fair::mq::Transport GetType() const = 0;
|
virtual fair::mq::Transport GetType() const = 0;
|
||||||
@@ -137,6 +176,7 @@ namespace fair
|
|||||||
namespace mq
|
namespace mq
|
||||||
{
|
{
|
||||||
|
|
||||||
|
using TransportFactory = FairMQTransportFactory;
|
||||||
struct TransportFactoryError : std::runtime_error { using std::runtime_error::runtime_error; };
|
struct TransportFactoryError : std::runtime_error { using std::runtime_error::runtime_error; };
|
||||||
|
|
||||||
} /* namespace mq */
|
} /* namespace mq */
|
||||||
|
@@ -10,28 +10,113 @@
|
|||||||
#define FAIRMQUNMANAGEDREGION_H_
|
#define FAIRMQUNMANAGEDREGION_H_
|
||||||
|
|
||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
|
#include <cstdint> // uint32_t
|
||||||
#include <memory> // std::unique_ptr
|
#include <memory> // std::unique_ptr
|
||||||
#include <functional> // std::function
|
#include <functional> // std::function
|
||||||
|
#include <ostream> // std::ostream
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class FairMQTransportFactory;
|
||||||
|
|
||||||
|
enum class FairMQRegionEvent : int
|
||||||
|
{
|
||||||
|
created,
|
||||||
|
destroyed,
|
||||||
|
local_only
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FairMQRegionInfo
|
||||||
|
{
|
||||||
|
FairMQRegionInfo()
|
||||||
|
: managed(true)
|
||||||
|
, id(0)
|
||||||
|
, ptr(nullptr)
|
||||||
|
, size(0)
|
||||||
|
, flags(0)
|
||||||
|
, event(FairMQRegionEvent::created)
|
||||||
|
{}
|
||||||
|
|
||||||
|
FairMQRegionInfo(bool _managed, uint64_t _id, void* _ptr, size_t _size, int64_t _flags, FairMQRegionEvent _event)
|
||||||
|
: managed(_managed)
|
||||||
|
, id(_id)
|
||||||
|
, ptr(_ptr)
|
||||||
|
, size(_size)
|
||||||
|
, flags(_flags)
|
||||||
|
, event(_event)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool managed; // managed/unmanaged
|
||||||
|
uint64_t id; // id of the region
|
||||||
|
void* ptr; // pointer to the start of the region
|
||||||
|
size_t size; // region size
|
||||||
|
int64_t flags; // custom flags set by the creator
|
||||||
|
FairMQRegionEvent event;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FairMQRegionBlock {
|
||||||
|
void* ptr;
|
||||||
|
size_t size;
|
||||||
|
void* hint;
|
||||||
|
|
||||||
|
FairMQRegionBlock(void* p, size_t s, void* h)
|
||||||
|
: ptr(p), size(s), hint(h)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
using FairMQRegionCallback = std::function<void(void*, size_t, void*)>;
|
using FairMQRegionCallback = std::function<void(void*, size_t, void*)>;
|
||||||
|
using FairMQRegionBulkCallback = std::function<void(const std::vector<FairMQRegionBlock>&)>;
|
||||||
|
using FairMQRegionEventCallback = std::function<void(FairMQRegionInfo)>;
|
||||||
|
|
||||||
class FairMQUnmanagedRegion
|
class FairMQUnmanagedRegion
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
FairMQUnmanagedRegion() {}
|
||||||
|
FairMQUnmanagedRegion(FairMQTransportFactory* factory) : fTransport(factory) {}
|
||||||
|
|
||||||
virtual void* GetData() const = 0;
|
virtual void* GetData() const = 0;
|
||||||
virtual size_t GetSize() const = 0;
|
virtual size_t GetSize() const = 0;
|
||||||
|
virtual uint16_t GetId() const = 0;
|
||||||
|
virtual void SetLinger(uint32_t linger) = 0;
|
||||||
|
virtual uint32_t GetLinger() const = 0;
|
||||||
|
|
||||||
|
FairMQTransportFactory* GetTransport() { return fTransport; }
|
||||||
|
void SetTransport(FairMQTransportFactory* transport) { fTransport = transport; }
|
||||||
|
|
||||||
virtual ~FairMQUnmanagedRegion() {};
|
virtual ~FairMQUnmanagedRegion() {};
|
||||||
|
|
||||||
|
private:
|
||||||
|
FairMQTransportFactory* fTransport{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
using FairMQUnmanagedRegionPtr = std::unique_ptr<FairMQUnmanagedRegion>;
|
using FairMQUnmanagedRegionPtr = std::unique_ptr<FairMQUnmanagedRegion>;
|
||||||
|
|
||||||
|
inline std::ostream& operator<<(std::ostream& os, const FairMQRegionEvent& event)
|
||||||
|
{
|
||||||
|
switch (event) {
|
||||||
|
case FairMQRegionEvent::created:
|
||||||
|
return os << "created";
|
||||||
|
case FairMQRegionEvent::destroyed:
|
||||||
|
return os << "destroyed";
|
||||||
|
case FairMQRegionEvent::local_only:
|
||||||
|
return os << "local_only";
|
||||||
|
default:
|
||||||
|
return os << "unrecognized event";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace fair
|
namespace fair
|
||||||
{
|
{
|
||||||
namespace mq
|
namespace mq
|
||||||
{
|
{
|
||||||
|
|
||||||
using UnmanagedRegionPtr = std::unique_ptr<FairMQUnmanagedRegion>;
|
using RegionCallback = FairMQRegionCallback;
|
||||||
|
using RegionBulkCallback = FairMQRegionBulkCallback;
|
||||||
|
using RegionEventCallback = FairMQRegionEventCallback;
|
||||||
|
using RegionEvent = FairMQRegionEvent;
|
||||||
|
using RegionInfo = FairMQRegionInfo;
|
||||||
|
using RegionBlock = FairMQRegionBlock;
|
||||||
|
using UnmanagedRegion = FairMQUnmanagedRegion;
|
||||||
|
using UnmanagedRegionPtr = FairMQUnmanagedRegionPtr;
|
||||||
|
|
||||||
} /* namespace mq */
|
} /* namespace mq */
|
||||||
} /* namespace fair */
|
} /* namespace fair */
|
||||||
|
@@ -12,16 +12,19 @@
|
|||||||
* Created on May 14, 2015, 5:01 PM
|
* Created on May 14, 2015, 5:01 PM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fairmq/PropertyOutput.h>
|
|
||||||
#include "JSONParser.h"
|
#include "JSONParser.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQChannel.h"
|
||||||
#include <fairmq/Tools.h>
|
#include <fairmq/PropertyOutput.h>
|
||||||
|
#include <fairmq/tools/CppSTL.h>
|
||||||
|
#include <fairmq/tools/Strings.h>
|
||||||
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
#include <boost/any.hpp>
|
#include <boost/any.hpp>
|
||||||
|
|
||||||
#include <ios>
|
#include <iomanip>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace fair::mq;
|
using namespace fair::mq;
|
||||||
|
@@ -15,15 +15,11 @@
|
|||||||
#ifndef FAIR_MQ_JSONPARSER_H
|
#ifndef FAIR_MQ_JSONPARSER_H
|
||||||
#define FAIR_MQ_JSONPARSER_H
|
#define FAIR_MQ_JSONPARSER_H
|
||||||
|
|
||||||
#include <string>
|
#include <fairmq/Properties.h>
|
||||||
#include <vector>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
#include <boost/property_tree/ptree_fwd.hpp>
|
#include <boost/property_tree/ptree_fwd.hpp>
|
||||||
|
|
||||||
#include "FairMQChannel.h"
|
#include <stdexcept>
|
||||||
#include <fairmq/Properties.h>
|
#include <string>
|
||||||
|
|
||||||
namespace fair
|
namespace fair
|
||||||
{
|
{
|
||||||
|
@@ -60,7 +60,7 @@ FairMQMessagePtr getMessage(ContainerT &&container_, FairMQMemoryResource *targe
|
|||||||
container.data(),
|
container.data(),
|
||||||
containerSizeBytes);
|
containerSizeBytes);
|
||||||
return message;
|
return message;
|
||||||
};
|
}
|
||||||
|
|
||||||
} /* namespace mq */
|
} /* namespace mq */
|
||||||
} /* namespace fair */
|
} /* namespace fair */
|
||||||
|
@@ -15,8 +15,7 @@
|
|||||||
#include <fairmq/FairMQTransportFactory.h>
|
#include <fairmq/FairMQTransportFactory.h>
|
||||||
#include <fairmq/MemoryResources.h>
|
#include <fairmq/MemoryResources.h>
|
||||||
|
|
||||||
void *fair::mq::ChannelResource::do_allocate(std::size_t bytes, std::size_t /*alignment*/)
|
void *fair::mq::ChannelResource::do_allocate(std::size_t bytes, std::size_t alignment)
|
||||||
{
|
{
|
||||||
return setMessage(factory->CreateMessage(bytes));
|
return setMessage(factory->CreateMessage(bytes, fair::mq::Alignment{alignment}));
|
||||||
};
|
}
|
||||||
|
|
||||||
|
@@ -18,11 +18,12 @@
|
|||||||
#include <fairmq/FairMQMessage.h>
|
#include <fairmq/FairMQMessage.h>
|
||||||
class FairMQTransportFactory;
|
class FairMQTransportFactory;
|
||||||
|
|
||||||
|
#include <boost/container/container_fwd.hpp>
|
||||||
#include <boost/container/flat_map.hpp>
|
#include <boost/container/flat_map.hpp>
|
||||||
#include <boost/container/pmr/memory_resource.hpp>
|
#include <boost/container/pmr/memory_resource.hpp>
|
||||||
#include <boost/container/pmr/monotonic_buffer_resource.hpp>
|
|
||||||
#include <boost/container/pmr/polymorphic_allocator.hpp>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace fair {
|
namespace fair {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2017-2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
@@ -8,15 +8,20 @@
|
|||||||
|
|
||||||
#include <fairmq/Plugin.h>
|
#include <fairmq/Plugin.h>
|
||||||
#include <FairMQLogger.h>
|
#include <FairMQLogger.h>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
fair::mq::Plugin::Plugin(const string name, const Version version, const string maintainer, const string homepage, PluginServices* pluginServices)
|
fair::mq::Plugin::Plugin(string name,
|
||||||
: fkName{name}
|
Version version,
|
||||||
|
string maintainer,
|
||||||
|
string homepage,
|
||||||
|
PluginServices* pluginServices)
|
||||||
|
: fkName(std::move(name))
|
||||||
, fkVersion(version)
|
, fkVersion(version)
|
||||||
, fkMaintainer{maintainer}
|
, fkMaintainer(std::move(maintainer))
|
||||||
, fkHomepage{homepage}
|
, fkHomepage(std::move(homepage))
|
||||||
, fPluginServices{pluginServices}
|
, fPluginServices(pluginServices)
|
||||||
{
|
{
|
||||||
LOG(debug) << "Loaded plugin: " << *this;
|
LOG(debug) << "Loaded plugin: " << *this;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2017-2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
@@ -44,7 +44,11 @@ class Plugin
|
|||||||
using Version = tools::Version;
|
using Version = tools::Version;
|
||||||
|
|
||||||
Plugin() = delete;
|
Plugin() = delete;
|
||||||
Plugin(const std::string name, const Version version, const std::string maintainer, const std::string homepage, PluginServices* pluginServices);
|
Plugin(std::string name,
|
||||||
|
Version version,
|
||||||
|
std::string maintainer,
|
||||||
|
std::string homepage,
|
||||||
|
PluginServices* pluginServices);
|
||||||
|
|
||||||
Plugin(const Plugin&) = delete;
|
Plugin(const Plugin&) = delete;
|
||||||
Plugin operator=(const Plugin&) = delete;
|
Plugin operator=(const Plugin&) = delete;
|
||||||
|
@@ -28,6 +28,8 @@ using boost::optional;
|
|||||||
|
|
||||||
const std::string fair::mq::PluginManager::fgkLibPrefix = "FairMQPlugin_";
|
const std::string fair::mq::PluginManager::fgkLibPrefix = "FairMQPlugin_";
|
||||||
|
|
||||||
|
std::vector<boost::dll::shared_library> fair::mq::PluginManager::fgDLLKeepAlive = std::vector<boost::dll::shared_library>();
|
||||||
|
|
||||||
fair::mq::PluginManager::PluginManager()
|
fair::mq::PluginManager::PluginManager()
|
||||||
: fSearchPaths{}
|
: fSearchPaths{}
|
||||||
, fPluginFactories()
|
, fPluginFactories()
|
||||||
|
@@ -80,7 +80,7 @@ class PluginManager
|
|||||||
auto ForEachPluginProgOptions(std::function<void (boost::program_options::options_description)> func) const -> void { for(const auto& pair : fPluginProgOptions) { func(pair.second); } }
|
auto ForEachPluginProgOptions(std::function<void (boost::program_options::options_description)> func) const -> void { for(const auto& pair : fPluginProgOptions) { func(pair.second); } }
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
auto EmplacePluginServices(Args&&... args) -> void { fPluginServices = fair::mq::tools::make_unique<PluginServices>(std::forward<Args>(args)...); };
|
auto EmplacePluginServices(Args&&... args) -> void { fPluginServices = fair::mq::tools::make_unique<PluginServices>(std::forward<Args>(args)...); }
|
||||||
|
|
||||||
auto WaitForPluginsToReleaseDeviceControl() -> void { fPluginServices->WaitForReleaseDeviceControl(); }
|
auto WaitForPluginsToReleaseDeviceControl() -> void { fPluginServices->WaitForReleaseDeviceControl(); }
|
||||||
|
|
||||||
@@ -97,6 +97,7 @@ class PluginManager
|
|||||||
using fair::mq::tools::ToString;
|
using fair::mq::tools::ToString;
|
||||||
|
|
||||||
auto lib = shared_library{std::forward<Args>(args)...};
|
auto lib = shared_library{std::forward<Args>(args)...};
|
||||||
|
fgDLLKeepAlive.push_back(lib);
|
||||||
|
|
||||||
fPluginFactories[pluginName] = import_alias<PluginFactory>(
|
fPluginFactories[pluginName] = import_alias<PluginFactory>(
|
||||||
shared_library{lib},
|
shared_library{lib},
|
||||||
@@ -117,6 +118,7 @@ class PluginManager
|
|||||||
|
|
||||||
static const std::string fgkLibPrefix;
|
static const std::string fgkLibPrefix;
|
||||||
std::vector<boost::filesystem::path> fSearchPaths;
|
std::vector<boost::filesystem::path> fSearchPaths;
|
||||||
|
static std::vector<boost::dll::shared_library> fgDLLKeepAlive;
|
||||||
std::map<std::string, std::function<PluginFactory>> fPluginFactories;
|
std::map<std::string, std::function<PluginFactory>> fPluginFactories;
|
||||||
std::unique_ptr<PluginServices> fPluginServices;
|
std::unique_ptr<PluginServices> fPluginServices;
|
||||||
std::map<std::string, std::unique_ptr<Plugin>> fPlugins;
|
std::map<std::string, std::unique_ptr<Plugin>> fPlugins;
|
||||||
|
@@ -17,13 +17,14 @@
|
|||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/optional/optional_io.hpp>
|
#include <boost/optional/optional_io.hpp>
|
||||||
|
|
||||||
|
#include <condition_variable>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <map>
|
||||||
|
#include <mutex>
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <mutex>
|
#include <vector>
|
||||||
#include <map>
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
namespace fair
|
namespace fair
|
||||||
{
|
{
|
||||||
|
@@ -62,7 +62,7 @@ ValInfo ConvertVarValToValInfo(const po::variable_value& v)
|
|||||||
} catch (out_of_range& oor) {
|
} catch (out_of_range& oor) {
|
||||||
return {string("[unidentified_type]"), string("[unidentified_type]"), origin};
|
return {string("[unidentified_type]"), string("[unidentified_type]"), origin};
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
string ConvertVarValToString(const po::variable_value& v)
|
string ConvertVarValToString(const po::variable_value& v)
|
||||||
{
|
{
|
||||||
@@ -79,7 +79,7 @@ ProgOptions::ProgOptions()
|
|||||||
fAllOptions.add_options()
|
fAllOptions.add_options()
|
||||||
("help,h", "Print help")
|
("help,h", "Print help")
|
||||||
("version,v", "Print version")
|
("version,v", "Print version")
|
||||||
("severity", po::value<string>()->default_value("debug"), "Log severity level (console): trace, debug, info, state, warn, error, fatal, nolog")
|
("severity", po::value<string>()->default_value(""), "Log severity level (console): trace, debug, info, state, warn, error, fatal, nolog.")
|
||||||
("file-severity", po::value<string>()->default_value("debug"), "Log severity level (file): trace, debug, info, state, warn, error, fatal, nolog")
|
("file-severity", po::value<string>()->default_value("debug"), "Log severity level (file): trace, debug, info, state, warn, error, fatal, nolog")
|
||||||
("verbosity", po::value<string>()->default_value("medium"), "Log verbosity level: veryhigh, high, medium, low")
|
("verbosity", po::value<string>()->default_value("medium"), "Log verbosity level: veryhigh, high, medium, low")
|
||||||
("color", po::value<bool >()->default_value(true), "Log color (true/false)")
|
("color", po::value<bool >()->default_value(true), "Log color (true/false)")
|
||||||
@@ -117,16 +117,24 @@ void ProgOptions::ParseAll(const int argc, char const* const* argv, bool allowUn
|
|||||||
// clear the container because it was filled with default values and subsequent calls to store() do not overwrite the existing values
|
// clear the container because it was filled with default values and subsequent calls to store() do not overwrite the existing values
|
||||||
fVarMap.clear();
|
fVarMap.clear();
|
||||||
|
|
||||||
if (allowUnregistered) {
|
|
||||||
po::command_line_parser parser(argc, argv);
|
|
||||||
parser.options(fAllOptions).allow_unregistered();
|
|
||||||
po::parsed_options parsed = parser.run();
|
|
||||||
fUnregisteredOptions = po::collect_unrecognized(parsed.options, po::include_positional);
|
|
||||||
|
|
||||||
po::store(parsed, fVarMap);
|
po::command_line_parser parser(argc, argv);
|
||||||
} else {
|
|
||||||
po::store(po::parse_command_line(argc, argv, fAllOptions), fVarMap);
|
parser.options(fAllOptions);
|
||||||
|
|
||||||
|
if (allowUnregistered) {
|
||||||
|
parser.allow_unregistered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace po::command_line_style;
|
||||||
|
style_t style = style_t(allow_short | short_allow_adjacent | short_allow_next | allow_long | long_allow_adjacent | long_allow_next | allow_sticky | allow_dash_for_short);
|
||||||
|
parser.style(style);
|
||||||
|
|
||||||
|
po::parsed_options parsed = parser.run();
|
||||||
|
|
||||||
|
fUnregisteredOptions = po::collect_unrecognized(parsed.options, po::include_positional);
|
||||||
|
|
||||||
|
po::store(parsed, fVarMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgOptions::Notify()
|
void ProgOptions::Notify()
|
||||||
@@ -443,4 +451,4 @@ void ProgOptions::PrintOptionsRaw() const
|
|||||||
|
|
||||||
|
|
||||||
} // namespace mq
|
} // namespace mq
|
||||||
} // namespace fair
|
} // namespace fair
|
||||||
|
@@ -76,9 +76,11 @@ unordered_map<type_index, function<pair<string, string>(const Property&)>> Prope
|
|||||||
{ type_index(typeid(const char*)), [](const Property& p) { return pair<string, string>{ string(any_cast<const char*>(p)), "string" }; } },
|
{ type_index(typeid(const char*)), [](const Property& p) { return pair<string, string>{ string(any_cast<const char*>(p)), "string" }; } },
|
||||||
{ type_index(typeid(string)), [](const Property& p) { return pair<string, string>{ any_cast<string>(p), "string" }; } },
|
{ type_index(typeid(string)), [](const Property& p) { return pair<string, string>{ any_cast<string>(p), "string" }; } },
|
||||||
{ type_index(typeid(int)), [](const Property& p) { return getString<int>(p, "int"); } },
|
{ type_index(typeid(int)), [](const Property& p) { return getString<int>(p, "int"); } },
|
||||||
|
{ type_index(typeid(short)), [](const Property& p) { return getString<short>(p, "short"); } },
|
||||||
{ type_index(typeid(long)), [](const Property& p) { return getString<long>(p, "long"); } },
|
{ type_index(typeid(long)), [](const Property& p) { return getString<long>(p, "long"); } },
|
||||||
{ type_index(typeid(long long)), [](const Property& p) { return getString<long long>(p, "long long"); } },
|
{ type_index(typeid(long long)), [](const Property& p) { return getString<long long>(p, "long long"); } },
|
||||||
{ type_index(typeid(unsigned)), [](const Property& p) { return getString<unsigned>(p, "unsigned"); } },
|
{ type_index(typeid(unsigned)), [](const Property& p) { return getString<unsigned>(p, "unsigned"); } },
|
||||||
|
{ type_index(typeid(unsigned short)), [](const Property& p) { return getString<unsigned short>(p, "unsigned short"); } },
|
||||||
{ type_index(typeid(unsigned long)), [](const Property& p) { return getString<unsigned long>(p, "unsigned long"); } },
|
{ type_index(typeid(unsigned long)), [](const Property& p) { return getString<unsigned long>(p, "unsigned long"); } },
|
||||||
{ type_index(typeid(unsigned long long)), [](const Property& p) { return getString<unsigned long long>(p, "unsigned long long"); } },
|
{ type_index(typeid(unsigned long long)), [](const Property& p) { return getString<unsigned long long>(p, "unsigned long long"); } },
|
||||||
{ type_index(typeid(float)), [](const Property& p) { return getStringPair<float>(p, "float"); } },
|
{ type_index(typeid(float)), [](const Property& p) { return getStringPair<float>(p, "float"); } },
|
||||||
@@ -92,9 +94,11 @@ unordered_map<type_index, function<pair<string, string>(const Property&)>> Prope
|
|||||||
{ type_index(typeid(vector<unsigned char>)), [](const Property& p) { return getStringPair<vector<unsigned char>>(p, "vector<unsigned char>"); } },
|
{ type_index(typeid(vector<unsigned char>)), [](const Property& p) { return getStringPair<vector<unsigned char>>(p, "vector<unsigned char>"); } },
|
||||||
{ type_index(typeid(vector<string>)), [](const Property& p) { return getStringPair<vector<string>>(p, "vector<string>"); } },
|
{ type_index(typeid(vector<string>)), [](const Property& p) { return getStringPair<vector<string>>(p, "vector<string>"); } },
|
||||||
{ type_index(typeid(vector<int>)), [](const Property& p) { return getStringPair<vector<int>>(p, "vector<int>"); } },
|
{ type_index(typeid(vector<int>)), [](const Property& p) { return getStringPair<vector<int>>(p, "vector<int>"); } },
|
||||||
|
{ type_index(typeid(vector<short>)), [](const Property& p) { return getStringPair<vector<short>>(p, "vector<short>"); } },
|
||||||
{ type_index(typeid(vector<long>)), [](const Property& p) { return getStringPair<vector<long>>(p, "vector<long>"); } },
|
{ type_index(typeid(vector<long>)), [](const Property& p) { return getStringPair<vector<long>>(p, "vector<long>"); } },
|
||||||
{ type_index(typeid(vector<long long>)), [](const Property& p) { return getStringPair<vector<long long>>(p, "vector<long long>"); } },
|
{ type_index(typeid(vector<long long>)), [](const Property& p) { return getStringPair<vector<long long>>(p, "vector<long long>"); } },
|
||||||
{ type_index(typeid(vector<unsigned>)), [](const Property& p) { return getStringPair<vector<unsigned>>(p, "vector<unsigned>"); } },
|
{ type_index(typeid(vector<unsigned>)), [](const Property& p) { return getStringPair<vector<unsigned>>(p, "vector<unsigned>"); } },
|
||||||
|
{ type_index(typeid(vector<unsigned short>)), [](const Property& p) { return getStringPair<vector<unsigned short>>(p, "vector<unsigned short>"); } },
|
||||||
{ type_index(typeid(vector<unsigned long>)), [](const Property& p) { return getStringPair<vector<unsigned long>>(p, "vector<unsigned long>"); } },
|
{ type_index(typeid(vector<unsigned long>)), [](const Property& p) { return getStringPair<vector<unsigned long>>(p, "vector<unsigned long>"); } },
|
||||||
{ type_index(typeid(vector<unsigned long long>)), [](const Property& p) { return getStringPair<vector<unsigned long long>>(p, "vector<unsigned long long>"); } },
|
{ type_index(typeid(vector<unsigned long long>)), [](const Property& p) { return getStringPair<vector<unsigned long long>>(p, "vector<unsigned long long>"); } },
|
||||||
{ type_index(typeid(vector<float>)), [](const Property& p) { return getStringPair<vector<float>>(p, "vector<float>"); } },
|
{ type_index(typeid(vector<float>)), [](const Property& p) { return getStringPair<vector<float>>(p, "vector<float>"); } },
|
||||||
@@ -110,9 +114,11 @@ unordered_map<type_index, void(*)(const EventManager&, const string&, const Prop
|
|||||||
{ type_index(typeid(const char*)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, string>(k, string(any_cast<const char*>(p))); } },
|
{ type_index(typeid(const char*)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, string>(k, string(any_cast<const char*>(p))); } },
|
||||||
{ type_index(typeid(string)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, string>(k, any_cast<string>(p)); } },
|
{ type_index(typeid(string)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, string>(k, any_cast<string>(p)); } },
|
||||||
{ type_index(typeid(int)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, int>(k, any_cast<int>(p)); } },
|
{ type_index(typeid(int)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, int>(k, any_cast<int>(p)); } },
|
||||||
|
{ type_index(typeid(short)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, short>(k, any_cast<short>(p)); } },
|
||||||
{ type_index(typeid(long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, long>(k, any_cast<long>(p)); } },
|
{ type_index(typeid(long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, long>(k, any_cast<long>(p)); } },
|
||||||
{ type_index(typeid(long long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, long long>(k, any_cast<long long>(p)); } },
|
{ type_index(typeid(long long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, long long>(k, any_cast<long long>(p)); } },
|
||||||
{ type_index(typeid(unsigned)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, unsigned>(k, any_cast<unsigned>(p)); } },
|
{ type_index(typeid(unsigned)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, unsigned>(k, any_cast<unsigned>(p)); } },
|
||||||
|
{ type_index(typeid(unsigned short)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, unsigned short>(k, any_cast<unsigned short>(p)); } },
|
||||||
{ type_index(typeid(unsigned long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, unsigned long>(k, any_cast<unsigned long>(p)); } },
|
{ type_index(typeid(unsigned long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, unsigned long>(k, any_cast<unsigned long>(p)); } },
|
||||||
{ type_index(typeid(unsigned long long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, unsigned long long>(k, any_cast<unsigned long long>(p)); } },
|
{ type_index(typeid(unsigned long long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, unsigned long long>(k, any_cast<unsigned long long>(p)); } },
|
||||||
{ type_index(typeid(float)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, float>(k, any_cast<float>(p)); } },
|
{ type_index(typeid(float)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, float>(k, any_cast<float>(p)); } },
|
||||||
@@ -126,9 +132,11 @@ unordered_map<type_index, void(*)(const EventManager&, const string&, const Prop
|
|||||||
{ type_index(typeid(vector<unsigned char>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<unsigned char>>(k, any_cast<vector<unsigned char>>(p)); } },
|
{ type_index(typeid(vector<unsigned char>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<unsigned char>>(k, any_cast<vector<unsigned char>>(p)); } },
|
||||||
{ type_index(typeid(vector<string>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<string>>(k, any_cast<vector<string>>(p)); } },
|
{ type_index(typeid(vector<string>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<string>>(k, any_cast<vector<string>>(p)); } },
|
||||||
{ type_index(typeid(vector<int>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<int>>(k, any_cast<vector<int>>(p)); } },
|
{ type_index(typeid(vector<int>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<int>>(k, any_cast<vector<int>>(p)); } },
|
||||||
|
{ type_index(typeid(vector<short>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<short>>(k, any_cast<vector<short>>(p)); } },
|
||||||
{ type_index(typeid(vector<long>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<long>>(k, any_cast<vector<long>>(p)); } },
|
{ type_index(typeid(vector<long>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<long>>(k, any_cast<vector<long>>(p)); } },
|
||||||
{ type_index(typeid(vector<long long>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<long long>>(k, any_cast<vector<long long>>(p)); } },
|
{ type_index(typeid(vector<long long>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<long long>>(k, any_cast<vector<long long>>(p)); } },
|
||||||
{ type_index(typeid(vector<unsigned>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<unsigned>>(k, any_cast<vector<unsigned>>(p)); } },
|
{ type_index(typeid(vector<unsigned>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<unsigned>>(k, any_cast<vector<unsigned>>(p)); } },
|
||||||
|
{ type_index(typeid(vector<unsigned short>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<unsigned short>>(k, any_cast<vector<unsigned short>>(p)); } },
|
||||||
{ type_index(typeid(vector<unsigned long>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<unsigned long>>(k, any_cast<vector<unsigned long>>(p)); } },
|
{ type_index(typeid(vector<unsigned long>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<unsigned long>>(k, any_cast<vector<unsigned long>>(p)); } },
|
||||||
{ type_index(typeid(vector<unsigned long long>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<unsigned long long>>(k, any_cast<vector<unsigned long long>>(p)); } },
|
{ type_index(typeid(vector<unsigned long long>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<unsigned long long>>(k, any_cast<vector<unsigned long long>>(p)); } },
|
||||||
{ type_index(typeid(vector<float>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<float>>(k, any_cast<vector<float>>(p)); } },
|
{ type_index(typeid(vector<float>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<float>>(k, any_cast<vector<float>>(p)); } },
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <typeindex>
|
#include <typeindex>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
@@ -7,7 +7,8 @@
|
|||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include <fairmq/StateMachine.h>
|
#include <fairmq/StateMachine.h>
|
||||||
#include <fairmq/Tools.h>
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
// Increase maximum number of boost::msm states (default is 10)
|
// Increase maximum number of boost::msm states (default is 10)
|
||||||
// This #define has to be before any msm header includes
|
// This #define has to be before any msm header includes
|
||||||
@@ -79,7 +80,9 @@ struct Machine_ : public state_machine_def<Machine_>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Machine_()
|
Machine_()
|
||||||
: fLastTransitionResult(true)
|
: fState(State::Ok)
|
||||||
|
, fNewState(State::Ok)
|
||||||
|
, fLastTransitionResult(true)
|
||||||
, fNewStatePending(false)
|
, fNewStatePending(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
#include <fairmq/States.h>
|
#include <fairmq/States.h>
|
||||||
|
|
||||||
#include <fairlogger/Logger.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@@ -18,9 +18,10 @@ namespace fair
|
|||||||
namespace mq
|
namespace mq
|
||||||
{
|
{
|
||||||
|
|
||||||
array<string, 15> stateNames =
|
array<string, 16> stateNames =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
"UNDEFINED",
|
||||||
"OK",
|
"OK",
|
||||||
"ERROR",
|
"ERROR",
|
||||||
"IDLE",
|
"IDLE",
|
||||||
@@ -41,6 +42,7 @@ array<string, 15> stateNames =
|
|||||||
|
|
||||||
unordered_map<string, State> states =
|
unordered_map<string, State> states =
|
||||||
{
|
{
|
||||||
|
{ "UNDEFINED", State::Undefined },
|
||||||
{ "OK", State::Ok },
|
{ "OK", State::Ok },
|
||||||
{ "ERROR", State::Error },
|
{ "ERROR", State::Error },
|
||||||
{ "IDLE", State::Idle },
|
{ "IDLE", State::Idle },
|
||||||
|
@@ -20,6 +20,7 @@ namespace mq
|
|||||||
|
|
||||||
enum class State : int
|
enum class State : int
|
||||||
{
|
{
|
||||||
|
Undefined = 0,
|
||||||
Ok,
|
Ok,
|
||||||
Error,
|
Error,
|
||||||
Idle,
|
Idle,
|
||||||
@@ -39,7 +40,7 @@ enum class State : int
|
|||||||
|
|
||||||
enum class Transition : int
|
enum class Transition : int
|
||||||
{
|
{
|
||||||
Auto,
|
Auto = 0,
|
||||||
InitDevice,
|
InitDevice,
|
||||||
CompleteInit,
|
CompleteInit,
|
||||||
Bind,
|
Bind,
|
||||||
|
@@ -12,9 +12,12 @@
|
|||||||
/// @brief Parser implementation for key-value subopt format
|
/// @brief Parser implementation for key-value subopt format
|
||||||
|
|
||||||
#include <fairmq/SuboptParser.h>
|
#include <fairmq/SuboptParser.h>
|
||||||
|
#include <fairmq/JSONParser.h>
|
||||||
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
#include <cstring>
|
|
||||||
#include <utility> // make_pair
|
#include <utility> // make_pair
|
||||||
|
|
||||||
using boost::property_tree::ptree;
|
using boost::property_tree::ptree;
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#ifndef FAIR_MQ_SUBOPTPARSER_H
|
#ifndef FAIR_MQ_SUBOPTPARSER_H
|
||||||
#define FAIR_MQ_SUBOPTPARSER_H
|
#define FAIR_MQ_SUBOPTPARSER_H
|
||||||
|
|
||||||
#include <fairmq/JSONParser.h>
|
#include <fairmq/Properties.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@@ -10,8 +10,10 @@
|
|||||||
#define FAIR_MQ_TRANSPORTS_H
|
#define FAIR_MQ_TRANSPORTS_H
|
||||||
|
|
||||||
#include <fairmq/tools/CppSTL.h>
|
#include <fairmq/tools/CppSTL.h>
|
||||||
|
#include <fairmq/tools/Strings.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
@@ -24,11 +26,12 @@ enum class Transport
|
|||||||
{
|
{
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
ZMQ,
|
ZMQ,
|
||||||
NN,
|
|
||||||
SHM,
|
SHM,
|
||||||
OFI
|
OFI
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TransportError : std::runtime_error { using std::runtime_error::runtime_error; };
|
||||||
|
|
||||||
} /* namespace mq */
|
} /* namespace mq */
|
||||||
} /* namespace fair */
|
} /* namespace fair */
|
||||||
|
|
||||||
@@ -48,7 +51,6 @@ namespace mq
|
|||||||
static std::unordered_map<std::string, Transport> TransportTypes {
|
static std::unordered_map<std::string, Transport> TransportTypes {
|
||||||
{ "default", Transport::DEFAULT },
|
{ "default", Transport::DEFAULT },
|
||||||
{ "zeromq", Transport::ZMQ },
|
{ "zeromq", Transport::ZMQ },
|
||||||
{ "nanomsg", Transport::NN },
|
|
||||||
{ "shmem", Transport::SHM },
|
{ "shmem", Transport::SHM },
|
||||||
{ "ofi", Transport::OFI }
|
{ "ofi", Transport::OFI }
|
||||||
};
|
};
|
||||||
@@ -56,11 +58,22 @@ static std::unordered_map<std::string, Transport> TransportTypes {
|
|||||||
static std::unordered_map<Transport, std::string> TransportNames {
|
static std::unordered_map<Transport, std::string> TransportNames {
|
||||||
{ Transport::DEFAULT, "default" },
|
{ Transport::DEFAULT, "default" },
|
||||||
{ Transport::ZMQ, "zeromq" },
|
{ Transport::ZMQ, "zeromq" },
|
||||||
{ Transport::NN, "nanomsg" },
|
|
||||||
{ Transport::SHM, "shmem" },
|
{ Transport::SHM, "shmem" },
|
||||||
{ Transport::OFI, "ofi" }
|
{ Transport::OFI, "ofi" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline std::string TransportName(Transport transport)
|
||||||
|
{
|
||||||
|
return TransportNames[transport];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Transport TransportType(const std::string& transport)
|
||||||
|
try {
|
||||||
|
return TransportTypes.at(transport);
|
||||||
|
} catch (std::out_of_range&) {
|
||||||
|
throw TransportError(tools::ToString("Unknown transport provided: ", transport));
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace mq */
|
} /* namespace mq */
|
||||||
} /* namespace fair */
|
} /* namespace fair */
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2018-2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
#define FAIRMQ_GIT_DATE "@PROJECT_GIT_DATE@"
|
#define FAIRMQ_GIT_DATE "@PROJECT_GIT_DATE@"
|
||||||
#define FAIRMQ_REPO_URL "https://github.com/FairRootGroup/FairMQ"
|
#define FAIRMQ_REPO_URL "https://github.com/FairRootGroup/FairMQ"
|
||||||
#define FAIRMQ_LICENSE "LGPL-3.0"
|
#define FAIRMQ_LICENSE "LGPL-3.0"
|
||||||
#define FAIRMQ_COPYRIGHT "2012-2019 GSI"
|
#define FAIRMQ_COPYRIGHT "2012-2020 GSI"
|
||||||
#define FAIRMQ_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
|
#define FAIRMQ_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
|
||||||
|
|
||||||
#endif // FAIR_MQ_VERSION_H
|
#endif // FAIR_MQ_VERSION_H
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
/********************************************************************************
|
|
||||||
* Copyright (C) 2014-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" *
|
|
||||||
********************************************************************************/
|
|
||||||
|
|
||||||
#include "FairMQBenchmarkSampler.h"
|
|
||||||
|
|
||||||
#include "tools/RateLimit.h"
|
|
||||||
#include "../FairMQLogger.h"
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
FairMQBenchmarkSampler::FairMQBenchmarkSampler()
|
|
||||||
: fMultipart(false)
|
|
||||||
, fNumParts(1)
|
|
||||||
, fMsgSize(10000)
|
|
||||||
, fMsgRate(0)
|
|
||||||
, fNumIterations(0)
|
|
||||||
, fMaxIterations(0)
|
|
||||||
, fOutChannelName()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQBenchmarkSampler::InitTask()
|
|
||||||
{
|
|
||||||
fMultipart = fConfig->GetProperty<bool>("multipart");
|
|
||||||
fNumParts = fConfig->GetProperty<size_t>("num-parts");
|
|
||||||
fMsgSize = fConfig->GetProperty<size_t>("msg-size");
|
|
||||||
fMsgRate = fConfig->GetProperty<float>("msg-rate");
|
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
|
||||||
fOutChannelName = fConfig->GetProperty<string>("out-channel");
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQBenchmarkSampler::Run()
|
|
||||||
{
|
|
||||||
// store the channel reference to avoid traversing the map on every loop iteration
|
|
||||||
FairMQChannel& dataOutChannel = fChannels.at(fOutChannelName).at(0);
|
|
||||||
|
|
||||||
FairMQMessagePtr baseMsg(dataOutChannel.NewMessage(fMsgSize));
|
|
||||||
|
|
||||||
LOG(info) << "Starting the benchmark with message size of " << fMsgSize << " and " << fMaxIterations << " iterations.";
|
|
||||||
auto tStart = chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
fair::mq::tools::RateLimiter rateLimiter(fMsgRate);
|
|
||||||
|
|
||||||
while (!NewStatePending())
|
|
||||||
{
|
|
||||||
if (fMultipart)
|
|
||||||
{
|
|
||||||
FairMQParts parts;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < fNumParts; ++i)
|
|
||||||
{
|
|
||||||
parts.AddPart(dataOutChannel.NewMessage(fMsgSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dataOutChannel.Send(parts) >= 0)
|
|
||||||
{
|
|
||||||
if (fMaxIterations > 0)
|
|
||||||
{
|
|
||||||
if (fNumIterations >= fMaxIterations)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++fNumIterations;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FairMQMessagePtr msg(dataOutChannel.NewMessage(fMsgSize));
|
|
||||||
|
|
||||||
if (dataOutChannel.Send(msg) >= 0)
|
|
||||||
{
|
|
||||||
if (fMaxIterations > 0)
|
|
||||||
{
|
|
||||||
if (fNumIterations >= fMaxIterations)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++fNumIterations;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fMsgRate > 0)
|
|
||||||
{
|
|
||||||
rateLimiter.maybe_sleep();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto tEnd = chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
LOG(info) << "Done " << fNumIterations << " iterations in " << chrono::duration<double, milli>(tEnd - tStart).count() << "ms.";
|
|
||||||
}
|
|
@@ -9,13 +9,16 @@
|
|||||||
#ifndef FAIRMQBENCHMARKSAMPLER_H_
|
#ifndef FAIRMQBENCHMARKSAMPLER_H_
|
||||||
#define FAIRMQBENCHMARKSAMPLER_H_
|
#define FAIRMQBENCHMARKSAMPLER_H_
|
||||||
|
|
||||||
#include <string>
|
#include "../FairMQLogger.h"
|
||||||
#include <atomic>
|
|
||||||
#include <cstddef> // size_t
|
|
||||||
#include <cstdint> // uint64_t
|
|
||||||
|
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
#include "tools/RateLimit.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstddef> // size_t
|
||||||
|
#include <cstdint> // uint64_t
|
||||||
|
#include <cstring> // memset
|
||||||
|
#include <string>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sampler to generate traffic for benchmarking.
|
* Sampler to generate traffic for benchmarking.
|
||||||
@@ -24,21 +27,98 @@
|
|||||||
class FairMQBenchmarkSampler : public FairMQDevice
|
class FairMQBenchmarkSampler : public FairMQDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQBenchmarkSampler();
|
FairMQBenchmarkSampler()
|
||||||
|
: fMultipart(false)
|
||||||
|
, fMemSet(false)
|
||||||
|
, fNumParts(1)
|
||||||
|
, fMsgSize(10000)
|
||||||
|
, fMsgAlignment(0)
|
||||||
|
, fMsgRate(0)
|
||||||
|
, fNumIterations(0)
|
||||||
|
, fMaxIterations(0)
|
||||||
|
, fOutChannelName()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void InitTask() override
|
||||||
|
{
|
||||||
|
fMultipart = fConfig->GetProperty<bool>("multipart");
|
||||||
|
fMemSet = fConfig->GetProperty<bool>("memset");
|
||||||
|
fNumParts = fConfig->GetProperty<size_t>("num-parts");
|
||||||
|
fMsgSize = fConfig->GetProperty<size_t>("msg-size");
|
||||||
|
fMsgAlignment = fConfig->GetProperty<size_t>("msg-alignment");
|
||||||
|
fMsgRate = fConfig->GetProperty<float>("msg-rate");
|
||||||
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
|
fOutChannelName = fConfig->GetProperty<std::string>("out-channel");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Run() override
|
||||||
|
{
|
||||||
|
// store the channel reference to avoid traversing the map on every loop iteration
|
||||||
|
FairMQChannel& dataOutChannel = fChannels.at(fOutChannelName).at(0);
|
||||||
|
|
||||||
|
LOG(info) << "Starting the benchmark with message size of " << fMsgSize << " and " << fMaxIterations << " iterations.";
|
||||||
|
auto tStart = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
|
fair::mq::tools::RateLimiter rateLimiter(fMsgRate);
|
||||||
|
|
||||||
|
while (!NewStatePending()) {
|
||||||
|
if (fMultipart) {
|
||||||
|
FairMQParts parts;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < fNumParts; ++i) {
|
||||||
|
parts.AddPart(dataOutChannel.NewMessage(fMsgSize, fair::mq::Alignment{fMsgAlignment}));
|
||||||
|
if (fMemSet) {
|
||||||
|
std::memset(parts.At(i)->GetData(), 0, parts.At(i)->GetSize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataOutChannel.Send(parts) >= 0) {
|
||||||
|
if (fMaxIterations > 0) {
|
||||||
|
if (fNumIterations >= fMaxIterations) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++fNumIterations;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FairMQMessagePtr msg(dataOutChannel.NewMessage(fMsgSize, fair::mq::Alignment{fMsgAlignment}));
|
||||||
|
if (fMemSet) {
|
||||||
|
std::memset(msg->GetData(), 0, msg->GetSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataOutChannel.Send(msg) >= 0) {
|
||||||
|
if (fMaxIterations > 0) {
|
||||||
|
if (fNumIterations >= fMaxIterations) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++fNumIterations;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fMsgRate > 0) {
|
||||||
|
rateLimiter.maybe_sleep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto tEnd = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
|
LOG(info) << "Done " << fNumIterations << " iterations in " << std::chrono::duration<double, std::milli>(tEnd - tStart).count() << "ms.";
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~FairMQBenchmarkSampler() {}
|
virtual ~FairMQBenchmarkSampler() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool fMultipart;
|
bool fMultipart;
|
||||||
|
bool fMemSet;
|
||||||
size_t fNumParts;
|
size_t fNumParts;
|
||||||
size_t fMsgSize;
|
size_t fMsgSize;
|
||||||
|
size_t fMsgAlignment;
|
||||||
std::atomic<int> fMsgCounter;
|
std::atomic<int> fMsgCounter;
|
||||||
float fMsgRate;
|
float fMsgRate;
|
||||||
uint64_t fNumIterations;
|
uint64_t fNumIterations;
|
||||||
uint64_t fMaxIterations;
|
uint64_t fMaxIterations;
|
||||||
std::string fOutChannelName;
|
std::string fOutChannelName;
|
||||||
|
|
||||||
virtual void InitTask() override;
|
|
||||||
virtual void Run() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQBENCHMARKSAMPLER_H_ */
|
#endif /* FAIRMQBENCHMARKSAMPLER_H_ */
|
||||||
|
@@ -1,122 +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" *
|
|
||||||
********************************************************************************/
|
|
||||||
/**
|
|
||||||
* FairMQMerger.cxx
|
|
||||||
*
|
|
||||||
* @since 2012-12-06
|
|
||||||
* @author D. Klein, A. Rybalchenko
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "FairMQMerger.h"
|
|
||||||
#include "../FairMQLogger.h"
|
|
||||||
#include "../FairMQPoller.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
FairMQMerger::FairMQMerger()
|
|
||||||
: fMultipart(true)
|
|
||||||
, fInChannelName("data-in")
|
|
||||||
, fOutChannelName("data-out")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQMerger::RegisterChannelEndpoints()
|
|
||||||
{
|
|
||||||
RegisterChannelEndpoint(fInChannelName, 1, 10000);
|
|
||||||
RegisterChannelEndpoint(fOutChannelName, 1, 1);
|
|
||||||
|
|
||||||
PrintRegisteredChannels();
|
|
||||||
}
|
|
||||||
|
|
||||||
FairMQMerger::~FairMQMerger()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQMerger::InitTask()
|
|
||||||
{
|
|
||||||
fMultipart = fConfig->GetProperty<bool>("multipart");
|
|
||||||
fInChannelName = fConfig->GetProperty<string>("in-channel");
|
|
||||||
fOutChannelName = fConfig->GetProperty<string>("out-channel");
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQMerger::Run()
|
|
||||||
{
|
|
||||||
int numInputs = fChannels.at(fInChannelName).size();
|
|
||||||
|
|
||||||
vector<FairMQChannel*> chans;
|
|
||||||
|
|
||||||
for (auto& chan : fChannels.at(fInChannelName))
|
|
||||||
{
|
|
||||||
chans.push_back(&chan);
|
|
||||||
}
|
|
||||||
|
|
||||||
FairMQPollerPtr poller(NewPoller(chans));
|
|
||||||
|
|
||||||
if (fMultipart)
|
|
||||||
{
|
|
||||||
while (!NewStatePending())
|
|
||||||
{
|
|
||||||
poller->Poll(100);
|
|
||||||
|
|
||||||
// Loop over the data input channels.
|
|
||||||
for (int i = 0; i < numInputs; ++i)
|
|
||||||
{
|
|
||||||
// Check if the channel has data ready to be received.
|
|
||||||
if (poller->CheckInput(i))
|
|
||||||
{
|
|
||||||
FairMQParts payload;
|
|
||||||
|
|
||||||
if (Receive(payload, fInChannelName, i) >= 0)
|
|
||||||
{
|
|
||||||
if (Send(payload, fOutChannelName) < 0)
|
|
||||||
{
|
|
||||||
LOG(debug) << "Transfer interrupted";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG(debug) << "Transfer interrupted";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (!NewStatePending())
|
|
||||||
{
|
|
||||||
poller->Poll(100);
|
|
||||||
|
|
||||||
// Loop over the data input channels.
|
|
||||||
for (int i = 0; i < numInputs; ++i)
|
|
||||||
{
|
|
||||||
// Check if the channel has data ready to be received.
|
|
||||||
if (poller->CheckInput(i))
|
|
||||||
{
|
|
||||||
FairMQMessagePtr payload(fTransportFactory->CreateMessage());
|
|
||||||
|
|
||||||
if (Receive(payload, fInChannelName, i) >= 0)
|
|
||||||
{
|
|
||||||
if (Send(payload, fOutChannelName) < 0)
|
|
||||||
{
|
|
||||||
LOG(debug) << "Transfer interrupted";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG(debug) << "Transfer interrupted";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -16,23 +16,100 @@
|
|||||||
#define FAIRMQMERGER_H_
|
#define FAIRMQMERGER_H_
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
#include "../FairMQPoller.h"
|
||||||
|
#include "../FairMQLogger.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class FairMQMerger : public FairMQDevice
|
class FairMQMerger : public FairMQDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQMerger();
|
FairMQMerger()
|
||||||
virtual ~FairMQMerger();
|
: fMultipart(true)
|
||||||
|
, fInChannelName("data-in")
|
||||||
|
, fOutChannelName("data-out")
|
||||||
|
{}
|
||||||
|
~FairMQMerger() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool fMultipart;
|
bool fMultipart;
|
||||||
std::string fInChannelName;
|
std::string fInChannelName;
|
||||||
std::string fOutChannelName;
|
std::string fOutChannelName;
|
||||||
|
|
||||||
virtual void RegisterChannelEndpoints() override;
|
void InitTask() override
|
||||||
virtual void Run() override;
|
{
|
||||||
virtual void InitTask() override;
|
fMultipart = fConfig->GetProperty<bool>("multipart");
|
||||||
|
fInChannelName = fConfig->GetProperty<std::string>("in-channel");
|
||||||
|
fOutChannelName = fConfig->GetProperty<std::string>("out-channel");
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterChannelEndpoints() override
|
||||||
|
{
|
||||||
|
RegisterChannelEndpoint(fInChannelName, 1, 10000);
|
||||||
|
RegisterChannelEndpoint(fOutChannelName, 1, 1);
|
||||||
|
|
||||||
|
PrintRegisteredChannels();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Run() override
|
||||||
|
{
|
||||||
|
int numInputs = fChannels.at(fInChannelName).size();
|
||||||
|
|
||||||
|
std::vector<FairMQChannel*> chans;
|
||||||
|
|
||||||
|
for (auto& chan : fChannels.at(fInChannelName)) {
|
||||||
|
chans.push_back(&chan);
|
||||||
|
}
|
||||||
|
|
||||||
|
FairMQPollerPtr poller(NewPoller(chans));
|
||||||
|
|
||||||
|
if (fMultipart) {
|
||||||
|
while (!NewStatePending()) {
|
||||||
|
poller->Poll(100);
|
||||||
|
|
||||||
|
// Loop over the data input channels.
|
||||||
|
for (int i = 0; i < numInputs; ++i) {
|
||||||
|
// Check if the channel has data ready to be received.
|
||||||
|
if (poller->CheckInput(i)) {
|
||||||
|
FairMQParts payload;
|
||||||
|
|
||||||
|
if (Receive(payload, fInChannelName, i) >= 0) {
|
||||||
|
if (Send(payload, fOutChannelName) < 0) {
|
||||||
|
LOG(debug) << "Transfer interrupted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG(debug) << "Transfer interrupted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (!NewStatePending()) {
|
||||||
|
poller->Poll(100);
|
||||||
|
|
||||||
|
// Loop over the data input channels.
|
||||||
|
for (int i = 0; i < numInputs; ++i) {
|
||||||
|
// Check if the channel has data ready to be received.
|
||||||
|
if (poller->CheckInput(i)) {
|
||||||
|
FairMQMessagePtr payload(fTransportFactory->CreateMessage());
|
||||||
|
|
||||||
|
if (Receive(payload, fInChannelName, i) >= 0) {
|
||||||
|
if (Send(payload, fOutChannelName) < 0) {
|
||||||
|
LOG(debug) << "Transfer interrupted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG(debug) << "Transfer interrupted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQMERGER_H_ */
|
#endif /* FAIRMQMERGER_H_ */
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user