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());
368 cfgMgr->loadConfigurationGroup(
369 groupPair.first.first,
370 groupPair.first.second,
371 true,0,&accumulateErrors);
373 catch(std::runtime_error& e)
376 std::cout << __COUT_HDR_FL__ <<
"Error was caught loading members for " <<
377 groupPair.first.first <<
378 "(" << groupPair.first.second <<
")" <<
380 std::cout << __COUT_HDR_FL__ << e.what() << std::endl;
385 std::cout << __COUT_HDR_FL__ <<
"Error was caught loading members for " <<
386 groupPair.first.first <<
387 "(" << groupPair.first.second <<
")" <<
398 std::cout << __COUT_HDR_FL__ <<
"Moving current directory: \t" << currentDir << std::endl;
399 std::cout << __COUT_HDR_FL__ <<
"\t... to: \t\t" << moveToDir << std::endl;
400 if(rename(currentDir.c_str(),moveToDir.c_str()) < 0)
402 __SS__ <<
"Problem!" << std::endl;
403 throw std::runtime_error(ss.str());
406 if(pathToSwapIn !=
"")
408 std::cout << __COUT_HDR_FL__ <<
"Swapping in directory: \t" << pathToSwapIn << std::endl;
409 std::cout << __COUT_HDR_FL__ <<
"\t.. to: \t\t" << currentDir << std::endl;
410 if(rename(pathToSwapIn.c_str(),currentDir.c_str()) < 0)
412 __SS__ <<
"Problem!" << std::endl;
413 throw std::runtime_error(ss.str());
418 std::cout << __COUT_HDR_FL__ <<
"Moving temporary directory: \t" << (moveToDir+
"_tmp") << std::endl;
419 std::cout << __COUT_HDR_FL__ <<
"\t.. to current directory: \t\t" << currentDir << std::endl;
420 if(rename((moveToDir+
"_tmp").c_str(),currentDir.c_str()) < 0)
422 __SS__ <<
"Problem!" << std::endl;
423 throw std::runtime_error(ss.str());
436 groupErrors.insert(std::pair<
437 std::pair<std::string,ConfigurationGroupKey>,
439 std::pair<std::string,ConfigurationGroupKey>(
440 groupPair.first.first,
441 groupPair.first.second),
442 "Error caught loading the group."));
454 for(
auto &memberPair:memberMap)
456 std::cout << __COUT_HDR_FL__ << memberPair.first <<
":v" << memberPair.second << std::endl;
460 if(modifiedTables.find(std::pair<std::string,ConfigurationVersion>(
463 )) != modifiedTables.end())
466 std::cout << __COUT_HDR_FL__ <<
"Table was already modified!" << std::endl;
467 memberPair.second = modifiedTables[std::pair<std::string,ConfigurationVersion>(
471 std::cout << __COUT_HDR_FL__ <<
"\t to...\t" <<
472 memberPair.first <<
":v" << memberPair.second << std::endl;
477 config = cfgMgr->getConfigurationByName(memberPair.first);
478 cfgView = config->getViewP();
480 theInterface_->saveActiveVersion(config);
483 cfgView->setVersion(memberPair.second);
485 memberPair.second = flatVersion;
487 std::cout << __COUT_HDR_FL__ <<
"\t to...\t" <<
488 memberPair.first <<
":v" << memberPair.second << std::endl;
491 modifiedTables.insert(std::pair<
492 std::pair<std::string,ConfigurationVersion>,
494 std::pair<std::string,ConfigurationVersion>(
502 theInterface_->saveConfigurationGroup(memberMap,
503 ConfigurationGroupKey::getFullGroupString(
504 groupPair.first.first,
505 ConfigurationGroupKey(flatVersion)));
508 groupPair.second = ConfigurationGroupKey(flatVersion);
511 if(activeGroupKeys.find(groupPair.first.first) != activeGroupKeys.end() &&
512 activeGroupKeys[groupPair.first.first].first == groupPair.first.second)
513 activeGroupKeys[groupPair.first.first].second =
514 ConfigurationGroupKey(flatVersion);
516 catch(std::runtime_error& e)
518 std::cout << __COUT_HDR_FL__ <<
"Error was caught saving group " <<
519 groupPair.first.first <<
520 " (" << groupPair.first.second <<
") " <<
522 std::cout << __COUT_HDR_FL__ << e.what() << std::endl;
524 groupErrors.insert(std::pair<
525 std::pair<std::string,ConfigurationGroupKey>,
527 std::pair<std::string,ConfigurationGroupKey>(
528 groupPair.first.first,
529 groupPair.first.second),
530 "Error caught saving the group."));
534 std::cout << __COUT_HDR_FL__ <<
"Error was caught saving group " <<
535 groupPair.first.first <<
536 " (" << groupPair.first.second <<
") " <<
539 groupErrors.insert(std::pair<
540 std::pair<std::string,ConfigurationGroupKey>,
542 std::pair<std::string,ConfigurationGroupKey>(
543 groupPair.first.first,
544 groupPair.first.second),
545 "Error caught saving the group."));
557 FILE *fp = fopen((moveToDir +
"/README_otsdaq_flatten.txt").c_str(),
"a");
559 std::cout << __COUT_HDR_FL__ <<
"\tError opening README file!" << std::endl;
563 struct tm * timeinfo;
567 timeinfo = localtime (&rawtime);
568 strftime (buffer,200,
"%b %d, %Y %I:%M%p %Z",timeinfo);
570 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",
571 currentDir.c_str(),moveToDir.c_str(),time(0),buffer);
580 FILE *fp = fopen((currentDir +
"/README_otsdaq_flatten.txt").c_str(),
"a");
583 std::cout << __COUT_HDR_FL__ <<
"\tError opening README file!" << std::endl;
587 struct tm * timeinfo;
591 timeinfo = localtime (&rawtime);
592 strftime (buffer,200,
"%b %d, %Y %I:%M:%S%p %Z",timeinfo);
594 fprintf(fp,
"This database was moved from...\t %s \t to...\t %s at this time \t %lu \t %s\n\n",
595 pathToSwapIn.c_str(),currentDir.c_str(),time(0),buffer);
628 if(activeBackboneGroupName ==
"")
630 std::cout << __COUT_HDR_FL__ <<
"No active Backbone table identified." << std::endl;
634 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
635 "Modifying the active Backbone table to reflect new table versions and group keys." <<
640 cfgMgr->loadConfigurationGroup(
641 activeBackboneGroupName,
642 activeGroupKeys[activeBackboneGroupName].second,
643 true,0,&accumulateErrors);
648 const std::string groupAliasesName =
"GroupAliasesConfiguration";
649 const std::string versionAliasesName =
"VersionAliasesConfiguration";
652 std::map<std::string, ConfigurationVersion> activeMap = cfgMgr->getActiveVersions();
655 if(activeMap.find(groupAliasesName) != activeMap.end())
657 std::cout << __COUT_HDR_FL__ <<
"\n\nModifying " << groupAliasesName << std::endl;
658 config = cfgMgr->getConfigurationByName(groupAliasesName);
659 cfgView = config->getViewP();
661 unsigned int col1 = cfgView->findCol(
"GroupName");
662 unsigned int col2 = cfgView->findCol(
"GroupKey");
668 for(
unsigned int row = 0; row<cfgView->getNumberOfRows(); ++row )
671 for(
const auto &group: groupSet)
672 if(group.second.isInvalid())
continue;
673 else if(cfgView->getDataView()[row][col1] == group.first.first &&
674 cfgView->getDataView()[row][col2] == group.first.second.toString())
677 std::cout << __COUT_HDR_FL__ <<
678 "Changing row " << row <<
" for " <<
679 cfgView->getDataView()[row][col1] <<
" key=" <<
680 cfgView->getDataView()[row][col2] <<
" to NEW key=" <<
681 group.second << std::endl;
683 group.second.toString(),
690 cfgView->deleteRow(row--);
696 if(activeMap.find(versionAliasesName) != activeMap.end())
698 std::cout << __COUT_HDR_FL__ <<
"\n\nModifying " << versionAliasesName << std::endl;
699 config = cfgMgr->getConfigurationByName(versionAliasesName);
700 cfgView = config->getViewP();
701 unsigned int col1 = cfgView->findCol(
"ConfigurationName");
702 unsigned int col2 = cfgView->findCol(
"Version");
706 for(
unsigned int row = 0; row<cfgView->getNumberOfRows(); ++row )
709 for(
const auto &table:modifiedTables)
710 if(cfgView->getDataView()[row][col1] == table.first.first &&
711 cfgView->getDataView()[row][col2] == table.first.second.toString())
714 std::cout << __COUT_HDR_FL__ <<
"Changing row " << row <<
" for " <<
715 cfgView->getDataView()[row][col1] <<
" version=" <<
716 cfgView->getDataView()[row][col2] <<
" to NEW version=" <<
717 table.second << std::endl;
718 cfgView->setValue(table.second.toString(),row,col2);
724 cfgView->deleteRow(row--);
732 std::cout << __COUT_HDR_FL__ << groupAliasesName <<
":v" <<
733 memberMap[groupAliasesName] << std::endl;
735 config = cfgMgr->getConfigurationByName(groupAliasesName);
736 cfgView = config->getViewP();
738 theInterface_->saveActiveVersion(config);
740 memberMap[groupAliasesName] = flatVersion;
742 std::cout << __COUT_HDR_FL__ <<
"\t to...\t" <<
743 groupAliasesName <<
":v" << memberMap[groupAliasesName] << std::endl;
747 std::cout << __COUT_HDR_FL__ << versionAliasesName <<
":v" <<
748 memberMap[versionAliasesName] << std::endl;
750 config = cfgMgr->getConfigurationByName(versionAliasesName);
751 cfgView = config->getViewP();
753 theInterface_->saveActiveVersion(config);
755 memberMap[versionAliasesName] = flatVersion;
757 std::cout << __COUT_HDR_FL__ <<
"\t to...\t" <<
758 versionAliasesName <<
":v" << memberMap[versionAliasesName] << std::endl;
761 theInterface_->saveConfigurationGroup(memberMap,
762 ConfigurationGroupKey::getFullGroupString(
763 activeBackboneGroupName,
764 ConfigurationGroupKey(flatVersion)));
766 activeGroupKeys[activeBackboneGroupName].second =
767 ConfigurationGroupKey(flatVersion);
769 std::cout << __COUT_HDR_FL__ <<
"New to-be-active backbone group " << activeBackboneGroupName <<
770 ":v" << activeGroupKeys[activeBackboneGroupName].second << std::endl;
780 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Manipulating the Active Groups file..." << std::endl;
783 FILE *fp = fopen(ConfigurationManager::ACTIVE_GROUP_FILENAME.c_str(),
"r");
786 __SS__ <<
"Original active groups file '" << ConfigurationManager::ACTIVE_GROUP_FILENAME
787 <<
"' not found." << std::endl;
791 std::cout << __COUT_HDR_FL__ <<
"Backing up file: " << ConfigurationManager::ACTIVE_GROUP_FILENAME
796 std::string renameFile = ConfigurationManager::ACTIVE_GROUP_FILENAME +
"." + nowTime;
797 rename(ConfigurationManager::ACTIVE_GROUP_FILENAME.c_str(),
800 std::cout << __COUT_HDR_FL__ <<
"Backup file name: " << renameFile
803 ConfigurationGroupKey *theConfigurationGroupKey_, *theContextGroupKey_, *theBackboneGroupKey_, *theIterateGroupKey_;
804 std::string theConfigurationGroup_, theContextGroup_, theBackboneGroup_, theIterateGroup_;
806 theConfigurationGroup_ = activeConfigGroupName;
807 theConfigurationGroupKey_ = &(activeGroupKeys[activeConfigGroupName].second);
809 theContextGroup_ = activeContextGroupName;
810 theContextGroupKey_ = &(activeGroupKeys[activeContextGroupName].second);
812 theBackboneGroup_ = activeBackboneGroupName;
813 theBackboneGroupKey_ = &(activeGroupKeys[activeBackboneGroupName].second);
815 theIterateGroup_ = activeIterateGroupName;
816 theIterateGroupKey_ = &(activeGroupKeys[activeIterateGroupName].second);
821 std::cout << __COUT_HDR_FL__ <<
"Updating persistent active groups to " <<
822 ConfigurationManager::ACTIVE_GROUP_FILENAME <<
" ..." << std::endl;
824 std::string fn = ConfigurationManager::ACTIVE_GROUP_FILENAME;
825 FILE *fp = fopen(fn.c_str(),
"w");
828 fprintf(fp,
"%s\n",theContextGroup_.c_str());
829 fprintf(fp,
"%s\n",theContextGroupKey_?theContextGroupKey_->toString().c_str():
"-1");
830 fprintf(fp,
"%s\n",theBackboneGroup_.c_str());
831 fprintf(fp,
"%s\n",theBackboneGroupKey_?theBackboneGroupKey_->toString().c_str():
"-1");
832 fprintf(fp,
"%s\n",theConfigurationGroup_.c_str());
833 fprintf(fp,
"%s\n",theConfigurationGroupKey_?theConfigurationGroupKey_->toString().c_str():
"-1");
834 fprintf(fp,
"%s\n",theIterateGroup_.c_str());
835 fprintf(fp,
"%s\n",theIterateGroupKey_?theIterateGroupKey_->toString().c_str():
"-1");
842 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Groups:" << std::endl;
843 for(
const auto &group: groupSet)
844 std::cout << __COUT_HDR_FL__ <<
"\t" << group.first.first <<
": " <<
845 group.first.second <<
" => " << group.second << std::endl;
846 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Groups end." << std::endl;
851 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Active Groups:" << std::endl;
852 for(
const auto &activeGroup: activeGroupKeys)
853 std::cout << __COUT_HDR_FL__ <<
"\t" << activeGroup.first <<
": " <<
854 activeGroup.second.first <<
" => " << activeGroup.second.second << std::endl;
856 std::cout << __COUT_HDR_FL__ << activeBackboneGroupName <<
" is the " <<
857 ConfigurationManager::ACTIVE_GROUP_NAME_BACKBONE <<
"." << std::endl;
858 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"Resulting Active Groups end." << std::endl;
863 std::cout <<
"\n\n" << __COUT_HDR_FL__ <<
"End of Flattening Active Configuration Groups!\n\n\n" << std::endl;
867 std::cout << __COUT_HDR_FL__ <<
"****************************" << std::endl;
868 std::cout << __COUT_HDR_FL__ <<
"There were " << groupSet.size() <<
869 " groups considered, and there were errors handling " << groupErrors.size() <<
870 " of those groups." << std::endl;
871 std::cout << __COUT_HDR_FL__ <<
"The following errors were found handling the groups:" << std::endl;
872 for(
auto& groupErr:groupErrors)
873 std::cout << __COUT_HDR_FL__ <<
"\t" << groupErr.first.first <<
" " << groupErr.first.second <<
874 ": \t" << groupErr.second << std::endl;
875 std::cout << __COUT_HDR_FL__ <<
"End of errors.\n\n" << std::endl;
878 std::cout << __COUT_HDR_FL__ <<
"Run the following to return to your previous database structure:" <<
880 std::cout << __COUT_HDR_FL__ <<
"\t otsdaq_flatten_system_aliases -1 " << moveToDir <<
887 int main(
int argc,
char* argv[])
889 FlattenActiveSystemAliasConfigurationGroups(argc,argv);