mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
Several FairMQ fixes and improvements:
- FairMQ: add possibility to poll on multiple channels. - FairMQ: include command channel when polling on blocking calls (for unblocking without termination). - FairMQ: move signal handler inside of FairMQDevice class (call FairMQDevice::CatchSignals() in the main function). - FairMQ: add 'bool CheckCurrentState(statename)' (instead of 'GetCurrentState() == statename' that cannot be thread safe). - FairMQDevice: add 'InteractiveStateLoop()' method that can be used to change states from the command line. - FairMQDevice: add automatic transition to IDLE state if Run() exits without an external event. - FairMQDevice: implement device reset. - FairMQDevice: use unordered_map for device channels. - FairMQChannel: improve address validation for channels. - FairMQChannel: add ExpectsAnotherPart() method to check if another msg part is expected (old approach still works). - FairMQ: remove invalid transition from the run files. - FairMQFileSink: disable ROOT termination signal handler. - Tutorial3: spawn xterm windows from start scripts without overlapping for better visibility. - FairMQ Examples: update protobuf test and move its files to a common directory. - FairMQStateMachine: improve feedback on invalid transitions (more readable).
This commit is contained in:
parent
d1bba61939
commit
1302e77a16
|
@ -6,7 +6,7 @@
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
configure_file(${CMAKE_SOURCE_DIR}/fairmq/options/ProgOptionTest/macro/bsampler-sink.json ${CMAKE_BINARY_DIR}/bin/config/example-bsampler-sink.json)
|
configure_file(${CMAKE_SOURCE_DIR}/fairmq/options/ProgOptionTest/macro/bsampler-sink.json ${CMAKE_BINARY_DIR}/bin/config/bsampler-sink.json)
|
||||||
configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/1-sampler-sink/sampler-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex1-sampler-sink.json)
|
configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/1-sampler-sink/sampler-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex1-sampler-sink.json)
|
||||||
configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/2-sampler-processor-sink/sampler-processor-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex2-sampler-processor-sink.json)
|
configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/2-sampler-processor-sink/sampler-processor-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex2-sampler-processor-sink.json)
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ Set(INCLUDE_DIRECTORIES
|
||||||
${CMAKE_SOURCE_DIR}/fairmq/examples/1-sampler-sink
|
${CMAKE_SOURCE_DIR}/fairmq/examples/1-sampler-sink
|
||||||
${CMAKE_SOURCE_DIR}/fairmq/examples/2-sampler-processor-sink
|
${CMAKE_SOURCE_DIR}/fairmq/examples/2-sampler-processor-sink
|
||||||
${CMAKE_SOURCE_DIR}/fairmq/examples/req-rep
|
${CMAKE_SOURCE_DIR}/fairmq/examples/req-rep
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||||
|
@ -27,7 +28,7 @@ Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||||
If(PROTOBUF_FOUND)
|
If(PROTOBUF_FOUND)
|
||||||
Set(INCLUDE_DIRECTORIES
|
Set(INCLUDE_DIRECTORIES
|
||||||
${INCLUDE_DIRECTORIES}
|
${INCLUDE_DIRECTORIES}
|
||||||
# # following directory is only for protobuf tests and is not essential part of FairMQ
|
# following directory is only for protobuf tests and is not essential part of FairMQ
|
||||||
# ${CMAKE_SOURCE_DIR}/fairmq/prototest
|
# ${CMAKE_SOURCE_DIR}/fairmq/prototest
|
||||||
)
|
)
|
||||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||||
|
@ -100,9 +101,18 @@ set(SRCS
|
||||||
|
|
||||||
if(PROTOBUF_FOUND)
|
if(PROTOBUF_FOUND)
|
||||||
# following source files are only for protobuf tests and are not essential part of FairMQ
|
# following source files are only for protobuf tests and are not essential part of FairMQ
|
||||||
|
# add_custom_command(
|
||||||
|
# OUTPUT
|
||||||
|
# ${CMAKE_CURRENT_BINARY_DIR}/payload.pb.h
|
||||||
|
# ${CMAKE_CURRENT_BINARY_DIR}/payload.pb.cc
|
||||||
|
# COMMAND
|
||||||
|
# ${SIMPATH}/bin/protoc -I=. --cpp_out=${CMAKE_CURRENT_BINARY_DIR} payload.proto
|
||||||
|
# WORKING_DIRECTORY
|
||||||
|
# ${CMAKE_SOURCE_DIR}/fairmq/prototest
|
||||||
|
# )
|
||||||
# set(SRCS
|
# set(SRCS
|
||||||
# ${SRCS}
|
# ${SRCS}
|
||||||
# "prototest/payload.pb.cc"
|
# ${CMAKE_CURRENT_BINARY_DIR}/payload.pb.cc
|
||||||
# "prototest/FairMQProtoSampler.cxx"
|
# "prototest/FairMQProtoSampler.cxx"
|
||||||
# "prototest/FairMQBinSampler.cxx"
|
# "prototest/FairMQBinSampler.cxx"
|
||||||
# "prototest/FairMQBinSink.cxx"
|
# "prototest/FairMQBinSink.cxx"
|
||||||
|
@ -209,10 +219,10 @@ set(Exe_Source
|
||||||
# if(PROTOBUF_FOUND)
|
# if(PROTOBUF_FOUND)
|
||||||
# set(Exe_Source
|
# set(Exe_Source
|
||||||
# ${Exe_Source}
|
# ${Exe_Source}
|
||||||
# run/runBinSampler.cxx
|
# prototest/runBinSampler.cxx
|
||||||
# run/runProtoSampler.cxx
|
# prototest/runProtoSampler.cxx
|
||||||
# run/runBinSink.cxx
|
# prototest/runBinSink.cxx
|
||||||
# run/runProtoSink.cxx
|
# prototest/runProtoSink.cxx
|
||||||
# )
|
# )
|
||||||
# endif(PROTOBUF_FOUND)
|
# endif(PROTOBUF_FOUND)
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,12 @@ FairMQChannel::FairMQChannel()
|
||||||
, fSndBufSize(1000)
|
, fSndBufSize(1000)
|
||||||
, fRcvBufSize(1000)
|
, fRcvBufSize(1000)
|
||||||
, fRateLogging(1)
|
, fRateLogging(1)
|
||||||
, fSocket()
|
, fSocket(nullptr)
|
||||||
, fChannelName("")
|
, fChannelName("")
|
||||||
, fIsValid(false)
|
, fIsValid(false)
|
||||||
|
, fPoller(nullptr)
|
||||||
|
, fCmdSocket(nullptr)
|
||||||
|
, fTransportFactory(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,13 +46,16 @@ FairMQChannel::FairMQChannel(const string& type, const string& method, const str
|
||||||
, fSndBufSize(1000)
|
, fSndBufSize(1000)
|
||||||
, fRcvBufSize(1000)
|
, fRcvBufSize(1000)
|
||||||
, fRateLogging(1)
|
, fRateLogging(1)
|
||||||
, fSocket()
|
, fSocket(nullptr)
|
||||||
, fChannelName("")
|
, fChannelName("")
|
||||||
, fIsValid(false)
|
, fIsValid(false)
|
||||||
|
, fPoller(nullptr)
|
||||||
|
, fCmdSocket(nullptr)
|
||||||
|
, fTransportFactory(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FairMQChannel::GetType()
|
std::string FairMQChannel::GetType() const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -58,11 +64,11 @@ std::string FairMQChannel::GetType()
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::GetType: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FairMQChannel::GetMethod()
|
std::string FairMQChannel::GetMethod() const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -71,11 +77,11 @@ std::string FairMQChannel::GetMethod()
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::GetMethod: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FairMQChannel::GetAddress()
|
std::string FairMQChannel::GetAddress() const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -84,11 +90,11 @@ std::string FairMQChannel::GetAddress()
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::GetAddress: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQChannel::GetSndBufSize()
|
int FairMQChannel::GetSndBufSize() const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -97,11 +103,11 @@ int FairMQChannel::GetSndBufSize()
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::GetSndBufSize: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQChannel::GetRcvBufSize()
|
int FairMQChannel::GetRcvBufSize() const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -110,11 +116,11 @@ int FairMQChannel::GetRcvBufSize()
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::GetRcvBufSize: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQChannel::GetRateLogging()
|
int FairMQChannel::GetRateLogging() const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -123,7 +129,7 @@ int FairMQChannel::GetRateLogging()
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::GetRateLogging: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,75 +138,86 @@ void FairMQChannel::UpdateType(const std::string& type)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fIsValid = false;
|
||||||
fType = type;
|
fType = type;
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::UpdateType: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQChannel::UpdateMethod(const std::string& method)
|
void FairMQChannel::UpdateMethod(const std::string& method)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fIsValid = false;
|
||||||
fMethod = method;
|
fMethod = method;
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::UpdateMethod: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQChannel::UpdateAddress(const std::string& address)
|
void FairMQChannel::UpdateAddress(const std::string& address)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fIsValid = false;
|
||||||
fAddress = address;
|
fAddress = address;
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::UpdateAddress: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQChannel::UpdateSndBufSize(const int sndBufSize)
|
void FairMQChannel::UpdateSndBufSize(const int sndBufSize)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fIsValid = false;
|
||||||
fSndBufSize = sndBufSize;
|
fSndBufSize = sndBufSize;
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::UpdateSndBufSize: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQChannel::UpdateRcvBufSize(const int rcvBufSize)
|
void FairMQChannel::UpdateRcvBufSize(const int rcvBufSize)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fIsValid = false;
|
||||||
fRcvBufSize = rcvBufSize;
|
fRcvBufSize = rcvBufSize;
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::UpdateRcvBufSize: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQChannel::UpdateRateLogging(const int rateLogging)
|
void FairMQChannel::UpdateRateLogging(const int rateLogging)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fIsValid = false;
|
||||||
fRateLogging = rateLogging;
|
fRateLogging = rateLogging;
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::UpdateRateLogging: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQChannel::IsValid()
|
bool FairMQChannel::IsValid() const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -209,7 +226,7 @@ bool FairMQChannel::IsValid()
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::IsValid: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +237,7 @@ bool FairMQChannel::ValidateChannel()
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << "Validating channel " << fChannelName << "... ";
|
ss << "Validating channel \"" << fChannelName << "\"... ";
|
||||||
|
|
||||||
if (fIsValid)
|
if (fIsValid)
|
||||||
{
|
{
|
||||||
|
@ -229,47 +246,88 @@ bool FairMQChannel::ValidateChannel()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate socket type
|
||||||
const string socketTypeNames[] = { "sub", "pub", "pull", "push", "req", "rep", "xsub", "xpub", "dealer", "router", "pair" };
|
const string socketTypeNames[] = { "sub", "pub", "pull", "push", "req", "rep", "xsub", "xpub", "dealer", "router", "pair" };
|
||||||
const set<string> socketTypes(socketTypeNames, socketTypeNames + sizeof(socketTypeNames) / sizeof(string));
|
const set<string> socketTypes(socketTypeNames, socketTypeNames + sizeof(socketTypeNames) / sizeof(string));
|
||||||
if (socketTypes.find(fType) == socketTypes.end())
|
if (socketTypes.find(fType) == socketTypes.end())
|
||||||
{
|
{
|
||||||
ss << "INVALID";
|
ss << "INVALID";
|
||||||
LOG(DEBUG) << ss.str();
|
LOG(DEBUG) << ss.str();
|
||||||
LOG(DEBUG) << "Invalid channel type: " << fType;
|
LOG(DEBUG) << "Invalid channel type: \"" << fType << "\"";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate socket method
|
||||||
const string socketMethodNames[] = { "bind", "connect" };
|
const string socketMethodNames[] = { "bind", "connect" };
|
||||||
const set<string> socketMethods(socketMethodNames, socketMethodNames + sizeof(socketMethodNames) / sizeof(string));
|
const set<string> socketMethods(socketMethodNames, socketMethodNames + sizeof(socketMethodNames) / sizeof(string));
|
||||||
if (socketMethods.find(fMethod) == socketMethods.end())
|
if (socketMethods.find(fMethod) == socketMethods.end())
|
||||||
{
|
{
|
||||||
ss << "INVALID";
|
ss << "INVALID";
|
||||||
LOG(DEBUG) << ss.str();
|
LOG(DEBUG) << ss.str();
|
||||||
LOG(DEBUG) << "Invalid channel method: " << fMethod;
|
LOG(DEBUG) << "Invalid channel method: \"" << fMethod << "\"";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate socket address
|
||||||
if (fAddress == "unspecified" || fAddress == "")
|
if (fAddress == "unspecified" || fAddress == "")
|
||||||
{
|
{
|
||||||
ss << "INVALID";
|
ss << "INVALID";
|
||||||
LOG(DEBUG) << ss.str();
|
LOG(DEBUG) << ss.str();
|
||||||
LOG(DEBUG) << "invalid channel address: " << fAddress;
|
LOG(DEBUG) << "invalid channel address: \"" << fAddress << "\"";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check if address is a tcp or ipc address
|
||||||
|
if (fAddress.compare(0, 6, "tcp://") == 0)
|
||||||
|
{
|
||||||
|
// check if TCP address contains port delimiter
|
||||||
|
string addressString = fAddress.substr(6);
|
||||||
|
if (addressString.find(":") == string::npos)
|
||||||
|
{
|
||||||
|
ss << "INVALID";
|
||||||
|
LOG(DEBUG) << ss.str();
|
||||||
|
LOG(DEBUG) << "invalid channel address: \"" << fAddress << "\" (missing port?)";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (fAddress.compare(0, 6, "ipc://") == 0)
|
||||||
|
{
|
||||||
|
// check if IPC address is not empty
|
||||||
|
string addressString = fAddress.substr(6);
|
||||||
|
if (addressString == "")
|
||||||
|
{
|
||||||
|
ss << "INVALID";
|
||||||
|
LOG(DEBUG) << ss.str();
|
||||||
|
LOG(DEBUG) << "invalid channel address: \"" << fAddress << "\" (empty IPC address?)";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if neither TCP or IPC is specified, return invalid
|
||||||
|
ss << "INVALID";
|
||||||
|
LOG(DEBUG) << ss.str();
|
||||||
|
LOG(DEBUG) << "invalid channel address: \"" << fAddress << "\" (missing protocol specifier?)";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate socket buffer size for sending
|
||||||
if (fSndBufSize < 0)
|
if (fSndBufSize < 0)
|
||||||
{
|
{
|
||||||
ss << "INVALID";
|
ss << "INVALID";
|
||||||
LOG(DEBUG) << ss.str();
|
LOG(DEBUG) << ss.str();
|
||||||
LOG(DEBUG) << "invalid channel send buffer size: " << fSndBufSize;
|
LOG(DEBUG) << "invalid channel send buffer size: \"" << fSndBufSize << "\"";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate socket buffer size for receiving
|
||||||
if (fRcvBufSize < 0)
|
if (fRcvBufSize < 0)
|
||||||
{
|
{
|
||||||
ss << "INVALID";
|
ss << "INVALID";
|
||||||
LOG(DEBUG) << ss.str();
|
LOG(DEBUG) << ss.str();
|
||||||
LOG(DEBUG) << "invalid channel receive buffer size: " << fRcvBufSize;
|
LOG(DEBUG) << "invalid channel receive buffer size: \"" << fRcvBufSize << "\"";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,35 +338,160 @@ bool FairMQChannel::ValidateChannel()
|
||||||
}
|
}
|
||||||
catch (boost::exception& e)
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << "Exception caught in FairMQChannel::ValidateChannel: " << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FairMQChannel::InitCommandInterface(FairMQTransportFactory* factory)
|
||||||
|
{
|
||||||
|
fTransportFactory = factory;
|
||||||
|
|
||||||
|
fCmdSocket = fTransportFactory->CreateSocket("sub", "device-commands", 1);
|
||||||
|
fCmdSocket->Connect("inproc://commands");
|
||||||
|
|
||||||
|
fPoller = fTransportFactory->CreatePoller(*fSocket, *fCmdSocket);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void FairMQChannel::ResetChannel()
|
void FairMQChannel::ResetChannel()
|
||||||
{
|
{
|
||||||
// TODO: implement resetting
|
fIsValid = false;
|
||||||
|
// TODO: implement channel resetting
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQChannel::Send(FairMQMessage* msg, const string& flag)
|
int FairMQChannel::Send(FairMQMessage* msg, const string& flag) const
|
||||||
|
{
|
||||||
|
if (flag == "")
|
||||||
|
{
|
||||||
|
fPoller->Poll(-1);
|
||||||
|
|
||||||
|
if (fPoller->CheckInput(0))
|
||||||
|
{
|
||||||
|
HandleCommand();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fPoller->CheckOutput(1))
|
||||||
|
{
|
||||||
|
return fSocket->Send(msg, flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return fSocket->Send(msg, flag);
|
return fSocket->Send(msg, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQChannel::Send(FairMQMessage* msg, const int flags)
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FairMQChannel::Send(FairMQMessage* msg, const int flags) const
|
||||||
|
{
|
||||||
|
if (flags == 0)
|
||||||
|
{
|
||||||
|
fPoller->Poll(-1);
|
||||||
|
|
||||||
|
if (fPoller->CheckInput(0))
|
||||||
|
{
|
||||||
|
HandleCommand();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fPoller->CheckOutput(1))
|
||||||
|
{
|
||||||
|
return fSocket->Send(msg, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return fSocket->Send(msg, flags);
|
return fSocket->Send(msg, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQChannel::Receive(FairMQMessage* msg, const string& flag)
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FairMQChannel::Receive(FairMQMessage* msg, const string& flag) const
|
||||||
|
{
|
||||||
|
if (flag == "")
|
||||||
|
{
|
||||||
|
fPoller->Poll(-1);
|
||||||
|
|
||||||
|
if (fPoller->CheckInput(0))
|
||||||
|
{
|
||||||
|
HandleCommand();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fPoller->CheckInput(1))
|
||||||
|
{
|
||||||
|
return fSocket->Receive(msg, flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return fSocket->Receive(msg, flag);
|
return fSocket->Receive(msg, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQChannel::Receive(FairMQMessage* msg, const int flags)
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FairMQChannel::Receive(FairMQMessage* msg, const int flags) const
|
||||||
|
{
|
||||||
|
if (flags == 0)
|
||||||
|
{
|
||||||
|
fPoller->Poll(-1);
|
||||||
|
|
||||||
|
if (fPoller->CheckInput(0))
|
||||||
|
{
|
||||||
|
HandleCommand();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fPoller->CheckInput(1))
|
||||||
|
{
|
||||||
|
return fSocket->Receive(msg, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return fSocket->Receive(msg, flags);
|
return fSocket->Receive(msg, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FairMQChannel::ExpectsAnotherPart() const
|
||||||
|
{
|
||||||
|
int64_t more = 0;
|
||||||
|
size_t more_size = sizeof more;
|
||||||
|
|
||||||
|
if (fSocket)
|
||||||
|
{
|
||||||
|
fSocket->GetOption("rcv-more", &more, &more_size);
|
||||||
|
if (more)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool FairMQChannel::HandleCommand() const
|
||||||
|
{
|
||||||
|
FairMQMessage* cmd = fTransportFactory->CreateMessage();
|
||||||
|
fCmdSocket->Receive(cmd, 0);
|
||||||
|
delete cmd;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
FairMQChannel::~FairMQChannel()
|
FairMQChannel::~FairMQChannel()
|
||||||
{
|
{
|
||||||
|
delete fCmdSocket;
|
||||||
|
delete fPoller;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,12 @@
|
||||||
|
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
|
|
||||||
|
#include "FairMQTransportFactory.h"
|
||||||
#include "FairMQSocket.h"
|
#include "FairMQSocket.h"
|
||||||
|
#include "FairMQPoller.h"
|
||||||
|
|
||||||
|
class FairMQPoller;
|
||||||
|
class FairMQTransportFactory;
|
||||||
|
|
||||||
class FairMQChannel
|
class FairMQChannel
|
||||||
{
|
{
|
||||||
|
@ -30,12 +35,12 @@ class FairMQChannel
|
||||||
FairMQChannel(const std::string& type, const std::string& method, const std::string& address);
|
FairMQChannel(const std::string& type, const std::string& method, const std::string& address);
|
||||||
virtual ~FairMQChannel();
|
virtual ~FairMQChannel();
|
||||||
|
|
||||||
std::string GetType();
|
std::string GetType() const;
|
||||||
std::string GetMethod();
|
std::string GetMethod() const;
|
||||||
std::string GetAddress();
|
std::string GetAddress() const;
|
||||||
int GetSndBufSize();
|
int GetSndBufSize() const;
|
||||||
int GetRcvBufSize();
|
int GetRcvBufSize() const;
|
||||||
int GetRateLogging();
|
int GetRateLogging() const;
|
||||||
|
|
||||||
void UpdateType(const std::string& type);
|
void UpdateType(const std::string& type);
|
||||||
void UpdateMethod(const std::string& method);
|
void UpdateMethod(const std::string& method);
|
||||||
|
@ -44,19 +49,24 @@ class FairMQChannel
|
||||||
void UpdateRcvBufSize(const int rcvBufSize);
|
void UpdateRcvBufSize(const int rcvBufSize);
|
||||||
void UpdateRateLogging(const int rateLogging);
|
void UpdateRateLogging(const int rateLogging);
|
||||||
|
|
||||||
bool IsValid();
|
bool IsValid() const;
|
||||||
|
|
||||||
bool ValidateChannel();
|
bool ValidateChannel();
|
||||||
|
bool InitCommandInterface(FairMQTransportFactory* factory);
|
||||||
|
|
||||||
void ResetChannel();
|
void ResetChannel();
|
||||||
|
|
||||||
FairMQSocket* fSocket;
|
FairMQSocket* fSocket;
|
||||||
|
|
||||||
// Wrappers for the socket methods to simplify the usage of channels
|
// Wrappers for the socket methods to simplify the usage of channels
|
||||||
int Send(FairMQMessage* msg, const std::string& flag = "");
|
int Send(FairMQMessage* msg, const std::string& flag = "") const;
|
||||||
int Send(FairMQMessage* msg, const int flags);
|
int Send(FairMQMessage* msg, const int flags) const;
|
||||||
int Receive(FairMQMessage* msg, const std::string& flag = "");
|
int Receive(FairMQMessage* msg, const std::string& flag = "") const;
|
||||||
int Receive(FairMQMessage* msg, const int flags);
|
int Receive(FairMQMessage* msg, const int flags) const;
|
||||||
|
|
||||||
|
/// Checks if the socket is expecting to receive another part of a multipart message.
|
||||||
|
/// \return Return true if the socket expects another part of a multipart message and false otherwise.
|
||||||
|
bool ExpectsAnotherPart() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string fType;
|
std::string fType;
|
||||||
|
@ -69,6 +79,13 @@ class FairMQChannel
|
||||||
std::string fChannelName;
|
std::string fChannelName;
|
||||||
bool fIsValid;
|
bool fIsValid;
|
||||||
|
|
||||||
|
FairMQPoller* fPoller;
|
||||||
|
FairMQSocket* fCmdSocket;
|
||||||
|
|
||||||
|
FairMQTransportFactory* fTransportFactory;
|
||||||
|
|
||||||
|
bool HandleCommand() const;
|
||||||
|
|
||||||
// use static mutex to make the class easily copyable
|
// use static mutex to make the class easily copyable
|
||||||
// implication: same mutex is used for all instances of the class
|
// implication: same mutex is used for all instances of the class
|
||||||
// this does not hurt much, because mutex is used only during initialization with very low contention
|
// this does not hurt much, because mutex is used only during initialization with very low contention
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <algorithm> // for std::sort()
|
#include <algorithm> // for std::sort()
|
||||||
|
#include <csignal> // for catching system signals
|
||||||
|
|
||||||
|
#include <termios.h> // for the InteractiveStateLoop
|
||||||
|
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <boost/random/mersenne_twister.hpp> // for choosing random port in range
|
#include <boost/random/mersenne_twister.hpp> // for choosing random port in range
|
||||||
|
@ -25,6 +28,13 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
// boost::function and a wrapper to catch the signals
|
||||||
|
boost::function<void(int)> sigHandler;
|
||||||
|
static void CallSignalHandler(int signal)
|
||||||
|
{
|
||||||
|
sigHandler(signal);
|
||||||
|
}
|
||||||
|
|
||||||
FairMQDevice::FairMQDevice()
|
FairMQDevice::FairMQDevice()
|
||||||
: fChannels()
|
: fChannels()
|
||||||
, fId()
|
, fId()
|
||||||
|
@ -33,26 +43,60 @@ FairMQDevice::FairMQDevice()
|
||||||
, fPortRangeMin(22000)
|
, fPortRangeMin(22000)
|
||||||
, fPortRangeMax(32000)
|
, fPortRangeMax(32000)
|
||||||
, fLogIntervalInMs(1000)
|
, fLogIntervalInMs(1000)
|
||||||
, fCommandSocket()
|
, fCmdSocket(nullptr)
|
||||||
, fTransportFactory(NULL)
|
, fTransportFactory(nullptr)
|
||||||
, fInitialValidationFinished(false)
|
, fInitialValidationFinished(false)
|
||||||
, fInitialValidationCondition()
|
, fInitialValidationCondition()
|
||||||
, fInitialValidationMutex()
|
, fInitialValidationMutex()
|
||||||
|
, fCatchingSignals(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FairMQDevice::CatchSignals()
|
||||||
|
{
|
||||||
|
if (!fCatchingSignals)
|
||||||
|
{
|
||||||
|
// setup signal catching
|
||||||
|
sigHandler = std::bind1st(std::mem_fun(&FairMQDevice::SignalHandler), this);
|
||||||
|
struct sigaction action;
|
||||||
|
action.sa_handler = CallSignalHandler;
|
||||||
|
action.sa_flags = 0;
|
||||||
|
sigemptyset(&action.sa_mask);
|
||||||
|
sigaction(SIGINT, &action, NULL);
|
||||||
|
sigaction(SIGTERM, &action, NULL);
|
||||||
|
|
||||||
|
fCatchingSignals = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FairMQDevice::SignalHandler(int signal)
|
||||||
|
{
|
||||||
|
LOG(INFO) << "Caught signal " << signal;
|
||||||
|
|
||||||
|
ChangeState(STOP);
|
||||||
|
|
||||||
|
ChangeState(RESET_TASK);
|
||||||
|
WaitForEndOfState(RESET_TASK);
|
||||||
|
|
||||||
|
ChangeState(RESET_DEVICE);
|
||||||
|
WaitForEndOfState(RESET_DEVICE);
|
||||||
|
|
||||||
|
ChangeState(END);
|
||||||
|
}
|
||||||
|
|
||||||
void FairMQDevice::InitWrapper()
|
void FairMQDevice::InitWrapper()
|
||||||
{
|
{
|
||||||
LOG(INFO) << "DEVICE: Initializing...";
|
if (!fCmdSocket)
|
||||||
|
{
|
||||||
fCommandSocket = fTransportFactory->CreateSocket("pair", "device-commands", 1);
|
fCmdSocket = fTransportFactory->CreateSocket("pub", "device-commands", 1);
|
||||||
fCommandSocket->Bind("inproc://commands");
|
fCmdSocket->Bind("inproc://commands");
|
||||||
|
}
|
||||||
|
|
||||||
// List to store the uninitialized channels.
|
// List to store the uninitialized channels.
|
||||||
list<FairMQChannel*> uninitializedChannels;
|
list<FairMQChannel*> uninitializedChannels;
|
||||||
for (map< string,vector<FairMQChannel> >::iterator mi = fChannels.begin(); mi != fChannels.end(); ++mi)
|
for (auto mi = fChannels.begin(); mi != fChannels.end(); ++mi)
|
||||||
{
|
{
|
||||||
for (vector<FairMQChannel>::iterator vi = (mi->second).begin(); vi != (mi->second).end(); ++vi)
|
for (auto vi = (mi->second).begin(); vi != (mi->second).end(); ++vi)
|
||||||
{
|
{
|
||||||
// set channel name: name + vector index
|
// set channel name: name + vector index
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
|
@ -66,8 +110,9 @@ void FairMQDevice::InitWrapper()
|
||||||
// go over the list of channels until all are initialized (and removed from the uninitialized list)
|
// go over the list of channels until all are initialized (and removed from the uninitialized list)
|
||||||
int numAttempts = 0;
|
int numAttempts = 0;
|
||||||
int maxAttempts = fMaxInitializationTime;
|
int maxAttempts = fMaxInitializationTime;
|
||||||
do {
|
do
|
||||||
list<FairMQChannel*>::iterator itr = uninitializedChannels.begin();
|
{
|
||||||
|
auto itr = uninitializedChannels.begin();
|
||||||
|
|
||||||
while (itr != uninitializedChannels.end())
|
while (itr != uninitializedChannels.end())
|
||||||
{
|
{
|
||||||
|
@ -75,6 +120,7 @@ void FairMQDevice::InitWrapper()
|
||||||
{
|
{
|
||||||
if (InitChannel(*(*itr)))
|
if (InitChannel(*(*itr)))
|
||||||
{
|
{
|
||||||
|
(*itr)->InitCommandInterface(fTransportFactory);
|
||||||
uninitializedChannels.erase(itr++);
|
uninitializedChannels.erase(itr++);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -89,7 +135,7 @@ void FairMQDevice::InitWrapper()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify parent thread about end of processing.
|
// notify parent thread about completion of first validation.
|
||||||
boost::lock_guard<boost::mutex> lock(fInitialValidationMutex);
|
boost::lock_guard<boost::mutex> lock(fInitialValidationMutex);
|
||||||
fInitialValidationFinished = true;
|
fInitialValidationFinished = true;
|
||||||
fInitialValidationCondition.notify_one();
|
fInitialValidationCondition.notify_one();
|
||||||
|
@ -106,7 +152,6 @@ void FairMQDevice::InitWrapper()
|
||||||
{
|
{
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (!uninitializedChannels.empty());
|
} while (!uninitializedChannels.empty());
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
@ -134,7 +179,7 @@ void FairMQDevice::Init()
|
||||||
|
|
||||||
bool FairMQDevice::InitChannel(FairMQChannel& ch)
|
bool FairMQDevice::InitChannel(FairMQChannel& ch)
|
||||||
{
|
{
|
||||||
LOG(DEBUG) << "Initializing channel " << ch.fChannelName << " to <" << ch.fType << "> data";
|
LOG(DEBUG) << "Initializing channel " << ch.fChannelName << " (" << ch.fType << ")";
|
||||||
// initialize the socket
|
// initialize the socket
|
||||||
ch.fSocket = fTransportFactory->CreateSocket(ch.fType, ch.fChannelName, 1);
|
ch.fSocket = fTransportFactory->CreateSocket(ch.fType, ch.fChannelName, 1);
|
||||||
// set high water marks
|
// set high water marks
|
||||||
|
@ -211,15 +256,15 @@ void FairMQDevice::SortChannel(const string& name, const bool reindex)
|
||||||
{
|
{
|
||||||
if (fChannels.find(name) != fChannels.end())
|
if (fChannels.find(name) != fChannels.end())
|
||||||
{
|
{
|
||||||
sort(fChannels[name].begin(), fChannels[name].end(), SortSocketsByAddress);
|
sort(fChannels.at(name).begin(), fChannels.at(name).end(), SortSocketsByAddress);
|
||||||
|
|
||||||
if (reindex)
|
if (reindex)
|
||||||
{
|
{
|
||||||
for (vector<FairMQChannel>::iterator vi = fChannels[name].begin(); vi != fChannels[name].end(); ++vi)
|
for (auto vi = fChannels.at(name).begin(); vi != fChannels.at(name).end(); ++vi)
|
||||||
{
|
{
|
||||||
// set channel name: name + vector index
|
// set channel name: name + vector index
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << name << "[" << vi - fChannels[name].begin() << "]";
|
ss << name << "[" << vi - fChannels.at(name).begin() << "]";
|
||||||
vi->fChannelName = ss.str();
|
vi->fChannelName = ss.str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +279,7 @@ void FairMQDevice::PrintChannel(const string& name)
|
||||||
{
|
{
|
||||||
if (fChannels.find(name) != fChannels.end())
|
if (fChannels.find(name) != fChannels.end())
|
||||||
{
|
{
|
||||||
for (vector<FairMQChannel>::iterator vi = fChannels[name].begin(); vi != fChannels[name].end(); ++vi)
|
for (auto vi = fChannels[name].begin(); vi != fChannels[name].end(); ++vi)
|
||||||
{
|
{
|
||||||
LOG(INFO) << vi->fChannelName << ": "
|
LOG(INFO) << vi->fChannelName << ": "
|
||||||
<< vi->fType << " | "
|
<< vi->fType << " | "
|
||||||
|
@ -269,6 +314,11 @@ void FairMQDevice::RunWrapper()
|
||||||
LOG(ERROR) << e.what();
|
LOG(ERROR) << e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CheckCurrentState(RUNNING))
|
||||||
|
{
|
||||||
|
ChangeState(internal_READY);
|
||||||
|
}
|
||||||
|
|
||||||
// notify parent thread about end of processing.
|
// notify parent thread about end of processing.
|
||||||
boost::lock_guard<boost::mutex> lock(fStateMutex);
|
boost::lock_guard<boost::mutex> lock(fStateMutex);
|
||||||
fStateFinished = true;
|
fStateFinished = true;
|
||||||
|
@ -281,7 +331,7 @@ void FairMQDevice::Run()
|
||||||
|
|
||||||
void FairMQDevice::Pause()
|
void FairMQDevice::Pause()
|
||||||
{
|
{
|
||||||
while (GetCurrentState() == PAUSED)
|
while (CheckCurrentState(PAUSED))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -296,38 +346,6 @@ void FairMQDevice::Pause()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQDevice::ResetTaskWrapper()
|
|
||||||
{
|
|
||||||
ResetTask();
|
|
||||||
|
|
||||||
ChangeState(internal_DEVICE_READY);
|
|
||||||
|
|
||||||
// notify parent thread about end of processing.
|
|
||||||
boost::lock_guard<boost::mutex> lock(fStateMutex);
|
|
||||||
fStateFinished = true;
|
|
||||||
fStateCondition.notify_one();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQDevice::ResetTask()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQDevice::ResetWrapper()
|
|
||||||
{
|
|
||||||
Reset();
|
|
||||||
|
|
||||||
ChangeState(internal_IDLE);
|
|
||||||
|
|
||||||
// notify parent thread about end of processing.
|
|
||||||
boost::lock_guard<boost::mutex> lock(fStateMutex);
|
|
||||||
fStateFinished = true;
|
|
||||||
fStateCondition.notify_one();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQDevice::Reset()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method for setting properties represented as a string.
|
// Method for setting properties represented as a string.
|
||||||
void FairMQDevice::SetProperty(const int key, const string& value)
|
void FairMQDevice::SetProperty(const int key, const string& value)
|
||||||
{
|
{
|
||||||
|
@ -417,10 +435,10 @@ void FairMQDevice::LogSocketRates()
|
||||||
vector<string> filteredChannelNames;
|
vector<string> filteredChannelNames;
|
||||||
|
|
||||||
// iterate over the channels map
|
// iterate over the channels map
|
||||||
for (map< string,vector<FairMQChannel> >::iterator mi = fChannels.begin(); mi != fChannels.end(); ++mi)
|
for (auto mi = fChannels.begin(); mi != fChannels.end(); ++mi)
|
||||||
{
|
{
|
||||||
// iterate over the channels vector
|
// iterate over the channels vector
|
||||||
for (vector<FairMQChannel>::iterator vi = (mi->second).begin(); vi != (mi->second).end(); ++vi)
|
for (auto vi = (mi->second).begin(); vi != (mi->second).end(); ++vi)
|
||||||
{
|
{
|
||||||
if (vi->fRateLogging == 1)
|
if (vi->fRateLogging == 1)
|
||||||
{
|
{
|
||||||
|
@ -449,7 +467,7 @@ void FairMQDevice::LogSocketRates()
|
||||||
vector<double> msgPerSecOut(numFilteredSockets);
|
vector<double> msgPerSecOut(numFilteredSockets);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (vector<FairMQSocket*>::iterator itr = filteredSockets.begin(); itr != filteredSockets.end(); ++itr)
|
for (auto itr = filteredSockets.begin(); itr != filteredSockets.end(); ++itr)
|
||||||
{
|
{
|
||||||
bytesIn.at(i) = (*itr)->GetBytesRx();
|
bytesIn.at(i) = (*itr)->GetBytesRx();
|
||||||
bytesOut.at(i) = (*itr)->GetBytesTx();
|
bytesOut.at(i) = (*itr)->GetBytesTx();
|
||||||
|
@ -460,7 +478,7 @@ void FairMQDevice::LogSocketRates()
|
||||||
|
|
||||||
t0 = get_timestamp();
|
t0 = get_timestamp();
|
||||||
|
|
||||||
while (GetCurrentState() == RUNNING)
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -470,7 +488,7 @@ void FairMQDevice::LogSocketRates()
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (vector<FairMQSocket*>::iterator itr = filteredSockets.begin(); itr != filteredSockets.end(); itr++)
|
for (auto itr = filteredSockets.begin(); itr != filteredSockets.end(); itr++)
|
||||||
{
|
{
|
||||||
bytesInNew.at(i) = (*itr)->GetBytesRx();
|
bytesInNew.at(i) = (*itr)->GetBytesRx();
|
||||||
mbPerSecIn.at(i) = ((double)(bytesInNew.at(i) - bytesIn.at(i)) / (1024. * 1024.)) / (double)msSinceLastLog * 1000.;
|
mbPerSecIn.at(i) = ((double)(bytesInNew.at(i) - bytesIn.at(i)) / (1024. * 1024.)) / (double)msSinceLastLog * 1000.;
|
||||||
|
@ -508,11 +526,148 @@ void FairMQDevice::LogSocketRates()
|
||||||
// LOG(DEBUG) << "FairMQDevice::LogSocketRates() stopping";
|
// LOG(DEBUG) << "FairMQDevice::LogSocketRates() stopping";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FairMQDevice::InteractiveStateLoop()
|
||||||
|
{
|
||||||
|
char c; // hold the user console input
|
||||||
|
bool running = true;
|
||||||
|
|
||||||
|
struct termios t;
|
||||||
|
tcgetattr(STDIN_FILENO, &t); // get the current terminal I/O structure
|
||||||
|
t.c_lflag &= ~ICANON; // disable canonical input
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &t); // apply the new settings
|
||||||
|
|
||||||
|
PrintInteractiveStateLoopHelp();
|
||||||
|
|
||||||
|
while (running && cin >> c)
|
||||||
|
{
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'i':
|
||||||
|
LOG(INFO) << "[i] init device";
|
||||||
|
ChangeState("INIT_DEVICE");
|
||||||
|
break;
|
||||||
|
case 'j':
|
||||||
|
LOG(INFO) << "[j] init task";
|
||||||
|
ChangeState("INIT_TASK");
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
LOG(INFO) << "[p] pause";
|
||||||
|
ChangeState("PAUSE");
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
LOG(INFO) << "[r] run";
|
||||||
|
ChangeState("RUN");
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
LOG(INFO) << "[s] stop";
|
||||||
|
ChangeState("STOP");
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
LOG(INFO) << "[t] reset task";
|
||||||
|
ChangeState("RESET_TASK");
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
LOG(INFO) << "[d] reset device";
|
||||||
|
ChangeState("RESET_DEVICE");
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
LOG(INFO) << "[h] help";
|
||||||
|
PrintInteractiveStateLoopHelp();
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
LOG(INFO) << "[q] end";
|
||||||
|
ChangeState("END");
|
||||||
|
if (CheckCurrentState("EXITING"))
|
||||||
|
{
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOG(INFO) << "Invalid input: [" << c << "]";
|
||||||
|
PrintInteractiveStateLoopHelp();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tcgetattr(STDIN_FILENO, &t); // get the current terminal I/O structure
|
||||||
|
t.c_lflag |= ICANON; // re-enable canonical input
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &t); // apply the new settings
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FairMQDevice::PrintInteractiveStateLoopHelp()
|
||||||
|
{
|
||||||
|
LOG(INFO) << "Use keys to control the state machine:";
|
||||||
|
LOG(INFO) << "[h] help, [p] pause, [r] run, [s] stop, [t] reset task, [d] reset device, [q] end, [j] init task, [i] init device";
|
||||||
|
}
|
||||||
|
|
||||||
void FairMQDevice::SendCommand(const string& command)
|
void FairMQDevice::SendCommand(const string& command)
|
||||||
{
|
{
|
||||||
FairMQMessage* cmd = fTransportFactory->CreateMessage(command.size());
|
FairMQMessage* cmd = fTransportFactory->CreateMessage(command.size());
|
||||||
memcpy(cmd->GetData(), command.c_str(), command.size());
|
memcpy(cmd->GetData(), command.c_str(), command.size());
|
||||||
fCommandSocket->Send(cmd, 0);
|
fCmdSocket->Send(cmd, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FairMQDevice::ResetTaskWrapper()
|
||||||
|
{
|
||||||
|
ResetTask();
|
||||||
|
|
||||||
|
ChangeState(internal_DEVICE_READY);
|
||||||
|
|
||||||
|
// notify parent thread about end of processing.
|
||||||
|
boost::lock_guard<boost::mutex> lock(fStateMutex);
|
||||||
|
fStateFinished = true;
|
||||||
|
fStateCondition.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FairMQDevice::ResetTask()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FairMQDevice::ResetWrapper()
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
|
||||||
|
ChangeState(internal_IDLE);
|
||||||
|
|
||||||
|
// notify parent thread about end of processing.
|
||||||
|
boost::lock_guard<boost::mutex> lock(fStateMutex);
|
||||||
|
fStateFinished = true;
|
||||||
|
fStateCondition.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FairMQDevice::Reset()
|
||||||
|
{
|
||||||
|
LOG(DEBUG) << "Resetting Device...";
|
||||||
|
|
||||||
|
// iterate over the channels map
|
||||||
|
for (auto mi = fChannels.begin(); mi != fChannels.end(); ++mi)
|
||||||
|
{
|
||||||
|
// iterate over the channels vector
|
||||||
|
for (auto vi = (mi->second).begin(); vi != (mi->second).end(); ++vi)
|
||||||
|
{
|
||||||
|
vi->fSocket->Close();
|
||||||
|
delete vi->fSocket;
|
||||||
|
vi->fSocket = nullptr;
|
||||||
|
|
||||||
|
delete vi->fPoller;
|
||||||
|
vi->fPoller = nullptr;
|
||||||
|
|
||||||
|
vi->fCmdSocket->Close();
|
||||||
|
delete vi->fCmdSocket;
|
||||||
|
vi->fCmdSocket = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(DEBUG) << "Device reset finished!";
|
||||||
|
}
|
||||||
|
|
||||||
|
void FairMQDevice::Terminate()
|
||||||
|
{
|
||||||
|
// Termination signal has to be sent only once to any socket.
|
||||||
|
if (fCmdSocket)
|
||||||
|
{
|
||||||
|
fCmdSocket->Terminate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQDevice::Shutdown()
|
void FairMQDevice::Shutdown()
|
||||||
|
@ -520,37 +675,54 @@ void FairMQDevice::Shutdown()
|
||||||
LOG(DEBUG) << "Closing sockets...";
|
LOG(DEBUG) << "Closing sockets...";
|
||||||
|
|
||||||
// iterate over the channels map
|
// iterate over the channels map
|
||||||
for (map< string,vector<FairMQChannel> >::iterator mi = fChannels.begin(); mi != fChannels.end(); ++mi)
|
for (auto mi = fChannels.begin(); mi != fChannels.end(); ++mi)
|
||||||
{
|
{
|
||||||
// iterate over the channels vector
|
// iterate over the channels vector
|
||||||
for (vector<FairMQChannel>::iterator vi = (mi->second).begin(); vi != (mi->second).end(); ++vi)
|
for (auto vi = (mi->second).begin(); vi != (mi->second).end(); ++vi)
|
||||||
|
{
|
||||||
|
if (vi->fSocket)
|
||||||
{
|
{
|
||||||
vi->fSocket->Close();
|
vi->fSocket->Close();
|
||||||
}
|
}
|
||||||
|
if (vi->fCmdSocket)
|
||||||
|
{
|
||||||
|
vi->fCmdSocket->Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fCommandSocket->Close();
|
if (fCmdSocket)
|
||||||
|
{
|
||||||
|
fCmdSocket->Close();
|
||||||
|
}
|
||||||
|
|
||||||
LOG(DEBUG) << "Closed all sockets!";
|
LOG(DEBUG) << "Closed all sockets!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQDevice::Terminate()
|
|
||||||
{
|
|
||||||
// Termination signal has to be sent only once to any socket.
|
|
||||||
fCommandSocket->Terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
FairMQDevice::~FairMQDevice()
|
FairMQDevice::~FairMQDevice()
|
||||||
{
|
{
|
||||||
// iterate over the channels map
|
// iterate over the channels map
|
||||||
for (map< string,vector<FairMQChannel> >::iterator mi = fChannels.begin(); mi != fChannels.end(); ++mi)
|
for (auto mi = fChannels.begin(); mi != fChannels.end(); ++mi)
|
||||||
{
|
{
|
||||||
// iterate over the channels vector
|
// iterate over the channels vector
|
||||||
for (vector<FairMQChannel>::iterator vi = (mi->second).begin(); vi != (mi->second).end(); ++vi)
|
for (auto vi = (mi->second).begin(); vi != (mi->second).end(); ++vi)
|
||||||
|
{
|
||||||
|
if (vi->fSocket)
|
||||||
{
|
{
|
||||||
delete vi->fSocket;
|
delete vi->fSocket;
|
||||||
|
vi->fSocket = nullptr;
|
||||||
|
}
|
||||||
|
if (vi->fPoller)
|
||||||
|
{
|
||||||
|
delete vi->fPoller;
|
||||||
|
vi->fPoller = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete fCommandSocket;
|
if (fCmdSocket)
|
||||||
|
{
|
||||||
|
delete fCmdSocket;
|
||||||
|
fCmdSocket = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "FairMQConfigurable.h"
|
#include "FairMQConfigurable.h"
|
||||||
#include "FairMQStateMachine.h"
|
#include "FairMQStateMachine.h"
|
||||||
|
@ -42,6 +42,8 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
|
|
||||||
FairMQDevice();
|
FairMQDevice();
|
||||||
|
|
||||||
|
void CatchSignals();
|
||||||
|
|
||||||
virtual void LogSocketRates();
|
virtual void LogSocketRates();
|
||||||
|
|
||||||
void SortChannel(const std::string& name, const bool reindex = true);
|
void SortChannel(const std::string& name, const bool reindex = true);
|
||||||
|
@ -49,6 +51,9 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
|
|
||||||
void WaitForInitialValidation();
|
void WaitForInitialValidation();
|
||||||
|
|
||||||
|
void InteractiveStateLoop();
|
||||||
|
void PrintInteractiveStateLoopHelp();
|
||||||
|
|
||||||
virtual void SetProperty(const int key, const std::string& value);
|
virtual void SetProperty(const int key, const std::string& value);
|
||||||
virtual std::string GetProperty(const int key, const std::string& default_ = "");
|
virtual std::string GetProperty(const int key, const std::string& default_ = "");
|
||||||
virtual void SetProperty(const int key, const int value);
|
virtual void SetProperty(const int key, const int value);
|
||||||
|
@ -60,7 +65,7 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
|
|
||||||
virtual ~FairMQDevice();
|
virtual ~FairMQDevice();
|
||||||
|
|
||||||
std::map< std::string,std::vector<FairMQChannel> > fChannels;
|
std::unordered_map< std::string,std::vector<FairMQChannel> > fChannels;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string fId;
|
std::string fId;
|
||||||
|
@ -74,7 +79,7 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
|
|
||||||
int fLogIntervalInMs;
|
int fLogIntervalInMs;
|
||||||
|
|
||||||
FairMQSocket* fCommandSocket;
|
FairMQSocket* fCmdSocket;
|
||||||
|
|
||||||
FairMQTransportFactory* fTransportFactory;
|
FairMQTransportFactory* fTransportFactory;
|
||||||
|
|
||||||
|
@ -95,7 +100,7 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
void ResetWrapper();
|
void ResetWrapper();
|
||||||
virtual void Reset();
|
virtual void Reset();
|
||||||
|
|
||||||
virtual void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
void Terminate();
|
void Terminate();
|
||||||
void SendCommand(const std::string& command);
|
void SendCommand(const std::string& command);
|
||||||
|
@ -108,6 +113,9 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
boost::condition_variable fInitialValidationCondition;
|
boost::condition_variable fInitialValidationCondition;
|
||||||
boost::mutex fInitialValidationMutex;
|
boost::mutex fInitialValidationMutex;
|
||||||
|
|
||||||
|
void SignalHandler(int signal);
|
||||||
|
bool fCatchingSignals;
|
||||||
|
|
||||||
/// Copy Constructor
|
/// Copy Constructor
|
||||||
FairMQDevice(const FairMQDevice&);
|
FairMQDevice(const FairMQDevice&);
|
||||||
FairMQDevice operator=(const FairMQDevice&);
|
FairMQDevice operator=(const FairMQDevice&);
|
||||||
|
|
|
@ -15,12 +15,16 @@
|
||||||
#ifndef FAIRMQPOLLER_H_
|
#ifndef FAIRMQPOLLER_H_
|
||||||
#define FAIRMQPOLLER_H_
|
#define FAIRMQPOLLER_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class FairMQPoller
|
class FairMQPoller
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void Poll(int timeout) = 0;
|
virtual void Poll(const int timeout) = 0;
|
||||||
virtual bool CheckInput(int index) = 0;
|
virtual bool CheckInput(const int index) = 0;
|
||||||
virtual bool CheckOutput(int index) = 0;
|
virtual bool CheckOutput(const int index) = 0;
|
||||||
|
virtual bool CheckInput(const std::string channelKey, const int index) = 0;
|
||||||
|
virtual bool CheckOutput(const std::string channelKey, const int index) = 0;
|
||||||
|
|
||||||
virtual ~FairMQPoller() {};
|
virtual ~FairMQPoller() {};
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,13 +40,12 @@ int FairMQStateMachine::GetEventNumber(std::string event)
|
||||||
if (event == "INIT_TASK") return INIT_TASK;
|
if (event == "INIT_TASK") return INIT_TASK;
|
||||||
if (event == "RUN") return RUN;
|
if (event == "RUN") return RUN;
|
||||||
if (event == "PAUSE") return PAUSE;
|
if (event == "PAUSE") return PAUSE;
|
||||||
if (event == "RESUME") return RESUME;
|
|
||||||
if (event == "STOP") return STOP;
|
if (event == "STOP") return STOP;
|
||||||
if (event == "RESET_DEVICE") return RESET_DEVICE;
|
if (event == "RESET_DEVICE") return RESET_DEVICE;
|
||||||
if (event == "RESET_TASK") return RESET_TASK;
|
if (event == "RESET_TASK") return RESET_TASK;
|
||||||
if (event == "END") return END;
|
if (event == "END") return END;
|
||||||
LOG(ERROR) << "Requested number for non-existent event... " << event << std::endl
|
LOG(ERROR) << "Requested number for non-existent event... " << event << std::endl
|
||||||
<< "Supported are: INIT_DEVICE, INIT_TASK, RUN, PAUSE, RESUME, STOP, RESET_DEVICE, RESET_TASK, END";
|
<< "Supported are: INIT_DEVICE, INIT_TASK, RUN, PAUSE, STOP, RESET_DEVICE, RESET_TASK, END";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +73,6 @@ bool FairMQStateMachine::ChangeState(int event)
|
||||||
case PAUSE:
|
case PAUSE:
|
||||||
process_event(FairMQFSM::PAUSE());
|
process_event(FairMQFSM::PAUSE());
|
||||||
return true;
|
return true;
|
||||||
case RESUME:
|
|
||||||
process_event(FairMQFSM::RESUME());
|
|
||||||
return true;
|
|
||||||
case STOP:
|
case STOP:
|
||||||
process_event(FairMQFSM::STOP());
|
process_event(FairMQFSM::STOP());
|
||||||
return true;
|
return true;
|
||||||
|
@ -94,7 +90,7 @@ bool FairMQStateMachine::ChangeState(int event)
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
LOG(ERROR) << "Requested unsupported state: " << event << std::endl
|
LOG(ERROR) << "Requested unsupported state: " << event << std::endl
|
||||||
<< "Supported are: INIT_DEVICE, INIT_TASK, RUN, PAUSE, RESUME, STOP, RESET_TASK, RESET_DEVICE, END";
|
<< "Supported are: INIT_DEVICE, INIT_TASK, RUN, PAUSE, STOP, RESET_TASK, RESET_DEVICE, END";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,22 +39,22 @@ namespace FairMQFSM
|
||||||
{
|
{
|
||||||
|
|
||||||
// defining events for the boost MSM state machine
|
// defining events for the boost MSM state machine
|
||||||
struct INIT_DEVICE {};
|
struct INIT_DEVICE { std::string name() const { return "INIT_DEVICE"; } };
|
||||||
struct internal_DEVICE_READY {};
|
struct internal_DEVICE_READY { std::string name() const { return "internal_DEVICE_READY"; } };
|
||||||
struct INIT_TASK {};
|
struct INIT_TASK { std::string name() const { return "INIT_TASK"; } };
|
||||||
struct internal_READY {};
|
struct internal_READY { std::string name() const { return "internal_READY"; } };
|
||||||
struct RUN {};
|
struct RUN { std::string name() const { return "RUN"; } };
|
||||||
struct PAUSE {};
|
struct PAUSE { std::string name() const { return "PAUSE"; } };
|
||||||
struct RESUME {};
|
struct STOP { std::string name() const { return "STOP"; } };
|
||||||
struct STOP {};
|
struct RESET_TASK { std::string name() const { return "RESET_TASK"; } };
|
||||||
struct RESET_TASK {};
|
struct RESET_DEVICE { std::string name() const { return "RESET_DEVICE"; } };
|
||||||
struct RESET_DEVICE {};
|
struct internal_IDLE { std::string name() const { return "internal_IDLE"; } };
|
||||||
struct internal_IDLE {};
|
struct END { std::string name() const { return "END"; } };
|
||||||
struct END {};
|
|
||||||
|
|
||||||
// defining the boost MSM state machine
|
// defining the boost MSM state machine
|
||||||
struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
FairMQFSM_()
|
FairMQFSM_()
|
||||||
: fState()
|
: fState()
|
||||||
, fStateThread()
|
, fStateThread()
|
||||||
|
@ -102,6 +102,7 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
||||||
{
|
{
|
||||||
fsm.fState = IDLE;
|
fsm.fState = IDLE;
|
||||||
|
LOG(STATE) << "Entering IDLE state";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,6 +123,7 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
template <class EVT, class FSM, class SourceState, class TargetState>
|
template <class EVT, class FSM, class SourceState, class TargetState>
|
||||||
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
||||||
{
|
{
|
||||||
|
LOG(STATE) << "Entering DEVICE READY state";
|
||||||
fsm.fState = DEVICE_READY;
|
fsm.fState = DEVICE_READY;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -144,6 +146,7 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
template <class EVT, class FSM, class SourceState, class TargetState>
|
template <class EVT, class FSM, class SourceState, class TargetState>
|
||||||
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
||||||
{
|
{
|
||||||
|
LOG(STATE) << "Entering READY state";
|
||||||
fsm.fState = READY;
|
fsm.fState = READY;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -166,10 +169,10 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
||||||
{
|
{
|
||||||
fsm.fStateFinished = false;
|
fsm.fStateFinished = false;
|
||||||
LOG(STATE) << "Entering PAUSED state";
|
|
||||||
fsm.fState = PAUSED;
|
fsm.fState = PAUSED;
|
||||||
fsm.SendCommand("pause");
|
fsm.SendCommand("pause");
|
||||||
fsm.fStateThread.join();
|
fsm.fStateThread.join();
|
||||||
|
LOG(STATE) << "Entering PAUSED state";
|
||||||
fsm.fStateThread = boost::thread(boost::bind(&FairMQFSM_::Pause, &fsm));
|
fsm.fStateThread = boost::thread(boost::bind(&FairMQFSM_::Pause, &fsm));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -195,11 +198,21 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
{
|
{
|
||||||
LOG(STATE) << "Received STOP event";
|
LOG(STATE) << "Received STOP event";
|
||||||
fsm.fState = IDLE;
|
fsm.fState = IDLE;
|
||||||
// fsm.SendCommand("stop");
|
fsm.SendCommand("stop");
|
||||||
fsm.fStateThread.join();
|
fsm.fStateThread.join();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct InternalStopFct
|
||||||
|
{
|
||||||
|
template <class EVT, class FSM, class SourceState, class TargetState>
|
||||||
|
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
||||||
|
{
|
||||||
|
LOG(STATE) << "RUNNING state finished without an external event";
|
||||||
|
fsm.fState = IDLE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct ResetTaskFct
|
struct ResetTaskFct
|
||||||
{
|
{
|
||||||
template <class EVT, class FSM, class SourceState, class TargetState>
|
template <class EVT, class FSM, class SourceState, class TargetState>
|
||||||
|
@ -220,7 +233,7 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
fsm.fStateFinished = false;
|
fsm.fStateFinished = false;
|
||||||
LOG(STATE) << "Entering RESETTING DEVICE state";
|
LOG(STATE) << "Entering RESETTING DEVICE state";
|
||||||
fsm.fState = RESETTING_DEVICE;
|
fsm.fState = RESETTING_DEVICE;
|
||||||
fsm.fStateThread = boost::thread(boost::bind(&FairMQFSM_::ResetWrapper, &fsm));
|
fsm.ResetWrapper();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -232,9 +245,9 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
LOG(STATE) << "Received END event";
|
LOG(STATE) << "Received END event";
|
||||||
fsm.fState = EXITING;
|
fsm.fState = EXITING;
|
||||||
|
|
||||||
fsm.fStateThread = boost::thread(boost::bind(&FairMQFSM_::Terminate, &fsm));
|
fsm.fTerminateStateThread = boost::thread(boost::bind(&FairMQFSM_::Terminate, &fsm));
|
||||||
fsm.Shutdown();
|
fsm.Shutdown();
|
||||||
fsm.fStateThread.join();
|
fsm.fTerminateStateThread.join();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -243,10 +256,13 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
template <class EVT, class FSM, class SourceState, class TargetState>
|
template <class EVT, class FSM, class SourceState, class TargetState>
|
||||||
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
||||||
{
|
{
|
||||||
|
LOG(STATE) << "Entering EXITING state";
|
||||||
fsm.fState = EXITING;
|
fsm.fState = EXITING;
|
||||||
|
fsm.SendCommand("stop");
|
||||||
|
fsm.fStateThread.interrupt();
|
||||||
|
fsm.fStateThread.join();
|
||||||
|
|
||||||
fsm.fTerminateStateThread = boost::thread(boost::bind(&FairMQFSM_::Terminate, &fsm));
|
fsm.fTerminateStateThread = boost::thread(boost::bind(&FairMQFSM_::Terminate, &fsm));
|
||||||
fsm.fStateThread.join();
|
|
||||||
fsm.Shutdown();
|
fsm.Shutdown();
|
||||||
fsm.fTerminateStateThread.join();
|
fsm.fTerminateStateThread.join();
|
||||||
}
|
}
|
||||||
|
@ -278,8 +294,9 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
msmf::Row<INITIALIZING_TASK_FSM, internal_READY, READY_FSM, ReadyFct, msmf::none>,
|
msmf::Row<INITIALIZING_TASK_FSM, internal_READY, READY_FSM, ReadyFct, msmf::none>,
|
||||||
msmf::Row<READY_FSM, RUN, RUNNING_FSM, RunFct, msmf::none>,
|
msmf::Row<READY_FSM, RUN, RUNNING_FSM, RunFct, msmf::none>,
|
||||||
msmf::Row<RUNNING_FSM, PAUSE, PAUSED_FSM, PauseFct, msmf::none>,
|
msmf::Row<RUNNING_FSM, PAUSE, PAUSED_FSM, PauseFct, msmf::none>,
|
||||||
msmf::Row<PAUSED_FSM, RESUME, RUNNING_FSM, ResumeFct, msmf::none>,
|
msmf::Row<PAUSED_FSM, RUN, RUNNING_FSM, ResumeFct, msmf::none>,
|
||||||
msmf::Row<RUNNING_FSM, STOP, READY_FSM, StopFct, msmf::none>,
|
msmf::Row<RUNNING_FSM, STOP, READY_FSM, StopFct, msmf::none>,
|
||||||
|
msmf::Row<RUNNING_FSM, internal_READY, READY_FSM, InternalStopFct, msmf::none>,
|
||||||
msmf::Row<READY_FSM, RESET_TASK, RESETTING_TASK_FSM, ResetTaskFct, msmf::none>,
|
msmf::Row<READY_FSM, RESET_TASK, RESETTING_TASK_FSM, ResetTaskFct, msmf::none>,
|
||||||
msmf::Row<RESETTING_TASK_FSM, internal_DEVICE_READY, DEVICE_READY_FSM, DeviceReadyFct, msmf::none>,
|
msmf::Row<RESETTING_TASK_FSM, internal_DEVICE_READY, DEVICE_READY_FSM, DeviceReadyFct, msmf::none>,
|
||||||
msmf::Row<DEVICE_READY_FSM, RESET_DEVICE, RESETTING_DEVICE_FSM, ResetDeviceFct, msmf::none>,
|
msmf::Row<DEVICE_READY_FSM, RESET_DEVICE, RESETTING_DEVICE_FSM, ResetDeviceFct, msmf::none>,
|
||||||
|
@ -292,7 +309,7 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
template <class FSM, class Event>
|
template <class FSM, class Event>
|
||||||
void no_transition(Event const& e, FSM&, int state)
|
void no_transition(Event const& e, FSM&, int state)
|
||||||
{
|
{
|
||||||
LOG(STATE) << "no transition from state " << GetStateName(state) << " on event " << typeid(e).name();
|
LOG(STATE) << "no transition from state " << GetStateName(state) << " on event " << e.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is to run certain functions in a separate thread
|
// this is to run certain functions in a separate thread
|
||||||
|
@ -314,7 +331,7 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
EXITING
|
EXITING
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string GetStateName(int state)
|
std::string GetStateName(int state) const
|
||||||
{
|
{
|
||||||
switch(state)
|
switch(state)
|
||||||
{
|
{
|
||||||
|
@ -343,14 +360,38 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetCurrentState()
|
std::string GetCurrentStateName() const
|
||||||
|
{
|
||||||
|
return GetStateName(fState);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetCurrentState() const
|
||||||
{
|
{
|
||||||
return fState;
|
return fState;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetCurrentStateName()
|
bool CheckCurrentState(int state) const
|
||||||
{
|
{
|
||||||
return GetStateName(fState);
|
if (state == fState)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CheckCurrentState(std::string state) const
|
||||||
|
{
|
||||||
|
if (state == GetCurrentStateName())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// condition variable to notify parent thread about end of state.
|
// condition variable to notify parent thread about end of state.
|
||||||
|
@ -376,7 +417,6 @@ class FairMQStateMachine : public FairMQFSM::FairMQFSM
|
||||||
internal_READY,
|
internal_READY,
|
||||||
RUN,
|
RUN,
|
||||||
PAUSE,
|
PAUSE,
|
||||||
RESUME,
|
|
||||||
STOP,
|
STOP,
|
||||||
RESET_TASK,
|
RESET_TASK,
|
||||||
RESET_DEVICE,
|
RESET_DEVICE,
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include "FairMQPoller.h"
|
#include "FairMQPoller.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
|
class FairMQChannel;
|
||||||
|
|
||||||
class FairMQTransportFactory
|
class FairMQTransportFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -31,6 +33,8 @@ class FairMQTransportFactory
|
||||||
virtual FairMQMessage* CreateMessage(void* data, size_t size, fairmq_free_fn *ffn = NULL, void* hint = NULL) = 0;
|
virtual FairMQMessage* CreateMessage(void* data, size_t size, fairmq_free_fn *ffn = NULL, void* hint = NULL) = 0;
|
||||||
virtual FairMQSocket* CreateSocket(const std::string& type, const std::string& name, int numIoThreads) = 0;
|
virtual FairMQSocket* CreateSocket(const std::string& type, const std::string& name, int numIoThreads) = 0;
|
||||||
virtual FairMQPoller* CreatePoller(const std::vector<FairMQChannel>& channels) = 0;
|
virtual FairMQPoller* CreatePoller(const std::vector<FairMQChannel>& channels) = 0;
|
||||||
|
virtual FairMQPoller* CreatePoller(std::map< std::string,std::vector<FairMQChannel> >& channelsMap, std::initializer_list<std::string> channelList) = 0;
|
||||||
|
virtual FairMQPoller* CreatePoller(FairMQSocket& dataSocket, FairMQSocket& cmdSocket) = 0;
|
||||||
|
|
||||||
virtual ~FairMQTransportFactory() {};
|
virtual ~FairMQTransportFactory() {};
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,12 +40,15 @@ void FairMQBenchmarkSampler::Run()
|
||||||
void* buffer = operator new[](fEventSize);
|
void* buffer = operator new[](fEventSize);
|
||||||
FairMQMessage* baseMsg = fTransportFactory->CreateMessage(buffer, fEventSize);
|
FairMQMessage* baseMsg = fTransportFactory->CreateMessage(buffer, fEventSize);
|
||||||
|
|
||||||
while (GetCurrentState() == RUNNING)
|
// store the channel reference to avoid traversing the map on every loop iteration
|
||||||
|
const FairMQChannel& dataChannel = fChannels.at("data-out").at(0);
|
||||||
|
|
||||||
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
msg->Copy(baseMsg);
|
msg->Copy(baseMsg);
|
||||||
|
|
||||||
fChannels["data-out"].at(0).Send(msg);
|
dataChannel.Send(msg);
|
||||||
|
|
||||||
--fEventCounter;
|
--fEventCounter;
|
||||||
|
|
||||||
|
@ -69,7 +72,7 @@ void FairMQBenchmarkSampler::Run()
|
||||||
|
|
||||||
void FairMQBenchmarkSampler::ResetEventCounter()
|
void FairMQBenchmarkSampler::ResetEventCounter()
|
||||||
{
|
{
|
||||||
while (GetCurrentState() == RUNNING)
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,13 +26,17 @@ FairMQBuffer::FairMQBuffer()
|
||||||
|
|
||||||
void FairMQBuffer::Run()
|
void FairMQBuffer::Run()
|
||||||
{
|
{
|
||||||
while (GetCurrentState() == RUNNING)
|
// store the channel references to avoid traversing the map on every loop iteration
|
||||||
|
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||||
|
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||||
|
|
||||||
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
if (fChannels["data-in"].at(0).Receive(msg) > 0)
|
if (dataInChannel.Receive(msg) > 0)
|
||||||
{
|
{
|
||||||
fChannels["data-out"].at(0).Send(msg);
|
dataOutChannel.Send(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete msg;
|
delete msg;
|
||||||
|
|
|
@ -29,21 +29,38 @@ FairMQMerger::~FairMQMerger()
|
||||||
|
|
||||||
void FairMQMerger::Run()
|
void FairMQMerger::Run()
|
||||||
{
|
{
|
||||||
FairMQPoller* poller = fTransportFactory->CreatePoller(fChannels["data-in"]);
|
FairMQPoller* poller = fTransportFactory->CreatePoller(fChannels.at("data-in"));
|
||||||
|
|
||||||
while (GetCurrentState() == RUNNING)
|
// store the channel references to avoid traversing the map on every loop iteration
|
||||||
|
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||||
|
FairMQChannel* dataInChannels[fChannels.at("data-in").size()];
|
||||||
|
for (int i = 0; i < fChannels.at("data-in").size(); ++i)
|
||||||
|
{
|
||||||
|
dataInChannels[i] = &(fChannels.at("data-in").at(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
poller->Poll(100);
|
poller->Poll(100);
|
||||||
|
|
||||||
for (int i = 0; i < fChannels["data-in"].size(); ++i)
|
for (int i = 0; i < fChannels.at("data-in").size(); ++i)
|
||||||
{
|
{
|
||||||
if (poller->CheckInput(i))
|
if (poller->CheckInput(i))
|
||||||
{
|
{
|
||||||
if (fChannels["data-in"].at(i).Receive(msg))
|
if (dataInChannels[i]->Receive(msg) > 0)
|
||||||
{
|
{
|
||||||
fChannels["data-out"].at(0).Send(msg);
|
if (dataOutChannel.Send(msg) < 0)
|
||||||
|
{
|
||||||
|
LOG(DEBUG) << "Blocking send interrupted by a command";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG(DEBUG) << "Blocking receive interrupted by a command";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,15 @@ void FairMQProxy::Run()
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
while (GetCurrentState() == RUNNING)
|
// store the channel references to avoid traversing the map on every loop iteration
|
||||||
|
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||||
|
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||||
|
|
||||||
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
if (fChannels["data-in"].at(0).Receive(msg) > 0)
|
if (dataInChannel.Receive(msg) > 0)
|
||||||
{
|
{
|
||||||
fChannels["data-out"].at(0).Send(msg);
|
dataOutChannel.Send(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,14 @@ FairMQSink::FairMQSink()
|
||||||
|
|
||||||
void FairMQSink::Run()
|
void FairMQSink::Run()
|
||||||
{
|
{
|
||||||
while (GetCurrentState() == RUNNING)
|
// store the channel reference to avoid traversing the map on every loop iteration
|
||||||
|
const FairMQChannel& dataChannel = fChannels.at("data-in").at(0);
|
||||||
|
|
||||||
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
fChannels["data-in"].at(0).Receive(msg);
|
dataChannel.Receive(msg);
|
||||||
|
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,25 @@ FairMQSplitter::~FairMQSplitter()
|
||||||
void FairMQSplitter::Run()
|
void FairMQSplitter::Run()
|
||||||
{
|
{
|
||||||
int direction = 0;
|
int direction = 0;
|
||||||
|
int numOutputs = fChannels.at("data-out").size();
|
||||||
|
|
||||||
while (GetCurrentState() == RUNNING)
|
// store the channel references to avoid traversing the map on every loop iteration
|
||||||
|
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||||
|
FairMQChannel* dataOutChannels[fChannels.at("data-out").size()];
|
||||||
|
for (int i = 0; i < numOutputs; ++i)
|
||||||
|
{
|
||||||
|
dataOutChannels[i] = &(fChannels.at("data-out").at(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
if (fChannels["data-in"].at(0).Receive(msg) > 0)
|
if (dataInChannel.Receive(msg) > 0)
|
||||||
{
|
{
|
||||||
fChannels["data-out"].at(direction).Send(msg);
|
dataOutChannels[direction]->Send(msg);
|
||||||
direction++;
|
++direction;
|
||||||
if (direction >= fChannels["data-out"].size())
|
if (direction >= numOutputs)
|
||||||
{
|
{
|
||||||
direction = 0;
|
direction = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,4 +89,3 @@ class GenericFileSink : public FairMQDevice, public InputPolicy, public OutputPo
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* GENERICFILESINK_H */
|
#endif /* GENERICFILESINK_H */
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,10 @@ void GenericFileSink<InputPolicy, OutputPolicy>::Run()
|
||||||
{
|
{
|
||||||
int receivedMsg = 0;
|
int receivedMsg = 0;
|
||||||
|
|
||||||
while (GetCurrentState() == RUNNING)
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
if (fChannels["data-in"].at(0).Receive(msg) > 0)
|
if (fChannels.at("data-in").at(0).Receive(msg) > 0)
|
||||||
{
|
{
|
||||||
OutputPolicy::AddToFile(InputPolicy::DeSerializeMsg(msg));
|
OutputPolicy::AddToFile(InputPolicy::DeSerializeMsg(msg));
|
||||||
receivedMsg++;
|
receivedMsg++;
|
||||||
|
|
|
@ -92,10 +92,7 @@ class GenericProcessor : public FairMQDevice, public InputPolicy, public OutputP
|
||||||
// bool ReceivePart();
|
// bool ReceivePart();
|
||||||
bool ReceivePart()
|
bool ReceivePart()
|
||||||
{
|
{
|
||||||
int64_t more = 0;
|
if (fChannels["data-in"].at(0).ExpectsAnotherPart())
|
||||||
size_t more_size = sizeof(more);
|
|
||||||
fChannels["data-in"].at(0).fSocket->GetOption("rcv-more", &more, &more_size);
|
|
||||||
if (more)
|
|
||||||
{
|
{
|
||||||
InputPolicy::CloseMessage();
|
InputPolicy::CloseMessage();
|
||||||
// fProcessorTask->GetPayload()->CloseMessage();
|
// fProcessorTask->GetPayload()->CloseMessage();
|
||||||
|
@ -123,7 +120,7 @@ class GenericProcessor : public FairMQDevice, public InputPolicy, public OutputP
|
||||||
int receivedMsgs = 0;
|
int receivedMsgs = 0;
|
||||||
int sentMsgs = 0;
|
int sentMsgs = 0;
|
||||||
|
|
||||||
while (GetCurrentState() == RUNNING)
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ void base_GenericSampler<T,U,K,L>::Run()
|
||||||
|
|
||||||
LOG(INFO) << "Number of events to process: " << fNumEvents;
|
LOG(INFO) << "Number of events to process: " << fNumEvents;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
for (fCurrentIdx = 0; fCurrentIdx < fNumEvents; fCurrentIdx++)
|
for (fCurrentIdx = 0; fCurrentIdx < fNumEvents; fCurrentIdx++)
|
||||||
{
|
{
|
||||||
for(auto& p : fChannels[fOutChanName])
|
for(auto& p : fChannels[fOutChanName])
|
||||||
|
@ -75,7 +76,7 @@ void base_GenericSampler<T,U,K,L>::Run()
|
||||||
// boost::this_thread::sleep(boost::posix_time::milliseconds(1));
|
// boost::this_thread::sleep(boost::posix_time::milliseconds(1));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (GetCurrentState() != RUNNING)
|
if (!CheckCurrentState(RUNNING))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if more than one socket, remove the last incrementation
|
// if more than one socket, remove the last incrementation
|
||||||
|
@ -83,7 +84,7 @@ void base_GenericSampler<T,U,K,L>::Run()
|
||||||
fCurrentIdx--;
|
fCurrentIdx--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ( GetCurrentState() == RUNNING && fContinuous );
|
while (CheckCurrentState(RUNNING) && fContinuous);
|
||||||
|
|
||||||
boost::timer::cpu_times const elapsed_time(timer.elapsed());
|
boost::timer::cpu_times const elapsed_time(timer.elapsed());
|
||||||
LOG(INFO) << "Sent everything in:\n" << boost::timer::format(elapsed_time, 2);
|
LOG(INFO) << "Sent everything in:\n" << boost::timer::format(elapsed_time, 2);
|
||||||
|
|
|
@ -40,7 +40,7 @@ void FairMQExample1Sampler::Run()
|
||||||
|
|
||||||
LOG(INFO) << "Sending \"" << fText << "\"";
|
LOG(INFO) << "Sending \"" << fText << "\"";
|
||||||
|
|
||||||
fChannels["data-out"].at(0).Send(msg);
|
fChannels.at("data-out").at(0).Send(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ void FairMQExample1Sink::Run()
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
fChannels["data-in"].at(0).Receive(msg);
|
fChannels.at("data-in").at(0).Receive(msg);
|
||||||
|
|
||||||
LOG(INFO) << "Received message: \""
|
LOG(INFO) << "Received message: \""
|
||||||
<< string(static_cast<char*>(msg->GetData()), msg->GetSize())
|
<< string(static_cast<char*>(msg->GetData()), msg->GetSize())
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -30,31 +29,10 @@
|
||||||
|
|
||||||
using namespace boost::program_options;
|
using namespace boost::program_options;
|
||||||
|
|
||||||
FairMQExample1Sampler sampler;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
sampler.ChangeState("END");
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQExample1Sampler sampler;
|
||||||
|
sampler.CatchSignals();
|
||||||
|
|
||||||
FairMQProgOptions config;
|
FairMQProgOptions config;
|
||||||
|
|
||||||
|
@ -100,18 +78,7 @@ int main(int argc, char** argv)
|
||||||
sampler.WaitForEndOfState("INIT_TASK");
|
sampler.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
sampler.ChangeState("RUN");
|
sampler.ChangeState("RUN");
|
||||||
sampler.WaitForEndOfState("RUN");
|
sampler.InteractiveStateLoop();
|
||||||
|
|
||||||
sampler.ChangeState("STOP");
|
|
||||||
|
|
||||||
sampler.ChangeState("RESET_TASK");
|
|
||||||
sampler.WaitForEndOfState("RESET_TASK");
|
|
||||||
|
|
||||||
sampler.ChangeState("RESET_DEVICE");
|
|
||||||
sampler.WaitForEndOfState("RESET_DEVICE");
|
|
||||||
|
|
||||||
sampler.ChangeState("END");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -30,31 +29,10 @@
|
||||||
|
|
||||||
using namespace boost::program_options;
|
using namespace boost::program_options;
|
||||||
|
|
||||||
FairMQExample1Sink sink;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQExample1Sink::END);
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQExample1Sink sink;
|
||||||
|
sink.CatchSignals();
|
||||||
|
|
||||||
FairMQProgOptions config;
|
FairMQProgOptions config;
|
||||||
|
|
||||||
|
@ -91,18 +69,7 @@ int main(int argc, char** argv)
|
||||||
sink.WaitForEndOfState("INIT_TASK");
|
sink.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
sink.ChangeState("RUN");
|
sink.ChangeState("RUN");
|
||||||
sink.WaitForEndOfState("RUN");
|
sink.InteractiveStateLoop();
|
||||||
|
|
||||||
sink.ChangeState("STOP");
|
|
||||||
|
|
||||||
sink.ChangeState("RESET_TASK");
|
|
||||||
sink.WaitForEndOfState("RESET_TASK");
|
|
||||||
|
|
||||||
sink.ChangeState("RESET_DEVICE");
|
|
||||||
sink.WaitForEndOfState("RESET_DEVICE");
|
|
||||||
|
|
||||||
sink.ChangeState("END");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ void FairMQExample2Processor::Run()
|
||||||
while (GetCurrentState() == RUNNING)
|
while (GetCurrentState() == RUNNING)
|
||||||
{
|
{
|
||||||
FairMQMessage* input = fTransportFactory->CreateMessage();
|
FairMQMessage* input = fTransportFactory->CreateMessage();
|
||||||
fChannels["data-in"].at(0).Receive(input);
|
fChannels.at("data-in").at(0).Receive(input);
|
||||||
|
|
||||||
LOG(INFO) << "Received data, processing...";
|
LOG(INFO) << "Received data, processing...";
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ void FairMQExample2Processor::Run()
|
||||||
delete input;
|
delete input;
|
||||||
|
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage(const_cast<char*>(text->c_str()), text->length(), CustomCleanup, text);
|
FairMQMessage* msg = fTransportFactory->CreateMessage(const_cast<char*>(text->c_str()), text->length(), CustomCleanup, text);
|
||||||
fChannels["data-out"].at(0).Send(msg);
|
fChannels.at("data-out").at(0).Send(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ void FairMQExample2Sampler::Run()
|
||||||
|
|
||||||
LOG(INFO) << "Sending \"" << fText << "\"";
|
LOG(INFO) << "Sending \"" << fText << "\"";
|
||||||
|
|
||||||
fChannels["data-out"].at(0).Send(msg);
|
fChannels.at("data-out").at(0).Send(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ void FairMQExample2Sink::Run()
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
fChannels["data-in"].at(0).Receive(msg);
|
fChannels.at("data-in").at(0).Receive(msg);
|
||||||
|
|
||||||
LOG(INFO) << "Received message: \""
|
LOG(INFO) << "Received message: \""
|
||||||
<< string(static_cast<char*>(msg->GetData()), msg->GetSize())
|
<< string(static_cast<char*>(msg->GetData()), msg->GetSize())
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -30,31 +29,10 @@
|
||||||
|
|
||||||
using namespace boost::program_options;
|
using namespace boost::program_options;
|
||||||
|
|
||||||
FairMQExample2Processor processor;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
processor.ChangeState("END");
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQExample2Processor processor;
|
||||||
|
processor.CatchSignals();
|
||||||
|
|
||||||
FairMQProgOptions config;
|
FairMQProgOptions config;
|
||||||
|
|
||||||
|
@ -91,18 +69,7 @@ int main(int argc, char** argv)
|
||||||
processor.WaitForEndOfState("INIT_TASK");
|
processor.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
processor.ChangeState("RUN");
|
processor.ChangeState("RUN");
|
||||||
processor.WaitForEndOfState("RUN");
|
processor.InteractiveStateLoop();
|
||||||
|
|
||||||
processor.ChangeState("STOP");
|
|
||||||
|
|
||||||
processor.ChangeState("RESET_TASK");
|
|
||||||
processor.WaitForEndOfState("RESET_TASK");
|
|
||||||
|
|
||||||
processor.ChangeState("RESET_DEVICE");
|
|
||||||
processor.WaitForEndOfState("RESET_DEVICE");
|
|
||||||
|
|
||||||
processor.ChangeState("END");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -30,31 +29,10 @@
|
||||||
|
|
||||||
using namespace boost::program_options;
|
using namespace boost::program_options;
|
||||||
|
|
||||||
FairMQExample2Sampler sampler;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
sampler.ChangeState("END");
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQExample2Sampler sampler;
|
||||||
|
sampler.CatchSignals();
|
||||||
|
|
||||||
FairMQProgOptions config;
|
FairMQProgOptions config;
|
||||||
|
|
||||||
|
@ -100,18 +78,7 @@ int main(int argc, char** argv)
|
||||||
sampler.WaitForEndOfState("INIT_TASK");
|
sampler.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
sampler.ChangeState("RUN");
|
sampler.ChangeState("RUN");
|
||||||
sampler.WaitForEndOfState("RUN");
|
sampler.InteractiveStateLoop();
|
||||||
|
|
||||||
sampler.ChangeState("STOP");
|
|
||||||
|
|
||||||
sampler.ChangeState("RESET_TASK");
|
|
||||||
sampler.WaitForEndOfState("RESET_TASK");
|
|
||||||
|
|
||||||
sampler.ChangeState("RESET_DEVICE");
|
|
||||||
sampler.WaitForEndOfState("RESET_DEVICE");
|
|
||||||
|
|
||||||
sampler.ChangeState("END");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -30,31 +29,10 @@
|
||||||
|
|
||||||
using namespace boost::program_options;
|
using namespace boost::program_options;
|
||||||
|
|
||||||
FairMQExample2Sink sink;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQExample2Sink::END);
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQExample2Sink sink;
|
||||||
|
sink.CatchSignals();
|
||||||
|
|
||||||
FairMQProgOptions config;
|
FairMQProgOptions config;
|
||||||
|
|
||||||
|
@ -91,18 +69,7 @@ int main(int argc, char** argv)
|
||||||
sink.WaitForEndOfState("INIT_TASK");
|
sink.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
sink.ChangeState("RUN");
|
sink.ChangeState("RUN");
|
||||||
sink.WaitForEndOfState("RUN");
|
sink.InteractiveStateLoop();
|
||||||
|
|
||||||
sink.ChangeState("STOP");
|
|
||||||
|
|
||||||
sink.ChangeState("RESET_TASK");
|
|
||||||
sink.WaitForEndOfState("RESET_TASK");
|
|
||||||
|
|
||||||
sink.ChangeState("RESET_DEVICE");
|
|
||||||
sink.WaitForEndOfState("RESET_DEVICE");
|
|
||||||
|
|
||||||
sink.ChangeState("END");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,8 +47,8 @@ void FairMQExampleClient::Run()
|
||||||
|
|
||||||
LOG(INFO) << "Sending \"" << fText << "\" to server.";
|
LOG(INFO) << "Sending \"" << fText << "\" to server.";
|
||||||
|
|
||||||
fChannels["data"].at(0).Send(request);
|
fChannels.at("data").at(0).Send(request);
|
||||||
fChannels["data"].at(0).Receive(reply);
|
fChannels.at("data").at(0).Receive(reply);
|
||||||
|
|
||||||
LOG(INFO) << "Received reply from server: \"" << string(static_cast<char*>(reply->GetData()), reply->GetSize()) << "\"";
|
LOG(INFO) << "Received reply from server: \"" << string(static_cast<char*>(reply->GetData()), reply->GetSize()) << "\"";
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ void FairMQExampleServer::Run()
|
||||||
|
|
||||||
FairMQMessage* request = fTransportFactory->CreateMessage();
|
FairMQMessage* request = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
fChannels["data"].at(0).Receive(request);
|
fChannels.at("data").at(0).Receive(request);
|
||||||
|
|
||||||
LOG(INFO) << "Received request from client: \"" << string(static_cast<char*>(request->GetData()), request->GetSize()) << "\"";
|
LOG(INFO) << "Received request from client: \"" << string(static_cast<char*>(request->GetData()), request->GetSize()) << "\"";
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ void FairMQExampleServer::Run()
|
||||||
|
|
||||||
FairMQMessage* reply = fTransportFactory->CreateMessage(const_cast<char*>(text->c_str()), text->length(), CustomCleanup, text);
|
FairMQMessage* reply = fTransportFactory->CreateMessage(const_cast<char*>(text->c_str()), text->length(), CustomCleanup, text);
|
||||||
|
|
||||||
fChannels["data"].at(0).Send(reply);
|
fChannels.at("data").at(0).Send(reply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -28,28 +27,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FairMQExampleClient client;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
client.ChangeState(FairMQExampleClient::END);
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct DeviceOptions
|
typedef struct DeviceOptions
|
||||||
{
|
{
|
||||||
DeviceOptions() :
|
DeviceOptions() :
|
||||||
|
@ -88,7 +65,8 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQExampleClient client;
|
||||||
|
client.CatchSignals();
|
||||||
|
|
||||||
DeviceOptions_t options;
|
DeviceOptions_t options;
|
||||||
try
|
try
|
||||||
|
@ -122,24 +100,14 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
client.fChannels["data"].push_back(requestChannel);
|
client.fChannels["data"].push_back(requestChannel);
|
||||||
|
|
||||||
client.ChangeState(FairMQExampleClient::INIT_DEVICE);
|
client.ChangeState("INIT_DEVICE");
|
||||||
client.WaitForEndOfState(FairMQExampleClient::INIT_DEVICE);
|
client.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
client.ChangeState(FairMQExampleClient::INIT_TASK);
|
client.ChangeState("INIT_TASK");
|
||||||
client.WaitForEndOfState(FairMQExampleClient::INIT_TASK);
|
client.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
client.ChangeState(FairMQExampleClient::RUN);
|
client.ChangeState("RUN");
|
||||||
client.WaitForEndOfState(FairMQExampleClient::RUN);
|
client.InteractiveStateLoop();
|
||||||
|
|
||||||
client.ChangeState(FairMQExampleClient::STOP);
|
|
||||||
|
|
||||||
client.ChangeState(FairMQExampleClient::RESET_TASK);
|
|
||||||
client.WaitForEndOfState(FairMQExampleClient::RESET_TASK);
|
|
||||||
|
|
||||||
client.ChangeState(FairMQExampleClient::RESET_DEVICE);
|
|
||||||
client.WaitForEndOfState(FairMQExampleClient::RESET_DEVICE);
|
|
||||||
|
|
||||||
client.ChangeState(FairMQExampleClient::END);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
#include "FairMQExampleServer.h"
|
#include "FairMQExampleServer.h"
|
||||||
|
@ -26,31 +25,10 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FairMQExampleServer server;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
server.ChangeState(FairMQExampleServer::END);
|
|
||||||
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQExampleServer server;
|
||||||
|
server.CatchSignals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
|
@ -72,24 +50,14 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
server.fChannels["data"].push_back(replyChannel);
|
server.fChannels["data"].push_back(replyChannel);
|
||||||
|
|
||||||
server.ChangeState(FairMQExampleServer::INIT_DEVICE);
|
server.ChangeState("INIT_DEVICE");
|
||||||
server.WaitForEndOfState(FairMQExampleServer::INIT_DEVICE);
|
server.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
server.ChangeState(FairMQExampleServer::INIT_TASK);
|
server.ChangeState("INIT_TASK");
|
||||||
server.WaitForEndOfState(FairMQExampleServer::INIT_TASK);
|
server.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
server.ChangeState(FairMQExampleServer::RUN);
|
server.ChangeState("RUN");
|
||||||
server.WaitForEndOfState(FairMQExampleServer::RUN);
|
server.InteractiveStateLoop();
|
||||||
|
|
||||||
server.ChangeState(FairMQExampleServer::STOP);
|
|
||||||
|
|
||||||
server.ChangeState(FairMQExampleServer::RESET_TASK);
|
|
||||||
server.WaitForEndOfState(FairMQExampleServer::RESET_TASK);
|
|
||||||
|
|
||||||
server.ChangeState(FairMQExampleServer::RESET_DEVICE);
|
|
||||||
server.WaitForEndOfState(FairMQExampleServer::RESET_DEVICE);
|
|
||||||
|
|
||||||
server.ChangeState(FairMQExampleServer::END);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nanomsg/nn.h>
|
#include <nanomsg/nn.h>
|
||||||
|
#include <nanomsg/pipeline.h>
|
||||||
|
#include <nanomsg/pubsub.h>
|
||||||
|
#include <nanomsg/reqrep.h>
|
||||||
|
#include <nanomsg/pair.h>
|
||||||
|
|
||||||
#include "FairMQPollerNN.h"
|
#include "FairMQPollerNN.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
@ -21,7 +25,8 @@ using namespace std;
|
||||||
|
|
||||||
FairMQPollerNN::FairMQPollerNN(const vector<FairMQChannel>& channels)
|
FairMQPollerNN::FairMQPollerNN(const vector<FairMQChannel>& channels)
|
||||||
: items()
|
: items()
|
||||||
, fNumItems()
|
, fNumItems(0)
|
||||||
|
, fOffsetMap()
|
||||||
{
|
{
|
||||||
fNumItems = channels.size();
|
fNumItems = channels.size();
|
||||||
items = new nn_pollfd[fNumItems];
|
items = new nn_pollfd[fNumItems];
|
||||||
|
@ -33,15 +38,95 @@ FairMQPollerNN::FairMQPollerNN(const vector<FairMQChannel>& channels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FairMQPollerNN::FairMQPollerNN(map< string,vector<FairMQChannel> >& channelsMap, initializer_list<string> channelList)
|
||||||
|
: items()
|
||||||
|
, fNumItems(0)
|
||||||
|
, fOffsetMap()
|
||||||
|
{
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// calculate offsets and the total size of the poll item set
|
||||||
|
for (string channel : channelList)
|
||||||
|
{
|
||||||
|
fOffsetMap[channel] = offset;
|
||||||
|
offset += channelsMap.at(channel).size();
|
||||||
|
fNumItems += channelsMap.at(channel).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
items = new nn_pollfd[fNumItems];
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
for (string channel : channelList)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < channelsMap.at(channel).size(); ++i)
|
||||||
|
{
|
||||||
|
index = fOffsetMap[channel] + i;
|
||||||
|
items[index].fd = channelsMap.at(channel).at(i).fSocket->GetSocket(1);
|
||||||
|
items[index].events = NN_POLLIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "At least one of the provided channel keys for poller initialization is invalid";
|
||||||
|
LOG(ERROR) << "Out of Range error: " << oor.what() << '\n';
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FairMQPollerNN::FairMQPollerNN(FairMQSocket& dataSocket, FairMQSocket& cmdSocket)
|
||||||
|
: items()
|
||||||
|
, fNumItems(2)
|
||||||
|
, fOffsetMap()
|
||||||
|
{
|
||||||
|
items = new nn_pollfd[fNumItems];
|
||||||
|
|
||||||
|
items[0].fd = cmdSocket.GetSocket(1);
|
||||||
|
items[0].events = NN_POLLIN;
|
||||||
|
|
||||||
|
int type = 0;
|
||||||
|
size_t sz = sizeof(type);
|
||||||
|
nn_getsockopt(dataSocket.GetSocket(1), NN_SOL_SOCKET, NN_PROTOCOL, &type, &sz);
|
||||||
|
|
||||||
|
items[1].fd = dataSocket.GetSocket(1);
|
||||||
|
|
||||||
|
if (type == NN_REQ || type == NN_REP || type == NN_PAIR)
|
||||||
|
{
|
||||||
|
items[1].events = NN_POLLIN|NN_POLLOUT;
|
||||||
|
}
|
||||||
|
else if (type == NN_PUSH || type == NN_PUB)
|
||||||
|
{
|
||||||
|
items[1].events = NN_POLLOUT;
|
||||||
|
}
|
||||||
|
else if (type == NN_PULL || type == NN_SUB)
|
||||||
|
{
|
||||||
|
items[1].events = NN_POLLIN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "invalid poller configuration, exiting.";
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FairMQPollerNN::Poll(int timeout)
|
void FairMQPollerNN::Poll(int timeout)
|
||||||
{
|
{
|
||||||
if (nn_poll(items, fNumItems, timeout) < 0)
|
if (nn_poll(items, fNumItems, timeout) < 0)
|
||||||
|
{
|
||||||
|
if (errno == ETERM)
|
||||||
|
{
|
||||||
|
LOG(DEBUG) << "polling exited, reason: " << nn_strerror(errno);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "polling failed, reason: " << nn_strerror(errno);
|
LOG(ERROR) << "polling failed, reason: " << nn_strerror(errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool FairMQPollerNN::CheckInput(int index)
|
bool FairMQPollerNN::CheckInput(const int index)
|
||||||
{
|
{
|
||||||
if (items[index].revents & NN_POLLIN)
|
if (items[index].revents & NN_POLLIN)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +136,7 @@ bool FairMQPollerNN::CheckInput(int index)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQPollerNN::CheckOutput(int index)
|
bool FairMQPollerNN::CheckOutput(const int index)
|
||||||
{
|
{
|
||||||
if (items[index].revents & NN_POLLOUT)
|
if (items[index].revents & NN_POLLOUT)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +146,44 @@ bool FairMQPollerNN::CheckOutput(int index)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FairMQPollerNN::CheckInput(const string channelKey, const int index)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (items[fOffsetMap.at(channelKey) + index].revents & NN_POLLIN)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "Invalid channel key: \"" << channelKey << "\"";
|
||||||
|
LOG(ERROR) << "Out of Range error: " << oor.what() << '\n';
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FairMQPollerNN::CheckOutput(const string channelKey, const int index)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (items[fOffsetMap.at(channelKey) + index].revents & NN_POLLOUT)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "Invalid channel key: \"" << channelKey << "\"";
|
||||||
|
LOG(ERROR) << "Out of Range error: " << oor.what() << '\n';
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FairMQPollerNN::~FairMQPollerNN()
|
FairMQPollerNN::~FairMQPollerNN()
|
||||||
{
|
{
|
||||||
if (items != NULL)
|
if (items != NULL)
|
||||||
|
|
|
@ -16,25 +16,40 @@
|
||||||
#define FAIRMQPOLLERNN_H_
|
#define FAIRMQPOLLERNN_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#include "FairMQPoller.h"
|
#include "FairMQPoller.h"
|
||||||
#include "FairMQChannel.h"
|
#include "FairMQChannel.h"
|
||||||
|
#include "FairMQTransportFactoryNN.h"
|
||||||
|
|
||||||
|
class FairMQChannel;
|
||||||
|
|
||||||
class FairMQPollerNN : public FairMQPoller
|
class FairMQPollerNN : public FairMQPoller
|
||||||
{
|
{
|
||||||
|
friend class FairMQChannel;
|
||||||
|
friend class FairMQTransportFactoryNN;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FairMQPollerNN(const std::vector<FairMQChannel>& channels);
|
FairMQPollerNN(const std::vector<FairMQChannel>& channels);
|
||||||
|
FairMQPollerNN(std::map< std::string,std::vector<FairMQChannel> >& channelsMap, std::initializer_list<std::string> channelList);
|
||||||
|
|
||||||
virtual void Poll(int timeout);
|
virtual void Poll(const int timeout);
|
||||||
virtual bool CheckInput(int index);
|
virtual bool CheckInput(const int index);
|
||||||
virtual bool CheckOutput(int index);
|
virtual bool CheckOutput(const int index);
|
||||||
|
virtual bool CheckInput(const std::string channelKey, const int index);
|
||||||
|
virtual bool CheckOutput(const std::string channelKey, const int index);
|
||||||
|
|
||||||
virtual ~FairMQPollerNN();
|
virtual ~FairMQPollerNN();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
FairMQPollerNN(FairMQSocket& dataSocket, FairMQSocket& cmdSocket);
|
||||||
|
|
||||||
nn_pollfd* items;
|
nn_pollfd* items;
|
||||||
int fNumItems;
|
int fNumItems;
|
||||||
|
|
||||||
|
std::unordered_map<std::string,int> fOffsetMap;
|
||||||
|
|
||||||
/// Copy Constructor
|
/// Copy Constructor
|
||||||
FairMQPollerNN(const FairMQPollerNN&);
|
FairMQPollerNN(const FairMQPollerNN&);
|
||||||
FairMQPollerNN operator=(const FairMQPollerNN&);
|
FairMQPollerNN operator=(const FairMQPollerNN&);
|
||||||
|
|
|
@ -22,7 +22,7 @@ using namespace std;
|
||||||
|
|
||||||
FairMQSocketNN::FairMQSocketNN(const string& type, const std::string& name, int numIoThreads)
|
FairMQSocketNN::FairMQSocketNN(const string& type, const std::string& name, int numIoThreads)
|
||||||
: FairMQSocket(0, 0, NN_DONTWAIT)
|
: FairMQSocket(0, 0, NN_DONTWAIT)
|
||||||
, fSocket()
|
, fSocket(-1)
|
||||||
, fId()
|
, fId()
|
||||||
, fBytesTx(0)
|
, fBytesTx(0)
|
||||||
, fBytesRx(0)
|
, fBytesRx(0)
|
||||||
|
|
|
@ -45,3 +45,13 @@ FairMQPoller* FairMQTransportFactoryNN::CreatePoller(const vector<FairMQChannel>
|
||||||
{
|
{
|
||||||
return new FairMQPollerNN(channels);
|
return new FairMQPollerNN(channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FairMQPoller* FairMQTransportFactoryNN::CreatePoller(std::map< std::string,std::vector<FairMQChannel> >& channelsMap, std::initializer_list<std::string> channelList)
|
||||||
|
{
|
||||||
|
return new FairMQPollerNN(channelsMap, channelList);
|
||||||
|
}
|
||||||
|
|
||||||
|
FairMQPoller* FairMQTransportFactoryNN::CreatePoller(FairMQSocket& dataSocket, FairMQSocket& cmdSocket)
|
||||||
|
{
|
||||||
|
return new FairMQPollerNN(dataSocket, cmdSocket);
|
||||||
|
}
|
||||||
|
|
|
@ -30,8 +30,12 @@ class FairMQTransportFactoryNN : public FairMQTransportFactory
|
||||||
virtual FairMQMessage* CreateMessage();
|
virtual FairMQMessage* CreateMessage();
|
||||||
virtual FairMQMessage* CreateMessage(size_t size);
|
virtual FairMQMessage* CreateMessage(size_t size);
|
||||||
virtual FairMQMessage* CreateMessage(void* data, size_t size, fairmq_free_fn *ffn = NULL, void* hint = NULL);
|
virtual FairMQMessage* CreateMessage(void* data, size_t size, fairmq_free_fn *ffn = NULL, void* hint = NULL);
|
||||||
|
|
||||||
virtual FairMQSocket* CreateSocket(const std::string& type, const std::string& name, int numIoThreads);
|
virtual FairMQSocket* CreateSocket(const std::string& type, const std::string& name, int numIoThreads);
|
||||||
|
|
||||||
virtual FairMQPoller* CreatePoller(const std::vector<FairMQChannel>& channels);
|
virtual FairMQPoller* CreatePoller(const std::vector<FairMQChannel>& channels);
|
||||||
|
virtual FairMQPoller* CreatePoller(std::map< std::string,std::vector<FairMQChannel> >& channelsMap, std::initializer_list<std::string> channelList);
|
||||||
|
virtual FairMQPoller* CreatePoller(FairMQSocket& dataSocket, FairMQSocket& cmdSocket);
|
||||||
|
|
||||||
virtual ~FairMQTransportFactoryNN() {};
|
virtual ~FairMQTransportFactoryNN() {};
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
// Boost
|
// Boost
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
|
@ -22,7 +23,7 @@
|
||||||
namespace FairMQParser
|
namespace FairMQParser
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef std::map< std::string,std::vector<FairMQChannel> > FairMQMap;
|
typedef std::unordered_map< std::string,std::vector<FairMQChannel> > FairMQMap;
|
||||||
|
|
||||||
FairMQMap ptreeToMQMap(const boost::property_tree::ptree& pt, const std::string& deviceId, const std::string& rootNode, const std::string& formatFlag = "json");
|
FairMQMap ptreeToMQMap(const boost::property_tree::ptree& pt, const std::string& deviceId, const std::string& rootNode, const std::string& formatFlag = "json");
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#ifndef FAIRMQPROGOPTIONS_H
|
#ifndef FAIRMQPROGOPTIONS_H
|
||||||
#define FAIRMQPROGOPTIONS_H
|
#define FAIRMQPROGOPTIONS_H
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "FairProgOptions.h"
|
#include "FairProgOptions.h"
|
||||||
|
|
||||||
#include "FairMQChannel.h"
|
#include "FairMQChannel.h"
|
||||||
|
@ -25,7 +27,7 @@ namespace pt = boost::property_tree;
|
||||||
class FairMQProgOptions : public FairProgOptions
|
class FairMQProgOptions : public FairProgOptions
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef std::map< std::string,std::vector<FairMQChannel> > FairMQMap;
|
typedef std::unordered_map< std::string,std::vector<FairMQChannel> > FairMQMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FairMQProgOptions();
|
FairMQProgOptions();
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "FairMQBinSampler.h"
|
#include "FairMQBinSampler.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
FairMQBinSampler::FairMQBinSampler()
|
FairMQBinSampler::FairMQBinSampler()
|
||||||
: fEventSize(10000)
|
: fEventSize(10000)
|
||||||
, fEventRate(1)
|
, fEventRate(1)
|
||||||
|
@ -33,25 +35,18 @@ FairMQBinSampler::~FairMQBinSampler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBinSampler::Init()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQBinSampler::Run()
|
void FairMQBinSampler::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
|
||||||
// boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
|
||||||
boost::thread resetEventCounter(boost::bind(&FairMQBinSampler::ResetEventCounter, this));
|
boost::thread resetEventCounter(boost::bind(&FairMQBinSampler::ResetEventCounter, this));
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
LOG(DEBUG) << "Message size: " << fEventSize * sizeof(Content) << " bytes.";
|
LOG(DEBUG) << "Message size: " << fEventSize * sizeof(Content) << " bytes.";
|
||||||
|
|
||||||
while (fState == RUNNING)
|
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||||
{
|
|
||||||
|
|
||||||
|
while (CheckCurrentState(RUNNING))
|
||||||
|
{
|
||||||
Content* payload = new Content[fEventSize];
|
Content* payload = new Content[fEventSize];
|
||||||
|
|
||||||
for (int i = 0; i < fEventSize; ++i)
|
for (int i = 0; i < fEventSize; ++i)
|
||||||
|
@ -67,7 +62,7 @@ void FairMQBinSampler::Run()
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage(fEventSize * sizeof(Content));
|
FairMQMessage* msg = fTransportFactory->CreateMessage(fEventSize * sizeof(Content));
|
||||||
memcpy(msg->GetData(), payload, fEventSize * sizeof(Content));
|
memcpy(msg->GetData(), payload, fEventSize * sizeof(Content));
|
||||||
|
|
||||||
fPayloadOutputs->at(0)->Send(msg);
|
dataOutChannel.Send(msg);
|
||||||
|
|
||||||
--fEventCounter;
|
--fEventCounter;
|
||||||
|
|
||||||
|
@ -80,16 +75,13 @@ void FairMQBinSampler::Run()
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
rateLogger.interrupt();
|
|
||||||
resetEventCounter.interrupt();
|
resetEventCounter.interrupt();
|
||||||
|
|
||||||
rateLogger.join();
|
|
||||||
resetEventCounter.join();
|
resetEventCounter.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBinSampler::ResetEventCounter()
|
void FairMQBinSampler::ResetEventCounter()
|
||||||
{
|
{
|
||||||
while (true)
|
while (GetCurrentState() == RUNNING)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -103,61 +95,26 @@ void FairMQBinSampler::ResetEventCounter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBinSampler::Log(int intervalInMs)
|
void FairMQBinSampler::SetProperty(const int key, const string& value)
|
||||||
{
|
|
||||||
timestamp_t t0;
|
|
||||||
timestamp_t t1;
|
|
||||||
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
|
|
||||||
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
|
|
||||||
unsigned long bytesNew = 0;
|
|
||||||
unsigned long messagesNew = 0;
|
|
||||||
double megabytesPerSecond = 0;
|
|
||||||
double messagesPerSecond = 0;
|
|
||||||
|
|
||||||
t0 = get_timestamp();
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
|
|
||||||
|
|
||||||
t1 = get_timestamp();
|
|
||||||
|
|
||||||
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
|
|
||||||
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
|
|
||||||
|
|
||||||
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
|
||||||
|
|
||||||
megabytesPerSecond = ((double)(bytesNew - bytes) / (1024. * 1024.)) / (double)timeSinceLastLog_ms * 1000.;
|
|
||||||
messagesPerSecond = (double)(messagesNew - messages) / (double)timeSinceLastLog_ms * 1000.;
|
|
||||||
|
|
||||||
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
|
|
||||||
|
|
||||||
bytes = bytesNew;
|
|
||||||
messages = messagesNew;
|
|
||||||
t0 = t1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQBinSampler::SetProperty(const int key, const string& value, const int slot /*= 0*/)
|
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
FairMQDevice::SetProperty(key, value, slot);
|
FairMQDevice::SetProperty(key, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string FairMQBinSampler::GetProperty(const int key, const string& default_ /*= ""*/, const int slot /*= 0*/)
|
string FairMQBinSampler::GetProperty(const int key, const string& default_ /*= ""*/)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
return FairMQDevice::GetProperty(key, default_, slot);
|
return FairMQDevice::GetProperty(key, default_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBinSampler::SetProperty(const int key, const int value, const int slot /*= 0*/)
|
void FairMQBinSampler::SetProperty(const int key, const int value)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
|
@ -168,12 +125,12 @@ void FairMQBinSampler::SetProperty(const int key, const int value, const int slo
|
||||||
fEventRate = value;
|
fEventRate = value;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FairMQDevice::SetProperty(key, value, slot);
|
FairMQDevice::SetProperty(key, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQBinSampler::GetProperty(const int key, const int default_ /*= 0*/, const int slot /*= 0*/)
|
int FairMQBinSampler::GetProperty(const int key, const int default_ /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
|
@ -182,6 +139,6 @@ int FairMQBinSampler::GetProperty(const int key, const int default_ /*= 0*/, con
|
||||||
case EventRate:
|
case EventRate:
|
||||||
return fEventRate;
|
return fEventRate;
|
||||||
default:
|
default:
|
||||||
return FairMQDevice::GetProperty(key, default_, slot);
|
return FairMQDevice::GetProperty(key, default_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,25 +33,25 @@ class FairMQBinSampler : public FairMQDevice
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
InputFile = FairMQDevice::Last,
|
EventRate = FairMQDevice::Last,
|
||||||
EventRate,
|
|
||||||
EventSize,
|
EventSize,
|
||||||
Last
|
Last
|
||||||
};
|
};
|
||||||
FairMQBinSampler();
|
FairMQBinSampler();
|
||||||
virtual ~FairMQBinSampler();
|
virtual ~FairMQBinSampler();
|
||||||
void Log(int intervalInMs);
|
|
||||||
void ResetEventCounter();
|
void ResetEventCounter();
|
||||||
virtual void SetProperty(const int key, const string& value, const int slot = 0);
|
|
||||||
virtual string GetProperty(const int key, const string& default_ = "", const int slot = 0);
|
virtual void SetProperty(const int key, const std::string& value);
|
||||||
virtual void SetProperty(const int key, const int value, const int slot = 0);
|
virtual std::string GetProperty(const int key, const std::string& default_ = "");
|
||||||
virtual int GetProperty(const int key, const int default_ = 0, const int slot = 0);
|
virtual void SetProperty(const int key, const int value);
|
||||||
|
virtual int GetProperty(const int key, const int default_ = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int fEventSize;
|
int fEventSize;
|
||||||
int fEventRate;
|
int fEventRate;
|
||||||
int fEventCounter;
|
int fEventCounter;
|
||||||
virtual void Init();
|
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,15 +24,13 @@ FairMQBinSink::FairMQBinSink()
|
||||||
|
|
||||||
void FairMQBinSink::Run()
|
void FairMQBinSink::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
while (CheckCurrentState(RUNNING))
|
||||||
|
|
||||||
while (fState == RUNNING)
|
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
fPayloadInputs->at(0)->Receive(msg);
|
dataInChannel.Receive(msg);
|
||||||
|
|
||||||
int inputSize = msg->GetSize();
|
int inputSize = msg->GetSize();
|
||||||
// int numInput = inputSize / sizeof(Content);
|
// int numInput = inputSize / sizeof(Content);
|
||||||
|
@ -44,9 +42,6 @@ void FairMQBinSink::Run()
|
||||||
|
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
rateLogger.interrupt();
|
|
||||||
rateLogger.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQBinSink::~FairMQBinSink()
|
FairMQBinSink::~FairMQBinSink()
|
||||||
|
|
|
@ -35,23 +35,16 @@ FairMQProtoSampler::~FairMQProtoSampler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQProtoSampler::Init()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQProtoSampler::Run()
|
void FairMQProtoSampler::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
|
||||||
// boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
|
||||||
boost::thread resetEventCounter(boost::bind(&FairMQProtoSampler::ResetEventCounter, this));
|
boost::thread resetEventCounter(boost::bind(&FairMQProtoSampler::ResetEventCounter, this));
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
while (fState == RUNNING)
|
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||||
{
|
|
||||||
|
|
||||||
|
while (CheckCurrentState(RUNNING))
|
||||||
|
{
|
||||||
sampler::Payload p;
|
sampler::Payload p;
|
||||||
|
|
||||||
for (int i = 0; i < fEventSize; ++i)
|
for (int i = 0; i < fEventSize; ++i)
|
||||||
|
@ -73,7 +66,7 @@ void FairMQProtoSampler::Run()
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage(size);
|
FairMQMessage* msg = fTransportFactory->CreateMessage(size);
|
||||||
memcpy(msg->GetData(), str.c_str(), size);
|
memcpy(msg->GetData(), str.c_str(), size);
|
||||||
|
|
||||||
fPayloadOutputs->at(0)->Send(msg);
|
dataOutChannel.Send(msg);
|
||||||
|
|
||||||
--fEventCounter;
|
--fEventCounter;
|
||||||
|
|
||||||
|
@ -85,10 +78,7 @@ void FairMQProtoSampler::Run()
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
rateLogger.interrupt();
|
|
||||||
resetEventCounter.interrupt();
|
resetEventCounter.interrupt();
|
||||||
|
|
||||||
rateLogger.join();
|
|
||||||
resetEventCounter.join();
|
resetEventCounter.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,61 +98,26 @@ void FairMQProtoSampler::ResetEventCounter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQProtoSampler::Log(int intervalInMs)
|
void FairMQProtoSampler::SetProperty(const int key, const string& value)
|
||||||
{
|
|
||||||
timestamp_t t0;
|
|
||||||
timestamp_t t1;
|
|
||||||
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
|
|
||||||
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
|
|
||||||
unsigned long bytesNew = 0;
|
|
||||||
unsigned long messagesNew = 0;
|
|
||||||
double megabytesPerSecond = 0;
|
|
||||||
double messagesPerSecond = 0;
|
|
||||||
|
|
||||||
t0 = get_timestamp();
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
|
|
||||||
|
|
||||||
t1 = get_timestamp();
|
|
||||||
|
|
||||||
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
|
|
||||||
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
|
|
||||||
|
|
||||||
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
|
||||||
|
|
||||||
megabytesPerSecond = ((double)(bytesNew - bytes) / (1024. * 1024.)) / (double)timeSinceLastLog_ms * 1000.;
|
|
||||||
messagesPerSecond = (double)(messagesNew - messages) / (double)timeSinceLastLog_ms * 1000.;
|
|
||||||
|
|
||||||
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
|
|
||||||
|
|
||||||
bytes = bytesNew;
|
|
||||||
messages = messagesNew;
|
|
||||||
t0 = t1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FairMQProtoSampler::SetProperty(const int key, const string& value, const int slot /*= 0*/)
|
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
FairMQDevice::SetProperty(key, value, slot);
|
FairMQDevice::SetProperty(key, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string FairMQProtoSampler::GetProperty(const int key, const string& default_ /*= ""*/, const int slot /*= 0*/)
|
string FairMQProtoSampler::GetProperty(const int key, const string& default_ /*= ""*/)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
return FairMQDevice::GetProperty(key, default_, slot);
|
return FairMQDevice::GetProperty(key, default_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQProtoSampler::SetProperty(const int key, const int value, const int slot /*= 0*/)
|
void FairMQProtoSampler::SetProperty(const int key, const int value)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
|
@ -173,12 +128,12 @@ void FairMQProtoSampler::SetProperty(const int key, const int value, const int s
|
||||||
fEventRate = value;
|
fEventRate = value;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FairMQDevice::SetProperty(key, value, slot);
|
FairMQDevice::SetProperty(key, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQProtoSampler::GetProperty(const int key, const int default_ /*= 0*/, const int slot /*= 0*/)
|
int FairMQProtoSampler::GetProperty(const int key, const int default_ /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
|
@ -187,6 +142,6 @@ int FairMQProtoSampler::GetProperty(const int key, const int default_ /*= 0*/, c
|
||||||
case EventRate:
|
case EventRate:
|
||||||
return fEventRate;
|
return fEventRate;
|
||||||
default:
|
default:
|
||||||
return FairMQDevice::GetProperty(key, default_, slot);
|
return FairMQDevice::GetProperty(key, default_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,25 +24,25 @@ class FairMQProtoSampler : public FairMQDevice
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
InputFile = FairMQDevice::Last,
|
EventRate = FairMQDevice::Last,
|
||||||
EventRate,
|
|
||||||
EventSize,
|
EventSize,
|
||||||
Last
|
Last
|
||||||
};
|
};
|
||||||
FairMQProtoSampler();
|
FairMQProtoSampler();
|
||||||
virtual ~FairMQProtoSampler();
|
virtual ~FairMQProtoSampler();
|
||||||
void Log(int intervalInMs);
|
|
||||||
void ResetEventCounter();
|
void ResetEventCounter();
|
||||||
virtual void SetProperty(const int key, const std::string& value, const int slot = 0);
|
|
||||||
virtual std::string GetProperty(const int key, const std::string& default_ = "", const int slot = 0);
|
virtual void SetProperty(const int key, const std::string& value);
|
||||||
virtual void SetProperty(const int key, const int value, const int slot = 0);
|
virtual std::string GetProperty(const int key, const std::string& default_ = "");
|
||||||
virtual int GetProperty(const int key, const int default_ = 0, const int slot = 0);
|
virtual void SetProperty(const int key, const int value);
|
||||||
|
virtual int GetProperty(const int key, const int default_ = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int fEventSize;
|
int fEventSize;
|
||||||
int fEventRate;
|
int fEventRate;
|
||||||
int fEventCounter;
|
int fEventCounter;
|
||||||
virtual void Init();
|
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,15 +26,13 @@ FairMQProtoSink::FairMQProtoSink()
|
||||||
|
|
||||||
void FairMQProtoSink::Run()
|
void FairMQProtoSink::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
while (CheckCurrentState(RUNNING))
|
||||||
|
|
||||||
while (fState == RUNNING)
|
|
||||||
{
|
{
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
fPayloadInputs->at(0)->Receive(msg);
|
dataInChannel.Receive(msg);
|
||||||
|
|
||||||
sampler::Payload p;
|
sampler::Payload p;
|
||||||
|
|
||||||
|
@ -47,9 +45,6 @@ void FairMQProtoSink::Run()
|
||||||
|
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
rateLogger.interrupt();
|
|
||||||
rateLogger.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQProtoSink::~FairMQProtoSink()
|
FairMQProtoSink::~FairMQProtoSink()
|
||||||
|
|
|
@ -1,698 +0,0 @@
|
||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
// source: payload.proto
|
|
||||||
|
|
||||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
|
||||||
#include "payload.pb.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
|
||||||
#include <google/protobuf/stubs/once.h>
|
|
||||||
#include <google/protobuf/io/coded_stream.h>
|
|
||||||
#include <google/protobuf/wire_format_lite_inl.h>
|
|
||||||
#include <google/protobuf/descriptor.h>
|
|
||||||
#include <google/protobuf/generated_message_reflection.h>
|
|
||||||
#include <google/protobuf/reflection_ops.h>
|
|
||||||
#include <google/protobuf/wire_format.h>
|
|
||||||
// @@protoc_insertion_point(includes)
|
|
||||||
|
|
||||||
namespace sampler {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const ::google::protobuf::Descriptor* Content_descriptor_ = NULL;
|
|
||||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
|
||||||
Content_reflection_ = NULL;
|
|
||||||
const ::google::protobuf::Descriptor* Payload_descriptor_ = NULL;
|
|
||||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
|
||||||
Payload_reflection_ = NULL;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
void protobuf_AssignDesc_payload_2eproto() {
|
|
||||||
protobuf_AddDesc_payload_2eproto();
|
|
||||||
const ::google::protobuf::FileDescriptor* file =
|
|
||||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
|
||||||
"payload.proto");
|
|
||||||
GOOGLE_CHECK(file != NULL);
|
|
||||||
Content_descriptor_ = file->message_type(0);
|
|
||||||
static const int Content_offsets_[5] = {
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, a_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, b_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, x_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, y_),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, z_),
|
|
||||||
};
|
|
||||||
Content_reflection_ =
|
|
||||||
new ::google::protobuf::internal::GeneratedMessageReflection(
|
|
||||||
Content_descriptor_,
|
|
||||||
Content::default_instance_,
|
|
||||||
Content_offsets_,
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, _has_bits_[0]),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, _unknown_fields_),
|
|
||||||
-1,
|
|
||||||
::google::protobuf::DescriptorPool::generated_pool(),
|
|
||||||
::google::protobuf::MessageFactory::generated_factory(),
|
|
||||||
sizeof(Content));
|
|
||||||
Payload_descriptor_ = file->message_type(1);
|
|
||||||
static const int Payload_offsets_[1] = {
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Payload, data_),
|
|
||||||
};
|
|
||||||
Payload_reflection_ =
|
|
||||||
new ::google::protobuf::internal::GeneratedMessageReflection(
|
|
||||||
Payload_descriptor_,
|
|
||||||
Payload::default_instance_,
|
|
||||||
Payload_offsets_,
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Payload, _has_bits_[0]),
|
|
||||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Payload, _unknown_fields_),
|
|
||||||
-1,
|
|
||||||
::google::protobuf::DescriptorPool::generated_pool(),
|
|
||||||
::google::protobuf::MessageFactory::generated_factory(),
|
|
||||||
sizeof(Payload));
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
|
||||||
inline void protobuf_AssignDescriptorsOnce() {
|
|
||||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
|
||||||
&protobuf_AssignDesc_payload_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_RegisterTypes(const ::std::string&) {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
|
||||||
Content_descriptor_, &Content::default_instance());
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
|
||||||
Payload_descriptor_, &Payload::default_instance());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void protobuf_ShutdownFile_payload_2eproto() {
|
|
||||||
delete Content::default_instance_;
|
|
||||||
delete Content_reflection_;
|
|
||||||
delete Payload::default_instance_;
|
|
||||||
delete Payload_reflection_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void protobuf_AddDesc_payload_2eproto() {
|
|
||||||
static bool already_here = false;
|
|
||||||
if (already_here) return;
|
|
||||||
already_here = true;
|
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
|
||||||
|
|
||||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
|
||||||
"\n\rpayload.proto\022\007sampler\"@\n\007Content\022\t\n\001a"
|
|
||||||
"\030\001 \001(\001\022\t\n\001b\030\002 \001(\001\022\t\n\001x\030\003 \001(\005\022\t\n\001y\030\004 \001(\005\022"
|
|
||||||
"\t\n\001z\030\005 \001(\005\")\n\007Payload\022\036\n\004data\030\001 \003(\0132\020.sa"
|
|
||||||
"mpler.Content", 133);
|
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
|
||||||
"payload.proto", &protobuf_RegisterTypes);
|
|
||||||
Content::default_instance_ = new Content();
|
|
||||||
Payload::default_instance_ = new Payload();
|
|
||||||
Content::default_instance_->InitAsDefaultInstance();
|
|
||||||
Payload::default_instance_->InitAsDefaultInstance();
|
|
||||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_payload_2eproto);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force AddDescriptors() to be called at static initialization time.
|
|
||||||
struct StaticDescriptorInitializer_payload_2eproto {
|
|
||||||
StaticDescriptorInitializer_payload_2eproto() {
|
|
||||||
protobuf_AddDesc_payload_2eproto();
|
|
||||||
}
|
|
||||||
} static_descriptor_initializer_payload_2eproto_;
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
const int Content::kAFieldNumber;
|
|
||||||
const int Content::kBFieldNumber;
|
|
||||||
const int Content::kXFieldNumber;
|
|
||||||
const int Content::kYFieldNumber;
|
|
||||||
const int Content::kZFieldNumber;
|
|
||||||
#endif // !_MSC_VER
|
|
||||||
|
|
||||||
Content::Content()
|
|
||||||
: ::google::protobuf::Message() {
|
|
||||||
SharedCtor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::InitAsDefaultInstance() {
|
|
||||||
}
|
|
||||||
|
|
||||||
Content::Content(const Content& from)
|
|
||||||
: ::google::protobuf::Message() {
|
|
||||||
SharedCtor();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::SharedCtor() {
|
|
||||||
_cached_size_ = 0;
|
|
||||||
a_ = 0;
|
|
||||||
b_ = 0;
|
|
||||||
x_ = 0;
|
|
||||||
y_ = 0;
|
|
||||||
z_ = 0;
|
|
||||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
|
||||||
}
|
|
||||||
|
|
||||||
Content::~Content() {
|
|
||||||
SharedDtor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::SharedDtor() {
|
|
||||||
if (this != default_instance_) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::SetCachedSize(int size) const {
|
|
||||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
|
||||||
_cached_size_ = size;
|
|
||||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
|
||||||
}
|
|
||||||
const ::google::protobuf::Descriptor* Content::descriptor() {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
return Content_descriptor_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Content& Content::default_instance() {
|
|
||||||
if (default_instance_ == NULL) protobuf_AddDesc_payload_2eproto();
|
|
||||||
return *default_instance_;
|
|
||||||
}
|
|
||||||
|
|
||||||
Content* Content::default_instance_ = NULL;
|
|
||||||
|
|
||||||
Content* Content::New() const {
|
|
||||||
return new Content;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::Clear() {
|
|
||||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
|
||||||
a_ = 0;
|
|
||||||
b_ = 0;
|
|
||||||
x_ = 0;
|
|
||||||
y_ = 0;
|
|
||||||
z_ = 0;
|
|
||||||
}
|
|
||||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
|
||||||
mutable_unknown_fields()->Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Content::MergePartialFromCodedStream(
|
|
||||||
::google::protobuf::io::CodedInputStream* input) {
|
|
||||||
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
|
|
||||||
::google::protobuf::uint32 tag;
|
|
||||||
while ((tag = input->ReadTag()) != 0) {
|
|
||||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
|
||||||
// optional double a = 1;
|
|
||||||
case 1: {
|
|
||||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) {
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
|
|
||||||
input, &a_)));
|
|
||||||
set_has_a();
|
|
||||||
} else {
|
|
||||||
goto handle_uninterpreted;
|
|
||||||
}
|
|
||||||
if (input->ExpectTag(17)) goto parse_b;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional double b = 2;
|
|
||||||
case 2: {
|
|
||||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) {
|
|
||||||
parse_b:
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
|
|
||||||
input, &b_)));
|
|
||||||
set_has_b();
|
|
||||||
} else {
|
|
||||||
goto handle_uninterpreted;
|
|
||||||
}
|
|
||||||
if (input->ExpectTag(24)) goto parse_x;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 x = 3;
|
|
||||||
case 3: {
|
|
||||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
|
||||||
parse_x:
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
|
||||||
input, &x_)));
|
|
||||||
set_has_x();
|
|
||||||
} else {
|
|
||||||
goto handle_uninterpreted;
|
|
||||||
}
|
|
||||||
if (input->ExpectTag(32)) goto parse_y;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 y = 4;
|
|
||||||
case 4: {
|
|
||||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
|
||||||
parse_y:
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
|
||||||
input, &y_)));
|
|
||||||
set_has_y();
|
|
||||||
} else {
|
|
||||||
goto handle_uninterpreted;
|
|
||||||
}
|
|
||||||
if (input->ExpectTag(40)) goto parse_z;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 z = 5;
|
|
||||||
case 5: {
|
|
||||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
|
||||||
parse_z:
|
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
|
||||||
input, &z_)));
|
|
||||||
set_has_z();
|
|
||||||
} else {
|
|
||||||
goto handle_uninterpreted;
|
|
||||||
}
|
|
||||||
if (input->ExpectAtEnd()) return true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
handle_uninterpreted:
|
|
||||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
|
||||||
input, tag, mutable_unknown_fields()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
#undef DO_
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::SerializeWithCachedSizes(
|
|
||||||
::google::protobuf::io::CodedOutputStream* output) const {
|
|
||||||
// optional double a = 1;
|
|
||||||
if (has_a()) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->a(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional double b = 2;
|
|
||||||
if (has_b()) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteDouble(2, this->b(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 x = 3;
|
|
||||||
if (has_x()) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->x(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 y = 4;
|
|
||||||
if (has_y()) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->y(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 z = 5;
|
|
||||||
if (has_z()) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->z(), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unknown_fields().empty()) {
|
|
||||||
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
|
||||||
unknown_fields(), output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::google::protobuf::uint8* Content::SerializeWithCachedSizesToArray(
|
|
||||||
::google::protobuf::uint8* target) const {
|
|
||||||
// optional double a = 1;
|
|
||||||
if (has_a()) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->a(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional double b = 2;
|
|
||||||
if (has_b()) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(2, this->b(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 x = 3;
|
|
||||||
if (has_x()) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->x(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 y = 4;
|
|
||||||
if (has_y()) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->y(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 z = 5;
|
|
||||||
if (has_z()) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->z(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unknown_fields().empty()) {
|
|
||||||
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
|
||||||
unknown_fields(), target);
|
|
||||||
}
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Content::ByteSize() const {
|
|
||||||
int total_size = 0;
|
|
||||||
|
|
||||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
|
||||||
// optional double a = 1;
|
|
||||||
if (has_a()) {
|
|
||||||
total_size += 1 + 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional double b = 2;
|
|
||||||
if (has_b()) {
|
|
||||||
total_size += 1 + 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 x = 3;
|
|
||||||
if (has_x()) {
|
|
||||||
total_size += 1 +
|
|
||||||
::google::protobuf::internal::WireFormatLite::Int32Size(
|
|
||||||
this->x());
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 y = 4;
|
|
||||||
if (has_y()) {
|
|
||||||
total_size += 1 +
|
|
||||||
::google::protobuf::internal::WireFormatLite::Int32Size(
|
|
||||||
this->y());
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 z = 5;
|
|
||||||
if (has_z()) {
|
|
||||||
total_size += 1 +
|
|
||||||
::google::protobuf::internal::WireFormatLite::Int32Size(
|
|
||||||
this->z());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!unknown_fields().empty()) {
|
|
||||||
total_size +=
|
|
||||||
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
|
||||||
unknown_fields());
|
|
||||||
}
|
|
||||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
|
||||||
_cached_size_ = total_size;
|
|
||||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
|
||||||
return total_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::MergeFrom(const ::google::protobuf::Message& from) {
|
|
||||||
GOOGLE_CHECK_NE(&from, this);
|
|
||||||
const Content* source =
|
|
||||||
::google::protobuf::internal::dynamic_cast_if_available<const Content*>(
|
|
||||||
&from);
|
|
||||||
if (source == NULL) {
|
|
||||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
|
||||||
} else {
|
|
||||||
MergeFrom(*source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::MergeFrom(const Content& from) {
|
|
||||||
GOOGLE_CHECK_NE(&from, this);
|
|
||||||
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
|
||||||
if (from.has_a()) {
|
|
||||||
set_a(from.a());
|
|
||||||
}
|
|
||||||
if (from.has_b()) {
|
|
||||||
set_b(from.b());
|
|
||||||
}
|
|
||||||
if (from.has_x()) {
|
|
||||||
set_x(from.x());
|
|
||||||
}
|
|
||||||
if (from.has_y()) {
|
|
||||||
set_y(from.y());
|
|
||||||
}
|
|
||||||
if (from.has_z()) {
|
|
||||||
set_z(from.z());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::CopyFrom(const ::google::protobuf::Message& from) {
|
|
||||||
if (&from == this) return;
|
|
||||||
Clear();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::CopyFrom(const Content& from) {
|
|
||||||
if (&from == this) return;
|
|
||||||
Clear();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Content::IsInitialized() const {
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Content::Swap(Content* other) {
|
|
||||||
if (other != this) {
|
|
||||||
std::swap(a_, other->a_);
|
|
||||||
std::swap(b_, other->b_);
|
|
||||||
std::swap(x_, other->x_);
|
|
||||||
std::swap(y_, other->y_);
|
|
||||||
std::swap(z_, other->z_);
|
|
||||||
std::swap(_has_bits_[0], other->_has_bits_[0]);
|
|
||||||
_unknown_fields_.Swap(&other->_unknown_fields_);
|
|
||||||
std::swap(_cached_size_, other->_cached_size_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::google::protobuf::Metadata Content::GetMetadata() const {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
::google::protobuf::Metadata metadata;
|
|
||||||
metadata.descriptor = Content_descriptor_;
|
|
||||||
metadata.reflection = Content_reflection_;
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
const int Payload::kDataFieldNumber;
|
|
||||||
#endif // !_MSC_VER
|
|
||||||
|
|
||||||
Payload::Payload()
|
|
||||||
: ::google::protobuf::Message() {
|
|
||||||
SharedCtor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::InitAsDefaultInstance() {
|
|
||||||
}
|
|
||||||
|
|
||||||
Payload::Payload(const Payload& from)
|
|
||||||
: ::google::protobuf::Message() {
|
|
||||||
SharedCtor();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::SharedCtor() {
|
|
||||||
_cached_size_ = 0;
|
|
||||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
|
||||||
}
|
|
||||||
|
|
||||||
Payload::~Payload() {
|
|
||||||
SharedDtor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::SharedDtor() {
|
|
||||||
if (this != default_instance_) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::SetCachedSize(int size) const {
|
|
||||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
|
||||||
_cached_size_ = size;
|
|
||||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
|
||||||
}
|
|
||||||
const ::google::protobuf::Descriptor* Payload::descriptor() {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
return Payload_descriptor_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Payload& Payload::default_instance() {
|
|
||||||
if (default_instance_ == NULL) protobuf_AddDesc_payload_2eproto();
|
|
||||||
return *default_instance_;
|
|
||||||
}
|
|
||||||
|
|
||||||
Payload* Payload::default_instance_ = NULL;
|
|
||||||
|
|
||||||
Payload* Payload::New() const {
|
|
||||||
return new Payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::Clear() {
|
|
||||||
data_.Clear();
|
|
||||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
|
||||||
mutable_unknown_fields()->Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Payload::MergePartialFromCodedStream(
|
|
||||||
::google::protobuf::io::CodedInputStream* input) {
|
|
||||||
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
|
|
||||||
::google::protobuf::uint32 tag;
|
|
||||||
while ((tag = input->ReadTag()) != 0) {
|
|
||||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
|
||||||
// repeated .sampler.Content data = 1;
|
|
||||||
case 1: {
|
|
||||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
|
|
||||||
parse_data:
|
|
||||||
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
|
|
||||||
input, add_data()));
|
|
||||||
} else {
|
|
||||||
goto handle_uninterpreted;
|
|
||||||
}
|
|
||||||
if (input->ExpectTag(10)) goto parse_data;
|
|
||||||
if (input->ExpectAtEnd()) return true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
handle_uninterpreted:
|
|
||||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
|
||||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
|
||||||
input, tag, mutable_unknown_fields()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
#undef DO_
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::SerializeWithCachedSizes(
|
|
||||||
::google::protobuf::io::CodedOutputStream* output) const {
|
|
||||||
// repeated .sampler.Content data = 1;
|
|
||||||
for (int i = 0; i < this->data_size(); i++) {
|
|
||||||
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
|
|
||||||
1, this->data(i), output);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unknown_fields().empty()) {
|
|
||||||
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
|
||||||
unknown_fields(), output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::google::protobuf::uint8* Payload::SerializeWithCachedSizesToArray(
|
|
||||||
::google::protobuf::uint8* target) const {
|
|
||||||
// repeated .sampler.Content data = 1;
|
|
||||||
for (int i = 0; i < this->data_size(); i++) {
|
|
||||||
target = ::google::protobuf::internal::WireFormatLite::
|
|
||||||
WriteMessageNoVirtualToArray(
|
|
||||||
1, this->data(i), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unknown_fields().empty()) {
|
|
||||||
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
|
||||||
unknown_fields(), target);
|
|
||||||
}
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Payload::ByteSize() const {
|
|
||||||
int total_size = 0;
|
|
||||||
|
|
||||||
// repeated .sampler.Content data = 1;
|
|
||||||
total_size += 1 * this->data_size();
|
|
||||||
for (int i = 0; i < this->data_size(); i++) {
|
|
||||||
total_size +=
|
|
||||||
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
|
|
||||||
this->data(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unknown_fields().empty()) {
|
|
||||||
total_size +=
|
|
||||||
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
|
||||||
unknown_fields());
|
|
||||||
}
|
|
||||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
|
||||||
_cached_size_ = total_size;
|
|
||||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
|
||||||
return total_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::MergeFrom(const ::google::protobuf::Message& from) {
|
|
||||||
GOOGLE_CHECK_NE(&from, this);
|
|
||||||
const Payload* source =
|
|
||||||
::google::protobuf::internal::dynamic_cast_if_available<const Payload*>(
|
|
||||||
&from);
|
|
||||||
if (source == NULL) {
|
|
||||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
|
||||||
} else {
|
|
||||||
MergeFrom(*source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::MergeFrom(const Payload& from) {
|
|
||||||
GOOGLE_CHECK_NE(&from, this);
|
|
||||||
data_.MergeFrom(from.data_);
|
|
||||||
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::CopyFrom(const ::google::protobuf::Message& from) {
|
|
||||||
if (&from == this) return;
|
|
||||||
Clear();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::CopyFrom(const Payload& from) {
|
|
||||||
if (&from == this) return;
|
|
||||||
Clear();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Payload::IsInitialized() const {
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Payload::Swap(Payload* other) {
|
|
||||||
if (other != this) {
|
|
||||||
data_.Swap(&other->data_);
|
|
||||||
std::swap(_has_bits_[0], other->_has_bits_[0]);
|
|
||||||
_unknown_fields_.Swap(&other->_unknown_fields_);
|
|
||||||
std::swap(_cached_size_, other->_cached_size_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::google::protobuf::Metadata Payload::GetMetadata() const {
|
|
||||||
protobuf_AssignDescriptorsOnce();
|
|
||||||
::google::protobuf::Metadata metadata;
|
|
||||||
metadata.descriptor = Payload_descriptor_;
|
|
||||||
metadata.reflection = Payload_reflection_;
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
|
||||||
|
|
||||||
} // namespace sampler
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope)
|
|
|
@ -1,415 +0,0 @@
|
||||||
/********************************************************************************
|
|
||||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
|
||||||
* *
|
|
||||||
* This software is distributed under the terms of the *
|
|
||||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
|
||||||
* copied verbatim in the file "LICENSE" *
|
|
||||||
********************************************************************************/
|
|
||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
// source: payload.proto
|
|
||||||
|
|
||||||
#ifndef PROTOBUF_payload_2eproto__INCLUDED
|
|
||||||
#define PROTOBUF_payload_2eproto__INCLUDED
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
|
||||||
|
|
||||||
#if GOOGLE_PROTOBUF_VERSION < 2005000
|
|
||||||
#error This file was generated by a newer version of protoc which is
|
|
||||||
#error incompatible with your Protocol Buffer headers. Please update
|
|
||||||
#error your headers.
|
|
||||||
#endif
|
|
||||||
#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
|
||||||
#error This file was generated by an older version of protoc which is
|
|
||||||
#error incompatible with your Protocol Buffer headers. Please
|
|
||||||
#error regenerate this file with a newer version of protoc.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <google/protobuf/generated_message_util.h>
|
|
||||||
#include <google/protobuf/message.h>
|
|
||||||
#include <google/protobuf/repeated_field.h>
|
|
||||||
#include <google/protobuf/extension_set.h>
|
|
||||||
#include <google/protobuf/unknown_field_set.h>
|
|
||||||
// @@protoc_insertion_point(includes)
|
|
||||||
|
|
||||||
namespace sampler {
|
|
||||||
|
|
||||||
// Internal implementation detail -- do not call these.
|
|
||||||
void protobuf_AddDesc_payload_2eproto();
|
|
||||||
void protobuf_AssignDesc_payload_2eproto();
|
|
||||||
void protobuf_ShutdownFile_payload_2eproto();
|
|
||||||
|
|
||||||
class Content;
|
|
||||||
class Payload;
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
class Content : public ::google::protobuf::Message {
|
|
||||||
public:
|
|
||||||
Content();
|
|
||||||
virtual ~Content();
|
|
||||||
|
|
||||||
Content(const Content& from);
|
|
||||||
|
|
||||||
inline Content& operator=(const Content& from) {
|
|
||||||
CopyFrom(from);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
|
|
||||||
return _unknown_fields_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
|
|
||||||
return &_unknown_fields_;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
|
||||||
static const Content& default_instance();
|
|
||||||
|
|
||||||
void Swap(Content* other);
|
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
|
||||||
|
|
||||||
Content* New() const;
|
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
|
||||||
void CopyFrom(const Content& from);
|
|
||||||
void MergeFrom(const Content& from);
|
|
||||||
void Clear();
|
|
||||||
bool IsInitialized() const;
|
|
||||||
|
|
||||||
int ByteSize() const;
|
|
||||||
bool MergePartialFromCodedStream(
|
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
|
||||||
void SerializeWithCachedSizes(
|
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
|
||||||
void SharedCtor();
|
|
||||||
void SharedDtor();
|
|
||||||
void SetCachedSize(int size) const;
|
|
||||||
public:
|
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
|
||||||
|
|
||||||
// optional double a = 1;
|
|
||||||
inline bool has_a() const;
|
|
||||||
inline void clear_a();
|
|
||||||
static const int kAFieldNumber = 1;
|
|
||||||
inline double a() const;
|
|
||||||
inline void set_a(double value);
|
|
||||||
|
|
||||||
// optional double b = 2;
|
|
||||||
inline bool has_b() const;
|
|
||||||
inline void clear_b();
|
|
||||||
static const int kBFieldNumber = 2;
|
|
||||||
inline double b() const;
|
|
||||||
inline void set_b(double value);
|
|
||||||
|
|
||||||
// optional int32 x = 3;
|
|
||||||
inline bool has_x() const;
|
|
||||||
inline void clear_x();
|
|
||||||
static const int kXFieldNumber = 3;
|
|
||||||
inline ::google::protobuf::int32 x() const;
|
|
||||||
inline void set_x(::google::protobuf::int32 value);
|
|
||||||
|
|
||||||
// optional int32 y = 4;
|
|
||||||
inline bool has_y() const;
|
|
||||||
inline void clear_y();
|
|
||||||
static const int kYFieldNumber = 4;
|
|
||||||
inline ::google::protobuf::int32 y() const;
|
|
||||||
inline void set_y(::google::protobuf::int32 value);
|
|
||||||
|
|
||||||
// optional int32 z = 5;
|
|
||||||
inline bool has_z() const;
|
|
||||||
inline void clear_z();
|
|
||||||
static const int kZFieldNumber = 5;
|
|
||||||
inline ::google::protobuf::int32 z() const;
|
|
||||||
inline void set_z(::google::protobuf::int32 value);
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(class_scope:sampler.Content)
|
|
||||||
private:
|
|
||||||
inline void set_has_a();
|
|
||||||
inline void clear_has_a();
|
|
||||||
inline void set_has_b();
|
|
||||||
inline void clear_has_b();
|
|
||||||
inline void set_has_x();
|
|
||||||
inline void clear_has_x();
|
|
||||||
inline void set_has_y();
|
|
||||||
inline void clear_has_y();
|
|
||||||
inline void set_has_z();
|
|
||||||
inline void clear_has_z();
|
|
||||||
|
|
||||||
::google::protobuf::UnknownFieldSet _unknown_fields_;
|
|
||||||
|
|
||||||
double a_;
|
|
||||||
double b_;
|
|
||||||
::google::protobuf::int32 x_;
|
|
||||||
::google::protobuf::int32 y_;
|
|
||||||
::google::protobuf::int32 z_;
|
|
||||||
|
|
||||||
mutable int _cached_size_;
|
|
||||||
::google::protobuf::uint32 _has_bits_[(5 + 31) / 32];
|
|
||||||
|
|
||||||
friend void protobuf_AddDesc_payload_2eproto();
|
|
||||||
friend void protobuf_AssignDesc_payload_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_payload_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
static Content* default_instance_;
|
|
||||||
};
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
class Payload : public ::google::protobuf::Message {
|
|
||||||
public:
|
|
||||||
Payload();
|
|
||||||
virtual ~Payload();
|
|
||||||
|
|
||||||
Payload(const Payload& from);
|
|
||||||
|
|
||||||
inline Payload& operator=(const Payload& from) {
|
|
||||||
CopyFrom(from);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
|
|
||||||
return _unknown_fields_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
|
|
||||||
return &_unknown_fields_;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const ::google::protobuf::Descriptor* descriptor();
|
|
||||||
static const Payload& default_instance();
|
|
||||||
|
|
||||||
void Swap(Payload* other);
|
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
|
||||||
|
|
||||||
Payload* New() const;
|
|
||||||
void CopyFrom(const ::google::protobuf::Message& from);
|
|
||||||
void MergeFrom(const ::google::protobuf::Message& from);
|
|
||||||
void CopyFrom(const Payload& from);
|
|
||||||
void MergeFrom(const Payload& from);
|
|
||||||
void Clear();
|
|
||||||
bool IsInitialized() const;
|
|
||||||
|
|
||||||
int ByteSize() const;
|
|
||||||
bool MergePartialFromCodedStream(
|
|
||||||
::google::protobuf::io::CodedInputStream* input);
|
|
||||||
void SerializeWithCachedSizes(
|
|
||||||
::google::protobuf::io::CodedOutputStream* output) const;
|
|
||||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
|
|
||||||
int GetCachedSize() const { return _cached_size_; }
|
|
||||||
private:
|
|
||||||
void SharedCtor();
|
|
||||||
void SharedDtor();
|
|
||||||
void SetCachedSize(int size) const;
|
|
||||||
public:
|
|
||||||
|
|
||||||
::google::protobuf::Metadata GetMetadata() const;
|
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
|
||||||
|
|
||||||
// repeated .sampler.Content data = 1;
|
|
||||||
inline int data_size() const;
|
|
||||||
inline void clear_data();
|
|
||||||
static const int kDataFieldNumber = 1;
|
|
||||||
inline const ::sampler::Content& data(int index) const;
|
|
||||||
inline ::sampler::Content* mutable_data(int index);
|
|
||||||
inline ::sampler::Content* add_data();
|
|
||||||
inline const ::google::protobuf::RepeatedPtrField< ::sampler::Content >&
|
|
||||||
data() const;
|
|
||||||
inline ::google::protobuf::RepeatedPtrField< ::sampler::Content >*
|
|
||||||
mutable_data();
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(class_scope:sampler.Payload)
|
|
||||||
private:
|
|
||||||
|
|
||||||
::google::protobuf::UnknownFieldSet _unknown_fields_;
|
|
||||||
|
|
||||||
::google::protobuf::RepeatedPtrField< ::sampler::Content > data_;
|
|
||||||
|
|
||||||
mutable int _cached_size_;
|
|
||||||
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
|
|
||||||
|
|
||||||
friend void protobuf_AddDesc_payload_2eproto();
|
|
||||||
friend void protobuf_AssignDesc_payload_2eproto();
|
|
||||||
friend void protobuf_ShutdownFile_payload_2eproto();
|
|
||||||
|
|
||||||
void InitAsDefaultInstance();
|
|
||||||
static Payload* default_instance_;
|
|
||||||
};
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
// Content
|
|
||||||
|
|
||||||
// optional double a = 1;
|
|
||||||
inline bool Content::has_a() const {
|
|
||||||
return (_has_bits_[0] & 0x00000001u) != 0;
|
|
||||||
}
|
|
||||||
inline void Content::set_has_a() {
|
|
||||||
_has_bits_[0] |= 0x00000001u;
|
|
||||||
}
|
|
||||||
inline void Content::clear_has_a() {
|
|
||||||
_has_bits_[0] &= ~0x00000001u;
|
|
||||||
}
|
|
||||||
inline void Content::clear_a() {
|
|
||||||
a_ = 0;
|
|
||||||
clear_has_a();
|
|
||||||
}
|
|
||||||
inline double Content::a() const {
|
|
||||||
return a_;
|
|
||||||
}
|
|
||||||
inline void Content::set_a(double value) {
|
|
||||||
set_has_a();
|
|
||||||
a_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional double b = 2;
|
|
||||||
inline bool Content::has_b() const {
|
|
||||||
return (_has_bits_[0] & 0x00000002u) != 0;
|
|
||||||
}
|
|
||||||
inline void Content::set_has_b() {
|
|
||||||
_has_bits_[0] |= 0x00000002u;
|
|
||||||
}
|
|
||||||
inline void Content::clear_has_b() {
|
|
||||||
_has_bits_[0] &= ~0x00000002u;
|
|
||||||
}
|
|
||||||
inline void Content::clear_b() {
|
|
||||||
b_ = 0;
|
|
||||||
clear_has_b();
|
|
||||||
}
|
|
||||||
inline double Content::b() const {
|
|
||||||
return b_;
|
|
||||||
}
|
|
||||||
inline void Content::set_b(double value) {
|
|
||||||
set_has_b();
|
|
||||||
b_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 x = 3;
|
|
||||||
inline bool Content::has_x() const {
|
|
||||||
return (_has_bits_[0] & 0x00000004u) != 0;
|
|
||||||
}
|
|
||||||
inline void Content::set_has_x() {
|
|
||||||
_has_bits_[0] |= 0x00000004u;
|
|
||||||
}
|
|
||||||
inline void Content::clear_has_x() {
|
|
||||||
_has_bits_[0] &= ~0x00000004u;
|
|
||||||
}
|
|
||||||
inline void Content::clear_x() {
|
|
||||||
x_ = 0;
|
|
||||||
clear_has_x();
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::int32 Content::x() const {
|
|
||||||
return x_;
|
|
||||||
}
|
|
||||||
inline void Content::set_x(::google::protobuf::int32 value) {
|
|
||||||
set_has_x();
|
|
||||||
x_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 y = 4;
|
|
||||||
inline bool Content::has_y() const {
|
|
||||||
return (_has_bits_[0] & 0x00000008u) != 0;
|
|
||||||
}
|
|
||||||
inline void Content::set_has_y() {
|
|
||||||
_has_bits_[0] |= 0x00000008u;
|
|
||||||
}
|
|
||||||
inline void Content::clear_has_y() {
|
|
||||||
_has_bits_[0] &= ~0x00000008u;
|
|
||||||
}
|
|
||||||
inline void Content::clear_y() {
|
|
||||||
y_ = 0;
|
|
||||||
clear_has_y();
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::int32 Content::y() const {
|
|
||||||
return y_;
|
|
||||||
}
|
|
||||||
inline void Content::set_y(::google::protobuf::int32 value) {
|
|
||||||
set_has_y();
|
|
||||||
y_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 z = 5;
|
|
||||||
inline bool Content::has_z() const {
|
|
||||||
return (_has_bits_[0] & 0x00000010u) != 0;
|
|
||||||
}
|
|
||||||
inline void Content::set_has_z() {
|
|
||||||
_has_bits_[0] |= 0x00000010u;
|
|
||||||
}
|
|
||||||
inline void Content::clear_has_z() {
|
|
||||||
_has_bits_[0] &= ~0x00000010u;
|
|
||||||
}
|
|
||||||
inline void Content::clear_z() {
|
|
||||||
z_ = 0;
|
|
||||||
clear_has_z();
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::int32 Content::z() const {
|
|
||||||
return z_;
|
|
||||||
}
|
|
||||||
inline void Content::set_z(::google::protobuf::int32 value) {
|
|
||||||
set_has_z();
|
|
||||||
z_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Payload
|
|
||||||
|
|
||||||
// repeated .sampler.Content data = 1;
|
|
||||||
inline int Payload::data_size() const {
|
|
||||||
return data_.size();
|
|
||||||
}
|
|
||||||
inline void Payload::clear_data() {
|
|
||||||
data_.Clear();
|
|
||||||
}
|
|
||||||
inline const ::sampler::Content& Payload::data(int index) const {
|
|
||||||
return data_.Get(index);
|
|
||||||
}
|
|
||||||
inline ::sampler::Content* Payload::mutable_data(int index) {
|
|
||||||
return data_.Mutable(index);
|
|
||||||
}
|
|
||||||
inline ::sampler::Content* Payload::add_data() {
|
|
||||||
return data_.Add();
|
|
||||||
}
|
|
||||||
inline const ::google::protobuf::RepeatedPtrField< ::sampler::Content >&
|
|
||||||
Payload::data() const {
|
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
inline ::google::protobuf::RepeatedPtrField< ::sampler::Content >*
|
|
||||||
Payload::mutable_data() {
|
|
||||||
return &data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
|
||||||
|
|
||||||
} // namespace sampler
|
|
||||||
|
|
||||||
#ifndef SWIG
|
|
||||||
namespace google {
|
|
||||||
namespace protobuf {
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace google
|
|
||||||
} // namespace protobuf
|
|
||||||
#endif // SWIG
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope)
|
|
||||||
|
|
||||||
#endif // PROTOBUF_payload_2eproto__INCLUDED
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -28,29 +27,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FairMQBinSampler sampler;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBinSampler::STOP);
|
|
||||||
sampler.ChangeState(FairMQBinSampler::END);
|
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct DeviceOptions
|
typedef struct DeviceOptions
|
||||||
{
|
{
|
||||||
DeviceOptions() :
|
DeviceOptions() :
|
||||||
|
@ -125,7 +101,8 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQBinSampler sampler;
|
||||||
|
sampler.CatchSignals();
|
||||||
|
|
||||||
DeviceOptions_t options;
|
DeviceOptions_t options;
|
||||||
try
|
try
|
||||||
|
@ -151,36 +128,26 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
sampler.SetTransport(transportFactory);
|
sampler.SetTransport(transportFactory);
|
||||||
|
|
||||||
|
FairMQChannel outputChannel(options.outputSocketType, options.outputMethod, options.outputAddress);
|
||||||
|
outputChannel.UpdateSndBufSize(options.outputBufSize);
|
||||||
|
outputChannel.UpdateRcvBufSize(options.outputBufSize);
|
||||||
|
outputChannel.UpdateRateLogging(1);
|
||||||
|
|
||||||
|
sampler.fChannels["data-out"].push_back(outputChannel);
|
||||||
|
|
||||||
sampler.SetProperty(FairMQBinSampler::Id, options.id);
|
sampler.SetProperty(FairMQBinSampler::Id, options.id);
|
||||||
sampler.SetProperty(FairMQBinSampler::EventSize, options.eventSize);
|
sampler.SetProperty(FairMQBinSampler::EventSize, options.eventSize);
|
||||||
sampler.SetProperty(FairMQBinSampler::EventRate, options.eventRate);
|
sampler.SetProperty(FairMQBinSampler::EventRate, options.eventRate);
|
||||||
sampler.SetProperty(FairMQBinSampler::NumIoThreads, options.ioThreads);
|
sampler.SetProperty(FairMQBinSampler::NumIoThreads, options.ioThreads);
|
||||||
|
|
||||||
sampler.SetProperty(FairMQBinSampler::NumInputs, 0);
|
sampler.ChangeState("INIT_DEVICE");
|
||||||
sampler.SetProperty(FairMQBinSampler::NumOutputs, 1);
|
sampler.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBinSampler::INIT);
|
sampler.ChangeState("INIT_TASK");
|
||||||
|
sampler.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
sampler.SetProperty(FairMQBinSampler::OutputSocketType, options.outputSocketType);
|
sampler.ChangeState("RUN");
|
||||||
sampler.SetProperty(FairMQBinSampler::OutputSndBufSize, options.outputBufSize);
|
sampler.InteractiveStateLoop();
|
||||||
sampler.SetProperty(FairMQBinSampler::OutputMethod, options.outputMethod);
|
|
||||||
sampler.SetProperty(FairMQBinSampler::OutputAddress, options.outputAddress);
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBinSampler::SETOUTPUT);
|
|
||||||
sampler.ChangeState(FairMQBinSampler::SETINPUT);
|
|
||||||
sampler.ChangeState(FairMQBinSampler::BIND);
|
|
||||||
sampler.ChangeState(FairMQBinSampler::CONNECT);
|
|
||||||
sampler.ChangeState(FairMQBinSampler::RUN);
|
|
||||||
|
|
||||||
// wait until the running thread has finished processing.
|
|
||||||
boost::unique_lock<boost::mutex> lock(sampler.fRunningMutex);
|
|
||||||
while (!sampler.fRunningFinished)
|
|
||||||
{
|
|
||||||
sampler.fRunningCondition.wait(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBinSampler::STOP);
|
|
||||||
sampler.ChangeState(FairMQBinSampler::END);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -28,29 +27,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FairMQBinSink sink;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQBinSink::STOP);
|
|
||||||
sink.ChangeState(FairMQBinSink::END);
|
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct DeviceOptions
|
typedef struct DeviceOptions
|
||||||
{
|
{
|
||||||
DeviceOptions() :
|
DeviceOptions() :
|
||||||
|
@ -115,7 +91,8 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQBinSink sink;
|
||||||
|
sink.CatchSignals();
|
||||||
|
|
||||||
DeviceOptions_t options;
|
DeviceOptions_t options;
|
||||||
try
|
try
|
||||||
|
@ -139,34 +116,24 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
sink.SetTransport(transportFactory);
|
sink.SetTransport(transportFactory);
|
||||||
|
|
||||||
|
FairMQChannel inputChannel(options.inputSocketType, options.inputMethod, options.inputAddress);
|
||||||
|
inputChannel.UpdateSndBufSize(options.inputBufSize);
|
||||||
|
inputChannel.UpdateRcvBufSize(options.inputBufSize);
|
||||||
|
inputChannel.UpdateRateLogging(1);
|
||||||
|
|
||||||
|
sink.fChannels["data-in"].push_back(inputChannel);
|
||||||
|
|
||||||
sink.SetProperty(FairMQBinSink::Id, options.id);
|
sink.SetProperty(FairMQBinSink::Id, options.id);
|
||||||
sink.SetProperty(FairMQBinSink::NumIoThreads, options.ioThreads);
|
sink.SetProperty(FairMQBinSink::NumIoThreads, options.ioThreads);
|
||||||
|
|
||||||
sink.SetProperty(FairMQBinSink::NumInputs, 1);
|
sink.ChangeState("INIT_DEVICE");
|
||||||
sink.SetProperty(FairMQBinSink::NumOutputs, 0);
|
sink.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
sink.ChangeState(FairMQBinSink::INIT);
|
sink.ChangeState("INIT_TASK");
|
||||||
|
sink.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
sink.SetProperty(FairMQBinSink::InputSocketType, options.inputSocketType);
|
sink.ChangeState("RUN");
|
||||||
sink.SetProperty(FairMQBinSink::InputRcvBufSize, options.inputBufSize);
|
sink.InteractiveStateLoop();
|
||||||
sink.SetProperty(FairMQBinSink::InputMethod, options.inputMethod);
|
|
||||||
sink.SetProperty(FairMQBinSink::InputAddress, options.inputAddress);
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQBinSink::SETOUTPUT);
|
|
||||||
sink.ChangeState(FairMQBinSink::SETINPUT);
|
|
||||||
sink.ChangeState(FairMQBinSink::BIND);
|
|
||||||
sink.ChangeState(FairMQBinSink::CONNECT);
|
|
||||||
sink.ChangeState(FairMQBinSink::RUN);
|
|
||||||
|
|
||||||
// wait until the running thread has finished processing.
|
|
||||||
boost::unique_lock<boost::mutex> lock(sink.fRunningMutex);
|
|
||||||
while (!sink.fRunningFinished)
|
|
||||||
{
|
|
||||||
sink.fRunningCondition.wait(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQBinSink::STOP);
|
|
||||||
sink.ChangeState(FairMQBinSink::END);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -28,29 +27,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FairMQProtoSampler sampler;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::STOP);
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::END);
|
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct DeviceOptions
|
typedef struct DeviceOptions
|
||||||
{
|
{
|
||||||
DeviceOptions() :
|
DeviceOptions() :
|
||||||
|
@ -125,7 +101,8 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQProtoSampler sampler;
|
||||||
|
sampler.CatchSignals();
|
||||||
|
|
||||||
DeviceOptions_t options;
|
DeviceOptions_t options;
|
||||||
try
|
try
|
||||||
|
@ -151,36 +128,26 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
sampler.SetTransport(transportFactory);
|
sampler.SetTransport(transportFactory);
|
||||||
|
|
||||||
|
FairMQChannel outputChannel(options.outputSocketType, options.outputMethod, options.outputAddress);
|
||||||
|
outputChannel.UpdateSndBufSize(options.outputBufSize);
|
||||||
|
outputChannel.UpdateRcvBufSize(options.outputBufSize);
|
||||||
|
outputChannel.UpdateRateLogging(1);
|
||||||
|
|
||||||
|
sampler.fChannels["data-out"].push_back(outputChannel);
|
||||||
|
|
||||||
sampler.SetProperty(FairMQProtoSampler::Id, options.id);
|
sampler.SetProperty(FairMQProtoSampler::Id, options.id);
|
||||||
sampler.SetProperty(FairMQProtoSampler::EventSize, options.eventSize);
|
sampler.SetProperty(FairMQProtoSampler::EventSize, options.eventSize);
|
||||||
sampler.SetProperty(FairMQProtoSampler::EventRate, options.eventRate);
|
sampler.SetProperty(FairMQProtoSampler::EventRate, options.eventRate);
|
||||||
sampler.SetProperty(FairMQProtoSampler::NumIoThreads, options.ioThreads);
|
sampler.SetProperty(FairMQProtoSampler::NumIoThreads, options.ioThreads);
|
||||||
|
|
||||||
sampler.SetProperty(FairMQProtoSampler::NumInputs, 0);
|
sampler.ChangeState("INIT_DEVICE");
|
||||||
sampler.SetProperty(FairMQProtoSampler::NumOutputs, 1);
|
sampler.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::INIT);
|
sampler.ChangeState("INIT_TASK");
|
||||||
|
sampler.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
sampler.SetProperty(FairMQProtoSampler::OutputSocketType, options.outputSocketType);
|
sampler.ChangeState("RUN");
|
||||||
sampler.SetProperty(FairMQProtoSampler::OutputSndBufSize, options.outputBufSize);
|
sampler.InteractiveStateLoop();
|
||||||
sampler.SetProperty(FairMQProtoSampler::OutputMethod, options.outputMethod);
|
|
||||||
sampler.SetProperty(FairMQProtoSampler::OutputAddress, options.outputAddress);
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::SETOUTPUT);
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::SETINPUT);
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::BIND);
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::CONNECT);
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::RUN);
|
|
||||||
|
|
||||||
// wait until the running thread has finished processing.
|
|
||||||
boost::unique_lock<boost::mutex> lock(sampler.fRunningMutex);
|
|
||||||
while (!sampler.fRunningFinished)
|
|
||||||
{
|
|
||||||
sampler.fRunningCondition.wait(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::STOP);
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::END);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -28,29 +27,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FairMQProtoSink sink;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQProtoSink::STOP);
|
|
||||||
sink.ChangeState(FairMQProtoSink::END);
|
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct DeviceOptions
|
typedef struct DeviceOptions
|
||||||
{
|
{
|
||||||
DeviceOptions() :
|
DeviceOptions() :
|
||||||
|
@ -115,7 +91,8 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQProtoSink sink;
|
||||||
|
sink.CatchSignals();
|
||||||
|
|
||||||
DeviceOptions_t options;
|
DeviceOptions_t options;
|
||||||
try
|
try
|
||||||
|
@ -139,34 +116,24 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
sink.SetTransport(transportFactory);
|
sink.SetTransport(transportFactory);
|
||||||
|
|
||||||
|
FairMQChannel inputChannel(options.inputSocketType, options.inputMethod, options.inputAddress);
|
||||||
|
inputChannel.UpdateSndBufSize(options.inputBufSize);
|
||||||
|
inputChannel.UpdateRcvBufSize(options.inputBufSize);
|
||||||
|
inputChannel.UpdateRateLogging(1);
|
||||||
|
|
||||||
|
sink.fChannels["data-in"].push_back(inputChannel);
|
||||||
|
|
||||||
sink.SetProperty(FairMQProtoSink::Id, options.id);
|
sink.SetProperty(FairMQProtoSink::Id, options.id);
|
||||||
sink.SetProperty(FairMQProtoSink::NumIoThreads, options.ioThreads);
|
sink.SetProperty(FairMQProtoSink::NumIoThreads, options.ioThreads);
|
||||||
|
|
||||||
sink.SetProperty(FairMQProtoSink::NumInputs, 1);
|
sink.ChangeState("INIT_DEVICE");
|
||||||
sink.SetProperty(FairMQProtoSink::NumOutputs, 0);
|
sink.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
sink.ChangeState(FairMQProtoSink::INIT);
|
sink.ChangeState("INIT_TASK");
|
||||||
|
sink.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
sink.SetProperty(FairMQProtoSink::InputSocketType, options.inputSocketType);
|
sink.ChangeState("RUN");
|
||||||
sink.SetProperty(FairMQProtoSink::InputRcvBufSize, options.inputBufSize);
|
sink.InteractiveStateLoop();
|
||||||
sink.SetProperty(FairMQProtoSink::InputMethod, options.inputMethod);
|
|
||||||
sink.SetProperty(FairMQProtoSink::InputAddress, options.inputAddress);
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQProtoSink::SETOUTPUT);
|
|
||||||
sink.ChangeState(FairMQProtoSink::SETINPUT);
|
|
||||||
sink.ChangeState(FairMQProtoSink::BIND);
|
|
||||||
sink.ChangeState(FairMQProtoSink::CONNECT);
|
|
||||||
sink.ChangeState(FairMQProtoSink::RUN);
|
|
||||||
|
|
||||||
// wait until the running thread has finished processing.
|
|
||||||
boost::unique_lock<boost::mutex> lock(sink.fRunningMutex);
|
|
||||||
while (!sink.fRunningFinished)
|
|
||||||
{
|
|
||||||
sink.fRunningCondition.wait(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQProtoSink::STOP);
|
|
||||||
sink.ChangeState(FairMQProtoSink::END);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -32,31 +31,10 @@ using namespace std;
|
||||||
using namespace FairMQParser;
|
using namespace FairMQParser;
|
||||||
using namespace boost::program_options;
|
using namespace boost::program_options;
|
||||||
|
|
||||||
FairMQBenchmarkSampler sampler;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::END);
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQBenchmarkSampler sampler;
|
||||||
|
sampler.CatchSignals();
|
||||||
|
|
||||||
FairMQProgOptions config;
|
FairMQProgOptions config;
|
||||||
|
|
||||||
|
@ -79,7 +57,7 @@ int main(int argc, char** argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
string filename = config.GetValue<string>("config-json-filename");
|
string filename = config.GetValue<string>("config-json-file");
|
||||||
string id = config.GetValue<string>("id");
|
string id = config.GetValue<string>("id");
|
||||||
|
|
||||||
config.UserParser<JSON>(filename, id);
|
config.UserParser<JSON>(filename, id);
|
||||||
|
@ -101,25 +79,14 @@ int main(int argc, char** argv)
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::EventRate, eventRate);
|
sampler.SetProperty(FairMQBenchmarkSampler::EventRate, eventRate);
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::NumIoThreads, ioThreads);
|
sampler.SetProperty(FairMQBenchmarkSampler::NumIoThreads, ioThreads);
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::INIT_DEVICE);
|
sampler.ChangeState("INIT_DEVICE");
|
||||||
sampler.WaitForEndOfState(FairMQBenchmarkSampler::INIT_DEVICE);
|
sampler.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::INIT_TASK);
|
sampler.ChangeState("INIT_TASK");
|
||||||
sampler.WaitForEndOfState(FairMQBenchmarkSampler::INIT_TASK);
|
sampler.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::RUN);
|
|
||||||
sampler.WaitForEndOfState(FairMQBenchmarkSampler::RUN);
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::STOP);
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::RESET_TASK);
|
|
||||||
sampler.WaitForEndOfState(FairMQBenchmarkSampler::RESET_TASK);
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::RESET_DEVICE);
|
|
||||||
sampler.WaitForEndOfState(FairMQBenchmarkSampler::RESET_DEVICE);
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::END);
|
|
||||||
|
|
||||||
|
sampler.ChangeState("RUN");
|
||||||
|
sampler.InteractiveStateLoop();
|
||||||
}
|
}
|
||||||
catch (exception& e)
|
catch (exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,11 +9,10 @@
|
||||||
* runBuffer.cxx
|
* runBuffer.cxx
|
||||||
*
|
*
|
||||||
* @since 2012-10-26
|
* @since 2012-10-26
|
||||||
* @author: D. Klein, A. Rybalchenko
|
* @author D. Klein, A. Rybalchenko
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -28,28 +27,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FairMQBuffer buffer;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::END);
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct DeviceOptions
|
typedef struct DeviceOptions
|
||||||
{
|
{
|
||||||
DeviceOptions() :
|
DeviceOptions() :
|
||||||
|
@ -135,7 +112,8 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQBuffer buffer;
|
||||||
|
buffer.CatchSignals();
|
||||||
|
|
||||||
DeviceOptions_t options;
|
DeviceOptions_t options;
|
||||||
try
|
try
|
||||||
|
@ -176,24 +154,14 @@ int main(int argc, char** argv)
|
||||||
buffer.SetProperty(FairMQBuffer::Id, options.id);
|
buffer.SetProperty(FairMQBuffer::Id, options.id);
|
||||||
buffer.SetProperty(FairMQBuffer::NumIoThreads, options.ioThreads);
|
buffer.SetProperty(FairMQBuffer::NumIoThreads, options.ioThreads);
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::INIT_DEVICE);
|
buffer.ChangeState("INIT_DEVICE");
|
||||||
buffer.WaitForEndOfState(FairMQBuffer::INIT_DEVICE);
|
buffer.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::INIT_TASK);
|
buffer.ChangeState("INIT_TASK");
|
||||||
buffer.WaitForEndOfState(FairMQBuffer::INIT_TASK);
|
buffer.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::RUN);
|
buffer.ChangeState("RUN");
|
||||||
buffer.WaitForEndOfState(FairMQBuffer::RUN);
|
buffer.InteractiveStateLoop();
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::STOP);
|
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::RESET_TASK);
|
|
||||||
buffer.WaitForEndOfState(FairMQBuffer::RESET_TASK);
|
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::RESET_DEVICE);
|
|
||||||
buffer.WaitForEndOfState(FairMQBuffer::RESET_DEVICE);
|
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::END);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -28,28 +27,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FairMQMerger merger;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::END);
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct DeviceOptions
|
typedef struct DeviceOptions
|
||||||
{
|
{
|
||||||
DeviceOptions() :
|
DeviceOptions() :
|
||||||
|
@ -140,7 +117,8 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQMerger merger;
|
||||||
|
merger.CatchSignals();
|
||||||
|
|
||||||
DeviceOptions_t options;
|
DeviceOptions_t options;
|
||||||
try
|
try
|
||||||
|
@ -184,24 +162,14 @@ int main(int argc, char** argv)
|
||||||
merger.SetProperty(FairMQMerger::Id, options.id);
|
merger.SetProperty(FairMQMerger::Id, options.id);
|
||||||
merger.SetProperty(FairMQMerger::NumIoThreads, options.ioThreads);
|
merger.SetProperty(FairMQMerger::NumIoThreads, options.ioThreads);
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::INIT_DEVICE);
|
merger.ChangeState("INIT_DEVICE");
|
||||||
merger.WaitForEndOfState(FairMQMerger::INIT_DEVICE);
|
merger.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::INIT_TASK);
|
merger.ChangeState("INIT_TASK");
|
||||||
merger.WaitForEndOfState(FairMQMerger::INIT_TASK);
|
merger.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::RUN);
|
merger.ChangeState("RUN");
|
||||||
merger.WaitForEndOfState(FairMQMerger::RUN);
|
merger.InteractiveStateLoop();
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::STOP);
|
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::RESET_TASK);
|
|
||||||
merger.WaitForEndOfState(FairMQMerger::RESET_TASK);
|
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::RESET_DEVICE);
|
|
||||||
merger.WaitForEndOfState(FairMQMerger::RESET_DEVICE);
|
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::END);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -28,28 +27,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FairMQProxy proxy;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::END);
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct DeviceOptions
|
typedef struct DeviceOptions
|
||||||
{
|
{
|
||||||
DeviceOptions() :
|
DeviceOptions() :
|
||||||
|
@ -135,7 +112,8 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQProxy proxy;
|
||||||
|
proxy.CatchSignals();
|
||||||
|
|
||||||
DeviceOptions_t options;
|
DeviceOptions_t options;
|
||||||
try
|
try
|
||||||
|
@ -176,24 +154,14 @@ int main(int argc, char** argv)
|
||||||
proxy.SetProperty(FairMQProxy::Id, options.id);
|
proxy.SetProperty(FairMQProxy::Id, options.id);
|
||||||
proxy.SetProperty(FairMQProxy::NumIoThreads, options.ioThreads);
|
proxy.SetProperty(FairMQProxy::NumIoThreads, options.ioThreads);
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::INIT_DEVICE);
|
proxy.ChangeState("INIT_DEVICE");
|
||||||
proxy.WaitForEndOfState(FairMQProxy::INIT_DEVICE);
|
proxy.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::INIT_TASK);
|
proxy.ChangeState("INIT_TASK");
|
||||||
proxy.WaitForEndOfState(FairMQProxy::INIT_TASK);
|
proxy.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::RUN);
|
proxy.ChangeState("RUN");
|
||||||
proxy.WaitForEndOfState(FairMQProxy::RUN);
|
proxy.InteractiveStateLoop();
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::STOP);
|
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::RESET_TASK);
|
|
||||||
proxy.WaitForEndOfState(FairMQProxy::RESET_TASK);
|
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::RESET_DEVICE);
|
|
||||||
proxy.WaitForEndOfState(FairMQProxy::RESET_DEVICE);
|
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::END);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -32,31 +31,10 @@ using namespace std;
|
||||||
using namespace FairMQParser;
|
using namespace FairMQParser;
|
||||||
using namespace boost::program_options;
|
using namespace boost::program_options;
|
||||||
|
|
||||||
FairMQSink sink;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::END);
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQSink sink;
|
||||||
|
sink.CatchSignals();
|
||||||
|
|
||||||
FairMQProgOptions config;
|
FairMQProgOptions config;
|
||||||
|
|
||||||
|
@ -75,7 +53,7 @@ int main(int argc, char** argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
string filename = config.GetValue<string>("config-json-filename");
|
string filename = config.GetValue<string>("config-json-file");
|
||||||
string id = config.GetValue<string>("id");
|
string id = config.GetValue<string>("id");
|
||||||
|
|
||||||
config.UserParser<JSON>(filename, id);
|
config.UserParser<JSON>(filename, id);
|
||||||
|
@ -95,25 +73,14 @@ int main(int argc, char** argv)
|
||||||
sink.SetProperty(FairMQSink::Id, id);
|
sink.SetProperty(FairMQSink::Id, id);
|
||||||
sink.SetProperty(FairMQSink::NumIoThreads, ioThreads);
|
sink.SetProperty(FairMQSink::NumIoThreads, ioThreads);
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::INIT_DEVICE);
|
sink.ChangeState("INIT_DEVICE");
|
||||||
sink.WaitForEndOfState(FairMQSink::INIT_DEVICE);
|
sink.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::INIT_TASK);
|
sink.ChangeState("INIT_TASK");
|
||||||
sink.WaitForEndOfState(FairMQSink::INIT_TASK);
|
sink.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::RUN);
|
|
||||||
sink.WaitForEndOfState(FairMQSink::RUN);
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::STOP);
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::RESET_TASK);
|
|
||||||
sink.WaitForEndOfState(FairMQSink::RESET_TASK);
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::RESET_DEVICE);
|
|
||||||
sink.WaitForEndOfState(FairMQSink::RESET_DEVICE);
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::END);
|
|
||||||
|
|
||||||
|
sink.ChangeState("RUN");
|
||||||
|
sink.InteractiveStateLoop();
|
||||||
}
|
}
|
||||||
catch (exception& e)
|
catch (exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
|
@ -28,28 +27,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FairMQSplitter splitter;
|
|
||||||
|
|
||||||
static void s_signal_handler(int signal)
|
|
||||||
{
|
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::END);
|
|
||||||
|
|
||||||
LOG(INFO) << "Shutdown complete.";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s_catch_signals(void)
|
|
||||||
{
|
|
||||||
struct sigaction action;
|
|
||||||
action.sa_handler = s_signal_handler;
|
|
||||||
action.sa_flags = 0;
|
|
||||||
sigemptyset(&action.sa_mask);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct DeviceOptions
|
typedef struct DeviceOptions
|
||||||
{
|
{
|
||||||
DeviceOptions() :
|
DeviceOptions() :
|
||||||
|
@ -141,7 +118,8 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
s_catch_signals();
|
FairMQSplitter splitter;
|
||||||
|
splitter.CatchSignals();
|
||||||
|
|
||||||
DeviceOptions_t options;
|
DeviceOptions_t options;
|
||||||
try
|
try
|
||||||
|
@ -185,24 +163,14 @@ int main(int argc, char** argv)
|
||||||
splitter.SetProperty(FairMQSplitter::Id, options.id);
|
splitter.SetProperty(FairMQSplitter::Id, options.id);
|
||||||
splitter.SetProperty(FairMQSplitter::NumIoThreads, options.ioThreads);
|
splitter.SetProperty(FairMQSplitter::NumIoThreads, options.ioThreads);
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::INIT_DEVICE);
|
splitter.ChangeState("INIT_DEVICE");
|
||||||
splitter.WaitForEndOfState(FairMQSplitter::INIT_DEVICE);
|
splitter.WaitForEndOfState("INIT_DEVICE");
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::INIT_TASK);
|
splitter.ChangeState("INIT_TASK");
|
||||||
splitter.WaitForEndOfState(FairMQSplitter::INIT_TASK);
|
splitter.WaitForEndOfState("INIT_TASK");
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::RUN);
|
splitter.ChangeState("RUN");
|
||||||
splitter.WaitForEndOfState(FairMQSplitter::RUN);
|
splitter.InteractiveStateLoop();
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::STOP);
|
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::RESET_TASK);
|
|
||||||
splitter.WaitForEndOfState(FairMQSplitter::RESET_TASK);
|
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::RESET_DEVICE);
|
|
||||||
splitter.WaitForEndOfState(FairMQSplitter::RESET_DEVICE);
|
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::END);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@ using namespace std;
|
||||||
|
|
||||||
FairMQPollerZMQ::FairMQPollerZMQ(const vector<FairMQChannel>& channels)
|
FairMQPollerZMQ::FairMQPollerZMQ(const vector<FairMQChannel>& channels)
|
||||||
: items()
|
: items()
|
||||||
, fNumItems()
|
, fNumItems(0)
|
||||||
|
, fOffsetMap()
|
||||||
{
|
{
|
||||||
fNumItems = channels.size();
|
fNumItems = channels.size();
|
||||||
items = new zmq_pollitem_t[fNumItems];
|
items = new zmq_pollitem_t[fNumItems];
|
||||||
|
@ -35,15 +36,101 @@ FairMQPollerZMQ::FairMQPollerZMQ(const vector<FairMQChannel>& channels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQPollerZMQ::Poll(int timeout)
|
FairMQPollerZMQ::FairMQPollerZMQ(map< string,vector<FairMQChannel> >& channelsMap, initializer_list<string> channelList)
|
||||||
|
: items()
|
||||||
|
, fNumItems(0)
|
||||||
|
, fOffsetMap()
|
||||||
|
{
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// calculate offsets and the total size of the poll item set
|
||||||
|
for (string channel : channelList)
|
||||||
|
{
|
||||||
|
fOffsetMap[channel] = offset;
|
||||||
|
offset += channelsMap.at(channel).size();
|
||||||
|
fNumItems += channelsMap.at(channel).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
items = new zmq_pollitem_t[fNumItems];
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
for (string channel : channelList)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < channelsMap.at(channel).size(); ++i)
|
||||||
|
{
|
||||||
|
index = fOffsetMap[channel] + i;
|
||||||
|
items[index].socket = channelsMap.at(channel).at(i).fSocket->GetSocket();
|
||||||
|
items[index].fd = 0;
|
||||||
|
items[index].events = ZMQ_POLLIN;
|
||||||
|
items[index].revents = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "At least one of the provided channel keys for poller initialization is invalid";
|
||||||
|
LOG(ERROR) << "Out of Range error: " << oor.what() << '\n';
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FairMQPollerZMQ::FairMQPollerZMQ(FairMQSocket& dataSocket, FairMQSocket& cmdSocket)
|
||||||
|
: items()
|
||||||
|
, fNumItems(2)
|
||||||
|
, fOffsetMap()
|
||||||
|
{
|
||||||
|
items = new zmq_pollitem_t[fNumItems];
|
||||||
|
|
||||||
|
items[0].socket = cmdSocket.GetSocket();
|
||||||
|
items[0].fd = 0;
|
||||||
|
items[0].events = ZMQ_POLLIN;
|
||||||
|
items[0].revents = 0;
|
||||||
|
|
||||||
|
items[1].socket = dataSocket.GetSocket();
|
||||||
|
items[1].fd = 0;
|
||||||
|
items[1].revents = 0;
|
||||||
|
|
||||||
|
int type = 0;
|
||||||
|
size_t size = sizeof(type);
|
||||||
|
zmq_getsockopt (dataSocket.GetSocket(), ZMQ_TYPE, &type, &size);
|
||||||
|
|
||||||
|
if (type == ZMQ_REQ || type == ZMQ_REP || type == ZMQ_PAIR || type == ZMQ_DEALER || type == ZMQ_ROUTER)
|
||||||
|
{
|
||||||
|
items[1].events = ZMQ_POLLIN|ZMQ_POLLOUT;
|
||||||
|
}
|
||||||
|
else if (type == ZMQ_PUSH || type == ZMQ_PUB || type == ZMQ_XPUB)
|
||||||
|
{
|
||||||
|
items[1].events = ZMQ_POLLOUT;
|
||||||
|
}
|
||||||
|
else if (type == ZMQ_PULL || type == ZMQ_SUB || type == ZMQ_XSUB)
|
||||||
|
{
|
||||||
|
items[1].events = ZMQ_POLLIN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "invalid poller configuration, exiting.";
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FairMQPollerZMQ::Poll(const int timeout)
|
||||||
{
|
{
|
||||||
if (zmq_poll(items, fNumItems, timeout) < 0)
|
if (zmq_poll(items, fNumItems, timeout) < 0)
|
||||||
|
{
|
||||||
|
if (errno == ETERM)
|
||||||
|
{
|
||||||
|
LOG(DEBUG) << "polling exited, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "polling failed, reason: " << zmq_strerror(errno);
|
LOG(ERROR) << "polling failed, reason: " << zmq_strerror(errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool FairMQPollerZMQ::CheckInput(int index)
|
bool FairMQPollerZMQ::CheckInput(const int index)
|
||||||
{
|
{
|
||||||
if (items[index].revents & ZMQ_POLLIN)
|
if (items[index].revents & ZMQ_POLLIN)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +140,7 @@ bool FairMQPollerZMQ::CheckInput(int index)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQPollerZMQ::CheckOutput(int index)
|
bool FairMQPollerZMQ::CheckOutput(const int index)
|
||||||
{
|
{
|
||||||
if (items[index].revents & ZMQ_POLLOUT)
|
if (items[index].revents & ZMQ_POLLOUT)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +150,44 @@ bool FairMQPollerZMQ::CheckOutput(int index)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FairMQPollerZMQ::CheckInput(const string channelKey, const int index)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (items[fOffsetMap.at(channelKey) + index].revents & ZMQ_POLLIN)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "Invalid channel key: \"" << channelKey << "\"";
|
||||||
|
LOG(ERROR) << "Out of Range error: " << oor.what() << '\n';
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FairMQPollerZMQ::CheckOutput(const string channelKey, const int index)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (items[fOffsetMap.at(channelKey) + index].revents & ZMQ_POLLOUT)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "Invalid channel key: \"" << channelKey << "\"";
|
||||||
|
LOG(ERROR) << "Out of Range error: " << oor.what() << '\n';
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FairMQPollerZMQ::~FairMQPollerZMQ()
|
FairMQPollerZMQ::~FairMQPollerZMQ()
|
||||||
{
|
{
|
||||||
if (items != NULL)
|
if (items != NULL)
|
||||||
|
|
|
@ -16,25 +16,40 @@
|
||||||
#define FAIRMQPOLLERZMQ_H_
|
#define FAIRMQPOLLERZMQ_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#include "FairMQPoller.h"
|
#include "FairMQPoller.h"
|
||||||
#include "FairMQChannel.h"
|
#include "FairMQChannel.h"
|
||||||
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
|
|
||||||
|
class FairMQChannel;
|
||||||
|
|
||||||
class FairMQPollerZMQ : public FairMQPoller
|
class FairMQPollerZMQ : public FairMQPoller
|
||||||
{
|
{
|
||||||
|
friend class FairMQChannel;
|
||||||
|
friend class FairMQTransportFactoryZMQ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FairMQPollerZMQ(const std::vector<FairMQChannel>& channels);
|
FairMQPollerZMQ(const std::vector<FairMQChannel>& channels);
|
||||||
|
FairMQPollerZMQ(std::map< std::string,std::vector<FairMQChannel> >& channelsMap, std::initializer_list<std::string> channelList);
|
||||||
|
|
||||||
virtual void Poll(int timeout);
|
virtual void Poll(const int timeout);
|
||||||
virtual bool CheckInput(int index);
|
virtual bool CheckInput(const int index);
|
||||||
virtual bool CheckOutput(int index);
|
virtual bool CheckOutput(const int index);
|
||||||
|
virtual bool CheckInput(const std::string channelKey, const int index);
|
||||||
|
virtual bool CheckOutput(const std::string channelKey, const int index);
|
||||||
|
|
||||||
virtual ~FairMQPollerZMQ();
|
virtual ~FairMQPollerZMQ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
FairMQPollerZMQ(FairMQSocket& dataSocket, FairMQSocket& cmdSocket);
|
||||||
|
|
||||||
zmq_pollitem_t* items;
|
zmq_pollitem_t* items;
|
||||||
int fNumItems;
|
int fNumItems;
|
||||||
|
|
||||||
|
std::unordered_map<std::string,int> fOffsetMap;
|
||||||
|
|
||||||
/// Copy Constructor
|
/// Copy Constructor
|
||||||
FairMQPollerZMQ(const FairMQPollerZMQ&);
|
FairMQPollerZMQ(const FairMQPollerZMQ&);
|
||||||
FairMQPollerZMQ operator=(const FairMQPollerZMQ&);
|
FairMQPollerZMQ operator=(const FairMQPollerZMQ&);
|
||||||
|
|
|
@ -98,6 +98,8 @@ void FairMQSocketZMQ::Connect(const string& address)
|
||||||
if (zmq_connect(fSocket, address.c_str()) != 0)
|
if (zmq_connect(fSocket, address.c_str()) != 0)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "failed connecting socket " << fId << ", reason: " << zmq_strerror(errno);
|
LOG(ERROR) << "failed connecting socket " << fId << ", reason: " << zmq_strerror(errno);
|
||||||
|
// error here means incorrect configuration. exit if it happens.
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,3 +49,13 @@ FairMQPoller* FairMQTransportFactoryZMQ::CreatePoller(const vector<FairMQChannel
|
||||||
{
|
{
|
||||||
return new FairMQPollerZMQ(channels);
|
return new FairMQPollerZMQ(channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FairMQPoller* FairMQTransportFactoryZMQ::CreatePoller(std::map< std::string,std::vector<FairMQChannel> >& channelsMap, std::initializer_list<std::string> channelList)
|
||||||
|
{
|
||||||
|
return new FairMQPollerZMQ(channelsMap, channelList);
|
||||||
|
}
|
||||||
|
|
||||||
|
FairMQPoller* FairMQTransportFactoryZMQ::CreatePoller(FairMQSocket& dataSocket, FairMQSocket& cmdSocket)
|
||||||
|
{
|
||||||
|
return new FairMQPollerZMQ(dataSocket, cmdSocket);
|
||||||
|
}
|
||||||
|
|
|
@ -31,8 +31,12 @@ class FairMQTransportFactoryZMQ : public FairMQTransportFactory
|
||||||
virtual FairMQMessage* CreateMessage();
|
virtual FairMQMessage* CreateMessage();
|
||||||
virtual FairMQMessage* CreateMessage(size_t size);
|
virtual FairMQMessage* CreateMessage(size_t size);
|
||||||
virtual FairMQMessage* CreateMessage(void* data, size_t size, fairmq_free_fn *ffn = NULL, void* hint = NULL);
|
virtual FairMQMessage* CreateMessage(void* data, size_t size, fairmq_free_fn *ffn = NULL, void* hint = NULL);
|
||||||
|
|
||||||
virtual FairMQSocket* CreateSocket(const std::string& type, const std::string& name, int numIoThreads);
|
virtual FairMQSocket* CreateSocket(const std::string& type, const std::string& name, int numIoThreads);
|
||||||
|
|
||||||
virtual FairMQPoller* CreatePoller(const std::vector<FairMQChannel>& channels);
|
virtual FairMQPoller* CreatePoller(const std::vector<FairMQChannel>& channels);
|
||||||
|
virtual FairMQPoller* CreatePoller(std::map< std::string,std::vector<FairMQChannel> >& channelsMap, std::initializer_list<std::string> channelList);
|
||||||
|
virtual FairMQPoller* CreatePoller(FairMQSocket& dataSocket, FairMQSocket& cmdSocket);
|
||||||
|
|
||||||
virtual ~FairMQTransportFactoryZMQ() {};
|
virtual ~FairMQTransportFactoryZMQ() {};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user