mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-18 11:01:45 +00:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1b30f3ac14 | ||
|
35c7959c53 | ||
|
5ea8ffeb34 | ||
|
04ee1db8e5 | ||
|
4a15a38dd4 | ||
|
0f5e1b6815 | ||
|
5e6ad47223 | ||
|
6932f88c84 | ||
|
5e97d85956 | ||
|
fdbf289364 | ||
|
266843cda5 | ||
|
b126ede45a | ||
|
12e6a874db | ||
|
73109fe6d3 | ||
|
3b2d2a0ac8 | ||
|
72a45f78b3 | ||
|
b63f31d0e0 | ||
|
70a583d08d | ||
|
fe9b87e4e2 | ||
|
2ac27905e7 |
@@ -53,6 +53,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)
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
@@ -429,4 +431,10 @@ message(STATUS " ${Cyan}INSTALL PREFIX${CR} ${BGreen}${CMAKE_INSTALL_PREFIX
|
|||||||
message(STATUS " ")
|
message(STATUS " ")
|
||||||
message(STATUS " ${Cyan}RUN STATIC ANALYSIS ${static_ana_summary}")
|
message(STATUS " ${Cyan}RUN STATIC ANALYSIS ${static_ana_summary}")
|
||||||
message(STATUS " ")
|
message(STATUS " ")
|
||||||
|
if(FAIRMQ_DEBUG_MODE)
|
||||||
|
message(STATUS " ${Cyan}DEBUG_MODE${CR} ${BGreen}${FAIRMQ_DEBUG_MODE}${CR} (disable with ${BMagenta}-DFAIRMQ_DEBUG_MODE=OFF${CR})")
|
||||||
|
else()
|
||||||
|
message(STATUS " ${Cyan}DEBUG_MODE${CR} ${BRed}${FAIRMQ_DEBUG_MODE}${CR} (enable with ${BMagenta}-DFAIRMQ_DEBUG_MODE=ON${CR})")
|
||||||
|
endif()
|
||||||
|
message(STATUS " ")
|
||||||
################################################################################
|
################################################################################
|
||||||
|
11
Jenkinsfile
vendored
11
Jenkinsfile
vendored
@@ -8,11 +8,15 @@ def jobMatrix(String prefix, List specs, Closure callback) {
|
|||||||
def nodes = [:]
|
def nodes = [:]
|
||||||
for (spec in specs) {
|
for (spec in specs) {
|
||||||
def label = specToLabel(spec)
|
def label = specToLabel(spec)
|
||||||
|
def node_tag = label
|
||||||
|
if (spec.os =~ /macOS/) {
|
||||||
|
node_tag = spec.os
|
||||||
|
}
|
||||||
def fairsoft = spec.fairsoft
|
def fairsoft = spec.fairsoft
|
||||||
def os = spec.os
|
def os = spec.os
|
||||||
def compiler = spec.compiler
|
def compiler = spec.compiler
|
||||||
nodes["${prefix}/${label}"] = {
|
nodes["${prefix}/${label}"] = {
|
||||||
node(label) {
|
node(node_tag) {
|
||||||
githubNotify(context: "${prefix}/${label}", description: 'Building ...', status: 'PENDING')
|
githubNotify(context: "${prefix}/${label}", description: 'Building ...', status: 'PENDING')
|
||||||
try {
|
try {
|
||||||
deleteDir()
|
deleteDir()
|
||||||
@@ -29,7 +33,7 @@ def jobMatrix(String prefix, List specs, Closure callback) {
|
|||||||
echo "module load compiler/gcc/9.1.0" >> Dart.cfg
|
echo "module load compiler/gcc/9.1.0" >> Dart.cfg
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
if (os =~ /MacOS/) {
|
if (os =~ /[Mm]acOS/) {
|
||||||
sh "echo \"export EXTRA_FLAGS='-DCMAKE_CXX_COMPILER=clang++'\" >> Dart.cfg"
|
sh "echo \"export EXTRA_FLAGS='-DCMAKE_CXX_COMPILER=clang++'\" >> Dart.cfg"
|
||||||
} else {
|
} else {
|
||||||
sh "echo \"export EXTRA_FLAGS='-DCMAKE_CXX_COMPILER=g++'\" >> Dart.cfg"
|
sh "echo \"export EXTRA_FLAGS='-DCMAKE_CXX_COMPILER=g++'\" >> Dart.cfg"
|
||||||
@@ -71,8 +75,7 @@ pipeline{
|
|||||||
script {
|
script {
|
||||||
def build_jobs = jobMatrix('build', [
|
def build_jobs = jobMatrix('build', [
|
||||||
[os: 'Debian8', arch: 'x86_64', compiler: 'gcc9.1.0', fairsoft: 'fairmq_dev'],
|
[os: 'Debian8', arch: 'x86_64', compiler: 'gcc9.1.0', fairsoft: 'fairmq_dev'],
|
||||||
[os: 'MacOS10.13', arch: 'x86_64', compiler: 'AppleLLVM10.0.0', fairsoft: 'fairmq_dev'],
|
[os: 'macOS10.15', arch: 'x86_64', compiler: 'AppleLLVM11.0.3', fairsoft: 'fairmq_dev'],
|
||||||
[os: 'MacOS10.14', arch: 'x86_64', compiler: 'AppleLLVM10.0.0', fairsoft: 'fairmq_dev'],
|
|
||||||
]) { spec, label ->
|
]) { spec, label ->
|
||||||
sh './Dart.sh alfa_ci Dart.cfg'
|
sh './Dart.sh alfa_ci Dart.cfg'
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
|
@@ -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)
|
||||||
|
@@ -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)
|
||||||
|
@@ -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
|
||||||
|
@@ -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
|
||||||
|
@@ -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,6 +367,9 @@ 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>
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
#include <fairmq/PluginManager.h>
|
#include <fairmq/PluginManager.h>
|
||||||
#include <fairmq/ProgOptions.h>
|
#include <fairmq/ProgOptions.h>
|
||||||
#include <FairMQDevice.h>
|
#include <FairMQDevice.h>
|
||||||
#include <FairMQLogger.h>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@@ -7,11 +7,15 @@
|
|||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include "FairMQChannel.h"
|
#include "FairMQChannel.h"
|
||||||
|
|
||||||
#include <fairmq/tools/Strings.h>
|
#include <fairmq/tools/Strings.h>
|
||||||
#include <fairmq/Properties.h>
|
#include <fairmq/Properties.h>
|
||||||
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp> // join/split
|
#include <boost/algorithm/string.hpp> // join/split
|
||||||
|
|
||||||
|
#include <cstddef> // size_t
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
@@ -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,7 +23,6 @@
|
|||||||
#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
|
class FairMQChannel
|
||||||
@@ -68,13 +66,13 @@ 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()
|
||||||
@@ -252,7 +250,7 @@ class FairMQChannel
|
|||||||
/// Sends a message to the socket queue.
|
/// Sends a message to the socket queue.
|
||||||
/// @param msg Constant reference of unique_ptr to a FairMQMessage
|
/// @param msg Constant reference of unique_ptr to a FairMQMessage
|
||||||
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
||||||
/// @return Number of bytes that have been queued. -2 If queueing was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been queued, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int Send(FairMQMessagePtr& msg, int sndTimeoutInMs = -1)
|
int Send(FairMQMessagePtr& msg, int sndTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
CheckSendCompatibility(msg);
|
CheckSendCompatibility(msg);
|
||||||
@@ -262,7 +260,7 @@ class FairMQChannel
|
|||||||
/// Receives a message from the socket queue.
|
/// Receives a message from the socket queue.
|
||||||
/// @param msg Constant reference of unique_ptr to a FairMQMessage
|
/// @param msg Constant reference of unique_ptr to a FairMQMessage
|
||||||
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
||||||
/// @return Number of bytes that have been received. -2 if reading from the queue was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been received, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int Receive(FairMQMessagePtr& msg, int rcvTimeoutInMs = -1)
|
int Receive(FairMQMessagePtr& msg, int rcvTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
CheckReceiveCompatibility(msg);
|
CheckReceiveCompatibility(msg);
|
||||||
@@ -272,7 +270,7 @@ class FairMQChannel
|
|||||||
/// Send a vector of messages
|
/// Send a vector of messages
|
||||||
/// @param msgVec message vector reference
|
/// @param msgVec message vector reference
|
||||||
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
||||||
/// @return Number of bytes that have been queued. -2 If queueing was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been queued, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Send(std::vector<FairMQMessagePtr>& msgVec, int sndTimeoutInMs = -1)
|
int64_t Send(std::vector<FairMQMessagePtr>& msgVec, int sndTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
CheckSendCompatibility(msgVec);
|
CheckSendCompatibility(msgVec);
|
||||||
@@ -282,7 +280,7 @@ class FairMQChannel
|
|||||||
/// Receive a vector of messages
|
/// Receive a vector of messages
|
||||||
/// @param msgVec message vector reference
|
/// @param msgVec message vector reference
|
||||||
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
||||||
/// @return Number of bytes that have been received. -2 if reading from the queue was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been received, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Receive(std::vector<FairMQMessagePtr>& msgVec, int rcvTimeoutInMs = -1)
|
int64_t Receive(std::vector<FairMQMessagePtr>& msgVec, int rcvTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
CheckReceiveCompatibility(msgVec);
|
CheckReceiveCompatibility(msgVec);
|
||||||
@@ -292,7 +290,7 @@ class FairMQChannel
|
|||||||
/// Send FairMQParts
|
/// Send FairMQParts
|
||||||
/// @param parts FairMQParts reference
|
/// @param parts FairMQParts reference
|
||||||
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
/// @param sndTimeoutInMs send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
||||||
/// @return Number of bytes that have been queued. -2 If queueing was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been queued, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Send(FairMQParts& parts, int sndTimeoutInMs = -1)
|
int64_t Send(FairMQParts& parts, int sndTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return Send(parts.fParts, sndTimeoutInMs);
|
return Send(parts.fParts, sndTimeoutInMs);
|
||||||
@@ -301,7 +299,7 @@ class FairMQChannel
|
|||||||
/// Receive FairMQParts
|
/// Receive FairMQParts
|
||||||
/// @param parts FairMQParts reference
|
/// @param parts FairMQParts reference
|
||||||
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
/// @param rcvTimeoutInMs receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
||||||
/// @return Number of bytes that have been received. -2 if reading from the queue was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been received, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Receive(FairMQParts& parts, int rcvTimeoutInMs = -1)
|
int64_t Receive(FairMQParts& parts, int rcvTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return Receive(parts.fParts, rcvTimeoutInMs);
|
return Receive(parts.fParts, rcvTimeoutInMs);
|
||||||
|
@@ -129,7 +129,7 @@ class FairMQDevice
|
|||||||
/// @param chan channel name
|
/// @param chan channel name
|
||||||
/// @param i channel index
|
/// @param i channel index
|
||||||
/// @param sndTimeoutInMs send timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
/// @param sndTimeoutInMs send timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
||||||
/// @return Number of bytes that have been queued. -2 If queueing was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been queued, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int Send(FairMQMessagePtr& msg, const std::string& channel, const int index = 0, int sndTimeoutInMs = -1)
|
int Send(FairMQMessagePtr& msg, const std::string& channel, const int index = 0, int sndTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return GetChannel(channel, index).Send(msg, sndTimeoutInMs);
|
return GetChannel(channel, index).Send(msg, sndTimeoutInMs);
|
||||||
@@ -140,7 +140,7 @@ class FairMQDevice
|
|||||||
/// @param chan channel name
|
/// @param chan channel name
|
||||||
/// @param i channel index
|
/// @param i channel index
|
||||||
/// @param rcvTimeoutInMs receive timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
/// @param rcvTimeoutInMs receive timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
||||||
/// @return Number of bytes that have been received. -2 if reading from the queue was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been received, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int Receive(FairMQMessagePtr& msg, const std::string& channel, const int index = 0, int rcvTimeoutInMs = -1)
|
int Receive(FairMQMessagePtr& msg, const std::string& channel, const int index = 0, int rcvTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return GetChannel(channel, index).Receive(msg, rcvTimeoutInMs);
|
return GetChannel(channel, index).Receive(msg, rcvTimeoutInMs);
|
||||||
@@ -151,7 +151,7 @@ class FairMQDevice
|
|||||||
/// @param chan channel name
|
/// @param chan channel name
|
||||||
/// @param i channel index
|
/// @param i channel index
|
||||||
/// @param sndTimeoutInMs send timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
/// @param sndTimeoutInMs send timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
|
||||||
/// @return Number of bytes that have been queued. -2 If queueing was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been queued, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Send(FairMQParts& parts, const std::string& channel, const int index = 0, int sndTimeoutInMs = -1)
|
int64_t Send(FairMQParts& parts, const std::string& channel, const int index = 0, int sndTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return GetChannel(channel, index).Send(parts.fParts, sndTimeoutInMs);
|
return GetChannel(channel, index).Send(parts.fParts, sndTimeoutInMs);
|
||||||
@@ -162,7 +162,7 @@ class FairMQDevice
|
|||||||
/// @param chan channel name
|
/// @param chan channel name
|
||||||
/// @param i channel index
|
/// @param i channel index
|
||||||
/// @param rcvTimeoutInMs receive timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
/// @param rcvTimeoutInMs receive timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive)
|
||||||
/// @return Number of bytes that have been received. -2 if reading from the queue was not possible or timed out. -1 if there was an error.
|
/// @return Number of bytes that have been received, TransferResult::timeout if timed out, TransferResult::error if there was an error, TransferResult::interrupted if interrupted (e.g. by requested state change)
|
||||||
int64_t Receive(FairMQParts& parts, const std::string& channel, const int index = 0, int rcvTimeoutInMs = -1)
|
int64_t Receive(FairMQParts& parts, const std::string& channel, const int index = 0, int rcvTimeoutInMs = -1)
|
||||||
{
|
{
|
||||||
return GetChannel(channel, index).Receive(parts.fParts, rcvTimeoutInMs);
|
return GetChannel(channel, index).Receive(parts.fParts, rcvTimeoutInMs);
|
||||||
|
@@ -9,14 +9,31 @@
|
|||||||
#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
|
||||||
|
{
|
||||||
|
namespace mq
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class TransferResult : int
|
||||||
|
{
|
||||||
|
error = -1,
|
||||||
|
timeout = -2,
|
||||||
|
interrupted = -3
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mq
|
||||||
|
} // namespace fair
|
||||||
|
|
||||||
class FairMQSocket
|
class FairMQSocket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
#include <FairMQLogger.h>
|
#include <FairMQLogger.h>
|
||||||
#include <fairmq/Tools.h>
|
#include <fairmq/Tools.h>
|
||||||
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
@@ -12,16 +12,19 @@
|
|||||||
* Created on May 14, 2015, 5:01 PM
|
* Created on May 14, 2015, 5:01 PM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fairmq/PropertyOutput.h>
|
|
||||||
#include "JSONParser.h"
|
#include "JSONParser.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQChannel.h"
|
||||||
#include <fairmq/Tools.h>
|
#include <fairmq/PropertyOutput.h>
|
||||||
|
#include <fairmq/tools/CppSTL.h>
|
||||||
|
#include <fairmq/tools/Strings.h>
|
||||||
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
#include <boost/any.hpp>
|
#include <boost/any.hpp>
|
||||||
|
|
||||||
#include <ios>
|
#include <iomanip>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace fair::mq;
|
using namespace fair::mq;
|
||||||
|
@@ -15,15 +15,11 @@
|
|||||||
#ifndef FAIR_MQ_JSONPARSER_H
|
#ifndef FAIR_MQ_JSONPARSER_H
|
||||||
#define FAIR_MQ_JSONPARSER_H
|
#define FAIR_MQ_JSONPARSER_H
|
||||||
|
|
||||||
#include <string>
|
#include <fairmq/Properties.h>
|
||||||
#include <vector>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
#include <boost/property_tree/ptree_fwd.hpp>
|
#include <boost/property_tree/ptree_fwd.hpp>
|
||||||
|
|
||||||
#include "FairMQChannel.h"
|
#include <stdexcept>
|
||||||
#include <fairmq/Properties.h>
|
#include <string>
|
||||||
|
|
||||||
namespace fair
|
namespace fair
|
||||||
{
|
{
|
||||||
|
@@ -18,11 +18,12 @@
|
|||||||
#include <fairmq/FairMQMessage.h>
|
#include <fairmq/FairMQMessage.h>
|
||||||
class FairMQTransportFactory;
|
class FairMQTransportFactory;
|
||||||
|
|
||||||
|
#include <boost/container/container_fwd.hpp>
|
||||||
#include <boost/container/flat_map.hpp>
|
#include <boost/container/flat_map.hpp>
|
||||||
#include <boost/container/pmr/memory_resource.hpp>
|
#include <boost/container/pmr/memory_resource.hpp>
|
||||||
#include <boost/container/pmr/monotonic_buffer_resource.hpp>
|
|
||||||
#include <boost/container/pmr/polymorphic_allocator.hpp>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace fair {
|
namespace fair {
|
||||||
|
@@ -17,13 +17,14 @@
|
|||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/optional/optional_io.hpp>
|
#include <boost/optional/optional_io.hpp>
|
||||||
|
|
||||||
|
#include <condition_variable>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <map>
|
||||||
|
#include <mutex>
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <mutex>
|
#include <vector>
|
||||||
#include <map>
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
namespace fair
|
namespace fair
|
||||||
{
|
{
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <typeindex>
|
#include <typeindex>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
@@ -7,7 +7,8 @@
|
|||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include <fairmq/StateMachine.h>
|
#include <fairmq/StateMachine.h>
|
||||||
#include <fairmq/Tools.h>
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
// Increase maximum number of boost::msm states (default is 10)
|
// Increase maximum number of boost::msm states (default is 10)
|
||||||
// This #define has to be before any msm header includes
|
// This #define has to be before any msm header includes
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
#include <fairmq/States.h>
|
#include <fairmq/States.h>
|
||||||
|
|
||||||
#include <fairlogger/Logger.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@@ -12,9 +12,12 @@
|
|||||||
/// @brief Parser implementation for key-value subopt format
|
/// @brief Parser implementation for key-value subopt format
|
||||||
|
|
||||||
#include <fairmq/SuboptParser.h>
|
#include <fairmq/SuboptParser.h>
|
||||||
|
#include <fairmq/JSONParser.h>
|
||||||
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
#include <cstring>
|
|
||||||
#include <utility> // make_pair
|
#include <utility> // make_pair
|
||||||
|
|
||||||
using boost::property_tree::ptree;
|
using boost::property_tree::ptree;
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#ifndef FAIR_MQ_SUBOPTPARSER_H
|
#ifndef FAIR_MQ_SUBOPTPARSER_H
|
||||||
#define FAIR_MQ_SUBOPTPARSER_H
|
#define FAIR_MQ_SUBOPTPARSER_H
|
||||||
|
|
||||||
#include <fairmq/JSONParser.h>
|
#include <fairmq/Properties.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@@ -1,122 +0,0 @@
|
|||||||
/********************************************************************************
|
|
||||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
|
||||||
* *
|
|
||||||
* This software is distributed under the terms of the *
|
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
|
||||||
* copied verbatim in the file "LICENSE" *
|
|
||||||
********************************************************************************/
|
|
||||||
/**
|
|
||||||
* FairMQMerger.cxx
|
|
||||||
*
|
|
||||||
* @since 2012-12-06
|
|
||||||
* @author D. Klein, A. Rybalchenko
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "FairMQMerger.h"
|
|
||||||
#include "../FairMQLogger.h"
|
|
||||||
#include "../FairMQPoller.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
FairMQMerger::FairMQMerger()
|
|
||||||
: fMultipart(true)
|
|
||||||
, fInChannelName("data-in")
|
|
||||||
, fOutChannelName("data-out")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQMerger::RegisterChannelEndpoints()
|
|
||||||
{
|
|
||||||
RegisterChannelEndpoint(fInChannelName, 1, 10000);
|
|
||||||
RegisterChannelEndpoint(fOutChannelName, 1, 1);
|
|
||||||
|
|
||||||
PrintRegisteredChannels();
|
|
||||||
}
|
|
||||||
|
|
||||||
FairMQMerger::~FairMQMerger()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQMerger::InitTask()
|
|
||||||
{
|
|
||||||
fMultipart = fConfig->GetProperty<bool>("multipart");
|
|
||||||
fInChannelName = fConfig->GetProperty<string>("in-channel");
|
|
||||||
fOutChannelName = fConfig->GetProperty<string>("out-channel");
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQMerger::Run()
|
|
||||||
{
|
|
||||||
int numInputs = fChannels.at(fInChannelName).size();
|
|
||||||
|
|
||||||
vector<FairMQChannel*> chans;
|
|
||||||
|
|
||||||
for (auto& chan : fChannels.at(fInChannelName))
|
|
||||||
{
|
|
||||||
chans.push_back(&chan);
|
|
||||||
}
|
|
||||||
|
|
||||||
FairMQPollerPtr poller(NewPoller(chans));
|
|
||||||
|
|
||||||
if (fMultipart)
|
|
||||||
{
|
|
||||||
while (!NewStatePending())
|
|
||||||
{
|
|
||||||
poller->Poll(100);
|
|
||||||
|
|
||||||
// Loop over the data input channels.
|
|
||||||
for (int i = 0; i < numInputs; ++i)
|
|
||||||
{
|
|
||||||
// Check if the channel has data ready to be received.
|
|
||||||
if (poller->CheckInput(i))
|
|
||||||
{
|
|
||||||
FairMQParts payload;
|
|
||||||
|
|
||||||
if (Receive(payload, fInChannelName, i) >= 0)
|
|
||||||
{
|
|
||||||
if (Send(payload, fOutChannelName) < 0)
|
|
||||||
{
|
|
||||||
LOG(debug) << "Transfer interrupted";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG(debug) << "Transfer interrupted";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (!NewStatePending())
|
|
||||||
{
|
|
||||||
poller->Poll(100);
|
|
||||||
|
|
||||||
// Loop over the data input channels.
|
|
||||||
for (int i = 0; i < numInputs; ++i)
|
|
||||||
{
|
|
||||||
// Check if the channel has data ready to be received.
|
|
||||||
if (poller->CheckInput(i))
|
|
||||||
{
|
|
||||||
FairMQMessagePtr payload(fTransportFactory->CreateMessage());
|
|
||||||
|
|
||||||
if (Receive(payload, fInChannelName, i) >= 0)
|
|
||||||
{
|
|
||||||
if (Send(payload, fOutChannelName) < 0)
|
|
||||||
{
|
|
||||||
LOG(debug) << "Transfer interrupted";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG(debug) << "Transfer interrupted";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -16,23 +16,100 @@
|
|||||||
#define FAIRMQMERGER_H_
|
#define FAIRMQMERGER_H_
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
#include "../FairMQPoller.h"
|
||||||
|
#include "../FairMQLogger.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class FairMQMerger : public FairMQDevice
|
class FairMQMerger : public FairMQDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQMerger();
|
FairMQMerger()
|
||||||
virtual ~FairMQMerger();
|
: fMultipart(true)
|
||||||
|
, fInChannelName("data-in")
|
||||||
|
, fOutChannelName("data-out")
|
||||||
|
{}
|
||||||
|
~FairMQMerger() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool fMultipart;
|
bool fMultipart;
|
||||||
std::string fInChannelName;
|
std::string fInChannelName;
|
||||||
std::string fOutChannelName;
|
std::string fOutChannelName;
|
||||||
|
|
||||||
virtual void RegisterChannelEndpoints() override;
|
void InitTask() override
|
||||||
virtual void Run() override;
|
{
|
||||||
virtual void InitTask() override;
|
fMultipart = fConfig->GetProperty<bool>("multipart");
|
||||||
|
fInChannelName = fConfig->GetProperty<std::string>("in-channel");
|
||||||
|
fOutChannelName = fConfig->GetProperty<std::string>("out-channel");
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterChannelEndpoints() override
|
||||||
|
{
|
||||||
|
RegisterChannelEndpoint(fInChannelName, 1, 10000);
|
||||||
|
RegisterChannelEndpoint(fOutChannelName, 1, 1);
|
||||||
|
|
||||||
|
PrintRegisteredChannels();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Run() override
|
||||||
|
{
|
||||||
|
int numInputs = fChannels.at(fInChannelName).size();
|
||||||
|
|
||||||
|
std::vector<FairMQChannel*> chans;
|
||||||
|
|
||||||
|
for (auto& chan : fChannels.at(fInChannelName)) {
|
||||||
|
chans.push_back(&chan);
|
||||||
|
}
|
||||||
|
|
||||||
|
FairMQPollerPtr poller(NewPoller(chans));
|
||||||
|
|
||||||
|
if (fMultipart) {
|
||||||
|
while (!NewStatePending()) {
|
||||||
|
poller->Poll(100);
|
||||||
|
|
||||||
|
// Loop over the data input channels.
|
||||||
|
for (int i = 0; i < numInputs; ++i) {
|
||||||
|
// Check if the channel has data ready to be received.
|
||||||
|
if (poller->CheckInput(i)) {
|
||||||
|
FairMQParts payload;
|
||||||
|
|
||||||
|
if (Receive(payload, fInChannelName, i) >= 0) {
|
||||||
|
if (Send(payload, fOutChannelName) < 0) {
|
||||||
|
LOG(debug) << "Transfer interrupted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG(debug) << "Transfer interrupted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (!NewStatePending()) {
|
||||||
|
poller->Poll(100);
|
||||||
|
|
||||||
|
// Loop over the data input channels.
|
||||||
|
for (int i = 0; i < numInputs; ++i) {
|
||||||
|
// Check if the channel has data ready to be received.
|
||||||
|
if (poller->CheckInput(i)) {
|
||||||
|
FairMQMessagePtr payload(fTransportFactory->CreateMessage());
|
||||||
|
|
||||||
|
if (Receive(payload, fInChannelName, i) >= 0) {
|
||||||
|
if (Send(payload, fOutChannelName) < 0) {
|
||||||
|
LOG(debug) << "Transfer interrupted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG(debug) << "Transfer interrupted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQMERGER_H_ */
|
#endif /* FAIRMQMERGER_H_ */
|
||||||
|
@@ -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;
|
|
||||||
}
|
|
@@ -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_ */
|
||||||
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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_ */
|
||||||
|
@@ -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);
|
||||||
|
@@ -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;
|
|
||||||
}
|
|
@@ -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_ */
|
||||||
|
@@ -284,7 +284,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>(TransferResult::error);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Socket::SendQueueReader() -> void
|
auto Socket::SendQueueReader() -> void
|
||||||
@@ -431,7 +431,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>(TransferResult::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 +456,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>(TransferResult::error);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Socket::RecvControlQueueReader() -> void
|
auto Socket::RecvControlQueueReader() -> void
|
||||||
|
@@ -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}
|
|
||||||
)
|
)
|
||||||
|
@@ -344,10 +344,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));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@@ -148,12 +148,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});
|
||||||
}
|
}
|
||||||
|
@@ -69,6 +69,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).")
|
||||||
|
@@ -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}
|
||||||
|
@@ -421,13 +421,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.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,7 +464,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:
|
||||||
|
@@ -290,6 +290,7 @@ string Cmds::Serialize(const Format type) const
|
|||||||
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: {
|
||||||
@@ -445,7 +446,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()));
|
||||||
|
@@ -50,7 +50,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 +188,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 +205,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
|
||||||
|
@@ -56,7 +56,7 @@ enum FBCmd:byte {
|
|||||||
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 }
|
||||||
|
@@ -58,12 +58,15 @@ void printControlsHelp()
|
|||||||
|
|
||||||
void handleCommand(const string& command, const string& path, unsigned int timeout, Topology& topo, const string& pKey, const string& pVal)
|
void handleCommand(const string& command, const string& path, unsigned int timeout, Topology& topo, const string& pKey, const string& pVal)
|
||||||
{
|
{
|
||||||
|
std::pair<std::error_code, fair::mq::sdk::TopologyState> changeStateResult;
|
||||||
|
|
||||||
if (command == "c") {
|
if (command == "c") {
|
||||||
cout << "> checking state of the devices" << endl;
|
cout << "> checking state of the devices" << endl;
|
||||||
auto const result = topo.GetCurrentState();
|
auto const result = topo.GetCurrentState();
|
||||||
for (const auto& d : result) {
|
for (const auto& d : result) {
|
||||||
cout << d.taskId << " : " << d.state << endl;
|
cout << d.taskId << " : " << d.state << endl;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
} else if (command == "o") {
|
} else if (command == "o") {
|
||||||
cout << "> dumping config of " << (path == "" ? "all" : path) << endl;
|
cout << "> dumping config of " << (path == "" ? "all" : path) << endl;
|
||||||
// TODO: extend this regex to return all properties, once command size limitation is removed.
|
// TODO: extend this regex to return all properties, once command size limitation is removed.
|
||||||
@@ -73,6 +76,7 @@ void handleCommand(const string& command, const string& path, unsigned int timeo
|
|||||||
cout << d.first << ": " << p.first << " : " << p.second << endl;
|
cout << d.first << ": " << p.first << " : " << p.second << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
} else if (command == "p") {
|
} else if (command == "p") {
|
||||||
if (pKey == "" || pVal == "") {
|
if (pKey == "" || pVal == "") {
|
||||||
cout << "cannot send property with empty key and/or value! given key: '" << pKey << "', value: '" << pVal << "'." << endl;
|
cout << "cannot send property with empty key and/or value! given key: '" << pKey << "', value: '" << pVal << "'." << endl;
|
||||||
@@ -83,42 +87,48 @@ void handleCommand(const string& command, const string& path, unsigned int timeo
|
|||||||
topo.SetProperties(props, path);
|
topo.SetProperties(props, path);
|
||||||
// give dds time to complete request
|
// give dds time to complete request
|
||||||
this_thread::sleep_for(chrono::milliseconds(100));
|
this_thread::sleep_for(chrono::milliseconds(100));
|
||||||
|
return;
|
||||||
} else if (command == "i") {
|
} else if (command == "i") {
|
||||||
cout << "> initiating InitDevice transition --> " << (path == "" ? "all" : path) << endl;
|
cout << "> initiating InitDevice transition --> " << (path == "" ? "all" : path) << endl;
|
||||||
topo.ChangeState(TopologyTransition::InitDevice, path, std::chrono::milliseconds(timeout));
|
changeStateResult = topo.ChangeState(TopologyTransition::InitDevice, path, std::chrono::milliseconds(timeout));
|
||||||
} else if (command == "k") {
|
} else if (command == "k") {
|
||||||
cout << "> initiating CompleteInit transition --> " << (path == "" ? "all" : path) << endl;
|
cout << "> initiating CompleteInit transition --> " << (path == "" ? "all" : path) << endl;
|
||||||
topo.ChangeState(TopologyTransition::CompleteInit, path, std::chrono::milliseconds(timeout));
|
changeStateResult = topo.ChangeState(TopologyTransition::CompleteInit, path, std::chrono::milliseconds(timeout));
|
||||||
} else if (command == "b") {
|
} else if (command == "b") {
|
||||||
cout << "> initiating Bind transition --> " << (path == "" ? "all" : path) << endl;
|
cout << "> initiating Bind transition --> " << (path == "" ? "all" : path) << endl;
|
||||||
topo.ChangeState(TopologyTransition::Bind, path, std::chrono::milliseconds(timeout));
|
changeStateResult = topo.ChangeState(TopologyTransition::Bind, path, std::chrono::milliseconds(timeout));
|
||||||
} else if (command == "x") {
|
} else if (command == "x") {
|
||||||
cout << "> initiating Connect transition --> " << (path == "" ? "all" : path) << endl;
|
cout << "> initiating Connect transition --> " << (path == "" ? "all" : path) << endl;
|
||||||
topo.ChangeState(TopologyTransition::Connect, path, std::chrono::milliseconds(timeout));
|
changeStateResult = topo.ChangeState(TopologyTransition::Connect, path, std::chrono::milliseconds(timeout));
|
||||||
} else if (command == "j") {
|
} else if (command == "j") {
|
||||||
cout << "> initiating InitTask transition --> " << (path == "" ? "all" : path) << endl;
|
cout << "> initiating InitTask transition --> " << (path == "" ? "all" : path) << endl;
|
||||||
topo.ChangeState(TopologyTransition::InitTask, path, std::chrono::milliseconds(timeout));
|
changeStateResult = topo.ChangeState(TopologyTransition::InitTask, path, std::chrono::milliseconds(timeout));
|
||||||
} else if (command == "r") {
|
} else if (command == "r") {
|
||||||
cout << "> initiating Run transition --> " << (path == "" ? "all" : path) << endl;
|
cout << "> initiating Run transition --> " << (path == "" ? "all" : path) << endl;
|
||||||
topo.ChangeState(TopologyTransition::Run, path, std::chrono::milliseconds(timeout));
|
changeStateResult = topo.ChangeState(TopologyTransition::Run, path, std::chrono::milliseconds(timeout));
|
||||||
} else if (command == "s") {
|
} else if (command == "s") {
|
||||||
cout << "> initiating Stop transition --> " << (path == "" ? "all" : path) << endl;
|
cout << "> initiating Stop transition --> " << (path == "" ? "all" : path) << endl;
|
||||||
topo.ChangeState(TopologyTransition::Stop, path, std::chrono::milliseconds(timeout));
|
changeStateResult = topo.ChangeState(TopologyTransition::Stop, path, std::chrono::milliseconds(timeout));
|
||||||
} else if (command == "t") {
|
} else if (command == "t") {
|
||||||
cout << "> initiating ResetTask transition --> " << (path == "" ? "all" : path) << endl;
|
cout << "> initiating ResetTask transition --> " << (path == "" ? "all" : path) << endl;
|
||||||
topo.ChangeState(TopologyTransition::ResetTask, path, std::chrono::milliseconds(timeout));
|
changeStateResult = topo.ChangeState(TopologyTransition::ResetTask, path, std::chrono::milliseconds(timeout));
|
||||||
} else if (command == "d") {
|
} else if (command == "d") {
|
||||||
cout << "> initiating ResetDevice transition --> " << (path == "" ? "all" : path) << endl;
|
cout << "> initiating ResetDevice transition --> " << (path == "" ? "all" : path) << endl;
|
||||||
topo.ChangeState(TopologyTransition::ResetDevice, path, std::chrono::milliseconds(timeout));
|
changeStateResult = topo.ChangeState(TopologyTransition::ResetDevice, path, std::chrono::milliseconds(timeout));
|
||||||
} else if (command == "q") {
|
} else if (command == "q") {
|
||||||
cout << "> initiating End transition --> " << (path == "" ? "all" : path) << endl;
|
cout << "> initiating End transition --> " << (path == "" ? "all" : path) << endl;
|
||||||
topo.ChangeState(TopologyTransition::End, path, std::chrono::milliseconds(timeout));
|
changeStateResult = topo.ChangeState(TopologyTransition::End, path, std::chrono::milliseconds(timeout));
|
||||||
} else if (command == "h") {
|
} else if (command == "h") {
|
||||||
cout << "> help" << endl;
|
cout << "> help" << endl;
|
||||||
printControlsHelp();
|
printControlsHelp();
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
cout << "\033[01;32mInvalid input: [" << command << "]\033[0m" << endl;
|
cout << "\033[01;32mInvalid input: [" << command << "]\033[0m" << endl;
|
||||||
printControlsHelp();
|
printControlsHelp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (changeStateResult.first != std::error_code()) {
|
||||||
|
cout << "ERROR: ChangeState failed for '" << path << "': " << changeStateResult.first.message() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@@ -12,13 +12,18 @@
|
|||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <functional> // std::equal_to
|
||||||
|
|
||||||
#include <boost/interprocess/managed_shared_memory.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
#include <boost/interprocess/allocators/allocator.hpp>
|
#include <boost/interprocess/allocators/allocator.hpp>
|
||||||
#include <boost/interprocess/containers/map.hpp>
|
#include <boost/interprocess/containers/map.hpp>
|
||||||
#include <boost/interprocess/containers/string.hpp>
|
#include <boost/interprocess/containers/string.hpp>
|
||||||
#include <boost/interprocess/containers/vector.hpp>
|
#include <boost/interprocess/containers/vector.hpp>
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/interprocess/indexes/null_index.hpp>
|
||||||
|
#include <boost/interprocess/managed_shared_memory.hpp>
|
||||||
|
#include <boost/interprocess/mem_algo/simple_seq_fit.hpp>
|
||||||
|
#include <boost/unordered_map.hpp>
|
||||||
|
#include <boost/variant.hpp>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -30,6 +35,17 @@ namespace mq
|
|||||||
namespace shmem
|
namespace shmem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct SharedMemoryError : std::runtime_error { using std::runtime_error::runtime_error; };
|
||||||
|
|
||||||
|
using SimpleSeqFitSegment = boost::interprocess::basic_managed_shared_memory<char,
|
||||||
|
boost::interprocess::simple_seq_fit<boost::interprocess::mutex_family>,
|
||||||
|
boost::interprocess::null_index>;
|
||||||
|
// boost::interprocess::iset_index>;
|
||||||
|
using RBTreeBestFitSegment = boost::interprocess::basic_managed_shared_memory<char,
|
||||||
|
boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,
|
||||||
|
boost::interprocess::null_index>;
|
||||||
|
// boost::interprocess::iset_index>;
|
||||||
|
|
||||||
using SegmentManager = boost::interprocess::managed_shared_memory::segment_manager;
|
using SegmentManager = boost::interprocess::managed_shared_memory::segment_manager;
|
||||||
using VoidAlloc = boost::interprocess::allocator<void, SegmentManager>;
|
using VoidAlloc = boost::interprocess::allocator<void, SegmentManager>;
|
||||||
using CharAlloc = boost::interprocess::allocator<char, SegmentManager>;
|
using CharAlloc = boost::interprocess::allocator<char, SegmentManager>;
|
||||||
@@ -37,6 +53,12 @@ using Str = boost::interprocess::basic_string<char, std::char_traits<
|
|||||||
using StrAlloc = boost::interprocess::allocator<Str, SegmentManager>;
|
using StrAlloc = boost::interprocess::allocator<Str, SegmentManager>;
|
||||||
using StrVector = boost::interprocess::vector<Str, StrAlloc>;
|
using StrVector = boost::interprocess::vector<Str, StrAlloc>;
|
||||||
|
|
||||||
|
enum class AllocationAlgorithm : int
|
||||||
|
{
|
||||||
|
rbtree_best_fit,
|
||||||
|
simple_seq_fit
|
||||||
|
};
|
||||||
|
|
||||||
struct RegionInfo
|
struct RegionInfo
|
||||||
{
|
{
|
||||||
RegionInfo(const VoidAlloc& alloc)
|
RegionInfo(const VoidAlloc& alloc)
|
||||||
@@ -59,8 +81,22 @@ struct RegionInfo
|
|||||||
bool fDestroyed;
|
bool fDestroyed;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Uint64RegionInfoPairAlloc = boost::interprocess::allocator<std::pair<const uint64_t, RegionInfo>, SegmentManager>;
|
using Uint16RegionInfoPairAlloc = boost::interprocess::allocator<std::pair<const uint16_t, RegionInfo>, SegmentManager>;
|
||||||
using Uint64RegionInfoMap = boost::interprocess::map<uint64_t, RegionInfo, std::less<uint64_t>, Uint64RegionInfoPairAlloc>;
|
using Uint16RegionInfoMap = boost::interprocess::map<uint16_t, RegionInfo, std::less<uint16_t>, Uint16RegionInfoPairAlloc>;
|
||||||
|
using Uint16RegionInfoHashMap = boost::unordered_map<uint16_t, RegionInfo, boost::hash<uint16_t>, std::equal_to<uint16_t>, Uint16RegionInfoPairAlloc>;
|
||||||
|
|
||||||
|
struct SegmentInfo
|
||||||
|
{
|
||||||
|
SegmentInfo(AllocationAlgorithm aa)
|
||||||
|
: fAllocationAlgorithm(aa)
|
||||||
|
{}
|
||||||
|
|
||||||
|
AllocationAlgorithm fAllocationAlgorithm;
|
||||||
|
};
|
||||||
|
|
||||||
|
using Uint16SegmentInfoPairAlloc = boost::interprocess::allocator<std::pair<const uint16_t, SegmentInfo>, SegmentManager>;
|
||||||
|
using Uint16SegmentInfoHashMap = boost::unordered_map<uint16_t, SegmentInfo, boost::hash<uint16_t>, std::equal_to<uint16_t>, Uint16SegmentInfoPairAlloc>;
|
||||||
|
// using Uint16SegmentInfoMap = boost::interprocess::map<uint16_t, SegmentInfo, std::less<uint16_t>, Uint16SegmentInfoPairAlloc>;
|
||||||
|
|
||||||
struct DeviceCounter
|
struct DeviceCounter
|
||||||
{
|
{
|
||||||
@@ -73,21 +109,65 @@ struct DeviceCounter
|
|||||||
|
|
||||||
struct RegionCounter
|
struct RegionCounter
|
||||||
{
|
{
|
||||||
RegionCounter(uint64_t c)
|
RegionCounter(uint16_t c)
|
||||||
: fCount(c)
|
: fCount(c)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::atomic<uint64_t> fCount;
|
std::atomic<uint16_t> fCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MetaHeader
|
struct MetaHeader
|
||||||
{
|
{
|
||||||
size_t fSize;
|
size_t fSize;
|
||||||
size_t fRegionId;
|
|
||||||
size_t fHint;
|
size_t fHint;
|
||||||
|
uint16_t fRegionId;
|
||||||
|
uint16_t fSegmentId;
|
||||||
boost::interprocess::managed_shared_memory::handle_t fHandle;
|
boost::interprocess::managed_shared_memory::handle_t fHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
struct MsgCounter
|
||||||
|
{
|
||||||
|
MsgCounter()
|
||||||
|
: fCount(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
MsgCounter(unsigned int c)
|
||||||
|
: fCount(c)
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::atomic<unsigned int> fCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
using Uint16MsgCounterPairAlloc = boost::interprocess::allocator<std::pair<const uint16_t, MsgCounter>, SegmentManager>;
|
||||||
|
using Uint16MsgCounterHashMap = boost::unordered_map<uint16_t, MsgCounter, boost::hash<uint16_t>, std::equal_to<uint16_t>, Uint16MsgCounterPairAlloc>;
|
||||||
|
|
||||||
|
struct MsgDebug
|
||||||
|
{
|
||||||
|
MsgDebug()
|
||||||
|
: fPid(0)
|
||||||
|
, fSize(0)
|
||||||
|
, fCreationTime(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
MsgDebug(pid_t pid, size_t size, const uint64_t creationTime)
|
||||||
|
: fPid(pid)
|
||||||
|
, fSize(size)
|
||||||
|
, fCreationTime(creationTime)
|
||||||
|
{}
|
||||||
|
|
||||||
|
pid_t fPid;
|
||||||
|
size_t fSize;
|
||||||
|
uint64_t fCreationTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
using SizetMsgDebugPairAlloc = boost::interprocess::allocator<std::pair<const size_t, MsgDebug>, SegmentManager>;
|
||||||
|
// using SizetMsgDebugHashMap = boost::unordered_map<size_t, MsgDebug, boost::hash<size_t>, std::equal_to<size_t>, SizetMsgDebugPairAlloc>;
|
||||||
|
using SizetMsgDebugMap = boost::interprocess::map<size_t, MsgDebug, std::less<size_t>, SizetMsgDebugPairAlloc>;
|
||||||
|
using Uint16MsgDebugMapPairAlloc = boost::interprocess::allocator<std::pair<const uint16_t, SizetMsgDebugMap>, SegmentManager>;
|
||||||
|
using Uint16MsgDebugMapHashMap = boost::unordered_map<uint16_t, SizetMsgDebugMap, boost::hash<uint16_t>, std::equal_to<uint16_t>, Uint16MsgDebugMapPairAlloc>;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct RegionBlock
|
struct RegionBlock
|
||||||
{
|
{
|
||||||
RegionBlock()
|
RegionBlock()
|
||||||
@@ -120,6 +200,101 @@ inline std::string buildShmIdFromSessionIdAndUserId(const std::string& sessionId
|
|||||||
return shmId;
|
return shmId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SegmentSize : public boost::static_visitor<size_t>
|
||||||
|
{
|
||||||
|
template<typename S>
|
||||||
|
size_t operator()(S& s) const { return s.get_size(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SegmentAddress : public boost::static_visitor<void*>
|
||||||
|
{
|
||||||
|
template<typename S>
|
||||||
|
void* operator()(S& s) const { return s.get_address(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SegmentMemoryZeroer : public boost::static_visitor<>
|
||||||
|
{
|
||||||
|
template<typename S>
|
||||||
|
void operator()(S& s) const { s.zero_free_memory(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SegmentFreeMemory : public boost::static_visitor<size_t>
|
||||||
|
{
|
||||||
|
template<typename S>
|
||||||
|
size_t operator()(S& s) const { return s.get_free_memory(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SegmentHandleFromAddress : public boost::static_visitor<boost::interprocess::managed_shared_memory::handle_t>
|
||||||
|
{
|
||||||
|
SegmentHandleFromAddress(const void* _ptr) : ptr(_ptr) {}
|
||||||
|
|
||||||
|
template<typename S>
|
||||||
|
boost::interprocess::managed_shared_memory::handle_t operator()(S& s) const { return s.get_handle_from_address(ptr); }
|
||||||
|
|
||||||
|
const void* ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SegmentAddressFromHandle : public boost::static_visitor<void*>
|
||||||
|
{
|
||||||
|
SegmentAddressFromHandle(const boost::interprocess::managed_shared_memory::handle_t _handle) : handle(_handle) {}
|
||||||
|
|
||||||
|
template<typename S>
|
||||||
|
void* operator()(S& s) const { return s.get_address_from_handle(handle); }
|
||||||
|
|
||||||
|
const boost::interprocess::managed_shared_memory::handle_t handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SegmentAllocate : public boost::static_visitor<void*>
|
||||||
|
{
|
||||||
|
SegmentAllocate(const size_t _size) : size(_size) {}
|
||||||
|
|
||||||
|
template<typename S>
|
||||||
|
void* operator()(S& s) const { return s.allocate(size); }
|
||||||
|
|
||||||
|
const size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SegmentAllocateAligned : public boost::static_visitor<void*>
|
||||||
|
{
|
||||||
|
SegmentAllocateAligned(const size_t _size, const size_t _alignment) : size(_size), alignment(_alignment) {}
|
||||||
|
|
||||||
|
template<typename S>
|
||||||
|
void* operator()(S& s) const { return s.allocate_aligned(size, alignment); }
|
||||||
|
|
||||||
|
const size_t size;
|
||||||
|
const size_t alignment;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SegmentBufferShrink : public boost::static_visitor<char*>
|
||||||
|
{
|
||||||
|
SegmentBufferShrink(const size_t _old_size, const size_t _new_size, char* _local_ptr)
|
||||||
|
: old_size(_old_size)
|
||||||
|
, new_size(_new_size)
|
||||||
|
, local_ptr(_local_ptr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<typename S>
|
||||||
|
char* operator()(S& s) const
|
||||||
|
{
|
||||||
|
boost::interprocess::managed_shared_memory::size_type shrunk_size = new_size;
|
||||||
|
return s.template allocation_command<char>(boost::interprocess::shrink_in_place, old_size + 128, shrunk_size, local_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t old_size;
|
||||||
|
const size_t new_size;
|
||||||
|
mutable char* local_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SegmentDeallocate : public boost::static_visitor<>
|
||||||
|
{
|
||||||
|
SegmentDeallocate(void* _ptr) : ptr(_ptr) {}
|
||||||
|
|
||||||
|
template<typename S>
|
||||||
|
void operator()(S& s) const { return s.deallocate(ptr); }
|
||||||
|
|
||||||
|
void* ptr;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace shmem
|
} // namespace shmem
|
||||||
} // namespace mq
|
} // namespace mq
|
||||||
} // namespace fair
|
} // namespace fair
|
||||||
|
@@ -27,18 +27,18 @@
|
|||||||
|
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/interprocess/indexes/null_index.hpp>
|
|
||||||
#include <boost/interprocess/ipc/message_queue.hpp>
|
#include <boost/interprocess/ipc/message_queue.hpp>
|
||||||
#include <boost/interprocess/managed_shared_memory.hpp>
|
#include <boost/interprocess/managed_shared_memory.hpp>
|
||||||
#include <boost/interprocess/sync/named_condition.hpp>
|
#include <boost/interprocess/sync/named_condition.hpp>
|
||||||
#include <boost/interprocess/sync/named_mutex.hpp>
|
#include <boost/interprocess/sync/named_mutex.hpp>
|
||||||
#include <boost/interprocess/mem_algo/simple_seq_fit.hpp>
|
|
||||||
#include <boost/process.hpp>
|
#include <boost/process.hpp>
|
||||||
|
#include <boost/variant.hpp>
|
||||||
|
|
||||||
#include <cstdlib> // getenv
|
#include <cstdlib> // getenv
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@@ -55,45 +55,43 @@ namespace mq
|
|||||||
namespace shmem
|
namespace shmem
|
||||||
{
|
{
|
||||||
|
|
||||||
struct SharedMemoryError : std::runtime_error { using std::runtime_error::runtime_error; };
|
|
||||||
|
|
||||||
using SimpleSeqFitSegment = boost::interprocess::basic_managed_shared_memory<char,
|
|
||||||
boost::interprocess::simple_seq_fit<boost::interprocess::mutex_family>,
|
|
||||||
boost::interprocess::iset_index>;
|
|
||||||
using RBTreeBestFitSegment = boost::interprocess::basic_managed_shared_memory<char,
|
|
||||||
boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,
|
|
||||||
boost::interprocess::iset_index>;
|
|
||||||
|
|
||||||
class Manager
|
class Manager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Manager(std::string shmId, std::string deviceId, size_t size, const ProgOptions* config)
|
Manager(std::string shmId, std::string deviceId, size_t size, const ProgOptions* config)
|
||||||
: fShmId(std::move(shmId))
|
: fShmId(std::move(shmId))
|
||||||
|
, fSegmentId(config ? config->GetProperty<uint16_t>("shm-segment-id", 0) : 0)
|
||||||
, fDeviceId(std::move(deviceId))
|
, fDeviceId(std::move(deviceId))
|
||||||
, fSegment(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_main").c_str(), size)
|
, fSegments()
|
||||||
, fManagementSegment(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_mng").c_str(), 655360)
|
, fManagementSegment(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_mng").c_str(), 6553600)
|
||||||
, fShmVoidAlloc(fManagementSegment.get_segment_manager())
|
, fShmVoidAlloc(fManagementSegment.get_segment_manager())
|
||||||
, fShmMtx(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_mtx").c_str())
|
, fShmMtx(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_mtx").c_str())
|
||||||
, fRegionEventsCV(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_cv").c_str())
|
, fRegionEventsCV(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_cv").c_str())
|
||||||
, fRegionEventsSubscriptionActive(false)
|
, fRegionEventsSubscriptionActive(false)
|
||||||
, fDeviceCounter(nullptr)
|
, fDeviceCounter(nullptr)
|
||||||
, fRegionInfos(nullptr)
|
, fShmSegments(nullptr)
|
||||||
|
, fShmRegions(nullptr)
|
||||||
, fInterrupted(false)
|
, fInterrupted(false)
|
||||||
, fMsgCounter(0)
|
, fMsgCounter(0)
|
||||||
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
, fMsgDebug(nullptr)
|
||||||
|
, fShmMsgCounters(nullptr)
|
||||||
|
#endif
|
||||||
, fHeartbeatThread()
|
, fHeartbeatThread()
|
||||||
, fSendHeartbeats(true)
|
, fSendHeartbeats(true)
|
||||||
, fThrowOnBadAlloc(true)
|
, fThrowOnBadAlloc(config ? config->GetProperty<bool>("shm-throw-bad-alloc", true) : true)
|
||||||
{
|
{
|
||||||
using namespace boost::interprocess;
|
using namespace boost::interprocess;
|
||||||
|
|
||||||
bool mlockSegment = false;
|
bool mlockSegment = false;
|
||||||
bool zeroSegment = false;
|
bool zeroSegment = false;
|
||||||
bool autolaunchMonitor = false;
|
bool autolaunchMonitor = false;
|
||||||
|
std::string allocationAlgorithm("rbtree_best_fit");
|
||||||
if (config) {
|
if (config) {
|
||||||
mlockSegment = config->GetProperty<bool>("shm-mlock-segment", mlockSegment);
|
mlockSegment = config->GetProperty<bool>("shm-mlock-segment", mlockSegment);
|
||||||
zeroSegment = config->GetProperty<bool>("shm-zero-segment", zeroSegment);
|
zeroSegment = config->GetProperty<bool>("shm-zero-segment", zeroSegment);
|
||||||
autolaunchMonitor = config->GetProperty<bool>("shm-monitor", autolaunchMonitor);
|
autolaunchMonitor = config->GetProperty<bool>("shm-monitor", autolaunchMonitor);
|
||||||
fThrowOnBadAlloc = config->GetProperty<bool>("shm-throw-bad-alloc", fThrowOnBadAlloc);
|
allocationAlgorithm = config->GetProperty<std::string>("shm-allocation", allocationAlgorithm);
|
||||||
} else {
|
} else {
|
||||||
LOG(debug) << "ProgOptions not available! Using defaults.";
|
LOG(debug) << "ProgOptions not available! Using defaults.";
|
||||||
}
|
}
|
||||||
@@ -102,25 +100,68 @@ class Manager
|
|||||||
StartMonitor(fShmId);
|
StartMonitor(fShmId);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(debug) << "created/opened shared memory segment '" << "fmq_" << fShmId << "_main" << "' of " << fSegment.get_size() << " bytes. Available are " << fSegment.get_free_memory() << " bytes.";
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(fShmMtx);
|
||||||
|
|
||||||
|
fShmSegments = fManagementSegment.find_or_construct<Uint16SegmentInfoHashMap>(unique_instance)(fShmVoidAlloc);
|
||||||
|
|
||||||
|
try {
|
||||||
|
auto it = fShmSegments->find(fSegmentId);
|
||||||
|
if (it == fShmSegments->end()) {
|
||||||
|
// no segment with given id exists, creating
|
||||||
|
if (allocationAlgorithm == "rbtree_best_fit") {
|
||||||
|
fSegments.emplace(fSegmentId, RBTreeBestFitSegment(create_only, std::string("fmq_" + fShmId + "_m_" + std::to_string(fSegmentId)).c_str(), size));
|
||||||
|
fShmSegments->emplace(fSegmentId, AllocationAlgorithm::rbtree_best_fit);
|
||||||
|
} else if (allocationAlgorithm == "simple_seq_fit") {
|
||||||
|
fSegments.emplace(fSegmentId, SimpleSeqFitSegment(create_only, std::string("fmq_" + fShmId + "_m_" + std::to_string(fSegmentId)).c_str(), size));
|
||||||
|
fShmSegments->emplace(fSegmentId, AllocationAlgorithm::simple_seq_fit);
|
||||||
|
}
|
||||||
|
ss << "Created ";
|
||||||
|
} else {
|
||||||
|
// found segment with the given id, opening
|
||||||
|
if (it->second.fAllocationAlgorithm == AllocationAlgorithm::rbtree_best_fit) {
|
||||||
|
fSegments.emplace(fSegmentId, RBTreeBestFitSegment(open_only, std::string("fmq_" + fShmId + "_m_" + std::to_string(fSegmentId)).c_str()));
|
||||||
|
if (allocationAlgorithm != "rbtree_best_fit") {
|
||||||
|
LOG(warn) << "Allocation algorithm of the opened segment is rbtree_best_fit, but requested is " << allocationAlgorithm << ". Ignoring requested setting.";
|
||||||
|
allocationAlgorithm = "rbtree_best_fit";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fSegments.emplace(fSegmentId, SimpleSeqFitSegment(open_only, std::string("fmq_" + fShmId + "_m_" + std::to_string(fSegmentId)).c_str()));
|
||||||
|
if (allocationAlgorithm != "simple_seq_fit") {
|
||||||
|
LOG(warn) << "Allocation algorithm of the opened segment is simple_seq_fit, but requested is " << allocationAlgorithm << ". Ignoring requested setting.";
|
||||||
|
allocationAlgorithm = "simple_seq_fit";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ss << "Opened ";
|
||||||
|
}
|
||||||
|
ss << "shared memory segment '" << "fmq_" << fShmId << "_m_" << fSegmentId << "'."
|
||||||
|
<< " Size: " << boost::apply_visitor(SegmentSize{}, fSegments.at(fSegmentId)) << " bytes."
|
||||||
|
<< " Available: " << boost::apply_visitor(SegmentFreeMemory{}, fSegments.at(fSegmentId)) << " bytes."
|
||||||
|
<< " Allocation algorithm: " << allocationAlgorithm;
|
||||||
|
LOG(debug) << ss.str();
|
||||||
|
} catch(interprocess_exception& bie) {
|
||||||
|
LOG(error) << "something went wrong: " << bie.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mlockSegment) {
|
if (mlockSegment) {
|
||||||
LOG(debug) << "Locking the managed segment memory pages...";
|
LOG(debug) << "Locking the managed segment memory pages...";
|
||||||
if (mlock(fSegment.get_address(), fSegment.get_size()) == -1) {
|
if (mlock(boost::apply_visitor(SegmentAddress{}, fSegments.at(fSegmentId)), boost::apply_visitor(SegmentSize{}, fSegments.at(fSegmentId))) == -1) {
|
||||||
LOG(error) << "Could not lock the managed segment memory. Code: " << errno << ", reason: " << strerror(errno);
|
LOG(error) << "Could not lock the managed segment memory. Code: " << errno << ", reason: " << strerror(errno);
|
||||||
}
|
}
|
||||||
LOG(debug) << "Successfully locked the managed segment memory pages.";
|
LOG(debug) << "Successfully locked the managed segment memory pages.";
|
||||||
}
|
}
|
||||||
if (zeroSegment) {
|
if (zeroSegment) {
|
||||||
LOG(debug) << "Zeroing the managed segment free memory...";
|
LOG(debug) << "Zeroing the managed segment free memory...";
|
||||||
fSegment.zero_free_memory();
|
boost::apply_visitor(SegmentMemoryZeroer{}, fSegments.at(fSegmentId));
|
||||||
LOG(debug) << "Successfully zeroed the managed segment free memory.";
|
LOG(debug) << "Successfully zeroed the managed segment free memory.";
|
||||||
}
|
}
|
||||||
|
|
||||||
fRegionInfos = fManagementSegment.find_or_construct<Uint64RegionInfoMap>(unique_instance)(fShmVoidAlloc);
|
{
|
||||||
// store info about the managed segment as region with id 0
|
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(fShmMtx);
|
||||||
fRegionInfos->emplace(0, RegionInfo("", 0, 0, fShmVoidAlloc));
|
|
||||||
|
|
||||||
boost::interprocess::scoped_lock<named_mutex> lock(fShmMtx);
|
fShmRegions = fManagementSegment.find_or_construct<Uint16RegionInfoHashMap>(unique_instance)(fShmVoidAlloc);
|
||||||
|
|
||||||
fDeviceCounter = fManagementSegment.find<DeviceCounter>(unique_instance).first;
|
fDeviceCounter = fManagementSegment.find<DeviceCounter>(unique_instance).first;
|
||||||
|
|
||||||
@@ -134,6 +175,12 @@ class Manager
|
|||||||
LOG(debug) << "initialized device counter with: " << fDeviceCounter->fCount;
|
LOG(debug) << "initialized device counter with: " << fDeviceCounter->fCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
fMsgDebug = fManagementSegment.find_or_construct<Uint16MsgDebugMapHashMap>(unique_instance)(fShmVoidAlloc);
|
||||||
|
fShmMsgCounters = fManagementSegment.find_or_construct<Uint16MsgCounterHashMap>(unique_instance)(fShmVoidAlloc);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
fHeartbeatThread = std::thread(&Manager::SendHeartbeats, this);
|
fHeartbeatThread = std::thread(&Manager::SendHeartbeats, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,9 +189,6 @@ class Manager
|
|||||||
Manager(const Manager&) = delete;
|
Manager(const Manager&) = delete;
|
||||||
Manager operator=(const Manager&) = delete;
|
Manager operator=(const Manager&) = delete;
|
||||||
|
|
||||||
RBTreeBestFitSegment& Segment() { return fSegment; }
|
|
||||||
boost::interprocess::managed_shared_memory& ManagementSegment() { return fManagementSegment; }
|
|
||||||
|
|
||||||
static void StartMonitor(const std::string& id)
|
static void StartMonitor(const std::string& id)
|
||||||
{
|
{
|
||||||
using namespace boost::interprocess;
|
using namespace boost::interprocess;
|
||||||
@@ -196,7 +240,7 @@ class Manager
|
|||||||
}
|
}
|
||||||
bool Interrupted() { return fInterrupted.load(); }
|
bool Interrupted() { return fInterrupted.load(); }
|
||||||
|
|
||||||
std::pair<boost::interprocess::mapped_region*, uint64_t> CreateRegion(const size_t size,
|
std::pair<boost::interprocess::mapped_region*, uint16_t> CreateRegion(const size_t size,
|
||||||
const int64_t userFlags,
|
const int64_t userFlags,
|
||||||
RegionCallback callback,
|
RegionCallback callback,
|
||||||
RegionBulkCallback bulkCallback,
|
RegionBulkCallback bulkCallback,
|
||||||
@@ -205,10 +249,10 @@ class Manager
|
|||||||
{
|
{
|
||||||
using namespace boost::interprocess;
|
using namespace boost::interprocess;
|
||||||
try {
|
try {
|
||||||
std::pair<mapped_region*, uint64_t> result;
|
std::pair<mapped_region*, uint16_t> result;
|
||||||
|
|
||||||
{
|
{
|
||||||
uint64_t id = 0;
|
uint16_t id = 0;
|
||||||
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(fShmMtx);
|
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(fShmMtx);
|
||||||
|
|
||||||
RegionCounter* rc = fManagementSegment.find<RegionCounter>(unique_instance).first;
|
RegionCounter* rc = fManagementSegment.find<RegionCounter>(unique_instance).first;
|
||||||
@@ -232,7 +276,7 @@ class Manager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create region info
|
// create region info
|
||||||
fRegionInfos->emplace(id, RegionInfo(path.c_str(), flags, userFlags, fShmVoidAlloc));
|
fShmRegions->emplace(id, RegionInfo(path.c_str(), flags, userFlags, fShmVoidAlloc));
|
||||||
|
|
||||||
auto r = fRegions.emplace(id, tools::make_unique<Region>(fShmId, id, size, false, callback, bulkCallback, path, flags));
|
auto r = fRegions.emplace(id, tools::make_unique<Region>(fShmId, id, size, false, callback, bulkCallback, path, flags));
|
||||||
// LOG(debug) << "Created region with id '" << id << "', path: '" << path << "', flags: '" << flags << "'";
|
// LOG(debug) << "Created region with id '" << id << "', path: '" << path << "', flags: '" << flags << "'";
|
||||||
@@ -252,13 +296,13 @@ class Manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Region* GetRegion(const uint64_t id)
|
Region* GetRegion(const uint16_t id)
|
||||||
{
|
{
|
||||||
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(fShmMtx);
|
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(fShmMtx);
|
||||||
return GetRegionUnsafe(id);
|
return GetRegionUnsafe(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Region* GetRegionUnsafe(const uint64_t id)
|
Region* GetRegionUnsafe(const uint16_t id)
|
||||||
{
|
{
|
||||||
// remote region could actually be a local one if a message originates from this device (has been sent out and returned)
|
// remote region could actually be a local one if a message originates from this device (has been sent out and returned)
|
||||||
auto it = fRegions.find(id);
|
auto it = fRegions.find(id);
|
||||||
@@ -267,7 +311,7 @@ class Manager
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// get region info
|
// get region info
|
||||||
RegionInfo regionInfo = fRegionInfos->at(id);
|
RegionInfo regionInfo = fShmRegions->at(id);
|
||||||
std::string path = regionInfo.fPath.c_str();
|
std::string path = regionInfo.fPath.c_str();
|
||||||
int flags = regionInfo.fFlags;
|
int flags = regionInfo.fFlags;
|
||||||
// LOG(debug) << "Located remote region with id '" << id << "', path: '" << path << "', flags: '" << flags << "'";
|
// LOG(debug) << "Located remote region with id '" << id << "', path: '" << path << "', flags: '" << flags << "'";
|
||||||
@@ -285,12 +329,12 @@ class Manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveRegion(const uint64_t id)
|
void RemoveRegion(const uint16_t id)
|
||||||
{
|
{
|
||||||
fRegions.erase(id);
|
fRegions.erase(id);
|
||||||
{
|
{
|
||||||
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(fShmMtx);
|
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(fShmMtx);
|
||||||
fRegionInfos->at(id).fDestroyed = true;
|
fShmRegions->at(id).fDestroyed = true;
|
||||||
}
|
}
|
||||||
fRegionEventsCV.notify_all();
|
fRegionEventsCV.notify_all();
|
||||||
}
|
}
|
||||||
@@ -305,12 +349,12 @@ class Manager
|
|||||||
{
|
{
|
||||||
std::vector<fair::mq::RegionInfo> result;
|
std::vector<fair::mq::RegionInfo> result;
|
||||||
|
|
||||||
for (const auto& e : *fRegionInfos) {
|
for (const auto& e : *fShmRegions) {
|
||||||
fair::mq::RegionInfo info;
|
fair::mq::RegionInfo info;
|
||||||
|
info.managed = false;
|
||||||
info.id = e.first;
|
info.id = e.first;
|
||||||
info.flags = e.second.fUserFlags;
|
info.flags = e.second.fUserFlags;
|
||||||
info.event = e.second.fDestroyed ? RegionEvent::destroyed : RegionEvent::created;
|
info.event = e.second.fDestroyed ? RegionEvent::destroyed : RegionEvent::created;
|
||||||
if (info.id != 0) {
|
|
||||||
if (!e.second.fDestroyed) {
|
if (!e.second.fDestroyed) {
|
||||||
auto region = GetRegionUnsafe(info.id);
|
auto region = GetRegionUnsafe(info.id);
|
||||||
info.ptr = region->fRegion.get_address();
|
info.ptr = region->fRegion.get_address();
|
||||||
@@ -320,17 +364,17 @@ class Manager
|
|||||||
info.size = 0;
|
info.size = 0;
|
||||||
}
|
}
|
||||||
result.push_back(info);
|
result.push_back(info);
|
||||||
} else {
|
|
||||||
if (!e.second.fDestroyed) {
|
|
||||||
info.ptr = fSegment.get_address();
|
|
||||||
info.size = fSegment.get_size();
|
|
||||||
} else {
|
|
||||||
info.ptr = nullptr;
|
|
||||||
info.size = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& e : *fShmSegments) {
|
||||||
|
fair::mq::RegionInfo info;
|
||||||
|
info.managed = true;
|
||||||
|
info.id = e.first;
|
||||||
|
info.event = RegionEvent::created;
|
||||||
|
info.ptr = boost::apply_visitor(SegmentAddress{}, fSegments.at(e.first));
|
||||||
|
info.size = boost::apply_visitor(SegmentSize{}, fSegments.at(e.first));
|
||||||
result.push_back(info);
|
result.push_back(info);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -394,6 +438,13 @@ class Manager
|
|||||||
void IncrementMsgCounter() { fMsgCounter.fetch_add(1, std::memory_order_relaxed); }
|
void IncrementMsgCounter() { fMsgCounter.fetch_add(1, std::memory_order_relaxed); }
|
||||||
void DecrementMsgCounter() { fMsgCounter.fetch_sub(1, std::memory_order_relaxed); }
|
void DecrementMsgCounter() { fMsgCounter.fetch_sub(1, std::memory_order_relaxed); }
|
||||||
|
|
||||||
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
void IncrementShmMsgCounter(uint16_t segmentId) { ++((*fShmMsgCounters)[segmentId].fCount); }
|
||||||
|
void DecrementShmMsgCounter(uint16_t segmentId) { --((*fShmMsgCounters)[segmentId].fCount); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
boost::interprocess::named_mutex& GetMtx() { return fShmMtx; }
|
||||||
|
|
||||||
void SendHeartbeats()
|
void SendHeartbeats()
|
||||||
{
|
{
|
||||||
std::string controlQueueName("fmq_" + fShmId + "_cq");
|
std::string controlQueueName("fmq_" + fShmId + "_cq");
|
||||||
@@ -416,6 +467,108 @@ class Manager
|
|||||||
|
|
||||||
bool ThrowingOnBadAlloc() const { return fThrowOnBadAlloc; }
|
bool ThrowingOnBadAlloc() const { return fThrowOnBadAlloc; }
|
||||||
|
|
||||||
|
void GetSegment(uint16_t id)
|
||||||
|
{
|
||||||
|
auto it = fSegments.find(id);
|
||||||
|
if (it == fSegments.end()) {
|
||||||
|
try {
|
||||||
|
// get region info
|
||||||
|
SegmentInfo segmentInfo = fShmSegments->at(id);
|
||||||
|
LOG(info) << "LOCATED SEGMENT WITH ID '" << id << "'";
|
||||||
|
|
||||||
|
using namespace boost::interprocess;
|
||||||
|
|
||||||
|
if (segmentInfo.fAllocationAlgorithm == AllocationAlgorithm::rbtree_best_fit) {
|
||||||
|
fSegments.emplace(id, RBTreeBestFitSegment(open_only, std::string("fmq_" + fShmId + "_m_" + std::to_string(id)).c_str()));
|
||||||
|
} else {
|
||||||
|
fSegments.emplace(id, SimpleSeqFitSegment(open_only, std::string("fmq_" + fShmId + "_m_" + std::to_string(id)).c_str()));
|
||||||
|
}
|
||||||
|
} catch (std::out_of_range& oor) {
|
||||||
|
LOG(error) << "Could not get segment with id '" << id << "': " << oor.what();
|
||||||
|
} catch (boost::interprocess::interprocess_exception& bie) {
|
||||||
|
LOG(error) << "Could not get segment with id '" << id << "': " << bie.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::interprocess::managed_shared_memory::handle_t GetHandleFromAddress(const void* ptr, uint16_t segmentId) const
|
||||||
|
{
|
||||||
|
return boost::apply_visitor(SegmentHandleFromAddress{ptr}, fSegments.at(segmentId));
|
||||||
|
}
|
||||||
|
void* GetAddressFromHandle(const boost::interprocess::managed_shared_memory::handle_t handle, uint16_t segmentId) const
|
||||||
|
{
|
||||||
|
return boost::apply_visitor(SegmentAddressFromHandle{handle}, fSegments.at(segmentId));
|
||||||
|
}
|
||||||
|
|
||||||
|
char* Allocate(const size_t size, size_t alignment = 0)
|
||||||
|
{
|
||||||
|
char* ptr = nullptr;
|
||||||
|
// tools::RateLimiter rateLimiter(20);
|
||||||
|
|
||||||
|
while (ptr == nullptr) {
|
||||||
|
try {
|
||||||
|
// boost::interprocess::managed_shared_memory::size_type actualSize = size;
|
||||||
|
// char* hint = 0; // unused for boost::interprocess::allocate_new
|
||||||
|
// ptr = fSegments.at(fSegmentId).allocation_command<char>(boost::interprocess::allocate_new, size, actualSize, hint);
|
||||||
|
size_t segmentSize = boost::apply_visitor(SegmentSize{}, fSegments.at(fSegmentId));
|
||||||
|
if (size > segmentSize) {
|
||||||
|
throw MessageBadAlloc(tools::ToString("Requested message size (", size, ") exceeds segment size (", segmentSize, ")"));
|
||||||
|
}
|
||||||
|
if (alignment == 0) {
|
||||||
|
ptr = reinterpret_cast<char*>(boost::apply_visitor(SegmentAllocate{size}, fSegments.at(fSegmentId)));
|
||||||
|
} else {
|
||||||
|
ptr = reinterpret_cast<char*>(boost::apply_visitor(SegmentAllocateAligned{size, alignment}, fSegments.at(fSegmentId)));
|
||||||
|
}
|
||||||
|
} catch (boost::interprocess::bad_alloc& ba) {
|
||||||
|
// LOG(warn) << "Shared memory full...";
|
||||||
|
if (ThrowingOnBadAlloc()) {
|
||||||
|
throw MessageBadAlloc(tools::ToString("shmem: could not create a message of size ", size, ", alignment: ", (alignment != 0) ? std::to_string(alignment) : "default", ", free memory: ", boost::apply_visitor(SegmentFreeMemory{}, fSegments.at(fSegmentId))));
|
||||||
|
}
|
||||||
|
// rateLimiter.maybe_sleep();
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
|
if (Interrupted()) {
|
||||||
|
return ptr;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(fShmMtx);
|
||||||
|
IncrementShmMsgCounter(fSegmentId);
|
||||||
|
if (fMsgDebug->count(fSegmentId) == 0) {
|
||||||
|
(*fMsgDebug).emplace(fSegmentId, fShmVoidAlloc);
|
||||||
|
}
|
||||||
|
(*fMsgDebug).at(fSegmentId).emplace(
|
||||||
|
static_cast<size_t>(GetHandleFromAddress(ptr, fSegmentId)),
|
||||||
|
MsgDebug(getpid(), size, std::chrono::system_clock::now().time_since_epoch().count())
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Deallocate(boost::interprocess::managed_shared_memory::handle_t handle, uint16_t segmentId)
|
||||||
|
{
|
||||||
|
boost::apply_visitor(SegmentDeallocate{GetAddressFromHandle(handle, segmentId)}, fSegments.at(segmentId));
|
||||||
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(fShmMtx);
|
||||||
|
DecrementShmMsgCounter(segmentId);
|
||||||
|
try {
|
||||||
|
(*fMsgDebug).at(segmentId).erase(handle);
|
||||||
|
} catch(const std::out_of_range& oor) {
|
||||||
|
LOG(debug) << "could not locate debug container for " << segmentId << ": " << oor.what();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
char* ShrinkInPlace(size_t oldSize, size_t newSize, char* localPtr, uint16_t segmentId)
|
||||||
|
{
|
||||||
|
return boost::apply_visitor(SegmentBufferShrink{oldSize, newSize, localPtr}, fSegments.at(segmentId));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t GetSegmentId() const { return fSegmentId; }
|
||||||
|
|
||||||
~Manager()
|
~Manager()
|
||||||
{
|
{
|
||||||
using namespace boost::interprocess;
|
using namespace boost::interprocess;
|
||||||
@@ -454,9 +607,9 @@ class Manager
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string fShmId;
|
std::string fShmId;
|
||||||
|
uint16_t fSegmentId;
|
||||||
std::string fDeviceId;
|
std::string fDeviceId;
|
||||||
// boost::interprocess::managed_shared_memory fSegment;
|
std::unordered_map<uint16_t, boost::variant<RBTreeBestFitSegment, SimpleSeqFitSegment>> fSegments;
|
||||||
RBTreeBestFitSegment fSegment;
|
|
||||||
boost::interprocess::managed_shared_memory fManagementSegment;
|
boost::interprocess::managed_shared_memory fManagementSegment;
|
||||||
VoidAlloc fShmVoidAlloc;
|
VoidAlloc fShmVoidAlloc;
|
||||||
boost::interprocess::named_mutex fShmMtx;
|
boost::interprocess::named_mutex fShmMtx;
|
||||||
@@ -465,14 +618,19 @@ class Manager
|
|||||||
std::thread fRegionEventThread;
|
std::thread fRegionEventThread;
|
||||||
bool fRegionEventsSubscriptionActive;
|
bool fRegionEventsSubscriptionActive;
|
||||||
std::function<void(fair::mq::RegionInfo)> fRegionEventCallback;
|
std::function<void(fair::mq::RegionInfo)> fRegionEventCallback;
|
||||||
std::unordered_map<uint64_t, RegionEvent> fObservedRegionEvents;
|
std::unordered_map<uint16_t, RegionEvent> fObservedRegionEvents;
|
||||||
|
|
||||||
DeviceCounter* fDeviceCounter;
|
DeviceCounter* fDeviceCounter;
|
||||||
Uint64RegionInfoMap* fRegionInfos;
|
Uint16SegmentInfoHashMap* fShmSegments;
|
||||||
std::unordered_map<uint64_t, std::unique_ptr<Region>> fRegions;
|
Uint16RegionInfoHashMap* fShmRegions;
|
||||||
|
std::unordered_map<uint16_t, std::unique_ptr<Region>> fRegions;
|
||||||
|
|
||||||
std::atomic<bool> fInterrupted;
|
std::atomic<bool> fInterrupted;
|
||||||
std::atomic<int32_t> fMsgCounter; // TODO: find a better lifetime solution instead of the counter
|
std::atomic<int32_t> fMsgCounter; // TODO: find a better lifetime solution instead of the counter
|
||||||
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
Uint16MsgDebugMapHashMap* fMsgDebug;
|
||||||
|
Uint16MsgCounterHashMap* fShmMsgCounters;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::thread fHeartbeatThread;
|
std::thread fHeartbeatThread;
|
||||||
bool fSendHeartbeats;
|
bool fSendHeartbeats;
|
||||||
|
@@ -22,6 +22,9 @@
|
|||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
|
#include <sys/types.h> // getpid
|
||||||
|
#include <unistd.h> // pid_t
|
||||||
|
|
||||||
namespace fair
|
namespace fair
|
||||||
{
|
{
|
||||||
namespace mq
|
namespace mq
|
||||||
@@ -40,7 +43,7 @@ class Message final : public fair::mq::Message
|
|||||||
: fair::mq::Message(factory)
|
: fair::mq::Message(factory)
|
||||||
, fManager(manager)
|
, fManager(manager)
|
||||||
, fQueued(false)
|
, fQueued(false)
|
||||||
, fMeta{0, 0, 0, -1}
|
, fMeta{0, 0, 0, fManager.GetSegmentId(), -1}
|
||||||
, fRegionPtr(nullptr)
|
, fRegionPtr(nullptr)
|
||||||
, fLocalPtr(nullptr)
|
, fLocalPtr(nullptr)
|
||||||
{
|
{
|
||||||
@@ -51,7 +54,7 @@ class Message final : public fair::mq::Message
|
|||||||
: fair::mq::Message(factory)
|
: fair::mq::Message(factory)
|
||||||
, fManager(manager)
|
, fManager(manager)
|
||||||
, fQueued(false)
|
, fQueued(false)
|
||||||
, fMeta{0, 0, 0, -1}
|
, fMeta{0, 0, 0, fManager.GetSegmentId(), -1}
|
||||||
, fRegionPtr(nullptr)
|
, fRegionPtr(nullptr)
|
||||||
, fLocalPtr(nullptr)
|
, fLocalPtr(nullptr)
|
||||||
{
|
{
|
||||||
@@ -62,7 +65,7 @@ class Message final : public fair::mq::Message
|
|||||||
: fair::mq::Message(factory)
|
: fair::mq::Message(factory)
|
||||||
, fManager(manager)
|
, fManager(manager)
|
||||||
, fQueued(false)
|
, fQueued(false)
|
||||||
, fMeta{0, 0, 0, -1}
|
, fMeta{0, 0, 0, fManager.GetSegmentId(), -1}
|
||||||
, fRegionPtr(nullptr)
|
, fRegionPtr(nullptr)
|
||||||
, fLocalPtr(nullptr)
|
, fLocalPtr(nullptr)
|
||||||
{
|
{
|
||||||
@@ -74,7 +77,7 @@ class Message final : public fair::mq::Message
|
|||||||
: fair::mq::Message(factory)
|
: fair::mq::Message(factory)
|
||||||
, fManager(manager)
|
, fManager(manager)
|
||||||
, fQueued(false)
|
, fQueued(false)
|
||||||
, fMeta{0, 0, 0, -1}
|
, fMeta{0, 0, 0, fManager.GetSegmentId(), -1}
|
||||||
, fRegionPtr(nullptr)
|
, fRegionPtr(nullptr)
|
||||||
, fLocalPtr(nullptr)
|
, fLocalPtr(nullptr)
|
||||||
{
|
{
|
||||||
@@ -86,7 +89,7 @@ class Message final : public fair::mq::Message
|
|||||||
: fair::mq::Message(factory)
|
: fair::mq::Message(factory)
|
||||||
, fManager(manager)
|
, fManager(manager)
|
||||||
, fQueued(false)
|
, fQueued(false)
|
||||||
, fMeta{0, 0, 0, -1}
|
, fMeta{0, 0, 0, fManager.GetSegmentId(), -1}
|
||||||
, fRegionPtr(nullptr)
|
, fRegionPtr(nullptr)
|
||||||
, fLocalPtr(nullptr)
|
, fLocalPtr(nullptr)
|
||||||
{
|
{
|
||||||
@@ -105,7 +108,7 @@ class Message final : public fair::mq::Message
|
|||||||
: fair::mq::Message(factory)
|
: fair::mq::Message(factory)
|
||||||
, fManager(manager)
|
, fManager(manager)
|
||||||
, fQueued(false)
|
, fQueued(false)
|
||||||
, fMeta{size, static_cast<UnmanagedRegion*>(region.get())->fRegionId, reinterpret_cast<size_t>(hint), -1}
|
, fMeta{size, reinterpret_cast<size_t>(hint), static_cast<UnmanagedRegion*>(region.get())->fRegionId, fManager.GetSegmentId(), -1}
|
||||||
, fRegionPtr(nullptr)
|
, fRegionPtr(nullptr)
|
||||||
, fLocalPtr(static_cast<char*>(data))
|
, fLocalPtr(static_cast<char*>(data))
|
||||||
{
|
{
|
||||||
@@ -166,7 +169,8 @@ class Message final : public fair::mq::Message
|
|||||||
if (!fLocalPtr) {
|
if (!fLocalPtr) {
|
||||||
if (fMeta.fRegionId == 0) {
|
if (fMeta.fRegionId == 0) {
|
||||||
if (fMeta.fSize > 0) {
|
if (fMeta.fSize > 0) {
|
||||||
fLocalPtr = reinterpret_cast<char*>(fManager.Segment().get_address_from_handle(fMeta.fHandle));
|
fManager.GetSegment(fMeta.fSegmentId);
|
||||||
|
fLocalPtr = reinterpret_cast<char*>(fManager.GetAddressFromHandle(fMeta.fHandle, fMeta.fSegmentId));
|
||||||
} else {
|
} else {
|
||||||
fLocalPtr = nullptr;
|
fLocalPtr = nullptr;
|
||||||
}
|
}
|
||||||
@@ -186,15 +190,14 @@ class Message final : public fair::mq::Message
|
|||||||
|
|
||||||
size_t GetSize() const override { return fMeta.fSize; }
|
size_t GetSize() const override { return fMeta.fSize; }
|
||||||
|
|
||||||
bool SetUsedSize(const size_t size) override
|
bool SetUsedSize(const size_t newSize) override
|
||||||
{
|
{
|
||||||
if (size == fMeta.fSize) {
|
if (newSize == fMeta.fSize) {
|
||||||
return true;
|
return true;
|
||||||
} else if (size <= fMeta.fSize) {
|
} else if (newSize <= fMeta.fSize) {
|
||||||
try {
|
try {
|
||||||
boost::interprocess::managed_shared_memory::size_type shrunkSize = size;
|
fLocalPtr = fManager.ShrinkInPlace(fMeta.fSize, newSize, fLocalPtr, fMeta.fSegmentId);
|
||||||
fLocalPtr = fManager.Segment().allocation_command<char>(boost::interprocess::shrink_in_place, fMeta.fSize + 128, shrunkSize, fLocalPtr);
|
fMeta.fSize = newSize;
|
||||||
fMeta.fSize = size;
|
|
||||||
return true;
|
return true;
|
||||||
} catch (boost::interprocess::interprocess_exception& e) {
|
} catch (boost::interprocess::interprocess_exception& e) {
|
||||||
LOG(info) << "could not set used size: " << e.what();
|
LOG(info) << "could not set used size: " << e.what();
|
||||||
@@ -242,49 +245,22 @@ class Message final : public fair::mq::Message
|
|||||||
mutable Region* fRegionPtr;
|
mutable Region* fRegionPtr;
|
||||||
mutable char* fLocalPtr;
|
mutable char* fLocalPtr;
|
||||||
|
|
||||||
bool InitializeChunk(const size_t size, size_t alignment = 0)
|
char* InitializeChunk(const size_t size, size_t alignment = 0)
|
||||||
{
|
{
|
||||||
// tools::RateLimiter rateLimiter(20);
|
fLocalPtr = fManager.Allocate(size, alignment);
|
||||||
|
if (fLocalPtr) {
|
||||||
while (fMeta.fHandle < 0) {
|
fMeta.fHandle = fManager.GetHandleFromAddress(fLocalPtr, fMeta.fSegmentId);
|
||||||
try {
|
|
||||||
// boost::interprocess::managed_shared_memory::size_type actualSize = size;
|
|
||||||
// char* hint = 0; // unused for boost::interprocess::allocate_new
|
|
||||||
// fLocalPtr = fManager.Segment().allocation_command<char>(boost::interprocess::allocate_new, size, actualSize, hint);
|
|
||||||
size_t segmentSize = fManager.Segment().get_size();
|
|
||||||
if (size > segmentSize) {
|
|
||||||
throw MessageBadAlloc(tools::ToString("Requested message size (", size, ") exceeds segment size (", segmentSize, ")"));
|
|
||||||
}
|
|
||||||
if (alignment == 0) {
|
|
||||||
fLocalPtr = reinterpret_cast<char*>(fManager.Segment().allocate(size));
|
|
||||||
} else {
|
|
||||||
fLocalPtr = reinterpret_cast<char*>(fManager.Segment().allocate_aligned(size, alignment));
|
|
||||||
}
|
|
||||||
} catch (boost::interprocess::bad_alloc& ba) {
|
|
||||||
// LOG(warn) << "Shared memory full...";
|
|
||||||
if (fManager.ThrowingOnBadAlloc()) {
|
|
||||||
throw MessageBadAlloc(tools::ToString("shmem: could not create a message of size ", size, ", alignment: ", (alignment != 0) ? std::to_string(alignment) : "default", ", free memory: ", fManager.Segment().get_free_memory()));
|
|
||||||
}
|
|
||||||
// rateLimiter.maybe_sleep();
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
|
||||||
if (fManager.Interrupted()) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fMeta.fHandle = fManager.Segment().get_handle_from_address(fLocalPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
fMeta.fSize = size;
|
fMeta.fSize = size;
|
||||||
return true;
|
}
|
||||||
|
return fLocalPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseMessage()
|
void CloseMessage()
|
||||||
{
|
{
|
||||||
if (fMeta.fHandle >= 0 && !fQueued) {
|
if (fMeta.fHandle >= 0 && !fQueued) {
|
||||||
if (fMeta.fRegionId == 0) {
|
if (fMeta.fRegionId == 0) {
|
||||||
fManager.Segment().deallocate(fManager.Segment().get_address_from_handle(fMeta.fHandle));
|
fManager.GetSegment(fMeta.fSegmentId);
|
||||||
|
fManager.Deallocate(fMeta.fHandle, fMeta.fSegmentId);
|
||||||
fMeta.fHandle = -1;
|
fMeta.fHandle = -1;
|
||||||
} else {
|
} else {
|
||||||
if (!fRegionPtr) {
|
if (!fRegionPtr) {
|
||||||
@@ -298,6 +274,8 @@ class Message final : public fair::mq::Message
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fLocalPtr = nullptr;
|
||||||
|
fMeta.fSize = 0;
|
||||||
|
|
||||||
fManager.DecrementMsgCounter();
|
fManager.DecrementMsgCounter();
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
@@ -63,7 +64,7 @@ Monitor::Monitor(const string& shmId, bool selfDestruct, bool interactive, bool
|
|||||||
, fTimeoutInMS(timeoutInMS)
|
, fTimeoutInMS(timeoutInMS)
|
||||||
, fIntervalInMS(intervalInMS)
|
, fIntervalInMS(intervalInMS)
|
||||||
, fShmId(shmId)
|
, fShmId(shmId)
|
||||||
, fSegmentName("fmq_" + fShmId + "_main")
|
, fSegmentName("fmq_" + fShmId + "_m_0")
|
||||||
, fManagementSegmentName("fmq_" + fShmId + "_mng")
|
, fManagementSegmentName("fmq_" + fShmId + "_mng")
|
||||||
, fControlQueueName("fmq_" + fShmId + "_cq")
|
, fControlQueueName("fmq_" + fShmId + "_cq")
|
||||||
, fTerminating(false)
|
, fTerminating(false)
|
||||||
@@ -189,8 +190,6 @@ void Monitor::Interactive()
|
|||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
PrintHelp();
|
PrintHelp();
|
||||||
cout << endl;
|
|
||||||
PrintHeader();
|
|
||||||
|
|
||||||
while (!fTerminating) {
|
while (!fTerminating) {
|
||||||
if (poll(cinfd, 1, fIntervalInMS)) {
|
if (poll(cinfd, 1, fIntervalInMS)) {
|
||||||
@@ -205,10 +204,6 @@ void Monitor::Interactive()
|
|||||||
cout << "\n[q] --> quitting." << endl;
|
cout << "\n[q] --> quitting." << endl;
|
||||||
fTerminating = true;
|
fTerminating = true;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
|
||||||
cout << "\n[p] --> active queues:" << endl;
|
|
||||||
PrintQueues();
|
|
||||||
break;
|
|
||||||
case 'x':
|
case 'x':
|
||||||
cout << "\n[x] --> closing shared memory:" << endl;
|
cout << "\n[x] --> closing shared memory:" << endl;
|
||||||
if (!fViewOnly) {
|
if (!fViewOnly) {
|
||||||
@@ -225,6 +220,9 @@ void Monitor::Interactive()
|
|||||||
case '\n':
|
case '\n':
|
||||||
cout << "\n[\\n] --> invalid input." << endl;
|
cout << "\n[\\n] --> invalid input." << endl;
|
||||||
break;
|
break;
|
||||||
|
case 'b':
|
||||||
|
PrintDebugInfo(ShmId{fShmId});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
cout << "\n[" << c << "] --> invalid input." << endl;
|
cout << "\n[" << c << "] --> invalid input." << endl;
|
||||||
break;
|
break;
|
||||||
@@ -233,8 +231,6 @@ void Monitor::Interactive()
|
|||||||
if (fTerminating) {
|
if (fTerminating) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintHeader();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fTerminating) {
|
if (fTerminating) {
|
||||||
@@ -251,45 +247,43 @@ void Monitor::Interactive()
|
|||||||
|
|
||||||
void Monitor::CheckSegment()
|
void Monitor::CheckSegment()
|
||||||
{
|
{
|
||||||
char c = '#';
|
using namespace boost::interprocess;
|
||||||
|
|
||||||
if (fInteractive) {
|
|
||||||
static uint64_t counter = 0;
|
|
||||||
int mod = counter++ % 5;
|
|
||||||
switch (mod) {
|
|
||||||
case 0:
|
|
||||||
c = '-';
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
c = '\\';
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
c = '|';
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
c = '-';
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
c = '/';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bipc::managed_shared_memory segment(bipc::open_only, fSegmentName.c_str());
|
managed_shared_memory managementSegment(open_only, fManagementSegmentName.c_str());
|
||||||
bipc::managed_shared_memory managementSegment(bipc::open_only, fManagementSegmentName.c_str());
|
VoidAlloc allocInstance(managementSegment.get_segment_manager());
|
||||||
|
|
||||||
|
Uint16SegmentInfoHashMap* segmentInfos = managementSegment.find<Uint16SegmentInfoHashMap>(unique_instance).first;
|
||||||
|
std::unordered_map<uint16_t, boost::variant<RBTreeBestFitSegment, SimpleSeqFitSegment>> segments;
|
||||||
|
|
||||||
|
if (!segmentInfos) {
|
||||||
|
cout << "Found management segment, but cannot locate segment info, something went wrong..." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& s : *segmentInfos) {
|
||||||
|
if (s.second.fAllocationAlgorithm == AllocationAlgorithm::rbtree_best_fit) {
|
||||||
|
segments.emplace(s.first, RBTreeBestFitSegment(open_only, std::string("fmq_" + fShmId + "_m_" + to_string(s.first)).c_str()));
|
||||||
|
} else {
|
||||||
|
segments.emplace(s.first, SimpleSeqFitSegment(open_only, std::string("fmq_" + fShmId + "_m_" + to_string(s.first)).c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fSeenOnce = true;
|
fSeenOnce = true;
|
||||||
|
|
||||||
unsigned int numDevices = 0;
|
unsigned int numDevices = 0;
|
||||||
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
Uint16MsgCounterHashMap* msgCounters = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (fInteractive || fViewOnly) {
|
if (fInteractive || fViewOnly) {
|
||||||
DeviceCounter* dc = managementSegment.find<DeviceCounter>(bipc::unique_instance).first;
|
DeviceCounter* dc = managementSegment.find<DeviceCounter>(unique_instance).first;
|
||||||
if (dc) {
|
if (dc) {
|
||||||
numDevices = dc->fCount;
|
numDevices = dc->fCount;
|
||||||
}
|
}
|
||||||
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
msgCounters = managementSegment.find_or_construct<Uint16MsgCounterHashMap>(unique_instance)(allocInstance);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
auto now = chrono::high_resolution_clock::now();
|
auto now = chrono::high_resolution_clock::now();
|
||||||
@@ -305,35 +299,37 @@ void Monitor::CheckSegment()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fInteractive) {
|
if (fInteractive || fViewOnly) {
|
||||||
cout << "| "
|
stringstream ss;
|
||||||
<< setw(18) << fSegmentName << " | "
|
size_t mfree = managementSegment.get_free_memory();
|
||||||
<< setw(10) << segment.get_size() << " | "
|
size_t mtotal = managementSegment.get_size();
|
||||||
<< setw(10) << segment.get_free_memory() << " | "
|
size_t mused = mtotal - mfree;
|
||||||
<< setw(8) << numDevices << " | "
|
|
||||||
<< setw(10) << (fViewOnly ? "view only" : to_string(duration)) << " |"
|
ss << "shm id: " << fShmId
|
||||||
<< c << flush;
|
<< ", devices: " << numDevices << ", segments:\n";
|
||||||
} else if (fViewOnly) {
|
for (const auto& s : segments) {
|
||||||
size_t free = segment.get_free_memory();
|
size_t free = boost::apply_visitor(SegmentFreeMemory{}, s.second);
|
||||||
size_t total = segment.get_size();
|
size_t total = boost::apply_visitor(SegmentSize{}, s.second);
|
||||||
size_t used = total - free;
|
size_t used = total - free;
|
||||||
LOGV(info, user1) << "[" << fSegmentName
|
ss << " [" << s.first
|
||||||
<< "] devices: " << numDevices
|
<< "]: total: " << total
|
||||||
<< ", total: " << total
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
<< ", msgs: " << (*msgCounters)[s.first].fCount
|
||||||
|
#else
|
||||||
|
<< ", msgs: NODEBUG"
|
||||||
|
#endif
|
||||||
<< ", free: " << free
|
<< ", free: " << free
|
||||||
<< ", used: " << used;
|
<< ", used: " << used
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
|
ss << " [m]: "
|
||||||
|
<< "total: " << mtotal
|
||||||
|
<< ", free: " << mfree
|
||||||
|
<< ", used: " << mused;
|
||||||
|
LOGV(info, user1) << ss.str();
|
||||||
}
|
}
|
||||||
} catch (bie&) {
|
} catch (bie&) {
|
||||||
fHeartbeatTriggered = false;
|
fHeartbeatTriggered = false;
|
||||||
if (fInteractive) {
|
|
||||||
cout << "| "
|
|
||||||
<< setw(18) << "-" << " | "
|
|
||||||
<< setw(10) << "-" << " | "
|
|
||||||
<< setw(10) << "-" << " | "
|
|
||||||
<< setw(8) << "-" << " | "
|
|
||||||
<< setw(10) << "-" << " |"
|
|
||||||
<< c << flush;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto now = chrono::high_resolution_clock::now();
|
auto now = chrono::high_resolution_clock::now();
|
||||||
unsigned int duration = chrono::duration_cast<chrono::milliseconds>(now - fLastHeartbeat).count();
|
unsigned int duration = chrono::duration_cast<chrono::milliseconds>(now - fLastHeartbeat).count();
|
||||||
@@ -356,172 +352,214 @@ void Monitor::CheckSegment()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::PrintQueues()
|
void Monitor::PrintDebugInfo(const ShmId& shmId __attribute__((unused)))
|
||||||
{
|
{
|
||||||
cout << '\n';
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
string managementSegmentName("fmq_" + shmId.shmId + "_mng");
|
||||||
try {
|
try {
|
||||||
bipc::managed_shared_memory segment(bipc::open_only, fSegmentName.c_str());
|
bipc::managed_shared_memory managementSegment(bipc::open_only, managementSegmentName.c_str());
|
||||||
StrVector* queues = segment.find<StrVector>(string("fmq_" + fShmId + "_qs").c_str()).first;
|
boost::interprocess::named_mutex mtx(boost::interprocess::open_only, string("fmq_" + shmId.shmId + "_mtx").c_str());
|
||||||
if (queues) {
|
boost::interprocess::scoped_lock<bipc::named_mutex> lock(mtx);
|
||||||
cout << "found " << queues->size() << " queue(s):" << endl;
|
|
||||||
|
|
||||||
for (const auto& queue : *queues) {
|
Uint16MsgDebugMapHashMap* debug = managementSegment.find<Uint16MsgDebugMapHashMap>(bipc::unique_instance).first;
|
||||||
string name(queue.c_str());
|
|
||||||
cout << '\t' << name << " : ";
|
size_t numMessages = 0;
|
||||||
atomic<int>* queueSize = segment.find<atomic<int>>(name.c_str()).first;
|
|
||||||
if (queueSize) {
|
for (const auto& e : *debug) {
|
||||||
cout << *queueSize << " messages" << endl;
|
numMessages += e.second.size();
|
||||||
} else {
|
}
|
||||||
cout << "\tqueue does not have a queue size entry." << endl;
|
cout << endl << "found " << numMessages << " messages." << endl;
|
||||||
|
|
||||||
|
for (const auto& s : *debug) {
|
||||||
|
for (const auto& e : s.second) {
|
||||||
|
using time_point = chrono::system_clock::time_point;
|
||||||
|
time_point tmpt{chrono::duration_cast<time_point::duration>(chrono::nanoseconds(e.second.fCreationTime))};
|
||||||
|
time_t t = chrono::system_clock::to_time_t(tmpt);
|
||||||
|
uint64_t ms = e.second.fCreationTime % 1000000;
|
||||||
|
auto tm = localtime(&t);
|
||||||
|
cout << "segment: " << setw(3) << setfill(' ') << s.first
|
||||||
|
<< ", offset: " << setw(12) << setfill(' ') << e.first
|
||||||
|
<< ", size: " << setw(10) << setfill(' ') << e.second.fSize
|
||||||
|
<< ", creator PID: " << e.second.fPid << setfill('0')
|
||||||
|
<< ", at: " << setw(2) << tm->tm_hour << ":" << setw(2) << tm->tm_min << ":" << setw(2) << tm->tm_sec << "." << setw(6) << ms << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
cout << setfill(' ');
|
||||||
cout << "\tno queues found" << endl;
|
|
||||||
}
|
|
||||||
} catch (bie&) {
|
} catch (bie&) {
|
||||||
cout << "\tno queues found" << endl;
|
cout << "no segments found" << endl;
|
||||||
} catch (out_of_range&) {
|
|
||||||
cout << "\tno queues found" << endl;
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
cout << "\n --> last heartbeats: " << endl << endl;
|
cout << "FairMQ was not compiled in debug mode (FAIRMQ_DEBUG_MODE)" << endl;
|
||||||
auto now = chrono::high_resolution_clock::now();
|
#endif
|
||||||
for (const auto& h : fDeviceHeartbeats) {
|
|
||||||
cout << "\t" << h.first << " : " << chrono::duration<double, milli>(now - h.second).count() << "ms ago." << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::PrintHeader()
|
void Monitor::PrintDebugInfo(const SessionId& sessionId)
|
||||||
{
|
{
|
||||||
cout << "| "
|
ShmId shmId{buildShmIdFromSessionIdAndUserId(sessionId.sessionId)};
|
||||||
<< setw(18) << "name" << " | "
|
PrintDebugInfo(shmId);
|
||||||
<< setw(10) << "size" << " | "
|
}
|
||||||
<< setw(10) << "free" << " | "
|
|
||||||
<< setw(8) << "devices" << " | "
|
unordered_map<uint16_t, std::vector<BufferDebugInfo>> Monitor::GetDebugInfo(const ShmId& shmId __attribute__((unused)))
|
||||||
<< setw(10) << "last hb" << " |"
|
{
|
||||||
<< endl;
|
unordered_map<uint16_t, std::vector<BufferDebugInfo>> result;
|
||||||
|
|
||||||
|
#ifdef FAIRMQ_DEBUG_MODE
|
||||||
|
string managementSegmentName("fmq_" + shmId.shmId + "_mng");
|
||||||
|
try {
|
||||||
|
bipc::managed_shared_memory managementSegment(bipc::open_only, managementSegmentName.c_str());
|
||||||
|
boost::interprocess::named_mutex mtx(boost::interprocess::open_only, string("fmq_" + shmId.shmId + "_mtx").c_str());
|
||||||
|
boost::interprocess::scoped_lock<bipc::named_mutex> lock(mtx);
|
||||||
|
|
||||||
|
Uint16MsgDebugMapHashMap* debug = managementSegment.find<Uint16MsgDebugMapHashMap>(bipc::unique_instance).first;
|
||||||
|
|
||||||
|
result.reserve(debug->size());
|
||||||
|
|
||||||
|
for (const auto& s : *debug) {
|
||||||
|
result[s.first].reserve(s.second.size());
|
||||||
|
for (const auto& e : s.second) {
|
||||||
|
result[s.first][e.first] = BufferDebugInfo(e.first, e.second.fPid, e.second.fSize, e.second.fCreationTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (bie&) {
|
||||||
|
cout << "no segments found" << endl;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
cout << "FairMQ was not compiled in debug mode (FAIRMQ_DEBUG_MODE)" << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
unordered_map<uint16_t, std::vector<BufferDebugInfo>> Monitor::GetDebugInfo(const SessionId& sessionId)
|
||||||
|
{
|
||||||
|
ShmId shmId{buildShmIdFromSessionIdAndUserId(sessionId.sessionId)};
|
||||||
|
return GetDebugInfo(shmId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::PrintHelp()
|
void Monitor::PrintHelp()
|
||||||
{
|
{
|
||||||
cout << "controls: [x] close memory, [p] print queues, [h] help, [q] quit." << endl;
|
cout << "controls: [x] close memory, "
|
||||||
|
<< "[b] print a list of allocated messages (only available when compiled with FAIMQ_DEBUG_MODE=ON), "
|
||||||
|
<< "[h] help, "
|
||||||
|
<< "[q] quit." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::RemoveObject(const string& name)
|
|
||||||
|
std::pair<std::string, bool> RunRemoval(std::function<bool(const std::string&)> f, std::string name, bool verbose)
|
||||||
{
|
{
|
||||||
if (bipc::shared_memory_object::remove(name.c_str())) {
|
if (f(name)) {
|
||||||
|
if (verbose) {
|
||||||
cout << "Successfully removed '" << name << "'." << endl;
|
cout << "Successfully removed '" << name << "'." << endl;
|
||||||
|
}
|
||||||
|
return {name, true};
|
||||||
} else {
|
} else {
|
||||||
|
if (verbose) {
|
||||||
cout << "Did not remove '" << name << "'. Already removed?" << endl;
|
cout << "Did not remove '" << name << "'. Already removed?" << endl;
|
||||||
}
|
}
|
||||||
|
return {name, false};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::RemoveFileMapping(const string& name)
|
bool Monitor::RemoveObject(const string& name) { return bipc::shared_memory_object::remove(name.c_str()); }
|
||||||
{
|
bool Monitor::RemoveFileMapping(const string& name) { return bipc::file_mapping::remove(name.c_str()); }
|
||||||
if (bipc::file_mapping::remove(name.c_str())) {
|
bool Monitor::RemoveQueue(const string& name) { return bipc::message_queue::remove(name.c_str()); }
|
||||||
cout << "Successfully removed '" << name << "'." << endl;
|
bool Monitor::RemoveMutex(const string& name) { return bipc::named_mutex::remove(name.c_str()); }
|
||||||
} else {
|
bool Monitor::RemoveCondition(const string& name) { return bipc::named_condition::remove(name.c_str()); }
|
||||||
cout << "Did not remove '" << name << "'. Already removed?" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Monitor::RemoveQueue(const string& name)
|
std::vector<std::pair<std::string, bool>> Monitor::Cleanup(const ShmId& shmId, bool verbose /* = true */)
|
||||||
{
|
{
|
||||||
if (bipc::message_queue::remove(name.c_str())) {
|
std::vector<std::pair<std::string, bool>> result;
|
||||||
cout << "Successfully removed '" << name << "'." << endl;
|
|
||||||
} else {
|
|
||||||
cout << "Did not remove '" << name << "'. Already removed?" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Monitor::RemoveMutex(const string& name)
|
if (verbose) {
|
||||||
{
|
|
||||||
if (bipc::named_mutex::remove(name.c_str())) {
|
|
||||||
cout << "Successfully removed '" << name << "'." << endl;
|
|
||||||
} else {
|
|
||||||
cout << "Did not remove '" << name << "'. Already removed?" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Monitor::RemoveCondition(const string& name)
|
|
||||||
{
|
|
||||||
if (bipc::named_condition::remove(name.c_str())) {
|
|
||||||
cout << "Successfully removed '" << name << "'." << endl;
|
|
||||||
} else {
|
|
||||||
cout << "Did not remove '" << name << "'. Already removed?" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Monitor::Cleanup(const ShmId& shmId)
|
|
||||||
{
|
|
||||||
cout << "Cleaning up for shared memory id '" << shmId.shmId << "'..." << endl;
|
cout << "Cleaning up for shared memory id '" << shmId.shmId << "'..." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
string managementSegmentName("fmq_" + shmId.shmId + "_mng");
|
string managementSegmentName("fmq_" + shmId.shmId + "_mng");
|
||||||
try {
|
try {
|
||||||
bipc::managed_shared_memory managementSegment(bipc::open_only, managementSegmentName.c_str());
|
bipc::managed_shared_memory managementSegment(bipc::open_only, managementSegmentName.c_str());
|
||||||
|
|
||||||
|
try {
|
||||||
RegionCounter* rc = managementSegment.find<RegionCounter>(bipc::unique_instance).first;
|
RegionCounter* rc = managementSegment.find<RegionCounter>(bipc::unique_instance).first;
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
if (verbose) {
|
||||||
cout << "Region counter found: " << rc->fCount << endl;
|
cout << "Region counter found: " << rc->fCount << endl;
|
||||||
uint64_t regionCount = rc->fCount;
|
}
|
||||||
|
uint16_t regionCount = rc->fCount;
|
||||||
|
|
||||||
Uint64RegionInfoMap* m = managementSegment.find<Uint64RegionInfoMap>(bipc::unique_instance).first;
|
Uint16RegionInfoMap* m = managementSegment.find<Uint16RegionInfoMap>(bipc::unique_instance).first;
|
||||||
|
|
||||||
for (uint64_t i = 1; i <= regionCount; ++i) {
|
for (uint16_t i = 1; i <= regionCount; ++i) {
|
||||||
if (m != nullptr) {
|
if (m != nullptr) {
|
||||||
RegionInfo ri = m->at(i);
|
RegionInfo ri = m->at(i);
|
||||||
string path = ri.fPath.c_str();
|
string path = ri.fPath.c_str();
|
||||||
int flags = ri.fFlags;
|
int flags = ri.fFlags;
|
||||||
|
if (verbose) {
|
||||||
cout << "Found RegionInfo with path: '" << path << "', flags: " << flags << ", fDestroyed: " << ri.fDestroyed << "." << endl;
|
cout << "Found RegionInfo with path: '" << path << "', flags: " << flags << ", fDestroyed: " << ri.fDestroyed << "." << endl;
|
||||||
|
}
|
||||||
if (path != "") {
|
if (path != "") {
|
||||||
RemoveFileMapping(tools::ToString(path, "fmq_" + shmId.shmId + "_rg_" + to_string(i)));
|
result.emplace_back(RunRemoval(Monitor::RemoveFileMapping, path + "fmq_" + shmId.shmId + "_rg_" + to_string(i), verbose));
|
||||||
} else {
|
} else {
|
||||||
RemoveObject("fmq_" + shmId.shmId + "_rg_" + to_string(i));
|
result.emplace_back(RunRemoval(Monitor::RemoveObject, "fmq_" + shmId.shmId + "_rg_" + to_string(i), verbose));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RemoveObject("fmq_" + shmId.shmId + "_rg_" + to_string(i));
|
result.emplace_back(RunRemoval(Monitor::RemoveObject, "fmq_" + shmId.shmId + "_rg_" + to_string(i), verbose));
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveQueue(string("fmq_" + shmId.shmId + "_rgq_" + to_string(i)));
|
result.emplace_back(RunRemoval(Monitor::RemoveQueue, string("fmq_" + shmId.shmId + "_rgq_" + to_string(i)), verbose));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (verbose) {
|
||||||
cout << "No region counter found. No regions to cleanup." << endl;
|
cout << "No region counter found. No regions to cleanup." << endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
RemoveObject(managementSegmentName.c_str());
|
|
||||||
} catch (bie&) {
|
|
||||||
cout << "Did not find '" << managementSegmentName << "' shared memory segment. No regions to cleanup." << endl;
|
|
||||||
} catch(out_of_range& oor) {
|
} catch(out_of_range& oor) {
|
||||||
|
if (verbose) {
|
||||||
cout << "Could not locate element in the region map, out of range: " << oor.what() << endl;
|
cout << "Could not locate element in the region map, out of range: " << oor.what() << endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RemoveObject("fmq_" + shmId.shmId + "_main");
|
Uint16SegmentInfoHashMap* segmentInfos = managementSegment.find<Uint16SegmentInfoHashMap>(bipc::unique_instance).first;
|
||||||
RemoveMutex("fmq_" + shmId.shmId + "_mtx");
|
|
||||||
RemoveCondition("fmq_" + shmId.shmId + "_cv");
|
|
||||||
|
|
||||||
cout << endl;
|
for (const auto& s : *segmentInfos) {
|
||||||
|
result.emplace_back(RunRemoval(Monitor::RemoveObject, "fmq_" + shmId.shmId + "_m_" + to_string(s.first), verbose));
|
||||||
|
}
|
||||||
|
|
||||||
|
result.emplace_back(RunRemoval(Monitor::RemoveObject, managementSegmentName.c_str(), verbose));
|
||||||
|
} catch (bie&) {
|
||||||
|
if (verbose) {
|
||||||
|
cout << "Did not find '" << managementSegmentName << "' shared memory segment. No regions to cleanup." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.emplace_back(RunRemoval(Monitor::RemoveMutex, "fmq_" + shmId.shmId + "_mtx", verbose));
|
||||||
|
result.emplace_back(RunRemoval(Monitor::RemoveCondition, "fmq_" + shmId.shmId + "_cv", verbose));
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::Cleanup(const SessionId& sessionId)
|
std::vector<std::pair<std::string, bool>> Monitor::Cleanup(const SessionId& sessionId, bool verbose /* = true */)
|
||||||
{
|
{
|
||||||
ShmId shmId{buildShmIdFromSessionIdAndUserId(sessionId.sessionId)};
|
ShmId shmId{buildShmIdFromSessionIdAndUserId(sessionId.sessionId)};
|
||||||
|
if (verbose) {
|
||||||
cout << "Cleanup called with session id '" << sessionId.sessionId << "', translating to shared memory id '" << shmId.shmId << "'" << endl;
|
cout << "Cleanup called with session id '" << sessionId.sessionId << "', translating to shared memory id '" << shmId.shmId << "'" << endl;
|
||||||
Cleanup(shmId);
|
}
|
||||||
|
return Cleanup(shmId, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::CleanupFull(const ShmId& shmId)
|
std::vector<std::pair<std::string, bool>> Monitor::CleanupFull(const ShmId& shmId, bool verbose /* = true */)
|
||||||
{
|
{
|
||||||
Cleanup(shmId);
|
auto result = Cleanup(shmId, verbose);
|
||||||
RemoveMutex("fmq_" + shmId.shmId + "_ms");
|
result.emplace_back(RunRemoval(Monitor::RemoveMutex, "fmq_" + shmId.shmId + "_ms", verbose));
|
||||||
RemoveQueue("fmq_" + shmId.shmId + "_cq");
|
result.emplace_back(RunRemoval(Monitor::RemoveQueue, "fmq_" + shmId.shmId + "_cq", verbose));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::CleanupFull(const SessionId& sessionId)
|
std::vector<std::pair<std::string, bool>> Monitor::CleanupFull(const SessionId& sessionId, bool verbose /* = true */)
|
||||||
{
|
{
|
||||||
ShmId shmId{buildShmIdFromSessionIdAndUserId(sessionId.sessionId)};
|
ShmId shmId{buildShmIdFromSessionIdAndUserId(sessionId.sessionId)};
|
||||||
|
if (verbose) {
|
||||||
cout << "Cleanup called with session id '" << sessionId.sessionId << "', translating to shared memory id '" << shmId.shmId << "'" << endl;
|
cout << "Cleanup called with session id '" << sessionId.sessionId << "', translating to shared memory id '" << shmId.shmId << "'" << endl;
|
||||||
CleanupFull(shmId);
|
}
|
||||||
|
return CleanupFull(shmId, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
Monitor::~Monitor()
|
Monitor::~Monitor()
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <utility> // pair
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace fair
|
namespace fair
|
||||||
{
|
{
|
||||||
@@ -34,6 +36,21 @@ struct ShmId
|
|||||||
explicit operator std::string() const { return shmId; }
|
explicit operator std::string() const { return shmId; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BufferDebugInfo
|
||||||
|
{
|
||||||
|
BufferDebugInfo(size_t offset, pid_t pid, size_t size, uint64_t creationTime)
|
||||||
|
: fOffset(offset)
|
||||||
|
, fPid(pid)
|
||||||
|
, fSize(size)
|
||||||
|
, fCreationTime(creationTime)
|
||||||
|
{}
|
||||||
|
|
||||||
|
size_t fOffset;
|
||||||
|
pid_t fPid;
|
||||||
|
size_t fSize;
|
||||||
|
uint64_t fCreationTime;
|
||||||
|
};
|
||||||
|
|
||||||
class Monitor
|
class Monitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -49,29 +66,36 @@ class Monitor
|
|||||||
|
|
||||||
/// @brief Cleanup all shared memory artifacts created by devices
|
/// @brief Cleanup all shared memory artifacts created by devices
|
||||||
/// @param shmId shared memory id
|
/// @param shmId shared memory id
|
||||||
static void Cleanup(const ShmId& shmId);
|
/// @param verbose output cleanup results to stdout
|
||||||
|
static std::vector<std::pair<std::string, bool>> Cleanup(const ShmId& shmId, bool verbose = true);
|
||||||
/// @brief Cleanup all shared memory artifacts created by devices
|
/// @brief Cleanup all shared memory artifacts created by devices
|
||||||
/// @param sessionId session id
|
/// @param sessionId session id
|
||||||
static void Cleanup(const SessionId& sessionId);
|
/// @param verbose output cleanup results to stdout
|
||||||
|
static std::vector<std::pair<std::string, bool>> Cleanup(const SessionId& sessionId, bool verbose = true);
|
||||||
/// @brief Cleanup all shared memory artifacts created by devices and monitors
|
/// @brief Cleanup all shared memory artifacts created by devices and monitors
|
||||||
/// @param shmId shared memory id
|
/// @param shmId shared memory id
|
||||||
static void CleanupFull(const ShmId& shmId);
|
/// @param verbose output cleanup results to stdout
|
||||||
|
static std::vector<std::pair<std::string, bool>> CleanupFull(const ShmId& shmId, bool verbose = true);
|
||||||
/// @brief Cleanup all shared memory artifacts created by devices and monitors
|
/// @brief Cleanup all shared memory artifacts created by devices and monitors
|
||||||
/// @param sessionId session id
|
/// @param sessionId session id
|
||||||
static void CleanupFull(const SessionId& sessionId);
|
/// @param verbose output cleanup results to stdout
|
||||||
|
static std::vector<std::pair<std::string, bool>> CleanupFull(const SessionId& sessionId, bool verbose = true);
|
||||||
|
|
||||||
static void RemoveObject(const std::string&);
|
static void PrintDebugInfo(const ShmId& shmId);
|
||||||
static void RemoveFileMapping(const std::string&);
|
static void PrintDebugInfo(const SessionId& shmId);
|
||||||
static void RemoveQueue(const std::string&);
|
static std::unordered_map<uint16_t, std::vector<BufferDebugInfo>> GetDebugInfo(const ShmId& shmId);
|
||||||
static void RemoveMutex(const std::string&);
|
static std::unordered_map<uint16_t, std::vector<BufferDebugInfo>> GetDebugInfo(const SessionId& shmId);
|
||||||
static void RemoveCondition(const std::string&);
|
|
||||||
|
static bool RemoveObject(const std::string& name);
|
||||||
|
static bool RemoveFileMapping(const std::string& name);
|
||||||
|
static bool RemoveQueue(const std::string& name);
|
||||||
|
static bool RemoveMutex(const std::string& name);
|
||||||
|
static bool RemoveCondition(const std::string& name);
|
||||||
|
|
||||||
struct DaemonPresent : std::runtime_error { using std::runtime_error::runtime_error; };
|
struct DaemonPresent : std::runtime_error { using std::runtime_error::runtime_error; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PrintHeader();
|
|
||||||
void PrintHelp();
|
void PrintHelp();
|
||||||
void PrintQueues();
|
|
||||||
void MonitorHeartbeats();
|
void MonitorHeartbeats();
|
||||||
void CheckSegment();
|
void CheckSegment();
|
||||||
void Interactive();
|
void Interactive();
|
||||||
|
@@ -11,8 +11,8 @@ Devices track and cleanup shared memory on shutdown. For more information on the
|
|||||||
FairMQ Shared Memory currently uses the following names to register shared memory on the system:
|
FairMQ Shared Memory currently uses the following names to register shared memory on the system:
|
||||||
|
|
||||||
| name | info | created by | used by |
|
| name | info | created by | used by |
|
||||||
| ------------------------- | ---------------------------------------------- | ------------------ | ------------------------------ |
|
| --------------------------- | ---------------------------------------------- | ------------------ | ------------------------------ |
|
||||||
| `fmq_<shmId>_main` | main segment (user data) | one of the devices | devices |
|
| `fmq_<shmId>_m_<segmentId>` | managed segment(s) (user data) | one of the devices | devices |
|
||||||
| `fmq_<shmId>_mng` | management segment (management data) | one of the devices | devices |
|
| `fmq_<shmId>_mng` | management segment (management data) | one of the devices | devices |
|
||||||
| `fmq_<shmId>_mtx` | mutex | one of the devices | devices |
|
| `fmq_<shmId>_mtx` | mutex | one of the devices | devices |
|
||||||
| `fmq_<shmId>_cv` | condition variable | one of the devices | devices with unmanaged regions |
|
| `fmq_<shmId>_cv` | condition variable | one of the devices | devices with unmanaged regions |
|
||||||
|
@@ -48,7 +48,7 @@ namespace shmem
|
|||||||
|
|
||||||
struct Region
|
struct Region
|
||||||
{
|
{
|
||||||
Region(const std::string& shmId, uint64_t id, uint64_t size, bool remote, RegionCallback callback, RegionBulkCallback bulkCallback, const std::string& path, int flags)
|
Region(const std::string& shmId, uint16_t id, uint64_t size, bool remote, RegionCallback callback, RegionBulkCallback bulkCallback, const std::string& path, int flags)
|
||||||
: fRemote(remote)
|
: fRemote(remote)
|
||||||
, fLinger(100)
|
, fLinger(100)
|
||||||
, fStop(false)
|
, fStop(false)
|
||||||
|
@@ -130,7 +130,7 @@ class Socket final : public fair::mq::Socket
|
|||||||
|
|
||||||
bool ShouldRetry(int flags, int timeout, int& elapsed) const
|
bool ShouldRetry(int flags, int timeout, int& elapsed) const
|
||||||
{
|
{
|
||||||
if (!fManager.Interrupted() && ((flags & ZMQ_DONTWAIT) == 0)) {
|
if ((flags & ZMQ_DONTWAIT) == 0) {
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
elapsed += fTimeout;
|
elapsed += fTimeout;
|
||||||
if (elapsed >= timeout) {
|
if (elapsed >= timeout) {
|
||||||
@@ -147,10 +147,10 @@ class Socket final : public fair::mq::Socket
|
|||||||
{
|
{
|
||||||
if (zmq_errno() == ETERM) {
|
if (zmq_errno() == ETERM) {
|
||||||
LOG(debug) << "Terminating socket " << fId;
|
LOG(debug) << "Terminating socket " << fId;
|
||||||
return -1;
|
return static_cast<int>(TransferResult::error);
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "Failed transfer on socket " << fId << ", reason: " << zmq_strerror(errno);
|
LOG(error) << "Failed transfer on socket " << fId << ", reason: " << zmq_strerror(errno);
|
||||||
return -1;
|
return static_cast<int>(TransferResult::error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ class Socket final : public fair::mq::Socket
|
|||||||
ZMsg zmqMsg(sizeof(MetaHeader));
|
ZMsg zmqMsg(sizeof(MetaHeader));
|
||||||
std::memcpy(zmqMsg.Data(), &(shmMsg->fMeta), sizeof(MetaHeader));
|
std::memcpy(zmqMsg.Data(), &(shmMsg->fMeta), sizeof(MetaHeader));
|
||||||
|
|
||||||
while (true && !fManager.Interrupted()) {
|
while (true) {
|
||||||
int nbytes = zmq_msg_send(zmqMsg.Msg(), fSocket, flags);
|
int nbytes = zmq_msg_send(zmqMsg.Msg(), fSocket, flags);
|
||||||
if (nbytes > 0) {
|
if (nbytes > 0) {
|
||||||
shmMsg->fQueued = true;
|
shmMsg->fQueued = true;
|
||||||
@@ -175,17 +175,19 @@ class Socket final : public fair::mq::Socket
|
|||||||
fBytesTx += size;
|
fBytesTx += size;
|
||||||
return size;
|
return size;
|
||||||
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
||||||
if (ShouldRetry(flags, timeout, elapsed)) {
|
if (fManager.Interrupted()) {
|
||||||
|
return static_cast<int>(TransferResult::interrupted);
|
||||||
|
} else if (ShouldRetry(flags, timeout, elapsed)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
return -2;
|
return static_cast<int>(TransferResult::timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return HandleErrors();
|
return HandleErrors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return static_cast<int>(TransferResult::error);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Receive(MessagePtr& msg, const int timeout = -1) override
|
int Receive(MessagePtr& msg, const int timeout = -1) override
|
||||||
@@ -218,10 +220,12 @@ class Socket final : public fair::mq::Socket
|
|||||||
++fMessagesRx;
|
++fMessagesRx;
|
||||||
return size;
|
return size;
|
||||||
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
||||||
if (ShouldRetry(flags, timeout, elapsed)) {
|
if (fManager.Interrupted()) {
|
||||||
|
return static_cast<int>(TransferResult::interrupted);
|
||||||
|
} else if (ShouldRetry(flags, timeout, elapsed)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
return -2;
|
return static_cast<int>(TransferResult::timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return HandleErrors();
|
return HandleErrors();
|
||||||
@@ -249,7 +253,7 @@ class Socket final : public fair::mq::Socket
|
|||||||
std::memcpy(metas++, &(shmMsg->fMeta), sizeof(MetaHeader));
|
std::memcpy(metas++, &(shmMsg->fMeta), sizeof(MetaHeader));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!fManager.Interrupted()) {
|
while (true) {
|
||||||
int64_t totalSize = 0;
|
int64_t totalSize = 0;
|
||||||
int nbytes = zmq_msg_send(zmqMsg.Msg(), fSocket, flags);
|
int nbytes = zmq_msg_send(zmqMsg.Msg(), fSocket, flags);
|
||||||
if (nbytes > 0) {
|
if (nbytes > 0) {
|
||||||
@@ -267,17 +271,19 @@ class Socket final : public fair::mq::Socket
|
|||||||
|
|
||||||
return totalSize;
|
return totalSize;
|
||||||
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
||||||
if (ShouldRetry(flags, timeout, elapsed)) {
|
if (fManager.Interrupted()) {
|
||||||
|
return static_cast<int>(TransferResult::interrupted);
|
||||||
|
} else if (ShouldRetry(flags, timeout, elapsed)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
return -2;
|
return static_cast<int>(TransferResult::timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return HandleErrors();
|
return HandleErrors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return static_cast<int>(TransferResult::error);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t Receive(std::vector<MessagePtr>& msgVec, const int timeout = -1) override
|
int64_t Receive(std::vector<MessagePtr>& msgVec, const int timeout = -1) override
|
||||||
@@ -290,7 +296,7 @@ class Socket final : public fair::mq::Socket
|
|||||||
|
|
||||||
ZMsg zmqMsg;
|
ZMsg zmqMsg;
|
||||||
|
|
||||||
while (!fManager.Interrupted()) {
|
while (true) {
|
||||||
int64_t totalSize = 0;
|
int64_t totalSize = 0;
|
||||||
int nbytes = zmq_msg_recv(zmqMsg.Msg(), fSocket, flags);
|
int nbytes = zmq_msg_recv(zmqMsg.Msg(), fSocket, flags);
|
||||||
if (nbytes > 0) {
|
if (nbytes > 0) {
|
||||||
@@ -321,17 +327,19 @@ class Socket final : public fair::mq::Socket
|
|||||||
|
|
||||||
return totalSize;
|
return totalSize;
|
||||||
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
||||||
if (ShouldRetry(flags, timeout, elapsed)) {
|
if (fManager.Interrupted()) {
|
||||||
|
return static_cast<int>(TransferResult::interrupted);
|
||||||
|
} else if (ShouldRetry(flags, timeout, elapsed)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
return -2;
|
return static_cast<int>(TransferResult::timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return HandleErrors();
|
return HandleErrors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return static_cast<int>(TransferResult::error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* GetSocket() const { return fSocket; }
|
void* GetSocket() const { return fSocket; }
|
||||||
@@ -498,7 +506,7 @@ class Socket final : public fair::mq::Socket
|
|||||||
if (constant == "pollout")
|
if (constant == "pollout")
|
||||||
return ZMQ_POLLOUT;
|
return ZMQ_POLLOUT;
|
||||||
|
|
||||||
return -1;
|
throw SocketError(tools::ToString("GetConstant called with an invalid argument: ", constant));
|
||||||
}
|
}
|
||||||
|
|
||||||
~Socket() override { Close(); }
|
~Socket() override { Close(); }
|
||||||
|
@@ -58,14 +58,21 @@ class TransportFactory final : public fair::mq::TransportFactory
|
|||||||
int numIoThreads = 1;
|
int numIoThreads = 1;
|
||||||
std::string sessionName = "default";
|
std::string sessionName = "default";
|
||||||
size_t segmentSize = 2ULL << 30;
|
size_t segmentSize = 2ULL << 30;
|
||||||
|
std::string allocationAlgorithm("rbtree_best_fit");
|
||||||
if (config) {
|
if (config) {
|
||||||
numIoThreads = config->GetProperty<int>("io-threads", numIoThreads);
|
numIoThreads = config->GetProperty<int>("io-threads", numIoThreads);
|
||||||
sessionName = config->GetProperty<std::string>("session", sessionName);
|
sessionName = config->GetProperty<std::string>("session", sessionName);
|
||||||
segmentSize = config->GetProperty<size_t>("shm-segment-size", segmentSize);
|
segmentSize = config->GetProperty<size_t>("shm-segment-size", segmentSize);
|
||||||
|
allocationAlgorithm = config->GetProperty<std::string>("shm-allocation", allocationAlgorithm);
|
||||||
} else {
|
} else {
|
||||||
LOG(debug) << "ProgOptions not available! Using defaults.";
|
LOG(debug) << "ProgOptions not available! Using defaults.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (allocationAlgorithm != "rbtree_best_fit" && allocationAlgorithm != "simple_seq_fit") {
|
||||||
|
LOG(error) << "Provided shared memory allocation algorithm '" << allocationAlgorithm << "' is not supported. Supported are 'rbtree_best_fit'/'simple_seq_fit'";
|
||||||
|
throw SharedMemoryError(tools::ToString("Provided shared memory allocation algorithm '", allocationAlgorithm, "' is not supported. Supported are 'rbtree_best_fit'/'simple_seq_fit'"));
|
||||||
|
}
|
||||||
|
|
||||||
fShmId = buildShmIdFromSessionIdAndUserId(sessionName);
|
fShmId = buildShmIdFromSessionIdAndUserId(sessionName);
|
||||||
LOG(debug) << "Generated shmid '" << fShmId << "' out of session id '" << sessionName << "'.";
|
LOG(debug) << "Generated shmid '" << fShmId << "' out of session id '" << sessionName << "'.";
|
||||||
|
|
||||||
|
@@ -56,7 +56,7 @@ class UnmanagedRegion final : public fair::mq::UnmanagedRegion
|
|||||||
|
|
||||||
void* GetData() const override { return fRegion->get_address(); }
|
void* GetData() const override { return fRegion->get_address(); }
|
||||||
size_t GetSize() const override { return fRegion->get_size(); }
|
size_t GetSize() const override { return fRegion->get_size(); }
|
||||||
uint64_t GetId() const override { return fRegionId; }
|
uint16_t GetId() const override { return fRegionId; }
|
||||||
void SetLinger(uint32_t linger) override { fManager.GetRegion(fRegionId)->SetLinger(linger); }
|
void SetLinger(uint32_t linger) override { fManager.GetRegion(fRegionId)->SetLinger(linger); }
|
||||||
uint32_t GetLinger() const override { return fManager.GetRegion(fRegionId)->GetLinger(); }
|
uint32_t GetLinger() const override { return fManager.GetRegion(fRegionId)->GetLinger(); }
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ class UnmanagedRegion final : public fair::mq::UnmanagedRegion
|
|||||||
private:
|
private:
|
||||||
Manager& fManager;
|
Manager& fManager;
|
||||||
boost::interprocess::mapped_region* fRegion;
|
boost::interprocess::mapped_region* fRegion;
|
||||||
uint64_t fRegionId;
|
uint16_t fRegionId;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -78,6 +78,7 @@ int main(int argc, char** argv)
|
|||||||
unsigned int timeoutInMS = 5000;
|
unsigned int timeoutInMS = 5000;
|
||||||
unsigned int intervalInMS = 100;
|
unsigned int intervalInMS = 100;
|
||||||
bool runAsDaemon = false;
|
bool runAsDaemon = false;
|
||||||
|
bool debug = false;
|
||||||
bool cleanOnExit = false;
|
bool cleanOnExit = false;
|
||||||
|
|
||||||
options_description desc("Options");
|
options_description desc("Options");
|
||||||
@@ -90,6 +91,7 @@ int main(int argc, char** argv)
|
|||||||
("view,v" , value<bool>(&viewOnly)->implicit_value(true), "Run in view only mode")
|
("view,v" , value<bool>(&viewOnly)->implicit_value(true), "Run in view only mode")
|
||||||
("timeout,t" , value<unsigned int>(&timeoutInMS)->default_value(5000), "Heartbeat timeout in milliseconds")
|
("timeout,t" , value<unsigned int>(&timeoutInMS)->default_value(5000), "Heartbeat timeout in milliseconds")
|
||||||
("daemonize,d" , value<bool>(&runAsDaemon)->implicit_value(true), "Daemonize the monitor")
|
("daemonize,d" , value<bool>(&runAsDaemon)->implicit_value(true), "Daemonize the monitor")
|
||||||
|
("debug,b" , value<bool>(&debug)->implicit_value(true), "Debug - Print a list of messages)")
|
||||||
("clean-on-exit,e", value<bool>(&cleanOnExit)->implicit_value(true), "Perform cleanup on exit")
|
("clean-on-exit,e", value<bool>(&cleanOnExit)->implicit_value(true), "Perform cleanup on exit")
|
||||||
("interval" , value<unsigned int>(&intervalInMS)->default_value(100), "Output interval for interactive/view-only mode")
|
("interval" , value<unsigned int>(&intervalInMS)->default_value(100), "Output interval for interactive/view-only mode")
|
||||||
("help,h", "Print help");
|
("help,h", "Print help");
|
||||||
@@ -117,6 +119,11 @@ int main(int argc, char** argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
Monitor::PrintDebugInfo(ShmId{shmId});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
cout << "Starting shared memory monitor for session: \"" << sessionName << "\" (shmId: " << shmId << ")..." << endl;
|
cout << "Starting shared memory monitor for session: \"" << sessionName << "\" (shmId: " << shmId << ")..." << endl;
|
||||||
if (viewOnly && !interactive) {
|
if (viewOnly && !interactive) {
|
||||||
cout << "running in non-interactive view-only mode, outputting with interval of " << intervalInMS << "ms. (change with --interval), press ctrl+C to exit." << endl;
|
cout << "running in non-interactive view-only mode, outputting with interval of " << intervalInMS << "ms. (change with --interval), press ctrl+C to exit." << endl;
|
||||||
|
@@ -56,7 +56,7 @@ class Context
|
|||||||
throw ContextError(tools::ToString("failed configuring context, reason: ", zmq_strerror(errno)));
|
throw ContextError(tools::ToString("failed configuring context, reason: ", zmq_strerror(errno)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fRegionEvents.emplace(0, nullptr, 0, 0, RegionEvent::local_only);
|
fRegionEvents.emplace(true, 0, nullptr, 0, 0, RegionEvent::local_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
Context(const Context&) = delete;
|
Context(const Context&) = delete;
|
||||||
@@ -114,24 +114,24 @@ class Context
|
|||||||
return fRegionInfos;
|
return fRegionInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t RegionCount() const
|
uint16_t RegionCount() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(fMtx);
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
return fRegionCounter;
|
return fRegionCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddRegion(uint64_t id, void* ptr, size_t size, int64_t userFlags, RegionEvent event)
|
void AddRegion(bool managed, uint16_t id, void* ptr, size_t size, int64_t userFlags, RegionEvent event)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(fMtx);
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
++fRegionCounter;
|
++fRegionCounter;
|
||||||
fRegionInfos.emplace_back(id, ptr, size, userFlags, event);
|
fRegionInfos.emplace_back(managed, id, ptr, size, userFlags, event);
|
||||||
fRegionEvents.emplace(id, ptr, size, userFlags, event);
|
fRegionEvents.emplace(managed, id, ptr, size, userFlags, event);
|
||||||
}
|
}
|
||||||
fRegionEventsCV.notify_one();
|
fRegionEventsCV.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveRegion(uint64_t id)
|
void RemoveRegion(uint16_t id)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(fMtx);
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
@@ -182,7 +182,7 @@ class Context
|
|||||||
mutable std::mutex fMtx;
|
mutable std::mutex fMtx;
|
||||||
std::atomic<bool> fInterrupted;
|
std::atomic<bool> fInterrupted;
|
||||||
|
|
||||||
uint64_t fRegionCounter;
|
uint16_t fRegionCounter;
|
||||||
std::condition_variable fRegionEventsCV;
|
std::condition_variable fRegionEventsCV;
|
||||||
std::vector<RegionInfo> fRegionInfos;
|
std::vector<RegionInfo> fRegionInfos;
|
||||||
std::queue<RegionInfo> fRegionEvents;
|
std::queue<RegionInfo> fRegionEvents;
|
||||||
|
@@ -108,7 +108,7 @@ class Socket final : public fair::mq::Socket
|
|||||||
|
|
||||||
bool ShouldRetry(int flags, int timeout, int& elapsed) const
|
bool ShouldRetry(int flags, int timeout, int& elapsed) const
|
||||||
{
|
{
|
||||||
if (!fCtx.Interrupted() && ((flags & ZMQ_DONTWAIT) == 0)) {
|
if ((flags & ZMQ_DONTWAIT) == 0) {
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
elapsed += fTimeout;
|
elapsed += fTimeout;
|
||||||
if (elapsed >= timeout) {
|
if (elapsed >= timeout) {
|
||||||
@@ -125,10 +125,10 @@ class Socket final : public fair::mq::Socket
|
|||||||
{
|
{
|
||||||
if (zmq_errno() == ETERM) {
|
if (zmq_errno() == ETERM) {
|
||||||
LOG(debug) << "Terminating socket " << fId;
|
LOG(debug) << "Terminating socket " << fId;
|
||||||
return -1;
|
return static_cast<int>(TransferResult::error);
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "Failed transfer on socket " << fId << ", errno: " << errno << ", reason: " << zmq_strerror(errno);
|
LOG(error) << "Failed transfer on socket " << fId << ", errno: " << errno << ", reason: " << zmq_strerror(errno);
|
||||||
return -1;
|
return static_cast<int>(TransferResult::error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,10 +149,12 @@ class Socket final : public fair::mq::Socket
|
|||||||
++fMessagesTx;
|
++fMessagesTx;
|
||||||
return nbytes;
|
return nbytes;
|
||||||
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
||||||
if (ShouldRetry(flags, timeout, elapsed)) {
|
if (fCtx.Interrupted()) {
|
||||||
|
return static_cast<int>(TransferResult::interrupted);
|
||||||
|
} else if (ShouldRetry(flags, timeout, elapsed)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
return -2;
|
return static_cast<int>(TransferResult::timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return HandleErrors();
|
return HandleErrors();
|
||||||
@@ -175,10 +177,12 @@ class Socket final : public fair::mq::Socket
|
|||||||
++fMessagesRx;
|
++fMessagesRx;
|
||||||
return nbytes;
|
return nbytes;
|
||||||
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
||||||
if (ShouldRetry(flags, timeout, elapsed)) {
|
if (fCtx.Interrupted()) {
|
||||||
|
return static_cast<int>(TransferResult::interrupted);
|
||||||
|
} else if (ShouldRetry(flags, timeout, elapsed)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
return -2;
|
return static_cast<int>(TransferResult::timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return HandleErrors();
|
return HandleErrors();
|
||||||
@@ -210,11 +214,13 @@ class Socket final : public fair::mq::Socket
|
|||||||
if (nbytes >= 0) {
|
if (nbytes >= 0) {
|
||||||
totalSize += nbytes;
|
totalSize += nbytes;
|
||||||
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
||||||
if (ShouldRetry(flags, timeout, elapsed)) {
|
if (fCtx.Interrupted()) {
|
||||||
|
return static_cast<int>(TransferResult::interrupted);
|
||||||
|
} else if (ShouldRetry(flags, timeout, elapsed)) {
|
||||||
repeat = true;
|
repeat = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
return -2;
|
return static_cast<int>(TransferResult::timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return HandleErrors();
|
return HandleErrors();
|
||||||
@@ -234,7 +240,7 @@ class Socket final : public fair::mq::Socket
|
|||||||
return Send(msgVec.back(), timeout);
|
return Send(msgVec.back(), timeout);
|
||||||
} else { // if the vector is empty, something might be wrong
|
} else { // if the vector is empty, something might be wrong
|
||||||
LOG(warn) << "Will not send empty vector";
|
LOG(warn) << "Will not send empty vector";
|
||||||
return -1;
|
return static_cast<int>(TransferResult::error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,11 +265,13 @@ class Socket final : public fair::mq::Socket
|
|||||||
msgVec.push_back(move(part));
|
msgVec.push_back(move(part));
|
||||||
totalSize += nbytes;
|
totalSize += nbytes;
|
||||||
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
} else if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) {
|
||||||
if (ShouldRetry(flags, timeout, elapsed)) {
|
if (fCtx.Interrupted()) {
|
||||||
|
return static_cast<int>(TransferResult::interrupted);
|
||||||
|
} else if (ShouldRetry(flags, timeout, elapsed)) {
|
||||||
repeat = true;
|
repeat = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
return -2;
|
return static_cast<int>(TransferResult::timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return HandleErrors();
|
return HandleErrors();
|
||||||
@@ -446,7 +454,7 @@ class Socket final : public fair::mq::Socket
|
|||||||
if (constant == "pollout")
|
if (constant == "pollout")
|
||||||
return ZMQ_POLLOUT;
|
return ZMQ_POLLOUT;
|
||||||
|
|
||||||
return -1;
|
throw SocketError(tools::ToString("GetConstant called with an invalid argument: ", constant));
|
||||||
}
|
}
|
||||||
|
|
||||||
~Socket() override { Close(); }
|
~Socket() override { Close(); }
|
||||||
|
@@ -125,7 +125,7 @@ class TransportFactory final : public FairMQTransportFactory
|
|||||||
{
|
{
|
||||||
UnmanagedRegionPtr ptr = tools::make_unique<UnmanagedRegion>(*fCtx, size, userFlags, callback, bulkCallback, this);
|
UnmanagedRegionPtr ptr = tools::make_unique<UnmanagedRegion>(*fCtx, size, userFlags, callback, bulkCallback, this);
|
||||||
auto zPtr = static_cast<UnmanagedRegion*>(ptr.get());
|
auto zPtr = static_cast<UnmanagedRegion*>(ptr.get());
|
||||||
fCtx->AddRegion(zPtr->GetId(), zPtr->GetData(), zPtr->GetSize(), zPtr->GetUserFlags(), RegionEvent::created);
|
fCtx->AddRegion(false, zPtr->GetId(), zPtr->GetData(), zPtr->GetSize(), zPtr->GetUserFlags(), RegionEvent::created);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ class UnmanagedRegion final : public fair::mq::UnmanagedRegion
|
|||||||
|
|
||||||
virtual void* GetData() const override { return fBuffer; }
|
virtual void* GetData() const override { return fBuffer; }
|
||||||
virtual size_t GetSize() const override { return fSize; }
|
virtual size_t GetSize() const override { return fSize; }
|
||||||
uint64_t GetId() const override { return fId; }
|
uint16_t GetId() const override { return fId; }
|
||||||
int64_t GetUserFlags() const { return fUserFlags; }
|
int64_t GetUserFlags() const { return fUserFlags; }
|
||||||
void SetLinger(uint32_t /* linger */) override { LOG(debug) << "ZeroMQ UnmanagedRegion linger option not implemented. Acknowledgements are local."; }
|
void SetLinger(uint32_t /* linger */) override { LOG(debug) << "ZeroMQ UnmanagedRegion linger option not implemented. Acknowledgements are local."; }
|
||||||
uint32_t GetLinger() const override { LOG(debug) << "ZeroMQ UnmanagedRegion linger option not implemented. Acknowledgements are local."; return 0; }
|
uint32_t GetLinger() const override { LOG(debug) << "ZeroMQ UnmanagedRegion linger option not implemented. Acknowledgements are local."; return 0; }
|
||||||
@@ -64,7 +64,7 @@ class UnmanagedRegion final : public fair::mq::UnmanagedRegion
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Context& fCtx;
|
Context& fCtx;
|
||||||
uint64_t fId;
|
uint16_t fId;
|
||||||
void* fBuffer;
|
void* fBuffer;
|
||||||
size_t fSize;
|
size_t fSize;
|
||||||
int64_t fUserFlags;
|
int64_t fUserFlags;
|
||||||
|
@@ -12,6 +12,18 @@ include(GTestHelper)
|
|||||||
# FairMQ Testsuites/helpers #
|
# FairMQ Testsuites/helpers #
|
||||||
#############################
|
#############################
|
||||||
|
|
||||||
|
if(FairLogger_VERSION VERSION_LESS 1.9.0 AND FairLogger_VERSION VERSION_GREATER_EQUAL 1.7.0)
|
||||||
|
LIST(APPEND definitions FAIR_MIN_SEVERITY=trace)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_OFI_TRANSPORT)
|
||||||
|
LIST(APPEND definitions BUILD_OFI_TRANSPORT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(definitions)
|
||||||
|
set(definitions DEFINITIONS ${definitions})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_testhelper(runTestDevice
|
add_testhelper(runTestDevice
|
||||||
SOURCES
|
SOURCES
|
||||||
helper/runTestDevice.cxx
|
helper/runTestDevice.cxx
|
||||||
@@ -30,16 +42,9 @@ add_testhelper(runTestDevice
|
|||||||
helper/devices/TestExceptions.h
|
helper/devices/TestExceptions.h
|
||||||
|
|
||||||
LINKS FairMQ
|
LINKS FairMQ
|
||||||
|
${definitions}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
|
||||||
LIST(APPEND definitions BUILD_OFI_TRANSPORT)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(definitions)
|
|
||||||
set(definitions DEFINITIONS ${definitions})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(MQ_CONFIG "${CMAKE_BINARY_DIR}/test/testsuite_FairMQ.IOPatterns_config.json")
|
set(MQ_CONFIG "${CMAKE_BINARY_DIR}/test/testsuite_FairMQ.IOPatterns_config.json")
|
||||||
set(RUN_TEST_DEVICE "${CMAKE_BINARY_DIR}/test/testhelper_runTestDevice")
|
set(RUN_TEST_DEVICE "${CMAKE_BINARY_DIR}/test/testhelper_runTestDevice")
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
||||||
|
@@ -31,7 +31,7 @@ TEST(Format, Construction)
|
|||||||
Cmds setPropertiesCmds(make<SetProperties>(42, props));
|
Cmds setPropertiesCmds(make<SetProperties>(42, props));
|
||||||
Cmds subscriptionHeartbeatCmds(make<SubscriptionHeartbeat>(60000));
|
Cmds subscriptionHeartbeatCmds(make<SubscriptionHeartbeat>(60000));
|
||||||
Cmds currentStateCmds(make<CurrentState>("somedeviceid", State::Running));
|
Cmds currentStateCmds(make<CurrentState>("somedeviceid", State::Running));
|
||||||
Cmds transitionStatusCmds(make<TransitionStatus>("somedeviceid", 123456, Result::Ok, Transition::Stop));
|
Cmds transitionStatusCmds(make<TransitionStatus>("somedeviceid", 123456, Result::Ok, Transition::Stop, State::Running));
|
||||||
Cmds configCmds(make<Config>("somedeviceid", "someconfig"));
|
Cmds configCmds(make<Config>("somedeviceid", "someconfig"));
|
||||||
Cmds stateChangeSubscriptionCmds(make<StateChangeSubscription>("somedeviceid", 123456, Result::Ok));
|
Cmds stateChangeSubscriptionCmds(make<StateChangeSubscription>("somedeviceid", 123456, Result::Ok));
|
||||||
Cmds stateChangeUnsubscriptionCmds(make<StateChangeUnsubscription>("somedeviceid", 123456, Result::Ok));
|
Cmds stateChangeUnsubscriptionCmds(make<StateChangeUnsubscription>("somedeviceid", 123456, Result::Ok));
|
||||||
@@ -63,6 +63,7 @@ TEST(Format, Construction)
|
|||||||
ASSERT_EQ(static_cast<TransitionStatus&>(transitionStatusCmds.At(0)).GetTaskId(), 123456);
|
ASSERT_EQ(static_cast<TransitionStatus&>(transitionStatusCmds.At(0)).GetTaskId(), 123456);
|
||||||
ASSERT_EQ(static_cast<TransitionStatus&>(transitionStatusCmds.At(0)).GetResult(), Result::Ok);
|
ASSERT_EQ(static_cast<TransitionStatus&>(transitionStatusCmds.At(0)).GetResult(), Result::Ok);
|
||||||
ASSERT_EQ(static_cast<TransitionStatus&>(transitionStatusCmds.At(0)).GetTransition(), Transition::Stop);
|
ASSERT_EQ(static_cast<TransitionStatus&>(transitionStatusCmds.At(0)).GetTransition(), Transition::Stop);
|
||||||
|
ASSERT_EQ(static_cast<TransitionStatus&>(transitionStatusCmds.At(0)).GetCurrentState(), State::Running);
|
||||||
ASSERT_EQ(configCmds.At(0).GetType(), Type::config);
|
ASSERT_EQ(configCmds.At(0).GetType(), Type::config);
|
||||||
ASSERT_EQ(static_cast<Config&>(configCmds.At(0)).GetDeviceId(), "somedeviceid");
|
ASSERT_EQ(static_cast<Config&>(configCmds.At(0)).GetDeviceId(), "somedeviceid");
|
||||||
ASSERT_EQ(static_cast<Config&>(configCmds.At(0)).GetConfig(), "someconfig");
|
ASSERT_EQ(static_cast<Config&>(configCmds.At(0)).GetConfig(), "someconfig");
|
||||||
@@ -104,7 +105,7 @@ void fillCommands(Cmds& cmds)
|
|||||||
cmds.Add<SetProperties>(42, props);
|
cmds.Add<SetProperties>(42, props);
|
||||||
cmds.Add<SubscriptionHeartbeat>(60000);
|
cmds.Add<SubscriptionHeartbeat>(60000);
|
||||||
cmds.Add<CurrentState>("somedeviceid", State::Running);
|
cmds.Add<CurrentState>("somedeviceid", State::Running);
|
||||||
cmds.Add<TransitionStatus>("somedeviceid", 123456, Result::Ok, Transition::Stop);
|
cmds.Add<TransitionStatus>("somedeviceid", 123456, Result::Ok, Transition::Stop, State::Running);
|
||||||
cmds.Add<Config>("somedeviceid", "someconfig");
|
cmds.Add<Config>("somedeviceid", "someconfig");
|
||||||
cmds.Add<StateChangeSubscription>("somedeviceid", 123456, Result::Ok);
|
cmds.Add<StateChangeSubscription>("somedeviceid", 123456, Result::Ok);
|
||||||
cmds.Add<StateChangeUnsubscription>("somedeviceid", 123456, Result::Ok);
|
cmds.Add<StateChangeUnsubscription>("somedeviceid", 123456, Result::Ok);
|
||||||
@@ -167,6 +168,7 @@ void checkCommands(Cmds& cmds)
|
|||||||
ASSERT_EQ(static_cast<TransitionStatus&>(*cmd).GetTaskId(), 123456);
|
ASSERT_EQ(static_cast<TransitionStatus&>(*cmd).GetTaskId(), 123456);
|
||||||
ASSERT_EQ(static_cast<TransitionStatus&>(*cmd).GetResult(), Result::Ok);
|
ASSERT_EQ(static_cast<TransitionStatus&>(*cmd).GetResult(), Result::Ok);
|
||||||
ASSERT_EQ(static_cast<TransitionStatus&>(*cmd).GetTransition(), Transition::Stop);
|
ASSERT_EQ(static_cast<TransitionStatus&>(*cmd).GetTransition(), Transition::Stop);
|
||||||
|
ASSERT_EQ(static_cast<TransitionStatus&>(*cmd).GetCurrentState(), State::Running);
|
||||||
break;
|
break;
|
||||||
case Type::config:
|
case Type::config:
|
||||||
++count;
|
++count;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2015-2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2015static_cast<int>(TransferResult::timeout017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH ) *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
@@ -24,20 +24,20 @@ class TransferTimeout : public FairMQDevice
|
|||||||
protected:
|
protected:
|
||||||
auto Run() -> void override
|
auto Run() -> void override
|
||||||
{
|
{
|
||||||
bool sendMsgCancelingAfter100ms = false;
|
bool sendMsgCancelingAfter200ms = false;
|
||||||
bool receiveMsgCancelingAfter100ms = false;
|
bool receiveMsgCancelingAfter200ms = false;
|
||||||
|
|
||||||
bool sendMsgCancelingAfter0ms = false;
|
bool sendMsgCancelingAfter0ms = false;
|
||||||
bool receiveMsgCancelingAfter0ms = false;
|
bool receiveMsgCancelingAfter0ms = false;
|
||||||
|
|
||||||
bool send1PartCancelingAfter100ms = false;
|
bool send1PartCancelingAfter200ms = false;
|
||||||
bool receive1PartCancelingAfter100ms = false;
|
bool receive1PartCancelingAfter200ms = false;
|
||||||
|
|
||||||
bool send1PartCancelingAfter0ms = false;
|
bool send1PartCancelingAfter0ms = false;
|
||||||
bool receive1PartCancelingAfter0ms = false;
|
bool receive1PartCancelingAfter0ms = false;
|
||||||
|
|
||||||
bool send2PartsCancelingAfter100ms = false;
|
bool send2PartsCancelingAfter200ms = false;
|
||||||
bool receive2PartsCancelingAfter100ms = false;
|
bool receive2PartsCancelingAfter200ms = false;
|
||||||
|
|
||||||
bool send2PartsCancelingAfter0ms = false;
|
bool send2PartsCancelingAfter0ms = false;
|
||||||
bool receive2PartsCancelingAfter0ms = false;
|
bool receive2PartsCancelingAfter0ms = false;
|
||||||
@@ -45,28 +45,28 @@ class TransferTimeout : public FairMQDevice
|
|||||||
FairMQMessagePtr msg1(NewMessage());
|
FairMQMessagePtr msg1(NewMessage());
|
||||||
FairMQMessagePtr msg2(NewMessage());
|
FairMQMessagePtr msg2(NewMessage());
|
||||||
|
|
||||||
if (Send(msg1, "data-out", 0, 100) == -2) {
|
if (Send(msg1, "data-out", 0, 200) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "send msg canceled (100ms)";
|
LOG(info) << "send msg canceled (200ms)";
|
||||||
sendMsgCancelingAfter100ms = true;
|
sendMsgCancelingAfter200ms = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "send msg did not cancel (100ms)";
|
LOG(error) << "send msg did not cancel (200ms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Receive(msg2, "data-in", 0, 100) == -2) {
|
if (Receive(msg2, "data-in", 0, 200) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "receive msg canceled (100ms)";
|
LOG(info) << "receive msg canceled (200ms)";
|
||||||
receiveMsgCancelingAfter100ms = true;
|
receiveMsgCancelingAfter200ms = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "receive msg did not cancel (100ms)";
|
LOG(error) << "receive msg did not cancel (200ms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Send(msg1, "data-out", 0, 0) == -2) {
|
if (Send(msg1, "data-out", 0, 0) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "send msg canceled (0ms)";
|
LOG(info) << "send msg canceled (0ms)";
|
||||||
sendMsgCancelingAfter0ms = true;
|
sendMsgCancelingAfter0ms = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "send msg did not cancel (0ms)";
|
LOG(error) << "send msg did not cancel (0ms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Receive(msg2, "data-in", 0, 0) == -2) {
|
if (Receive(msg2, "data-in", 0, 0) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "receive msg canceled (0ms)";
|
LOG(info) << "receive msg canceled (0ms)";
|
||||||
receiveMsgCancelingAfter0ms = true;
|
receiveMsgCancelingAfter0ms = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -77,28 +77,28 @@ class TransferTimeout : public FairMQDevice
|
|||||||
parts1.AddPart(NewMessage(10));
|
parts1.AddPart(NewMessage(10));
|
||||||
FairMQParts parts2;
|
FairMQParts parts2;
|
||||||
|
|
||||||
if (Send(parts1, "data-out", 0, 100) == -2) {
|
if (Send(parts1, "data-out", 0, 200) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "send 1 part canceled (100ms)";
|
LOG(info) << "send 1 part canceled (200ms)";
|
||||||
send1PartCancelingAfter100ms = true;
|
send1PartCancelingAfter200ms = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "send 1 part did not cancel (100ms)";
|
LOG(error) << "send 1 part did not cancel (200ms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Receive(parts2, "data-in", 0, 100) == -2) {
|
if (Receive(parts2, "data-in", 0, 200) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "receive 1 part canceled (100ms)";
|
LOG(info) << "receive 1 part canceled (200ms)";
|
||||||
receive1PartCancelingAfter100ms = true;
|
receive1PartCancelingAfter200ms = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "receive 1 part did not cancel (100ms)";
|
LOG(error) << "receive 1 part did not cancel (200ms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Send(parts1, "data-out", 0, 0) == -2) {
|
if (Send(parts1, "data-out", 0, 0) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "send 1 part canceled (0ms)";
|
LOG(info) << "send 1 part canceled (0ms)";
|
||||||
send1PartCancelingAfter0ms = true;
|
send1PartCancelingAfter0ms = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "send 1 part did not cancel (0ms)";
|
LOG(error) << "send 1 part did not cancel (0ms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Receive(parts2, "data-in", 0, 0) == -2) {
|
if (Receive(parts2, "data-in", 0, 0) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "receive 1 part canceled (0ms)";
|
LOG(info) << "receive 1 part canceled (0ms)";
|
||||||
receive1PartCancelingAfter0ms = true;
|
receive1PartCancelingAfter0ms = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -110,44 +110,44 @@ class TransferTimeout : public FairMQDevice
|
|||||||
parts3.AddPart(NewMessage(10));
|
parts3.AddPart(NewMessage(10));
|
||||||
FairMQParts parts4;
|
FairMQParts parts4;
|
||||||
|
|
||||||
if (Send(parts3, "data-out", 0, 100) == -2) {
|
if (Send(parts3, "data-out", 0, 200) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "send 2 parts canceled (100ms)";
|
LOG(info) << "send 2 parts canceled (200ms)";
|
||||||
send2PartsCancelingAfter100ms = true;
|
send2PartsCancelingAfter200ms = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "send 2 parts did not cancel (100ms)";
|
LOG(error) << "send 2 parts did not cancel (200ms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Receive(parts4, "data-in", 0, 100) == -2) {
|
if (Receive(parts4, "data-in", 0, 200) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "receive 2 parts canceled (100ms)";
|
LOG(info) << "receive 2 parts canceled (200ms)";
|
||||||
receive2PartsCancelingAfter100ms = true;
|
receive2PartsCancelingAfter200ms = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "receive 2 parts did not cancel (100ms)";
|
LOG(error) << "receive 2 parts did not cancel (200ms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Send(parts3, "data-out", 0, 0) == -2) {
|
if (Send(parts3, "data-out", 0, 0) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "send 2 parts canceled (0ms)";
|
LOG(info) << "send 2 parts canceled (0ms)";
|
||||||
send2PartsCancelingAfter0ms = true;
|
send2PartsCancelingAfter0ms = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "send 2 parts did not cancel (0ms)";
|
LOG(error) << "send 2 parts did not cancel (0ms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Receive(parts4, "data-in", 0, 0) == -2) {
|
if (Receive(parts4, "data-in", 0, 0) == static_cast<int>(TransferResult::timeout)) {
|
||||||
LOG(info) << "receive 2 parts canceled (0ms)";
|
LOG(info) << "receive 2 parts canceled (0ms)";
|
||||||
receive2PartsCancelingAfter0ms = true;
|
receive2PartsCancelingAfter0ms = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "receive 2 parts did not cancel (0ms)";
|
LOG(error) << "receive 2 parts did not cancel (0ms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendMsgCancelingAfter100ms &&
|
if (sendMsgCancelingAfter200ms &&
|
||||||
receiveMsgCancelingAfter100ms &&
|
receiveMsgCancelingAfter200ms &&
|
||||||
sendMsgCancelingAfter0ms &&
|
sendMsgCancelingAfter0ms &&
|
||||||
receiveMsgCancelingAfter0ms &&
|
receiveMsgCancelingAfter0ms &&
|
||||||
send1PartCancelingAfter100ms &&
|
send1PartCancelingAfter200ms &&
|
||||||
receive1PartCancelingAfter100ms &&
|
receive1PartCancelingAfter200ms &&
|
||||||
send1PartCancelingAfter0ms &&
|
send1PartCancelingAfter0ms &&
|
||||||
receive1PartCancelingAfter0ms &&
|
receive1PartCancelingAfter0ms &&
|
||||||
send2PartsCancelingAfter100ms &&
|
send2PartsCancelingAfter200ms &&
|
||||||
receive2PartsCancelingAfter100ms &&
|
receive2PartsCancelingAfter200ms &&
|
||||||
send2PartsCancelingAfter0ms &&
|
send2PartsCancelingAfter0ms &&
|
||||||
receive2PartsCancelingAfter0ms)
|
receive2PartsCancelingAfter0ms)
|
||||||
{
|
{
|
||||||
|
@@ -6,66 +6,83 @@
|
|||||||
* copied verbatim in the file "LICENSE" *
|
* copied verbatim in the file "LICENSE" *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <fairmq/FairMQTransportFactory.h>
|
#include <fairmq/FairMQTransportFactory.h>
|
||||||
#include <fairmq/MemoryResourceTools.h>
|
#include <fairmq/MemoryResourceTools.h>
|
||||||
|
#include <fairmq/ProgOptions.h>
|
||||||
|
#include <fairmq/Tools.h>
|
||||||
|
|
||||||
|
#include <boost/container/pmr/polymorphic_allocator.hpp>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace fair::mq;
|
using namespace fair::mq;
|
||||||
using factoryType = std::shared_ptr<FairMQTransportFactory>;
|
|
||||||
|
|
||||||
factoryType factoryZMQ = FairMQTransportFactory::CreateTransportFactory("zeromq");
|
using FactoryType = shared_ptr<FairMQTransportFactory>;
|
||||||
factoryType factorySHM = FairMQTransportFactory::CreateTransportFactory("shmem");
|
|
||||||
|
|
||||||
struct testData
|
struct TestData
|
||||||
{
|
{
|
||||||
int i{1};
|
int i{1};
|
||||||
static int nallocated;
|
static int nallocated;
|
||||||
static int nallocations;
|
static int nallocations;
|
||||||
static int ndeallocations;
|
static int ndeallocations;
|
||||||
testData()
|
|
||||||
|
TestData()
|
||||||
{
|
{
|
||||||
++nallocated;
|
++nallocated;
|
||||||
++nallocations;
|
++nallocations;
|
||||||
}
|
}
|
||||||
testData(const testData& in)
|
|
||||||
|
TestData(const TestData& in)
|
||||||
: i{in.i}
|
: i{in.i}
|
||||||
{
|
{
|
||||||
++nallocated;
|
++nallocated;
|
||||||
++nallocations;
|
++nallocations;
|
||||||
}
|
}
|
||||||
testData(const testData&& in)
|
|
||||||
|
TestData(const TestData&& in)
|
||||||
: i{in.i}
|
: i{in.i}
|
||||||
{
|
{
|
||||||
++nallocated;
|
++nallocated;
|
||||||
++nallocations;
|
++nallocations;
|
||||||
}
|
}
|
||||||
testData(int in)
|
|
||||||
|
TestData(int in)
|
||||||
: i{in}
|
: i{in}
|
||||||
{
|
{
|
||||||
++nallocated;
|
++nallocated;
|
||||||
++nallocations;
|
++nallocations;
|
||||||
}
|
}
|
||||||
~testData()
|
|
||||||
|
~TestData()
|
||||||
{
|
{
|
||||||
--nallocated;
|
--nallocated;
|
||||||
++ndeallocations;
|
++ndeallocations;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int testData::nallocated = 0;
|
int TestData::nallocated = 0;
|
||||||
int testData::nallocations = 0;
|
int TestData::nallocations = 0;
|
||||||
int testData::ndeallocations = 0;
|
int TestData::ndeallocations = 0;
|
||||||
|
|
||||||
auto allocZMQ = factoryZMQ -> GetMemoryResource();
|
TEST(MemoryResources, transportAllocatorMap)
|
||||||
auto allocSHM = factorySHM -> GetMemoryResource();
|
|
||||||
|
|
||||||
TEST(MemoryResources, transportallocatormap)
|
|
||||||
{
|
{
|
||||||
|
size_t session{tools::UuidHash()};
|
||||||
|
ProgOptions config;
|
||||||
|
config.SetProperty<string>("session", to_string(session));
|
||||||
|
|
||||||
|
FactoryType factoryZMQ = FairMQTransportFactory::CreateTransportFactory("zeromq", fair::mq::tools::Uuid(), &config);
|
||||||
|
FactoryType factorySHM = FairMQTransportFactory::CreateTransportFactory("shmem", fair::mq::tools::Uuid(), &config);
|
||||||
|
|
||||||
|
auto allocZMQ = factoryZMQ->GetMemoryResource();
|
||||||
|
auto allocSHM = factorySHM->GetMemoryResource();
|
||||||
|
|
||||||
EXPECT_TRUE(allocZMQ != nullptr && allocSHM != allocZMQ);
|
EXPECT_TRUE(allocZMQ != nullptr && allocSHM != allocZMQ);
|
||||||
auto _tmp = factoryZMQ->GetMemoryResource();
|
auto _tmp = factoryZMQ->GetMemoryResource();
|
||||||
EXPECT_TRUE(_tmp == allocZMQ);
|
EXPECT_TRUE(_tmp == allocZMQ);
|
||||||
@@ -75,29 +92,45 @@ using namespace fair::mq::pmr;
|
|||||||
|
|
||||||
TEST(MemoryResources, allocator)
|
TEST(MemoryResources, allocator)
|
||||||
{
|
{
|
||||||
testData::nallocations = 0;
|
TestData::nallocations = 0;
|
||||||
testData::ndeallocations = 0;
|
TestData::ndeallocations = 0;
|
||||||
|
|
||||||
|
size_t session{tools::UuidHash()};
|
||||||
|
ProgOptions config;
|
||||||
|
config.SetProperty<string>("session", to_string(session));
|
||||||
|
|
||||||
|
FactoryType factoryZMQ = FairMQTransportFactory::CreateTransportFactory("zeromq", fair::mq::tools::Uuid(), &config);
|
||||||
|
|
||||||
|
auto allocZMQ = factoryZMQ->GetMemoryResource();
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<testData, polymorphic_allocator<testData>> v(
|
std::vector<TestData, polymorphic_allocator<TestData>> v(polymorphic_allocator<TestData>{allocZMQ});
|
||||||
polymorphic_allocator<testData>{allocZMQ});
|
|
||||||
v.reserve(3);
|
v.reserve(3);
|
||||||
EXPECT_TRUE(v.capacity() == 3);
|
EXPECT_TRUE(v.capacity() == 3);
|
||||||
EXPECT_TRUE(allocZMQ->getNumberOfMessages() == 1);
|
EXPECT_TRUE(allocZMQ->getNumberOfMessages() == 1);
|
||||||
v.emplace_back(1);
|
v.emplace_back(1);
|
||||||
v.emplace_back(2);
|
v.emplace_back(2);
|
||||||
v.emplace_back(3);
|
v.emplace_back(3);
|
||||||
EXPECT_TRUE((fair::mq::byte*)&(*v.end()) - (fair::mq::byte*)&(*v.begin()) == 3 * sizeof(testData));
|
EXPECT_TRUE((fair::mq::byte*)&(*v.end()) - (fair::mq::byte*)&(*v.begin()) == 3 * sizeof(TestData));
|
||||||
EXPECT_TRUE(testData::nallocated == 3);
|
EXPECT_TRUE(TestData::nallocated == 3);
|
||||||
}
|
}
|
||||||
EXPECT_TRUE(testData::nallocated == 0);
|
EXPECT_TRUE(TestData::nallocated == 0);
|
||||||
EXPECT_TRUE(testData::nallocations == testData::ndeallocations);
|
EXPECT_TRUE(TestData::nallocations == TestData::ndeallocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MemoryResources, getMessage)
|
TEST(MemoryResources, getMessage)
|
||||||
{
|
{
|
||||||
testData::nallocations = 0;
|
TestData::nallocations = 0;
|
||||||
testData::ndeallocations = 0;
|
TestData::ndeallocations = 0;
|
||||||
|
|
||||||
|
size_t session{tools::UuidHash()};
|
||||||
|
ProgOptions config;
|
||||||
|
config.SetProperty<string>("session", to_string(session));
|
||||||
|
|
||||||
|
FactoryType factoryZMQ = FairMQTransportFactory::CreateTransportFactory("zeromq", fair::mq::tools::Uuid(), &config);
|
||||||
|
FactoryType factorySHM = FairMQTransportFactory::CreateTransportFactory("shmem", fair::mq::tools::Uuid(), &config);
|
||||||
|
|
||||||
|
auto allocZMQ = factoryZMQ->GetMemoryResource();
|
||||||
|
|
||||||
FairMQMessagePtr message{nullptr};
|
FairMQMessagePtr message{nullptr};
|
||||||
|
|
||||||
@@ -105,8 +138,7 @@ TEST(MemoryResources, getMessage)
|
|||||||
|
|
||||||
// test message creation on the same channel it was allocated with
|
// test message creation on the same channel it was allocated with
|
||||||
{
|
{
|
||||||
std::vector<testData, polymorphic_allocator<testData>> v(
|
std::vector<TestData, polymorphic_allocator<TestData>> v(polymorphic_allocator<TestData>{allocZMQ});
|
||||||
polymorphic_allocator<testData>{allocZMQ});
|
|
||||||
v.emplace_back(1);
|
v.emplace_back(1);
|
||||||
v.emplace_back(2);
|
v.emplace_back(2);
|
||||||
v.emplace_back(3);
|
v.emplace_back(3);
|
||||||
@@ -115,14 +147,13 @@ TEST(MemoryResources, getMessage)
|
|||||||
EXPECT_TRUE(message != nullptr);
|
EXPECT_TRUE(message != nullptr);
|
||||||
EXPECT_TRUE(message->GetData() == vectorBeginPtr);
|
EXPECT_TRUE(message->GetData() == vectorBeginPtr);
|
||||||
}
|
}
|
||||||
EXPECT_TRUE(message->GetSize() == 3 * sizeof(testData));
|
EXPECT_TRUE(message->GetSize() == 3 * sizeof(TestData));
|
||||||
messageArray = static_cast<int*>(message->GetData());
|
messageArray = static_cast<int*>(message->GetData());
|
||||||
EXPECT_TRUE(messageArray[0] == 1 && messageArray[1] == 2 && messageArray[2] == 3);
|
EXPECT_TRUE(messageArray[0] == 1 && messageArray[1] == 2 && messageArray[2] == 3);
|
||||||
|
|
||||||
// test message creation on a different channel than it was allocated with
|
// test message creation on a different channel than it was allocated with
|
||||||
{
|
{
|
||||||
std::vector<testData, polymorphic_allocator<testData>> v(
|
std::vector<TestData, polymorphic_allocator<TestData>> v(polymorphic_allocator<TestData>{allocZMQ});
|
||||||
polymorphic_allocator<testData>{allocZMQ});
|
|
||||||
v.emplace_back(4);
|
v.emplace_back(4);
|
||||||
v.emplace_back(5);
|
v.emplace_back(5);
|
||||||
v.emplace_back(6);
|
v.emplace_back(6);
|
||||||
@@ -132,7 +163,7 @@ TEST(MemoryResources, getMessage)
|
|||||||
EXPECT_TRUE(message->GetData() != vectorBeginPtr);
|
EXPECT_TRUE(message->GetData() != vectorBeginPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(message->GetSize() == 3 * sizeof(testData));
|
EXPECT_TRUE(message->GetSize() == 3 * sizeof(TestData));
|
||||||
messageArray = static_cast<int*>(message->GetData());
|
messageArray = static_cast<int*>(message->GetData());
|
||||||
EXPECT_TRUE(messageArray[0] == 4 && messageArray[1] == 5 && messageArray[2] == 6);
|
EXPECT_TRUE(messageArray[0] == 4 && messageArray[1] == 5 && messageArray[2] == 6);
|
||||||
}
|
}
|
||||||
|
@@ -48,6 +48,7 @@ void RegionEventSubscriptions(const string& transport)
|
|||||||
ASSERT_EQ(factory->SubscribedToRegionEvents(), false);
|
ASSERT_EQ(factory->SubscribedToRegionEvents(), false);
|
||||||
factory->SubscribeToRegionEvents([&](FairMQRegionInfo info) {
|
factory->SubscribeToRegionEvents([&](FairMQRegionInfo info) {
|
||||||
LOG(warn) << ">>>" << info.event;
|
LOG(warn) << ">>>" << info.event;
|
||||||
|
LOG(warn) << "managed: " << info.managed;
|
||||||
LOG(warn) << "id: " << info.id;
|
LOG(warn) << "id: " << info.id;
|
||||||
LOG(warn) << "ptr: " << info.ptr;
|
LOG(warn) << "ptr: " << info.ptr;
|
||||||
LOG(warn) << "size: " << info.size;
|
LOG(warn) << "size: " << info.size;
|
||||||
|
@@ -361,7 +361,7 @@ TEST_F(Topology, AsyncSetPropertiesTimeout)
|
|||||||
|
|
||||||
topo.AsyncSetProperties({{"key1", "val1"}},
|
topo.AsyncSetProperties({{"key1", "val1"}},
|
||||||
"",
|
"",
|
||||||
std::chrono::milliseconds(1),
|
std::chrono::microseconds(1),
|
||||||
[=](std::error_code ec, sdk::FailedDevices) mutable {
|
[=](std::error_code ec, sdk::FailedDevices) mutable {
|
||||||
LOG(info) << ec;
|
LOG(info) << ec;
|
||||||
EXPECT_EQ(ec, MakeErrorCode(ErrorCode::OperationTimeout));
|
EXPECT_EQ(ec, MakeErrorCode(ErrorCode::OperationTimeout));
|
||||||
|
@@ -7,9 +7,16 @@
|
|||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include "runner.h"
|
#include "runner.h"
|
||||||
|
#include <FairMQChannel.h>
|
||||||
|
#include <FairMQLogger.h>
|
||||||
|
#include <FairMQTransportFactory.h>
|
||||||
|
#include <fairmq/ProgOptions.h>
|
||||||
#include <fairmq/Tools.h>
|
#include <fairmq/Tools.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <sstream> // std::stringstream
|
#include <sstream> // std::stringstream
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -18,6 +25,12 @@ using namespace std;
|
|||||||
using namespace fair::mq::test;
|
using namespace fair::mq::test;
|
||||||
using namespace fair::mq::tools;
|
using namespace fair::mq::tools;
|
||||||
|
|
||||||
|
void delayedInterruptor(FairMQTransportFactory& transport)
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
transport.Interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
auto RunTransferTimeout(string transport) -> void
|
auto RunTransferTimeout(string transport) -> void
|
||||||
{
|
{
|
||||||
size_t session{fair::mq::tools::UuidHash()};
|
size_t session{fair::mq::tools::UuidHash()};
|
||||||
@@ -31,6 +44,28 @@ auto RunTransferTimeout(string transport) -> void
|
|||||||
exit(res.exit_code);
|
exit(res.exit_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InterruptTransfer(const string& transport, const string& _address)
|
||||||
|
{
|
||||||
|
size_t session{fair::mq::tools::UuidHash()};
|
||||||
|
std::string address(fair::mq::tools::ToString(_address, "_", transport));
|
||||||
|
|
||||||
|
fair::mq::ProgOptions config;
|
||||||
|
config.SetProperty<string>("session", to_string(session));
|
||||||
|
|
||||||
|
auto factory = FairMQTransportFactory::CreateTransportFactory(transport, fair::mq::tools::Uuid(), &config);
|
||||||
|
|
||||||
|
FairMQChannel pull{"Pull", "pull", factory};
|
||||||
|
pull.Bind(address);
|
||||||
|
|
||||||
|
FairMQMessagePtr msg(pull.NewMessage());
|
||||||
|
|
||||||
|
auto t = thread(delayedInterruptor, ref(*factory));
|
||||||
|
|
||||||
|
auto result = pull.Receive(msg);
|
||||||
|
t.join();
|
||||||
|
ASSERT_EQ(result, static_cast<int>(fair::mq::TransferResult::interrupted));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(TransferTimeout, zeromq)
|
TEST(TransferTimeout, zeromq)
|
||||||
{
|
{
|
||||||
EXPECT_EXIT(RunTransferTimeout("zeromq"), ::testing::ExitedWithCode(0), "Transfer timeout test successfull");
|
EXPECT_EXIT(RunTransferTimeout("zeromq"), ::testing::ExitedWithCode(0), "Transfer timeout test successfull");
|
||||||
@@ -41,4 +76,14 @@ TEST(TransferTimeout, shmem)
|
|||||||
EXPECT_EXIT(RunTransferTimeout("shmem"), ::testing::ExitedWithCode(0), "Transfer timeout test successfull");
|
EXPECT_EXIT(RunTransferTimeout("shmem"), ::testing::ExitedWithCode(0), "Transfer timeout test successfull");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(InterruptTransfer, zeromq)
|
||||||
|
{
|
||||||
|
InterruptTransfer("zeromq", "ipc://test_interrupt_transfer");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(InterruptTransfer, shmem)
|
||||||
|
{
|
||||||
|
InterruptTransfer("shmem", "ipc://test_interrupt_transfer");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Reference in New Issue
Block a user