Line data Source code
1 : #ifndef artdaq_Application_MPI2_DispatcherCore_hh
2 : #define artdaq_Application_MPI2_DispatcherCore_hh
3 :
4 : #include "artdaq/Application/DataReceiverCore.hh"
5 :
6 : #include "fhiclcpp/ParameterSet.h"
7 :
8 : #include <mutex>
9 : #include <string>
10 : #include <unordered_map>
11 :
12 : namespace artdaq {
13 : class DispatcherCore;
14 : }
15 :
16 : /**
17 : * \brief DispatcherCore implements the state machine for the Dispatcher artdaq application.
18 : * DispatcherCore processes incoming events in one of three roles: Data Logger, Online Monitor, or Dispatcher.
19 : */
20 : class artdaq::DispatcherCore : public DataReceiverCore
21 : {
22 : public:
23 : /**
24 : * \brief DispatcherCore Constructor.
25 : */
26 0 : DispatcherCore() = default;
27 :
28 : /**
29 : * \brief Copy Constructor is deleted
30 : */
31 : DispatcherCore(DispatcherCore const&) = delete;
32 :
33 : /**
34 : * Destructor.
35 : */
36 0 : ~DispatcherCore()
37 0 : {
38 0 : TLOG(TLVL_DEBUG + 32) << "Destructor";
39 0 : }
40 :
41 : /**
42 : * \brief Copy Assignment operator is deleted
43 : * \return DispatcherCore copy
44 : */
45 : DispatcherCore& operator=(DispatcherCore const&) = delete;
46 : DispatcherCore(DispatcherCore&&) = delete; ///< Move Constructor is deleted
47 : DispatcherCore& operator=(DispatcherCore&&) = delete; ///< Move Assignment Operator is deleted
48 :
49 : /**
50 : * \brief Processes the initialize request.
51 : * \param pset ParameterSet used to configure the DispatcherCore
52 : * \return Whether the initialize attempt succeeded
53 : *
54 : * Configuration Parameters unique to the Dispatcher:
55 : * "allow_label_overwrites" (default: true): Allow a new process to start with the same unique_label as an old one, stopping the appropriate art process and restarting with the new configuration.
56 : * Note that the "Dispatcher" ParameterSet is also used to configure the EventStore. See that class' documentation for more information.
57 : */
58 : bool initialize(fhicl::ParameterSet const& pset) override;
59 :
60 : /**
61 : * \brief Create a new TransferInterface instance using the given configuration
62 : * \param pset ParameterSet used to configure the TransferInterface
63 : * \return String detailing any errors encountered or "Success"
64 : *
65 : * See TransferInterface for details on the expected configuration
66 : */
67 : std::string register_monitor(fhicl::ParameterSet const& pset);
68 :
69 : /**
70 : * \brief Delete the TransferInterface having the given unique label
71 : * \param label Label of the TransferInterface to delete
72 : * \return String detailing any errors encountered or "Success"
73 : */
74 : std::string unregister_monitor(std::string const& label);
75 :
76 : private:
77 : fhicl::ParameterSet generate_filter_fhicl_();
78 : fhicl::ParameterSet merge_parameter_sets_(fhicl::ParameterSet const& skel, const std::string& label, const fhicl::ParameterSet& pset);
79 : void check_filters_();
80 :
81 : void start_art_process_(std::string const& label);
82 : void stop_art_process_(std::string const& label);
83 : void restart_art_process_(std::string const& label);
84 :
85 : std::mutex dispatcher_transfers_mutex_;
86 : std::unordered_map<std::string, fhicl::ParameterSet> registered_monitors_;
87 : std::unordered_map<std::string, pid_t> registered_monitor_pids_;
88 : fhicl::ParameterSet pset_; // The ParameterSet initially passed to the Dispatcher (contains input info)
89 : bool broadcast_mode_;
90 : bool allow_label_overwrites_;
91 : };
92 :
93 : #endif
94 :
95 : // LocalWords: ds
|