1 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
2 #include "artdaq/Application/LoadParameterSet.hh"
3 #include "otsdaq/ConfigurationInterface/ConfigurationInterface.h"
4 #include "otsdaq/ProgressBar/ProgressBar.h"
5 #include "otsdaq/TablePlugins/XDAQContextTable/XDAQContextTable.h"
9 #include "otsdaq/TableCore/TableGroupKey.h"
10 #include "otsdaq/TablePlugins/DesktopIconTable.h"
15 #define __MF_SUBJECT__ "ConfigurationManager"
22 const std::string ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH = ((getenv(
"SERVICE_DATA_PATH") == NULL)
23 ? (std::string(__ENV__(
"USER_DATA")) +
"/ServiceData")
24 : (std::string(__ENV__(
"SERVICE_DATA_PATH")))) +
27 const std::string ConfigurationManager::LAST_ACTIVATED_CONFIG_GROUP_FILE =
"CFGLastActivatedConfigGroup.hist";
28 const std::string ConfigurationManager::LAST_ACTIVATED_CONTEXT_GROUP_FILE =
"CFGLastActivatedContextGroup.hist";
29 const std::string ConfigurationManager::LAST_ACTIVATED_BACKBONE_GROUP_FILE =
"CFGLastActivatedBackboneGroup.hist";
30 const std::string ConfigurationManager::LAST_ACTIVATED_ITERATE_GROUP_FILE =
"CFGLastActivatedIterateGroup.hist";
32 const std::string ConfigurationManager::ACTIVATED_CONFIGS_FILE =
"CFGActivatedConfigGroups.hist";
33 const std::string ConfigurationManager::ACTIVATED_CONTEXTS_FILE =
"CFGActivatedContextGroups.hist";
34 const std::string ConfigurationManager::ACTIVATED_BACKBONES_FILE =
"CFGActivatedBackboneGroups.hist";
35 const std::string ConfigurationManager::ACTIVATED_ITERATES_FILE =
"CFGActivatedIterateGroups.hist";
37 const std::string ConfigurationManager::LAST_CONFIGURED_CONFIG_ALIAS_FILE =
"CFGLastConfiguredConfigAlias.hist";
38 const std::string ConfigurationManager::LAST_CONFIGURED_CONFIG_GROUP_FILE =
"CFGLastConfiguredConfigGroup.hist";
39 const std::string ConfigurationManager::LAST_CONFIGURED_CONTEXT_GROUP_FILE =
"CFGLastConfiguredContextGroup.hist";
40 const std::string ConfigurationManager::LAST_CONFIGURED_BACKBONE_GROUP_FILE =
"CFGLastConfiguredBackboneGroup.hist";
41 const std::string ConfigurationManager::LAST_CONFIGURED_ITERATE_GROUP_FILE =
"CFGLastConfiguredIterateGroup.hist";
43 const std::string ConfigurationManager::CONFIGURED_CONFIG_ALIASES_FILE =
"CFGConfiguredConfigAliases.hist";
44 const std::string ConfigurationManager::CONFIGURED_CONFIGS_FILE =
"CFGConfiguredConfigGroups.hist";
45 const std::string ConfigurationManager::CONFIGURED_CONTEXTS_FILE =
"CFGConfiguredContextGroups.hist";
46 const std::string ConfigurationManager::CONFIGURED_BACKBONES_FILE =
"CFGConfiguredBackboneGroups.hist";
47 const std::string ConfigurationManager::CONFIGURED_ITERATES_FILE =
"CFGConfiguredIterateGroups.hist";
49 const std::string ConfigurationManager::LAST_STARTED_CONFIG_ALIAS_FILE =
"CFGLastStartedConfigAlias.hist";
50 const std::string ConfigurationManager::LAST_STARTED_CONFIG_GROUP_FILE =
"CFGLastStartedConfigGroup.hist";
51 const std::string ConfigurationManager::LAST_STARTED_CONTEXT_GROUP_FILE =
"CFGLastStartedContextGroup.hist";
52 const std::string ConfigurationManager::LAST_STARTED_BACKBONE_GROUP_FILE =
"CFGLastStartedBackboneGroup.hist";
53 const std::string ConfigurationManager::LAST_STARTED_ITERATE_GROUP_FILE =
"CFGLastStartedIterateGroup.hist";
55 const std::string ConfigurationManager::STARTED_CONFIG_ALIASES_FILE =
"CFGStartedConfigAliases.hist";
56 const std::string ConfigurationManager::STARTED_CONFIGS_FILE =
"CFGStartedConfigGroups.hist";
57 const std::string ConfigurationManager::STARTED_CONTEXTS_FILE =
"CFGStartedContextGroups.hist";
58 const std::string ConfigurationManager::STARTED_BACKBONES_FILE =
"CFGStartedBackboneGroups.hist";
59 const std::string ConfigurationManager::STARTED_ITERATES_FILE =
"CFGStartedIterateGroups.hist";
61 const std::string ConfigurationManager::CONFIGURED_OR_STARTED_CONFIG_ALIASES_FILE =
"CFGConfiguredOrStartedConfigAliases.hist";
62 const std::string ConfigurationManager::CONFIGURED_OR_STARTED_CONFIGS_FILE =
"CFGConfiguredOrStartedConfigGroups.hist";
63 const std::string ConfigurationManager::CONFIGURED_OR_STARTED_CONTEXTS_FILE =
"CFGConfiguredOrStartedContextGroups.hist";
64 const std::string ConfigurationManager::CONFIGURED_OR_STARTED_BACKBONES_FILE =
"CFGConfiguredOrStartedBackboneGroups.hist";
65 const std::string ConfigurationManager::CONFIGURED_OR_STARTED_ITERATES_FILE =
"CFGConfiguredOrStartedIterateGroups.hist";
68 const std::string ConfigurationManager::READONLY_USER =
"READONLY_USER";
70 const std::string ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME =
"XDAQContextTable";
71 const std::string ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME =
"XDAQApplicationTable";
72 const std::string ConfigurationManager::XDAQ_APP_PROPERTY_TABLE_NAME =
"XDAQApplicationPropertyTable";
73 const std::string ConfigurationManager::GROUP_ALIASES_TABLE_NAME =
"GroupAliasesTable";
74 const std::string ConfigurationManager::VERSION_ALIASES_TABLE_NAME =
"VersionAliasesTable";
75 const std::string ConfigurationManager::ARTDAQ_TOP_TABLE_NAME =
"ARTDAQSupervisorTable";
76 const std::string ConfigurationManager::DESKTOP_ICON_TABLE_NAME =
"DesktopIconTable";
80 ? (std::string(__ENV__(
"USER_DATA")) +
"/ServiceData")
81 : (std::string(__ENV__(
"SERVICE_DATA_PATH")))) +
82 "/ActiveTableGroups.cfg";
83 const std::string ConfigurationManager::ALIAS_VERSION_PREAMBLE =
"ALIAS:";
84 const std::string ConfigurationManager::SCRATCH_VERSION_ALIAS =
"Scratch";
86 const std::string ConfigurationManager::GROUP_TYPE_NAME_CONTEXT =
"Context";
87 const std::string ConfigurationManager::GROUP_TYPE_NAME_BACKBONE =
"Backbone";
88 const std::string ConfigurationManager::GROUP_TYPE_NAME_ITERATE =
"Iterate";
89 const std::string ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION =
"Configuration";
90 const std::string ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN =
"UNKNOWN";
92 const std::string ConfigurationManager::UNKNOWN_INFO =
"UNKNOWN";
93 const std::string ConfigurationManager::UNKNOWN_TIME =
"0";
95 const uint8_t ConfigurationManager::METADATA_COL_ALIASES = 1;
96 const uint8_t ConfigurationManager::METADATA_COL_COMMENT = 2;
97 const uint8_t ConfigurationManager::METADATA_COL_AUTHOR = 3;
98 const uint8_t ConfigurationManager::METADATA_COL_TIMESTAMP = 4;
100 const std::string ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE =
"SubsystemUserDataPathsTable";
103 const std::set<std::string> ConfigurationManager::fixedContextMemberNames_ = {
104 ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME,
105 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
106 "XDAQApplicationPropertyTable",
107 ConfigurationManager::DESKTOP_ICON_TABLE_NAME,
108 "MessageFacilityTable",
109 "GatewaySupervisorTable",
111 "DesktopWindowParameterTable",
112 "SlowControlsDashboardSupervisorTable"
114 const std::set<std::string> ConfigurationManager::backboneMemberNames_ = {
115 ConfigurationManager::GROUP_ALIASES_TABLE_NAME,
116 ConfigurationManager::VERSION_ALIASES_TABLE_NAME
118 const std::set<std::string> ConfigurationManager::iterateMemberNames_ = {
120 "IterationPlanTable",
121 "IterationTargetTable",
122 "IterationCommandBeginLabelTable",
123 "IterationCommandChooseFSMTable",
124 "IterationCommandConfigureAliasTable",
125 "IterationCommandConfigureGroupTable",
126 "IterationCommandExecuteFEMacroTable",
127 "IterationCommandExecuteMacroTable",
128 "IterationCommandMacroDimensionalLoopTable",
129 "IterationCommandMacroDimensionalLoopParameterTable",
130 "IterationCommandModifyGroupTable",
131 "IterationCommandRepeatLabelTable",
132 "IterationCommandRunTable"
139 bool doInitializeFromFhicl ,
140 bool forceNotFirstInContext )
141 : startClockTime_(std::chrono::steady_clock::now())
142 , deltaClockTime_(std::chrono::steady_clock::now())
143 , forceNotFirstInContext_(forceNotFirstInContext)
147 , theConfigurationTableGroupKey_(0)
148 , theContextTableGroupKey_(0)
149 , theBackboneTableGroupKey_(0)
150 , theConfigurationTableGroup_(
"")
151 , theContextTableGroup_(
"")
152 , theBackboneTableGroup_(
"")
153 , groupMetadataTable_(true ,
TableBase::GROUP_METADATA_TABLE_NAME)
155 __GEN_COUTTV__(runTimeSeconds());
156 theInterface_ = ConfigurationInterface::getInstance(
157 ConfigurationInterface::CONFIGURATION_MODE::
160 __GEN_COUTTV__(runTimeSeconds());
232 if(doInitializeFromFhicl)
235 initializeFromFhicl(__ENV__(
"CONFIGURATION_INIT_FCL"));
240 __GEN_COUTTV__(runTimeSeconds());
241 if(!initForWriteAccess)
242 init(0 , initForWriteAccess);
243 __GEN_COUTTV__(runTimeSeconds());
251 __GEN_COUT__ <<
"Private constructor for write access called." << __E__;
253 mfSubject_ = username;
254 username_ = username;
258 ConfigurationManager::~ConfigurationManager() { destroy(); }
267 bool initForWriteAccess ,
268 std::string* accumulatedWarnings )
280 __GEN_COUTTV__(username_);
285 ConfigurationManager::LoadGroupType onlyLoadIfBackboneOrContext =
286 ConfigurationManager::LoadGroupType::ALL_TYPES;
287 if(username_ == ConfigurationManager::READONLY_USER && !initForWriteAccess)
288 onlyLoadIfBackboneOrContext =
289 ConfigurationManager::LoadGroupType::ONLY_BACKBONE_OR_CONTEXT_TYPES;
294 onlyLoadIfBackboneOrContext,
295 accumulatedWarnings);
298 catch(std::runtime_error& e)
300 __GEN_COUT_ERR__ <<
"Error caught in init(): " << e.what();
301 if(accumulatedErrors)
302 *accumulatedErrors += e.what();
319 const std::string& pathToActiveGroupsFile ,
320 ConfigurationManager::LoadGroupType
321 onlyLoadIfBackboneOrContext ,
322 std::string* accumulatedWarnings )
328 FILE* fp = fopen(fn.c_str(),
"r");
330 __GEN_COUTT__ <<
"ACTIVE_GROUPS_FILENAME = " << fn << __E__;
331 __GEN_COUTS__(10) <<
"ARTDAQ_DATABASE_URI = "
332 << std::string(__ENV__(
"ARTDAQ_DATABASE_URI")) << __E__;
336 __GEN_COUT_WARN__ <<
"No active groups file found at " << fn << __E__;
340 __GEN_COUTVS__(10, throwErrors);
345 std::string groupName;
346 std::string errorStr =
"";
351 while(fgets(tmp, 500, fp))
356 sscanf(tmp,
"%d", &numberCheck);
360 <<
"Out of sync with active groups file lines, attempting to resync."
367 sscanf(tmp,
"%s", strVal);
368 for(
unsigned int j = 0; j < strlen(strVal); ++j)
369 if(!((strVal[j] >=
'a' && strVal[j] <=
'z') ||
370 (strVal[j] >=
'A' && strVal[j] <=
'Z') ||
371 (strVal[j] >=
'0' && strVal[j] <=
'9')))
374 __GEN_COUT_WARN__ <<
"Illegal character found in group name '" << strVal
375 <<
"', so skipping! Check active groups file: " << fn
387 sscanf(tmp,
"%s", strVal);
389 for(
unsigned int j = 0; j < strlen(strVal); ++j)
390 if(!((strVal[j] >=
'0' && strVal[j] <=
'9')))
394 if(groupName.size() > 3)
396 <<
"Skipping active group with illegal character in group key '"
397 << strVal <<
".' Check active groups file: " << fn << __E__;
403 if(groupName.size() <= 3)
416 <<
"illegal group according to TableGroupKey::getFullGroupString... "
417 "Check active groups file: "
428 std::string groupAccumulatedErrors =
"";
430 if(accumulatedWarnings)
431 __GEN_COUT__ <<
"Ignoring warnings while loading and activating group '"
432 << groupName <<
"(" << strVal <<
")'" << __E__;
440 (accumulatedWarnings ? &groupAccumulatedErrors
448 onlyLoadIfBackboneOrContext
451 if(accumulatedWarnings)
452 *accumulatedWarnings += groupAccumulatedErrors;
454 catch(std::runtime_error& e)
456 ss <<
"Failed to load group in ConfigurationManager::init() with name '"
457 << groupName <<
"(" << strVal
458 <<
")' specified active by active groups file: " << fn << __E__;
459 ss << e.what() << __E__;
461 errorStr += ss.str();
465 ss <<
"Failed to load group in ConfigurationManager::init() with name '"
466 << groupName <<
"(" << strVal
467 <<
")' specified active by active groups file: " << fn << __E__;
472 catch(
const std::exception& e)
474 ss <<
"Exception message: " << e.what();
479 errorStr += ss.str();
485 if(throwErrors && errorStr !=
"")
487 __SS__ <<
"\n" << errorStr;
490 else if(errorStr !=
"")
491 __GEN_COUT_WARN__ <<
"\n" << errorStr;
504 bool isContext = theGroup ==
"" || theGroup == theContextTableGroup_;
505 bool isBackbone = theGroup ==
"" || theGroup == theBackboneTableGroup_;
506 bool isIterate = theGroup ==
"" || theGroup == theIterateTableGroup_;
507 bool isConfiguration = theGroup ==
"" || theGroup == theConfigurationTableGroup_;
509 if(!isContext && !isBackbone && !isIterate && !isConfiguration)
511 __SS__ <<
"Invalid configuration group to destroy: " << theGroup << __E__;
512 __GEN_COUT_ERR__ << ss.str();
516 std::string dbgHeader = onlyDeactivate ?
"Deactivating" :
"Destroying";
520 __GEN_COUT__ << dbgHeader <<
" Context group: " << theGroup << __E__;
522 __GEN_COUT__ << dbgHeader <<
" Backbone group: " << theGroup << __E__;
524 __GEN_COUT__ << dbgHeader <<
" Iterate group: " << theGroup << __E__;
526 __GEN_COUT__ << dbgHeader <<
" Configuration group: " << theGroup << __E__;
529 getActiveContextMemberNames();
531 std::set<std::string>::const_iterator contextFindIt, backboneFindIt, iterateFindIt;
532 for(
auto it = nameToTableMap_.begin(); it != nameToTableMap_.end();
535 contextFindIt = contextMemberNames_.find(it->first);
536 backboneFindIt = backboneMemberNames_.find(it->first);
537 iterateFindIt = iterateMemberNames_.find(it->first);
539 __GEN_COUTT__ <<
"Considering table: " << it->first <<
" contextFindIt:"
540 << (contextFindIt != contextMemberNames_.end() ?
"Y" :
"N")
541 <<
" backboneFindIt:"
542 << (backboneFindIt != backboneMemberNames_.end() ?
"Y" :
"N")
544 << (iterateFindIt != iterateMemberNames_.end() ?
"Y" :
"N")
554 CONTEXT_SUBSYSTEM_OPTIONAL_TABLE) ||
555 (isBackbone && backboneFindIt != backboneMemberNames_.end()) ||
556 (isIterate && iterateFindIt != iterateMemberNames_.end()) ||
558 contextFindIt == contextMemberNames_.end() &&
559 it->first != ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE &&
560 backboneFindIt == backboneMemberNames_.end() &&
561 iterateFindIt == iterateMemberNames_.end())))
563 __GEN_COUTT__ <<
"\t" << dbgHeader <<
".. " << it->first
564 << (it->second->isActive()
565 ?
"_v" + it->second->getViewVersion().str()
571 it->second->deactivate();
577 nameToTableMap_.erase(it++);
586 theConfigurationTableGroup_ =
"";
587 if(theConfigurationTableGroupKey_ != 0)
589 __GEN_COUTT__ <<
"Destroying Configuration Key: "
590 << *theConfigurationTableGroupKey_ << __E__;
591 theConfigurationTableGroupKey_.reset();
596 theBackboneTableGroup_ =
"";
597 if(theBackboneTableGroupKey_ != 0)
599 __GEN_COUTT__ <<
"Destroying Backbone Key: " << *theBackboneTableGroupKey_
601 theBackboneTableGroupKey_.reset();
606 theIterateTableGroup_ =
"";
607 if(theIterateTableGroupKey_ != 0)
609 __GEN_COUTT__ <<
"Destroying Iterate Key: " << *theIterateTableGroupKey_
611 theIterateTableGroupKey_.reset();
616 theContextTableGroup_ =
"";
617 if(theContextTableGroupKey_ != 0)
619 __GEN_COUTT__ <<
"Destroying Context Key: " << *theContextTableGroupKey_
621 theContextTableGroupKey_.reset();
636 const ConfigurationManager::GroupType& groupTypeId)
638 return groupTypeId == ConfigurationManager::GroupType::CONTEXT_TYPE
639 ? ConfigurationManager::GROUP_TYPE_NAME_CONTEXT
640 : (groupTypeId == ConfigurationManager::GroupType::BACKBONE_TYPE
641 ? ConfigurationManager::GROUP_TYPE_NAME_BACKBONE
642 : (groupTypeId == ConfigurationManager::GroupType::ITERATE_TYPE
643 ? ConfigurationManager::GROUP_TYPE_NAME_ITERATE
644 : (groupTypeId == ConfigurationManager::GroupType::
646 ? ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION
647 : ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)));
658 const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap)
660 bool isContext =
true;
661 bool isBackbone =
true;
662 bool isIterate =
true;
664 bool inContext =
false;
665 bool inBackbone =
false;
666 bool inIterate =
false;
667 unsigned int matchCount = 0;
669 for(
auto& memberPair : memberMap)
674 if(memberPair.first == CONTEXT_SUBSYSTEM_OPTIONAL_TABLE)
680 for(
auto& contextMemberString : fixedContextMemberNames_)
681 if(memberPair.first == contextMemberString)
693 __SS__ <<
"This group is an incomplete match to a Context group.\n";
694 ss <<
"\nTo be a Context group, the members must exactly match "
695 <<
"the following members (w/ or wo/ the optional table "
696 << CONTEXT_SUBSYSTEM_OPTIONAL_TABLE <<
"):\n";
698 for(
const auto& memberName : fixedContextMemberNames_)
699 ss << ++i <<
". " << memberName <<
"\n";
700 ss <<
"\nThe members are as follows::\n";
702 for(
const auto& memberPairTmp : memberMap)
703 ss << ++i <<
". " << memberPairTmp.first <<
"\n";
710 for(
auto& backboneMemberString : backboneMemberNames_)
711 if(memberPair.first == backboneMemberString)
723 __SS__ <<
"This group is an incomplete match to a Backbone group.\n";
724 ss <<
"\nTo be a Backbone group, the members must exactly match "
725 <<
"the following members:\n";
727 for(
auto& memberName : backboneMemberNames_)
728 ss << ++i <<
". " << memberName <<
"\n";
729 ss <<
"\nThe members are as follows::\n";
731 for(
const auto& memberPairTmp : memberMap)
732 ss << ++i <<
". " << memberPairTmp.first <<
"\n";
740 for(
auto& iterateMemberString : iterateMemberNames_)
741 if(memberPair.first == iterateMemberString)
753 __SS__ <<
"This group is an incomplete match to a Iterate group.\n";
754 ss <<
"\nTo be a Iterate group, the members must exactly match "
755 <<
"the following members:\n";
757 for(
auto& memberName : iterateMemberNames_)
758 ss << ++i <<
". " << memberName <<
"\n";
759 ss <<
"\nThe members are as follows::\n";
761 for(
const auto& memberPairTmp : memberMap)
762 ss << ++i <<
". " << memberPairTmp.first <<
"\n";
769 if((isContext || inContext) && matchCount != fixedContextMemberNames_.size())
771 __SS__ <<
"This group is an incomplete match to a Context group: "
772 <<
" Size=" << matchCount <<
" but should be "
773 << fixedContextMemberNames_.size() << __E__;
774 ss <<
"\nThe members currently are...\n";
776 for(
auto& memberPair : memberMap)
777 ss << ++i <<
". " << memberPair.first <<
"\n";
778 ss <<
"\nThe expected Context members are...\n";
780 for(
auto& memberName : fixedContextMemberNames_)
781 ss << ++i <<
". " << memberName <<
"\n";
782 ss <<
"optional. (" << CONTEXT_SUBSYSTEM_OPTIONAL_TABLE <<
")\n";
787 if((isBackbone || inBackbone) && matchCount != backboneMemberNames_.size())
789 __SS__ <<
"This group is an incomplete match to a Backbone group: "
790 <<
" Size=" << matchCount <<
" but should be "
791 << backboneMemberNames_.size() << __E__;
792 ss <<
"\nThe members currently are...\n";
794 for(
auto& memberPair : memberMap)
795 ss << ++i <<
". " << memberPair.first <<
"\n";
796 ss <<
"\nThe expected Backbone members are...\n";
798 for(
auto& memberName : backboneMemberNames_)
799 ss << ++i <<
". " << memberName <<
"\n";
804 if((isIterate || inIterate) && matchCount != iterateMemberNames_.size())
806 __SS__ <<
"This group is an incomplete match to a Iterate group: "
807 <<
" Size=" << matchCount <<
" but should be "
808 << iterateMemberNames_.size() << __E__;
809 ss <<
"\nThe members currently are...\n";
811 for(
auto& memberPair : memberMap)
812 ss << ++i <<
". " << memberPair.first <<
"\n";
813 ss <<
"\nThe expected Iterate members are...\n";
815 for(
auto& memberName : iterateMemberNames_)
816 ss << ++i <<
". " << memberName <<
"\n";
822 ? ConfigurationManager::GroupType::CONTEXT_TYPE
824 ? ConfigurationManager::GroupType::BACKBONE_TYPE
826 ? ConfigurationManager::GroupType::ITERATE_TYPE
827 : ConfigurationManager::GroupType::CONFIGURATION_TYPE));
834 const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap)
845 #define OUT out << tabStr << commentStr
846 #define PUSHTAB tabStr += "\t"
847 #define POPTAB tabStr.resize(tabStr.size() - 1)
848 #define PUSHCOMMENT commentStr += "# "
849 #define POPCOMMENT commentStr.resize(commentStr.size() - 2)
851 void ConfigurationManager::dumpMacroMakerModeFhicl()
853 std::string filepath =
854 __ENV__(
"USER_DATA") + std::string(
"/") +
"MacroMakerModeConfigurations";
855 mkdir(filepath.c_str(), 0755);
856 filepath +=
"/MacroMakerModeFhiclDump.fcl";
857 __GEN_COUT__ <<
"dumpMacroMakerModeFhicl: " << filepath << __E__;
863 std::string tabStr =
"";
864 std::string commentStr =
"";
866 out.open(filepath, std::fstream::out | std::fstream::trunc);
869 __SS__ <<
"Failed to open MacroMaker mode fcl file for configuration dump: "
870 << filepath << __E__;
876 std::vector<std::pair<std::string, ConfigurationTree>> fes =
882 if(!fe.second.status())
887 OUT << fe.first <<
": {" << __E__;
892 OUT <<
"FEInterfacePluginName"
894 <<
"\"" << fe.second.getNode(
"FEInterfacePluginName").getValueAsString()
897 recursiveTreeToFhicl(
898 fe.second.getNode(
"LinkToFETypeTable"), out, tabStr, commentStr);
901 OUT <<
"} //end " << fe.first << __E__ << __E__;
907 __SS__ <<
"Failed to complete MacroMaker mode fcl "
908 "file configuration dump due to error."
914 catch(
const std::runtime_error& e)
916 ss <<
"Exception message: " << e.what();
918 catch(
const std::exception& e)
920 ss <<
"Exception message: " << e.what();
922 __GEN_COUT_ERR__ << ss.str();
940 std::string& tabStr ,
941 std::string& commentStr ,
946 __COUT__ << __COUT_HDR_P__ <<
"Depth limit reached. Ending recursion." << __E__;
952 if(depth == (
unsigned int)-1)
972 std::vector<std::pair<std::string, ConfigurationTree>> children =
974 for(
auto& child : children)
975 recursiveTreeToFhicl(child.second, out, tabStr, commentStr, depth - 1);
979 <<
" group link record" << __E__;
991 std::vector<std::pair<std::string, ConfigurationTree>> fields =
995 for(
unsigned int i = 0; i < fields.size() - 3; ++i)
999 if(fields[i].second.isLinkNode())
1001 recursiveTreeToFhicl(
1002 fields[i].second, out, tabStr, commentStr, depth - 1);
1007 OUT << fields[i].second.getFieldName() <<
": \t";
1008 if(fields[i].second.isValueNumberDataType())
1009 OUT << fields[i].second.getValueAsString() << __E__;
1011 OUT <<
"\"" << fields[i].second.getValueAsString() <<
"\"" << __E__;
1024 <<
" link record" << __E__;
1033 const std::string& dumpType,
1034 const std::string& configurationAlias,
1035 const std::string& logEntry,
1036 const std::string& activeUsers,
1037 const std::string& activeStateMachine,
1038 std::ostream& altOut )
1040 time_t rawtime = time(0);
1041 __GEN_COUT__ <<
"filePath = " << filePath << __E__;
1042 __GEN_COUT__ <<
"dumpType = " << dumpType << __E__;
1046 fs.open(filePath, std::fstream::out | std::fstream::trunc);
1057 __SS__ <<
"Invalid file path to dump active configuration. File " << filePath
1058 <<
" could not be opened!" << __E__;
1059 __GEN_COUT_ERR__ << ss.str();
1065 if(dumpType ==
"JSON all")
1068 (*out) <<
"\t\"ARTDAQ_DATABASE_URI\": \"" << __ENV__(
"ARTDAQ_DATABASE_URI")
1072 (*out) <<
"\t\"HOSTNAME\": \"" << __ENV__(
"HOSTNAME") <<
"\"," << __E__;
1073 (*out) <<
"\t\"HOSTNAME filepath\": \"" << filePath <<
"\"," << __E__;
1074 (*out) <<
"\t\"Active State Machine\": \"" << activeStateMachine <<
"\","
1077 (*out) <<
"\t\"active_users\": \t[";
1078 if(activeUsers.size())
1080 std::istringstream iss(activeUsers);
1083 while(std::getline(iss, user,
','))
1087 (*out) <<
"\n\t\t\"" << user <<
"\"";
1091 (*out) <<
"\n\t]," << __E__;
1092 (*out) <<
"\t\"dump_type\": \t\t\"" << dumpType <<
"\"," << __E__;
1093 (*out) <<
"\t\"dump_time\": \t\t\"" << rawtime <<
"\"," << __E__;
1094 (*out) <<
"\t\"dump_formatted_time\": \t\t\""
1099 (*out) <<
"#################################" << __E__;
1100 (*out) <<
"This is an ots configuration dump.\n" << __E__;
1101 (*out) <<
"Source database is $ARTDAQ_DATABASE_URI: "
1102 << __ENV__(
"ARTDAQ_DATABASE_URI") << __E__;
1104 (*out) <<
"Original location of dump: " << __ENV__(
"HOSTNAME")
1105 <<
":" << filePath << __E__;
1106 (*out) <<
"\nActive ots users: \t"
1107 << (activeUsers.size() ? activeUsers :
"no active users") << __E__;
1108 (*out) <<
"Type of dump: \t\t" << dumpType << __E__;
1109 (*out) <<
"Time of dump: \t\t" << rawtime;
1114 std::pair<std::string, ots::TableGroupKey> configurationTableGroup =
1117 if(dumpType !=
"JSON all")
1119 (*out) <<
"Configuration Alias: \t\t\t" << configurationAlias <<
"\n";
1120 (*out) <<
"Configuration Alias translation: \t" << configurationTableGroup.first
1121 <<
"(" << configurationTableGroup.second <<
")\n\n";
1124 (*out) <<
"User Log Entry (" << logEntry.size() <<
" chars):\n"
1125 << logEntry << __E__;
1137 bool jsonify =
false,
1138 std::string configurationAlias =
"") {
1139 std::map<std::string, std::pair<std::string, TableGroupKey>> activeGroups =
1144 (*out) <<
"\n\t\"groups\": {\n";
1148 (*out) <<
"\n\n************************" << __E__;
1149 (*out) <<
"Active Groups: " << __E__;
1152 std::map<std::string, std::pair<std::string, TableGroupKey>>::iterator it;
1154 for(it = activeGroups.begin(); it != activeGroups.end(); ++it)
1158 (*out) <<
"\t\t\"" << it->first <<
"_group_name\": \"" << it->second.first
1160 (*out) <<
"\t\t\"" << it->first <<
"_group_key\": \"" << it->second.second
1162 if(it->first ==
"Configuration")
1166 <<
"Configuration_alias\": \"" << configurationAlias <<
"\"";
1168 (*out) << (std::next(it) == activeGroups.end() ?
"" :
",") <<
"\n";
1172 (*out) <<
"\t" << it->first <<
" := " << it->second.first <<
" ("
1173 << it->second.second <<
")" << __E__;
1184 bool jsonify =
false) {
1189 (*out) <<
"\t\"tables\": { " << __E__;
1193 (*out) <<
"\n\n************************" << __E__;
1194 (*out) <<
"Active Tables:" << __E__;
1195 (*out) <<
"Active Tables count = " << activeTables.size() << __E__;
1199 std::map<std::string, TableVersion>::iterator it;
1200 for(it = activeTables.begin(); it != activeTables.end(); ++it)
1205 <<
"active_table_name"
1206 <<
"\": \"" << it->first <<
"\",\n";
1208 <<
"active_table_version"
1209 <<
"\": \"" << it->second <<
"\"";
1210 (*out) << (std::next(it) == activeTables.end() ?
"" :
",") <<
"\n";
1214 (*out) <<
"\t" << ++i <<
". " << it->first <<
"-v" << it->second << __E__;
1225 bool jsonify =
false) {
1226 std::map<std::string, std::pair<std::string, TableGroupKey>> activeGroups =
1231 (*out) <<
"\t\"group_members\": { " << __E__;
1235 (*out) <<
"\n\n************************" << __E__;
1236 (*out) <<
"Active Group Members:" << __E__;
1240 std::map<std::string, std::pair<std::string, TableGroupKey>>::iterator it;
1241 for(it = activeGroups.begin(); it != activeGroups.end(); ++it)
1245 (*out) <<
"\t" << it->first <<
" := " << it->second.first <<
" ("
1246 << it->second.second <<
")" << __E__;
1249 if(it->second.first ==
"")
1254 <<
"Empty group name. Assuming no active group." << __E__;
1261 (*out) <<
"\t\t\"" << it->first <<
"\" : {" << __E__;
1262 (*out) <<
"\t\t\t\"Name\": \t\"" << it->second.first <<
"\""
1263 << (std::next(it) == activeGroups.end() ?
"" :
",") << __E__;
1267 std::map<std::string , std::string > groupAliases;
1268 std::string groupComment;
1269 std::string groupAuthor;
1270 std::string groupCreateTime;
1271 time_t groupCreateTime_t;
1288 (*out) <<
"\t\t\t\"key\": \t\"" << it->second.second <<
"\"," << __E__;
1289 (*out) <<
"\t\t\t\"comment\": \t\"" << groupComment <<
"\"," << __E__;
1290 (*out) <<
"\t\t\t\"author\": \t\"" << groupAuthor <<
"\"," << __E__;
1292 sscanf(groupCreateTime.c_str(),
"%ld", &groupCreateTime_t);
1293 std::string timeCreated = ctime(&groupCreateTime_t);
1294 (*out) <<
"\t\t\t\"create_time\": \t\""
1295 << timeCreated.erase(timeCreated.find(
'\n', 0), 1) <<
"\","
1297 (*out) <<
"\t\t\t\"group_aliases\": \t\""
1300 (*out) <<
"\t\t\t\"table_count\": \t\"" << memberMap.size() <<
"\","
1302 tableCount += memberMap.size();
1304 (*out) <<
"\t\t\t\"tables\": {" << __E__;
1308 for(iterMap = memberMap.begin(); iterMap != memberMap.end(); ++iterMap)
1310 (*out) <<
"\t\t\t\t\"" << iterMap->first <<
"\": \""
1311 << iterMap->second <<
"\""
1312 << (std::next(iterMap) == memberMap.end() ?
"" :
",") << __E__;
1314 (*out) <<
"\t\t\t}" << __E__;
1315 (*out) <<
"\t\t}," << __E__;
1319 (*out) <<
"\t\tGroup Comment: \t" << groupComment << __E__;
1320 (*out) <<
"\t\tGroup Author: \t" << groupAuthor << __E__;
1322 sscanf(groupCreateTime.c_str(),
"%ld", &groupCreateTime_t);
1323 (*out) <<
"\t\tGroup Create Time: \t" << ctime(&groupCreateTime_t)
1325 (*out) <<
"\t\tGroup Aliases: \t"
1328 (*out) <<
"\t\tMember table count = " << memberMap.size() << __E__;
1329 tableCount += memberMap.size();
1332 for(
auto& member : memberMap)
1334 (*out) <<
"\t\t\t" << ++i <<
". " << member.first <<
"-v"
1335 << member.second << __E__;
1342 (*out) <<
"\t\"total_table_count\": \"" << tableCount <<
"\"" << __E__;
1347 (*out) <<
"\nActive Group Members total table count = " << tableCount
1355 bool jsonify =
false) {
1360 (*out) <<
"\t\"tables\": {" << __E__;
1364 (*out) <<
"\n\n************************" << __E__;
1365 (*out) <<
"Active Table Contents (table count = " << activeTables.size()
1370 std::map<std::string, TableVersion>::iterator it;
1371 for(it = activeTables.begin(); it != activeTables.end(); ++it)
1375 __COUT__ <<
"localDumpActiveTableContents table: " << it->first << __E__;
1376 auto table = cfgMgr->nameToTableMap_.find(it->first)->second->getViewP();
1377 (*out) <<
"\t\t\"" << it->first <<
"-v" << it->second <<
"\": ";
1378 table->printJSON(*out);
1379 (*out) << (std::next(it) == activeTables.end() ?
"" :
",") << __E__;
1383 (*out) <<
"\n\n=========================================================="
1387 (*out) <<
"=============================================================="
1391 (*out) <<
"\t" << ++i <<
". " << it->first <<
"-v" << it->second << __E__;
1393 cfgMgr->nameToTableMap_.find(it->first)->second->print(*out);
1399 (*out) <<
"\t}" << __E__;
1405 std::ostream* out) {
1408 __COUT__ <<
"Active Table size: " << activeTables.size() << __E__;
1409 (*out) <<
"\t\"Active Table Structure\": [" << __E__;
1412 std::string activeTableStructure =
"";
1413 std::map<std::string, TableVersion>::iterator it;
1414 size_t tableStructureFoundCount = 0;
1415 for(it = activeTables.begin(); it != activeTables.end(); ++it)
1419 __COUTT__ <<
"Trying to retrieve " << it->first <<
"-v" << it->second
1420 <<
" Structure" << __E__;
1421 activeTableStructure =
1422 cfgMgr->nameToTableMap_.find(it->first)->second->getStructureAsJSON(
1424 if(activeTableStructure !=
"")
1426 __COUT__ <<
"Found Structure for Active Table: " << it->first <<
"-v"
1427 << it->second << __E__;
1429 (*out) << (tableStructureFoundCount++ ?
"," :
"") << __E__;
1431 (*out) <<
"\t{ \"table_name\": \"" << it->first <<
"\", "
1432 <<
"\"table_version\": \"" << it->second
1433 <<
"\", \n\t\"table_structure\": " << __E__;
1434 (*out) << activeTableStructure << __E__;
1438 catch(
const std::exception& e)
1440 __COUT__ <<
"Error caught in localDumpActiveTableStructureStatus(): "
1442 __COUT__ <<
"Structure Status may not be implemented." << __E__;
1446 __COUT__ <<
"Found " << tableStructureFoundCount <<
" Active Table Structures."
1449 (*out) <<
"\t]" << __E__;
1452 if(dumpType ==
"GroupKeys")
1454 localDumpActiveGroups(
this, out);
1456 else if(dumpType ==
"TableVersions")
1458 localDumpActiveTables(
this, out);
1460 else if(dumpType ==
"GroupKeysAndTableVersions")
1462 localDumpActiveGroups(
this, out);
1463 localDumpActiveTables(
this, out);
1465 else if(dumpType ==
"All")
1467 localDumpActiveGroups(
this, out);
1468 localDumpActiveGroupMembers(
this, out);
1469 localDumpActiveTables(
this, out);
1470 localDumpActiveTableContents(
this, out);
1472 else if(dumpType ==
"JSON all")
1474 localDumpActiveGroups(
this, out,
true, configurationAlias);
1476 localDumpActiveGroupMembers(
this, out,
true);
1480 localDumpActiveTableContents(
this, out,
true);
1481 (*out) <<
",\n" << __E__;
1482 localDumpActiveTableStructureStatus(
this, out);
1488 <<
"Invalid dump type '" << dumpType
1489 <<
"' given during dumpActiveConfiguration(). Valid types are as follows:\n"
1497 <<
"GroupsKeysAndTableVersions"
1502 "\n\nPlease change the State Machine configuration to a valid dump type."
1519 const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap,
1520 std::string* accumulatedWarnings )
1522 __GEN_COUTTV__(runTimeSeconds());
1527 bool usingCache =
false;
1528 if(memberMap.size() > 10 && nameToTableMap_.size() &&
1529 nameToTableMap_.find(memberMap.begin()->first) != nameToTableMap_.end() &&
1530 nameToTableMap_.at(memberMap.begin()->first)->isStored(memberMap.begin()->second))
1535 __GEN_COUTT__ <<
"Using cache!" << __E__;
1539 const int numOfThreads =
1541 if(memberMap.size() <= 2 || usingCache ||
1546 for(
auto& memberPair : memberMap)
1558 tmpTableBasePtr =
nullptr;
1559 if(nameToTableMap_.find(memberPair.first) != nameToTableMap_.end())
1560 tmpTableBasePtr = nameToTableMap_.at(memberPair.first);
1562 std::string getError =
"";
1565 theInterface_->get(tmpTableBasePtr,
1574 catch(
const std::runtime_error& e)
1576 __SS__ <<
"Failed to load member table '" << memberPair.first <<
"-v"
1577 << memberPair.second <<
"' - here is the error: \n\n"
1578 << e.what() << __E__;
1580 ss <<
"\nIf the table '" << memberPair.first
1581 <<
"' should not exist, then please remove it from the group. If it "
1582 "should exist, then it "
1583 <<
"seems to have a problem; use the Table Editor to fix the table "
1585 "edit the table content to match the table definition."
1589 if(accumulatedWarnings)
1590 getError = ss.str();
1596 __SS__ <<
"Failed to load member table '" << memberPair.first <<
" -v"
1597 << memberPair.second <<
"' due to unknown error!" << __E__;
1602 catch(
const std::exception& e)
1604 ss <<
"Exception message: " << e.what();
1610 ss <<
"\nIf the table '" << memberPair.first
1611 <<
"' should not exist, then please remove it from the group. If it "
1612 "should exist, then it "
1613 <<
"seems to have a problem; use the Table Editor to fix the table "
1615 "edit the table content to match the table definition."
1619 if(accumulatedWarnings)
1620 getError = ss.str();
1626 if(!tmpTableBasePtr)
1628 __SS__ <<
"Null pointer returned for table '" << memberPair.first <<
" -v"
1629 << memberPair.second <<
".' Was the table info deleted?" << __E__;
1630 __GEN_COUT_ERR__ << ss.str();
1632 nameToTableMap_.erase(memberPair.first);
1633 if(accumulatedWarnings)
1635 *accumulatedWarnings += ss.str();
1642 nameToTableMap_[memberPair.first] = tmpTableBasePtr;
1643 if(nameToTableMap_[memberPair.first]->getViewP())
1648 if(accumulatedWarnings && getError !=
"")
1650 __SS__ <<
"Error caught during '" << memberPair.first <<
" -v"
1651 << memberPair.second <<
"' table retrieval: \n"
1652 << getError << __E__;
1653 __GEN_COUT_ERR__ << ss.str();
1654 *accumulatedWarnings += ss.str();
1659 __SS__ << nameToTableMap_[memberPair.first]->getTableName() <<
" -v"
1660 << memberPair.second <<
": View version not activated properly!";
1667 __GEN_COUTT__ <<
" PROCESSOR_COUNT " <<
PROCESSOR_COUNT <<
" ==> " << numOfThreads
1668 <<
" threads for loading member map of size " << memberMap.size()
1671 int threadsLaunched = 0;
1672 int foundThreadIndex = 0;
1673 std::string threadErrors;
1674 std::mutex threadMutex;
1675 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
1676 for(
int i = 0; i < numOfThreads; ++i)
1677 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
1678 std::vector<TableBase*> tmpTableBasePtrs;
1679 for(
int i = 0; i < numOfThreads; ++i)
1680 tmpTableBasePtrs.push_back(
nullptr);
1682 for(
auto& memberPair : memberMap)
1684 if(threadsLaunched >= numOfThreads)
1687 foundThreadIndex = -1;
1688 while(foundThreadIndex == -1)
1690 for(
int i = 0; i < numOfThreads; ++i)
1691 if(*(threadDone[i]))
1693 foundThreadIndex = i;
1696 if(foundThreadIndex == -1)
1698 __GEN_COUTT__ <<
"Waiting for available thread..." << __E__;
1702 threadsLaunched = numOfThreads - 1;
1704 __GEN_COUTT__ <<
"Starting filling thread... " << foundThreadIndex <<
" for "
1705 << memberPair.first <<
" -v" << memberPair.second << __E__;
1706 *(threadDone[foundThreadIndex]) =
false;
1714 tmpTableBasePtrs[foundThreadIndex] =
nullptr;
1715 if(nameToTableMap_.find(memberPair.first) != nameToTableMap_.end())
1716 tmpTableBasePtrs[foundThreadIndex] = nameToTableMap_.at(memberPair.first);
1720 std::map<std::string, ots::TableBase*>* theNameToTableMap,
1722 std::string theTableName,
1724 std::string* theThreadErrors,
1725 std::mutex* theThreadMutex,
1726 std::shared_ptr<std::atomic<bool>> theThreadDone) {
1727 ConfigurationManager::fillTableThread(theInterface,
1738 tmpTableBasePtrs[foundThreadIndex],
1743 threadDone[foundThreadIndex])
1753 foundThreadIndex = -1;
1754 for(
int i = 0; i < numOfThreads; ++i)
1755 if(!*(threadDone[i]))
1757 foundThreadIndex = i;
1760 if(foundThreadIndex != -1)
1762 __GEN_COUT_TYPE__(TLVL_DEBUG + 2)
1763 << __COUT_HDR__ <<
"Waiting for thread to finish... "
1764 << foundThreadIndex << __E__;
1767 }
while(foundThreadIndex != -1);
1768 __GEN_COUTT__ <<
"All threads done." << __E__;
1770 if(threadErrors !=
"")
1772 __SS__ <<
"Error identified in threads during loading of member map: \n"
1773 << threadErrors << __E__;
1774 __GEN_COUTT__ <<
"\n" << ss.str() << __E__;
1775 if(accumulatedWarnings)
1776 *accumulatedWarnings += ss.str();
1782 __GEN_COUTT__ <<
"loadMemberMap end runTimeSeconds()=" << runTimeSeconds() << __E__;
1808 const std::string& groupName,
1811 std::map<std::string /*table name*/, TableVersion>*
1814 std::string* accumulatedWarnings ,
1815 std::string* groupComment ,
1816 std::string* groupAuthor ,
1817 std::string* groupCreateTime ,
1818 bool doNotLoadMembers ,
1819 std::string* groupTypeString ,
1820 std::map<std::string /*name*/, std::string /*alias*/>*
1822 ConfigurationManager::LoadGroupType
1824 bool ignoreVersionTracking )
1828 *groupComment = ConfigurationManager::UNKNOWN_INFO;
1830 *groupAuthor = ConfigurationManager::UNKNOWN_INFO;
1832 *groupCreateTime = ConfigurationManager::UNKNOWN_TIME;
1834 *groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
1836 __GEN_COUTT__ <<
"No group type requested." << __E__;
1863 __GEN_COUTT__ <<
"Loading Table Group: " << groupName <<
"(" << groupKey <<
")"
1864 <<
" accumulatedWarnings=" << (accumulatedWarnings ? 1 : 0) << __E__;
1876 progressBar->
step();
1879 auto metaTablePair = memberMap.find(TableBase::GROUP_METADATA_TABLE_NAME);
1880 if(metaTablePair != memberMap.end())
1883 if(groupAliases || groupComment || groupAuthor || groupCreateTime)
1885 std::lock_guard<std::mutex> lock(metaDataTableMutex_);
1888 while(groupMetadataTable_.getView().getNumberOfRows())
1889 groupMetadataTable_.getViewP()->
deleteRow(0);
1894 theInterface_->fill(&groupMetadataTable_, metaTablePair->second);
1896 catch(
const std::runtime_error& e)
1899 <<
"Failed to load " << groupMetadataTable_.
getTableName() <<
"-v"
1900 << metaTablePair->second <<
". Metadata error: " << e.what()
1906 <<
"Failed to load " << groupMetadataTable_.
getTableName() <<
"-v"
1907 << metaTablePair->second <<
". Ignoring unknown metadata error. "
1912 if(groupMetadataTable_.getView().getNumberOfRows() != 1)
1914 groupMetadataTable_.
print();
1915 __GEN_COUT_ERR__ <<
"Ignoring that groupMetadataTable_ has wrong "
1916 "number of rows for '"
1917 << groupName <<
"(" << groupKey
1919 "be 1. Going with anonymous defaults."
1923 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
1924 groupMetadataTable_.getViewP()->
deleteRow(0);
1925 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
1926 groupMetadataTable_.getViewP()->
addRow();
1935 0, ConfigurationManager::METADATA_COL_ALIASES),
1939 0, ConfigurationManager::METADATA_COL_COMMENT);
1942 0, ConfigurationManager::METADATA_COL_AUTHOR);
1945 0, ConfigurationManager::METADATA_COL_TIMESTAMP);
1949 memberMap.erase(metaTablePair);
1954 __GEN_COUT__ <<
"Ignoring that groupMetadataTable_ is missing for group '"
1955 << groupName <<
"(" << groupKey
1956 <<
"). Going with anonymous defaults." << __E__;
1967 std::map<std::string, std::string>& aliasMap = *groupAliases;
1968 std::map<std::string , std::map<std::string ,
TableVersion>>
1978 for(
auto& aliasPair : aliasMap)
1981 if(memberMap.find(aliasPair.first) != memberMap.end())
1983 __GEN_COUT__ <<
"Group member '" << aliasPair.first
1984 <<
"' was found in group member map!" << __E__;
1985 __GEN_COUT__ <<
"Looking for alias '" << aliasPair.second
1986 <<
"' in active version aliases..." << __E__;
1988 if(versionAliases.find(aliasPair.first) == versionAliases.end() ||
1989 versionAliases[aliasPair.first].find(aliasPair.second) ==
1990 versionAliases[aliasPair.first].end())
1992 __SS__ <<
"Group '" << groupName <<
"(" << groupKey
1993 <<
")' requires table version alias '" << aliasPair.first
1994 <<
":" << aliasPair.second
1995 <<
",' which was not found in the active Backbone!"
2000 memberMap[aliasPair.first] =
2001 versionAliases[aliasPair.first][aliasPair.second];
2002 __GEN_COUT__ <<
"Version alias translated to " << aliasPair.first
2009 *groupMembers = memberMap;
2012 progressBar->
step();
2014 ConfigurationManager::GroupType groupType =
2015 ConfigurationManager::GroupType::CONFIGURATION_TYPE;
2024 __GEN_COUTT__ <<
"No group type requested." << __E__;
2026 if(doNotLoadMembers)
2030 if(!groupTypeString)
2033 if(groupTypeToLoad ==
2034 ConfigurationManager::LoadGroupType::ONLY_BACKBONE_OR_CONTEXT_TYPES &&
2035 groupType != ConfigurationManager::GroupType::CONTEXT_TYPE &&
2036 groupType != ConfigurationManager::GroupType::BACKBONE_TYPE)
2038 __GEN_COUT__ <<
"Not loading group because it is not of type Context or "
2039 "Backbone (it is type '"
2043 else if(groupTypeToLoad ==
2044 ConfigurationManager::LoadGroupType::ONLY_BACKBONE_TYPE &&
2045 groupType != ConfigurationManager::GroupType::BACKBONE_TYPE)
2047 __GEN_COUT__ <<
"Not loading group because it is not of type "
2048 "Backbone (it is type '"
2056 <<
"------------------------------------- init start \t [for all "
2064 std::string groupToDeactivate =
2065 groupType == ConfigurationManager::GroupType::CONTEXT_TYPE
2066 ? theContextTableGroup_
2067 : (groupType == ConfigurationManager::GroupType::BACKBONE_TYPE
2068 ? theBackboneTableGroup_
2070 ConfigurationManager::GroupType::ITERATE_TYPE
2071 ? theIterateTableGroup_
2072 : theConfigurationTableGroup_));
2075 if(groupToDeactivate !=
"")
2077 __GEN_COUTT__ <<
"groupToDeactivate '" << groupToDeactivate
2086 __GEN_COUTT__ <<
"no group to deactivate of type "
2093 progressBar->
step();
2098 progressBar->
step();
2100 __GEN_COUTT__ <<
"loadMemberMap() completed." << __E__;
2102 if(accumulatedWarnings)
2104 __GEN_COUTT__ <<
"Checking chosen group for tree errors... here are the "
2105 "current warnings: "
2106 << *accumulatedWarnings << __E__;
2109 if(*accumulatedWarnings !=
"")
2112 <<
"Errors detected while loading Table Group: " << groupName
2113 <<
"(" << groupKey <<
"). Ignoring the following errors: "
2115 << *accumulatedWarnings << __E__;
2117 __GEN_COUTT__ <<
"After checking children warnings: "
2118 << *accumulatedWarnings << __E__;
2122 progressBar->
step();
2124 __GEN_COUTT__ <<
"Tree view check complete." << __E__;
2135 <<
" threads for initializing tables for Table Group '"
2136 << groupName <<
"(" << groupKey <<
")'." << __E__;
2137 if(groupType != ConfigurationManager::GroupType::CONFIGURATION_TYPE ||
2140 for(
auto& memberPair : memberMap)
2143 if(!ignoreVersionTracking &&
2144 ConfigurationInterface::isVersionTrackingEnabled() &&
2145 memberPair.second.isScratchVersion())
2148 <<
"Error while activating member Table '"
2149 << nameToTableMap_[memberPair.first]->getTableName()
2150 <<
"-v" << memberPair.second <<
" for Table Group '"
2151 << groupName <<
"(" << groupKey
2152 <<
")'. When version tracking is enabled, Scratch views"
2153 <<
" are not allowed! Please only use unique, persistent "
2154 "versions when version tracking is enabled."
2163 nameToTableMap_.at(memberPair.first)->init(
this);
2165 catch(std::runtime_error& e)
2167 __SS__ <<
"Error detected calling " << memberPair.first
2168 <<
".init()!\n\n " << e.what() << __E__;
2170 if(accumulatedWarnings)
2172 *accumulatedWarnings += ss.str();
2182 __SS__ <<
"Unknown Error detected calling "
2183 << memberPair.first <<
".init()!\n\n " << __E__;
2188 catch(
const std::exception& e)
2190 ss <<
"Exception message: " << e.what();
2197 if(accumulatedWarnings)
2199 *accumulatedWarnings += ss.str();
2202 __GEN_COUT_WARN__ << ss.str();
2208 int threadsLaunched = 0;
2209 int foundThreadIndex = 0;
2210 std::string threadErrors;
2211 std::mutex threadMutex;
2212 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
2213 for(
int i = 0; i < numOfThreads; ++i)
2214 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
2216 if(!ignoreVersionTracking &&
2217 ConfigurationInterface::isVersionTrackingEnabled())
2218 for(
auto& memberPair : memberMap)
2221 if(memberPair.second.isScratchVersion())
2224 <<
"Error while activating member Table '"
2225 << nameToTableMap_[memberPair.first]->getTableName()
2226 <<
"-v" << memberPair.second <<
" for Table Group '"
2227 << groupName <<
"(" << groupKey
2228 <<
")'. When version tracking is enabled, Scratch "
2230 <<
" are not allowed! Please only use unique, "
2232 "versions when version tracking is enabled."
2238 for(
auto& memberPair : memberMap)
2240 if(threadsLaunched >= numOfThreads)
2243 foundThreadIndex = -1;
2244 while(foundThreadIndex == -1)
2246 for(
int i = 0; i < numOfThreads; ++i)
2247 if(*(threadDone[i]))
2249 foundThreadIndex = i;
2252 if(foundThreadIndex == -1)
2254 __GEN_COUTT__ <<
"Waiting for available thread..."
2259 threadsLaunched = numOfThreads - 1;
2261 __GEN_COUTT__ <<
"Starting init table thread... "
2262 << foundThreadIndex <<
" for " << memberPair.first
2264 *(threadDone[foundThreadIndex]) =
false;
2269 std::string* theThreadErrors,
2270 std::mutex* theThreadMutex,
2271 std::shared_ptr<std::atomic<bool>> theThreadDone) {
2272 ConfigurationManager::initTableThread(cfgMgr,
2279 nameToTableMap_.at(memberPair.first),
2282 threadDone[foundThreadIndex])
2292 foundThreadIndex = -1;
2293 for(
int i = 0; i < numOfThreads; ++i)
2294 if(!*(threadDone[i]))
2296 foundThreadIndex = i;
2299 if(foundThreadIndex != -1)
2301 __GEN_COUTT__ <<
"Waiting for thread to finish... "
2302 << foundThreadIndex << __E__;
2305 }
while(foundThreadIndex != -1);
2306 __GEN_COUTT__ <<
"All threads done." << __E__;
2308 if(threadErrors !=
"")
2310 __SS__ <<
"Error identified in threads during init of table "
2312 << threadErrors << __E__;
2313 __GEN_COUTT__ <<
"\n" << ss.str() << __E__;
2314 if(accumulatedWarnings)
2315 *accumulatedWarnings += ss.str();
2325 progressBar->
step();
2334 if(groupType == ConfigurationManager::GroupType::CONTEXT_TYPE)
2340 theContextTableGroup_ = groupName;
2341 theContextTableGroupKey_ =
2342 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2344 else if(groupType == ConfigurationManager::GroupType::BACKBONE_TYPE)
2349 theBackboneTableGroup_ = groupName;
2350 theBackboneTableGroupKey_ =
2351 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2353 else if(groupType == ConfigurationManager::GroupType::ITERATE_TYPE)
2359 theIterateTableGroup_ = groupName;
2360 theIterateTableGroupKey_ =
2361 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2368 theConfigurationTableGroup_ = groupName;
2369 theConfigurationTableGroupKey_ =
2370 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2375 progressBar->
step();
2379 <<
"------------------------------------- init complete \t [for all "
2389 std::pair<std::string, TableGroupKey>(groupName,
TableGroupKey(groupKey));
2395 catch(
const std::runtime_error& e)
2397 __SS__ <<
"Error occurred while loading table group '" << groupName <<
"("
2398 << groupKey <<
")': \n"
2399 << e.what() << __E__;
2401 if(accumulatedWarnings)
2402 *accumulatedWarnings += ss.str();
2408 __SS__ <<
"An unknown error occurred while loading table group '"
2409 << groupName <<
"(" << groupKey <<
")." << __E__;
2414 catch(
const std::exception& e)
2416 ss <<
"Exception message: " << e.what();
2421 if(accumulatedWarnings)
2422 *accumulatedWarnings += ss.str();
2428 __GEN_COUTT__ <<
"loadTableGroup() complete for Table Group '" << groupName <<
"("
2429 << groupKey <<
")'." << __E__;
2431 std::make_pair(std::make_pair(groupName,
TableGroupKey(groupKey)), memberMap);
2436 __GEN_COUTT__ <<
"loadTableGroup() failed." << __E__;
2439 lastFailedGroupLoad_[ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN] =
2440 std::pair<std::string, TableGroupKey>(groupName,
TableGroupKey(groupKey));
2446 catch(
const std::runtime_error& e)
2448 __SS__ <<
"Error occurred while loading table group '" << groupName <<
"("
2449 << groupKey <<
")': \n"
2450 << e.what() << __E__;
2452 if(accumulatedWarnings)
2453 *accumulatedWarnings += ss.str();
2459 __SS__ <<
"An unknown error occurred while loading table group '" << groupName
2460 <<
"(" << groupKey <<
")." << __E__;
2465 catch(
const std::exception& e)
2467 ss <<
"Exception message: " << e.what();
2474 if(accumulatedWarnings)
2475 *accumulatedWarnings += ss.str();
2487 const std::map<std::string, TableVersion>& memberMap,
2488 const std::string& groupName ,
2491 bool ignoreVersionTracking )
2496 ConfigurationManager::GroupType groupType =
getTypeOfGroup(memberMap);
2500 __GEN_COUT__ <<
"------------------------------------- cacheCopy init start "
2502 "plug-ins in member map"
2507 std::string groupToDeactivate =
2508 groupType == ConfigurationManager::GroupType::CONTEXT_TYPE
2509 ? theContextTableGroup_
2510 : (groupType == ConfigurationManager::GroupType::BACKBONE_TYPE
2511 ? theBackboneTableGroup_
2512 : (groupType == ConfigurationManager::GroupType::ITERATE_TYPE
2513 ? theIterateTableGroup_
2514 : theConfigurationTableGroup_));
2517 if(groupToDeactivate !=
"")
2534 for(
auto& memberPair : memberMap)
2536 __GEN_COUTT__ <<
"Copying " << memberPair.first <<
"-v" << memberPair.second
2540 if(nameToTableMap_.find(memberPair.first) == nameToTableMap_.end())
2543 theInterface_->get(table,
2550 nameToTableMap_[memberPair.first] = table;
2552 nameToTableMap_.at(memberPair.first)
2554 ->getView(memberPair.second),
2557 ->getView(memberPair.second)
2565 __GEN_COUTT__ <<
"Done with member copy loop." << __E__;
2571 std::string accumulatedWarnings;
2574 << numOfThreads <<
" threads for initializing tables." << __E__;
2575 if(groupType != ConfigurationManager::GroupType::CONFIGURATION_TYPE ||
2578 for(
auto& memberPair : memberMap)
2581 if(!ignoreVersionTracking &&
2582 ConfigurationInterface::isVersionTrackingEnabled() &&
2583 memberPair.second.isScratchVersion())
2585 __SS__ <<
"Error while activating member Table '"
2586 << nameToTableMap_[memberPair.first]->getTableName()
2587 <<
"-v" << memberPair.second
2588 <<
" for member map. When version tracking is enabled, "
2590 <<
" are not allowed! Please only use unique, persistent "
2591 "versions when version tracking is enabled."
2600 nameToTableMap_.at(memberPair.first)->init(
this);
2602 catch(std::runtime_error& e)
2604 __SS__ <<
"Error detected calling " << memberPair.first
2605 <<
".init()!\n\n " << e.what() << __E__;
2606 accumulatedWarnings += ss.str();
2610 __SS__ <<
"Unknown Error detected calling " << memberPair.first
2611 <<
".init()!\n\n " << __E__;
2616 catch(
const std::exception& e)
2618 ss <<
"Exception message: " << e.what();
2623 accumulatedWarnings += ss.str();
2629 int threadsLaunched = 0;
2630 int foundThreadIndex = 0;
2631 std::mutex threadMutex;
2632 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
2633 for(
int i = 0; i < numOfThreads; ++i)
2634 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
2636 if(!ignoreVersionTracking &&
2637 ConfigurationInterface::isVersionTrackingEnabled())
2638 for(
auto& memberPair : memberMap)
2641 if(memberPair.second.isScratchVersion())
2644 <<
"Error while activating member Table '"
2645 << nameToTableMap_[memberPair.first]->getTableName()
2646 <<
"-v" << memberPair.second
2647 <<
" for member map. When version tracking is enabled, "
2649 <<
" are not allowed! Please only use unique, persistent "
2650 "versions when version tracking is enabled."
2656 for(
auto& memberPair : memberMap)
2658 if(threadsLaunched >= numOfThreads)
2661 foundThreadIndex = -1;
2662 while(foundThreadIndex == -1)
2664 for(
int i = 0; i < numOfThreads; ++i)
2665 if(*(threadDone[i]))
2667 foundThreadIndex = i;
2670 if(foundThreadIndex == -1)
2672 __GEN_COUTT__ <<
"Waiting for available thread..."
2677 threadsLaunched = numOfThreads - 1;
2679 __GEN_COUTT__ <<
"Starting init table thread... " << foundThreadIndex
2680 <<
" for " << memberPair.first << __E__;
2681 *(threadDone[foundThreadIndex]) =
false;
2686 std::string* theAccumulatedWarnings,
2687 std::mutex* theThreadMutex,
2688 std::shared_ptr<std::atomic<bool>> theThreadDone) {
2689 ConfigurationManager::initTableThread(cfgMgr,
2691 theAccumulatedWarnings,
2696 nameToTableMap_.at(memberPair.first),
2697 &accumulatedWarnings,
2699 threadDone[foundThreadIndex])
2709 foundThreadIndex = -1;
2710 for(
int i = 0; i < numOfThreads; ++i)
2711 if(!*(threadDone[i]))
2713 foundThreadIndex = i;
2716 if(foundThreadIndex != -1)
2718 __GEN_COUTT__ <<
"Waiting for thread to finish... "
2719 << foundThreadIndex << __E__;
2722 }
while(foundThreadIndex != -1);
2726 if(accumulatedWarnings !=
"")
2728 __GEN_COUT__ <<
"Activating the member map after copying cache had the "
2729 "following warnings: "
2730 << accumulatedWarnings << __E__;
2741 if(groupType == ConfigurationManager::GroupType::CONTEXT_TYPE)
2747 theContextTableGroup_ = groupName;
2748 theContextTableGroupKey_ =
2749 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2751 else if(groupType == ConfigurationManager::GroupType::BACKBONE_TYPE)
2756 theBackboneTableGroup_ = groupName;
2757 theBackboneTableGroupKey_ =
2758 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2760 else if(groupType == ConfigurationManager::GroupType::ITERATE_TYPE)
2766 theIterateTableGroup_ = groupName;
2767 theIterateTableGroupKey_ =
2768 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2775 theConfigurationTableGroup_ = groupName;
2776 theConfigurationTableGroupKey_ =
2777 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2782 __GEN_COUT__ <<
"------------------------------------- cacheCopy init "
2783 "complete \t [for all "
2784 "plug-ins in member map"
2787 __GEN_COUTT__ <<
"Completed cache copy." << __E__;
2790 make_pair(make_pair(groupName,
TableGroupKey(groupKey)), memberMap);
2794 __GEN_COUT__ <<
"Unknown failure in cache copy." << __E__;
2797 std::pair<std::string, TableGroupKey>(groupName,
TableGroupKey(groupKey));
2804 ConfigurationManager::getGroupOfLoadedTable(
const std::string& tableName)
const
2806 for(
const auto& loadedGroup : lastGroupLoad_)
2807 if(loadedGroup.second.second.find(tableName) != loadedGroup.second.second.end())
2808 return loadedGroup.second.first;
2809 return std::make_pair(
"",
TableGroupKey(TableGroupKey::INVALID));
2816 std::string* threadErrors,
2817 std::mutex* threadMutex,
2818 std::shared_ptr<std::atomic<bool>> threadDone)
2821 __COUTT__ <<
"Thread init of " << table->
getTableName() <<
"-v"
2822 << table->
getViewVersion() <<
" threadErrors=" << (threadErrors ? 1 : 0)
2830 table->init(cfgMgr);
2832 catch(std::runtime_error& e)
2834 __SS__ <<
"Error detected calling " << table->
getTableName() <<
".init()!\n\n "
2835 << e.what() << __E__;
2839 std::lock_guard<std::mutex> lock(*threadMutex);
2840 *threadErrors += ss.str();
2850 __SS__ <<
"Unknown Error detected calling " << table->
getTableName()
2851 <<
".init()!\n\n " << __E__;
2856 catch(
const std::exception& e)
2858 ss <<
"Exception message: " << e.what();
2866 std::lock_guard<std::mutex> lock(*threadMutex);
2867 *threadErrors += ss.str();
2876 *(threadDone) =
true;
2880 __SS__ <<
"Error occurred initializing table '" << table->
getTableName() <<
"-v"
2886 catch(
const std::runtime_error& e)
2888 ss <<
" Run-time Exception message: " << e.what();
2890 catch(
const std::exception& e)
2892 ss <<
" Exception message: " << e.what();
2894 __COUT_WARN__ << ss.str() << __E__;
2898 std::lock_guard<std::mutex> lock(*threadMutex);
2899 *threadErrors += ss.str();
2902 *(threadDone) =
true;
2907 void ConfigurationManager::fillTableThread(
2909 std::map<std::string, ots::TableBase*>* nameToTableMap,
2911 std::string tableName,
2913 std::string* threadErrors,
2914 std::mutex* threadMutex,
2915 std::shared_ptr<std::atomic<bool>> threadDone)
2918 __COUTT__ <<
"Thread fill of " << tableName <<
"-v" << version << __E__;
2928 std::string getError =
"";
2933 theInterface->get(table,
2942 catch(
const std::runtime_error& e)
2944 __SS__ <<
"Failed to load member table '" << tableName <<
"-v" << version
2945 <<
"' - here is the error: \n\n"
2946 << e.what() << __E__;
2948 ss <<
"\nIf the table '" << tableName
2949 <<
"' should not exist, then please remove it from the group. If it "
2950 "should exist, then it "
2951 <<
"seems to have a problem; use the Table Editor to fix the table "
2953 "edit the table content to match the table definition."
2958 getError = ss.str();
2964 __SS__ <<
"Failed to load member table '" << tableName <<
"-v" << version
2965 <<
"' due to unknown error!" << __E__;
2970 catch(
const std::exception& e)
2972 ss <<
"Exception message: " << e.what();
2977 ss <<
"\nIf the table '" << tableName
2978 <<
"' should not exist, then please remove it from the group. If it "
2979 "should exist, then it "
2980 <<
"seems to have a problem; use the Table Editor to fix the table "
2982 "edit the table content to match the table definition."
2987 getError = ss.str();
2993 __COUTV__(getError);
2995 __COUT_TYPE__(TLVL_TRACE + 1)
2996 << __COUT_HDR__ <<
"Checking ptr.. " << (table ?
"GOOD" :
"BAD") << __E__;
2999 __SS__ <<
"Null pointer returned for table '" << tableName
3000 <<
".' Was the table info deleted?" << __E__;
3001 __COUT_ERR__ << ss.str();
3003 std::lock_guard<std::mutex> lock(*threadMutex);
3004 nameToTableMap->erase(tableName);
3008 *threadErrors += ss.str();
3009 *(threadDone) =
true;
3017 std::lock_guard<std::mutex> lock(*threadMutex);
3018 (*nameToTableMap)[tableName] = table;
3021 if(nameToTableMap->at(tableName)->getViewP())
3023 __COUT_TYPE__(TLVL_TRACE + 1)
3025 <<
"Activated version: " << nameToTableMap->at(tableName)->getViewVersion()
3028 if(threadErrors && getError !=
"")
3030 __SS__ <<
"Error caught during '" << tableName <<
"' table retrieval: \n"
3031 << getError << __E__;
3032 __COUT_ERR__ << ss.str();
3033 std::lock_guard<std::mutex> lock(*threadMutex);
3034 *threadErrors += ss.str();
3039 __SS__ << tableName <<
": View version not activated properly!";
3043 __COUTT__ <<
"end Thread fill of " << tableName <<
"-v" << version << __E__;
3044 *(threadDone) =
true;
3046 catch(
const std::runtime_error& e)
3048 __SS__ <<
"Error occurred filling table '" << tableName <<
"-v" << version
3049 <<
"': " << e.what() << __E__;
3050 __COUT_ERR__ << ss.str();
3054 std::lock_guard<std::mutex> lock(*threadMutex);
3055 *threadErrors += ss.str();
3058 *(threadDone) =
true;
3062 __SS__ <<
"Unknwon error occurred filling table '" << tableName <<
"-v" << version
3068 catch(
const std::exception& e)
3070 ss <<
"Exception message: " << e.what();
3075 __COUT_ERR__ << ss.str();
3079 std::lock_guard<std::mutex> lock(*threadMutex);
3080 *threadErrors += ss.str();
3083 *(threadDone) =
true;
3092 std::map<std::string, std::pair<std::string, TableGroupKey>>
3096 std::map<std::string, std::pair<std::string, TableGroupKey>> retMap;
3098 retMap[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT] =
3099 std::pair<std::string, TableGroupKey>(
3100 theContextTableGroup_,
3101 theContextTableGroupKey_ ? *theContextTableGroupKey_ :
TableGroupKey());
3102 retMap[ConfigurationManager::GROUP_TYPE_NAME_BACKBONE] =
3103 std::pair<std::string, TableGroupKey>(
3104 theBackboneTableGroup_,
3105 theBackboneTableGroupKey_ ? *theBackboneTableGroupKey_ :
TableGroupKey());
3106 retMap[ConfigurationManager::GROUP_TYPE_NAME_ITERATE] =
3107 std::pair<std::string, TableGroupKey>(
3108 theIterateTableGroup_,
3109 theIterateTableGroupKey_ ? *theIterateTableGroupKey_ :
TableGroupKey());
3110 retMap[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION] =
3111 std::pair<std::string, TableGroupKey>(theConfigurationTableGroup_,
3112 theConfigurationTableGroupKey_
3113 ? *theConfigurationTableGroupKey_
3119 const std::string& ConfigurationManager::getActiveGroupName(
3120 const ConfigurationManager::GroupType& type)
const
3122 if(type == ConfigurationManager::GroupType::CONFIGURATION_TYPE)
3123 return theConfigurationTableGroup_;
3124 else if(type == ConfigurationManager::GroupType::CONTEXT_TYPE)
3125 return theContextTableGroup_;
3126 else if(type == ConfigurationManager::GroupType::BACKBONE_TYPE)
3127 return theBackboneTableGroup_;
3128 else if(type == ConfigurationManager::GroupType::ITERATE_TYPE)
3129 return theIterateTableGroup_;
3131 __SS__ <<
"IMPOSSIBLE! Invalid type requested '" << (int)type <<
"'" << __E__;
3137 const ConfigurationManager::GroupType& type)
const
3139 if(type == ConfigurationManager::GroupType::CONFIGURATION_TYPE)
3140 return theConfigurationTableGroupKey_ ? *theConfigurationTableGroupKey_
3142 else if(type == ConfigurationManager::GroupType::CONTEXT_TYPE)
3143 return theContextTableGroupKey_ ? *theContextTableGroupKey_ :
TableGroupKey();
3144 else if(type == ConfigurationManager::GroupType::BACKBONE_TYPE)
3145 return theBackboneTableGroupKey_ ? *theBackboneTableGroupKey_ :
TableGroupKey();
3146 else if(type == ConfigurationManager::GroupType::ITERATE_TYPE)
3147 return theIterateTableGroupKey_ ? *theIterateTableGroupKey_ :
TableGroupKey();
3149 __SS__ <<
"IMPOSSIBLE! Invalid type requested '" << (int)type <<
"'" << __E__;
3155 const std::string& contextUID,
const std::string& )
const
3163 const std::string& contextUID,
const std::string& applicationUID)
const
3166 contextUID +
"/LinkToApplicationTable/" + applicationUID);
3171 const std::string& contextUID,
const std::string& applicationUID)
const
3174 contextUID +
"/LinkToApplicationTable/" + applicationUID +
3175 "/LinkToSupervisorTable");
3182 auto contextChildren =
3185 for(
const auto& contextChild : contextChildren)
3187 auto appChildren = contextChild.second.getNode(
"LinkToApplicationTable")
3189 for(
const auto& appChild : appChildren)
3191 if(appChild.second.getNode(
"Class").getValue() ==
3192 "ots::GatewaySupervisor")
3193 return appChild.second;
3196 __SS__ <<
"No Gateway Supervisor node found!" << __E__;
3202 bool doNotThrowOnBrokenUIDLinks)
const
3207 if(nodeString.length() < 1)
3209 __SS__ << (
"Invalid empty node name") << __E__;
3214 size_t startingIndex = 0;
3215 while(startingIndex < nodeString.length() && nodeString[startingIndex] ==
'/')
3217 size_t endingIndex = nodeString.find(
'/', startingIndex);
3218 if(endingIndex == std::string::npos)
3219 endingIndex = nodeString.length();
3221 std::string nodeName = nodeString.substr(startingIndex, endingIndex - startingIndex);
3223 if(nodeName.length() < 1)
3233 std::string childPath =
3234 (endingIndex >= nodeString.length() ?
"" : nodeString.substr(endingIndex));
3240 if(childPath.length() > 1)
3241 return configTree.
getNode(childPath, doNotThrowOnBrokenUIDLinks);
3247 std::map<std::string, ConfigurationTree> ConfigurationManager::getNodes(
3248 const std::string& nodeString)
const
3260 std::string path =
"/";
3271 std::map<std::string, TableVersion>* memberMap,
3272 std::string* accumulatedTreeErrors)
const
3274 std::vector<std::pair<std::string, ConfigurationTree>> retVector;
3279 bool filtering = memberMap && memberMap->size();
3282 for(
auto& tablePair : nameToTableMap_)
3287 if(memberMap->find(tablePair.first) == memberMap->end())
3293 if(!tablePair.second->isActive())
3295 __SS__ <<
"Get Children with member map requires a child '"
3296 << tablePair.first <<
"' that is not active!" << __E__;
3300 catch(
const std::runtime_error& e)
3302 if(accumulatedTreeErrors)
3304 *accumulatedTreeErrors += e.what();
3305 __GEN_COUT_ERR__ <<
"Skipping " << tablePair.first
3306 <<
" since the table "
3315 if(!tablePair.second->isActive())
3319 if(accumulatedTreeErrors)
3323 std::vector<std::pair<std::string, ConfigurationTree>> newNodeChildren =
3325 for(
auto& newNodeChild : newNodeChildren)
3327 if(newNodeChild.second.getTableName() ==
3328 ConfigurationManager::DESKTOP_ICON_TABLE_NAME &&
3329 !newNodeChild.second.isEnabled())
3332 std::vector<std::pair<std::string, ConfigurationTree>>
3333 twoDeepChildren = newNodeChild.second.getChildren();
3335 for(
auto& twoDeepChild : twoDeepChildren)
3340 if(twoDeepChild.second.isLinkNode() &&
3341 twoDeepChild.second.isDisconnected() &&
3342 twoDeepChild.second.getDisconnectedTableName() !=
3343 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
3345 __SS__ <<
"At node '" + tablePair.first +
3346 "' with entry UID '" + newNodeChild.first +
3347 "' there is a disconnected child node at link "
3349 twoDeepChild.first +
"'" +
3350 " that points to table named '" +
3351 twoDeepChild.second.getDisconnectedTableName() +
3353 *accumulatedTreeErrors += ss.str();
3358 catch(std::runtime_error& e)
3360 __SS__ <<
"At node '" + tablePair.first +
3361 "' error detected descending through children:\n" +
3363 *accumulatedTreeErrors += ss.str();
3367 retVector.push_back(
3368 std::pair<std::string, ConfigurationTree>(tablePair.first, newNode));
3382 std::string* accumulatedTreeErrors)
const
3389 bool filtering = memberMap && memberMap->size();
3392 for(
auto& tablePair : nameToTableMap_)
3397 if(memberMap->find(tablePair.first) == memberMap->end())
3403 if(!tablePair.second->isActive())
3405 __SS__ <<
"Get Children with member map requires a child '"
3406 << tablePair.first <<
"' that is not active!" << __E__;
3410 catch(
const std::runtime_error& e)
3412 if(accumulatedTreeErrors)
3414 *accumulatedTreeErrors += e.what();
3415 __GEN_COUT_ERR__ <<
"Skipping " << tablePair.first
3416 <<
" since the table "
3425 if(!tablePair.second->isActive())
3429 if(accumulatedTreeErrors)
3433 std::vector<std::pair<std::string, ConfigurationTree>> newNodeChildren =
3435 for(
auto& newNodeChild : newNodeChildren)
3437 if(newNodeChild.second.getTableName() ==
3438 ConfigurationManager::DESKTOP_ICON_TABLE_NAME &&
3439 !newNodeChild.second.isEnabled())
3442 std::vector<std::pair<std::string, ConfigurationTree>>
3443 twoDeepChildren = newNodeChild.second.getChildren();
3445 for(
auto& twoDeepChild : twoDeepChildren)
3450 if(twoDeepChild.second.isLinkNode() &&
3451 twoDeepChild.second.isDisconnected() &&
3452 twoDeepChild.second.getDisconnectedTableName() !=
3453 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
3455 __SS__ <<
"At node '" + tablePair.first +
3456 "' with entry UID '" + newNodeChild.first +
3457 "' there is a disconnected child node at link "
3459 twoDeepChild.first +
"'" +
3460 " that points to table named '" +
3461 twoDeepChild.second.getDisconnectedTableName() +
3463 *accumulatedTreeErrors += ss.str();
3468 catch(std::runtime_error& e)
3470 __SS__ <<
"At node '" + tablePair.first +
3471 "' error detected descending through children:\n" +
3473 *accumulatedTreeErrors += ss.str();
3478 std::pair<std::string, ConfigurationTree>(tablePair.first, newNode));
3491 std::map<std::string, TableBase*>::const_iterator it;
3492 if((it = nameToTableMap_.find(tableName)) == nameToTableMap_.end())
3494 __SS__ <<
"Cannot find table named '" << tableName
3495 <<
"' - you need to load the table before it can be used.";
3497 if(nameToTableMap_.size() == 0)
3498 ss <<
"\n\nAll tables are missing. Your configuration database connection "
3499 "may have been interrupted. Did an ssh tunnel disconnect?"
3503 if(tableName == XDAQ_CONTEXT_TABLE_NAME)
3504 ss <<
"\n\nThe XDAQ Context Table is essential to the operation of ots. "
3505 "Without it, ots can not determine which applications are running "
3506 "on which hosts. Make sure that you have loaded a valid "
3507 "Configuration Context group that contains the XDAQ Context "
3511 ss <<
" It is likely missing from the member list of the Table "
3512 "Group that was loaded."
3515 ss <<
"\nYou may need to enter wiz mode to remedy the situation, use the "
3526 TLOG_DEBUG(55) <<
"Table " << tableName <<
" is at "
3527 <<
static_cast<void*
>(it->second);
3537 if(!theBackboneTableGroupKey_)
3539 __GEN_COUT_WARN__ <<
"getTableGroupKey() Failed! No active backbone currently."
3545 loadTableGroup(theBackboneTableGroup_, *theBackboneTableGroupKey_);
3547 return *theBackboneTableGroupKey_;
3564 std::string systemAlias,
ProgressBar* progressBar)
3574 progressBar->
step();
3576 if(systemAlias.find(
"GROUP:") == 0)
3579 progressBar->
step();
3581 unsigned int i = strlen(
"GROUP:");
3582 unsigned int j = systemAlias.find(
':', i);
3585 progressBar->
step();
3587 return std::pair<std::string, TableGroupKey>(
3588 systemAlias.substr(i, j - i),
TableGroupKey(systemAlias.substr(j + 1)));
3590 return std::pair<std::string, TableGroupKey>(
"",
TableGroupKey());
3596 progressBar->
step();
3602 getNode(ConfigurationManager::GROUP_ALIASES_TABLE_NAME).
getNode(systemAlias);
3605 progressBar->
step();
3607 return std::pair<std::string, TableGroupKey>(
3618 progressBar->
step();
3620 return std::pair<std::string, TableGroupKey>(
"",
TableGroupKey());
3626 std::map<std::string , std::pair<std::string ,
TableGroupKey>>
3632 ConfigurationManager::LoadGroupType::
3633 ONLY_BACKBONE_TYPE);
3636 std::map<std::string ,
3640 std::vector<std::pair<std::string, ConfigurationTree>> entries =
3642 for(
auto& entryPair : entries)
3644 retMap[entryPair.first] = std::pair<std::string, TableGroupKey>(
3645 entryPair.second.getNode(
"GroupName").getValueAsString(),
3646 TableGroupKey(entryPair.second.getNode(
"GroupKey").getValueAsString()));
3654 std::map<std::string ,
3660 std::map<std::string ,
3665 std::string versionAliasesTableName =
3666 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
3667 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
3669 __SS__ <<
"Active version of VersionAliases missing!"
3670 <<
" Make sure you have a valid active Backbone Group." << __E__;
3671 __GEN_COUT_WARN__ <<
"\n" << ss.str();
3677 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
3683 std::string tableName, versionAlias;
3684 for(
auto& aliasNodePair : aliasNodePairs)
3686 tableName = aliasNodePair.second.getNode(
"TableName").getValueAsString();
3687 versionAlias = aliasNodePair.second.getNode(
"VersionAlias").getValueAsString();
3689 if(retMap.find(tableName) != retMap.end() &&
3690 retMap[tableName].find(versionAlias) != retMap[tableName].end())
3695 retMap[tableName][versionAlias] =
3696 TableVersion(aliasNodePair.second.getNode(
"Version").getValueAsString());
3706 std::map<std::string, TableVersion> retMap;
3707 for(
auto& table : nameToTableMap_)
3709 __GEN_COUTS__(2) << table.first << __E__;
3712 if(table.second && table.second->
isActive())
3714 __GEN_COUTS__(2) << table.first <<
"_v" << table.second->
getViewVersion()
3716 retMap.insert(std::pair<std::string, TableVersion>(
3750 if(theConfigurationTableGroupKey_)
3752 if(*theConfigurationTableGroupKey_ != key)
3755 return theConfigurationTableGroupKey_;
3757 return std::shared_ptr<TableGroupKey>(
new TableGroupKey(key));
3761 const std::set<std::string>& ConfigurationManager::getActiveContextMemberNames()
3764 contextMemberNames_ = ConfigurationManager::fixedContextMemberNames_;
3767 nameToTableMap_.find(ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE);
3768 if(it == nameToTableMap_.end())
3769 return contextMemberNames_;
3771 if(!it->second->isActive())
3773 contextMemberNames_.emplace(
3774 ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE);
3776 return contextMemberNames_;
3780 const std::set<std::string>& ConfigurationManager::getFixedContextMemberNames()
3782 return ConfigurationManager::fixedContextMemberNames_;
3786 const std::set<std::string>& ConfigurationManager::getBackboneMemberNames()
3788 return ConfigurationManager::backboneMemberNames_;
3792 const std::set<std::string>& ConfigurationManager::getIterateMemberNames()
3794 return ConfigurationManager::iterateMemberNames_;
3798 const std::set<std::string>& ConfigurationManager::getConfigurationMemberNames(
void)
3800 configurationMemberNames_.clear();
3804 for(
auto& tablePair : activeTables)
3807 ConfigurationManager::fixedContextMemberNames_.find(tablePair.first) ==
3808 ConfigurationManager::fixedContextMemberNames_.end() &&
3809 tablePair.first != ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE &&
3812 ConfigurationManager::backboneMemberNames_.find(tablePair.first) ==
3813 ConfigurationManager::backboneMemberNames_.end() &&
3816 ConfigurationManager::iterateMemberNames_.find(tablePair.first) ==
3817 ConfigurationManager::iterateMemberNames_.end())
3820 configurationMemberNames_.emplace(tablePair.first);
3823 return configurationMemberNames_;
3827 void ConfigurationManager::initializeFromFhicl(
const std::string& fhiclPath)
3829 __GEN_COUT__ <<
"Initializing from fhicl: " << fhiclPath << __E__;
3834 fhicl::ParameterSet pset = LoadParameterSet(fhiclPath);
3836 if(pset.get_names().size() == 0)
3838 __GEN_SS__ <<
"Empty fcl configuration parameter set found! File: " << fhiclPath
3870 theInterface_->get(table,
3871 ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME,
3877 nameToTableMap_[ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME] = table;
3880 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3883 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3888 auto colMap = view->getColumnNamesMap();
3890 view->
setValue(
"MacroMakerFEContext", 0, colMap[
"ContextUID"]);
3891 view->
setValue(
"XDAQApplicationTable", 0, colMap[
"LinkToApplicationTable"]);
3892 view->
setValue(
"MacroMakerFEContextApps", 0, colMap[
"LinkToApplicationGroupID"]);
3893 view->
setValue(
"1", 0, colMap[TableViewColumnInfo::COL_NAME_STATUS]);
3895 __GEN_COUT__ <<
"Done adding context record..." << __E__;
3905 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
3911 nameToTableMap_[ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME] = table;
3914 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3917 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3922 auto colMap = view->getColumnNamesMap();
3924 view->
setValue(
"MacroMakerFEContextApps", 0, colMap[
"ApplicationGroupID"]);
3925 view->
setValue(
"MacroMakerFESupervisor", 0, colMap[
"ApplicationUID"]);
3926 view->
setValue(
"FESupervisorTable", 0, colMap[
"LinkToSupervisorTable"]);
3927 view->
setValue(
"MacroMakerFESupervisor", 0, colMap[
"LinkToSupervisorUID"]);
3928 view->
setValue(
"1", 0, colMap[TableViewColumnInfo::COL_NAME_STATUS]);
3929 view->
setValue(__ENV__(
"FE_SUPERVISOR_ID"), 0, colMap[
"Id"]);
3931 __GEN_COUT__ <<
"Done adding application record..." << __E__;
3938 theInterface_->get(table,
3939 "FESupervisorTable",
3945 nameToTableMap_[
"FESupervisorTable"] = table;
3948 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3951 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3956 auto colMap = view->getColumnNamesMap();
3958 view->
setValue(
"MacroMakerFESupervisor", 0, colMap[
"SupervisorUID"]);
3959 view->
setValue(
"FEInterfaceTable", 0, colMap[
"LinkToFEInterfaceTable"]);
3961 "MacroMakerFESupervisorInterfaces", 0, colMap[
"LinkToFEInterfaceGroupID"]);
3963 __GEN_COUT__ <<
"Done adding supervisor record..." << __E__;
3968 recursiveInitFromFhiclPSet(
"FEInterfaceTable" ,
3971 "MacroMakerFESupervisorInterfaces" ,
3975 for(
auto& table : nameToTableMap_)
3977 table.second->getViewP()->
init();
3983 __GEN_COUT__ <<
"================================================" << __E__;
3984 nameToTableMap_[
"FESupervisorTable"]->getViewP()->print();
3985 nameToTableMap_[
"FEInterfaceTable"]->getViewP()->print();
3988 __GEN_COUT__ <<
"Supervisors extracted from fhicl: " << sups.size() << __E__;
3990 __GEN_COUT__ <<
"Front-ends extracted from fhicl: " << fes.size() << __E__;
3992 auto a =
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME);
3993 __GEN_COUTV__(a.getValueAsString());
3995 auto b = a.getNode(
"MacroMakerFEContext");
3996 __GEN_COUTV__(b.getValueAsString());
3998 auto c = b.getNode(
"LinkToApplicationTable");
3999 __GEN_COUTV__(c.getValueAsString());
4001 auto d = c.getNode(
"MacroMakerFESupervisor");
4002 __GEN_COUTV__(d.getValueAsString());
4004 auto e = d.getNode(
"LinkToSupervisorTable");
4005 __GEN_COUTV__(e.getValueAsString());
4007 auto f = e.getNode(
"LinkToFEInterfaceTable");
4008 __GEN_COUTV__(f.getValueAsString());
4010 auto z = f.getChildrenNames();
4012 __GEN_COUTV__(z.size());
4013 auto y = f.getChildrenNames(
false ,
true );
4015 __GEN_COUTV__(y.size());
4016 auto x = f.getChildrenNames(
true ,
true );
4018 __GEN_COUTV__(x.size());
4020 auto g = f.getNode(
"dtc0");
4021 __GEN_COUTV__(g.getValueAsString());
4022 auto h = f.getNode(
"interface0");
4023 __GEN_COUTV__(h.getValueAsString());
4026 getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
4028 "MacroMakerFEContext/LinkToApplicationTable/"
4029 "MacroMakerFESupervisor/LinkToSupervisorTable")
4030 .
getNode(
"LinkToFEInterfaceTable")
4032 __GEN_COUTV__(fes.size());
4044 void ConfigurationManager::recursiveInitFromFhiclPSet(
const std::string& tableName,
4045 const fhicl::ParameterSet& pset,
4046 const std::string& recordName,
4047 const std::string& groupName,
4048 const std::string& groupLinkIndex)
4050 __GEN_COUT__ << __COUT_HDR_P__ <<
"Adding table '" << tableName <<
"' record(s)..."
4057 if(nameToTableMap_.find(tableName) == nameToTableMap_.end())
4059 __GEN_COUT__ <<
"Table not found, so making '" << tableName <<
"' instance..."
4061 theInterface_->get(table,
4068 nameToTableMap_[tableName] = table;
4073 __GEN_COUT__ <<
"Existing table found, so using '" << tableName
4074 <<
"'instance..." << __E__;
4075 table = nameToTableMap_[tableName];
4078 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
4081 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
4084 if(recordName !=
"")
4092 __GEN_COUTV__(recordName);
4095 unsigned int r = view->
addRow();
4096 auto colMap = view->getColumnNamesMap();
4106 __GEN_COUT__ <<
"No status column to set for '" << recordName <<
"'"
4112 __GEN_COUT__ <<
"Setting group ID for group link index '"
4113 << groupLinkIndex <<
"'" << __E__;
4116 __GEN_COUT__ <<
"Setting group ID for group link index '"
4117 << groupLinkIndex <<
"' at column " << groupIDCol <<
" to '"
4118 << groupName <<
".'" << __E__;
4120 view->
setValue(groupName, r, groupIDCol);
4124 auto names = pset.get_names();
4125 for(
const auto& colName : names)
4127 if(!pset.is_key_to_atom(colName))
4130 auto colIt = colMap.find(colName);
4131 if(colIt == colMap.end())
4133 __SS__ <<
"Field '" << colName <<
"' of record '" << recordName
4134 <<
"' in table '" << tableName <<
"' was not found in columns."
4135 <<
"\n\nHere are the existing column names:\n";
4137 for(
const auto& col : colMap)
4138 ss <<
"\n" << ++i <<
".\t" << col.first;
4143 if(view->getColumnInfo(colIt->second).
isGroupID())
4146 const std::string value = pset.get<std::string>(colName);
4147 __GEN_COUT__ <<
"Setting '" << recordName <<
"' parameter at column "
4148 << colIt->second <<
", '" << colName <<
"'\t = " << value
4154 for(
const auto& linkName : names)
4156 if(pset.is_key_to_atom(linkName))
4159 __GEN_COUTV__(linkName);
4162 unsigned int c = linkName.size() - 1;
4164 if(linkName[c] ==
'_')
4169 __SS__ <<
"Illegal link name '" << linkName
4170 <<
"' found. The format must be <Column name>_<Target table "
4171 "name>,.. for example '"
4172 <<
"LinkToFETypeTable_FEOtsUDPTemplateInterfaceTable'"
4176 std::string colName = linkName.substr(0, c);
4177 __GEN_COUTV__(colName);
4179 auto colIt = colMap.find(colName);
4180 if(colIt == colMap.end())
4182 __SS__ <<
"Link '" << colName <<
"' of record '" << recordName
4183 <<
"' in table '" << tableName <<
"' was not found in columns."
4184 <<
"\n\nHere are the existing column names:\n";
4186 for(
const auto& col : colMap)
4187 ss <<
"\n" << i <<
".\t" << col.first << __E__;
4192 std::pair<
unsigned int ,
unsigned int >
4195 view->
getChildLink(colIt->second, isGroupLink, linkPair);
4201 std::string linkTableName = linkName.substr(c + 1);
4202 __GEN_COUTV__(linkTableName);
4204 auto linkPset = pset.get<fhicl::ParameterSet>(linkName);
4205 auto linkRecords = linkPset.get_pset_names();
4206 if(!isGroupLink && linkRecords.size() > 1)
4208 __SS__ <<
"A Unique Link can only point to one record. "
4209 <<
"The specified link '" << colName <<
"' of record '"
4210 << recordName <<
"' in table '" << tableName <<
"' has "
4211 << linkRecords.size() <<
" children records specified. "
4216 if(linkRecords.size() == 0)
4218 __GEN_COUT__ <<
"No child records, so leaving link disconnected."
4223 __GEN_COUT__ <<
"Setting Link at columns [" << linkPair.first <<
","
4224 << linkPair.second <<
"]" << __E__;
4225 view->
setValue(linkTableName, r, linkPair.first);
4229 __GEN_COUT__ <<
"Setting up Unique link to " << linkRecords[0]
4232 view->
setValue(linkRecords[0], r, linkPair.second);
4234 recursiveInitFromFhiclPSet(
4236 linkPset.get<fhicl::ParameterSet>(
4243 std::string childLinkIndex =
4245 std::string groupName = recordName +
"Group";
4247 view->
setValue(groupName, r, linkPair.second);
4249 for(
const auto& groupRecord : linkRecords)
4251 __GEN_COUT__ <<
"Setting '" << childLinkIndex
4252 <<
"' Group link to '" << groupName <<
"' record '"
4253 << groupRecord <<
"'" << __E__;
4255 recursiveInitFromFhiclPSet(
4257 linkPset.get<fhicl::ParameterSet>(
4267 else if(groupName !=
"")
4271 __GEN_COUTV__(groupName);
4272 auto psets = pset.get_pset_names();
4273 for(
const auto& ps : psets)
4276 recursiveInitFromFhiclPSet(
4278 pset.get<fhicl::ParameterSet>(ps) ,
4286 __SS__ <<
"Illegal recursive parameters!" << __E__;
4289 __GEN_COUT__ << __COUT_HDR_P__ <<
"Done adding table '" << tableName
4290 <<
"' record(s)..." << __E__;
4302 __GEN_COUTS__(11) <<
"Checking if owner '" << ownerContextUID_ <<
"/" << ownerAppUID_
4303 <<
"' is first App in Context:\n"
4306 if(ownerContextUID_ ==
"" || ownerAppUID_ ==
"")
4308 __GEN_COUTTV__(!forceNotFirstInContext_);
4309 return !forceNotFirstInContext_;
4312 __GEN_COUTVS__(10, ownerContextUID_);
4313 __GEN_COUTVS__(10, ownerAppUID_);
4317 auto contextChildren =
4318 getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME +
"/" +
4319 ownerContextUID_ +
"/LinkToApplicationTable")
4322 if(contextChildren.size() == 0)
4325 getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME +
"/" +
4326 ownerContextUID_ +
"/LinkToApplicationTable")
4333 bool isFirstAppInContext =
4334 contextChildren.size() == 0 || contextChildren[0] == ownerAppUID_;
4336 __GEN_COUTVS__(10, isFirstAppInContext);
4338 return isFirstAppInContext;
4342 __GEN_COUTS__(10) <<
"Exception caught looking for XDAQ Context '"
4343 << ownerContextUID_ <<
"' in tree, so defaulting to 'yes'."
4353 const std::string& otherSubsystemUID,
4354 std::string* userDataPathPtr ,
4355 std::string* hostnamePtr ,
4356 std::string* usernamePtr ,
4357 std::string* fullNamePtr )
4359 __GEN_COUTTV__(otherSubsystemUID);
4362 getNode(ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE)
4364 std::string userPath = node.
getNode(
"SubsystemUserDataPath").
getValue();
4371 if(!splitPath.size() || splitPath.size() > 2)
4373 __GEN_SS__ <<
"Illegal user data path specified for subsystem '"
4374 << otherSubsystemUID <<
"': " << userPath << __E__;
4377 std::string userDataPath = splitPath[splitPath.size() - 1];
4380 for(
unsigned int i = 0; i < userDataPath.length(); ++i)
4381 if(!((userDataPath[i] >=
'a' && userDataPath[i] <=
'z') ||
4382 (userDataPath[i] >=
'A' && userDataPath[i] <=
'Z') ||
4383 (userDataPath[i] >=
'0' && userDataPath[i] <=
'9') ||
4384 userDataPath[i] ==
'-' || userDataPath[i] ==
'_' || userDataPath[i] ==
'/'))
4386 __GEN_SS__ <<
"Illegal user data path specified (no special characters "
4387 "allowed) for subsystem '"
4388 << otherSubsystemUID <<
"': " << userPath << __E__;
4393 *userDataPathPtr = userDataPath;
4395 std::string username, hostname;
4396 if(splitPath.size() == 2)
4399 std::vector<std::string> userHostSplit =
4401 __GEN_COUTTV__(userHostSplit.size());
4402 if(userHostSplit.size() == 1)
4403 hostname = userHostSplit[0];
4404 else if(userHostSplit.size() == 2)
4406 username = userHostSplit[0];
4407 hostname = userHostSplit[1];
4411 __GEN_SS__ <<
"Illegal remote username/host specified for subsystem '"
4412 << otherSubsystemUID <<
"': " << userPath << __E__;
4416 for(
unsigned int i = 0; userHostSplit.size() == 2 && i < username.length(); ++i)
4417 if(!((username[i] >=
'a' && username[i] <=
'z') ||
4418 (username[i] >=
'A' && username[i] <=
'Z') ||
4419 (username[i] >=
'0' && username[i] <=
'9') || username[i] ==
'-' ||
4420 username[i] ==
'_'))
4422 __GEN_SS__ <<
"Illegal remote username specified for subsystem '"
4423 << otherSubsystemUID <<
"': " << userPath << __E__;
4426 unsigned int ii = 0;
4427 for(
unsigned int i = 0; i < hostname.length(); ++i)
4428 if(!((hostname[i] >=
'a' && hostname[i] <=
'z') ||
4429 (hostname[i] >=
'A' && hostname[i] <=
'Z') ||
4430 (hostname[i] >=
'0' && hostname[i] <=
'9') || hostname[i] ==
'-' ||
4431 hostname[i] ==
'_'))
4433 if(hostname[i] ==
'.' && i > ii + 1)
4440 __GEN_SS__ <<
"Illegal remote hostname '" << hostname
4441 <<
"' specified for subsystem '" << otherSubsystemUID
4442 <<
"': " << userPath << __E__;
4447 else if(splitPath.size() == 1)
4449 __GEN_COUT__ <<
"Local user date path identified." << __E__;
4453 __GEN_SS__ <<
"Illegal user data path specified for subsystem '"
4454 << otherSubsystemUID <<
"': " << userPath << __E__;
4459 *hostnamePtr = hostname;
4461 *usernamePtr = username;
4466 std::map<std::string , std::pair<std::string ,
TableGroupKey>>
4467 ConfigurationManager::getOtherSubsystemActiveTableGroups(
4468 const std::string& otherSubsystemUID,
4469 std::string* userDataPathPtr ,
4470 std::string* hostnamePtr ,
4471 std::string* usernamePtr )
4473 std::map<std::string ,
4477 __GEN_COUTTV__(otherSubsystemUID);
4479 std::string userDataPath;
4480 std::string username, hostname;
4484 __GEN_COUTTV__(userDataPath);
4485 __GEN_COUTTV__(username);
4486 __GEN_COUTTV__(hostname);
4489 *userDataPathPtr = userDataPath;
4491 *hostnamePtr = hostname;
4493 *usernamePtr = username;
4496 std::string filename = userDataPath +
"/ServiceData/ActiveTableGroups.cfg";
4498 std::string cmdResult;
4502 std::string tmpSubsystemFilename =
4504 __GEN_COUTTV__(tmpSubsystemFilename);
4508 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + username +
"@" +
4509 hostname +
":" + filename +
" " + tmpSubsystemFilename +
" 2>&1; cat " +
4510 tmpSubsystemFilename +
" 2>&1")
4515 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + hostname +
":" +
4516 filename +
" " + tmpSubsystemFilename +
" 2>&1; cat " +
4517 tmpSubsystemFilename +
" 2>&1")
4522 __GEN_COUT__ <<
"Local user date path identified." << __E__;
4526 __GEN_COUTTV__(cmdResult);
4527 if(cmdResult.find(
"Permission denied") != std::string::npos)
4530 <<
"\n\nPermission denied accessing user data path specified for subsystem '"
4531 << otherSubsystemUID <<
"': ";
4533 ss << username <<
"@";
4535 ss << hostname <<
":";
4536 ss << userDataPath << __E__;
4541 cmdResult, {
'\n'} , {
' ',
'\t'} );
4543 __GEN_COUTTV__(subsystemActiveGroupMap.size());
4547 for(
unsigned int i = 0; i + 1 < subsystemActiveGroupMap.size(); i += 2)
4549 if(subsystemActiveGroupMap[i] ==
"" || subsystemActiveGroupMap[i + 1] ==
"-1")
4552 __GEN_COUTT__ <<
"Loading type of subsystem '" << otherSubsystemUID <<
"' group "
4553 << subsystemActiveGroupMap[i] <<
"("
4554 << subsystemActiveGroupMap[i + 1] <<
")" << __E__;
4570 catch(
const std::runtime_error& e)
4572 __GEN_COUTT__ <<
"Ignoring error loading subsystem '" << otherSubsystemUID
4573 <<
"' group " << subsystemActiveGroupMap[i] <<
"("
4574 << subsystemActiveGroupMap[i + 1] <<
"): " << __E__ << e.what()
4576 groupType = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
4578 retMap[groupType] = std::make_pair(subsystemActiveGroupMap[i],
4588 std::set<std::string >
4591 std::set<std::string> retSet;
4593 __GEN_COUTTV__(otherSubsystemUID);
4595 std::map<std::string ,
4597 retMap = getOtherSubsystemActiveTableGroups(otherSubsystemUID);
4602 auto it = retMap.find(
4604 if(it == retMap.end())
4607 <<
"No active Backbone group found in the active groups of remote subsystem '"
4608 << otherSubsystemUID <<
"!'" << __E__;
4611 auto it2 = retMap.find(
4613 if(it2 == retMap.end())
4616 <<
"No active Context group found in the active groups of remote subsystem '"
4617 << otherSubsystemUID <<
"!'" << __E__;
4621 std::string accumulatedWarnings;
4630 &accumulatedWarnings
4632 __GEN_COUTTV__(accumulatedWarnings);
4635 std::vector<std::pair<std::string, ConfigurationTree>> entries =
4638 for(
auto& entry : entries)
4640 if(entry.first.find(
"Context") == std::string::npos &&
4641 entry.first.find(
"Iterat") == std::string::npos)
4642 retSet.emplace(entry.first);
4650 std::set<std::string >
4652 const std::string& otherSubsystemUID,
const std::string& otherSubsystemFsmName)
4654 std::set<std::string> retSet;
4656 std::map<std::string ,
4658 retMap = getOtherSubsystemActiveTableGroups(otherSubsystemUID);
4661 auto it = retMap.find(
4663 if(it == retMap.end())
4666 <<
"No active Backbone group found in the active groups of remote subsystem '"
4667 << otherSubsystemUID <<
"!'" << __E__;
4670 auto it2 = retMap.find(
4672 if(it2 == retMap.end())
4675 <<
"No active Context group found in the active groups of remote subsystem '"
4676 << otherSubsystemUID <<
"!'" << __E__;
4680 std::string accumulatedWarnings;
4689 &accumulatedWarnings
4696 &accumulatedWarnings
4698 __GEN_COUTTV__(accumulatedWarnings);
4701 std::vector<std::pair<std::string, ConfigurationTree>> entries =
4706 std::string stateMachineAliasFilter =
"*";
4711 otherGatewayNode.
getNode(
"LinkToStateMachineTable")
4712 .
getNode(otherSubsystemFsmName +
"/SystemAliasFilter");
4714 stateMachineAliasFilter = fsmFilterNode.
getValue<std::string>();
4716 __GEN_COUT_INFO__ <<
"FSM has no SystemAliasFilter value." << __E__;
4718 catch(std::runtime_error& e)
4720 __COUT__ <<
"Ignoring unsetup SystemAliasFilter value: " << e.what() << __E__;
4724 __COUT__ <<
"Ignoring unsetup SystemAliasFilter value." << __E__;
4727 __COUT__ <<
"Applying alias filter for other user_data path FSM '"
4728 << otherSubsystemFsmName
4729 <<
"' and stateMachineAliasFilter = " << stateMachineAliasFilter << __E__;
4736 stateMachineAliasFilter.size() && stateMachineAliasFilter[0] ==
'!';
4737 std::vector<std::string> filterArr;
4744 while((f = stateMachineAliasFilter.find(
'*', i)) != std::string::npos)
4746 tmp = stateMachineAliasFilter.substr(i, f - i);
4748 filterArr.push_back(tmp);
4749 __COUTS__(20) << filterArr[filterArr.size() - 1] <<
" " << i <<
" of "
4750 << stateMachineAliasFilter.size() << __E__;
4752 if(i <= stateMachineAliasFilter.size())
4754 tmp = stateMachineAliasFilter.substr(i);
4755 filterArr.push_back(tmp);
4756 __COUTS__(20) << filterArr[filterArr.size() - 1] <<
" last." << __E__;
4761 for(
auto& aliasMapPair : entries)
4763 __COUTS__(20) <<
"aliasMapPair.first: " << aliasMapPair.first << __E__;
4767 if(filterArr.size() == 1)
4769 if(filterArr[0] !=
"" && filterArr[0] !=
"*" &&
4770 aliasMapPair.first != filterArr[0])
4771 filterMatch =
false;
4776 for(f = 0; f < filterArr.size(); ++f)
4778 if(!filterArr[f].size())
4783 if((i = aliasMapPair.first.find(filterArr[f])) != 0)
4785 filterMatch =
false;
4789 else if(f == filterArr.size() - 1)
4791 if(aliasMapPair.first.rfind(filterArr[f]) !=
4792 aliasMapPair.first.size() - filterArr[f].size())
4794 filterMatch =
false;
4798 else if((i = aliasMapPair.first.find(filterArr[f])) ==
4801 filterMatch =
false;
4808 filterMatch = !filterMatch;
4810 __COUTS__(20) <<
"filterMatch=" << filterMatch << __E__;
4815 retSet.emplace(aliasMapPair.first);
4827 const std::string& otherSubsystemUID,
4828 const std::string& configAlias,
4829 std::pair<std::string, TableGroupKey>& groupTranslation,
4830 std::string& groupComment,
4831 std::string& groupAuthor,
4832 std::string& groupCreationTime)
4834 __GEN_COUTV__(otherSubsystemUID);
4836 std::map<std::string ,
4838 retMap = getOtherSubsystemActiveTableGroups(otherSubsystemUID);
4841 auto it = retMap.find(
4843 if(it == retMap.end())
4846 <<
"No active Backbone group found in the active groups of remote subsystem '"
4847 << otherSubsystemUID <<
"!'" << __E__;
4850 auto it2 = retMap.find(
4852 if(it2 == retMap.end())
4855 <<
"No active Context group found in the active groups of remote subsystem '"
4856 << otherSubsystemUID <<
"!'" << __E__;
4860 std::string accumulatedWarnings;
4869 &accumulatedWarnings
4871 __GEN_COUTTV__(accumulatedWarnings);
4878 getNode(ConfigurationManager::GROUP_ALIASES_TABLE_NAME).
getNode(configAlias);
4880 groupTranslation = std::pair<std::string, TableGroupKey>(
4883 __COUT__ <<
"Found " << configAlias <<
" translates to " << groupTranslation.first
4884 <<
"(" << groupTranslation.second <<
")" << __E__;
4890 groupTranslation.second,
4894 &accumulatedWarnings,
4902 __COUT_WARN__ <<
"Failed to load group metadata." << __E__;
4904 __COUT__ <<
"Found " << configAlias <<
" author: " << groupAuthor
4905 <<
", createTime: " << groupCreationTime <<
", comment: " << groupComment
4910 __GEN_SS__ <<
"Did not find the Configuration Alias '" << configAlias
4911 <<
"' in the active Backbone group of remote subsystem '"
4912 << otherSubsystemUID <<
"!'" << __E__;
4920 TableBase* ConfigurationManager::getDesktopIconTable(
void)
4922 if(nameToTableMap_.find(DESKTOP_ICON_TABLE_NAME) == nameToTableMap_.end())
4924 __SS__ <<
"Desktop icon table not found!" << __E__;
4929 return nameToTableMap_.at(DESKTOP_ICON_TABLE_NAME);
4933 void ConfigurationManager::saveGroupNameAndKey(
4934 const std::pair<std::string /*group name*/, TableGroupKey>& theGroup,
4935 const std::string& fileName,
4937 const std::string& associatedUser )
4939 std::string fullPath =
4940 ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/" + fileName;
4941 __COUT__ <<
"Saving group " << theGroup.first <<
"(" << theGroup.second <<
") to "
4942 << (appendMode ?
"history " :
"") <<
"file: " << fullPath << __E__;
4944 std::ofstream groupFile;
4948 const size_t MAX_RECORDS = 200;
4950 while(records.size() >= MAX_RECORDS)
4951 records.erase(records.begin());
4953 groupFile.open(fullPath.c_str());
4954 for(
const auto& record : records)
4956 groupFile << record.at(
"groupName") <<
"\n"
4957 << record.at(
"groupKey") <<
"\n"
4958 << record.at(
"time") <<
" , " << record.at(
"user") <<
"\n";
4962 groupFile.open(fullPath.c_str());
4963 if(!groupFile.is_open())
4965 __SS__ <<
"Error. Can't open file to save group activity: " << fullPath << __E__;
4968 std::stringstream outss;
4969 outss << theGroup.first <<
"\n" << theGroup.second <<
"\n";
4971 if(associatedUser !=
"")
4972 outss <<
" , " << associatedUser;
4974 groupFile << outss.str().c_str();
4986 std::string& returnedTimeString)
4988 std::string fullPath =
4989 ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/" + fileName;
4991 FILE* groupFile = fopen(fullPath.c_str(),
"r");
4994 __COUT__ <<
"Can't open file: " << fullPath
4995 <<
". Returning empty groupName and key -1" << __E__;
5004 fgets(line, 500, groupFile);
5005 if(strlen(line) && line[strlen(line) - 1] ==
'\n')
5006 line[strlen(line) - 1] =
'\0';
5007 theGroup.first = line;
5009 fgets(line, 500, groupFile);
5011 sscanf(line,
"%d", &key);
5012 theGroup.second = key;
5014 fgets(line, 500, groupFile);
5016 sscanf(line,
"%ld", ×tamp);
5023 __COUTT__ <<
"theGroup.first=" << theGroup.first
5024 <<
" theGroup.second=" << theGroup.second << __E__;
5032 std::map<std::string , std::string >>
5034 const std::string& groupType,
5037 __COUTTV__(groupAction);
5038 __COUTTV__(groupType);
5040 std::string fullPath = ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/";
5042 if(groupAction ==
"Activated")
5044 if(groupType == ConfigurationManager::GROUP_TYPE_NAME_BACKBONE)
5045 fullPath += ConfigurationManager::ACTIVATED_BACKBONES_FILE;
5046 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONTEXT)
5047 fullPath += ConfigurationManager::ACTIVATED_CONTEXTS_FILE;
5048 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
5049 fullPath += ConfigurationManager::ACTIVATED_CONFIGS_FILE;
5050 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_ITERATE)
5051 fullPath += ConfigurationManager::ACTIVATED_ITERATES_FILE;
5053 else if(groupAction ==
"Configured")
5055 if(groupType == ConfigurationManager::GROUP_TYPE_NAME_BACKBONE)
5056 fullPath += ConfigurationManager::CONFIGURED_BACKBONES_FILE;
5057 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONTEXT)
5058 fullPath += ConfigurationManager::CONFIGURED_CONTEXTS_FILE;
5059 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
5060 fullPath += ConfigurationManager::CONFIGURED_CONFIGS_FILE;
5061 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_ITERATE)
5062 fullPath += ConfigurationManager::CONFIGURED_ITERATES_FILE;
5063 else if(groupType ==
"Config Alias")
5064 fullPath += ConfigurationManager::CONFIGURED_CONFIG_ALIASES_FILE;
5066 else if(groupAction ==
"Started")
5068 if(groupType == ConfigurationManager::GROUP_TYPE_NAME_BACKBONE)
5069 fullPath += ConfigurationManager::STARTED_BACKBONES_FILE;
5070 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONTEXT)
5071 fullPath += ConfigurationManager::STARTED_CONTEXTS_FILE;
5072 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
5073 fullPath += ConfigurationManager::STARTED_CONFIGS_FILE;
5074 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_ITERATE)
5075 fullPath += ConfigurationManager::STARTED_ITERATES_FILE;
5076 else if(groupType ==
"Config Alias")
5077 fullPath += ConfigurationManager::STARTED_CONFIG_ALIASES_FILE;
5079 else if(groupAction ==
"Configured or Started")
5081 if(groupType == ConfigurationManager::GROUP_TYPE_NAME_BACKBONE)
5082 fullPath += ConfigurationManager::CONFIGURED_OR_STARTED_BACKBONES_FILE;
5083 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONTEXT)
5084 fullPath += ConfigurationManager::CONFIGURED_OR_STARTED_CONTEXTS_FILE;
5085 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION)
5086 fullPath += ConfigurationManager::CONFIGURED_OR_STARTED_CONFIGS_FILE;
5087 else if(groupType == ConfigurationManager::GROUP_TYPE_NAME_ITERATE)
5088 fullPath += ConfigurationManager::CONFIGURED_OR_STARTED_ITERATES_FILE;
5089 else if(groupType ==
"Config Alias")
5090 fullPath += ConfigurationManager::CONFIGURED_OR_STARTED_CONFIG_ALIASES_FILE;
5093 if(fullPath == ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/")
5095 __SS__ <<
"Illegal groupAction and groupType combination: " << groupAction <<
", "
5096 << groupType << __E__;
5105 std::map<std::string , std::string >>
5110 std::map<std::string , std::string >>
5113 __COUTV__(fullPath);
5114 FILE* groupFile = fopen(fullPath.c_str(),
"r");
5117 __COUT_WARN__ <<
"Can't open group history file (assuming no history yet): "
5118 << fullPath << __E__;
5120 __COUTV__(retVec.size());
5127 std::string returnedTimeString, associatedUser;
5130 while(fgets(line, 500, groupFile))
5132 if(strlen(line) && line[strlen(line) - 1] ==
'\n')
5133 line[strlen(line) - 1] =
'\0';
5134 theGroup.first = line;
5136 fgets(line, 500, groupFile);
5138 sscanf(line,
"%d", &key);
5139 theGroup.second = key;
5141 fgets(line, 500, groupFile);
5144 sscanf(line,
"%ld , %s", ×tamp, user);
5149 __COUTS__(20) <<
"Read group from history file: " << theGroup.first <<
"("
5150 << theGroup.second <<
"), timestamp=" << timestamp
5151 <<
", user=" << user << __E__;
5153 retVec.push_back({{
"groupName", theGroup.first},
5154 {
"groupKey", theGroup.second.toString()},
5157 : std::to_string(timestamp)},
5163 __COUTV__(retVec.size());
virtual std::map< std::string, TableVersion > getTableGroupMembers(std::string const &, bool=false) const
returns the set of table groups that contain the specified table name and version
std::map< std::string, std::map< std::string, TableVersion > > getVersionAliases(void) const
static const unsigned int PROCESSOR_COUNT
Static members.
static const std::string & convertGroupTypeToName(const ConfigurationManager::GroupType &groupTypeId)
bool isOwnerFirstAppInContext(void)
void restoreActiveTableGroups(bool throwErrors=false, const std::string &pathToActiveGroupsFile="", ConfigurationManager::LoadGroupType onlyLoadIfBackboneOrContext=ConfigurationManager::LoadGroupType::ALL_TYPES, std::string *accumulatedWarnings=0)
std::map< std::string, std::pair< std::string, TableGroupKey > > getActiveTableGroups(void) const
std::set< std::string > getOtherSubsystemConfigAliases(const std::string &otherSubsystemUID)
Ignore any System Aliases with "Context" or "Iterat" in the name.
void loadMemberMap(const std::map< std::string, TableVersion > &memberMap, std::string *accumulateWarnings=0)
std::map< std::string, TableVersion > getActiveVersions(void) const
getActiveVersions
void loadTableGroup(const std::string &tableGroupName, const TableGroupKey &tableGroupKey, bool doActivate=false, std::map< std::string, TableVersion > *groupMembers=0, ProgressBar *progressBar=0, std::string *accumulateWarnings=0, std::string *groupComment=0, std::string *groupAuthor=0, std::string *groupCreateTime=0, bool doNotLoadMember=false, std::string *groupTypeString=0, std::map< std::string, std::string > *groupAliases=0, ConfigurationManager::LoadGroupType groupTypeToLoad=ConfigurationManager::LoadGroupType::ALL_TYPES, bool ignoreVersionTracking=false)
std::shared_ptr< TableGroupKey > makeTheTableGroupKey(TableGroupKey key)
Setters/Modifiers.
void copyTableGroupFromCache(const ConfigurationManager &cacheConfigMgr, const std::map< std::string, TableVersion > &groupMembers, const std::string &configGroupName="", const TableGroupKey &tableGroupKey=TableGroupKey(TableGroupKey::INVALID), bool doActivate=false, bool ignoreVersionTracking=false)
void getOtherSubsystemInstanceInfo(const std::string &otherSubsystemUID, std::string *userDataPathPtr=nullptr, std::string *hostnamePtr=nullptr, std::string *usernamePtr=nullptr, std::string *fullNamePtr=nullptr)
ConfigurationManager(bool initForWriteAccess=false, bool initializeFromFhicl=false, bool forceNotFirstInContext=false)
ConfigurationTree getNode(const std::string &nodeString, bool doNotThrowOnBrokenUIDLinks=false) const
"root/parent/parent/"
void init(std::string *accumulatedErrors=0, bool initForWriteAccess=false, std::string *accumulatedWarnings=0)
std::string getFirstPathToNode(const ConfigurationTree &node, const std::string &startPath="/") const
getFirstPathToNode
static ConfigurationManager::GroupType getTypeOfGroup(const std::map< std::string, TableVersion > &memberMap)
static const std::string & getTypeNameOfGroup(const std::map< std::string, TableVersion > &memberMap)
void destroyTableGroup(const std::string &theGroup="", bool onlyDeactivate=false)
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, TableVersion > *memberMap=0, std::string *accumulatedTreeErrors=0) const
std::map< std::string, ConfigurationTree > getChildrenMap(std::map< std::string, TableVersion > *memberMap=0, std::string *accumulatedTreeErrors=0) const
std::pair< std::string, TableGroupKey > getTableGroupFromAlias(std::string systemAlias, ProgressBar *progressBar=0)
Getters.
static std::vector< std::map< std::string, std::string > > loadGroupHistory(const std::string &groupAction, const std::string &groupType, bool formatTime=false)
loadGroupHistory static
void getOtherSubsystemConfigAliasInfo(const std::string &otherSubsystemUID, const std::string &configAlias, std::pair< std::string, TableGroupKey > &groupTranslation, std::string &groupComment, std::string &groupAuthor, std::string &groupCreationTime)
returns configAlias translation group info by reference
void dumpActiveConfiguration(const std::string &filePath, const std::string &dumpType, const std::string &configurationAlias, const std::string &logEntry, const std::string &activeUsers, const std::string &activeStateMachine, std::ostream &altOut=std::cout)
ConfigurationTree getGatewaySupervisorNode(void) const
There can only be one active Gateway Superivsor app, so find it.
static const std::string ACTIVE_GROUPS_FILENAME
added env check for otsdaq_flatten_active_to_version to function
std::set< std::string > getOtherSubsystemFilteredConfigAliases(const std::string &otherSubsystemUID, const std::string &otherSubsystemFsmName)
Ignore any System Aliases with "Context" or "Iterat" in the name.
TableGroupKey loadConfigurationBackbone(void)
const TableBase * getTableByName(const std::string &configurationName) const
static std::pair< std::string, TableGroupKey > loadGroupNameAndKey(const std::string &fileName, std::string &returnedTimeString)
std::map< std::string, std::pair< std::string, TableGroupKey > > getActiveGroupAliases(void)
bool isDisconnected(void) const
std::vector< std::string > getChildrenNames(bool byPriority=false, bool onlyStatusTrue=false) const
ConfigurationTree getNode(const std::string &nodeName, bool doNotThrowOnBrokenUIDLinks=false) const
navigating between nodes
std::map< std::string, ConfigurationTree > getChildrenMap(std::map< std::string, std::string > filterMap=std::map< std::string, std::string >(), bool onlyStatusTrue=false) const
const std::string & getValueAsString(bool returnLinkTableValue=false) const
void getValue(T &value) const
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, std::string > filterMap=std::map< std::string, std::string >(), bool byPriority=false, bool onlyStatusTrue=false) const
bool isLinkNode(void) const
const std::string & getFieldName(void) const
alias for getValueName
bool isGroupLinkNode(void) const
bool isDefaultValue(void) const
boolean info
const std::string & getTableName(void) const
Getters.
void setupMockupView(TableVersion version)
bool isActive(void)
isActive
const TableVersion & getViewVersion(void) const
always the active one
void print(std::ostream &out=std::cout) const
always prints active view
static std::string getFullGroupString(const std::string &groupName, const TableGroupKey &key, const std::string &preKey="_v", const std::string &postKey="")
std::string getChildLinkIndex(void) const
getChildLinkIndex
bool isGroupID(void) const
void setValueAsString(const std::string &value, unsigned int row, unsigned int col)
unsigned int getColStatus(void) const
unsigned int getLinkGroupIDColumn(const std::string &childLinkIndex) const
bool getChildLink(const unsigned int &col, bool &isGroup, std::pair< unsigned int, unsigned int > &linkPair) const
std::string getValueAsString(unsigned int row, unsigned int col, bool convertEnvironmentVariables=true) const
unsigned int getColUID(void) const
void setValue(const T &value, unsigned int row, unsigned int col)
< in included .icc source
unsigned int addRow(const std::string &author="", unsigned char incrementUniqueData=false, const std::string &baseNameAutoUID="", unsigned int rowToAdd=(unsigned int) -1, std::string childLinkIndex="", std::string groupId="")
defines used also by OtsConfigurationWizardSupervisor
static std::string getTimestampString(const std::string &linuxTimeInSeconds)
static void getVectorFromString(const std::string &inputString, std::vector< std::string > &listToReturn, const std::set< char > &delimiter={',', '|', '&'}, const std::set< char > &whitespace={' ', '\t', '\n', '\r'}, std::vector< char > *listOfDelimiters=0, bool decodeURIComponents=false)
static std::string exec(const char *cmd)
static std::string setToString(const std::set< T > &setToReturn, const std::string &delimeter=", ")
setToString ~
static std::string vectorToString(const std::vector< T > &setToReturn, const std::string &delimeter=", ")
vectorToString ~
static std::string mapToString(const std::map< std::string, T > &mapToReturn, const std::string &primaryDelimeter=", ", const std::string &secondaryDelimeter=": ")
static void getMapFromString(const std::string &inputString, std::map< S, T > &mapToReturn, const std::set< char > &pairPairDelimiter={',', '|', '&'}, const std::set< char > &nameValueDelimiter={'=', ':'}, const std::set< char > &whitespace={' ', '\t', '\n', '\r'})
getMapFromString ~
static std::string stackTrace(void)