33 const std::set<std::string>& pipeline_enabled_node_names,
34 uint64_t pipeline_heartbeat,
35 bool multiple_triggers,
37 pipeline_collection_path_(pipeline_collection_path),
38 pipeline_enabled_node_names_(pipeline_enabled_node_names),
39 pipeline_heartbeat_(pipeline_heartbeat),
40 multiple_triggers_(multiple_triggers),
54 sparta_assert(!triggered_,
"Why has pipeline trigger been triggered?");
56 std::cout <<
"Pipeline collection started, output to files with prefix '"
57 << pipeline_collector_->getFilePath() <<
"'" << std::endl;
60 if(multiple_triggers_) {
61 std::cout <<
"#" << num_collections_ <<
" pipeline collection started" << std::endl;
67 sparta_assert(triggered_,
"Why stop an inactivated trigger?");
71 if(multiple_triggers_) {
72 std::cout <<
"#" << num_collections_ <<
" pipeline collection ended" << std::endl;
74 pipeline_collector_->reactivate(getCollectionPath_());
79 void startCollection_()
81 if(pipeline_enabled_node_names_.empty()) {
83 pipeline_collector_->startCollection(root_);
87 for(
const auto & node_name : pipeline_enabled_node_names_) {
88 std::vector<TreeNode*> results;
90 if(results.size() == 0) {
91 std::cerr << SPARTA_CURRENT_COLOR_RED
92 <<
"WARNING (Pipeline collection): Could not find node named: '"
94 <<
"' Collection will not occur on that node!"
98 for(
auto & tn : results) {
99 std::cout <<
"Collection enabled on node: '" << tn->getLocation() <<
"'" << std::endl;
100 pipeline_collector_->startCollection(tn);
106 void stopCollection_()
108 if(pipeline_enabled_node_names_.empty()) {
110 pipeline_collector_->stopCollection(root_);
114 for(
const auto & node_name : pipeline_enabled_node_names_) {
115 std::vector<TreeNode*> results;
117 for(
auto & tn : results) {
118 pipeline_collector_->stopCollection(tn);
122 pipeline_collector_->destroy();
125 std::string getCollectionPath_()
const
127 if(pipeline_collection_path_.back() ==
'/') {
128 return pipeline_collection_path_ + std::to_string(num_collections_) +
'_';
131 return pipeline_collection_path_ +
'_' + std::to_string(num_collections_) +
'_';
135 std::unique_ptr<collection::PipelineCollector> pipeline_collector_;
136 const std::string pipeline_collection_path_;
137 const std::set<std::string> pipeline_enabled_node_names_;
138 const uint64_t pipeline_heartbeat_;
139 const bool multiple_triggers_;
142 uint32_t num_collections_ = 0;