mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +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:
committed by
Mohammad Al-Turany
parent
d1bba61939
commit
1302e77a16
@@ -13,7 +13,6 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <csignal>
|
||||
|
||||
#include "boost/program_options.hpp"
|
||||
|
||||
@@ -28,28 +27,6 @@
|
||||
|
||||
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
|
||||
{
|
||||
DeviceOptions() :
|
||||
@@ -94,7 +71,7 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||
bpo::variables_map vm;
|
||||
bpo::store(bpo::parse_command_line(_argc, _argv, desc), vm);
|
||||
|
||||
if ( vm.count("help") )
|
||||
if (vm.count("help"))
|
||||
{
|
||||
LOG(INFO) << "FairMQ Merger" << endl << desc;
|
||||
return false;
|
||||
@@ -102,37 +79,37 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||
|
||||
bpo::notify(vm);
|
||||
|
||||
if ( vm.count("id") )
|
||||
if (vm.count("id"))
|
||||
_options->id = vm["id"].as<string>();
|
||||
|
||||
if ( vm.count("io-threads") )
|
||||
if (vm.count("io-threads"))
|
||||
_options->ioThreads = vm["io-threads"].as<int>();
|
||||
|
||||
if ( vm.count("num-inputs") )
|
||||
if (vm.count("num-inputs"))
|
||||
_options->numInputs = vm["num-inputs"].as<int>();
|
||||
|
||||
if ( vm.count("input-socket-type") )
|
||||
if (vm.count("input-socket-type"))
|
||||
_options->inputSocketType = vm["input-socket-type"].as< vector<string> >();
|
||||
|
||||
if ( vm.count("input-buff-size") )
|
||||
if (vm.count("input-buff-size"))
|
||||
_options->inputBufSize = vm["input-buff-size"].as< vector<int> >();
|
||||
|
||||
if ( vm.count("input-method") )
|
||||
if (vm.count("input-method"))
|
||||
_options->inputMethod = vm["input-method"].as< vector<string> >();
|
||||
|
||||
if ( vm.count("input-address") )
|
||||
if (vm.count("input-address"))
|
||||
_options->inputAddress = vm["input-address"].as< vector<string> >();
|
||||
|
||||
if ( vm.count("output-socket-type") )
|
||||
if (vm.count("output-socket-type"))
|
||||
_options->outputSocketType = vm["output-socket-type"].as<string>();
|
||||
|
||||
if ( vm.count("output-buff-size") )
|
||||
if (vm.count("output-buff-size"))
|
||||
_options->outputBufSize = vm["output-buff-size"].as<int>();
|
||||
|
||||
if ( vm.count("output-method") )
|
||||
if (vm.count("output-method"))
|
||||
_options->outputMethod = vm["output-method"].as<string>();
|
||||
|
||||
if ( vm.count("output-address") )
|
||||
if (vm.count("output-address"))
|
||||
_options->outputAddress = vm["output-address"].as<string>();
|
||||
|
||||
return true;
|
||||
@@ -140,7 +117,8 @@ inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
s_catch_signals();
|
||||
FairMQMerger merger;
|
||||
merger.CatchSignals();
|
||||
|
||||
DeviceOptions_t options;
|
||||
try
|
||||
@@ -184,24 +162,14 @@ int main(int argc, char** argv)
|
||||
merger.SetProperty(FairMQMerger::Id, options.id);
|
||||
merger.SetProperty(FairMQMerger::NumIoThreads, options.ioThreads);
|
||||
|
||||
merger.ChangeState(FairMQMerger::INIT_DEVICE);
|
||||
merger.WaitForEndOfState(FairMQMerger::INIT_DEVICE);
|
||||
merger.ChangeState("INIT_DEVICE");
|
||||
merger.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
merger.ChangeState(FairMQMerger::INIT_TASK);
|
||||
merger.WaitForEndOfState(FairMQMerger::INIT_TASK);
|
||||
merger.ChangeState("INIT_TASK");
|
||||
merger.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
merger.ChangeState(FairMQMerger::RUN);
|
||||
merger.WaitForEndOfState(FairMQMerger::RUN);
|
||||
|
||||
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);
|
||||
merger.ChangeState("RUN");
|
||||
merger.InteractiveStateLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user