Compare commits

...

72 Commits

Author SHA1 Message Date
Alexey Rybalchenko
93dff3c5a7 Fix regression in shmmonitor 2021-02-19 09:54:29 +01:00
Alexey Rybalchenko
2b3e38d9a4 shmmonitor: non-interactive mode checks and quits 2021-02-10 10:36:08 +01:00
Alexey Rybalchenko
c6b13cd3a1 Fix shmem::Message::SetUsedSize(0) 2021-01-25 13:46:40 +01:00
Alexey Rybalchenko
c5487a11ed Remove custom implementation for enum hashing 2021-01-25 13:46:40 +01:00
Alexey Rybalchenko
4a09154a91 17-ify namespaces 2021-01-25 13:46:40 +01:00
Alexey Rybalchenko
d9a5e82160 Cleanup tools includes 2021-01-25 13:46:40 +01:00
Alexey Rybalchenko
751c53171c Replace tools::make_unique with std::make_unique 2021-01-25 13:46:40 +01:00
Alexey Rybalchenko
6815c9c172 zmq: implement alignment 2021-01-13 12:36:32 +01:00
Alexey Rybalchenko
02a3980343 Remove useless parameter from implementation 2021-01-13 12:36:32 +01:00
Alexey Rybalchenko
38b34785e0 format & remove unused variable 2021-01-13 12:36:32 +01:00
Alexey Rybalchenko
be94ceb7a7 zmq: simplify SetUsedSize implementation 2021-01-13 12:36:32 +01:00
Alexey Rybalchenko
afadbb53e4 zmq: correct accounting for msg size > 2GB 2021-01-13 12:36:32 +01:00
Alexey Rybalchenko
749d28a3b5 DeviceRunner: check FAIRMQ_SEVERITY env var for severity 2021-01-13 12:36:32 +01:00
Alexey Rybalchenko
29f45fa77d Rename TransferResult to TransferCode 2021-01-13 12:36:32 +01:00
Alexey Rybalchenko
ea746b17d0 Remove deprecated methods 2021-01-13 12:36:32 +01:00
Alexey Rybalchenko
636846fcdb Bump C++ standard requirement to C++17 2021-01-13 12:36:32 +01:00
Alexey Rybalchenko
f46d446d52 shm: do mlock/zeroing under shmem lock 2020-12-04 13:27:45 +01:00
Alexey Rybalchenko
db0937f339 shm: ensure local segments are complete for region subscriptions 2020-11-25 13:41:23 +01:00
Alexey Rybalchenko
bb1ce794b6 Let single message methods also return int64_t 2020-11-17 14:04:20 +01:00
Dennis Klein
9e2373b55d extern/asio: Bump to 1.18.0 2020-11-13 15:55:52 +01:00
Dennis Klein
c51e88e114 CI: Do not run unstable tests on macOS 10.14 hosts 2020-11-13 02:58:09 +01:00
Dennis Klein
f9219dab65 CI: Remove old options 2020-11-13 02:58:09 +01:00
Alexey Rybalchenko
0806720f61 Bump DDS version to 3.5.3 (multiple sessions support) 2020-11-13 02:58:09 +01:00
Alexey Rybalchenko
e39d17d09e Apply suggestions from -Wrange-loop-analysis 2020-11-13 02:58:09 +01:00
Alexey Rybalchenko
a14502242f DDS command UI: return EXIT_FAILURE on errors 2020-11-13 02:58:09 +01:00
Alexey Rybalchenko
d3697ec97b SDK: add WaitForPublisherCount() and related ctor arg 2020-11-13 02:58:09 +01:00
Dennis Klein
73377c5100 CI: Update macOS builds 2020-11-05 15:12:02 +01:00
Alexey Rybalchenko
49d8a1b4dd DeviceRunner: Set log severity only if one was provided 2020-10-19 10:23:08 +02:00
Alexey Rybalchenko
f14f507584 SDK: Remove instance limit from DDSSession 2020-10-09 13:35:55 +02:00
Alexey Rybalchenko
8dd0b25c06 Make BasicTopology actually movable 2020-10-09 13:35:55 +02:00
Christian Tacke
7edf436919 Improve PMIx Package Finding on Debian
Debian's libpmix-dev package installs everything below
/usr/lib/ARCH-TRIPLET/pmix2.
For some reasoning behind this,
see: https://bugs.debian.org/882033

CMake does not search there by default, so help it.

Also add myself to CONTRIBUTORS.
2020-10-08 17:27:12 +02:00
Alexey Rybalchenko
0e5978b160 Properties: add output support for shorts 2020-10-06 16:17:37 +02:00
Alexey Rybalchenko
71b1866d7b small includes cleanup 2020-10-06 16:17:37 +02:00
Alexey Rybalchenko
6699711e17 FairMQChannel: Refactor, moving short methods to header 2020-10-06 16:17:37 +02:00
Alexey Rybalchenko
120760da0a FairMQChannel: avoid copy when iterating over endpoints 2020-10-06 16:17:37 +02:00
Alexey Rybalchenko
d03a504ccd shmem: fail earlier if given an unsupported socket type 2020-10-06 16:17:37 +02:00
Alexey Rybalchenko
cf004f69b2 FairMQChannel: replace ResetChannel() with Invalidate() 2020-10-06 16:17:37 +02:00
Alexey Rybalchenko
cfa18ccfce FairMQChannel: remove artifacts from no longer used optimizations 2020-10-06 16:17:37 +02:00
Alexey Rybalchenko
e332e20dbd Remove thread-safety from channel methods 2020-10-06 16:17:37 +02:00
Alexey Rybalchenko
3ab10ced7a FairMQChannel: remove deprecated methods 2020-10-06 16:17:37 +02:00
Alexey Rybalchenko
1b30f3ac14 Update return types in ofi::Socket 2020-09-23 09:29:57 +02:00
Alexey Rybalchenko
35c7959c53 Workaround Cpp17MoveInsertable issue on xcode 12 2020-09-22 05:33:29 +02:00
Alexey Rybalchenko
5ea8ffeb34 Update command format in PMIx plugin 2020-09-17 14:22:03 +02:00
Alexey Rybalchenko
04ee1db8e5 Avoid default session id in shmem tests 2020-09-17 14:22:03 +02:00
Dennis Klein
4a15a38dd4 Tests.Device: Set correct log level for FairLogger 1.[7-8] 2020-09-16 15:43:58 +02:00
Dennis Klein
0f5e1b6815 Tests.SDK: Reduce timeout by factor 1000 because new machines can be fast enough to complete within 1ms 2020-09-16 15:43:58 +02:00
Dennis Klein
5e6ad47223 CI: Run macOS checks on newer environment 2020-09-16 15:43:58 +02:00
Alexey Rybalchenko
6932f88c84 Adjust transfer methods behaviour when interrupted
A transer is attempted even if the transport has been interrupted
(with a timeout). When the timeout is reached, transfer methods will
return TransferResult::interrupted (-3).
2020-09-16 15:43:58 +02:00
Alexey Rybalchenko
5e97d85956 Cleanup includes 2020-09-08 16:56:35 +02:00
Alexey Rybalchenko
fdbf289364 Update monitor & debug tools for multiple segments 2020-09-08 16:56:35 +02:00
Alexey Rybalchenko
266843cda5 Shm: initial multiple segments support 2020-09-08 16:56:35 +02:00
Alexey Rybalchenko
b126ede45a Shm: Verbosity switch for Cleanup methods 2020-09-08 16:56:35 +02:00
Alexey Rybalchenko
12e6a874db Remove built-in devices from the main lib 2020-09-08 16:56:35 +02:00
Alexey Rybalchenko
73109fe6d3 Shm: configurable allocation strategy 2020-09-08 16:56:35 +02:00
Alexey Rybalchenko
3b2d2a0ac8 Shm: Refactor to localize segment access 2020-09-08 16:56:35 +02:00
Alexey Rybalchenko
72a45f78b3 Shm: Add Monitor::GetDebugInfo() 2020-09-08 16:56:35 +02:00
Alexey Rybalchenko
b63f31d0e0 Shm: Provide debug infos only in debug mode 2020-09-08 16:56:35 +02:00
Alexey Rybalchenko
70a583d08d Shm: Provide segment/msg debug infos 2020-09-08 16:56:35 +02:00
Alexey Rybalchenko
fe9b87e4e2 Improve error reporting in SDK/fairmq-dds-command-ui 2020-09-07 12:52:43 +02:00
Alexey Rybalchenko
2ac27905e7 Move fairmq-dds-command-ui to SDK 2020-09-03 17:34:05 +02:00
Alexey Rybalchenko
690e8a0370 Retry on EINTR in blocking zmq calls 2020-08-28 18:22:03 +02:00
Alexey Rybalchenko
1f0c94f898 Fix tag mismatch in topology files 2020-08-17 12:39:10 +02:00
Alexey Rybalchenko
62ed4e5f80 Avoid unconditional call to now() when allocating message 2020-08-13 14:16:12 +02:00
neskovic@gmail.com
f1d6b18668 Message counter: use relaxed/acquire memory ordering 2020-08-13 11:49:55 +02:00
Alexey Rybalchenko
c0153a6b55 shmMonitor: Adjust output slightly 2020-08-07 14:27:14 +02:00
Alexey Rybalchenko
86a1dd38a2 ShmMonitor: Use FairLogger for timestamp calculation 2020-08-07 14:27:14 +02:00
Alexey Rybalchenko
be8ab06cc1 Bump FairLogger requirement to 1.6 2020-08-07 14:27:14 +02:00
Alexey Rybalchenko
b0f73017e2 shmmonitor: add output with -v (non-interactive) 2020-08-06 12:24:01 +02:00
Alexey Rybalchenko
b83655d5da MessageBadAlloc: report amount of available memory 2020-08-06 12:24:01 +02:00
Alexey Rybalchenko
9c27051cdc BenchmarkSampler: add alignment parameter 2020-08-06 12:24:01 +02:00
Alexey Rybalchenko
65f9519917 Add error handling for mlock 2020-08-06 12:24:01 +02:00
Alexey Rybalchenko
b5545c1575 Add helpers for AggregatedTopologyState 2020-07-17 12:41:53 +02:00
182 changed files with 2739 additions and 2937 deletions

View File

@@ -18,11 +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 OR BUILD_PMIX_PLUGIN) set(PROJECT_MIN_CXX_STANDARD 17)
set(PROJECT_MIN_CXX_STANDARD 14)
else()
set(PROJECT_MIN_CXX_STANDARD 11)
endif()
set_fairmq_defaults() set_fairmq_defaults()
@@ -53,6 +49,8 @@ fairmq_build_option(FAST_BUILD "Fast production build. Not recommen
DEFAULT OFF) DEFAULT OFF)
fairmq_build_option(USE_EXTERNAL_GTEST "Do not use bundled GTest. Not recommended." 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)
################################################################################ ################################################################################
@@ -80,7 +78,7 @@ endif()
if(BUILD_DDS_PLUGIN OR BUILD_SDK) if(BUILD_DDS_PLUGIN OR BUILD_SDK)
find_package2(PRIVATE DDS REQUIRED find_package2(PRIVATE DDS REQUIRED
VERSION 3.0 VERSION 3.5.3
) )
set(DDS_Boost_COMPONENTS system log log_setup regex filesystem thread) set(DDS_Boost_COMPONENTS system log log_setup regex filesystem thread)
set(DDS_Boost_VERSION 1.67) set(DDS_Boost_VERSION 1.67)
@@ -94,7 +92,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)
@@ -134,7 +132,7 @@ endif()
if(BUILD_SDK) if(BUILD_SDK)
find_package2(BUNDLED asio find_package2(BUNDLED asio
VERSION 1.13.0 VERSION 1.18.0
) )
if(NOT asio_FOUND) if(NOT asio_FOUND)
build_bundled(asio extern/asio) build_bundled(asio extern/asio)
@@ -260,7 +258,7 @@ install_cmake_package()
# Summary ###################################################################### # Summary ######################################################################
message(STATUS " ") message(STATUS " ")
message(STATUS " ${Cyan}CXX STANDARD${CR} ${BGreen}C++${CMAKE_CXX_STANDARD}${CR} (>= C++${PROJECT_MIN_CXX_STANDARD}, change with ${BMagenta}-DCMAKE_CXX_STANDARD=17${CR})") message(STATUS " ${Cyan}CXX STANDARD${CR} ${BGreen}C++${CMAKE_CXX_STANDARD}${CR} (>= C++${PROJECT_MIN_CXX_STANDARD}, change with ${BMagenta}-DCMAKE_CXX_STANDARD=20${CR})")
if(CMAKE_CXX_FLAGS) if(CMAKE_CXX_FLAGS)
message(STATUS " ") message(STATUS " ")
message(STATUS " ${Cyan}GLOBAL CXX FLAGS${CR} ${BGreen}${CMAKE_CXX_FLAGS}${CR}") message(STATUS " ${Cyan}GLOBAL CXX FLAGS${CR} ${BGreen}${CMAKE_CXX_FLAGS}${CR}")
@@ -363,9 +361,9 @@ else()
endif() endif()
message(STATUS " ${BWhite}tests${CR} ${tests_summary}") message(STATUS " ${BWhite}tests${CR} ${tests_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 (disable with ${BMagenta}-DBUILD_OFI_TRANSPORT=OFF${CR})")
else() else()
set(ofi_summary "${BRed} NO${CR} EXPERIMENTAL (requires C++14) (default, enable with ${BMagenta}-DBUILD_OFI_TRANSPORT=ON${CR})") set(ofi_summary "${BRed} NO${CR} EXPERIMENTAL (default, enable with ${BMagenta}-DBUILD_OFI_TRANSPORT=ON${CR})")
endif() endif()
message(STATUS " ${BWhite}ofi_transport${CR} ${ofi_summary}") message(STATUS " ${BWhite}ofi_transport${CR} ${ofi_summary}")
if(BUILD_DDS_PLUGIN) if(BUILD_DDS_PLUGIN)
@@ -375,9 +373,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} EXPERIMENTAL (requires C++14) (disable with ${BMagenta}-DBUILD_PMIX_PLUGIN=OFF${CR})") set(pmix_summary "${BGreen}YES${CR} EXPERIMENTAL (disable with ${BMagenta}-DBUILD_PMIX_PLUGIN=OFF${CR})")
else() else()
set(pmix_summary "${BRed} NO${CR} EXPERIMENTAL (requires C++14) (default, enable with ${BMagenta}-DBUILD_PMIX_PLUGIN=ON${CR})") set(pmix_summary "${BRed} NO${CR} EXPERIMENTAL (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)
@@ -393,9 +391,9 @@ else()
endif() endif()
message(STATUS " ${BWhite}docs${CR} ${docs_summary}") message(STATUS " ${BWhite}docs${CR} ${docs_summary}")
if(BUILD_SDK) if(BUILD_SDK)
set(sdk_summary "${BGreen}YES${CR} EXPERIMENTAL (required C++14) (disable with ${BMagenta}-DBUILD_SDK=OFF${CR})") set(sdk_summary "${BGreen}YES${CR} EXPERIMENTAL (disable with ${BMagenta}-DBUILD_SDK=OFF${CR})")
else() else()
set(sdk_summary "${BRed} NO${CR} EXPERIMENTAL (required C++14) (default, enable with ${BMagenta}-DBUILD_SDK=ON${CR})") set(sdk_summary "${BRed} NO${CR} EXPERIMENTAL (default, enable with ${BMagenta}-DBUILD_SDK=ON${CR})")
endif() endif()
message(STATUS " ${BWhite}sdk${CR} ${sdk_summary}") message(STATUS " ${BWhite}sdk${CR} ${sdk_summary}")
if(BUILD_SDK_COMMANDS) if(BUILD_SDK_COMMANDS)
@@ -429,4 +427,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 " ")
################################################################################ ################################################################################

View File

@@ -8,5 +8,6 @@ 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

View File

@@ -30,9 +30,6 @@ Set(configure_options "${configure_options};-DCMAKE_PREFIX_PATH=$ENV{SIMPATH}")
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};-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)
@@ -60,8 +57,13 @@ Ctest_Configure(BUILD "${CTEST_BINARY_DIRECTORY}"
Ctest_Build(BUILD "${CTEST_BINARY_DIRECTORY}") Ctest_Build(BUILD "${CTEST_BINARY_DIRECTORY}")
unset(exclude_tests)
if($ENV{EXCLUDE_UNSTABLE_DDS_TESTS})
set(exclude_tests EXCLUDE ".*\\.localhost$")
endif()
Ctest_Test(BUILD "${CTEST_BINARY_DIRECTORY}" Ctest_Test(BUILD "${CTEST_BINARY_DIRECTORY}"
# PARALLEL_LEVEL $ENV{number_of_processors} # PARALLEL_LEVEL $ENV{number_of_processors}
${exclude_tests}
PARALLEL_LEVEL $ENV{number_of_processors} PARALLEL_LEVEL $ENV{number_of_processors}
RETURN_VALUE _ctest_test_ret_val RETURN_VALUE _ctest_test_ret_val
) )

17
Jenkinsfile vendored
View File

@@ -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"
@@ -42,6 +46,11 @@ def jobMatrix(String prefix, List specs, Closure callback) {
echo "export GIT_BRANCH=$JOB_BASE_NAME" >> Dart.cfg echo "export GIT_BRANCH=$JOB_BASE_NAME" >> Dart.cfg
echo "echo \\\$PATH" >> Dart.cfg echo "echo \\\$PATH" >> Dart.cfg
''' '''
if (os =~ /macOS10.14/) {
sh "echo \"export EXCLUDE_UNSTABLE_DDS_TESTS=1\" >> Dart.cfg"
}
sh 'cat Dart.cfg' sh 'cat Dart.cfg'
callback.call(spec, label) callback.call(spec, label)
@@ -71,8 +80,8 @@ 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.14', arch: 'x86_64', compiler: 'AppleClang11.0', fairsoft: 'fairmq_dev'],
[os: 'MacOS10.14', arch: 'x86_64', compiler: 'AppleLLVM10.0.0', fairsoft: 'fairmq_dev'], [os: 'macOS10.15', arch: 'x86_64', compiler: 'AppleClang12.0', fairsoft: 'fairmq_dev'],
]) { spec, label -> ]) { spec, label ->
sh './Dart.sh alfa_ci Dart.cfg' sh './Dart.sh alfa_ci Dart.cfg'
} }

View File

@@ -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)

View File

@@ -29,7 +29,7 @@ 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)
list(JOIN Boost_LIBRARY_DIRS ":" LIB_DIR) list(JOIN Boost_LIBRARY_DIRS ":" LIB_DIR)
set(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/fairmq/plugins/DDS) 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)

View File

@@ -18,7 +18,7 @@ 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) 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) list(JOIN Boost_LIBRARY_DIRS ":" LIB_DIR)
set(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/fairmq/plugins/DDS) 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-n-m-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-n-m-topology.xml @ONLY) 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}/ex-n-m-pair-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-n-m-pair-topology.xml @ONLY)

View File

@@ -10,7 +10,7 @@
<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> <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> <env reachable="false">fairmq-ex-n-m-env.sh</env>
<properties> <properties>
<name access="write">fmqchan_sync</id> <name access="write">fmqchan_sync</name>
</properties> </properties>
</decltask> </decltask>
@@ -18,8 +18,8 @@
<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> <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> <env reachable="false">fairmq-ex-n-m-env.sh</env>
<properties> <properties>
<name access="read">fmqchan_sync</id> <name access="read">fmqchan_sync</name>
<name access="read">fmqchan_data</id> <name access="read">fmqchan_data</name>
</properties> </properties>
</decltask> </decltask>
@@ -27,7 +27,7 @@
<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> <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> <env reachable="false">fairmq-ex-n-m-env.sh</env>
<properties> <properties>
<name access="write">fmqchan_data</id> <name access="write">fmqchan_data</name>
</properties> </properties>
</decltask> </decltask>

View File

@@ -10,7 +10,7 @@
<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> <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> <env reachable="false">fairmq-ex-n-m-env.sh</env>
<properties> <properties>
<name access="write">fmqchan_sync</id> <name access="write">fmqchan_sync</name>
</properties> </properties>
</decltask> </decltask>
@@ -18,8 +18,8 @@
<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> <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> <env reachable="false">fairmq-ex-n-m-env.sh</env>
<properties> <properties>
<name access="read">fmqchan_sync</id> <name access="read">fmqchan_sync</name>
<name access="read">fmqchan_data</id> <name access="read">fmqchan_data</name>
</properties> </properties>
</decltask> </decltask>
@@ -27,7 +27,7 @@
<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> <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> <env reachable="false">fairmq-ex-n-m-env.sh</env>
<properties> <properties>
<name access="write">fmqchan_data</id> <name access="write">fmqchan_data</name>
</properties> </properties>
</decltask> </decltask>

View File

@@ -21,7 +21,7 @@ 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) 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) list(JOIN Boost_LIBRARY_DIRS ":" LIB_DIR)
set(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/fairmq/plugins/DDS) 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-qc-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-qc-topology.xml @ONLY) 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-ex-qc-env.sh ${CMAKE_CURRENT_BINARY_DIR}/fairmq-ex-qc-env.sh @ONLY)

View File

@@ -38,6 +38,7 @@ void Sampler::InitTask()
fChannels.at("data").at(0).Transport()->SubscribeToRegionEvents([](FairMQRegionInfo info) { fChannels.at("data").at(0).Transport()->SubscribeToRegionEvents([](FairMQRegionInfo info) {
LOG(info) << "Region event: " << info.event LOG(info) << "Region event: " << info.event
<< ", managed: " << info.managed
<< ", id: " << info.id << ", id: " << info.id
<< ", ptr: " << info.ptr << ", ptr: " << info.ptr
<< ", size: " << info.size << ", size: " << info.size

View File

@@ -31,6 +31,7 @@ void Sink::InitTask()
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations"); fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
fChannels.at("data").at(0).Transport()->SubscribeToRegionEvents([](FairMQRegionInfo info) { fChannels.at("data").at(0).Transport()->SubscribeToRegionEvents([](FairMQRegionInfo info) {
LOG(info) << "Region event: " << info.event LOG(info) << "Region event: " << info.event
<< ", managed: " << info.managed
<< ", id: " << info.id << ", id: " << info.id
<< ", ptr: " << info.ptr << ", ptr: " << info.ptr
<< ", size: " << info.size << ", size: " << info.size

2
extern/asio vendored

View File

@@ -174,12 +174,6 @@ if(BUILD_FAIRMQ)
) )
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
@@ -221,10 +215,6 @@ if(BUILD_FAIRMQ)
FairMQPoller.cxx FairMQPoller.cxx
FairMQSocket.cxx FairMQSocket.cxx
FairMQTransportFactory.cxx FairMQTransportFactory.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
@@ -278,6 +268,9 @@ 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(FAIRMQ_DEBUG_MODE)
target_compile_definitions(${_target} PUBLIC FAIRMQ_DEBUG_MODE)
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)
endif() endif()
@@ -374,12 +367,16 @@ 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 PicoSHA2
) )
target_include_directories(fairmq-shmmonitor PUBLIC target_include_directories(fairmq-shmmonitor PUBLIC

View File

@@ -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,8 +56,14 @@ 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);
auto envFairMQSeverity = getenv("FAIRMQ_SEVERITY");
if (envFairMQSeverity) {
severity = envFairMQSeverity;
}
if (severity != "") {
fair::Logger::SetConsoleSeverity(severity); fair::Logger::SetConsoleSeverity(severity);
} }
}
if (printLogo) { if (printLogo) {
LOG(info) << endl LOG(info) << endl
@@ -150,8 +160,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;
} }

View File

@@ -13,15 +13,14 @@
#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>
#include <string> #include <string>
#include <vector> #include <vector>
namespace fair { namespace fair::mq
namespace mq { {
/** /**
* @class DeviceRunner DeviceRunner.h <fairmq/DeviceRunner.h> * @class DeviceRunner DeviceRunner.h <fairmq/DeviceRunner.h>
@@ -89,7 +88,6 @@ struct ModifyRawCmdLineArgs : Event<DeviceRunner&> {};
struct InstantiateDevice : Event<DeviceRunner&> {}; struct InstantiateDevice : Event<DeviceRunner&> {};
} /* namespace hooks */ } /* namespace hooks */
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
#endif /* FAIR_MQ_DEVICERUNNER_H */ #endif /* FAIR_MQ_DEVICERUNNER_H */

View File

@@ -21,9 +21,7 @@
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
#include <boost/signals2.hpp> #include <boost/signals2.hpp>
namespace fair namespace fair::mq
{
namespace mq
{ {
// Inherit from this base event type to create custom event types // Inherit from this base event type to create custom event types
@@ -137,7 +135,6 @@ class EventManager
} }
}; /* class EventManager */ }; /* class EventManager */
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
#endif /* FAIR_MQ_EVENTMANAGER_H */ #endif /* FAIR_MQ_EVENTMANAGER_H */

View File

@@ -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>
@@ -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,10 +128,8 @@ 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)
@@ -137,12 +138,6 @@ FairMQChannel& FairMQChannel::operator=(const FairMQChannel& chan)
return *this; return *this;
} }
{
// TODO: replace this with std::scoped_lock (c++17)
lock(fMtx, chan.fMtx);
lock_guard<mutex> lock1(fMtx, adopt_lock);
lock_guard<mutex> lock2(chan.fMtx, adopt_lock);
fTransportFactory = nullptr; fTransportFactory = nullptr;
fTransportType = chan.fTransportType; fTransportType = chan.fTransportType;
fSocket = nullptr; fSocket = nullptr;
@@ -159,350 +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;
@@ -535,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);
@@ -637,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;
@@ -648,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)
@@ -670,14 +331,11 @@ 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;
@@ -718,10 +376,3 @@ bool FairMQChannel::BindEndpoint(string& endpoint)
} }
} }
void FairMQChannel::ResetChannel()
{
lock_guard<mutex> lock(fMtx);
fIsValid = false;
// TODO: implement channel resetting
}

View File

@@ -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" or "shmem") /// Get channel transport name ("default", "zeromq" or "shmem")
/// @return Returns channel transport name (e.g. "default", "zeromq" 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" 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,14 +250,14 @@ 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, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::interrupted if interrupted (e.g. by requested state change)
int Send(FairMQMessagePtr& msg, int sndTimeoutInMs = -1) int64_t Send(FairMQMessagePtr& msg, int sndTimeoutInMs = -1)
{ {
CheckSendCompatibility(msg); CheckSendCompatibility(msg);
return fSocket->Send(msg, sndTimeoutInMs); return fSocket->Send(msg, sndTimeoutInMs);
@@ -262,8 +266,8 @@ 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, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::interrupted if interrupted (e.g. by requested state change)
int Receive(FairMQMessagePtr& msg, int rcvTimeoutInMs = -1) int64_t Receive(FairMQMessagePtr& msg, int rcvTimeoutInMs = -1)
{ {
CheckReceiveCompatibility(msg); CheckReceiveCompatibility(msg);
return fSocket->Receive(msg, rcvTimeoutInMs); return fSocket->Receive(msg, rcvTimeoutInMs);
@@ -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, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::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, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::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, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::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, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::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)
@@ -376,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)
{ {
@@ -439,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_ */

View File

@@ -24,34 +24,6 @@
using namespace std; using namespace std;
using namespace fair::mq; using namespace fair::mq;
static map<Transition, State> backwardsCompatibilityWaitForEndOfStateHelper =
{
{ Transition::InitDevice, State::InitializingDevice },
{ Transition::CompleteInit, State::Initialized },
{ Transition::Bind, State::Bound },
{ Transition::Connect, State::DeviceReady },
{ Transition::InitTask, State::Ready },
{ Transition::Run, State::Ready },
{ Transition::Stop, State::Ready },
{ Transition::ResetTask, State::DeviceReady },
{ Transition::ResetDevice, State::Idle }
};
static map<int, Transition> backwardsCompatibilityChangeStateHelper =
{
{ FairMQDevice::Event::INIT_DEVICE, Transition::InitDevice },
{ FairMQDevice::Event::internal_DEVICE_READY, Transition::Auto },
{ FairMQDevice::Event::INIT_TASK, Transition::InitTask },
{ FairMQDevice::Event::internal_READY, Transition::Auto },
{ FairMQDevice::Event::RUN, Transition::Run },
{ FairMQDevice::Event::STOP, Transition::Stop },
{ FairMQDevice::Event::RESET_TASK, Transition::ResetTask },
{ FairMQDevice::Event::RESET_DEVICE, Transition::ResetDevice },
{ FairMQDevice::Event::internal_IDLE, Transition::Auto },
{ FairMQDevice::Event::END, Transition::End },
{ FairMQDevice::Event::ERROR_FOUND, Transition::ErrorFound }
};
constexpr const char* FairMQDevice::DefaultId; constexpr const char* FairMQDevice::DefaultId;
constexpr int FairMQDevice::DefaultIOThreads; constexpr int FairMQDevice::DefaultIOThreads;
constexpr const char* FairMQDevice::DefaultTransportName; constexpr const char* FairMQDevice::DefaultTransportName;
@@ -103,7 +75,7 @@ FairMQDevice::FairMQDevice(ProgOptions* config, const tools::Version version)
: fTransportFactory(nullptr) : fTransportFactory(nullptr)
, fTransports() , fTransports()
, fChannels() , fChannels()
, fInternalConfig(config ? nullptr : tools::make_unique<ProgOptions>()) , fInternalConfig(config ? nullptr : make_unique<ProgOptions>())
, fConfig(config ? config : fInternalConfig.get()) , fConfig(config ? config : fInternalConfig.get())
, fId(DefaultId) , fId(DefaultId)
, fDefaultTransportType(DefaultTransportType) , fDefaultTransportType(DefaultTransportType)
@@ -244,16 +216,6 @@ void FairMQDevice::TransitionTo(const fair::mq::State s)
} }
} }
bool FairMQDevice::ChangeState(const int transition)
{
return ChangeState(backwardsCompatibilityChangeStateHelper.at(transition));
}
void FairMQDevice::WaitForEndOfState(Transition transition)
{
WaitForState(backwardsCompatibilityWaitForEndOfStateHelper.at(transition));
}
void FairMQDevice::InitWrapper() void FairMQDevice::InitWrapper()
{ {
// run initialization once CompleteInit transition is requested // run initialization once CompleteInit transition is requested
@@ -390,7 +352,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 {

View File

@@ -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>
@@ -42,51 +41,16 @@ using FairMQChannelMap = std::unordered_map<std::string, std::vector<FairMQChann
using InputMsgCallback = std::function<bool(FairMQMessagePtr&, int)>; using InputMsgCallback = std::function<bool(FairMQMessagePtr&, int)>;
using InputMultipartCallback = std::function<bool(FairMQParts&, int)>; using InputMultipartCallback = std::function<bool(FairMQParts&, int)>;
namespace fair namespace fair::mq
{
namespace mq
{ {
struct OngoingTransition : std::runtime_error { using std::runtime_error::runtime_error; }; struct OngoingTransition : std::runtime_error { using std::runtime_error::runtime_error; };
} }
}
class FairMQDevice class FairMQDevice
{ {
friend class FairMQChannel; friend class FairMQChannel;
public: public:
// backwards-compatibility enum for old state machine interface, todo: delete this
enum Event
{
INIT_DEVICE,
internal_DEVICE_READY,
INIT_TASK,
internal_READY,
RUN,
STOP,
RESET_TASK,
RESET_DEVICE,
internal_IDLE,
END,
ERROR_FOUND
};
// backwards-compatibility enum for old state machine interface, todo: delete this
enum State
{
OK,
Error,
IDLE,
INITIALIZING_DEVICE,
DEVICE_READY,
INITIALIZING_TASK,
READY,
RUNNING,
RESETTING_TASK,
RESETTING_DEVICE,
EXITING
};
/// Default constructor /// Default constructor
FairMQDevice(); FairMQDevice();
/// Constructor with external fair::mq::ProgOptions /// Constructor with external fair::mq::ProgOptions
@@ -129,8 +93,8 @@ 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, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::interrupted if interrupted (e.g. by requested state change)
int Send(FairMQMessagePtr& msg, const std::string& channel, const int index = 0, int sndTimeoutInMs = -1) int64_t 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,8 +104,8 @@ 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, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::interrupted if interrupted (e.g. by requested state change)
int Receive(FairMQMessagePtr& msg, const std::string& channel, const int index = 0, int rcvTimeoutInMs = -1) int64_t 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 +115,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, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::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 +126,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, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::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);
@@ -363,10 +327,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;
} }
} }
} }
@@ -450,8 +414,6 @@ class FairMQDevice
/// Called in the RUNNING state once after executing the Run()/ConditionalRun() method /// Called in the RUNNING state once after executing the Run()/ConditionalRun() method
virtual void PostRun() {} virtual void PostRun() {}
virtual void Pause() __attribute__((deprecated("PAUSE state is removed. This method is never called. To pause Run, go to READY with STOP transition and back to RUNNING with RUN to resume."))) {}
/// Resets the user task (to be overloaded in child classes) /// Resets the user task (to be overloaded in child classes)
virtual void ResetTask() {} virtual void ResetTask() {}
@@ -462,11 +424,6 @@ class FairMQDevice
bool ChangeState(const fair::mq::Transition transition) { return fStateMachine.ChangeState(transition); } bool ChangeState(const fair::mq::Transition transition) { return fStateMachine.ChangeState(transition); }
bool ChangeState(const std::string& transition) { return fStateMachine.ChangeState(fair::mq::GetTransition(transition)); } bool ChangeState(const std::string& transition) { return fStateMachine.ChangeState(fair::mq::GetTransition(transition)); }
bool ChangeState(const int transition) __attribute__((deprecated("Use ChangeState(const fair::mq::Transition transition).")));
void WaitForEndOfState(const fair::mq::Transition transition) __attribute__((deprecated("Use WaitForState(fair::mq::State expectedState).")));
void WaitForEndOfState(const std::string& transition) __attribute__((deprecated("Use WaitForState(fair::mq::State expectedState)."))) { WaitForState(transition); }
fair::mq::State WaitForNextState() { return fStateQueue.WaitForNext(); } fair::mq::State WaitForNextState() { return fStateQueue.WaitForNext(); }
void WaitForState(fair::mq::State state) { fStateQueue.WaitForState(state); } void WaitForState(fair::mq::State state) { fStateQueue.WaitForState(state); }
void WaitForState(const std::string& state) { WaitForState(fair::mq::GetState(state)); } void WaitForState(const std::string& state) { WaitForState(fair::mq::GetState(state)); }
@@ -479,9 +436,6 @@ class FairMQDevice
void SubscribeToNewTransition(const std::string& key, std::function<void(const fair::mq::Transition)> callback) { fStateMachine.SubscribeToNewTransition(key, callback); } void SubscribeToNewTransition(const std::string& key, std::function<void(const fair::mq::Transition)> callback) { fStateMachine.SubscribeToNewTransition(key, callback); }
void UnsubscribeFromNewTransition(const std::string& key) { fStateMachine.UnsubscribeFromNewTransition(key); } void UnsubscribeFromNewTransition(const std::string& key) { fStateMachine.UnsubscribeFromNewTransition(key); }
bool CheckCurrentState(const int /* state */) const __attribute__((deprecated("Use NewStatePending()."))) { return !fStateMachine.NewStatePending(); }
bool CheckCurrentState(const std::string& /* state */) const __attribute__((deprecated("Use NewStatePending()."))) { return !fStateMachine.NewStatePending(); }
/// Returns true is a new state has been requested, signaling the current handler to stop. /// Returns true is a new state has been requested, signaling the current handler to stop.
bool NewStatePending() const { return fStateMachine.NewStatePending(); } bool NewStatePending() const { return fStateMachine.NewStatePending(); }

View File

@@ -18,9 +18,7 @@
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 fair::mq
{
namespace mq
{ {
struct Alignment struct Alignment
@@ -29,8 +27,7 @@ struct Alignment
explicit operator size_t() const { return alignment; } explicit operator size_t() const { return alignment; }
}; };
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
class FairMQMessage class FairMQMessage
{ {
@@ -39,7 +36,9 @@ class FairMQMessage
FairMQMessage(FairMQTransportFactory* factory) : fTransport(factory) {} FairMQMessage(FairMQTransportFactory* factory) : fTransport(factory) {}
virtual void Rebuild() = 0; virtual void Rebuild() = 0;
virtual void Rebuild(fair::mq::Alignment alignment) = 0;
virtual void Rebuild(const size_t size) = 0; virtual void Rebuild(const size_t size) = 0;
virtual void Rebuild(const size_t size, fair::mq::Alignment alignment) = 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;
virtual void* GetData() const = 0; virtual void* GetData() const = 0;
@@ -61,9 +60,7 @@ class FairMQMessage
using FairMQMessagePtr = std::unique_ptr<FairMQMessage>; using FairMQMessagePtr = std::unique_ptr<FairMQMessage>;
namespace fair namespace fair::mq
{
namespace mq
{ {
using Message = FairMQMessage; using Message = FairMQMessage;
@@ -71,7 +68,6 @@ 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; }; struct MessageBadAlloc : std::runtime_error { using std::runtime_error::runtime_error; };
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
#endif /* FAIRMQMESSAGE_H_ */ #endif /* FAIRMQMESSAGE_H_ */

View File

@@ -26,16 +26,13 @@ class FairMQPoller
using FairMQPollerPtr = std::unique_ptr<FairMQPoller>; using FairMQPollerPtr = std::unique_ptr<FairMQPoller>;
namespace fair namespace fair::mq
{
namespace mq
{ {
using Poller = FairMQPoller; using Poller = FairMQPoller;
using PollerPtr = FairMQPollerPtr; 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 fair::mq
} /* namespace fair */
#endif /* FAIRMQPOLLER_H_ */ #endif /* FAIRMQPOLLER_H_ */

View File

@@ -9,14 +9,29 @@
#ifndef FAIRMQSOCKET_H_ #ifndef FAIRMQSOCKET_H_
#define FAIRMQSOCKET_H_ #define FAIRMQSOCKET_H_
#include "FairMQMessage.h"
#include <memory> #include <memory>
#include <ostream>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <vector> #include <vector>
#include "FairMQMessage.h"
class FairMQTransportFactory; class FairMQTransportFactory;
namespace fair::mq
{
enum class TransferCode : int
{
success = 0,
error = -1,
timeout = -2,
interrupted = -3
};
} // namespace fair::mq
class FairMQSocket class FairMQSocket
{ {
public: public:
@@ -28,8 +43,8 @@ class FairMQSocket
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;
virtual int Send(FairMQMessagePtr& msg, int timeout = -1) = 0; virtual int64_t Send(FairMQMessagePtr& msg, int timeout = -1) = 0;
virtual int Receive(FairMQMessagePtr& msg, int timeout = -1) = 0; virtual int64_t Receive(FairMQMessagePtr& msg, int timeout = -1) = 0;
virtual int64_t Send(std::vector<std::unique_ptr<FairMQMessage>>& msgVec, int timeout = -1) = 0; virtual int64_t Send(std::vector<std::unique_ptr<FairMQMessage>>& msgVec, int timeout = -1) = 0;
virtual int64_t Receive(std::vector<std::unique_ptr<FairMQMessage>>& msgVec, int timeout = -1) = 0; virtual int64_t Receive(std::vector<std::unique_ptr<FairMQMessage>>& msgVec, int timeout = -1) = 0;
@@ -69,16 +84,13 @@ class FairMQSocket
using FairMQSocketPtr = std::unique_ptr<FairMQSocket>; using FairMQSocketPtr = std::unique_ptr<FairMQSocket>;
namespace fair namespace fair::mq
{
namespace mq
{ {
using Socket = FairMQSocket; using Socket = FairMQSocket;
using SocketPtr = FairMQSocketPtr; using SocketPtr = FairMQSocketPtr;
struct SocketError : std::runtime_error { using std::runtime_error::runtime_error; }; struct SocketError : std::runtime_error { using std::runtime_error::runtime_error; };
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
#endif /* FAIRMQSOCKET_H_ */ #endif /* FAIRMQSOCKET_H_ */

View File

@@ -13,7 +13,10 @@
#include <fairmq/ofi/TransportFactory.h> #include <fairmq/ofi/TransportFactory.h>
#endif #endif
#include <FairMQLogger.h> #include <FairMQLogger.h>
#include <fairmq/Tools.h> #include <fairmq/tools/Unique.h>
#include <fairmq/tools/Strings.h>
#include <fairlogger/Logger.h>
#include <memory> #include <memory>
#include <string> #include <string>

View File

@@ -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>
@@ -25,7 +24,7 @@
#include <cstddef> // size_t #include <cstddef> // size_t
class FairMQChannel; class FairMQChannel;
namespace fair { namespace mq { class ProgOptions; } } namespace fair::mq { class ProgOptions; }
class FairMQTransportFactory class FairMQTransportFactory
{ {
@@ -172,15 +171,12 @@ class FairMQTransportFactory
} }
}; };
namespace fair namespace fair::mq
{
namespace mq
{ {
using TransportFactory = FairMQTransportFactory; 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 fair::mq
} /* namespace fair */
#endif /* FAIRMQTRANSPORTFACTORY_H_ */ #endif /* FAIRMQTRANSPORTFACTORY_H_ */

View File

@@ -28,21 +28,24 @@ enum class FairMQRegionEvent : int
struct FairMQRegionInfo struct FairMQRegionInfo
{ {
FairMQRegionInfo() FairMQRegionInfo()
: id(0) : managed(true)
, id(0)
, ptr(nullptr) , ptr(nullptr)
, size(0) , size(0)
, flags(0) , flags(0)
, event(FairMQRegionEvent::created) , event(FairMQRegionEvent::created)
{} {}
FairMQRegionInfo(uint64_t _id, void* _ptr, size_t _size, int64_t _flags, FairMQRegionEvent _event) FairMQRegionInfo(bool _managed, uint64_t _id, void* _ptr, size_t _size, int64_t _flags, FairMQRegionEvent _event)
: id(_id) : managed(_managed)
, id(_id)
, ptr(_ptr) , ptr(_ptr)
, size(_size) , size(_size)
, flags(_flags) , flags(_flags)
, event(_event) , event(_event)
{} {}
bool managed; // managed/unmanaged
uint64_t id; // id of the region uint64_t id; // id of the region
void* ptr; // pointer to the start of the region void* ptr; // pointer to the start of the region
size_t size; // region size size_t size; // region size
@@ -72,7 +75,7 @@ class FairMQUnmanagedRegion
virtual void* GetData() const = 0; virtual void* GetData() const = 0;
virtual size_t GetSize() const = 0; virtual size_t GetSize() const = 0;
virtual uint64_t GetId() const = 0; virtual uint16_t GetId() const = 0;
virtual void SetLinger(uint32_t linger) = 0; virtual void SetLinger(uint32_t linger) = 0;
virtual uint32_t GetLinger() const = 0; virtual uint32_t GetLinger() const = 0;
@@ -101,9 +104,7 @@ inline std::ostream& operator<<(std::ostream& os, const FairMQRegionEvent& event
} }
} }
namespace fair namespace fair::mq
{
namespace mq
{ {
using RegionCallback = FairMQRegionCallback; using RegionCallback = FairMQRegionCallback;
@@ -115,7 +116,6 @@ using RegionBlock = FairMQRegionBlock;
using UnmanagedRegion = FairMQUnmanagedRegion; using UnmanagedRegion = FairMQUnmanagedRegion;
using UnmanagedRegionPtr = FairMQUnmanagedRegionPtr; using UnmanagedRegionPtr = FairMQUnmanagedRegionPtr;
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
#endif /* FAIRMQUNMANAGEDREGION_H_ */ #endif /* FAIRMQUNMANAGEDREGION_H_ */

View File

@@ -12,25 +12,25 @@
* 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/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;
using namespace fair::mq::tools; using namespace fair::mq::tools;
using namespace boost::property_tree; using namespace boost::property_tree;
namespace fair namespace fair::mq
{
namespace mq
{ {
fair::mq::Properties PtreeParser(const ptree& pt, const string& id) fair::mq::Properties PtreeParser(const ptree& pt, const string& id)
@@ -183,5 +183,4 @@ void SubChannelParser(const ptree& channelTree, fair::mq::Properties& properties
} }
} // helper namespace } // helper namespace
} // namespace mq } // namespace fair::mq
} // namespace fair

View File

@@ -15,19 +15,13 @@
#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::mq
{
namespace mq
{ {
struct ParserError : std::runtime_error { using std::runtime_error::runtime_error; }; struct ParserError : std::runtime_error { using std::runtime_error::runtime_error; };
@@ -45,7 +39,6 @@ void SubChannelParser(const boost::property_tree::ptree& tree, fair::mq::Propert
} // helper namespace } // helper namespace
} // namespace mq } // namespace fair::mq
} // namespace fair
#endif /* FAIR_MQ_JSONPARSER_H */ #endif /* FAIR_MQ_JSONPARSER_H */

View File

@@ -15,8 +15,8 @@
#include <fairmq/FairMQTransportFactory.h> #include <fairmq/FairMQTransportFactory.h>
#include <fairmq/MemoryResources.h> #include <fairmq/MemoryResources.h>
namespace fair { namespace fair::mq
namespace mq { {
using BytePmrAllocator = pmr::polymorphic_allocator<fair::mq::byte>; using BytePmrAllocator = pmr::polymorphic_allocator<fair::mq::byte>;
@@ -62,5 +62,4 @@ FairMQMessagePtr getMessage(ContainerT &&container_, FairMQMemoryResource *targe
return message; return message;
} }
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */

View File

@@ -18,15 +18,16 @@
#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::mq
namespace mq { {
using byte = unsigned char; using byte = unsigned char;
namespace pmr = boost::container::pmr; namespace pmr = boost::container::pmr;
@@ -106,7 +107,6 @@ class ChannelResource : public FairMQMemoryResource
}; };
}; };
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
#endif /* FAIR_MQ_MEMORY_RESOURCES_H */ #endif /* FAIR_MQ_MEMORY_RESOURCES_H */

View File

@@ -9,7 +9,6 @@
#ifndef FAIR_MQ_PLUGIN_H #ifndef FAIR_MQ_PLUGIN_H
#define FAIR_MQ_PLUGIN_H #define FAIR_MQ_PLUGIN_H
#include <fairmq/tools/CppSTL.h>
#include <fairmq/tools/Version.h> #include <fairmq/tools/Version.h>
#include <fairmq/PluginServices.h> #include <fairmq/PluginServices.h>
@@ -25,9 +24,7 @@
#include <tuple> #include <tuple>
#include <utility> #include <utility>
namespace fair namespace fair::mq
{
namespace mq
{ {
/** /**
@@ -134,13 +131,12 @@ class Plugin
PluginServices* fPluginServices; PluginServices* fPluginServices;
}; /* class Plugin */ }; /* class Plugin */
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
#define REGISTER_FAIRMQ_PLUGIN(KLASS, NAME, VERSION, MAINTAINER, HOMEPAGE, PROGOPTIONS) \ #define REGISTER_FAIRMQ_PLUGIN(KLASS, NAME, VERSION, MAINTAINER, HOMEPAGE, PROGOPTIONS) \
static auto Make_##NAME##_Plugin(fair::mq::PluginServices* pluginServices) -> std::unique_ptr<fair::mq::Plugin> \ static auto Make_##NAME##_Plugin(fair::mq::PluginServices* pluginServices) -> std::unique_ptr<fair::mq::Plugin> \
{ \ { \
return fair::mq::tools::make_unique<KLASS>(std::string{#NAME}, VERSION, std::string{MAINTAINER}, std::string{HOMEPAGE}, pluginServices); \ return std::make_unique<KLASS>(std::string{#NAME}, VERSION, std::string{MAINTAINER}, std::string{HOMEPAGE}, pluginServices); \
} \ } \
BOOST_DLL_ALIAS(Make_##NAME##_Plugin, make_##NAME##_plugin) \ BOOST_DLL_ALIAS(Make_##NAME##_Plugin, make_##NAME##_plugin) \
BOOST_DLL_ALIAS(PROGOPTIONS, get_##NAME##_plugin_progoptions) BOOST_DLL_ALIAS(PROGOPTIONS, get_##NAME##_plugin_progoptions)

View File

@@ -11,7 +11,6 @@
#include <fairmq/Plugin.h> #include <fairmq/Plugin.h>
#include <fairmq/PluginServices.h> #include <fairmq/PluginServices.h>
#include <fairmq/tools/CppSTL.h>
#include <fairmq/tools/Strings.h> #include <fairmq/tools/Strings.h>
#define BOOST_FILESYSTEM_VERSION 3 #define BOOST_FILESYSTEM_VERSION 3
@@ -31,9 +30,7 @@
#include <vector> #include <vector>
#include <utility> // forward #include <utility> // forward
namespace fair namespace fair::mq
{
namespace mq
{ {
/** /**
@@ -80,7 +77,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 = std::make_unique<PluginServices>(std::forward<Args>(args)...); }
auto WaitForPluginsToReleaseDeviceControl() -> void { fPluginServices->WaitForReleaseDeviceControl(); } auto WaitForPluginsToReleaseDeviceControl() -> void { fPluginServices->WaitForReleaseDeviceControl(); }
@@ -126,7 +123,6 @@ class PluginManager
std::map<std::string, boost::program_options::options_description> fPluginProgOptions; std::map<std::string, boost::program_options::options_description> fPluginProgOptions;
}; /* class PluginManager */ }; /* class PluginManager */
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
#endif /* FAIR_MQ_PLUGINMANAGER_H */ #endif /* FAIR_MQ_PLUGINMANAGER_H */

View File

@@ -17,17 +17,16 @@
#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::mq
{
namespace mq
{ {
/** /**
@@ -280,7 +279,6 @@ class PluginServices
std::condition_variable fReleaseDeviceControlCondition; std::condition_variable fReleaseDeviceControlCondition;
}; /* class PluginServices */ }; /* class PluginServices */
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
#endif /* FAIR_MQ_PLUGINSERVICES_H */ #endif /* FAIR_MQ_PLUGINSERVICES_H */

View File

@@ -39,9 +39,7 @@ struct ValInfo
string origin; string origin;
}; };
namespace fair namespace fair::mq
{
namespace mq
{ {
ValInfo ConvertVarValToValInfo(const po::variable_value& v) ValInfo ConvertVarValToValInfo(const po::variable_value& v)
@@ -79,7 +77,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)")
@@ -449,6 +447,4 @@ void ProgOptions::PrintOptionsRaw() const
} }
} }
} // namespace fair::mq
} // namespace mq
} // namespace fair

View File

@@ -26,9 +26,7 @@
#include <vector> #include <vector>
#include <stdexcept> #include <stdexcept>
namespace fair namespace fair::mq
{
namespace mq
{ {
struct PropertyNotFoundError : std::runtime_error { using std::runtime_error::runtime_error; }; struct PropertyNotFoundError : std::runtime_error { using std::runtime_error::runtime_error; };
@@ -270,7 +268,6 @@ class ProgOptions
mutable std::mutex fMtx; mutable std::mutex fMtx;
}; };
} // namespace mq } // namespace fair::mq
} // namespace fair
#endif /* FAIR_MQ_PROGOPTIONS_H */ #endif /* FAIR_MQ_PROGOPTIONS_H */

View File

@@ -9,13 +9,10 @@
#ifndef FAIR_MQ_PROGOPTIONSFWD_H #ifndef FAIR_MQ_PROGOPTIONSFWD_H
#define FAIR_MQ_PROGOPTIONSFWD_H #define FAIR_MQ_PROGOPTIONSFWD_H
namespace fair namespace fair::mq
{
namespace mq
{ {
class ProgOptions; class ProgOptions;
} }
}
using FairMQProgOptions = fair::mq::ProgOptions; using FairMQProgOptions = fair::mq::ProgOptions;

View File

@@ -7,17 +7,13 @@
********************************************************************************/ ********************************************************************************/
#include <fairmq/Properties.h> #include <fairmq/Properties.h>
#include <fairmq/Tools.h>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
using namespace std; using namespace std;
using namespace fair::mq::tools;
using boost::any_cast; using boost::any_cast;
namespace fair namespace fair::mq
{
namespace mq
{ {
template<class T> template<class T>
@@ -76,9 +72,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 +90,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 +110,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 +128,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)); } },
@@ -137,5 +141,4 @@ unordered_map<type_index, void(*)(const EventManager&, const string&, const Prop
{ type_index(typeid(vector<boost::filesystem::path>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<boost::filesystem::path>>(k, any_cast<vector<boost::filesystem::path>>(p)); } }, { type_index(typeid(vector<boost::filesystem::path>)), [](const EventManager& em, const string& k, const Property& p) { em.Emit<PropertyChange, vector<boost::filesystem::path>>(k, any_cast<vector<boost::filesystem::path>>(p)); } },
}; };
} // namespace mq } // namespace fair::mq
} // namespace fair

View File

@@ -16,14 +16,13 @@
#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>
#include <utility> // pair #include <utility> // pair
namespace fair namespace fair::mq
{
namespace mq
{ {
using Property = boost::any; using Property = boost::any;
@@ -71,7 +70,6 @@ class PropertyHelper
static std::unordered_map<std::type_index, std::function<std::pair<std::string, std::string>(const Property&)>> fTypeInfos; static std::unordered_map<std::type_index, std::function<std::pair<std::string, std::string>(const Property&)>> fTypeInfos;
}; };
}
} }
#endif /* FAIR_MQ_PROPERTIES_H */ #endif /* FAIR_MQ_PROPERTIES_H */

View File

@@ -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
@@ -34,9 +35,7 @@ using namespace boost::msm::front;
using namespace boost::msm::back; using namespace boost::msm::back;
namespace bmpl = boost::mpl; namespace bmpl = boost::mpl;
namespace fair namespace fair::mq
{
namespace mq
{ {
namespace fsm namespace fsm
{ {
@@ -238,8 +237,7 @@ struct Machine_ : public state_machine_def<Machine_>
using FairMQFSM = state_machine<Machine_>; using FairMQFSM = state_machine<Machine_>;
} // namespace fsm } // namespace fsm
} // namespace mq } // namespace fair::mq
} // namespace fair
using namespace fair::mq::fsm; using namespace fair::mq::fsm;
using namespace fair::mq; using namespace fair::mq;

View File

@@ -11,16 +11,12 @@
#include <fairmq/States.h> #include <fairmq/States.h>
#include <fairlogger/Logger.h>
#include <string> #include <string>
#include <memory> #include <memory>
#include <functional> #include <functional>
#include <stdexcept> #include <stdexcept>
namespace fair namespace fair::mq
{
namespace mq
{ {
class StateMachine class StateMachine
@@ -58,7 +54,6 @@ class StateMachine
std::shared_ptr<void> fFsm; std::shared_ptr<void> fFsm;
}; };
} // namespace mq } // namespace fair::mq
} // namespace fair
#endif /* FAIRMQSTATEMACHINE_H_ */ #endif /* FAIRMQSTATEMACHINE_H_ */

View File

@@ -17,9 +17,7 @@
#include <utility> // pair #include <utility> // pair
#include <condition_variable> #include <condition_variable>
namespace fair namespace fair::mq
{
namespace mq
{ {
class StateQueue class StateQueue
@@ -88,7 +86,6 @@ class StateQueue
std::condition_variable fCV; std::condition_variable fCV;
}; };
} // namespace mq } // namespace fair::mq
} // namespace fair
#endif /* FAIRMQSTATEQUEUE_H_ */ #endif /* FAIRMQSTATEQUEUE_H_ */

View File

@@ -13,9 +13,7 @@
using namespace std; using namespace std;
namespace fair namespace fair::mq
{
namespace mq
{ {
array<string, 16> stateNames = array<string, 16> stateNames =
@@ -114,5 +112,4 @@ Transition GetTransition(const string& transition)
return transitions.at(transition); return transitions.at(transition);
} }
} // namespace mq } // namespace fair::mq
} // namespace fair

View File

@@ -13,9 +13,7 @@
#include <ostream> #include <ostream>
#include <stdexcept> #include <stdexcept>
namespace fair namespace fair::mq
{
namespace mq
{ {
enum class State : int enum class State : int
@@ -64,7 +62,6 @@ struct DeviceErrorState : std::runtime_error { using std::runtime_error::runtime
inline std::ostream& operator<<(std::ostream& os, const State& state) { return os << GetStateName(state); } inline std::ostream& operator<<(std::ostream& os, const State& state) { return os << GetStateName(state); }
inline std::ostream& operator<<(std::ostream& os, const Transition& transition) { return os << GetTransitionName(transition); } inline std::ostream& operator<<(std::ostream& os, const Transition& transition) { return os << GetTransitionName(transition); }
} // namespace mq } // namespace fair::mq
} // namespace fair
#endif /* FAIRMQSTATES_H_ */ #endif /* FAIRMQSTATES_H_ */

View File

@@ -12,17 +12,18 @@
/// @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;
using namespace std; using namespace std;
namespace fair namespace fair::mq
{
namespace mq
{ {
enum channelOptionKeyIds enum channelOptionKeyIds
@@ -117,4 +118,3 @@ Properties SuboptParser(const vector<string>& channelConfig, const string& devic
} }
} }
}

View File

@@ -14,14 +14,12 @@
#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>
namespace fair namespace fair::mq
{
namespace mq
{ {
/** /**
@@ -43,7 +41,6 @@ namespace mq
Properties SuboptParser(const std::vector<std::string>& channelConfig, const std::string& deviceId); Properties SuboptParser(const std::vector<std::string>& channelConfig, const std::string& deviceId);
}
} }
#endif /* FAIR_MQ_SUBOPTPARSER_H */ #endif /* FAIR_MQ_SUBOPTPARSER_H */

View File

@@ -9,15 +9,14 @@
#ifndef FAIR_MQ_TRANSPORTS_H #ifndef FAIR_MQ_TRANSPORTS_H
#define FAIR_MQ_TRANSPORTS_H #define FAIR_MQ_TRANSPORTS_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>
namespace fair namespace fair::mq
{
namespace mq
{ {
enum class Transport enum class Transport
@@ -28,20 +27,11 @@ enum class Transport
OFI OFI
}; };
} /* namespace mq */ struct TransportError : std::runtime_error { using std::runtime_error::runtime_error; };
} /* namespace fair */
namespace std } // namespace fair::mq
{
template<> namespace fair::mq
struct hash<fair::mq::Transport> : fair::mq::tools::HashEnum<fair::mq::Transport> {};
} /* namespace std */
namespace fair
{
namespace mq
{ {
static std::unordered_map<std::string, Transport> TransportTypes { static std::unordered_map<std::string, Transport> TransportTypes {
@@ -58,7 +48,18 @@ static std::unordered_map<Transport, std::string> TransportNames {
{ Transport::OFI, "ofi" } { Transport::OFI, "ofi" }
}; };
} /* namespace mq */ inline std::string TransportName(Transport transport)
} /* namespace fair */ {
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 fair::mq
#endif /* FAIR_MQ_TRANSPORTS_H */ #endif /* FAIR_MQ_TRANSPORTS_H */

View File

@@ -13,7 +13,6 @@
#include "FairMQDevice.h" #include "FairMQDevice.h"
#include "tools/RateLimit.h" #include "tools/RateLimit.h"
#include <atomic>
#include <chrono> #include <chrono>
#include <cstddef> // size_t #include <cstddef> // size_t
#include <cstdint> // uint64_t #include <cstdint> // uint64_t
@@ -32,6 +31,7 @@ class FairMQBenchmarkSampler : public FairMQDevice
, fMemSet(false) , fMemSet(false)
, fNumParts(1) , fNumParts(1)
, fMsgSize(10000) , fMsgSize(10000)
, fMsgAlignment(0)
, fMsgRate(0) , fMsgRate(0)
, fNumIterations(0) , fNumIterations(0)
, fMaxIterations(0) , fMaxIterations(0)
@@ -44,6 +44,7 @@ class FairMQBenchmarkSampler : public FairMQDevice
fMemSet = fConfig->GetProperty<bool>("memset"); fMemSet = fConfig->GetProperty<bool>("memset");
fNumParts = fConfig->GetProperty<size_t>("num-parts"); fNumParts = fConfig->GetProperty<size_t>("num-parts");
fMsgSize = fConfig->GetProperty<size_t>("msg-size"); fMsgSize = fConfig->GetProperty<size_t>("msg-size");
fMsgAlignment = fConfig->GetProperty<size_t>("msg-alignment");
fMsgRate = fConfig->GetProperty<float>("msg-rate"); fMsgRate = fConfig->GetProperty<float>("msg-rate");
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations"); fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
fOutChannelName = fConfig->GetProperty<std::string>("out-channel"); fOutChannelName = fConfig->GetProperty<std::string>("out-channel");
@@ -64,7 +65,7 @@ class FairMQBenchmarkSampler : public FairMQDevice
FairMQParts parts; FairMQParts parts;
for (size_t i = 0; i < fNumParts; ++i) { for (size_t i = 0; i < fNumParts; ++i) {
parts.AddPart(dataOutChannel.NewMessage(fMsgSize)); parts.AddPart(dataOutChannel.NewMessage(fMsgSize, fair::mq::Alignment{fMsgAlignment}));
if (fMemSet) { if (fMemSet) {
std::memset(parts.At(i)->GetData(), 0, parts.At(i)->GetSize()); std::memset(parts.At(i)->GetData(), 0, parts.At(i)->GetSize());
} }
@@ -79,7 +80,7 @@ class FairMQBenchmarkSampler : public FairMQDevice
++fNumIterations; ++fNumIterations;
} }
} else { } else {
FairMQMessagePtr msg(dataOutChannel.NewMessage(fMsgSize)); FairMQMessagePtr msg(dataOutChannel.NewMessage(fMsgSize, fair::mq::Alignment{fMsgAlignment}));
if (fMemSet) { if (fMemSet) {
std::memset(msg->GetData(), 0, msg->GetSize()); std::memset(msg->GetData(), 0, msg->GetSize());
} }
@@ -104,14 +105,12 @@ class FairMQBenchmarkSampler : public FairMQDevice
LOG(info) << "Done " << fNumIterations << " iterations in " << std::chrono::duration<double, std::milli>(tEnd - tStart).count() << "ms."; LOG(info) << "Done " << fNumIterations << " iterations in " << std::chrono::duration<double, std::milli>(tEnd - tStart).count() << "ms.";
} }
virtual ~FairMQBenchmarkSampler() {}
protected: protected:
bool fMultipart; bool fMultipart;
bool fMemSet; bool fMemSet;
size_t fNumParts; size_t fNumParts;
size_t fMsgSize; size_t fMsgSize;
std::atomic<int> fMsgCounter; size_t fMsgAlignment;
float fMsgRate; float fMsgRate;
uint64_t fNumIterations; uint64_t fNumIterations;
uint64_t fMaxIterations; uint64_t fMaxIterations;

View File

@@ -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;
}
}
}
}
}
}

View File

@@ -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_ */

View File

@@ -1,110 +0,0 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include "FairMQMultiplier.h"
#include "../FairMQLogger.h"
using namespace std;
FairMQMultiplier::FairMQMultiplier()
: fMultipart(true)
, fNumOutputs(0)
, fInChannelName()
, fOutChannelNames()
{
}
FairMQMultiplier::~FairMQMultiplier()
{
}
void FairMQMultiplier::InitTask()
{
fMultipart = fConfig->GetProperty<bool>("multipart");
fInChannelName = fConfig->GetProperty<string>("in-channel");
fOutChannelNames = fConfig->GetProperty<vector<string>>("out-channel");
fNumOutputs = fChannels.at(fOutChannelNames.at(0)).size();
if (fMultipart)
{
OnData(fInChannelName, &FairMQMultiplier::HandleMultipartData);
}
else
{
OnData(fInChannelName, &FairMQMultiplier::HandleSingleData);
}
}
bool FairMQMultiplier::HandleSingleData(std::unique_ptr<FairMQMessage>& payload, int /*index*/)
{
for (unsigned int i = 0; i < fOutChannelNames.size() - 1; ++i) // all except last channel
{
for (unsigned int j = 0; j < fChannels.at(fOutChannelNames.at(i)).size(); ++j) // all subChannels in a channel
{
FairMQMessagePtr msgCopy(fTransportFactory->CreateMessage());
msgCopy->Copy(*payload);
Send(msgCopy, fOutChannelNames.at(i), j);
}
}
unsigned int lastChannelSize = fChannels.at(fOutChannelNames.back()).size();
for (unsigned int i = 0; i < lastChannelSize - 1; ++i) // iterate over all except last subChannels of the last channel
{
FairMQMessagePtr msgCopy(fTransportFactory->CreateMessage());
msgCopy->Copy(*payload);
Send(msgCopy, fOutChannelNames.back(), i);
}
Send(payload, fOutChannelNames.back(), lastChannelSize - 1); // send final message to last subChannel of last channel
return true;
}
bool FairMQMultiplier::HandleMultipartData(FairMQParts& payload, int /*index*/)
{
for (unsigned int i = 0; i < fOutChannelNames.size() - 1; ++i) // all except last channel
{
for (unsigned int j = 0; j < fChannels.at(fOutChannelNames.at(i)).size(); ++j) // all subChannels in a channel
{
FairMQParts parts;
for (int k = 0; k < payload.Size(); ++k)
{
FairMQMessagePtr msgCopy(fTransportFactory->CreateMessage());
msgCopy->Copy(payload.AtRef(k));
parts.AddPart(std::move(msgCopy));
}
Send(parts, fOutChannelNames.at(i), j);
}
}
unsigned int lastChannelSize = fChannels.at(fOutChannelNames.back()).size();
for (unsigned int i = 0; i < lastChannelSize - 1; ++i) // iterate over all except last subChannels of the last channel
{
FairMQParts parts;
for (int k = 0; k < payload.Size(); ++k)
{
FairMQMessagePtr msgCopy(fTransportFactory->CreateMessage());
msgCopy->Copy(payload.AtRef(k));
parts.AddPart(std::move(msgCopy));
}
Send(parts, fOutChannelNames.back(), i);
}
Send(payload, fOutChannelNames.back(), lastChannelSize - 1); // send final message to last subChannel of last channel
return true;
}

View File

@@ -12,12 +12,18 @@
#include "FairMQDevice.h" #include "FairMQDevice.h"
#include <string> #include <string>
#include <vector>
class FairMQMultiplier : public FairMQDevice class FairMQMultiplier : public FairMQDevice
{ {
public: public:
FairMQMultiplier(); FairMQMultiplier()
virtual ~FairMQMultiplier(); : fMultipart(true)
, fNumOutputs(0)
, fInChannelName()
, fOutChannelNames()
{}
~FairMQMultiplier() {}
protected: protected:
bool fMultipart; bool fMultipart;
@@ -25,10 +31,80 @@ class FairMQMultiplier : public FairMQDevice
std::string fInChannelName; std::string fInChannelName;
std::vector<std::string> fOutChannelNames; std::vector<std::string> fOutChannelNames;
virtual void InitTask(); void InitTask() override
{
fMultipart = fConfig->GetProperty<bool>("multipart");
fInChannelName = fConfig->GetProperty<std::string>("in-channel");
fOutChannelNames = fConfig->GetProperty<std::vector<std::string>>("out-channel");
fNumOutputs = fChannels.at(fOutChannelNames.at(0)).size();
bool HandleSingleData(std::unique_ptr<FairMQMessage>&, int); if (fMultipart) {
bool HandleMultipartData(FairMQParts&, int); OnData(fInChannelName, &FairMQMultiplier::HandleMultipartData);
} else {
OnData(fInChannelName, &FairMQMultiplier::HandleSingleData);
}
}
bool HandleSingleData(std::unique_ptr<FairMQMessage>& payload, int)
{
for (unsigned int i = 0; i < fOutChannelNames.size() - 1; ++i) { // all except last channel
for (unsigned int j = 0; j < fChannels.at(fOutChannelNames.at(i)).size(); ++j) { // all subChannels in a channel
FairMQMessagePtr msgCopy(fTransportFactory->CreateMessage());
msgCopy->Copy(*payload);
Send(msgCopy, fOutChannelNames.at(i), j);
}
}
unsigned int lastChannelSize = fChannels.at(fOutChannelNames.back()).size();
for (unsigned int i = 0; i < lastChannelSize - 1; ++i) { // iterate over all except last subChannels of the last channel
FairMQMessagePtr msgCopy(fTransportFactory->CreateMessage());
msgCopy->Copy(*payload);
Send(msgCopy, fOutChannelNames.back(), i);
}
Send(payload, fOutChannelNames.back(), lastChannelSize - 1); // send final message to last subChannel of last channel
return true;
}
bool HandleMultipartData(FairMQParts& payload, int)
{
for (unsigned int i = 0; i < fOutChannelNames.size() - 1; ++i) { // all except last channel
for (unsigned int j = 0; j < fChannels.at(fOutChannelNames.at(i)).size(); ++j) { // all subChannels in a channel
FairMQParts parts;
for (int k = 0; k < payload.Size(); ++k) {
FairMQMessagePtr msgCopy(fTransportFactory->CreateMessage());
msgCopy->Copy(payload.AtRef(k));
parts.AddPart(std::move(msgCopy));
}
Send(parts, fOutChannelNames.at(i), j);
}
}
unsigned int lastChannelSize = fChannels.at(fOutChannelNames.back()).size();
for (unsigned int i = 0; i < lastChannelSize - 1; ++i) { // iterate over all except last subChannels of the last channel
FairMQParts parts;
for (int k = 0; k < payload.Size(); ++k) {
FairMQMessagePtr msgCopy(fTransportFactory->CreateMessage());
msgCopy->Copy(payload.AtRef(k));
parts.AddPart(std::move(msgCopy));
}
Send(parts, fOutChannelNames.back(), i);
}
Send(payload, fOutChannelNames.back(), lastChannelSize - 1); // send final message to last subChannel of last channel
return true;
}
}; };
#endif /* FAIRMQMULTIPLIER_H_ */ #endif /* FAIRMQMULTIPLIER_H_ */

View File

@@ -1,81 +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" *
********************************************************************************/
/**
* FairMQProxy.cxx
*
* @since 2013-10-02
* @author A. Rybalchenko
*/
#include "FairMQProxy.h"
#include "../FairMQLogger.h"
using namespace std;
FairMQProxy::FairMQProxy()
: fMultipart(true)
, fInChannelName()
, fOutChannelName()
{
}
FairMQProxy::~FairMQProxy()
{
}
void FairMQProxy::InitTask()
{
fMultipart = fConfig->GetProperty<bool>("multipart");
fInChannelName = fConfig->GetProperty<string>("in-channel");
fOutChannelName = fConfig->GetProperty<string>("out-channel");
}
void FairMQProxy::Run()
{
if (fMultipart)
{
while (!NewStatePending())
{
FairMQParts payload;
if (Receive(payload, fInChannelName) >= 0)
{
if (Send(payload, fOutChannelName) < 0)
{
LOG(debug) << "Transfer interrupted";
break;
}
}
else
{
LOG(debug) << "Transfer interrupted";
break;
}
}
}
else
{
while (!NewStatePending())
{
unique_ptr<FairMQMessage> payload(fTransportFactory->CreateMessage());
if (Receive(payload, fInChannelName) >= 0)
{
if (Send(payload, fOutChannelName) < 0)
{
LOG(debug) << "Transfer interrupted";
break;
}
}
else
{
LOG(debug) << "Transfer interrupted";
break;
}
}
}
}

View File

@@ -22,16 +22,55 @@
class FairMQProxy : public FairMQDevice class FairMQProxy : public FairMQDevice
{ {
public: public:
FairMQProxy(); FairMQProxy()
virtual ~FairMQProxy(); : fMultipart(true)
, fInChannelName()
, fOutChannelName()
{}
~FairMQProxy() {}
protected: protected:
bool fMultipart; bool fMultipart;
std::string fInChannelName; std::string fInChannelName;
std::string fOutChannelName; std::string fOutChannelName;
virtual void Run(); void InitTask() override
virtual void InitTask(); {
fMultipart = fConfig->GetProperty<bool>("multipart");
fInChannelName = fConfig->GetProperty<std::string>("in-channel");
fOutChannelName = fConfig->GetProperty<std::string>("out-channel");
}
void Run() override
{
if (fMultipart) {
while (!NewStatePending()) {
FairMQParts payload;
if (Receive(payload, fInChannelName) >= 0) {
if (Send(payload, fOutChannelName) < 0) {
LOG(debug) << "Transfer interrupted";
break;
}
} else {
LOG(debug) << "Transfer interrupted";
break;
}
}
} else {
while (!NewStatePending()) {
FairMQMessagePtr payload(fTransportFactory->CreateMessage());
if (Receive(payload, fInChannelName) >= 0) {
if (Send(payload, fOutChannelName) < 0) {
LOG(debug) << "Transfer interrupted";
break;
}
} else {
LOG(debug) << "Transfer interrupted";
break;
}
}
}
}
}; };
#endif /* FAIRMQPROXY_H_ */ #endif /* FAIRMQPROXY_H_ */

View File

@@ -32,7 +32,7 @@ class FairMQSink : public FairMQDevice //, public OutputPolicy
, fInChannelName() , fInChannelName()
{} {}
virtual ~FairMQSink() {} ~FairMQSink() {}
protected: protected:
bool fMultipart; bool fMultipart;
@@ -40,14 +40,14 @@ class FairMQSink : public FairMQDevice //, public OutputPolicy
uint64_t fNumIterations; uint64_t fNumIterations;
std::string fInChannelName; std::string fInChannelName;
virtual void InitTask() void InitTask() override
{ {
fMultipart = fConfig->GetProperty<bool>("multipart"); fMultipart = fConfig->GetProperty<bool>("multipart");
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations"); fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
fInChannelName = fConfig->GetProperty<std::string>("in-channel"); fInChannelName = fConfig->GetProperty<std::string>("in-channel");
} }
virtual void Run() void Run() override
{ {
// store the channel reference to avoid traversing the map on every loop iteration // store the channel reference to avoid traversing the map on every loop iteration
FairMQChannel& dataInChannel = fChannels.at(fInChannelName).at(0); FairMQChannel& dataInChannel = fChannels.at(fInChannelName).at(0);

View File

@@ -1,74 +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" *
********************************************************************************/
/**
* FairMQSplitter.cxx
*
* @since 2012-12-06
* @author D. Klein, A. Rybalchenko
*/
#include "FairMQSplitter.h"
#include "../FairMQLogger.h"
using namespace std;
FairMQSplitter::FairMQSplitter()
: fMultipart(true)
, fNumOutputs(0)
, fDirection(0)
, fInChannelName()
, fOutChannelName()
{
}
FairMQSplitter::~FairMQSplitter()
{
}
void FairMQSplitter::InitTask()
{
fMultipart = fConfig->GetProperty<bool>("multipart");
fInChannelName = fConfig->GetProperty<string>("in-channel");
fOutChannelName = fConfig->GetProperty<string>("out-channel");
fNumOutputs = fChannels.at(fOutChannelName).size();
fDirection = 0;
if (fMultipart)
{
OnData(fInChannelName, &FairMQSplitter::HandleMultipartData);
}
else
{
OnData(fInChannelName, &FairMQSplitter::HandleSingleData);
}
}
bool FairMQSplitter::HandleSingleData(FairMQMessagePtr& payload, int /*index*/)
{
Send(payload, fOutChannelName, fDirection);
if (++fDirection >= fNumOutputs)
{
fDirection = 0;
}
return true;
}
bool FairMQSplitter::HandleMultipartData(FairMQParts& payload, int /*index*/)
{
Send(payload, fOutChannelName, fDirection);
if (++fDirection >= fNumOutputs)
{
fDirection = 0;
}
return true;
}

View File

@@ -22,8 +22,14 @@
class FairMQSplitter : public FairMQDevice class FairMQSplitter : public FairMQDevice
{ {
public: public:
FairMQSplitter(); FairMQSplitter()
virtual ~FairMQSplitter(); : fMultipart(true)
, fNumOutputs(0)
, fDirection(0)
, fInChannelName()
, fOutChannelName()
{}
~FairMQSplitter() {}
protected: protected:
bool fMultipart; bool fMultipart;
@@ -32,10 +38,32 @@ class FairMQSplitter : public FairMQDevice
std::string fInChannelName; std::string fInChannelName;
std::string fOutChannelName; std::string fOutChannelName;
virtual void InitTask(); void InitTask() override
{
fMultipart = fConfig->GetProperty<bool>("multipart");
fInChannelName = fConfig->GetProperty<std::string>("in-channel");
fOutChannelName = fConfig->GetProperty<std::string>("out-channel");
fNumOutputs = fChannels.at(fOutChannelName).size();
fDirection = 0;
bool HandleSingleData(std::unique_ptr<FairMQMessage>&, int); if (fMultipart) {
bool HandleMultipartData(FairMQParts&, int); OnData(fInChannelName, &FairMQSplitter::HandleData<FairMQParts>);
} else {
OnData(fInChannelName, &FairMQSplitter::HandleData<FairMQMessagePtr>);
}
}
template<typename T>
bool HandleData(T& payload, int)
{
Send(payload, fOutChannelName, fDirection);
if (++fDirection >= fNumOutputs) {
fDirection = 0;
}
return true;
}
}; };
#endif /* FAIRMQSPLITTER_H_ */ #endif /* FAIRMQSPLITTER_H_ */

View File

@@ -7,7 +7,7 @@
********************************************************************************/ ********************************************************************************/
#include <fairmq/ofi/Context.h> #include <fairmq/ofi/Context.h>
#include <fairmq/Tools.h> #include <fairmq/tools/Strings.h>
#include <FairMQLogger.h> #include <FairMQLogger.h>
#include <asiofi/version.hpp> #include <asiofi/version.hpp>
@@ -22,11 +22,7 @@
#include <string.h> #include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
namespace fair namespace fair::mq::ofi
{
namespace mq
{
namespace ofi
{ {
using namespace std; using namespace std;
@@ -134,6 +130,4 @@ auto Context::MakeSendMessage(size_t size) -> MessagePtr
return fSendFactory.CreateMessage(size); return fSendFactory.CreateMessage(size);
} }
} /* namespace ofi */ } // namespace fair::mq::ofi
} /* namespace mq */
} /* namespace fair */

View File

@@ -24,11 +24,7 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
namespace fair namespace fair::mq::ofi
{
namespace mq
{
namespace ofi
{ {
enum class ConnectionType : bool { Bind, Connect }; enum class ConnectionType : bool { Bind, Connect };
@@ -88,8 +84,6 @@ class Context
struct ContextError : std::runtime_error { using std::runtime_error::runtime_error; }; struct ContextError : std::runtime_error { using std::runtime_error::runtime_error; };
} /* namespace ofi */ } // namespace fair::mq::ofi
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_OFI_CONTEXT_H */ #endif /* FAIR_MQ_OFI_CONTEXT_H */

View File

@@ -17,8 +17,8 @@
#include <memory> #include <memory>
#include <type_traits> #include <type_traits>
namespace boost { namespace boost::asio
namespace asio { {
template<typename PodType> template<typename PodType>
auto buffer(const PodType& obj) -> boost::asio::const_buffer auto buffer(const PodType& obj) -> boost::asio::const_buffer
@@ -26,12 +26,10 @@ auto buffer(const PodType& obj) -> boost::asio::const_buffer
return boost::asio::const_buffer(static_cast<const void*>(&obj), sizeof(PodType)); return boost::asio::const_buffer(static_cast<const void*>(&obj), sizeof(PodType));
} }
} // namespace asio } // namespace boost::asio
} // namespace boost
namespace fair { namespace fair::mq::ofi
namespace mq { {
namespace ofi {
enum class ControlMessageType enum class ControlMessageType
{ {
@@ -109,8 +107,6 @@ auto MakeControlMessage(Args&&... args) -> ControlMessage
return ctrl; return ctrl;
} }
} // namespace ofi } // namespace fair::mq::ofi
} // namespace mq
} // namespace fair
#endif /* FAIR_MQ_OFI_CONTROLMESSAGES_H */ #endif /* FAIR_MQ_OFI_CONTROLMESSAGES_H */

View File

@@ -7,7 +7,6 @@
********************************************************************************/ ********************************************************************************/
#include <fairmq/ofi/Message.h> #include <fairmq/ofi/Message.h>
#include <fairmq/Tools.h>
#include <FairMQLogger.h> #include <FairMQLogger.h>
#include <asiofi.hpp> #include <asiofi.hpp>
@@ -15,11 +14,7 @@
#include <cstdlib> #include <cstdlib>
#include <zmq.h> #include <zmq.h>
namespace fair namespace fair::mq::ofi
{
namespace mq
{
namespace ofi
{ {
using namespace std; using namespace std;
@@ -110,6 +105,12 @@ auto Message::Rebuild() -> void
fHint = nullptr; fHint = nullptr;
} }
auto Message::Rebuild(Alignment /* alignment */) -> void
{
// TODO: implement alignment
Rebuild();
}
auto Message::Rebuild(const size_t size) -> void auto Message::Rebuild(const size_t size) -> void
{ {
if (fFreeFunction) { if (fFreeFunction) {
@@ -131,6 +132,12 @@ auto Message::Rebuild(const size_t size) -> void
fHint = nullptr; fHint = nullptr;
} }
auto Message::Rebuild(const size_t size, Alignment /* alignment */) -> void
{
// TODO: implement alignment
Rebuild(size);
}
auto Message::Rebuild(void* /*data*/, const size_t size, fairmq_free_fn* ffn, void* hint) -> void auto Message::Rebuild(void* /*data*/, const size_t size, fairmq_free_fn* ffn, void* hint) -> void
{ {
if (fFreeFunction) { if (fFreeFunction) {
@@ -190,6 +197,4 @@ Message::~Message()
} }
} }
} /* namespace ofi */ } // namespace fair::mq::ofi
} /* namespace mq */
} /* namespace fair */

View File

@@ -17,11 +17,7 @@
#include <cstddef> // size_t #include <cstddef> // size_t
#include <zmq.h> #include <zmq.h>
namespace fair namespace fair::mq::ofi
{
namespace mq
{
namespace ofi
{ {
/** /**
@@ -52,7 +48,9 @@ class Message final : public fair::mq::Message
Message operator=(const Message&) = delete; Message operator=(const Message&) = delete;
auto Rebuild() -> void override; auto Rebuild() -> void override;
auto Rebuild(Alignment alignment) -> void override;
auto Rebuild(const size_t size) -> void override; auto Rebuild(const size_t size) -> void override;
auto Rebuild(const size_t size, Alignment alignment) -> void override;
auto Rebuild(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) -> void override; auto Rebuild(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) -> void override;
auto GetData() const -> void* override; auto GetData() const -> void* override;
@@ -75,8 +73,6 @@ class Message final : public fair::mq::Message
boost::container::pmr::memory_resource* fPmr; boost::container::pmr::memory_resource* fPmr;
}; /* class Message */ }; /* class Message */
} /* namespace ofi */ } // namespace fair::mq::ofi
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_OFI_MESSAGE_H */ #endif /* FAIR_MQ_OFI_MESSAGE_H */

View File

@@ -8,16 +8,12 @@
#include <fairmq/ofi/Poller.h> #include <fairmq/ofi/Poller.h>
#include <fairmq/ofi/Socket.h> #include <fairmq/ofi/Socket.h>
#include <fairmq/Tools.h> #include <fairmq/tools/Strings.h>
#include <FairMQLogger.h> #include <FairMQLogger.h>
#include <zmq.h> #include <zmq.h>
namespace fair namespace fair::mq::ofi
{
namespace mq
{
namespace ofi
{ {
using namespace std; using namespace std;
@@ -153,6 +149,4 @@ Poller::~Poller()
delete[] fItems; delete[] fItems;
} }
} /* namespace ofi */ } // namespace fair::mq::ofi
} /* namespace mq */
} /* namespace fair */

View File

@@ -18,11 +18,7 @@
#include <zmq.h> #include <zmq.h>
namespace fair namespace fair::mq::ofi
{
namespace mq
{
namespace ofi
{ {
class TransportFactory; class TransportFactory;
@@ -63,8 +59,6 @@ class Poller final : public FairMQPoller
std::unordered_map<std::string, int> fOffsetMap; std::unordered_map<std::string, int> fOffsetMap;
}; /* class Poller */ }; /* class Poller */
} /* namespace ofi */ } // namespace fair::mq::ofi
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_OFI_POLLER_H */ #endif /* FAIR_MQ_OFI_POLLER_H */

View File

@@ -9,7 +9,7 @@
#include <fairmq/ofi/ControlMessages.h> #include <fairmq/ofi/ControlMessages.h>
#include <fairmq/ofi/Socket.h> #include <fairmq/ofi/Socket.h>
#include <fairmq/ofi/TransportFactory.h> #include <fairmq/ofi/TransportFactory.h>
#include <fairmq/Tools.h> #include <fairmq/tools/Strings.h>
#include <FairMQLogger.h> #include <FairMQLogger.h>
#include <asiofi.hpp> #include <asiofi.hpp>
@@ -25,11 +25,7 @@
#include <mutex> #include <mutex>
#include <queue> #include <queue>
namespace fair namespace fair::mq::ofi
{
namespace mq
{
namespace ofi
{ {
using namespace std; using namespace std;
@@ -74,16 +70,16 @@ auto Socket::InitOfi(Address addr) -> void
hints.set_provider("verbs"); hints.set_provider("verbs");
} }
if (fRemoteAddr == addr) { if (fRemoteAddr == addr) {
fOfiInfo = tools::make_unique<asiofi::info>(addr.Ip.c_str(), std::to_string(addr.Port).c_str(), 0, hints); fOfiInfo = make_unique<asiofi::info>(addr.Ip.c_str(), std::to_string(addr.Port).c_str(), 0, hints);
} else { } else {
fOfiInfo = tools::make_unique<asiofi::info>(addr.Ip.c_str(), std::to_string(addr.Port).c_str(), FI_SOURCE, hints); fOfiInfo = make_unique<asiofi::info>(addr.Ip.c_str(), std::to_string(addr.Port).c_str(), FI_SOURCE, hints);
} }
LOG(debug) << "OFI transport (" << fId << "): " << *fOfiInfo; LOG(debug) << "OFI transport (" << fId << "): " << *fOfiInfo;
fOfiFabric = tools::make_unique<asiofi::fabric>(*fOfiInfo); fOfiFabric = make_unique<asiofi::fabric>(*fOfiInfo);
fOfiDomain = tools::make_unique<asiofi::domain>(*fOfiFabric); fOfiDomain = make_unique<asiofi::domain>(*fOfiFabric);
} }
} }
@@ -96,7 +92,7 @@ try {
InitOfi(fLocalAddr); InitOfi(fLocalAddr);
fPassiveEndpoint = tools::make_unique<asiofi::passive_endpoint>(fContext.GetIoContext(), *fOfiFabric); fPassiveEndpoint = make_unique<asiofi::passive_endpoint>(fContext.GetIoContext(), *fOfiFabric);
//fPassiveEndpoint->set_local_address(Context::ConvertAddress(fLocalAddr)); //fPassiveEndpoint->set_local_address(Context::ConvertAddress(fLocalAddr));
BindControlEndpoint(); BindControlEndpoint();
@@ -128,7 +124,7 @@ auto Socket::BindControlEndpoint() -> void
fPassiveEndpoint->listen([&](asiofi::info&& info) { fPassiveEndpoint->listen([&](asiofi::info&& info) {
LOG(debug) << "OFI transport (" << fId LOG(debug) << "OFI transport (" << fId
<< "): control band connection request received. Accepting ..."; << "): control band connection request received. Accepting ...";
fControlEndpoint = tools::make_unique<asiofi::connected_endpoint>( fControlEndpoint = make_unique<asiofi::connected_endpoint>(
fContext.GetIoContext(), *fOfiDomain, info); fContext.GetIoContext(), *fOfiDomain, info);
fControlEndpoint->enable(); fControlEndpoint->enable();
fControlEndpoint->accept([&]() { fControlEndpoint->accept([&]() {
@@ -148,7 +144,7 @@ auto Socket::BindDataEndpoint() -> void
fPassiveEndpoint->listen([&](asiofi::info&& info) { fPassiveEndpoint->listen([&](asiofi::info&& info) {
LOG(debug) << "OFI transport (" << fId LOG(debug) << "OFI transport (" << fId
<< "): data band connection request received. Accepting ..."; << "): data band connection request received. Accepting ...";
fDataEndpoint = tools::make_unique<asiofi::connected_endpoint>( fDataEndpoint = make_unique<asiofi::connected_endpoint>(
fContext.GetIoContext(), *fOfiDomain, info); fContext.GetIoContext(), *fOfiDomain, info);
fDataEndpoint->enable(); fDataEndpoint->enable();
fDataEndpoint->accept([&]() { fDataEndpoint->accept([&]() {
@@ -215,7 +211,7 @@ auto Socket::ConnectEndpoint(std::unique_ptr<asiofi::connected_endpoint>& endpoi
std::string band(type == Band::Control ? "control" : "data"); std::string band(type == Band::Control ? "control" : "data");
endpoint = tools::make_unique<asiofi::connected_endpoint>(fContext.GetIoContext(), *fOfiDomain); endpoint = make_unique<asiofi::connected_endpoint>(fContext.GetIoContext(), *fOfiDomain);
endpoint->enable(); endpoint->enable();
LOG(debug) << "OFI transport (" << fId << "): Sending " << band << " band connection request to " << fRemoteAddr; LOG(debug) << "OFI transport (" << fId << "): Sending " << band << " band connection request to " << fRemoteAddr;
@@ -254,7 +250,7 @@ auto Socket::ConnectEndpoint(std::unique_ptr<asiofi::connected_endpoint>& endpoi
} }
} }
auto Socket::Send(MessagePtr& msg, const int /*timeout*/) -> int auto Socket::Send(MessagePtr& msg, const int /*timeout*/) -> int64_t
{ {
// timeout argument not yet implemented // timeout argument not yet implemented
@@ -284,7 +280,7 @@ try {
return size; return size;
} catch (const std::exception& e) { } catch (const std::exception& e) {
LOG(error) << e.what(); LOG(error) << e.what();
return -1; return static_cast<int64_t>(TransferCode::error);
} }
auto Socket::SendQueueReader() -> void auto Socket::SendQueueReader() -> void
@@ -412,7 +408,7 @@ auto Socket::SendQueueReaderStatic() -> void
}); });
} }
auto Socket::Receive(MessagePtr& msg, const int /*timeout*/) -> int auto Socket::Receive(MessagePtr& msg, const int /*timeout*/) -> int64_t
try { try {
// timeout argument not yet implemented // timeout argument not yet implemented
@@ -431,7 +427,7 @@ try {
return size; return size;
} catch (const std::exception& e) { } catch (const std::exception& e) {
LOG(error) << e.what(); LOG(error) << e.what();
return -1; return static_cast<int>(TransferCode::error);
} }
auto Socket::Receive(std::vector<MessagePtr>& msgVec, const int /*timeout*/) -> int64_t auto Socket::Receive(std::vector<MessagePtr>& msgVec, const int /*timeout*/) -> int64_t
@@ -456,7 +452,7 @@ try {
return size; return size;
} catch (const std::exception& e) { } catch (const std::exception& e) {
LOG(error) << e.what(); LOG(error) << e.what();
return -1; return static_cast<int64_t>(TransferCode::error);
} }
auto Socket::RecvControlQueueReader() -> void auto Socket::RecvControlQueueReader() -> void
@@ -683,6 +679,4 @@ Socket::~Socket()
} }
} }
} /* namespace ofi */ } // namespace fair::mq::ofi
} /* namespace mq */
} /* namespace fair */

View File

@@ -23,11 +23,7 @@
#include <mutex> #include <mutex>
namespace fair namespace fair::mq::ofi
{
namespace mq
{
namespace ofi
{ {
/** /**
@@ -49,8 +45,8 @@ class Socket final : public fair::mq::Socket
auto Bind(const std::string& address) -> bool override; auto Bind(const std::string& address) -> bool override;
auto Connect(const std::string& address) -> bool override; auto Connect(const std::string& address) -> bool override;
auto Send(MessagePtr& msg, int timeout = 0) -> int override; auto Send(MessagePtr& msg, int timeout = 0) -> int64_t override;
auto Receive(MessagePtr& msg, int timeout = 0) -> int override; auto Receive(MessagePtr& msg, int timeout = 0) -> int64_t override;
auto Send(std::vector<MessagePtr>& msgVec, int timeout = 0) -> int64_t override; auto Send(std::vector<MessagePtr>& msgVec, int timeout = 0) -> int64_t override;
auto Receive(std::vector<MessagePtr>& msgVec, int timeout = 0) -> int64_t override; auto Receive(std::vector<MessagePtr>& msgVec, int timeout = 0) -> int64_t override;
@@ -120,8 +116,6 @@ class Socket final : public fair::mq::Socket
struct SilentSocketError : SocketError { using SocketError::SocketError; }; struct SilentSocketError : SocketError { using SocketError::SocketError; };
} /* namespace ofi */ } // namespace fair::mq::ofi
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_OFI_SOCKET_H */ #endif /* FAIR_MQ_OFI_SOCKET_H */

View File

@@ -10,15 +10,10 @@
#include <fairmq/ofi/Poller.h> #include <fairmq/ofi/Poller.h>
#include <fairmq/ofi/Socket.h> #include <fairmq/ofi/Socket.h>
#include <fairmq/ofi/TransportFactory.h> #include <fairmq/ofi/TransportFactory.h>
#include <fairmq/Tools.h>
#include <stdexcept> #include <stdexcept>
namespace fair namespace fair::mq::ofi
{
namespace mq
{
namespace ofi
{ {
using namespace std; using namespace std;
@@ -122,6 +117,4 @@ auto TransportFactory::GetType() const -> Transport
return Transport::OFI; return Transport::OFI;
} }
} /* namespace ofi */ } // namespace fair::mq::ofi
} /* namespace mq */
} /* namespace fair */

View File

@@ -15,11 +15,7 @@
#include <asiofi.hpp> #include <asiofi.hpp>
namespace fair namespace fair::mq::ofi
{
namespace mq
{
namespace ofi
{ {
/** /**
@@ -69,8 +65,6 @@ class TransportFactory final : public FairMQTransportFactory
asiofi::allocated_pool_resource fMemoryResource; asiofi::allocated_pool_resource fMemoryResource;
}; /* class TransportFactory */ }; /* class TransportFactory */
} /* namespace ofi */ } // namespace fair::mq::ofi
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_OFI_TRANSPORTFACTORY_H */ #endif /* FAIR_MQ_OFI_TRANSPORTFACTORY_H */

View File

@@ -8,14 +8,16 @@
#include "Control.h" #include "Control.h"
#include <termios.h> // for the interactive mode #include <atomic>
#include <poll.h> // for the interactive mode #include <chrono>
#include <csignal> // catching system signals #include <csignal> // catching system signals
#include <cstdlib> #include <cstdlib>
#include <functional> #include <functional>
#include <atomic> #include <iostream>
#include <thread> #include <thread>
#include <chrono>
#include <poll.h> // for the interactive mode
#include <termios.h> // for the interactive mode
using namespace std; using namespace std;
@@ -41,11 +43,7 @@ namespace
} }
} }
namespace fair namespace fair::mq::plugins
{
namespace mq
{
namespace plugins
{ {
Control::Control(const string& name, const Plugin::Version version, const string& maintainer, const string& homepage, PluginServices* pluginServices) Control::Control(const string& name, const Plugin::Version version, const string& maintainer, const string& homepage, PluginServices* pluginServices)
@@ -473,6 +471,4 @@ Control::~Control()
UnsubscribeFromDeviceStateChange(); UnsubscribeFromDeviceStateChange();
} }
} /* namespace plugins */ } // namespace fair::mq::plugins
} /* namespace mq */
} /* namespace fair */

View File

@@ -21,11 +21,7 @@
#include <atomic> #include <atomic>
#include <stdexcept> #include <stdexcept>
namespace fair namespace fair::mq::plugins
{
namespace mq
{
namespace plugins
{ {
class Control : public Plugin class Control : public Plugin
@@ -68,8 +64,6 @@ REGISTER_FAIRMQ_PLUGIN(
// boost::optional<boost::program_options::options_description> // boost::optional<boost::program_options::options_description>
) )
} /* namespace plugins */ } // namespace fair::mq::plugins
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_PLUGINS_CONTROL */ #endif /* FAIR_MQ_PLUGINS_CONTROL */

View File

@@ -17,13 +17,7 @@ set_target_properties(${plugin} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/fairmq LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/fairmq
) )
set(exe fairmq-dds-command-ui) install(TARGETS ${plugin}
add_executable(${exe} ${CMAKE_CURRENT_SOURCE_DIR}/runDDSCommandUI.cxx)
target_link_libraries(${exe} FairMQ Commands SDK StateMachine)
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
install(TARGETS ${plugin} ${exe}
EXPORT ${PROJECT_EXPORT_SET} EXPORT ${PROJECT_EXPORT_SET}
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
) )

View File

@@ -22,11 +22,7 @@
using namespace std; using namespace std;
using fair::mq::tools::ToString; using fair::mq::tools::ToString;
namespace fair namespace fair::mq::plugins
{
namespace mq
{
namespace plugins
{ {
DDS::DDS(const string& name, DDS::DDS(const string& name,
@@ -344,10 +340,10 @@ auto DDS::HandleCmd(const string& id, sdk::cmd::Cmd& cmd, const string& cond, ui
case Type::change_state: { case Type::change_state: {
Transition transition = static_cast<ChangeState&>(cmd).GetTransition(); Transition transition = static_cast<ChangeState&>(cmd).GetTransition();
if (ChangeDeviceState(transition)) { if (ChangeDeviceState(transition)) {
Cmds outCmds(make<TransitionStatus>(id, fDDSTaskId, Result::Ok, transition)); Cmds outCmds(make<TransitionStatus>(id, fDDSTaskId, Result::Ok, transition, GetCurrentDeviceState()));
fDDS.Send(outCmds.Serialize(), to_string(senderId)); fDDS.Send(outCmds.Serialize(), to_string(senderId));
} else { } else {
Cmds outCmds(make<TransitionStatus>(id, fDDSTaskId, Result::Failure, transition)); Cmds outCmds(make<TransitionStatus>(id, fDDSTaskId, Result::Failure, transition, GetCurrentDeviceState()));
fDDS.Send(outCmds.Serialize(), to_string(senderId)); fDDS.Send(outCmds.Serialize(), to_string(senderId));
} }
{ {
@@ -357,7 +353,7 @@ auto DDS::HandleCmd(const string& id, sdk::cmd::Cmd& cmd, const string& cond, ui
} break; } break;
case Type::dump_config: { case Type::dump_config: {
stringstream ss; stringstream ss;
for (const auto pKey : GetPropertyKeys()) { for (const auto& pKey : GetPropertyKeys()) {
ss << id << ": " << pKey << " -> " << GetPropertyAsString(pKey) << "\n"; ss << id << ": " << pKey << " -> " << GetPropertyAsString(pKey) << "\n";
} }
Cmds outCmds(make<Config>(id, ss.str())); Cmds outCmds(make<Config>(id, ss.str()));
@@ -458,6 +454,4 @@ DDS::~DDS()
} }
} }
} /* namespace plugins */ } // namespace fair::mq::plugins
} /* namespace mq */
} /* namespace fair */

View File

@@ -32,11 +32,7 @@
#include <utility> // pair #include <utility> // pair
#include <vector> #include <vector>
namespace fair namespace fair::mq::plugins
{
namespace mq
{
namespace plugins
{ {
struct DDSConfig struct DDSConfig
@@ -196,8 +192,6 @@ REGISTER_FAIRMQ_PLUGIN(
DDSProgramOptions // custom program options for the plugin DDSProgramOptions // custom program options for the plugin
) )
} /* namespace plugins */ } // namespace fair::mq::plugins
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_PLUGINS_DDS */ #endif /* FAIR_MQ_PLUGINS_DDS */

View File

@@ -13,7 +13,7 @@
#include <FairMQLogger.h> #include <FairMQLogger.h>
#include <fairmq/tools/Semaphore.h> #include <fairmq/tools/Semaphore.h>
#include <fairmq/tools/CppSTL.h> #include <memory> // make_unique
#include <string> #include <string>
namespace pmix namespace pmix
@@ -156,7 +156,7 @@ class Commands
void Send(const std::string& msg, const std::vector<proc>& destination) void Send(const std::string& msg, const std::vector<proc>& destination)
{ {
std::unique_ptr<Holder> holder = fair::mq::tools::make_unique<Holder>(); std::unique_ptr<Holder> holder = std::make_unique<Holder>();
PMIX_DATA_ARRAY_CREATE(holder->fData, destination.size(), PMIX_PROC); PMIX_DATA_ARRAY_CREATE(holder->fData, destination.size(), PMIX_PROC);
memcpy(holder->fData->array, destination.data(), destination.size() * sizeof(pmix_proc_t)); memcpy(holder->fData->array, destination.data(), destination.size() * sizeof(pmix_proc_t));

View File

@@ -9,7 +9,7 @@
#include "PMIxPlugin.h" #include "PMIxPlugin.h"
#include <fairmq/sdk/commands/Commands.h> #include <fairmq/sdk/commands/Commands.h>
#include <fairmq/Tools.h> #include <fairmq/tools/Strings.h>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
@@ -18,11 +18,7 @@
using namespace std; using namespace std;
using namespace fair::mq::sdk::cmd; using namespace fair::mq::sdk::cmd;
namespace fair namespace fair::mq::plugins
{
namespace mq
{
namespace plugins
{ {
PMIxPlugin::PMIxPlugin(const string& name, PMIxPlugin::PMIxPlugin(const string& name,
@@ -148,12 +144,12 @@ auto PMIxPlugin::SubscribeForCommands() -> void
Transition transition = static_cast<ChangeState&>(*cmd).GetTransition(); Transition transition = static_cast<ChangeState&>(*cmd).GetTransition();
if (ChangeDeviceState(transition)) { if (ChangeDeviceState(transition)) {
fCommands.Send( fCommands.Send(
Cmds(make<TransitionStatus>(fDeviceId, 0, Result::Ok, transition)) Cmds(make<TransitionStatus>(fDeviceId, 0, Result::Ok, transition, GetCurrentDeviceState()))
.Serialize(Format::JSON), .Serialize(Format::JSON),
{sender}); {sender});
} else { } else {
fCommands.Send( fCommands.Send(
Cmds(make<TransitionStatus>(fDeviceId, 0, Result::Failure, transition)) Cmds(make<TransitionStatus>(fDeviceId, 0, Result::Failure, transition, GetCurrentDeviceState()))
.Serialize(Format::JSON), .Serialize(Format::JSON),
{sender}); {sender});
} }
@@ -304,6 +300,4 @@ auto PMIxPlugin::WaitForExitingAck() -> void
}); });
} }
} /* namespace plugins */ } // namespace fair::mq::plugins
} /* namespace mq */
} /* namespace fair */

View File

@@ -24,11 +24,7 @@
#include <unistd.h> #include <unistd.h>
#include <vector> #include <vector>
namespace fair namespace fair::mq::plugins
{
namespace mq
{
namespace plugins
{ {
class PMIxPlugin : public Plugin class PMIxPlugin : public Plugin
@@ -88,8 +84,6 @@ REGISTER_FAIRMQ_PLUGIN(
PMIxProgramOptions // custom program options for the plugin PMIxProgramOptions // custom program options for the plugin
) )
} /* namespace plugins */ } // namespace fair::mq::plugins
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_PLUGINS_PMIX */ #endif /* FAIR_MQ_PLUGINS_PMIX */

View File

@@ -15,11 +15,7 @@
using namespace std; using namespace std;
namespace fair namespace fair::mq::plugins
{
namespace mq
{
namespace plugins
{ {
Config::Config(const string& name, const Plugin::Version version, const string& maintainer, const string& homepage, PluginServices* pluginServices) Config::Config(const string& name, const Plugin::Version version, const string& maintainer, const string& homepage, PluginServices* pluginServices)
@@ -69,6 +65,8 @@ Plugin::ProgOptions ConfigPluginProgramOptions()
("max-run-time", po::value<uint64_t >()->default_value(0), "Maximum runtime for the Running state handler, after which state will change to Ready (in seconds, 0 for no limit).") ("max-run-time", po::value<uint64_t >()->default_value(0), "Maximum runtime for the Running state handler, after which state will change to Ready (in seconds, 0 for no limit).")
("print-channels", po::value<bool >()->implicit_value(true), "Print registered channel endpoints in a machine-readable format (<channel name>:<min num subchannels>:<max num subchannels>)") ("print-channels", po::value<bool >()->implicit_value(true), "Print registered channel endpoints in a machine-readable format (<channel name>:<min num subchannels>:<max num subchannels>)")
("shm-segment-size", po::value<size_t >()->default_value(2ULL << 30), "Shared memory: size of the shared memory segment (in bytes).") ("shm-segment-size", po::value<size_t >()->default_value(2ULL << 30), "Shared memory: size of the shared memory segment (in bytes).")
("shm-allocation", po::value<string >()->default_value("rbtree_best_fit"), "Shared memory allocation algorithm: rbtree_best_fit/simple_seq_fit.")
("shm-segment-id", po::value<uint16_t >()->default_value(0), "EXPERIMENTAL: Shared memory segment id for message creation.")
("shm-mlock-segment", po::value<bool >()->default_value(false), "Shared memory: mlock the shared memory segment after initialization.") ("shm-mlock-segment", po::value<bool >()->default_value(false), "Shared memory: mlock the shared memory segment after initialization.")
("shm-zero-segment", po::value<bool >()->default_value(false), "Shared memory: zero the shared memory segment memory after initialization.") ("shm-zero-segment", po::value<bool >()->default_value(false), "Shared memory: zero the shared memory segment memory after initialization.")
("shm-throw-bad-alloc", po::value<bool >()->default_value(true), "Throw a fair::mq::MessageBadAlloc if cannot allocate a message (retry if false).") ("shm-throw-bad-alloc", po::value<bool >()->default_value(true), "Throw a fair::mq::MessageBadAlloc if cannot allocate a message (retry if false).")
@@ -87,6 +85,4 @@ Config::~Config()
UnsubscribeFromDeviceStateChange(); UnsubscribeFromDeviceStateChange();
} }
} /* namespace plugins */ } // namespace fair::mq::plugins
} /* namespace mq */
} /* namespace fair */

View File

@@ -14,11 +14,7 @@
#include <string> #include <string>
namespace fair namespace fair::mq::plugins
{
namespace mq
{
namespace plugins
{ {
class Config : public Plugin class Config : public Plugin
@@ -40,8 +36,6 @@ REGISTER_FAIRMQ_PLUGIN(
ConfigPluginProgramOptions ConfigPluginProgramOptions
) )
} /* namespace plugins */ } // namespace fair::mq::plugins
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_PLUGINS_CONFIG */ #endif /* FAIR_MQ_PLUGINS_CONFIG */

View File

@@ -19,6 +19,7 @@ void addCustomOptions(bpo::options_description& options)
("memset", bpo::value<bool>()->default_value(false), "Memset allocated buffers to 0") ("memset", bpo::value<bool>()->default_value(false), "Memset allocated buffers to 0")
("num-parts", bpo::value<size_t>()->default_value(1), "Number of parts to send. 1 will send single messages, not parts") ("num-parts", bpo::value<size_t>()->default_value(1), "Number of parts to send. 1 will send single messages, not parts")
("msg-size", bpo::value<size_t>()->default_value(1000000), "Message size in bytes") ("msg-size", bpo::value<size_t>()->default_value(1000000), "Message size in bytes")
("msg-alignment", bpo::value<size_t>()->default_value(0), "Message alignment")
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Number of run iterations (0 - infinite)") ("max-iterations", bpo::value<uint64_t>()->default_value(0), "Number of run iterations (0 - infinite)")
("msg-rate", bpo::value<float>()->default_value(0), "Msg rate limit in maximum number of messages per second"); ("msg-rate", bpo::value<float>()->default_value(0), "Msg rate limit in maximum number of messages per second");
} }

View File

@@ -5,7 +5,7 @@
* 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" *
********************************************************************************/ ********************************************************************************/
#include <fairmq/Tools.h> #include <fairmq/tools/Unique.h>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>

View File

@@ -12,6 +12,7 @@
#include <asio/associated_allocator.hpp> #include <asio/associated_allocator.hpp>
#include <asio/associated_executor.hpp> #include <asio/associated_executor.hpp>
#include <asio/executor_work_guard.hpp> #include <asio/executor_work_guard.hpp>
#include <asio/dispatch.hpp>
#include <asio/system_executor.hpp> #include <asio/system_executor.hpp>
#include <chrono> #include <chrono>
#include <exception> #include <exception>
@@ -28,9 +29,8 @@
#define FAIR_LOG LOG #define FAIR_LOG LOG
#endif /* ifndef FAIR_LOG */ #endif /* ifndef FAIR_LOG */
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
template<typename... SignatureArgTypes> template<typename... SignatureArgTypes>
struct AsioAsyncOpImplBase struct AsioAsyncOpImplBase
@@ -69,7 +69,7 @@ struct AsioAsyncOpImpl : AsioAsyncOpImplBase<SignatureArgTypes...>
throw RuntimeError("Async operation already completed"); throw RuntimeError("Async operation already completed");
} }
GetEx2().dispatch( asio::dispatch(GetEx2(),
[=, handler = std::move(fHandler)]() mutable { [=, handler = std::move(fHandler)]() mutable {
try { try {
handler(ec, args...); handler(ec, args...);
@@ -78,8 +78,7 @@ struct AsioAsyncOpImpl : AsioAsyncOpImplBase<SignatureArgTypes...>
} catch (...) { } catch (...) {
FAIR_LOG(error) << "Unknown uncaught exception in AsioAsyncOp completion handler."; FAIR_LOG(error) << "Unknown uncaught exception in AsioAsyncOp completion handler.";
} }
}, });
GetAlloc2());
fWork1.reset(); fWork1.reset();
fWork2.reset(); fWork2.reset();
@@ -219,9 +218,6 @@ struct AsioAsyncOp<Executor,
} }
}; };
} /* namespace sdk */ } // namespace fair::mq::sdk
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_SDK_ASIOASYNCOP_H */ #endif /* FAIR_MQ_SDK_ASIOASYNCOP_H */

View File

@@ -9,16 +9,15 @@
#ifndef FAIR_MQ_SDK_ASIOBASE_H #ifndef FAIR_MQ_SDK_ASIOBASE_H
#define FAIR_MQ_SDK_ASIOBASE_H #define FAIR_MQ_SDK_ASIOBASE_H
#include <asio/executor.hpp> #include <asio/any_io_executor.hpp>
#include <fairmq/sdk/Traits.h> #include <fairmq/sdk/Traits.h>
#include <memory> #include <memory>
#include <utility> #include <utility>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
using DefaultExecutor = asio::executor; using DefaultExecutor = asio::any_io_executor;
using DefaultAllocator = std::allocator<int>; using DefaultAllocator = std::allocator<int>;
/** /**
@@ -69,8 +68,6 @@ class AsioBase
AllocatorType fAllocator; AllocatorType fAllocator;
}; };
} /* namespace sdk */ } // namespace fair::mq::sdk
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_SDK_ASIOBASE_H */ #endif /* FAIR_MQ_SDK_ASIOBASE_H */

View File

@@ -84,10 +84,19 @@ target_link_libraries(fairmq
Boost::program_options Boost::program_options
) )
add_executable(fairmq-dds-command-ui ${CMAKE_CURRENT_SOURCE_DIR}/runDDSCommandUI.cxx)
target_link_libraries(fairmq-dds-command-ui
FairMQ
Commands
SDK
StateMachine
)
install( install(
TARGETS TARGETS
SDK SDK
fairmq fairmq
fairmq-dds-command-ui
EXPORT ${PROJECT_EXPORT_SET} EXPORT ${PROJECT_EXPORT_SET}
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}

View File

@@ -16,9 +16,8 @@
#include <chrono> #include <chrono>
#include <cstdint> #include <cstdint>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
/** /**
* @class DDSAgent <fairmq/sdk/DDSAgent.h> * @class DDSAgent <fairmq/sdk/DDSAgent.h>
@@ -74,8 +73,6 @@ class DDSAgent
std::string fUsername; std::string fUsername;
}; };
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair
#endif /* FAIR_MQ_SDK_DDSSAGENT_H */ #endif /* FAIR_MQ_SDK_DDSSAGENT_H */

View File

@@ -14,9 +14,8 @@
#include <ostream> #include <ostream>
#include <cstdint> #include <cstdint>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
/** /**
* @class DDSCollection <fairmq/sdk/DDSCollection.h> * @class DDSCollection <fairmq/sdk/DDSCollection.h>
@@ -42,8 +41,6 @@ class DDSCollection
Id fId; Id fId;
}; };
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair
#endif /* FAIR_MQ_SDK_DDSCOLLECTION_H */ #endif /* FAIR_MQ_SDK_DDSCOLLECTION_H */

View File

@@ -11,14 +11,13 @@
#include <cstdlib> #include <cstdlib>
#include <dds/dds.h> #include <dds/dds.h>
#include <fairlogger/Logger.h> #include <fairlogger/Logger.h>
#include <fairmq/Tools.h> #include <fairmq/tools/InstanceLimit.h>
#include <fairmq/sdk/DDSInfo.h> #include <fairmq/sdk/DDSInfo.h>
#include <sstream> #include <sstream>
#include <utility> #include <utility>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
struct DDSEnvironment::Impl struct DDSEnvironment::Impl
{ {
@@ -133,6 +132,4 @@ auto operator<<(std::ostream& os, DDSEnvironment env) -> std::ostream&
<< "$DDS_CONFIG_HOME: " << env.GetConfigHome() / DDSEnvironment::Path(".DDS"); << "$DDS_CONFIG_HOME: " << env.GetConfigHome() / DDSEnvironment::Path(".DDS");
} }
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair

View File

@@ -13,9 +13,8 @@
#include <memory> #include <memory>
#include <ostream> #include <ostream>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
/** /**
* @class DDSEnvironment DDSSession.h <fairmq/sdk/DDSSession.h> * @class DDSEnvironment DDSSession.h <fairmq/sdk/DDSSession.h>
@@ -40,8 +39,6 @@ class DDSEnvironment
using DDSEnv = DDSEnvironment; using DDSEnv = DDSEnvironment;
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair
#endif /* FAIR_MQ_SDK_DDSENVIRONMENT_H */ #endif /* FAIR_MQ_SDK_DDSENVIRONMENT_H */

View File

@@ -11,23 +11,11 @@
#include <string> #include <string>
namespace dds { namespace dds::tools_api { class CSession; }
namespace tools_api { namespace dds::topology_api { class CTopology; }
class CSession; namespace fair::mq::sdk
{
} // namespace tools_api
namespace topology_api {
class CTopology;
} // namespace topology_api
} // namespace dds
namespace fair {
namespace mq {
namespace sdk {
const std::string DDSVersion("@DDS_VERSION@"); const std::string DDSVersion("@DDS_VERSION@");
const std::string DDSInstallPrefix("@DDS_INSTALL_PREFIX@"); const std::string DDSInstallPrefix("@DDS_INSTALL_PREFIX@");
@@ -36,8 +24,6 @@ const std::string DDSIncludeDir("@DDS_INCDIR@");
const std::string DDSLibraryDir("@DDS_LIBDIR@"); const std::string DDSLibraryDir("@DDS_LIBDIR@");
const std::string DDSPluginDir("@DDS_PLUGINDIR@"); const std::string DDSPluginDir("@DDS_PLUGINDIR@");
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair
#endif /* FAIR_MQ_SDK_DDSINFO_H */ #endif /* FAIR_MQ_SDK_DDSINFO_H */

View File

@@ -14,7 +14,8 @@
#include <cstdlib> #include <cstdlib>
#include <dds/dds.h> #include <dds/dds.h>
#include <fairlogger/Logger.h> #include <fairlogger/Logger.h>
#include <fairmq/Tools.h> #include <fairmq/tools/Strings.h>
#include <fairmq/tools/Semaphore.h>
#include <fairmq/sdk/DDSAgent.h> #include <fairmq/sdk/DDSAgent.h>
#include <fairmq/sdk/DDSEnvironment.h> #include <fairmq/sdk/DDSEnvironment.h>
#include <fairmq/sdk/DDSTopology.h> #include <fairmq/sdk/DDSTopology.h>
@@ -24,9 +25,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
auto operator<<(std::ostream& os, DDSRMSPlugin plugin) -> std::ostream& auto operator<<(std::ostream& os, DDSRMSPlugin plugin) -> std::ostream&
{ {
@@ -65,8 +65,6 @@ struct DDSSession::Impl
, fId(to_string(fSession->create())) , fId(to_string(fSession->create()))
, fStopOnDestruction(false) , fStopOnDestruction(false)
{ {
setenv("DDS_SESSION_ID", fId.c_str(), 1);
fDDSService.subscribeOnError([](const dds::intercom_api::EErrorCode errorCode, const std::string& msg) { fDDSService.subscribeOnError([](const dds::intercom_api::EErrorCode errorCode, const std::string& msg) {
std::cerr << "DDS error, error code: " << errorCode << ", error message: " << msg << std::endl; std::cerr << "DDS error, error code: " << errorCode << ", error message: " << msg << std::endl;
}); });
@@ -81,10 +79,6 @@ struct DDSSession::Impl
, fStopOnDestruction(false) , fStopOnDestruction(false)
{ {
fSession->attach(fId); fSession->attach(fId);
auto envId(std::getenv("DDS_SESSION_ID"));
if (envId != nullptr && std::string(envId) != fId) {
setenv("DDS_SESSION_ID", fId.c_str(), 1);
}
fDDSService.subscribeOnError([](const dds::intercom_api::EErrorCode errorCode, const std::string& msg) { fDDSService.subscribeOnError([](const dds::intercom_api::EErrorCode errorCode, const std::string& msg) {
std::cerr << "DDS error, error code: " << errorCode << ", error message: " << msg << std::endl; std::cerr << "DDS error, error code: " << errorCode << ", error message: " << msg << std::endl;
@@ -99,11 +93,6 @@ struct DDSSession::Impl
, fId(to_string(fSession->getSessionID())) , fId(to_string(fSession->getSessionID()))
, fStopOnDestruction(false) , fStopOnDestruction(false)
{ {
auto envId(std::getenv("DDS_SESSION_ID"));
if (envId != nullptr && std::string(envId) != fId) {
setenv("DDS_SESSION_ID", fId.c_str(), 1);
}
// Sanity check // Sanity check
if (!fSession->IsRunning()) { if (!fSession->IsRunning()) {
throw std::runtime_error("Given CSession must be running"); throw std::runtime_error("Given CSession must be running");
@@ -123,10 +112,6 @@ struct DDSSession::Impl
Impl(Impl&&) = delete; Impl(Impl&&) = delete;
Impl& operator=(Impl&&) = delete; Impl& operator=(Impl&&) = delete;
struct Tag {};
friend auto operator<<(std::ostream& os, Tag) -> std::ostream& { return os << "DDSSession"; }
tools::InstanceLimiter<Tag, 1> fCount;
DDSEnvironment fEnv; DDSEnvironment fEnv;
DDSRMSPlugin fRMSPlugin; DDSRMSPlugin fRMSPlugin;
Path fRMSConfig; Path fRMSConfig;
@@ -398,6 +383,4 @@ auto getMostRecentRunningDDSSession(DDSEnv env) -> DDSSession
return DDSSession(DDSSession::Id(sessionId), std::move(env)); return DDSSession(DDSSession::Id(sessionId), std::move(env));
} }
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair

View File

@@ -24,9 +24,8 @@
#include <functional> #include <functional>
#include <vector> #include <vector>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
/** /**
* @enum DDSRMSPlugin DDSSession.h <fairmq/sdk/DDSSession.h> * @enum DDSRMSPlugin DDSSession.h <fairmq/sdk/DDSSession.h>
@@ -114,8 +113,6 @@ class DDSSession
auto getMostRecentRunningDDSSession(DDSEnv env = {}) -> DDSSession; auto getMostRecentRunningDDSSession(DDSEnv env = {}) -> DDSSession;
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair
#endif /* FAIR_MQ_SDK_DDSSESSION_H */ #endif /* FAIR_MQ_SDK_DDSSESSION_H */

View File

@@ -14,9 +14,8 @@
#include <ostream> #include <ostream>
#include <cstdint> #include <cstdint>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
/** /**
* @class DDSTask <fairmq/sdk/DDSTask.h> * @class DDSTask <fairmq/sdk/DDSTask.h>
@@ -45,8 +44,6 @@ class DDSTask
DDSCollection::Id fCollectionId; DDSCollection::Id fCollectionId;
}; };
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair
#endif /* FAIR_MQ_SDK_DDSTASK_H */ #endif /* FAIR_MQ_SDK_DDSTASK_H */

View File

@@ -11,16 +11,14 @@
#include <boost/range/iterator_range.hpp> #include <boost/range/iterator_range.hpp>
#include <dds/dds.h> #include <dds/dds.h>
#include <fairlogger/Logger.h> #include <fairlogger/Logger.h>
#include <fairmq/Tools.h>
#include <fairmq/sdk/DDSEnvironment.h> #include <fairmq/sdk/DDSEnvironment.h>
#include <memory> #include <memory>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
struct DDSTopology::Impl struct DDSTopology::Impl
{ {
@@ -113,6 +111,4 @@ try {
return os << "DDS topology: " << t.GetName(); return os << "DDS topology: " << t.GetName();
} }
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair

View File

@@ -18,9 +18,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
/** /**
* @class DDSTopology DDSTopology.h <fairmq/sdk/DDSTopology.h> * @class DDSTopology DDSTopology.h <fairmq/sdk/DDSTopology.h>
@@ -71,8 +70,6 @@ class DDSTopology
using DDSTopo = DDSTopology; using DDSTopo = DDSTopology;
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair
#endif /* FAIR_MQ_SDK_DDSTOPOLOGY_H */ #endif /* FAIR_MQ_SDK_DDSTOPOLOGY_H */

View File

@@ -8,8 +8,8 @@
#include "Error.h" #include "Error.h"
namespace fair { namespace fair::mq
namespace mq { {
const char* ErrorCategory::name() const noexcept const char* ErrorCategory::name() const noexcept
{ {
@@ -40,5 +40,4 @@ const ErrorCategory errorCategory{};
std::error_code MakeErrorCode(ErrorCode e) { return {static_cast<int>(e), errorCategory}; } std::error_code MakeErrorCode(ErrorCode e) { return {static_cast<int>(e), errorCategory}; }
} // namespace mq } // namespace fair::mq
} // namespace fair

View File

@@ -13,9 +13,11 @@
#include <stdexcept> #include <stdexcept>
#include <system_error> #include <system_error>
namespace fair { namespace fair::mq
namespace mq { {
namespace sdk {
namespace sdk
{
struct RuntimeError : ::std::runtime_error struct RuntimeError : ::std::runtime_error
{ {
@@ -45,10 +47,10 @@ struct ErrorCategory : std::error_category
std::string message(int ev) const override; std::string message(int ev) const override;
}; };
} /* namespace mq */ } // namespace fair::mq
} /* namespace fair */
namespace std { namespace std
{
template<> template<>
struct is_error_code_enum<fair::mq::ErrorCode> : true_type struct is_error_code_enum<fair::mq::ErrorCode> : true_type

View File

@@ -10,21 +10,20 @@
#include <dds/dds.h> #include <dds/dds.h>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
/// @brief Helper to (Re)Construct a FairMQ topology based on already existing native DDS API objects /// @brief Helper to (Re)Construct a FairMQ topology based on already existing native DDS API objects
/// @param nativeSession Existing and initialized CSession (either via create() or attach()) /// @param nativeSession Existing and initialized CSession (either via create() or attach())
/// @param nativeTopo Existing CTopology that is activated on the given nativeSession /// @param nativeTopo Existing CTopology that is activated on the given nativeSession
/// @param env Optional DDSEnv (needed primarily for unit testing) /// @param env Optional DDSEnv (needed primarily for unit testing)
/// @param blockUntilConnected if true, ctor will wait for all tasks to confirm subscriptions
auto MakeTopology(dds::topology_api::CTopology nativeTopo, auto MakeTopology(dds::topology_api::CTopology nativeTopo,
std::shared_ptr<dds::tools_api::CSession> nativeSession, std::shared_ptr<dds::tools_api::CSession> nativeSession,
DDSEnv env) -> Topology DDSEnv env,
bool blockUntilConnected) -> Topology
{ {
return {DDSTopo(std::move(nativeTopo), env), DDSSession(std::move(nativeSession), env)}; return {DDSTopo(std::move(nativeTopo), env), DDSSession(std::move(nativeSession), env), blockUntilConnected};
} }
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair

View File

@@ -48,9 +48,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace fair { namespace fair::mq::sdk
namespace mq { {
namespace sdk {
using DeviceId = std::string; using DeviceId = std::string;
using DeviceState = fair::mq::State; using DeviceState = fair::mq::State;
@@ -105,12 +104,30 @@ inline auto operator==(AggregatedTopologyState lhs, DeviceState rhs) -> bool
inline std::ostream& operator<<(std::ostream& os, const AggregatedTopologyState& state) inline std::ostream& operator<<(std::ostream& os, const AggregatedTopologyState& state)
{ {
if (state == AggregatedTopologyState::Mixed) { if (state == AggregatedTopologyState::Mixed) {
return os << "Mixed"; return os << "MIXED";
} else { } else {
return os << static_cast<DeviceState>(state); return os << static_cast<DeviceState>(state);
} }
} }
inline std::string GetAggregatedTopologyStateName(AggregatedTopologyState s)
{
if (s == AggregatedTopologyState::Mixed) {
return "MIXED";
} else {
return GetStateName(static_cast<State>(s));
}
}
inline AggregatedTopologyState GetAggregatedTopologyState(const std::string& state)
{
if (state == "MIXED") {
return AggregatedTopologyState::Mixed;
} else {
return static_cast<AggregatedTopologyState>(GetState(state));
}
}
struct DeviceStatus struct DeviceStatus
{ {
bool subscribed_to_state_changes; bool subscribed_to_state_changes;
@@ -198,24 +215,30 @@ class BasicTopology : public AsioBase<Executor, Allocator>
/// @brief (Re)Construct a FairMQ topology from an existing DDS topology /// @brief (Re)Construct a FairMQ topology from an existing DDS topology
/// @param topo DDSTopology /// @param topo DDSTopology
/// @param session DDSSession /// @param session DDSSession
BasicTopology(DDSTopology topo, DDSSession session) /// @param blockUntilConnected if true, ctor will wait for all tasks to confirm subscriptions
: BasicTopology<Executor, Allocator>(asio::system_executor(), std::move(topo), std::move(session)) BasicTopology(DDSTopology topo, DDSSession session, bool blockUntilConnected = false)
: BasicTopology<Executor, Allocator>(asio::system_executor(), std::move(topo), std::move(session), blockUntilConnected)
{} {}
/// @brief (Re)Construct a FairMQ topology from an existing DDS topology /// @brief (Re)Construct a FairMQ topology from an existing DDS topology
/// @param ex I/O executor to be associated /// @param ex I/O executor to be associated
/// @param topo DDSTopology /// @param topo DDSTopology
/// @param session DDSSession /// @param session DDSSession
/// @param blockUntilConnected if true, ctor will wait for all tasks to confirm subscriptions
/// @throws RuntimeError /// @throws RuntimeError
BasicTopology(const Executor& ex, BasicTopology(const Executor& ex,
DDSTopology topo, DDSTopology topo,
DDSSession session, DDSSession session,
bool blockUntilConnected = false,
Allocator alloc = DefaultAllocator()) Allocator alloc = DefaultAllocator())
: AsioBase<Executor, Allocator>(ex, std::move(alloc)) : AsioBase<Executor, Allocator>(ex, std::move(alloc))
, fDDSSession(std::move(session)) , fDDSSession(std::move(session))
, fDDSTopo(std::move(topo)) , fDDSTopo(std::move(topo))
, fStateData() , fStateData()
, fStateIndex() , fStateIndex()
, fMtx(std::make_unique<std::mutex>())
, fStateChangeSubscriptionsCV(std::make_unique<std::condition_variable>())
, fNumStateChangePublishers(0)
, fHeartbeatsTimer(asio::system_executor()) , fHeartbeatsTimer(asio::system_executor())
, fHeartbeatInterval(600000) , fHeartbeatInterval(600000)
{ {
@@ -231,6 +254,9 @@ class BasicTopology : public AsioBase<Executor, Allocator>
fDDSSession.StartDDSService(); fDDSSession.StartDDSService();
SubscribeToStateChanges(); SubscribeToStateChanges();
if (blockUntilConnected) {
WaitForPublisherCount(fStateIndex.size());
}
} }
/// not copyable /// not copyable
@@ -245,7 +271,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
{ {
UnsubscribeFromStateChanges(); UnsubscribeFromStateChanges();
std::lock_guard<std::mutex> lk(fMtx); std::lock_guard<std::mutex> lk(*fMtx);
fDDSSession.UnsubscribeFromCommands(); fDDSSession.UnsubscribeFromCommands();
try { try {
for (auto& op : fChangeStateOps) { for (auto& op : fChangeStateOps) {
@@ -264,6 +290,14 @@ class BasicTopology : public AsioBase<Executor, Allocator>
fHeartbeatsTimer.async_wait(std::bind(&BasicTopology::SendSubscriptionHeartbeats, this, std::placeholders::_1)); fHeartbeatsTimer.async_wait(std::bind(&BasicTopology::SendSubscriptionHeartbeats, this, std::placeholders::_1));
} }
void WaitForPublisherCount(unsigned int number)
{
std::unique_lock<std::mutex> lk(*fMtx);
fStateChangeSubscriptionsCV->wait(lk, [&](){
return fNumStateChangePublishers == number;
});
}
void SendSubscriptionHeartbeats(const std::error_code& ec) void SendSubscriptionHeartbeats(const std::error_code& ec)
{ {
if (!ec) { if (!ec) {
@@ -288,13 +322,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
fDDSSession.SendCommand(cmd::Cmds(cmd::make<cmd::UnsubscribeFromStateChange>()).Serialize()); fDDSSession.SendCommand(cmd::Cmds(cmd::make<cmd::UnsubscribeFromStateChange>()).Serialize());
// wait for all tasks to confirm unsubscription // wait for all tasks to confirm unsubscription
std::unique_lock<std::mutex> lk(fMtx); WaitForPublisherCount(0);
fStateChangeUnsubscriptionCV.wait(lk, [&](){
unsigned int count = std::count_if(fStateIndex.cbegin(), fStateIndex.cend(), [=](const auto& s) {
return fStateData.at(s.second).subscribed_to_state_changes == false;
});
return count == fStateIndex.size();
});
} }
void SubscribeToCommands() void SubscribeToCommands()
@@ -340,11 +368,19 @@ class BasicTopology : public AsioBase<Executor, Allocator>
DDSTask::Id taskId(cmd.GetTaskId()); DDSTask::Id taskId(cmd.GetTaskId());
try { try {
std::lock_guard<std::mutex> lk(fMtx); std::unique_lock<std::mutex> lk(*fMtx);
DeviceStatus& task = fStateData.at(fStateIndex.at(taskId)); DeviceStatus& task = fStateData.at(fStateIndex.at(taskId));
if (!task.subscribed_to_state_changes) {
task.subscribed_to_state_changes = true; task.subscribed_to_state_changes = true;
++fNumStateChangePublishers;
} else {
FAIR_LOG(warn) << "Task '" << task.taskId << "' sent subscription confirmation more than once";
}
lk.unlock();
fStateChangeSubscriptionsCV->notify_one();
} catch (const std::exception& e) { } catch (const std::exception& e) {
FAIR_LOG(error) << "Exception in HandleCmd(cmd::StateChangeSubscription const&): " << e.what(); FAIR_LOG(error) << "Exception in HandleCmd(cmd::StateChangeSubscription const&): " << e.what();
FAIR_LOG(error) << "Possibly no task with id '" << taskId << "'?";
} }
} else { } else {
FAIR_LOG(error) << "State change subscription failed for device: " << cmd.GetDeviceId() << ", task id: " << cmd.GetTaskId(); FAIR_LOG(error) << "State change subscription failed for device: " << cmd.GetDeviceId() << ", task id: " << cmd.GetTaskId();
@@ -357,11 +393,16 @@ class BasicTopology : public AsioBase<Executor, Allocator>
DDSTask::Id taskId(cmd.GetTaskId()); DDSTask::Id taskId(cmd.GetTaskId());
try { try {
std::unique_lock<std::mutex> lk(fMtx); std::unique_lock<std::mutex> lk(*fMtx);
DeviceStatus& task = fStateData.at(fStateIndex.at(taskId)); DeviceStatus& task = fStateData.at(fStateIndex.at(taskId));
if (task.subscribed_to_state_changes) {
task.subscribed_to_state_changes = false; task.subscribed_to_state_changes = false;
--fNumStateChangePublishers;
} else {
FAIR_LOG(warn) << "Task '" << task.taskId << "' sent unsubscription confirmation more than once";
}
lk.unlock(); lk.unlock();
fStateChangeUnsubscriptionCV.notify_one(); fStateChangeSubscriptionsCV->notify_one();
} catch (const std::exception& e) { } catch (const std::exception& e) {
FAIR_LOG(error) << "Exception in HandleCmd(cmd::StateChangeUnsubscription const&): " << e.what(); FAIR_LOG(error) << "Exception in HandleCmd(cmd::StateChangeUnsubscription const&): " << e.what();
} }
@@ -379,13 +420,14 @@ class BasicTopology : public AsioBase<Executor, Allocator>
DDSTask::Id taskId(cmd.GetTaskId()); DDSTask::Id taskId(cmd.GetTaskId());
try { try {
std::lock_guard<std::mutex> lk(fMtx); std::lock_guard<std::mutex> lk(*fMtx);
DeviceStatus& task = fStateData.at(fStateIndex.at(taskId)); DeviceStatus& task = fStateData.at(fStateIndex.at(taskId));
task.lastState = cmd.GetLastState(); task.lastState = cmd.GetLastState();
task.state = cmd.GetCurrentState(); task.state = cmd.GetCurrentState();
// if the task is exiting, it will not respond to unsubscription request anymore, set it to false now. // if the task is exiting, it will not respond to unsubscription request anymore, set it to false now.
if (task.state == DeviceState::Exiting) { if (task.state == DeviceState::Exiting) {
task.subscribed_to_state_changes = false; task.subscribed_to_state_changes = false;
--fNumStateChangePublishers;
} }
// FAIR_LOG(debug) << "Updated state entry: taskId=" << taskId << ", state=" << state; // FAIR_LOG(debug) << "Updated state entry: taskId=" << taskId << ", state=" << state;
@@ -403,13 +445,16 @@ class BasicTopology : public AsioBase<Executor, Allocator>
auto HandleCmd(cmd::TransitionStatus const& cmd) -> void auto HandleCmd(cmd::TransitionStatus const& cmd) -> void
{ {
if (cmd.GetResult() != cmd::Result::Ok) { if (cmd.GetResult() != cmd::Result::Ok) {
FAIR_LOG(error) << cmd.GetTransition() << " transition failed for " << cmd.GetDeviceId();
DDSTask::Id taskId(cmd.GetTaskId()); DDSTask::Id taskId(cmd.GetTaskId());
std::lock_guard<std::mutex> lk(fMtx); std::lock_guard<std::mutex> lk(*fMtx);
for (auto& op : fChangeStateOps) { for (auto& op : fChangeStateOps) {
if (!op.second.IsCompleted() && op.second.ContainsTask(taskId) && if (!op.second.IsCompleted() && op.second.ContainsTask(taskId)) {
fStateData.at(fStateIndex.at(taskId)).state != op.second.GetTargetState()) { if (fStateData.at(fStateIndex.at(taskId)).state != op.second.GetTargetState()) {
FAIR_LOG(error) << cmd.GetTransition() << " transition failed for " << cmd.GetDeviceId() << ", device is in " << cmd.GetCurrentState() << " state.";
op.second.Complete(MakeErrorCode(ErrorCode::DeviceChangeStateFailed)); op.second.Complete(MakeErrorCode(ErrorCode::DeviceChangeStateFailed));
} else {
FAIR_LOG(debug) << cmd.GetTransition() << " transition failed for " << cmd.GetDeviceId() << ", device is already in " << cmd.GetCurrentState() << " state.";
}
} }
} }
} }
@@ -417,7 +462,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
auto HandleCmd(cmd::Properties const& cmd) -> void auto HandleCmd(cmd::Properties const& cmd) -> void
{ {
std::unique_lock<std::mutex> lk(fMtx); std::unique_lock<std::mutex> lk(*fMtx);
try { try {
auto& op(fGetPropertiesOps.at(cmd.GetRequestId())); auto& op(fGetPropertiesOps.at(cmd.GetRequestId()));
lk.unlock(); lk.unlock();
@@ -431,7 +476,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
auto HandleCmd(cmd::PropertiesSet const& cmd) -> void auto HandleCmd(cmd::PropertiesSet const& cmd) -> void
{ {
std::unique_lock<std::mutex> lk(fMtx); std::unique_lock<std::mutex> lk(*fMtx);
try { try {
auto& op(fSetPropertiesOps.at(cmd.GetRequestId())); auto& op(fSetPropertiesOps.at(cmd.GetRequestId()));
lk.unlock(); lk.unlock();
@@ -443,7 +488,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
} }
} }
using Duration = std::chrono::milliseconds; using Duration = std::chrono::microseconds;
using ChangeStateCompletionSignature = void(std::error_code, TopologyState); using ChangeStateCompletionSignature = void(std::error_code, TopologyState);
private: private:
@@ -638,7 +683,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
return asio::async_initiate<CompletionToken, ChangeStateCompletionSignature>([&](auto handler) { return asio::async_initiate<CompletionToken, ChangeStateCompletionSignature>([&](auto handler) {
typename ChangeStateOp::Id const id(tools::UuidHash()); typename ChangeStateOp::Id const id(tools::UuidHash());
std::lock_guard<std::mutex> lk(fMtx); std::lock_guard<std::mutex> lk(*fMtx);
for (auto it = begin(fChangeStateOps); it != end(fChangeStateOps);) { for (auto it = begin(fChangeStateOps); it != end(fChangeStateOps);) {
if (it->second.IsCompleted()) { if (it->second.IsCompleted()) {
@@ -656,7 +701,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
fDDSTopo.GetTasks(path), fDDSTopo.GetTasks(path),
fStateData, fStateData,
timeout, timeout,
fMtx, *fMtx,
AsioBase<Executor, Allocator>::GetExecutor(), AsioBase<Executor, Allocator>::GetExecutor(),
AsioBase<Executor, Allocator>::GetAllocator(), AsioBase<Executor, Allocator>::GetAllocator(),
std::move(handler))); std::move(handler)));
@@ -741,7 +786,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
/// @return map of id : DeviceStatus /// @return map of id : DeviceStatus
auto GetCurrentState() const -> TopologyState auto GetCurrentState() const -> TopologyState
{ {
std::lock_guard<std::mutex> lk(fMtx); std::lock_guard<std::mutex> lk(*fMtx);
return fStateData; return fStateData;
} }
@@ -869,7 +914,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
return asio::async_initiate<CompletionToken, WaitForStateCompletionSignature>([&](auto handler) { return asio::async_initiate<CompletionToken, WaitForStateCompletionSignature>([&](auto handler) {
typename GetPropertiesOp::Id const id(tools::UuidHash()); typename GetPropertiesOp::Id const id(tools::UuidHash());
std::lock_guard<std::mutex> lk(fMtx); std::lock_guard<std::mutex> lk(*fMtx);
for (auto it = begin(fWaitForStateOps); it != end(fWaitForStateOps);) { for (auto it = begin(fWaitForStateOps); it != end(fWaitForStateOps);) {
if (it->second.IsCompleted()) { if (it->second.IsCompleted()) {
@@ -887,7 +932,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
targetCurrentState, targetCurrentState,
fDDSTopo.GetTasks(path), fDDSTopo.GetTasks(path),
timeout, timeout,
fMtx, *fMtx,
AsioBase<Executor, Allocator>::GetExecutor(), AsioBase<Executor, Allocator>::GetExecutor(),
AsioBase<Executor, Allocator>::GetAllocator(), AsioBase<Executor, Allocator>::GetAllocator(),
std::move(handler))); std::move(handler)));
@@ -1050,7 +1095,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
[&](auto handler) { [&](auto handler) {
typename GetPropertiesOp::Id const id(tools::UuidHash()); typename GetPropertiesOp::Id const id(tools::UuidHash());
std::lock_guard<std::mutex> lk(fMtx); std::lock_guard<std::mutex> lk(*fMtx);
for (auto it = begin(fGetPropertiesOps); it != end(fGetPropertiesOps);) { for (auto it = begin(fGetPropertiesOps); it != end(fGetPropertiesOps);) {
if (it->second.IsCompleted()) { if (it->second.IsCompleted()) {
@@ -1066,7 +1111,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
std::forward_as_tuple(id, std::forward_as_tuple(id,
fDDSTopo.GetTasks(path).size(), fDDSTopo.GetTasks(path).size(),
timeout, timeout,
fMtx, *fMtx,
AsioBase<Executor, Allocator>::GetExecutor(), AsioBase<Executor, Allocator>::GetExecutor(),
AsioBase<Executor, Allocator>::GetAllocator(), AsioBase<Executor, Allocator>::GetAllocator(),
std::move(handler))); std::move(handler)));
@@ -1206,7 +1251,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
[&](auto handler) { [&](auto handler) {
typename SetPropertiesOp::Id const id(tools::UuidHash()); typename SetPropertiesOp::Id const id(tools::UuidHash());
std::lock_guard<std::mutex> lk(fMtx); std::lock_guard<std::mutex> lk(*fMtx);
for (auto it = begin(fGetPropertiesOps); it != end(fGetPropertiesOps);) { for (auto it = begin(fGetPropertiesOps); it != end(fGetPropertiesOps);) {
if (it->second.IsCompleted()) { if (it->second.IsCompleted()) {
@@ -1222,7 +1267,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
std::forward_as_tuple(id, std::forward_as_tuple(id,
fDDSTopo.GetTasks(path).size(), fDDSTopo.GetTasks(path).size(),
timeout, timeout,
fMtx, *fMtx,
AsioBase<Executor, Allocator>::GetExecutor(), AsioBase<Executor, Allocator>::GetExecutor(),
AsioBase<Executor, Allocator>::GetAllocator(), AsioBase<Executor, Allocator>::GetAllocator(),
std::move(handler))); std::move(handler)));
@@ -1275,9 +1320,10 @@ class BasicTopology : public AsioBase<Executor, Allocator>
TopologyState fStateData; TopologyState fStateData;
TopologyStateIndex fStateIndex; TopologyStateIndex fStateIndex;
mutable std::mutex fMtx; mutable std::unique_ptr<std::mutex> fMtx;
std::condition_variable fStateChangeUnsubscriptionCV; std::unique_ptr<std::condition_variable> fStateChangeSubscriptionsCV;
unsigned int fNumStateChangePublishers;
asio::steady_timer fHeartbeatsTimer; asio::steady_timer fHeartbeatsTimer;
Duration fHeartbeatInterval; Duration fHeartbeatInterval;
@@ -1313,12 +1359,12 @@ using Topo = Topology;
/// @param nativeSession Existing and initialized CSession (either via create() or attach()) /// @param nativeSession Existing and initialized CSession (either via create() or attach())
/// @param nativeTopo Existing CTopology that is activated on the given nativeSession /// @param nativeTopo Existing CTopology that is activated on the given nativeSession
/// @param env Optional DDSEnv (needed primarily for unit testing) /// @param env Optional DDSEnv (needed primarily for unit testing)
/// @param blockUntilConnected if true, ctor will wait for all tasks to confirm subscriptions
auto MakeTopology(dds::topology_api::CTopology nativeTopo, auto MakeTopology(dds::topology_api::CTopology nativeTopo,
std::shared_ptr<dds::tools_api::CSession> nativeSession, std::shared_ptr<dds::tools_api::CSession> nativeSession,
DDSEnv env = {}) -> Topology; DDSEnv env = {},
bool blockUntilConnected = false) -> Topology;
} // namespace sdk } // namespace fair::mq::sdk
} // namespace mq
} // namespace fair
#endif /* FAIR_MQ_SDK_TOPOLOGY_H */ #endif /* FAIR_MQ_SDK_TOPOLOGY_H */

View File

@@ -13,8 +13,7 @@
#include <asio/associated_executor.hpp> #include <asio/associated_executor.hpp>
#include <type_traits> #include <type_traits>
namespace asio { namespace asio::detail {
namespace detail {
/// Specialize to match our coding conventions /// Specialize to match our coding conventions
template<typename T, typename Executor> template<typename T, typename Executor>
@@ -44,7 +43,6 @@ struct associated_allocator_impl<T,
} }
}; };
} /* namespace detail */ } /* namespace asio::detail */
} /* namespace asio */
#endif /* FAIR_MQ_SDK_TRAITS_H */ #endif /* FAIR_MQ_SDK_TRAITS_H */

View File

@@ -17,10 +17,8 @@
using namespace std; using namespace std;
namespace fair { namespace fair::mq::sdk::cmd
namespace mq { {
namespace sdk {
namespace cmd {
array<Result, 2> fbResultToResult = array<Result, 2> fbResultToResult =
{ {
@@ -219,37 +217,37 @@ string Cmds::Serialize(const Format type) const
switch (cmd->GetType()) { switch (cmd->GetType()) {
case Type::check_state: { case Type::check_state: {
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
} }
break; break;
case Type::change_state: { case Type::change_state: {
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_transition(GetFBTransition(static_cast<ChangeState&>(*cmd).GetTransition())); cmdBuilder->add_transition(GetFBTransition(static_cast<ChangeState&>(*cmd).GetTransition()));
} }
break; break;
case Type::dump_config: { case Type::dump_config: {
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
} }
break; break;
break; break;
case Type::subscribe_to_state_change: { case Type::subscribe_to_state_change: {
auto _cmd = static_cast<SubscribeToStateChange&>(*cmd); auto _cmd = static_cast<SubscribeToStateChange&>(*cmd);
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_interval(_cmd.GetInterval()); cmdBuilder->add_interval(_cmd.GetInterval());
} }
break; break;
case Type::unsubscribe_from_state_change: { case Type::unsubscribe_from_state_change: {
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
} }
break; break;
case Type::state_change_exiting_received: { case Type::state_change_exiting_received: {
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
} }
break; break;
case Type::get_properties: { case Type::get_properties: {
auto _cmd = static_cast<GetProperties&>(*cmd); auto _cmd = static_cast<GetProperties&>(*cmd);
auto query = fbb.CreateString(_cmd.GetQuery()); auto query = fbb.CreateString(_cmd.GetQuery());
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_request_id(_cmd.GetRequestId()); cmdBuilder->add_request_id(_cmd.GetRequestId());
cmdBuilder->add_property_query(query); cmdBuilder->add_property_query(query);
} }
@@ -263,21 +261,21 @@ string Cmds::Serialize(const Format type) const
propsVector.push_back(CreateFBProperty(fbb, key, val)); propsVector.push_back(CreateFBProperty(fbb, key, val));
} }
auto props = fbb.CreateVector(propsVector); auto props = fbb.CreateVector(propsVector);
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_request_id(_cmd.GetRequestId()); cmdBuilder->add_request_id(_cmd.GetRequestId());
cmdBuilder->add_properties(props); cmdBuilder->add_properties(props);
} }
break; break;
case Type::subscription_heartbeat: { case Type::subscription_heartbeat: {
auto _cmd = static_cast<SubscriptionHeartbeat&>(*cmd); auto _cmd = static_cast<SubscriptionHeartbeat&>(*cmd);
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_interval(_cmd.GetInterval()); cmdBuilder->add_interval(_cmd.GetInterval());
} }
break; break;
case Type::current_state: { case Type::current_state: {
auto _cmd = static_cast<CurrentState&>(*cmd); auto _cmd = static_cast<CurrentState&>(*cmd);
auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); auto deviceId = fbb.CreateString(_cmd.GetDeviceId());
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_device_id(deviceId); cmdBuilder->add_device_id(deviceId);
cmdBuilder->add_current_state(GetFBState(_cmd.GetCurrentState())); cmdBuilder->add_current_state(GetFBState(_cmd.GetCurrentState()));
} }
@@ -285,18 +283,19 @@ string Cmds::Serialize(const Format type) const
case Type::transition_status: { case Type::transition_status: {
auto _cmd = static_cast<TransitionStatus&>(*cmd); auto _cmd = static_cast<TransitionStatus&>(*cmd);
auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); auto deviceId = fbb.CreateString(_cmd.GetDeviceId());
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_device_id(deviceId); cmdBuilder->add_device_id(deviceId);
cmdBuilder->add_task_id(_cmd.GetTaskId()); cmdBuilder->add_task_id(_cmd.GetTaskId());
cmdBuilder->add_result(GetFBResult(_cmd.GetResult())); cmdBuilder->add_result(GetFBResult(_cmd.GetResult()));
cmdBuilder->add_transition(GetFBTransition(_cmd.GetTransition())); cmdBuilder->add_transition(GetFBTransition(_cmd.GetTransition()));
cmdBuilder->add_current_state(GetFBState(_cmd.GetCurrentState()));
} }
break; break;
case Type::config: { case Type::config: {
auto _cmd = static_cast<Config&>(*cmd); auto _cmd = static_cast<Config&>(*cmd);
auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); auto deviceId = fbb.CreateString(_cmd.GetDeviceId());
auto config = fbb.CreateString(_cmd.GetConfig()); auto config = fbb.CreateString(_cmd.GetConfig());
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_device_id(deviceId); cmdBuilder->add_device_id(deviceId);
cmdBuilder->add_config_string(config); cmdBuilder->add_config_string(config);
} }
@@ -304,7 +303,7 @@ string Cmds::Serialize(const Format type) const
case Type::state_change_subscription: { case Type::state_change_subscription: {
auto _cmd = static_cast<StateChangeSubscription&>(*cmd); auto _cmd = static_cast<StateChangeSubscription&>(*cmd);
auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); auto deviceId = fbb.CreateString(_cmd.GetDeviceId());
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_device_id(deviceId); cmdBuilder->add_device_id(deviceId);
cmdBuilder->add_task_id(_cmd.GetTaskId()); cmdBuilder->add_task_id(_cmd.GetTaskId());
cmdBuilder->add_result(GetFBResult(_cmd.GetResult())); cmdBuilder->add_result(GetFBResult(_cmd.GetResult()));
@@ -313,7 +312,7 @@ string Cmds::Serialize(const Format type) const
case Type::state_change_unsubscription: { case Type::state_change_unsubscription: {
auto _cmd = static_cast<StateChangeUnsubscription&>(*cmd); auto _cmd = static_cast<StateChangeUnsubscription&>(*cmd);
auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); auto deviceId = fbb.CreateString(_cmd.GetDeviceId());
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_device_id(deviceId); cmdBuilder->add_device_id(deviceId);
cmdBuilder->add_task_id(_cmd.GetTaskId()); cmdBuilder->add_task_id(_cmd.GetTaskId());
cmdBuilder->add_result(GetFBResult(_cmd.GetResult())); cmdBuilder->add_result(GetFBResult(_cmd.GetResult()));
@@ -322,7 +321,7 @@ string Cmds::Serialize(const Format type) const
case Type::state_change: { case Type::state_change: {
auto _cmd = static_cast<StateChange&>(*cmd); auto _cmd = static_cast<StateChange&>(*cmd);
auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); auto deviceId = fbb.CreateString(_cmd.GetDeviceId());
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_device_id(deviceId); cmdBuilder->add_device_id(deviceId);
cmdBuilder->add_task_id(_cmd.GetTaskId()); cmdBuilder->add_task_id(_cmd.GetTaskId());
cmdBuilder->add_last_state(GetFBState(_cmd.GetLastState())); cmdBuilder->add_last_state(GetFBState(_cmd.GetLastState()));
@@ -341,7 +340,7 @@ string Cmds::Serialize(const Format type) const
propsVector.push_back(prop); propsVector.push_back(prop);
} }
auto props = fbb.CreateVector(propsVector); auto props = fbb.CreateVector(propsVector);
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_device_id(deviceId); cmdBuilder->add_device_id(deviceId);
cmdBuilder->add_request_id(_cmd.GetRequestId()); cmdBuilder->add_request_id(_cmd.GetRequestId());
cmdBuilder->add_result(GetFBResult(_cmd.GetResult())); cmdBuilder->add_result(GetFBResult(_cmd.GetResult()));
@@ -351,7 +350,7 @@ string Cmds::Serialize(const Format type) const
case Type::properties_set: { case Type::properties_set: {
auto _cmd = static_cast<PropertiesSet&>(*cmd); auto _cmd = static_cast<PropertiesSet&>(*cmd);
auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); auto deviceId = fbb.CreateString(_cmd.GetDeviceId());
cmdBuilder = tools::make_unique<FBCommandBuilder>(fbb); cmdBuilder = make_unique<FBCommandBuilder>(fbb);
cmdBuilder->add_device_id(deviceId); cmdBuilder->add_device_id(deviceId);
cmdBuilder->add_request_id(_cmd.GetRequestId()); cmdBuilder->add_request_id(_cmd.GetRequestId());
cmdBuilder->add_result(GetFBResult(_cmd.GetResult())); cmdBuilder->add_result(GetFBResult(_cmd.GetResult()));
@@ -445,7 +444,7 @@ void Cmds::Deserialize(const string& str, const Format type)
fCmds.emplace_back(make<CurrentState>(cmdPtr.device_id()->str(), GetMQState(cmdPtr.current_state()))); fCmds.emplace_back(make<CurrentState>(cmdPtr.device_id()->str(), GetMQState(cmdPtr.current_state())));
break; break;
case FBCmd_transition_status: case FBCmd_transition_status:
fCmds.emplace_back(make<TransitionStatus>(cmdPtr.device_id()->str(), cmdPtr.task_id(), GetResult(cmdPtr.result()), GetMQTransition(cmdPtr.transition()))); fCmds.emplace_back(make<TransitionStatus>(cmdPtr.device_id()->str(), cmdPtr.task_id(), GetResult(cmdPtr.result()), GetMQTransition(cmdPtr.transition()), GetMQState(cmdPtr.current_state())));
break; break;
case FBCmd_config: case FBCmd_config:
fCmds.emplace_back(make<Config>(cmdPtr.device_id()->str(), cmdPtr.config_string()->str())); fCmds.emplace_back(make<Config>(cmdPtr.device_id()->str(), cmdPtr.config_string()->str()));
@@ -477,7 +476,4 @@ void Cmds::Deserialize(const string& str, const Format type)
} }
} }
} // namespace cmd } // namespace fair::mq::sdk::cmd
} // namespace sdk
} // namespace mq
} // namespace fair

View File

@@ -10,7 +10,6 @@
#define FAIR_MQ_SDK_COMMANDFACTORY #define FAIR_MQ_SDK_COMMANDFACTORY
#include <fairmq/States.h> #include <fairmq/States.h>
#include <fairmq/tools/CppSTL.h>
#include <vector> #include <vector>
#include <string> #include <string>
@@ -18,13 +17,7 @@
#include <type_traits> #include <type_traits>
#include <stdexcept> #include <stdexcept>
namespace fair namespace fair::mq::sdk::cmd
{
namespace mq
{
namespace sdk
{
namespace cmd
{ {
enum class Format : int { enum class Format : int {
@@ -50,7 +43,7 @@ enum class Type : int
subscription_heartbeat, // args: { interval } subscription_heartbeat, // args: { interval }
current_state, // args: { device_id, current_state } current_state, // args: { device_id, current_state }
transition_status, // args: { device_id, task_id, Result, transition } transition_status, // args: { device_id, task_id, Result, transition, current_state }
config, // args: { device_id, config_string } config, // args: { device_id, config_string }
state_change_subscription, // args: { device_id, task_id, Result } state_change_subscription, // args: { device_id, task_id, Result }
state_change_unsubscription, // args: { device_id, task_id, Result } state_change_unsubscription, // args: { device_id, task_id, Result }
@@ -188,12 +181,13 @@ struct CurrentState : Cmd
struct TransitionStatus : Cmd struct TransitionStatus : Cmd
{ {
explicit TransitionStatus(const std::string& deviceId, const uint64_t taskId, const Result result, const Transition transition) explicit TransitionStatus(const std::string& deviceId, const uint64_t taskId, const Result result, const Transition transition, State currentState)
: Cmd(Type::transition_status) : Cmd(Type::transition_status)
, fDeviceId(deviceId) , fDeviceId(deviceId)
, fTaskId(taskId) , fTaskId(taskId)
, fResult(result) , fResult(result)
, fTransition(transition) , fTransition(transition)
, fCurrentState(currentState)
{} {}
std::string GetDeviceId() const { return fDeviceId; } std::string GetDeviceId() const { return fDeviceId; }
@@ -204,12 +198,15 @@ struct TransitionStatus : Cmd
void SetResult(const Result result) { fResult = result; } void SetResult(const Result result) { fResult = result; }
Transition GetTransition() const { return fTransition; } Transition GetTransition() const { return fTransition; }
void SetTransition(const Transition transition) { fTransition = transition; } void SetTransition(const Transition transition) { fTransition = transition; }
fair::mq::State GetCurrentState() const { return fCurrentState; }
void SetCurrentState(fair::mq::State state) { fCurrentState = state; }
private: private:
std::string fDeviceId; std::string fDeviceId;
uint64_t fTaskId; uint64_t fTaskId;
Result fResult; Result fResult;
Transition fTransition; Transition fTransition;
fair::mq::State fCurrentState;
}; };
struct Config : Cmd struct Config : Cmd
@@ -350,7 +347,7 @@ struct PropertiesSet : Cmd {
template<typename C, typename... Args> template<typename C, typename... Args>
std::unique_ptr<Cmd> make(Args&&... args) std::unique_ptr<Cmd> make(Args&&... args)
{ {
return fair::mq::tools::make_unique<C>(std::forward<Args>(args)...); return std::make_unique<C>(std::forward<Args>(args)...);
} }
struct Cmds struct Cmds
@@ -411,9 +408,6 @@ std::string GetTypeName(const Type type);
inline std::ostream& operator<<(std::ostream& os, const Result& result) { return os << GetResultName(result); } inline std::ostream& operator<<(std::ostream& os, const Result& result) { return os << GetResultName(result); }
inline std::ostream& operator<<(std::ostream& os, const Type& type) { return os << GetTypeName(type); } inline std::ostream& operator<<(std::ostream& os, const Type& type) { return os << GetTypeName(type); }
} /* namespace cmd */ } // namespace fair::mq::sdk::cmd
} /* namespace sdk */
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_SDK_COMMANDFACTORY */ #endif /* FAIR_MQ_SDK_COMMANDFACTORY */

Some files were not shown because too many files have changed in this diff Show More