6 #include "otsdaq-core/ConfigurationInterface/ConfigurationManagerRW.h"
7 #include "otsdaq-core/ConfigurationInterface/ConfigurationInterface.h"
20 void FlattenActiveSystemAliasConfigurationGroups(
int argc,
char* argv[])
22 std::cout <<
"=================================================\n";
23 std::cout <<
"=================================================\n";
24 std::cout <<
"=================================================\n";
25 std::cout << __COUT_HDR_FL__ <<
"\nFlattening Active System Aliases!" << std::endl;
27 std::cout <<
"\n\nusage: Two arguments:\n\t pathToSwapIn <baseFlatVersion> <pathToSwapIn (optional)> \n\n" <<
28 "\t Default values: baseFlatVersion = 0, pathToSwapIn = \"\" \n\n" <<
31 std::cout <<
"\n\nNote: you can optionally just swap databases (and not modify their contents at all)" <<
32 " by providing an invalid baseFlatVersion of -1.\n\n" <<
35 std::cout <<
"\n\nNote: This assumes artdaq db file type interface. " <<
36 "The current database/ will be moved to database_<linuxtime>/ " <<
37 "and if a pathToSwapIn is specified it will be copied to database/ " <<
38 "before saving the currently active groups.\n\n" <<
41 std::cout <<
"argc = " << argc << std::endl;
42 for(
int i = 0; i < argc; i++)
43 std::cout <<
"argv[" << i <<
"] = " << argv[i] << std::endl;
47 std::cout <<
"Must provide at least one parameter.";
52 std::string flatVersionStr = argv[1];
53 if(flatVersionStr.find(
'h') != std::string::npos)
55 std::cout <<
"Recognized parameter 1. as a 'help' option. Usage was printed. Exiting." << std::endl;
60 std::string pathToSwapIn =
"";
62 sscanf(argv[1],
"%d",&flatVersion);
64 pathToSwapIn = argv[2];
66 std::cout << __COUT_HDR_FL__ <<
"flatVersion = " << flatVersion << std::endl;
67 std::cout << __COUT_HDR_FL__ <<
"pathToSwapIn = " << pathToSwapIn << std::endl;
75 setenv(
"CONFIGURATION_TYPE",
"File",1);
76 setenv(
"CONFIGURATION_DATA_PATH",(std::string(getenv(
"USER_DATA")) +
"/ConfigurationDataExamples").c_str(),1);
77 setenv(
"CONFIGURATION_INFO_PATH",(std::string(getenv(
"USER_DATA")) +
"/ConfigurationInfo").c_str(),1);
81 setenv(
"SERVICE_DATA_PATH",(std::string(getenv(
"USER_DATA")) +
"/ServiceData").c_str(),1);
85 setenv(
"OTSDAQ_LIB",(std::string(getenv(
"USER_DATA")) +
"/").c_str(),1);
86 setenv(
"OTSDAQ_UTILITIES_LIB",(std::string(getenv(
"USER_DATA")) +
"/").c_str(),1);
89 setenv(
"OTS_MAIN_PORT",
"2015",1);
92 setenv(
"XDAQ_CONFIGURATION_DATA_PATH",(std::string(getenv(
"USER_DATA")) +
"/XDAQConfigurations").c_str(),1);
93 setenv(
"XDAQ_CONFIGURATION_XML",
"otsConfigurationNoRU_CMake",1);
100 std::cout <<
"\n\n\n" << __COUT_HDR_FL__ <<
"Loading active Aliases..." << std::endl;
130 std::map<std::pair<std::string,ConfigurationGroupKey>,
133 std::map<std::pair<std::string,ConfigurationVersion>,
136 ConfigurationGroupKey>> activeGroupKeys;
137 std::map<std::pair<std::string,ConfigurationGroupKey>,
138 std::string> groupErrors;
140 std::string activeBackboneGroupName =
"";
141 std::string activeContextGroupName =
"";
142 std::string activeIterateGroupName =
"";
143 std::string activeConfigGroupName =
"";
145 std::string nowTime = std::to_string(time(0));
147 std::string thenTime =
"";
148 if(pathToSwapIn !=
"")
150 thenTime = pathToSwapIn.substr(pathToSwapIn.rfind(
'_')+1);
151 std::cout << __COUT_HDR_FL__<<
"thenTime = " << thenTime << std::endl;
156 std::map<std::string, std::pair<std::string, ConfigurationGroupKey>> activeGroupsMap =
157 cfgMgr->getActiveConfigurationGroups();
159 for(
const auto &activeGroup: activeGroupsMap)
161 groupSet.insert(std::pair<
162 std::pair<std::string,ConfigurationGroupKey>,
163 ConfigurationGroupKey> (
164 std::pair<std::string,ConfigurationGroupKey>(
165 activeGroup.second.first,
166 activeGroup.second.second),
167 ConfigurationGroupKey())
169 activeGroupKeys.insert(std::pair<
171 std::pair<ConfigurationGroupKey,ConfigurationGroupKey>> (
172 activeGroup.second.first,
173 std::pair<ConfigurationGroupKey,ConfigurationGroupKey>(
174 activeGroup.second.second,
175 ConfigurationGroupKey()))
178 if(activeGroup.first == ConfigurationManager::ACTIVE_GROUP_NAME_BACKBONE)
180 activeBackboneGroupName = activeGroup.second.first;
181 std::cout << __COUT_HDR_FL__<<
"found activeBackboneGroupName = " <<
182 activeBackboneGroupName << std::endl;
184 else if(activeGroup.first == ConfigurationManager::ACTIVE_GROUP_NAME_CONTEXT)
186 activeContextGroupName = activeGroup.second.first;
187 std::cout << __COUT_HDR_FL__<<
"found activeContextGroupName = " <<
188 activeContextGroupName << std::endl;
190 else if(activeGroup.first == ConfigurationManager::ACTIVE_GROUP_NAME_ITERATE)
192 activeIterateGroupName = activeGroup.second.first;
193 std::cout << __COUT_HDR_FL__<<
"found activeIterateGroupName = " <<
194 activeIterateGroupName << std::endl;
196 else if(activeGroup.first == ConfigurationManager::ACTIVE_GROUP_NAME_CONFIGURATION)
198 activeConfigGroupName = activeGroup.second.first;
199 std::cout << __COUT_HDR_FL__<<
"found activeConfigGroupName = " <<
200 activeConfigGroupName << std::endl;
205 const std::string groupAliasesTableName =
"GroupAliasesConfiguration";
206 std::map<std::string, ConfigurationVersion> activeVersions = cfgMgr->getActiveVersions();
207 if(activeVersions.find(groupAliasesTableName) == activeVersions.end())
209 __SS__ <<
"\nActive version of GroupAliasesConfiguration missing! " <<
210 "GroupAliasesConfiguration is a required member of the Backbone configuration group." <<
211 "\n\nLikely you need to activate a valid Backbone group." <<
213 throw std::runtime_error(ss.str());
217 std::vector<std::pair<std::string,ConfigurationTree> > aliasNodePairs =
218 cfgMgr->getNode(groupAliasesTableName).getChildren();
219 for(
auto& groupPair:aliasNodePairs)
220 groupSet.insert(std::pair<
221 std::pair<std::string,ConfigurationGroupKey>,
222 ConfigurationGroupKey> (
223 std::pair<std::string,ConfigurationGroupKey>(
224 groupPair.second.getNode(
"GroupName").getValueAsString(),
225 ConfigurationGroupKey(groupPair.second.getNode(
"GroupKey").getValueAsString())),
226 ConfigurationGroupKey())
229 std::cout << __COUT_HDR_FL__<<
"Identfied groups:" << std::endl;
230 for(
auto& group:groupSet)
231 std::cout << __COUT_HDR_FL__<< group.first.first <<
" " << group.first.second << std::endl;
232 std::cout << __COUT_HDR_FL__<< std::endl;
233 std::cout << __COUT_HDR_FL__<< std::endl;
238 std::string currentDir = getenv(
"ARTDAQ_DATABASE_URI");
240 if(currentDir.find(
"filesystemdb://") != 0)
242 __SS__ <<
"filesystemdb:// was not found in $ARTDAQ_DATABASE_URI!" << std::endl;
243 __COUT_ERR__ <<
"\n" << ss.str();
244 throw std::runtime_error(ss.str());
247 currentDir = currentDir.substr(std::string(
"filesystemdb://").length());
248 while(currentDir.length() && currentDir[currentDir.length()-1] ==
'/')
249 currentDir = currentDir.substr(0,currentDir.length()-1);
250 std::string moveToDir = currentDir +
"_" + nowTime;
253 __SS__ << (
"Aborting move! Must at least give version argument to flatten to!") << std::endl;
254 __COUT_ERR__ <<
"\n" << ss.str();
255 throw std::runtime_error(ss.str());
258 if(pathToSwapIn !=
"")
261 if((dp = opendir(pathToSwapIn.c_str())) == 0)
263 std::cout << __COUT_HDR_FL__<<
"ERROR:(" << errno <<
"). Can't open directory: " << pathToSwapIn << std::endl;
270 std::cout << __COUT_HDR_FL__ <<
"Moving current directory: \t" << currentDir << std::endl;
271 std::cout << __COUT_HDR_FL__ <<
"\t... to: \t\t" << moveToDir << std::endl;
273 rename(currentDir.c_str(),moveToDir.c_str());
275 if(pathToSwapIn !=
"")
277 std::cout << __COUT_HDR_FL__ <<
"Swapping in directory: \t" << pathToSwapIn << std::endl;
278 std::cout << __COUT_HDR_FL__ <<
"\t.. to: \t\t" << currentDir << std::endl;
279 rename(pathToSwapIn.c_str(),currentDir.c_str());
283 std::string activeGroupsFile = ConfigurationManager::ACTIVE_GROUP_FILENAME +
"." + thenTime;
284 FILE *fp = fopen(activeGroupsFile.c_str(),
"r");
287 std::cout << __COUT_HDR_FL__ <<
"Swapping active groups file: \t" <<
288 activeGroupsFile << std::endl;
289 std::cout << __COUT_HDR_FL__ <<
"\t.. to: \t\t" <<
290 ConfigurationManager::ACTIVE_GROUP_FILENAME << std::endl;
291 rename(activeGroupsFile.c_str(),
292 ConfigurationManager::ACTIVE_GROUP_FILENAME.c_str());
305 std::string accumulateErrors =
"";
306 std::map<std::string, ConfigurationVersion> memberMap;
314 " is an invalid or temporary version. Skipping to end!" << std::endl;
319 for(
auto& groupPair:groupSet)
323 std::cout << __COUT_HDR_FL__ <<
"****************************" << std::endl;
324 std::cout << __COUT_HDR_FL__ <<
"Loading members for " <<
325 groupPair.first.first <<
326 "(" << groupPair.first.second <<
")" <<
328 std::cout << __COUT_HDR_FL__ <<
"flatVersion = " << flatVersion << std::endl;
331 if(pathToSwapIn !=
"")
333 std::cout << __COUT_HDR_FL__ <<
"REVERT by Swapping back directory: \t" << currentDir << std::endl;
334 std::cout << __COUT_HDR_FL__ <<
"\t.. to: \t\t" << pathToSwapIn << std::endl;
335 if(rename(currentDir.c_str(),pathToSwapIn.c_str()) < 0)
337 __SS__ <<
"Problem!" << std::endl;
338 throw std::runtime_error(ss.str());
344 std::cout << __COUT_HDR_FL__ <<
"REVERT by Moving directory: \t" << currentDir << std::endl;
345 std::cout << __COUT_HDR_FL__ <<
"\t.. to temporary directory: \t\t" << (moveToDir+
"_tmp") << std::endl;
346 if(rename(currentDir.c_str(),(moveToDir+
"_tmp").c_str()) < 0)
348 __SS__ <<
"Problem!" << std::endl;
349 throw std::runtime_error(ss.str());
354 std::cout << __COUT_HDR_FL__ <<
"REVERT by Moving directory: \t" << moveToDir << std::endl;
355 std::cout << __COUT_HDR_FL__ <<
"\t... to: \t\t" << currentDir << std::endl;
356 if(rename(moveToDir.c_str(),currentDir.c_str()) < 0)
358 __SS__ <<
"Problem!" << std::endl;
359 throw std::runtime_error(ss.str());
367 cfgMgr->loadConfigurationGroup(
368 groupPair.first.first,
369 groupPair.first.second,
370 true,&memberMap,0,&accumulateErrors);
372 catch(std::runtime_error& e)
375 std::cout << __COUT_HDR_FL__ <<
"Error was caught loading members for " <<
376 groupPair.first.first <<
377 "(" << groupPair.first.second <<
")" <<
379 std::cout << __COUT_HDR_FL__ << e.what() << std::endl;
384 std::cout << __COUT_HDR_FL__ <<
"Error was caught loading members for " <<
385 groupPair.first.first <<
386 "(" << groupPair.first.second <<
")" <<
397 std::cout << __COUT_HDR_FL__ <<
"Moving current directory: \t" << currentDir << std::endl;
398 std::cout << __COUT_HDR_FL__ <<
"\t... to: \t\t" << moveToDir << std::endl;
399 if(rename(currentDir.c_str(),moveToDir.c_str()) < 0)
401 __SS__ <<
"Problem!" << std::endl;
402 throw std::runtime_error(ss.str());
405 if(pathToSwapIn !=
"")
407 std::cout << __COUT_HDR_FL__ <<
"Swapping in directory: \t" << pathToSwapIn << std::endl;
408 std::cout << __COUT_HDR_FL__ <<
"\t.. to: \t\t" << currentDir << std::endl;
409 if(rename(pathToSwapIn.c_str(),currentDir.c_str()) < 0)
411 __SS__ <<
"Problem!" << std::endl;
412 throw std::runtime_error(ss.str());
417 std::cout << __COUT_HDR_FL__ <<
"Moving temporary directory: \t" << (moveToDir+
"_tmp") << std::endl;
418 std::cout << __COUT_HDR_FL__ <<
"\t.. to current directory: \t\t" << currentDir << std::endl;
419 if(rename((moveToDir+
"_tmp").c_str(),currentDir.c_str()) < 0)
421 __SS__ <<
"Problem!" << std::endl;
422 throw std::runtime_error(ss.str());
435 groupErrors.insert(std::pair<
436 std::pair<std::string,ConfigurationGroupKey>,
438 std::pair<std::string,ConfigurationGroupKey>(
439 groupPair.first.first,
440 groupPair.first.second),
441 "Error caught loading the group."));
453 for(
auto &memberPair:memberMap)
455 std::cout << __COUT_HDR_FL__ << memberPair.first <<
":v" << memberPair.second << std::endl;
459 if(modifiedTables.find(std::pair<std::string,ConfigurationVersion>(
462 )) != modifiedTables.end())
465 std::cout << __COUT_HDR_FL__ <<
"Table was already modified!" << std::endl;
466 memberPair.second = modifiedTables[std::pair<std::string,ConfigurationVersion>(
470 std::cout << __COUT_HDR_FL__ <<
"\t to...\t" <<
471 memberPair.first <<
":v" << memberPair.second << std::endl;
476 config = cfgMgr->getConfigurationByName(memberPair.first);
477 cfgView = config->getViewP();
479 theInterface_->saveActiveVersion(config);
482 cfgView->setVersion(memberPair.second);
484 memberPair.second = flatVersion;
486 std::cout << __COUT_HDR_FL__ <<
"\t to...\t" <<
487 memberPair.first <<
":v" << memberPair.second << std::endl;
490 modifiedTables.insert(std::pair<
491 std::pair<std::string,ConfigurationVersion>,
493 std::pair<std::string,ConfigurationVersion>(
501 theInterface_->saveConfigurationGroup(memberMap,
502 ConfigurationGroupKey::getFullGroupString(
503 groupPair.first.first,
504 ConfigurationGroupKey(flatVersion)));
507 groupPair.second = ConfigurationGroupKey(flatVersion);
510 if(activeGroupKeys.find(groupPair.first.first) != activeGroupKeys.end() &&
511 activeGroupKeys[groupPair.first.first].first == groupPair.first.second)
512 activeGroupKeys[groupPair.first.first].second =
513 ConfigurationGroupKey(flatVersion);
515 catch(std::runtime_error& e)
517 std::cout << __COUT_HDR_FL__ <<
"Error was caught saving group " <<
518 groupPair.first.first <<
519 " (" << groupPair.first.second <<
") " <<
521 std::cout << __COUT_HDR_FL__ << e.what() << std::endl;
523 groupErrors.insert(std::pair<
524 std::pair<std::string,ConfigurationGroupKey>,
526 std::pair<std::string,ConfigurationGroupKey>(
527 groupPair.first.first,
528 groupPair.first.second),
529 "Error caught saving the group."));
533 std::cout << __COUT_HDR_FL__ <<
"Error was caught saving group " <<
534 groupPair.first.first <<
535 " (" << groupPair.first.second <<
") " <<
538 groupErrors.insert(std::pair<
539 std::pair<std::string,ConfigurationGroupKey>,
541 std::pair<std::string,ConfigurationGroupKey>(
542 groupPair.first.first,
543 groupPair.first.second),
544 "Error caught saving the group."));
556 FILE *fp = fopen((moveToDir +
"/README_otsdaq_flatten.txt").c_str(),
"a");
558 std::cout << __COUT_HDR_FL__ <<
"\tError opening README file!" << std::endl;
562 struct tm * timeinfo;
566 timeinfo = localtime (&rawtime);
567 strftime (buffer,200,
"%b %d, %Y %I:%M%p %Z",timeinfo);
569 fprintf(fp,
"This database was moved from...\n\t %s \nto...\n\t %s \nat this time \n\t %lu \t %s\n\n\n",
570 currentDir.c_str(),moveToDir.c_str(),time(0),buffer);
579 FILE *fp = fopen((currentDir +
"/README_otsdaq_flatten.txt").c_str(),
"a");
582 std::cout << __COUT_HDR_FL__ <<
"\tError opening README file!" << std::endl;
586 struct tm * timeinfo;
590 timeinfo = localtime (&rawtime);
591 strftime (buffer,200,
"%b %d, %Y %I:%M:%S%p %Z",timeinfo);
593 fprintf(fp,
"This database was moved from...\t %s \t to...\t %s at this time \t %lu \t %s\n\n",
594 pathToSwapIn.c_str(),currentDir.c_str(),time(0),buffer);
627 if(activeBackboneGroupName ==
"")
629 std::cout << __COUT_HDR_FL__ <<
"No active Backbone table identified." << std::endl;
633 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
634 "Modifying the active Backbone table to reflect new table versions and group keys." <<
638 cfgMgr->loadConfigurationGroup(
639 activeBackboneGroupName,
640 activeGroupKeys[activeBackboneGroupName].second,
641 true,&memberMap,0,&accumulateErrors);
646 const std::string groupAliasesName =
"GroupAliasesConfiguration";
647 const std::string versionAliasesName =
"VersionAliasesConfiguration";
650 std::map<std::string, ConfigurationVersion> activeMap = cfgMgr->getActiveVersions();
653 if(activeMap.find(groupAliasesName) != activeMap.end())
655 std::cout << __COUT_HDR_FL__ <<
"\n\nModifying " << groupAliasesName << std::endl;
656 config = cfgMgr->getConfigurationByName(groupAliasesName);
657 cfgView = config->getViewP();
659 unsigned int col1 = cfgView->findCol(
"GroupName");
660 unsigned int col2 = cfgView->findCol(
"GroupKey");
666 for(
unsigned int row = 0; row<cfgView->getNumberOfRows(); ++row )
669 for(
const auto &group: groupSet)
670 if(group.second.isInvalid())
continue;
671 else if(cfgView->getDataView()[row][col1] == group.first.first &&
672 cfgView->getDataView()[row][col2] == group.first.second.toString())
675 std::cout << __COUT_HDR_FL__ <<
676 "Changing row " << row <<
" for " <<
677 cfgView->getDataView()[row][col1] <<
" key=" <<
678 cfgView->getDataView()[row][col2] <<
" to NEW key=" <<
679 group.second << std::endl;
681 group.second.toString(),
688 cfgView->deleteRow(row--);
694 if(activeMap.find(versionAliasesName) != activeMap.end())
696 std::cout << __COUT_HDR_FL__ <<
"\n\nModifying " << versionAliasesName << std::endl;
697 config = cfgMgr->getConfigurationByName(versionAliasesName);
698 cfgView = config->getViewP();
699 unsigned int col1 = cfgView->findCol(
"ConfigurationName");
700 unsigned int col2 = cfgView->findCol(
"Version");
704 for(
unsigned int row = 0; row<cfgView->getNumberOfRows(); ++row )
707 for(
const auto &table:modifiedTables)
708 if(cfgView->getDataView()[row][col1] == table.first.first &&
709 cfgView->getDataView()[row][col2] == table.first.second.toString())
712 std::cout << __COUT_HDR_FL__ <<
"Changing row " << row <<
" for " <<
713 cfgView->getDataView()[row][col1] <<
" version=" <<
714 cfgView->getDataView()[row][col2] <<
" to NEW version=" <<
715 table.second << std::endl;
716 cfgView->setValue(table.second.toString(),row,col2);
722 cfgView->deleteRow(row--);
730 std::cout << __COUT_HDR_FL__ << groupAliasesName <<
":v" <<
731 memberMap[groupAliasesName] << std::endl;
733 config = cfgMgr->getConfigurationByName(groupAliasesName);
734 cfgView = config->getViewP();
736 theInterface_->saveActiveVersion(config);
738 memberMap[groupAliasesName] = flatVersion;
740 std::cout << __COUT_HDR_FL__ <<
"\t to...\t" <<
741 groupAliasesName <<
":v" << memberMap[groupAliasesName] << std::endl;
745 std::cout << __COUT_HDR_FL__ << versionAliasesName <<
":v" <<
746 memberMap[versionAliasesName] << std::endl;
748 config = cfgMgr->getConfigurationByName(versionAliasesName);
749 cfgView = config->getViewP();
751 theInterface_->saveActiveVersion(config);
753 memberMap[versionAliasesName] = flatVersion;
755 std::cout << __COUT_HDR_FL__ <<
"\t to...\t" <<
756 versionAliasesName <<
":v" << memberMap[versionAliasesName] << std::endl;
759 theInterface_->saveConfigurationGroup(memberMap,
760 ConfigurationGroupKey::getFullGroupString(
761 activeBackboneGroupName,
762 ConfigurationGroupKey(flatVersion)));
764 activeGroupKeys[activeBackboneGroupName].second =
765 ConfigurationGroupKey(flatVersion);
767 std::cout << __COUT_HDR_FL__ <<
"New to-be-active backbone group " << activeBackboneGroupName <<
768 ":v" << activeGroupKeys[activeBackboneGroupName].second << std::endl;
778 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Manipulating the Active Groups file..." << std::endl;
781 FILE *fp = fopen(ConfigurationManager::ACTIVE_GROUP_FILENAME.c_str(),
"r");
784 __SS__ <<
"Original active groups file '" << ConfigurationManager::ACTIVE_GROUP_FILENAME
785 <<
"' not found." << std::endl;
789 std::cout << __COUT_HDR_FL__ <<
"Backing up file: " << ConfigurationManager::ACTIVE_GROUP_FILENAME
794 std::string renameFile = ConfigurationManager::ACTIVE_GROUP_FILENAME +
"." + nowTime;
795 rename(ConfigurationManager::ACTIVE_GROUP_FILENAME.c_str(),
798 std::cout << __COUT_HDR_FL__ <<
"Backup file name: " << renameFile
801 ConfigurationGroupKey *theConfigurationGroupKey_, *theContextGroupKey_, *theBackboneGroupKey_, *theIterateGroupKey_;
802 std::string theConfigurationGroup_, theContextGroup_, theBackboneGroup_, theIterateGroup_;
804 theConfigurationGroup_ = activeConfigGroupName;
805 theConfigurationGroupKey_ = &(activeGroupKeys[activeConfigGroupName].second);
807 theContextGroup_ = activeContextGroupName;
808 theContextGroupKey_ = &(activeGroupKeys[activeContextGroupName].second);
810 theBackboneGroup_ = activeBackboneGroupName;
811 theBackboneGroupKey_ = &(activeGroupKeys[activeBackboneGroupName].second);
813 theIterateGroup_ = activeIterateGroupName;
814 theIterateGroupKey_ = &(activeGroupKeys[activeIterateGroupName].second);
819 std::cout << __COUT_HDR_FL__ <<
"Updating persistent active groups to " <<
820 ConfigurationManager::ACTIVE_GROUP_FILENAME <<
" ..." << std::endl;
822 std::string fn = ConfigurationManager::ACTIVE_GROUP_FILENAME;
823 FILE *fp = fopen(fn.c_str(),
"w");
826 fprintf(fp,
"%s\n",theContextGroup_.c_str());
827 fprintf(fp,
"%s\n",theContextGroupKey_?theContextGroupKey_->toString().c_str():
"-1");
828 fprintf(fp,
"%s\n",theBackboneGroup_.c_str());
829 fprintf(fp,
"%s\n",theBackboneGroupKey_?theBackboneGroupKey_->toString().c_str():
"-1");
830 fprintf(fp,
"%s\n",theConfigurationGroup_.c_str());
831 fprintf(fp,
"%s\n",theConfigurationGroupKey_?theConfigurationGroupKey_->toString().c_str():
"-1");
832 fprintf(fp,
"%s\n",theIterateGroup_.c_str());
833 fprintf(fp,
"%s\n",theIterateGroupKey_?theIterateGroupKey_->toString().c_str():
"-1");
840 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Groups:" << std::endl;
841 for(
const auto &group: groupSet)
842 std::cout << __COUT_HDR_FL__ <<
"\t" << group.first.first <<
": " <<
843 group.first.second <<
" => " << group.second << std::endl;
844 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Groups end." << std::endl;
849 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Active Groups:" << std::endl;
850 for(
const auto &activeGroup: activeGroupKeys)
851 std::cout << __COUT_HDR_FL__ <<
"\t" << activeGroup.first <<
": " <<
852 activeGroup.second.first <<
" => " << activeGroup.second.second << std::endl;
854 std::cout << __COUT_HDR_FL__ << activeBackboneGroupName <<
" is the " <<
855 ConfigurationManager::ACTIVE_GROUP_NAME_BACKBONE <<
"." << std::endl;
856 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Active Groups end." << std::endl;
861 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"End of Flattening Active Configuration Groups!\n\n\n" << std::endl;
865 std::cout << __COUT_HDR_FL__ <<
"****************************" << std::endl;
866 std::cout << __COUT_HDR_FL__ <<
"There were " << groupSet.size() <<
867 " groups considered, and there were errors handling " << groupErrors.size() <<
868 " of those groups." << std::endl;
869 std::cout << __COUT_HDR_FL__ <<
"The following errors were found handling the groups:" << std::endl;
870 for(
auto& groupErr:groupErrors)
871 std::cout << __COUT_HDR_FL__ <<
"\t" << groupErr.first.first <<
" " << groupErr.first.second <<
872 ": \t" << groupErr.second << std::endl;
873 std::cout << __COUT_HDR_FL__ <<
"End of errors.\n\n" << std::endl;
876 std::cout << __COUT_HDR_FL__ <<
"Run the following to return to your previous database structure:" <<
878 std::cout << __COUT_HDR_FL__ <<
"\t otsdaq_flatten_system_aliases -1 " << moveToDir <<
885 int main(
int argc,
char* argv[])
887 FlattenActiveSystemAliasConfigurationGroups(argc,argv);