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"
19 std::thread::hardware_concurrency();
21 const std::string ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH =
22 ((getenv(
"SERVICE_DATA_PATH") == NULL)
23 ? (std::string(__ENV__(
"USER_DATA")) +
"/ServiceData")
24 : (std::string(__ENV__(
"SERVICE_DATA_PATH")))) +
26 const std::string ConfigurationManager::LAST_ACTIVATED_CONFIG_GROUP_FILE =
27 "CFGLastActivatedConfigGroup.hist";
28 const std::string ConfigurationManager::LAST_ACTIVATED_CONTEXT_GROUP_FILE =
29 "CFGLastActivatedContextGroup.hist";
30 const std::string ConfigurationManager::LAST_ACTIVATED_BACKBONE_GROUP_FILE =
31 "CFGLastActivatedBackboneGroup.hist";
32 const std::string ConfigurationManager::LAST_ACTIVATED_ITERATOR_GROUP_FILE =
33 "CFGLastActivatedIteratorGroup.hist";
35 const std::string ConfigurationManager::READONLY_USER =
"READONLY_USER";
37 const std::string ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME =
"XDAQContextTable";
38 const std::string ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME =
39 "XDAQApplicationTable";
40 const std::string ConfigurationManager::XDAQ_APP_PROPERTY_TABLE_NAME =
41 "XDAQApplicationPropertyTable";
42 const std::string ConfigurationManager::GROUP_ALIASES_TABLE_NAME =
"GroupAliasesTable";
43 const std::string ConfigurationManager::VERSION_ALIASES_TABLE_NAME =
44 "VersionAliasesTable";
45 const std::string ConfigurationManager::ARTDAQ_TOP_TABLE_NAME =
"ARTDAQSupervisorTable";
46 const std::string ConfigurationManager::DESKTOP_ICON_TABLE_NAME =
"DesktopIconTable";
50 ((getenv(
"SERVICE_DATA_PATH") == NULL)
51 ? (std::string(__ENV__(
"USER_DATA")) +
"/ServiceData")
52 : (std::string(__ENV__(
"SERVICE_DATA_PATH")))) +
53 "/ActiveTableGroups.cfg";
54 const std::string ConfigurationManager::ALIAS_VERSION_PREAMBLE =
"ALIAS:";
55 const std::string ConfigurationManager::SCRATCH_VERSION_ALIAS =
"Scratch";
57 const std::string ConfigurationManager::GROUP_TYPE_NAME_CONTEXT =
"Context";
58 const std::string ConfigurationManager::GROUP_TYPE_NAME_BACKBONE =
"Backbone";
59 const std::string ConfigurationManager::GROUP_TYPE_NAME_ITERATE =
"Iterate";
60 const std::string ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION =
"Configuration";
61 const std::string ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN =
"UNKNOWN";
63 const std::string ConfigurationManager::UNKNOWN_INFO =
"UNKNOWN";
64 const std::string ConfigurationManager::UNKNOWN_TIME =
"0";
66 const uint8_t ConfigurationManager::METADATA_COL_ALIASES = 1;
67 const uint8_t ConfigurationManager::METADATA_COL_COMMENT = 2;
68 const uint8_t ConfigurationManager::METADATA_COL_AUTHOR = 3;
69 const uint8_t ConfigurationManager::METADATA_COL_TIMESTAMP = 4;
71 const std::string ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE =
72 "SubsystemUserDataPathsTable";
74 ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME,
75 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
76 "XDAQApplicationPropertyTable",
77 ConfigurationManager::DESKTOP_ICON_TABLE_NAME,
78 "MessageFacilityTable",
79 "GatewaySupervisorTable",
81 "DesktopWindowParameterTable",
82 "SlowControlsDashboardSupervisorTable"};
84 ConfigurationManager::GROUP_ALIASES_TABLE_NAME,
85 ConfigurationManager::VERSION_ALIASES_TABLE_NAME};
89 "IterationTargetTable",
90 "IterationCommandBeginLabelTable",
91 "IterationCommandChooseFSMTable",
92 "IterationCommandConfigureAliasTable",
93 "IterationCommandConfigureGroupTable",
94 "IterationCommandExecuteFEMacroTable",
95 "IterationCommandExecuteMacroTable",
96 "IterationCommandMacroDimensionalLoopTable",
97 "IterationCommandMacroDimensionalLoopParameterTable",
98 "IterationCommandModifyGroupTable",
99 "IterationCommandRepeatLabelTable",
100 "IterationCommandRunTable"};
104 bool doInitializeFromFhicl )
105 : startClockTime_(std::chrono::steady_clock::now())
106 , deltaClockTime_(std::chrono::steady_clock::now())
110 , theConfigurationTableGroupKey_(0)
111 , theContextTableGroupKey_(0)
112 , theBackboneTableGroupKey_(0)
113 , theConfigurationTableGroup_(
"")
114 , theContextTableGroup_(
"")
115 , theBackboneTableGroup_(
"")
116 , groupMetadataTable_(true ,
TableBase::GROUP_METADATA_TABLE_NAME)
118 __GEN_COUTTV__(runTimeSeconds());
119 theInterface_ = ConfigurationInterface::getInstance(
120 ConfigurationInterface::CONFIGURATION_MODE::
123 __GEN_COUTTV__(runTimeSeconds());
195 if(doInitializeFromFhicl)
198 initializeFromFhicl(__ENV__(
"CONFIGURATION_INIT_FCL"));
203 __GEN_COUTTV__(runTimeSeconds());
204 if(!initForWriteAccess)
205 init(0 , initForWriteAccess);
206 __GEN_COUTTV__(runTimeSeconds());
214 __GEN_COUT__ <<
"Private constructor for write access called." << __E__;
216 mfSubject_ = username;
217 username_ = username;
221 ConfigurationManager::~ConfigurationManager() { destroy(); }
230 bool initForWriteAccess ,
231 std::string* accumulatedWarnings )
243 __GEN_COUTTV__(username_);
248 ConfigurationManager::LoadGroupType onlyLoadIfBackboneOrContext =
249 ConfigurationManager::LoadGroupType::ALL_TYPES;
250 if(username_ == ConfigurationManager::READONLY_USER && !initForWriteAccess)
251 onlyLoadIfBackboneOrContext =
252 ConfigurationManager::LoadGroupType::ONLY_BACKBONE_OR_CONTEXT_TYPES;
257 onlyLoadIfBackboneOrContext,
258 accumulatedWarnings);
261 catch(std::runtime_error& e)
263 __GEN_COUT_ERR__ <<
"Error caught in init(): " << e.what();
264 if(accumulatedErrors)
265 *accumulatedErrors += e.what();
282 const std::string& pathToActiveGroupsFile ,
283 ConfigurationManager::LoadGroupType
284 onlyLoadIfBackboneOrContext ,
285 std::string* accumulatedWarnings )
291 FILE* fp = fopen(fn.c_str(),
"r");
293 __GEN_COUT__ <<
"ACTIVE_GROUPS_FILENAME = " << fn << __E__;
294 __GEN_COUT__ <<
"ARTDAQ_DATABASE_URI = "
295 << std::string(__ENV__(
"ARTDAQ_DATABASE_URI")) << __E__;
299 __GEN_COUT_WARN__ <<
"No active groups file found at " << fn << __E__;
308 std::string groupName;
309 std::string errorStr =
"";
314 while(fgets(tmp, 500, fp))
319 sscanf(tmp,
"%d", &numberCheck);
323 <<
"Out of sync with active groups file lines, attempting to resync."
330 sscanf(tmp,
"%s", strVal);
331 for(
unsigned int j = 0; j < strlen(strVal); ++j)
332 if(!((strVal[j] >=
'a' && strVal[j] <=
'z') ||
333 (strVal[j] >=
'A' && strVal[j] <=
'Z') ||
334 (strVal[j] >=
'0' && strVal[j] <=
'9')))
337 __GEN_COUT_INFO__ <<
"Illegal character found in group name '" << strVal
338 <<
"', so skipping! Check active groups file: " << fn
350 sscanf(tmp,
"%s", strVal);
352 for(
unsigned int j = 0; j < strlen(strVal); ++j)
353 if(!((strVal[j] >=
'0' && strVal[j] <=
'9')))
357 if(groupName.size() > 3)
359 <<
"Skipping active group with illegal character in group key '"
360 << strVal <<
".' Check active groups file: " << fn << __E__;
366 if(groupName.size() <= 3)
379 <<
"illegal group according to TableGroupKey::getFullGroupString... "
380 "Check active groups file: "
391 std::string groupAccumulatedErrors =
"";
393 if(accumulatedWarnings)
394 __GEN_COUT__ <<
"Ignoring warnings while loading and activating group '"
395 << groupName <<
"(" << strVal <<
")'" << __E__;
403 (accumulatedWarnings ? &groupAccumulatedErrors
411 onlyLoadIfBackboneOrContext
414 if(accumulatedWarnings)
415 *accumulatedWarnings += groupAccumulatedErrors;
417 catch(std::runtime_error& e)
419 ss <<
"Failed to load group in ConfigurationManager::init() with name '"
420 << groupName <<
"(" << strVal
421 <<
")' specified active by active groups file: " << fn << __E__;
422 ss << e.what() << __E__;
424 errorStr += ss.str();
428 ss <<
"Failed to load group in ConfigurationManager::init() with name '"
429 << groupName <<
"(" << strVal
430 <<
")' specified active by active groups file: " << fn << __E__;
435 catch(
const std::exception& e)
437 ss <<
"Exception message: " << e.what();
442 errorStr += ss.str();
448 if(throwErrors && errorStr !=
"")
450 __SS__ <<
"\n" << errorStr;
453 else if(errorStr !=
"")
454 __GEN_COUT_INFO__ <<
"\n" << errorStr;
467 bool isContext = theGroup ==
"" || theGroup == theContextTableGroup_;
468 bool isBackbone = theGroup ==
"" || theGroup == theBackboneTableGroup_;
469 bool isIterate = theGroup ==
"" || theGroup == theIterateTableGroup_;
470 bool isConfiguration = theGroup ==
"" || theGroup == theConfigurationTableGroup_;
472 if(!isContext && !isBackbone && !isIterate && !isConfiguration)
474 __SS__ <<
"Invalid configuration group to destroy: " << theGroup << __E__;
475 __GEN_COUT_ERR__ << ss.str();
479 std::string dbgHeader = onlyDeactivate ?
"Deactivating" :
"Destroying";
483 __GEN_COUT__ << dbgHeader <<
" Context group: " << theGroup << __E__;
485 __GEN_COUT__ << dbgHeader <<
" Backbone group: " << theGroup << __E__;
487 __GEN_COUT__ << dbgHeader <<
" Iterate group: " << theGroup << __E__;
489 __GEN_COUT__ << dbgHeader <<
" Configuration group: " << theGroup << __E__;
492 std::set<std::string>::const_iterator contextFindIt, backboneFindIt, iterateFindIt;
493 for(
auto it = nameToTableMap_.begin(); it != nameToTableMap_.end();
507 CONTEXT_SUBSYSTEM_OPTIONAL_TABLE) ||
512 it->first != ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE &&
522 it->second->deactivate();
528 nameToTableMap_.erase(it++);
537 theConfigurationTableGroup_ =
"";
538 if(theConfigurationTableGroupKey_ != 0)
540 __GEN_COUT__ <<
"Destroying Configuration Key: "
541 << *theConfigurationTableGroupKey_ << __E__;
542 theConfigurationTableGroupKey_.reset();
549 theBackboneTableGroup_ =
"";
550 if(theBackboneTableGroupKey_ != 0)
552 __GEN_COUT__ <<
"Destroying Backbone Key: " << *theBackboneTableGroupKey_
554 theBackboneTableGroupKey_.reset();
559 theIterateTableGroup_ =
"";
560 if(theIterateTableGroupKey_ != 0)
562 __GEN_COUT__ <<
"Destroying Iterate Key: " << *theIterateTableGroupKey_
564 theIterateTableGroupKey_.reset();
569 theContextTableGroup_ =
"";
570 if(theContextTableGroupKey_ != 0)
572 __GEN_COUT__ <<
"Destroying Context Key: " << *theContextTableGroupKey_
574 theContextTableGroupKey_.reset();
580 void ConfigurationManager::destroy(
void)
596 const ConfigurationManager::GroupType& groupTypeId)
598 return groupTypeId == ConfigurationManager::GroupType::CONTEXT_TYPE
599 ? ConfigurationManager::GROUP_TYPE_NAME_CONTEXT
600 : (groupTypeId == ConfigurationManager::GroupType::BACKBONE_TYPE
601 ? ConfigurationManager::GROUP_TYPE_NAME_BACKBONE
602 : (groupTypeId == ConfigurationManager::GroupType::ITERATE_TYPE
603 ? ConfigurationManager::GROUP_TYPE_NAME_ITERATE
604 : (groupTypeId == ConfigurationManager::GroupType::
606 ? ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION
607 : ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)));
618 const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap)
620 bool isContext =
true;
621 bool isBackbone =
true;
622 bool isIterate =
true;
624 bool inContext =
false;
625 bool inBackbone =
false;
626 bool inIterate =
false;
627 unsigned int matchCount = 0;
629 for(
auto& memberPair : memberMap)
634 if(memberPair.first == CONTEXT_SUBSYSTEM_OPTIONAL_TABLE)
641 if(memberPair.first == contextMemberString)
653 __SS__ <<
"This group is an incomplete match to a Context group.\n";
654 ss <<
"\nTo be a Context group, the members must exactly match "
655 <<
"the following members (w/ or wo/ the optional table "
656 << CONTEXT_SUBSYSTEM_OPTIONAL_TABLE <<
"):\n";
659 ss << ++i <<
". " << memberName <<
"\n";
660 ss <<
"\nThe members are as follows::\n";
662 for(
const auto& memberPairTmp : memberMap)
663 ss << ++i <<
". " << memberPairTmp.first <<
"\n";
671 if(memberPair.first == backboneMemberString)
683 __SS__ <<
"This group is an incomplete match to a Backbone group.\n";
684 ss <<
"\nTo be a Backbone group, the members must exactly match "
685 <<
"the following members:\n";
688 ss << ++i <<
". " << memberName <<
"\n";
689 ss <<
"\nThe members are as follows::\n";
691 for(
const auto& memberPairTmp : memberMap)
692 ss << ++i <<
". " << memberPairTmp.first <<
"\n";
701 if(memberPair.first == iterateMemberString)
713 __SS__ <<
"This group is an incomplete match to a Iterate group.\n";
714 ss <<
"\nTo be a Iterate group, the members must exactly match "
715 <<
"the following members:\n";
718 ss << ++i <<
". " << memberName <<
"\n";
719 ss <<
"\nThe members are as follows::\n";
721 for(
const auto& memberPairTmp : memberMap)
722 ss << ++i <<
". " << memberPairTmp.first <<
"\n";
731 __SS__ <<
"This group is an incomplete match to a Context group: "
732 <<
" Size=" << matchCount <<
" but should be "
734 ss <<
"\nThe members currently are...\n";
736 for(
auto& memberPair : memberMap)
737 ss << ++i <<
". " << memberPair.first <<
"\n";
738 ss <<
"\nThe expected Context members are...\n";
741 ss << ++i <<
". " << memberName <<
"\n";
748 __SS__ <<
"This group is an incomplete match to a Backbone group: "
749 <<
" Size=" << matchCount <<
" but should be "
751 ss <<
"\nThe members currently are...\n";
753 for(
auto& memberPair : memberMap)
754 ss << ++i <<
". " << memberPair.first <<
"\n";
755 ss <<
"\nThe expected Backbone members are...\n";
758 ss << ++i <<
". " << memberName <<
"\n";
765 __SS__ <<
"This group is an incomplete match to a Iterate group: "
766 <<
" Size=" << matchCount <<
" but should be "
768 ss <<
"\nThe members currently are...\n";
770 for(
auto& memberPair : memberMap)
771 ss << ++i <<
". " << memberPair.first <<
"\n";
772 ss <<
"\nThe expected Iterate members are...\n";
775 ss << ++i <<
". " << memberName <<
"\n";
781 ? ConfigurationManager::GroupType::CONTEXT_TYPE
783 ? ConfigurationManager::GroupType::BACKBONE_TYPE
785 ? ConfigurationManager::GroupType::ITERATE_TYPE
786 : ConfigurationManager::GroupType::CONFIGURATION_TYPE));
793 const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap)
804 #define OUT out << tabStr << commentStr
805 #define PUSHTAB tabStr += "\t"
806 #define POPTAB tabStr.resize(tabStr.size() - 1)
807 #define PUSHCOMMENT commentStr += "# "
808 #define POPCOMMENT commentStr.resize(commentStr.size() - 2)
810 void ConfigurationManager::dumpMacroMakerModeFhicl()
812 std::string filepath =
813 __ENV__(
"USER_DATA") + std::string(
"/") +
"MacroMakerModeConfigurations";
814 mkdir(filepath.c_str(), 0755);
815 filepath +=
"/MacroMakerModeFhiclDump.fcl";
816 __GEN_COUT__ <<
"dumpMacroMakerModeFhicl: " << filepath << __E__;
822 std::string tabStr =
"";
823 std::string commentStr =
"";
825 out.open(filepath, std::fstream::out | std::fstream::trunc);
828 __SS__ <<
"Failed to open MacroMaker mode fcl file for configuration dump: "
829 << filepath << __E__;
835 std::vector<std::pair<std::string, ConfigurationTree>> fes =
841 if(!fe.second.status())
846 OUT << fe.first <<
": {" << __E__;
851 OUT <<
"FEInterfacePluginName"
853 <<
"\"" << fe.second.getNode(
"FEInterfacePluginName").getValueAsString()
856 recursiveTreeToFhicl(
857 fe.second.getNode(
"LinkToFETypeTable"), out, tabStr, commentStr);
860 OUT <<
"} //end " << fe.first << __E__ << __E__;
866 __SS__ <<
"Failed to complete MacroMaker mode fcl "
867 "file configuration dump due to error."
873 catch(
const std::runtime_error& e)
875 ss <<
"Exception message: " << e.what();
877 catch(
const std::exception& e)
879 ss <<
"Exception message: " << e.what();
881 __GEN_COUT_ERR__ << ss.str();
899 std::string& tabStr ,
900 std::string& commentStr ,
905 __COUT__ << __COUT_HDR_P__ <<
"Depth limit reached. Ending recursion." << __E__;
911 if(depth == (
unsigned int)-1)
931 std::vector<std::pair<std::string, ConfigurationTree>> children =
933 for(
auto& child : children)
934 recursiveTreeToFhicl(child.second, out, tabStr, commentStr, depth - 1);
938 <<
" group link record" << __E__;
950 std::vector<std::pair<std::string, ConfigurationTree>> fields =
954 for(
unsigned int i = 0; i < fields.size() - 3; ++i)
958 if(fields[i].second.isLinkNode())
960 recursiveTreeToFhicl(
961 fields[i].second, out, tabStr, commentStr, depth - 1);
966 OUT << fields[i].second.getFieldName() <<
": \t";
967 if(fields[i].second.isValueNumberDataType())
968 OUT << fields[i].second.getValueAsString() << __E__;
970 OUT <<
"\"" << fields[i].second.getValueAsString() <<
"\"" << __E__;
983 <<
" link record" << __E__;
992 const std::string& dumpType,
993 const std::string& configurationAlias,
994 const std::string& logEntry,
995 const std::string& activeUsers,
996 std::ostream& altOut )
998 time_t rawtime = time(0);
999 __GEN_COUT__ <<
"filePath = " << filePath << __E__;
1000 __GEN_COUT__ <<
"dumpType = " << dumpType << __E__;
1004 fs.open(filePath, std::fstream::out | std::fstream::trunc);
1015 __SS__ <<
"Invalid file path to dump active configuration. File " << filePath
1016 <<
" could not be opened!" << __E__;
1017 __GEN_COUT_ERR__ << ss.str();
1023 (*out) <<
"#################################" << __E__;
1024 (*out) <<
"This is an ots configuration dump.\n" << __E__;
1025 (*out) <<
"Source database is $ARTDAQ_DATABASE_URI: "
1026 << __ENV__(
"ARTDAQ_DATABASE_URI") << __E__;
1028 (*out) <<
"Original location of dump: " << __ENV__(
"HOSTNAME")
1029 <<
":" << filePath << __E__;
1030 (*out) <<
"\nActive ots users: \t"
1031 << (activeUsers.size() ? activeUsers :
"no active users") << __E__;
1032 (*out) <<
"Type of dump: \t\t" << dumpType << __E__;
1033 (*out) <<
"Time of dump: \t\t" << rawtime;
1035 struct tm* timeinfo = localtime(&rawtime);
1037 strftime(buffer, 100,
"%c %Z", timeinfo);
1038 (*out) <<
" \t" << buffer << __E__;
1042 std::pair<std::string, ots::TableGroupKey> configurationTableGroup =
1044 (*out) <<
"Configuration Alias: \t\t\t" << configurationAlias <<
"\n";
1045 (*out) <<
"Configuration Alias translation: \t" << configurationTableGroup.first
1046 <<
"(" << configurationTableGroup.second <<
")\n\n";
1049 (*out) <<
"User Log Entry (" << logEntry.size() <<
" chars):\n"
1050 << logEntry << __E__;
1059 std::ostream* out) {
1060 std::map<std::string, std::pair<std::string, TableGroupKey>> activeGroups =
1063 (*out) <<
"\n\n************************" << __E__;
1064 (*out) <<
"Active Groups:" << __E__;
1065 for(
auto& group : activeGroups)
1067 (*out) <<
"\t" << group.first <<
" := " << group.second.first <<
" ("
1068 << group.second.second <<
")" << __E__;
1073 std::ostream* out) {
1076 (*out) <<
"\n\n************************" << __E__;
1077 (*out) <<
"Active Tables:" << __E__;
1078 (*out) <<
"Active Tables count = " << activeTables.size() << __E__;
1081 for(
auto& table : activeTables)
1083 (*out) <<
"\t" << ++i <<
". " << table.first <<
"-v" << table.second << __E__;
1088 std::ostream* out) {
1089 std::map<std::string, std::pair<std::string, TableGroupKey>> activeGroups =
1091 (*out) <<
"\n\n************************" << __E__;
1092 (*out) <<
"Active Group Members:" << __E__;
1094 for(
auto& group : activeGroups)
1096 (*out) <<
"\t" << group.first <<
" := " << group.second.first <<
" ("
1097 << group.second.second <<
")" << __E__;
1099 if(group.second.first ==
"")
1102 <<
"Empty group name. Assuming no active group." << __E__;
1107 std::map<std::string , std::string > groupAliases;
1108 std::string groupComment;
1109 std::string groupAuthor;
1110 std::string groupCreateTime;
1111 time_t groupCreateTime_t;
1114 group.second.second,
1126 (*out) <<
"\t\tGroup Comment: \t" << groupComment << __E__;
1127 (*out) <<
"\t\tGroup Author: \t" << groupAuthor << __E__;
1129 sscanf(groupCreateTime.c_str(),
"%ld", &groupCreateTime_t);
1130 (*out) <<
"\t\tGroup Create Time: \t" << ctime(&groupCreateTime_t) << __E__;
1134 (*out) <<
"\t\tMember table count = " << memberMap.size() << __E__;
1135 tableCount += memberMap.size();
1138 for(
auto& member : memberMap)
1140 (*out) <<
"\t\t\t" << ++i <<
". " << member.first <<
"-v" << member.second
1144 (*out) <<
"\nActive Group Members total table count = " << tableCount << __E__;
1148 std::ostream* out) {
1151 (*out) <<
"\n\n************************" << __E__;
1152 (*out) <<
"Active Table Contents (table count = " << activeTables.size()
1155 for(
auto& table : activeTables)
1157 (*out) <<
"\n\n=============================================================="
1160 (*out) <<
"=================================================================="
1163 (*out) <<
"\t" << ++i <<
". " << table.first <<
"-v" << table.second << __E__;
1165 cfgMgr->nameToTableMap_.find(table.first)->second->print(*out);
1169 if(dumpType ==
"GroupKeys")
1171 localDumpActiveGroups(
this, out);
1173 else if(dumpType ==
"TableVersions")
1175 localDumpActiveTables(
this, out);
1177 else if(dumpType ==
"GroupKeysAndTableVersions")
1179 localDumpActiveGroups(
this, out);
1180 localDumpActiveTables(
this, out);
1182 else if(dumpType ==
"All")
1184 localDumpActiveGroups(
this, out);
1185 localDumpActiveGroupMembers(
this, out);
1186 localDumpActiveTables(
this, out);
1187 localDumpActiveTableContents(
this, out);
1192 <<
"Invalid dump type '" << dumpType
1193 <<
"' given during dumpActiveConfiguration(). Valid types are as follows:\n"
1201 <<
"GroupsKeysAndTableVersions"
1206 "\n\nPlease change the State Machine configuration to a valid dump type."
1223 const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap,
1224 std::string* accumulatedWarnings )
1226 __GEN_COUTTV__(runTimeSeconds());
1231 bool usingCache =
false;
1232 if(memberMap.size() > 10 && nameToTableMap_.size() &&
1233 nameToTableMap_.find(memberMap.begin()->first) != nameToTableMap_.end() &&
1234 nameToTableMap_.at(memberMap.begin()->first)->isStored(memberMap.begin()->second))
1239 __GEN_COUTT__ <<
"Using cache!" << __E__;
1243 const int numOfThreads =
1245 if(memberMap.size() <= 2 || usingCache ||
1250 for(
auto& memberPair : memberMap)
1262 tmpTableBasePtr =
nullptr;
1263 if(nameToTableMap_.find(memberPair.first) != nameToTableMap_.end())
1264 tmpTableBasePtr = nameToTableMap_.at(memberPair.first);
1266 std::string getError =
"";
1269 theInterface_->get(tmpTableBasePtr,
1278 catch(
const std::runtime_error& e)
1280 __SS__ <<
"Failed to load member table '" << memberPair.first <<
"-v"
1281 << memberPair.second <<
"' - here is the error: \n\n"
1282 << e.what() << __E__;
1284 ss <<
"\nIf the table '" << memberPair.first
1285 <<
"' should not exist, then please remove it from the group. If it "
1286 "should exist, then it "
1287 <<
"seems to have a problem; use the Table Editor to fix the table "
1289 "edit the table content to match the table definition."
1293 if(accumulatedWarnings)
1294 getError = ss.str();
1300 __SS__ <<
"Failed to load member table '" << memberPair.first <<
" -v"
1301 << memberPair.second <<
"' due to unknown error!" << __E__;
1306 catch(
const std::exception& e)
1308 ss <<
"Exception message: " << e.what();
1314 ss <<
"\nIf the table '" << memberPair.first
1315 <<
"' should not exist, then please remove it from the group. If it "
1316 "should exist, then it "
1317 <<
"seems to have a problem; use the Table Editor to fix the table "
1319 "edit the table content to match the table definition."
1323 if(accumulatedWarnings)
1324 getError = ss.str();
1330 if(!tmpTableBasePtr)
1332 __SS__ <<
"Null pointer returned for table '" << memberPair.first <<
" -v"
1333 << memberPair.second <<
".' Was the table info deleted?" << __E__;
1334 __GEN_COUT_ERR__ << ss.str();
1336 nameToTableMap_.erase(memberPair.first);
1337 if(accumulatedWarnings)
1339 *accumulatedWarnings += ss.str();
1346 nameToTableMap_[memberPair.first] = tmpTableBasePtr;
1347 if(nameToTableMap_[memberPair.first]->getViewP())
1352 if(accumulatedWarnings && getError !=
"")
1354 __SS__ <<
"Error caught during '" << memberPair.first <<
" -v"
1355 << memberPair.second <<
"' table retrieval: \n"
1356 << getError << __E__;
1357 __GEN_COUT_ERR__ << ss.str();
1358 *accumulatedWarnings += ss.str();
1363 __SS__ << nameToTableMap_[memberPair.first]->getTableName() <<
" -v"
1364 << memberPair.second <<
": View version not activated properly!";
1371 __GEN_COUT__ <<
" PROCESSOR_COUNT " <<
PROCESSOR_COUNT <<
" ==> " << numOfThreads
1372 <<
" threads for loading member map of size " << memberMap.size()
1375 int threadsLaunched = 0;
1376 int foundThreadIndex = 0;
1377 std::string threadErrors;
1378 std::mutex threadMutex;
1379 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
1380 for(
int i = 0; i < numOfThreads; ++i)
1381 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
1382 std::vector<TableBase*> tmpTableBasePtrs;
1383 for(
int i = 0; i < numOfThreads; ++i)
1384 tmpTableBasePtrs.push_back(
nullptr);
1386 for(
auto& memberPair : memberMap)
1388 if(threadsLaunched >= numOfThreads)
1391 foundThreadIndex = -1;
1392 while(foundThreadIndex == -1)
1394 for(
int i = 0; i < numOfThreads; ++i)
1395 if(*(threadDone[i]))
1397 foundThreadIndex = i;
1400 if(foundThreadIndex == -1)
1402 __GEN_COUTT__ <<
"Waiting for available thread..." << __E__;
1406 threadsLaunched = numOfThreads - 1;
1408 __GEN_COUTT__ <<
"Starting filling thread... " << foundThreadIndex <<
" for "
1409 << memberPair.first <<
" -v" << memberPair.second << __E__;
1410 *(threadDone[foundThreadIndex]) =
false;
1418 tmpTableBasePtrs[foundThreadIndex] =
nullptr;
1419 if(nameToTableMap_.find(memberPair.first) != nameToTableMap_.end())
1420 tmpTableBasePtrs[foundThreadIndex] = nameToTableMap_.at(memberPair.first);
1424 std::map<std::string, ots::TableBase*>* theNameToTableMap,
1426 std::string theTableName,
1428 std::string* theThreadErrors,
1429 std::mutex* theThreadMutex,
1430 std::shared_ptr<std::atomic<bool>> theThreadDone) {
1431 ConfigurationManager::fillTableThread(theInterface,
1442 tmpTableBasePtrs[foundThreadIndex],
1447 threadDone[foundThreadIndex])
1457 foundThreadIndex = -1;
1458 for(
int i = 0; i < numOfThreads; ++i)
1459 if(!*(threadDone[i]))
1461 foundThreadIndex = i;
1464 if(foundThreadIndex != -1)
1466 __GEN_COUT_TYPE__(TLVL_DEBUG + 2)
1467 << __COUT_HDR__ <<
"Waiting for thread to finish... "
1468 << foundThreadIndex << __E__;
1471 }
while(foundThreadIndex != -1);
1472 __GEN_COUTT__ <<
"All threads done." << __E__;
1474 if(threadErrors !=
"")
1476 __SS__ <<
"Error identified in threads during loading of member map: \n"
1477 << threadErrors << __E__;
1478 __GEN_COUTT__ <<
"\n" << ss.str() << __E__;
1479 if(accumulatedWarnings)
1480 *accumulatedWarnings += ss.str();
1486 __GEN_COUTT__ <<
"loadMemberMap end runTimeSeconds()=" << runTimeSeconds() << __E__;
1512 const std::string& groupName,
1515 std::map<std::string /*table name*/, TableVersion>*
1518 std::string* accumulatedWarnings ,
1519 std::string* groupComment ,
1520 std::string* groupAuthor ,
1521 std::string* groupCreateTime ,
1522 bool doNotLoadMembers ,
1523 std::string* groupTypeString ,
1524 std::map<std::string /*name*/, std::string /*alias*/>*
1526 ConfigurationManager::LoadGroupType
1527 onlyLoadIfBackboneOrContext ,
1528 bool ignoreVersionTracking )
1532 *groupComment = ConfigurationManager::UNKNOWN_INFO;
1534 *groupAuthor = ConfigurationManager::UNKNOWN_INFO;
1536 *groupCreateTime = ConfigurationManager::UNKNOWN_TIME;
1538 *groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
1540 __GEN_COUTT__ <<
"No group type requested." << __E__;
1567 __GEN_COUTT__ <<
"Loading Table Group: " << groupName <<
"(" << groupKey <<
")"
1580 progressBar->
step();
1583 auto metaTablePair = memberMap.find(TableBase::GROUP_METADATA_TABLE_NAME);
1584 if(metaTablePair != memberMap.end())
1587 if(groupAliases || groupComment || groupAuthor || groupCreateTime)
1589 std::lock_guard<std::mutex> lock(metaDataTableMutex_);
1592 while(groupMetadataTable_.getView().getNumberOfRows())
1593 groupMetadataTable_.getViewP()->
deleteRow(0);
1598 theInterface_->fill(&groupMetadataTable_, metaTablePair->second);
1600 catch(
const std::runtime_error& e)
1603 <<
"Failed to load " << groupMetadataTable_.
getTableName() <<
"-v"
1604 << metaTablePair->second <<
". Metadata error: " << e.what()
1610 <<
"Failed to load " << groupMetadataTable_.
getTableName() <<
"-v"
1611 << metaTablePair->second <<
". Ignoring unknown metadata error. "
1616 if(groupMetadataTable_.getView().getNumberOfRows() != 1)
1618 groupMetadataTable_.
print();
1619 __GEN_COUT_ERR__ <<
"Ignoring that groupMetadataTable_ has wrong "
1620 "number of rows for '"
1621 << groupName <<
"(" << groupKey
1623 "be 1. Going with anonymous defaults."
1627 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
1628 groupMetadataTable_.getViewP()->
deleteRow(0);
1629 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
1630 groupMetadataTable_.getViewP()->
addRow();
1639 0, ConfigurationManager::METADATA_COL_ALIASES),
1643 0, ConfigurationManager::METADATA_COL_COMMENT);
1646 0, ConfigurationManager::METADATA_COL_AUTHOR);
1649 0, ConfigurationManager::METADATA_COL_TIMESTAMP);
1653 memberMap.erase(metaTablePair);
1658 __GEN_COUT_ERR__ <<
"Ignoring that groupMetadataTable_ is missing for group '"
1659 << groupName <<
"(" << groupKey
1660 <<
"). Going with anonymous defaults." << __E__;
1671 std::map<std::string, std::string>& aliasMap = *groupAliases;
1672 std::map<std::string , std::map<std::string ,
TableVersion>>
1682 for(
auto& aliasPair : aliasMap)
1685 if(memberMap.find(aliasPair.first) != memberMap.end())
1687 __GEN_COUT__ <<
"Group member '" << aliasPair.first
1688 <<
"' was found in group member map!" << __E__;
1689 __GEN_COUT__ <<
"Looking for alias '" << aliasPair.second
1690 <<
"' in active version aliases..." << __E__;
1692 if(versionAliases.find(aliasPair.first) == versionAliases.end() ||
1693 versionAliases[aliasPair.first].find(aliasPair.second) ==
1694 versionAliases[aliasPair.first].end())
1696 __SS__ <<
"Group '" << groupName <<
"(" << groupKey
1697 <<
")' requires table version alias '" << aliasPair.first
1698 <<
":" << aliasPair.second
1699 <<
",' which was not found in the active Backbone!"
1704 memberMap[aliasPair.first] =
1705 versionAliases[aliasPair.first][aliasPair.second];
1706 __GEN_COUT__ <<
"Version alias translated to " << aliasPair.first
1713 *groupMembers = memberMap;
1716 progressBar->
step();
1718 ConfigurationManager::GroupType groupType =
1719 ConfigurationManager::GroupType::CONFIGURATION_TYPE;
1728 __GEN_COUTT__ <<
"No group type requested." << __E__;
1730 if(doNotLoadMembers)
1734 if(!groupTypeString)
1737 if(onlyLoadIfBackboneOrContext ==
1738 ConfigurationManager::LoadGroupType::ONLY_BACKBONE_OR_CONTEXT_TYPES &&
1739 groupType != ConfigurationManager::GroupType::CONTEXT_TYPE &&
1740 groupType != ConfigurationManager::GroupType::BACKBONE_TYPE)
1742 __GEN_COUT__ <<
"Not loading group because it is not of type Context or "
1743 "Backbone (it is type '"
1747 else if(onlyLoadIfBackboneOrContext ==
1748 ConfigurationManager::LoadGroupType::ONLY_BACKBONE_TYPE &&
1749 groupType != ConfigurationManager::GroupType::BACKBONE_TYPE)
1751 __GEN_COUT__ <<
"Not loading group because it is not of type "
1752 "Backbone (it is type '"
1759 <<
"------------------------------------- init start \t [for all "
1767 std::string groupToDeactivate =
1768 groupType == ConfigurationManager::GroupType::CONTEXT_TYPE
1769 ? theContextTableGroup_
1770 : (groupType == ConfigurationManager::GroupType::BACKBONE_TYPE
1771 ? theBackboneTableGroup_
1773 ConfigurationManager::GroupType::ITERATE_TYPE
1774 ? theIterateTableGroup_
1775 : theConfigurationTableGroup_));
1778 if(groupToDeactivate !=
"")
1792 progressBar->
step();
1797 progressBar->
step();
1799 __GEN_COUTT__ <<
"loadMemberMap() completed." << __E__;
1801 if(accumulatedWarnings)
1806 if(*accumulatedWarnings !=
"")
1809 <<
"Errors detected while loading Table Group: " << groupName
1810 <<
"(" << groupKey <<
"). Ignoring the following errors: "
1812 << *accumulatedWarnings << __E__;
1817 progressBar->
step();
1819 __GEN_COUTT__ <<
"Tree view check complete." << __E__;
1827 << numOfThreads <<
" threads for initializing tables."
1829 if(groupType != ConfigurationManager::GroupType::CONFIGURATION_TYPE ||
1832 for(
auto& memberPair : memberMap)
1835 if(!ignoreVersionTracking &&
1836 ConfigurationInterface::isVersionTrackingEnabled() &&
1837 memberPair.second.isScratchVersion())
1840 <<
"Error while activating member Table '"
1841 << nameToTableMap_[memberPair.first]->getTableName()
1842 <<
"-v" << memberPair.second <<
" for Table Group '"
1843 << groupName <<
"(" << groupKey
1844 <<
")'. When version tracking is enabled, Scratch views"
1845 <<
" are not allowed! Please only use unique, persistent "
1846 "versions when version tracking is enabled."
1855 nameToTableMap_.at(memberPair.first)->init(
this);
1857 catch(std::runtime_error& e)
1859 __SS__ <<
"Error detected calling " << memberPair.first
1860 <<
".init()!\n\n " << e.what() << __E__;
1862 if(accumulatedWarnings)
1864 *accumulatedWarnings += ss.str();
1874 __SS__ <<
"Unknown Error detected calling "
1875 << memberPair.first <<
".init()!\n\n " << __E__;
1880 catch(
const std::exception& e)
1882 ss <<
"Exception message: " << e.what();
1889 if(accumulatedWarnings)
1891 *accumulatedWarnings += ss.str();
1894 __GEN_COUT_WARN__ << ss.str();
1900 int threadsLaunched = 0;
1901 int foundThreadIndex = 0;
1902 std::mutex threadMutex;
1903 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
1904 for(
int i = 0; i < numOfThreads; ++i)
1905 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
1907 if(!ignoreVersionTracking &&
1908 ConfigurationInterface::isVersionTrackingEnabled())
1909 for(
auto& memberPair : memberMap)
1912 if(memberPair.second.isScratchVersion())
1915 <<
"Error while activating member Table '"
1916 << nameToTableMap_[memberPair.first]->getTableName()
1917 <<
"-v" << memberPair.second <<
" for Table Group '"
1918 << groupName <<
"(" << groupKey
1919 <<
")'. When version tracking is enabled, Scratch "
1921 <<
" are not allowed! Please only use unique, "
1923 "versions when version tracking is enabled."
1929 for(
auto& memberPair : memberMap)
1931 if(threadsLaunched >= numOfThreads)
1934 foundThreadIndex = -1;
1935 while(foundThreadIndex == -1)
1937 for(
int i = 0; i < numOfThreads; ++i)
1938 if(*(threadDone[i]))
1940 foundThreadIndex = i;
1943 if(foundThreadIndex == -1)
1945 __GEN_COUTT__ <<
"Waiting for available thread..."
1950 threadsLaunched = numOfThreads - 1;
1952 __GEN_COUTT__ <<
"Starting init table thread... "
1953 << foundThreadIndex <<
" for " << memberPair.first
1955 *(threadDone[foundThreadIndex]) =
false;
1960 std::string* theAccumulatedWarnings,
1961 std::mutex* theThreadMutex,
1962 std::shared_ptr<std::atomic<bool>> theThreadDone) {
1963 ConfigurationManager::initTableThread(
1966 theAccumulatedWarnings,
1971 nameToTableMap_.at(memberPair.first),
1972 accumulatedWarnings,
1974 threadDone[foundThreadIndex])
1984 foundThreadIndex = -1;
1985 for(
int i = 0; i < numOfThreads; ++i)
1986 if(!*(threadDone[i]))
1988 foundThreadIndex = i;
1991 if(foundThreadIndex != -1)
1993 __GEN_COUTT__ <<
"Waiting for thread to finish... "
1994 << foundThreadIndex << __E__;
1997 }
while(foundThreadIndex != -1);
2003 progressBar->
step();
2012 if(groupType == ConfigurationManager::GroupType::CONTEXT_TYPE)
2018 theContextTableGroup_ = groupName;
2019 theContextTableGroupKey_ =
2020 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2022 else if(groupType == ConfigurationManager::GroupType::BACKBONE_TYPE)
2027 theBackboneTableGroup_ = groupName;
2028 theBackboneTableGroupKey_ =
2029 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2031 else if(groupType == ConfigurationManager::GroupType::ITERATE_TYPE)
2037 theIterateTableGroup_ = groupName;
2038 theIterateTableGroupKey_ =
2039 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2046 theConfigurationTableGroup_ = groupName;
2047 theConfigurationTableGroupKey_ =
2048 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2053 progressBar->
step();
2057 <<
"------------------------------------- init complete \t [for all "
2067 std::pair<std::string, TableGroupKey>(groupName,
TableGroupKey(groupKey));
2073 catch(
const std::runtime_error& e)
2075 __SS__ <<
"Error occurred while loading table group '" << groupName <<
"("
2076 << groupKey <<
")': \n"
2077 << e.what() << __E__;
2079 if(accumulatedWarnings)
2080 *accumulatedWarnings += ss.str();
2086 __SS__ <<
"An unknown error occurred while loading table group '"
2087 << groupName <<
"(" << groupKey <<
")." << __E__;
2092 catch(
const std::exception& e)
2094 ss <<
"Exception message: " << e.what();
2099 if(accumulatedWarnings)
2100 *accumulatedWarnings += ss.str();
2106 __GEN_COUTT__ <<
"loadTableGroup() complete." << __E__;
2108 std::make_pair(std::make_pair(groupName,
TableGroupKey(groupKey)), memberMap);
2113 __GEN_COUTT__ <<
"loadTableGroup() failed." << __E__;
2116 lastFailedGroupLoad_[ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN] =
2117 std::pair<std::string, TableGroupKey>(groupName,
TableGroupKey(groupKey));
2123 catch(
const std::runtime_error& e)
2125 __SS__ <<
"Error occurred while loading table group '" << groupName <<
"("
2126 << groupKey <<
")': \n"
2127 << e.what() << __E__;
2129 if(accumulatedWarnings)
2130 *accumulatedWarnings += ss.str();
2136 __SS__ <<
"An unknown error occurred while loading table group '" << groupName
2137 <<
"(" << groupKey <<
")." << __E__;
2142 catch(
const std::exception& e)
2144 ss <<
"Exception message: " << e.what();
2151 if(accumulatedWarnings)
2152 *accumulatedWarnings += ss.str();
2164 const std::map<std::string, TableVersion>& memberMap,
2165 const std::string& groupName ,
2168 bool ignoreVersionTracking )
2173 ConfigurationManager::GroupType groupType =
getTypeOfGroup(memberMap);
2177 __GEN_COUT__ <<
"------------------------------------- cacheCopy init start "
2179 "plug-ins in member map"
2184 std::string groupToDeactivate =
2185 groupType == ConfigurationManager::GroupType::CONTEXT_TYPE
2186 ? theContextTableGroup_
2187 : (groupType == ConfigurationManager::GroupType::BACKBONE_TYPE
2188 ? theBackboneTableGroup_
2189 : (groupType == ConfigurationManager::GroupType::ITERATE_TYPE
2190 ? theIterateTableGroup_
2191 : theConfigurationTableGroup_));
2194 if(groupToDeactivate !=
"")
2211 for(
auto& memberPair : memberMap)
2213 __GEN_COUTT__ <<
"Copying " << memberPair.first <<
"-v" << memberPair.second
2217 if(nameToTableMap_.find(memberPair.first) == nameToTableMap_.end())
2220 theInterface_->get(table,
2227 nameToTableMap_[memberPair.first] = table;
2229 nameToTableMap_.at(memberPair.first)
2231 ->getView(memberPair.second),
2234 ->getView(memberPair.second)
2242 __GEN_COUTT__ <<
"Done with member copy loop." << __E__;
2248 std::string accumulatedWarnings;
2251 << numOfThreads <<
" threads for initializing tables." << __E__;
2252 if(groupType != ConfigurationManager::GroupType::CONFIGURATION_TYPE ||
2255 for(
auto& memberPair : memberMap)
2258 if(!ignoreVersionTracking &&
2259 ConfigurationInterface::isVersionTrackingEnabled() &&
2260 memberPair.second.isScratchVersion())
2262 __SS__ <<
"Error while activating member Table '"
2263 << nameToTableMap_[memberPair.first]->getTableName()
2264 <<
"-v" << memberPair.second
2265 <<
" for member map. When version tracking is enabled, "
2267 <<
" are not allowed! Please only use unique, persistent "
2268 "versions when version tracking is enabled."
2277 nameToTableMap_.at(memberPair.first)->init(
this);
2279 catch(std::runtime_error& e)
2281 __SS__ <<
"Error detected calling " << memberPair.first
2282 <<
".init()!\n\n " << e.what() << __E__;
2283 accumulatedWarnings += ss.str();
2287 __SS__ <<
"Unknown Error detected calling " << memberPair.first
2288 <<
".init()!\n\n " << __E__;
2293 catch(
const std::exception& e)
2295 ss <<
"Exception message: " << e.what();
2300 accumulatedWarnings += ss.str();
2306 int threadsLaunched = 0;
2307 int foundThreadIndex = 0;
2308 std::mutex threadMutex;
2309 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
2310 for(
int i = 0; i < numOfThreads; ++i)
2311 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
2313 if(!ignoreVersionTracking &&
2314 ConfigurationInterface::isVersionTrackingEnabled())
2315 for(
auto& memberPair : memberMap)
2318 if(memberPair.second.isScratchVersion())
2321 <<
"Error while activating member Table '"
2322 << nameToTableMap_[memberPair.first]->getTableName()
2323 <<
"-v" << memberPair.second
2324 <<
" for member map. When version tracking is enabled, "
2326 <<
" are not allowed! Please only use unique, persistent "
2327 "versions when version tracking is enabled."
2333 for(
auto& memberPair : memberMap)
2335 if(threadsLaunched >= numOfThreads)
2338 foundThreadIndex = -1;
2339 while(foundThreadIndex == -1)
2341 for(
int i = 0; i < numOfThreads; ++i)
2342 if(*(threadDone[i]))
2344 foundThreadIndex = i;
2347 if(foundThreadIndex == -1)
2349 __GEN_COUTT__ <<
"Waiting for available thread..."
2354 threadsLaunched = numOfThreads - 1;
2356 __GEN_COUTT__ <<
"Starting init table thread... " << foundThreadIndex
2357 <<
" for " << memberPair.first << __E__;
2358 *(threadDone[foundThreadIndex]) =
false;
2363 std::string* theAccumulatedWarnings,
2364 std::mutex* theThreadMutex,
2365 std::shared_ptr<std::atomic<bool>> theThreadDone) {
2366 ConfigurationManager::initTableThread(cfgMgr,
2368 theAccumulatedWarnings,
2373 nameToTableMap_.at(memberPair.first),
2374 &accumulatedWarnings,
2376 threadDone[foundThreadIndex])
2386 foundThreadIndex = -1;
2387 for(
int i = 0; i < numOfThreads; ++i)
2388 if(!*(threadDone[i]))
2390 foundThreadIndex = i;
2393 if(foundThreadIndex != -1)
2395 __GEN_COUTT__ <<
"Waiting for thread to finish... "
2396 << foundThreadIndex << __E__;
2399 }
while(foundThreadIndex != -1);
2403 if(accumulatedWarnings !=
"")
2405 __GEN_COUT__ <<
"Activating the member map after copying cache had the "
2406 "following warnings: "
2407 << accumulatedWarnings << __E__;
2418 if(groupType == ConfigurationManager::GroupType::CONTEXT_TYPE)
2424 theContextTableGroup_ = groupName;
2425 theContextTableGroupKey_ =
2426 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2428 else if(groupType == ConfigurationManager::GroupType::BACKBONE_TYPE)
2433 theBackboneTableGroup_ = groupName;
2434 theBackboneTableGroupKey_ =
2435 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2437 else if(groupType == ConfigurationManager::GroupType::ITERATE_TYPE)
2443 theIterateTableGroup_ = groupName;
2444 theIterateTableGroupKey_ =
2445 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2452 theConfigurationTableGroup_ = groupName;
2453 theConfigurationTableGroupKey_ =
2454 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2459 __GEN_COUT__ <<
"------------------------------------- cacheCopy init "
2460 "complete \t [for all "
2461 "plug-ins in member map"
2464 __GEN_COUTT__ <<
"Completed cache copy." << __E__;
2467 make_pair(make_pair(groupName,
TableGroupKey(groupKey)), memberMap);
2471 __GEN_COUT__ <<
"Unknown failure in cache copy." << __E__;
2474 std::pair<std::string, TableGroupKey>(groupName,
TableGroupKey(groupKey));
2481 ConfigurationManager::getGroupOfLoadedTable(
const std::string& tableName)
const
2483 for(
const auto& loadedGroup : lastGroupLoad_)
2484 if(loadedGroup.second.second.find(tableName) != loadedGroup.second.second.end())
2485 return loadedGroup.second.first;
2486 return std::make_pair(
"",
TableGroupKey(TableGroupKey::INVALID));
2493 std::string* accumulatedWarnings,
2494 std::mutex* threadMutex,
2495 std::shared_ptr<std::atomic<bool>> threadDone)
2502 table->init(cfgMgr);
2504 catch(std::runtime_error& e)
2506 __SS__ <<
"Error detected calling " << table->
getTableName() <<
".init()!\n\n "
2507 << e.what() << __E__;
2509 if(accumulatedWarnings)
2511 std::lock_guard<std::mutex> lock(*threadMutex);
2512 *accumulatedWarnings += ss.str();
2522 __SS__ <<
"Unknown Error detected calling " << table->
getTableName()
2523 <<
".init()!\n\n " << __E__;
2528 catch(
const std::exception& e)
2530 ss <<
"Exception message: " << e.what();
2536 if(accumulatedWarnings)
2538 std::lock_guard<std::mutex> lock(*threadMutex);
2539 *accumulatedWarnings += ss.str();
2542 __COUT_WARN__ << ss.str();
2545 *(threadDone) =
true;
2549 __COUT_WARN__ <<
"Error occurred initializing table '" << table->
getTableName()
2552 *(threadDone) =
true;
2557 void ConfigurationManager::fillTableThread(
2559 std::map<std::string, ots::TableBase*>* nameToTableMap,
2561 std::string tableName,
2563 std::string* threadErrors,
2564 std::mutex* threadMutex,
2565 std::shared_ptr<std::atomic<bool>> threadDone)
2568 __COUTT__ <<
"Thread fill of " << tableName <<
"-v" << version << __E__;
2578 std::string getError =
"";
2583 theInterface->get(table,
2592 catch(
const std::runtime_error& e)
2594 __SS__ <<
"Failed to load member table '" << tableName <<
"-v" << version
2595 <<
"' - here is the error: \n\n"
2596 << e.what() << __E__;
2598 ss <<
"\nIf the table '" << tableName
2599 <<
"' should not exist, then please remove it from the group. If it "
2600 "should exist, then it "
2601 <<
"seems to have a problem; use the Table Editor to fix the table "
2603 "edit the table content to match the table definition."
2608 getError = ss.str();
2614 __SS__ <<
"Failed to load member table '" << tableName <<
"-v" << version
2615 <<
"' due to unknown error!" << __E__;
2620 catch(
const std::exception& e)
2622 ss <<
"Exception message: " << e.what();
2627 ss <<
"\nIf the table '" << tableName
2628 <<
"' should not exist, then please remove it from the group. If it "
2629 "should exist, then it "
2630 <<
"seems to have a problem; use the Table Editor to fix the table "
2632 "edit the table content to match the table definition."
2637 getError = ss.str();
2643 __COUTV__(getError);
2645 __COUT_TYPE__(TLVL_TRACE + 1)
2646 << __COUT_HDR__ <<
"Checking ptr.. " << (table ?
"GOOD" :
"BAD") << __E__;
2649 __SS__ <<
"Null pointer returned for table '" << tableName
2650 <<
".' Was the table info deleted?" << __E__;
2651 __COUT_ERR__ << ss.str();
2653 std::lock_guard<std::mutex> lock(*threadMutex);
2654 nameToTableMap->erase(tableName);
2658 *threadErrors += ss.str();
2659 *(threadDone) =
true;
2667 std::lock_guard<std::mutex> lock(*threadMutex);
2668 (*nameToTableMap)[tableName] = table;
2671 if(nameToTableMap->at(tableName)->getViewP())
2673 __COUT_TYPE__(TLVL_TRACE + 1)
2675 <<
"Activated version: " << nameToTableMap->at(tableName)->getViewVersion()
2678 if(threadErrors && getError !=
"")
2680 __SS__ <<
"Error caught during '" << tableName <<
"' table retrieval: \n"
2681 << getError << __E__;
2682 __COUT_ERR__ << ss.str();
2683 std::lock_guard<std::mutex> lock(*threadMutex);
2684 *threadErrors += ss.str();
2689 __SS__ << tableName <<
": View version not activated properly!";
2693 __COUTT__ <<
"end Thread fill of " << tableName <<
"-v" << version << __E__;
2694 *(threadDone) =
true;
2696 catch(
const std::runtime_error& e)
2698 __SS__ <<
"Error occurred filling table '" << tableName <<
"-v" << version
2699 <<
"': " << e.what() << __E__;
2700 __COUT_ERR__ << ss.str();
2701 std::lock_guard<std::mutex> lock(*threadMutex);
2702 *threadErrors += ss.str();
2704 *(threadDone) =
true;
2708 __SS__ <<
"Unknwon error occurred filling table '" << tableName <<
"-v" << version
2714 catch(
const std::exception& e)
2716 ss <<
"Exception message: " << e.what();
2721 __COUT_ERR__ << ss.str();
2722 std::lock_guard<std::mutex> lock(*threadMutex);
2723 *threadErrors += ss.str();
2725 *(threadDone) =
true;
2734 std::map<std::string, std::pair<std::string, TableGroupKey>>
2738 std::map<std::string, std::pair<std::string, TableGroupKey>> retMap;
2740 retMap[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT] =
2741 std::pair<std::string, TableGroupKey>(
2742 theContextTableGroup_,
2743 theContextTableGroupKey_ ? *theContextTableGroupKey_ :
TableGroupKey());
2744 retMap[ConfigurationManager::GROUP_TYPE_NAME_BACKBONE] =
2745 std::pair<std::string, TableGroupKey>(
2746 theBackboneTableGroup_,
2747 theBackboneTableGroupKey_ ? *theBackboneTableGroupKey_ :
TableGroupKey());
2748 retMap[ConfigurationManager::GROUP_TYPE_NAME_ITERATE] =
2749 std::pair<std::string, TableGroupKey>(
2750 theIterateTableGroup_,
2751 theIterateTableGroupKey_ ? *theIterateTableGroupKey_ :
TableGroupKey());
2752 retMap[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION] =
2753 std::pair<std::string, TableGroupKey>(theConfigurationTableGroup_,
2754 theConfigurationTableGroupKey_
2755 ? *theConfigurationTableGroupKey_
2761 const std::string& ConfigurationManager::getActiveGroupName(
2762 const ConfigurationManager::GroupType& type)
const
2764 if(type == ConfigurationManager::GroupType::CONFIGURATION_TYPE)
2765 return theConfigurationTableGroup_;
2766 else if(type == ConfigurationManager::GroupType::CONTEXT_TYPE)
2767 return theContextTableGroup_;
2768 else if(type == ConfigurationManager::GroupType::BACKBONE_TYPE)
2769 return theBackboneTableGroup_;
2770 else if(type == ConfigurationManager::GroupType::ITERATE_TYPE)
2771 return theIterateTableGroup_;
2773 __SS__ <<
"IMPOSSIBLE! Invalid type requested '" << (int)type <<
"'" << __E__;
2779 const ConfigurationManager::GroupType& type)
const
2781 if(type == ConfigurationManager::GroupType::CONFIGURATION_TYPE)
2782 return theConfigurationTableGroupKey_ ? *theConfigurationTableGroupKey_
2784 else if(type == ConfigurationManager::GroupType::CONTEXT_TYPE)
2785 return theContextTableGroupKey_ ? *theContextTableGroupKey_ :
TableGroupKey();
2786 else if(type == ConfigurationManager::GroupType::BACKBONE_TYPE)
2787 return theBackboneTableGroupKey_ ? *theBackboneTableGroupKey_ :
TableGroupKey();
2788 else if(type == ConfigurationManager::GroupType::ITERATE_TYPE)
2789 return theIterateTableGroupKey_ ? *theIterateTableGroupKey_ :
TableGroupKey();
2791 __SS__ <<
"IMPOSSIBLE! Invalid type requested '" << (int)type <<
"'" << __E__;
2797 const std::string& contextUID,
const std::string& )
const
2805 const std::string& contextUID,
const std::string& applicationUID)
const
2808 contextUID +
"/LinkToApplicationTable/" + applicationUID);
2813 const std::string& contextUID,
const std::string& applicationUID)
const
2816 contextUID +
"/LinkToApplicationTable/" + applicationUID +
2817 "/LinkToSupervisorTable");
2824 auto contextChildren =
2827 for(
const auto& contextChild : contextChildren)
2829 auto appChildren = contextChild.second.getNode(
"LinkToApplicationTable")
2831 for(
const auto& appChild : appChildren)
2833 if(appChild.second.getNode(
"Class").getValue() ==
2834 "ots::GatewaySupervisor")
2835 return appChild.second;
2838 __SS__ <<
"No Gateway Supervisor node found!" << __E__;
2844 bool doNotThrowOnBrokenUIDLinks)
const
2849 if(nodeString.length() < 1)
2851 __SS__ << (
"Invalid empty node name") << __E__;
2856 size_t startingIndex = 0;
2857 while(startingIndex < nodeString.length() && nodeString[startingIndex] ==
'/')
2859 size_t endingIndex = nodeString.find(
'/', startingIndex);
2860 if(endingIndex == std::string::npos)
2861 endingIndex = nodeString.length();
2863 std::string nodeName = nodeString.substr(startingIndex, endingIndex - startingIndex);
2865 if(nodeName.length() < 1)
2875 std::string childPath =
2876 (endingIndex >= nodeString.length() ?
"" : nodeString.substr(endingIndex));
2882 if(childPath.length() > 1)
2883 return configTree.
getNode(childPath, doNotThrowOnBrokenUIDLinks);
2889 std::map<std::string, ConfigurationTree> ConfigurationManager::getNodes(
2890 const std::string& nodeString)
const
2902 std::string path =
"/";
2913 std::map<std::string, TableVersion>* memberMap,
2914 std::string* accumulatedTreeErrors)
const
2916 std::vector<std::pair<std::string, ConfigurationTree>> retVector;
2921 bool filtering = memberMap && memberMap->size();
2924 for(
auto& tablePair : nameToTableMap_)
2929 if(memberMap->find(tablePair.first) == memberMap->end())
2935 if(!tablePair.second->isActive())
2937 __SS__ <<
"Get Children with member map requires a child '"
2938 << tablePair.first <<
"' that is not active!" << __E__;
2942 catch(
const std::runtime_error& e)
2944 if(accumulatedTreeErrors)
2946 *accumulatedTreeErrors += e.what();
2947 __GEN_COUT_ERR__ <<
"Skipping " << tablePair.first
2948 <<
" since the table "
2957 if(!tablePair.second->isActive())
2961 if(accumulatedTreeErrors)
2965 std::vector<std::pair<std::string, ConfigurationTree>> newNodeChildren =
2967 for(
auto& newNodeChild : newNodeChildren)
2969 if(newNodeChild.second.getTableName() ==
2970 ConfigurationManager::DESKTOP_ICON_TABLE_NAME &&
2971 !newNodeChild.second.isEnabled())
2974 std::vector<std::pair<std::string, ConfigurationTree>>
2975 twoDeepChildren = newNodeChild.second.getChildren();
2977 for(
auto& twoDeepChild : twoDeepChildren)
2982 if(twoDeepChild.second.isLinkNode() &&
2983 twoDeepChild.second.isDisconnected() &&
2984 twoDeepChild.second.getDisconnectedTableName() !=
2985 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
2987 __SS__ <<
"At node '" + tablePair.first +
2988 "' with entry UID '" + newNodeChild.first +
2989 "' there is a disconnected child node at link "
2991 twoDeepChild.first +
"'" +
2992 " that points to table named '" +
2993 twoDeepChild.second.getDisconnectedTableName() +
2995 *accumulatedTreeErrors += ss.str();
3000 catch(std::runtime_error& e)
3002 __SS__ <<
"At node '" + tablePair.first +
3003 "' error detected descending through children:\n" +
3005 *accumulatedTreeErrors += ss.str();
3009 retVector.push_back(
3010 std::pair<std::string, ConfigurationTree>(tablePair.first, newNode));
3024 std::string* accumulatedTreeErrors)
const
3031 bool filtering = memberMap && memberMap->size();
3034 for(
auto& tablePair : nameToTableMap_)
3039 if(memberMap->find(tablePair.first) == memberMap->end())
3045 if(!tablePair.second->isActive())
3047 __SS__ <<
"Get Children with member map requires a child '"
3048 << tablePair.first <<
"' that is not active!" << __E__;
3052 catch(
const std::runtime_error& e)
3054 if(accumulatedTreeErrors)
3056 *accumulatedTreeErrors += e.what();
3057 __GEN_COUT_ERR__ <<
"Skipping " << tablePair.first
3058 <<
" since the table "
3067 if(!tablePair.second->isActive())
3071 if(accumulatedTreeErrors)
3075 std::vector<std::pair<std::string, ConfigurationTree>> newNodeChildren =
3077 for(
auto& newNodeChild : newNodeChildren)
3079 if(newNodeChild.second.getTableName() ==
3080 ConfigurationManager::DESKTOP_ICON_TABLE_NAME &&
3081 !newNodeChild.second.isEnabled())
3084 std::vector<std::pair<std::string, ConfigurationTree>>
3085 twoDeepChildren = newNodeChild.second.getChildren();
3087 for(
auto& twoDeepChild : twoDeepChildren)
3092 if(twoDeepChild.second.isLinkNode() &&
3093 twoDeepChild.second.isDisconnected() &&
3094 twoDeepChild.second.getDisconnectedTableName() !=
3095 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
3097 __SS__ <<
"At node '" + tablePair.first +
3098 "' with entry UID '" + newNodeChild.first +
3099 "' there is a disconnected child node at link "
3101 twoDeepChild.first +
"'" +
3102 " that points to table named '" +
3103 twoDeepChild.second.getDisconnectedTableName() +
3105 *accumulatedTreeErrors += ss.str();
3110 catch(std::runtime_error& e)
3112 __SS__ <<
"At node '" + tablePair.first +
3113 "' error detected descending through children:\n" +
3115 *accumulatedTreeErrors += ss.str();
3120 std::pair<std::string, ConfigurationTree>(tablePair.first, newNode));
3133 std::map<std::string, TableBase*>::const_iterator it;
3134 if((it = nameToTableMap_.find(tableName)) == nameToTableMap_.end())
3136 __SS__ <<
"Can not find table named '" << tableName
3137 <<
"' - you need to load the table before it can be used.";
3139 if(nameToTableMap_.size() == 0)
3140 ss <<
"\n\nAll tables are missing. Your configuration database connection "
3141 "may have been interrupted. Did an ssh tunnel disconnect?"
3145 ss <<
" It probably is missing from the member list of the Table "
3146 "Group that was loaded.\n"
3147 <<
"\nYou may need to enter wiz mode to remedy the situation, use the "
3171 if(!theBackboneTableGroupKey_)
3173 __GEN_COUT_WARN__ <<
"getTableGroupKey() Failed! No active backbone currently."
3179 loadTableGroup(theBackboneTableGroup_, *theBackboneTableGroupKey_);
3181 return *theBackboneTableGroupKey_;
3198 std::string systemAlias,
ProgressBar* progressBar)
3208 progressBar->
step();
3210 if(systemAlias.find(
"GROUP:") == 0)
3213 progressBar->
step();
3215 unsigned int i = strlen(
"GROUP:");
3216 unsigned int j = systemAlias.find(
':', i);
3219 progressBar->
step();
3221 return std::pair<std::string, TableGroupKey>(
3222 systemAlias.substr(i, j - i),
TableGroupKey(systemAlias.substr(j + 1)));
3224 return std::pair<std::string, TableGroupKey>(
"",
TableGroupKey());
3230 progressBar->
step();
3236 getNode(ConfigurationManager::GROUP_ALIASES_TABLE_NAME).
getNode(systemAlias);
3239 progressBar->
step();
3241 return std::pair<std::string, TableGroupKey>(
3252 progressBar->
step();
3254 return std::pair<std::string, TableGroupKey>(
"",
TableGroupKey());
3260 std::map<std::string , std::pair<std::string ,
TableGroupKey>>
3266 ConfigurationManager::LoadGroupType::
3267 ONLY_BACKBONE_TYPE);
3270 std::map<std::string ,
3274 std::vector<std::pair<std::string, ConfigurationTree>> entries =
3276 for(
auto& entryPair : entries)
3278 retMap[entryPair.first] = std::pair<std::string, TableGroupKey>(
3279 entryPair.second.getNode(
"GroupName").getValueAsString(),
3280 TableGroupKey(entryPair.second.getNode(
"GroupKey").getValueAsString()));
3288 std::map<std::string ,
3294 std::map<std::string ,
3299 std::string versionAliasesTableName =
3300 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
3301 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
3303 __SS__ <<
"Active version of VersionAliases missing!"
3304 <<
" Make sure you have a valid active Backbone Group." << __E__;
3305 __GEN_COUT_WARN__ <<
"\n" << ss.str();
3311 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
3317 std::string tableName, versionAlias;
3318 for(
auto& aliasNodePair : aliasNodePairs)
3320 tableName = aliasNodePair.second.getNode(
"TableName").getValueAsString();
3321 versionAlias = aliasNodePair.second.getNode(
"VersionAlias").getValueAsString();
3323 if(retMap.find(tableName) != retMap.end() &&
3324 retMap[tableName].find(versionAlias) != retMap[tableName].end())
3329 retMap[tableName][versionAlias] =
3330 TableVersion(aliasNodePair.second.getNode(
"Version").getValueAsString());
3340 std::map<std::string, TableVersion> retMap;
3341 for(
auto& config : nameToTableMap_)
3346 if(config.second && config.second->isActive())
3350 retMap.insert(std::pair<std::string, TableVersion>(
3351 config.first, config.second->getViewVersion()));
3383 if(theConfigurationTableGroupKey_)
3385 if(*theConfigurationTableGroupKey_ != key)
3388 return theConfigurationTableGroupKey_;
3390 return std::shared_ptr<TableGroupKey>(
new TableGroupKey(key));
3394 const std::set<std::string>& ConfigurationManager::getContextMemberNames()
3400 const std::set<std::string>& ConfigurationManager::getBackboneMemberNames()
3406 const std::set<std::string>& ConfigurationManager::getIterateMemberNames()
3411 const std::set<std::string>& ConfigurationManager::getConfigurationMemberNames(
void)
3417 for(
auto& tablePair : activeTables)
3430 void ConfigurationManager::initializeFromFhicl(
const std::string& fhiclPath)
3432 __GEN_COUT__ <<
"Initializing from fhicl: " << fhiclPath << __E__;
3437 fhicl::ParameterSet pset = LoadParameterSet(fhiclPath);
3439 if(pset.get_names().size() == 0)
3441 __GEN_SS__ <<
"Empty fcl configuration parameter set found! File: " << fhiclPath
3473 theInterface_->get(table,
3474 ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME,
3480 nameToTableMap_[ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME] = table;
3483 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3486 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3491 auto colMap = view->getColumnNamesMap();
3493 view->
setValue(
"MacroMakerFEContext", 0, colMap[
"ContextUID"]);
3494 view->
setValue(
"XDAQApplicationTable", 0, colMap[
"LinkToApplicationTable"]);
3495 view->
setValue(
"MacroMakerFEContextApps", 0, colMap[
"LinkToApplicationGroupID"]);
3496 view->
setValue(
"1", 0, colMap[TableViewColumnInfo::COL_NAME_STATUS]);
3498 __GEN_COUT__ <<
"Done adding context record..." << __E__;
3508 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
3514 nameToTableMap_[ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME] = table;
3517 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3520 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3525 auto colMap = view->getColumnNamesMap();
3527 view->
setValue(
"MacroMakerFEContextApps", 0, colMap[
"ApplicationGroupID"]);
3528 view->
setValue(
"MacroMakerFESupervisor", 0, colMap[
"ApplicationUID"]);
3529 view->
setValue(
"FESupervisorTable", 0, colMap[
"LinkToSupervisorTable"]);
3530 view->
setValue(
"MacroMakerFESupervisor", 0, colMap[
"LinkToSupervisorUID"]);
3531 view->
setValue(
"1", 0, colMap[TableViewColumnInfo::COL_NAME_STATUS]);
3532 view->
setValue(__ENV__(
"FE_SUPERVISOR_ID"), 0, colMap[
"Id"]);
3534 __GEN_COUT__ <<
"Done adding application record..." << __E__;
3541 theInterface_->get(table,
3542 "FESupervisorTable",
3548 nameToTableMap_[
"FESupervisorTable"] = table;
3551 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3554 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3559 auto colMap = view->getColumnNamesMap();
3561 view->
setValue(
"MacroMakerFESupervisor", 0, colMap[
"SupervisorUID"]);
3562 view->
setValue(
"FEInterfaceTable", 0, colMap[
"LinkToFEInterfaceTable"]);
3564 "MacroMakerFESupervisorInterfaces", 0, colMap[
"LinkToFEInterfaceGroupID"]);
3566 __GEN_COUT__ <<
"Done adding supervisor record..." << __E__;
3571 recursiveInitFromFhiclPSet(
"FEInterfaceTable" ,
3574 "MacroMakerFESupervisorInterfaces" ,
3578 for(
auto& table : nameToTableMap_)
3580 table.second->getViewP()->
init();
3586 __GEN_COUT__ <<
"================================================" << __E__;
3587 nameToTableMap_[
"FESupervisorTable"]->getViewP()->print();
3588 nameToTableMap_[
"FEInterfaceTable"]->getViewP()->print();
3591 __GEN_COUT__ <<
"Supervisors extracted from fhicl: " << sups.size() << __E__;
3593 __GEN_COUT__ <<
"Front-ends extracted from fhicl: " << fes.size() << __E__;
3595 auto a =
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME);
3596 __GEN_COUTV__(a.getValueAsString());
3598 auto b = a.getNode(
"MacroMakerFEContext");
3599 __GEN_COUTV__(b.getValueAsString());
3601 auto c = b.getNode(
"LinkToApplicationTable");
3602 __GEN_COUTV__(c.getValueAsString());
3604 auto d = c.getNode(
"MacroMakerFESupervisor");
3605 __GEN_COUTV__(d.getValueAsString());
3607 auto e = d.getNode(
"LinkToSupervisorTable");
3608 __GEN_COUTV__(e.getValueAsString());
3610 auto f = e.getNode(
"LinkToFEInterfaceTable");
3611 __GEN_COUTV__(f.getValueAsString());
3613 auto z = f.getChildrenNames();
3615 __GEN_COUTV__(z.size());
3616 auto y = f.getChildrenNames(
false ,
true );
3618 __GEN_COUTV__(y.size());
3619 auto x = f.getChildrenNames(
true ,
true );
3621 __GEN_COUTV__(x.size());
3623 auto g = f.getNode(
"dtc0");
3624 __GEN_COUTV__(g.getValueAsString());
3625 auto h = f.getNode(
"interface0");
3626 __GEN_COUTV__(h.getValueAsString());
3629 getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
3631 "MacroMakerFEContext/LinkToApplicationTable/"
3632 "MacroMakerFESupervisor/LinkToSupervisorTable")
3633 .
getNode(
"LinkToFEInterfaceTable")
3635 __GEN_COUTV__(fes.size());
3647 void ConfigurationManager::recursiveInitFromFhiclPSet(
const std::string& tableName,
3648 const fhicl::ParameterSet& pset,
3649 const std::string& recordName,
3650 const std::string& groupName,
3651 const std::string& groupLinkIndex)
3653 __GEN_COUT__ << __COUT_HDR_P__ <<
"Adding table '" << tableName <<
"' record(s)..."
3660 if(nameToTableMap_.find(tableName) == nameToTableMap_.end())
3662 __GEN_COUT__ <<
"Table not found, so making '" << tableName <<
"' instance..."
3664 theInterface_->get(table,
3671 nameToTableMap_[tableName] = table;
3676 __GEN_COUT__ <<
"Existing table found, so using '" << tableName
3677 <<
"'instance..." << __E__;
3678 table = nameToTableMap_[tableName];
3681 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3684 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3687 if(recordName !=
"")
3695 __GEN_COUTV__(recordName);
3698 unsigned int r = view->
addRow();
3699 auto colMap = view->getColumnNamesMap();
3709 __GEN_COUT__ <<
"No status column to set for '" << recordName <<
"'"
3715 __GEN_COUT__ <<
"Setting group ID for group link index '"
3716 << groupLinkIndex <<
"'" << __E__;
3719 __GEN_COUT__ <<
"Setting group ID for group link index '"
3720 << groupLinkIndex <<
"' at column " << groupIDCol <<
" to '"
3721 << groupName <<
".'" << __E__;
3723 view->
setValue(groupName, r, groupIDCol);
3727 auto names = pset.get_names();
3728 for(
const auto& colName : names)
3730 if(!pset.is_key_to_atom(colName))
3733 auto colIt = colMap.find(colName);
3734 if(colIt == colMap.end())
3736 __SS__ <<
"Field '" << colName <<
"' of record '" << recordName
3737 <<
"' in table '" << tableName <<
"' was not found in columns."
3738 <<
"\n\nHere are the existing column names:\n";
3740 for(
const auto& col : colMap)
3741 ss <<
"\n" << ++i <<
".\t" << col.first;
3746 if(view->getColumnInfo(colIt->second).
isGroupID())
3749 const std::string value = pset.get<std::string>(colName);
3750 __GEN_COUT__ <<
"Setting '" << recordName <<
"' parameter at column "
3751 << colIt->second <<
", '" << colName <<
"'\t = " << value
3757 for(
const auto& linkName : names)
3759 if(pset.is_key_to_atom(linkName))
3762 __GEN_COUTV__(linkName);
3765 unsigned int c = linkName.size() - 1;
3767 if(linkName[c] ==
'_')
3772 __SS__ <<
"Illegal link name '" << linkName
3773 <<
"' found. The format must be <Column name>_<Target table "
3774 "name>,.. for example '"
3775 <<
"LinkToFETypeTable_FEOtsUDPTemplateInterfaceTable'"
3779 std::string colName = linkName.substr(0, c);
3780 __GEN_COUTV__(colName);
3782 auto colIt = colMap.find(colName);
3783 if(colIt == colMap.end())
3785 __SS__ <<
"Link '" << colName <<
"' of record '" << recordName
3786 <<
"' in table '" << tableName <<
"' was not found in columns."
3787 <<
"\n\nHere are the existing column names:\n";
3789 for(
const auto& col : colMap)
3790 ss <<
"\n" << i <<
".\t" << col.first << __E__;
3795 std::pair<
unsigned int ,
unsigned int >
3798 view->
getChildLink(colIt->second, isGroupLink, linkPair);
3804 std::string linkTableName = linkName.substr(c + 1);
3805 __GEN_COUTV__(linkTableName);
3807 auto linkPset = pset.get<fhicl::ParameterSet>(linkName);
3808 auto linkRecords = linkPset.get_pset_names();
3809 if(!isGroupLink && linkRecords.size() > 1)
3811 __SS__ <<
"A Unique Link can only point to one record. "
3812 <<
"The specified link '" << colName <<
"' of record '"
3813 << recordName <<
"' in table '" << tableName <<
"' has "
3814 << linkRecords.size() <<
" children records specified. "
3819 if(linkRecords.size() == 0)
3821 __GEN_COUT__ <<
"No child records, so leaving link disconnected."
3826 __GEN_COUT__ <<
"Setting Link at columns [" << linkPair.first <<
","
3827 << linkPair.second <<
"]" << __E__;
3828 view->
setValue(linkTableName, r, linkPair.first);
3832 __GEN_COUT__ <<
"Setting up Unique link to " << linkRecords[0]
3835 view->
setValue(linkRecords[0], r, linkPair.second);
3837 recursiveInitFromFhiclPSet(
3839 linkPset.get<fhicl::ParameterSet>(
3846 std::string childLinkIndex =
3848 std::string groupName = recordName +
"Group";
3850 view->
setValue(groupName, r, linkPair.second);
3852 for(
const auto& groupRecord : linkRecords)
3854 __GEN_COUT__ <<
"Setting '" << childLinkIndex
3855 <<
"' Group link to '" << groupName <<
"' record '"
3856 << groupRecord <<
"'" << __E__;
3858 recursiveInitFromFhiclPSet(
3860 linkPset.get<fhicl::ParameterSet>(
3870 else if(groupName !=
"")
3874 __GEN_COUTV__(groupName);
3875 auto psets = pset.get_pset_names();
3876 for(
const auto& ps : psets)
3879 recursiveInitFromFhiclPSet(
3881 pset.get<fhicl::ParameterSet>(ps) ,
3889 __SS__ <<
"Illegal recursive parameters!" << __E__;
3892 __GEN_COUT__ << __COUT_HDR_P__ <<
"Done adding table '" << tableName
3893 <<
"' record(s)..." << __E__;
3900 bool ConfigurationManager::isOwnerFirstAppInContext()
3903 if(ownerContextUID_ ==
"" || ownerAppUID_ ==
"")
3911 auto contextChildren =
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME +
3912 "/" + ownerContextUID_)
3915 bool isFirstAppInContext =
3916 contextChildren.size() == 0 || contextChildren[0] == ownerAppUID_;
3920 return isFirstAppInContext;
3929 void ConfigurationManager::getOtherSubsystemInstanceInfo(
3930 const std::string& otherSubsystemUID,
3931 std::string* userDataPathPtr ,
3932 std::string* hostnamePtr ,
3933 std::string* usernamePtr ,
3934 std::string* fullNamePtr )
3936 __GEN_COUTTV__(otherSubsystemUID);
3939 getNode(ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE)
3941 std::string userPath = node.
getNode(
"SubsystemUserDataPath").
getValue();
3948 if(!splitPath.size() || splitPath.size() > 2)
3950 __GEN_SS__ <<
"Illegal user data path specified for subsystem '"
3951 << otherSubsystemUID <<
"': " << userPath << __E__;
3954 std::string userDataPath = splitPath[splitPath.size() - 1];
3957 for(
unsigned int i = 0; i < userDataPath.length(); ++i)
3958 if(!((userDataPath[i] >=
'a' && userDataPath[i] <=
'z') ||
3959 (userDataPath[i] >=
'A' && userDataPath[i] <=
'Z') ||
3960 (userDataPath[i] >=
'0' && userDataPath[i] <=
'9') ||
3961 userDataPath[i] ==
'-' || userDataPath[i] ==
'_' || userDataPath[i] ==
'/'))
3963 __GEN_SS__ <<
"Illegal user data path specified (no special characters "
3964 "allowed) for subsystem '"
3965 << otherSubsystemUID <<
"': " << userPath << __E__;
3970 *userDataPathPtr = userDataPath;
3972 std::string username, hostname;
3973 if(splitPath.size() == 2)
3976 std::vector<std::string> userHostSplit =
3978 __GEN_COUTTV__(userHostSplit.size());
3979 if(userHostSplit.size() == 1)
3980 hostname = userHostSplit[0];
3981 else if(userHostSplit.size() == 2)
3983 username = userHostSplit[0];
3984 hostname = userHostSplit[1];
3988 __GEN_SS__ <<
"Illegal remote username/host specified for subsystem '"
3989 << otherSubsystemUID <<
"': " << userPath << __E__;
3993 for(
unsigned int i = 0; userHostSplit.size() == 2 && i < username.length(); ++i)
3994 if(!((username[i] >=
'a' && username[i] <=
'z') ||
3995 (username[i] >=
'A' && username[i] <=
'Z') ||
3996 (username[i] >=
'0' && username[i] <=
'9') || username[i] ==
'-' ||
3997 username[i] ==
'_'))
3999 __GEN_SS__ <<
"Illegal remote username specified for subsystem '"
4000 << otherSubsystemUID <<
"': " << userPath << __E__;
4003 unsigned int ii = 0;
4004 for(
unsigned int i = 0; i < hostname.length(); ++i)
4005 if(!((hostname[i] >=
'a' && hostname[i] <=
'z') ||
4006 (hostname[i] >=
'A' && hostname[i] <=
'Z') ||
4007 (hostname[i] >=
'0' && hostname[i] <=
'9') || hostname[i] ==
'-' ||
4008 hostname[i] ==
'_'))
4010 if(hostname[i] ==
'.' && i > ii + 1)
4017 __GEN_SS__ <<
"Illegal remote hostname '" << hostname
4018 <<
"' specified for subsystem '" << otherSubsystemUID
4019 <<
"': " << userPath << __E__;
4024 else if(splitPath.size() == 1)
4026 __GEN_COUT__ <<
"Local user date path identified." << __E__;
4030 __GEN_SS__ <<
"Illegal user data path specified for subsystem '"
4031 << otherSubsystemUID <<
"': " << userPath << __E__;
4036 *hostnamePtr = hostname;
4038 *usernamePtr = username;
4043 std::map<std::string , std::pair<std::string ,
TableGroupKey>>
4044 ConfigurationManager::getOtherSubsystemActiveTableGroups(
4045 const std::string& otherSubsystemUID,
4046 std::string* userDataPathPtr ,
4047 std::string* hostnamePtr ,
4048 std::string* usernamePtr )
4050 std::map<std::string ,
4054 __GEN_COUTTV__(otherSubsystemUID);
4056 std::string userDataPath;
4057 std::string username, hostname;
4059 getOtherSubsystemInstanceInfo(otherSubsystemUID, &userDataPath, &hostname, &username);
4061 __GEN_COUTTV__(userDataPath);
4062 __GEN_COUTTV__(username);
4063 __GEN_COUTTV__(hostname);
4066 *userDataPathPtr = userDataPath;
4068 *hostnamePtr = hostname;
4070 *usernamePtr = username;
4073 std::string filename = userDataPath +
"/ServiceData/ActiveTableGroups.cfg";
4075 std::string cmdResult;
4079 std::string tmpSubsystemFilename =
4081 __GEN_COUTTV__(tmpSubsystemFilename);
4085 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + username +
"@" +
4086 hostname +
":" + filename +
" " + tmpSubsystemFilename +
" 2>&1; cat " +
4087 tmpSubsystemFilename +
" 2>&1")
4092 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + hostname +
":" +
4093 filename +
" " + tmpSubsystemFilename +
" 2>&1; cat " +
4094 tmpSubsystemFilename +
" 2>&1")
4099 __GEN_COUT__ <<
"Local user date path identified." << __E__;
4103 __GEN_COUTTV__(cmdResult);
4104 if(cmdResult.find(
"Permission denied") != std::string::npos)
4107 <<
"Permission denied accessing user data path specified for subsystem '"
4108 << otherSubsystemUID <<
"': ";
4110 ss << username <<
"@";
4112 ss << hostname <<
":";
4113 ss << userDataPath << __E__;
4118 cmdResult, {
'\n'} , {
' ',
'\t'} );
4120 __GEN_COUTTV__(subsystemActiveGroupMap.size());
4124 for(
unsigned int i = 0; i + 1 < subsystemActiveGroupMap.size(); i += 2)
4126 if(subsystemActiveGroupMap[i] ==
"" || subsystemActiveGroupMap[i + 1] ==
"-1")
4129 __GEN_COUTT__ <<
"Loading type of subsystem '" << otherSubsystemUID <<
"' group "
4130 << subsystemActiveGroupMap[i] <<
"("
4131 << subsystemActiveGroupMap[i + 1] <<
")" << __E__;
4147 catch(
const std::runtime_error& e)
4149 __GEN_COUT__ <<
"Ignoring error loading subsystem '" << otherSubsystemUID
4150 <<
"' group " << subsystemActiveGroupMap[i] <<
"("
4151 << subsystemActiveGroupMap[i + 1] <<
"): " << __E__ << e.what()
4153 groupType = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
4155 retMap[groupType] = std::make_pair(subsystemActiveGroupMap[i],
4165 std::set<std::string >
4168 std::set<std::string> retSet;
4170 std::map<std::string ,
4172 retMap = getOtherSubsystemActiveTableGroups(otherSubsystemUID);
4175 auto it = retMap.find(
4177 if(it == retMap.end())
4180 <<
"No active Backbone group found in the active groups of remote subsystem '"
4181 << otherSubsystemUID <<
"!'" << __E__;
4184 auto it2 = retMap.find(
4186 if(it2 == retMap.end())
4189 <<
"No active Context group found in the active groups of remote subsystem '"
4190 << otherSubsystemUID <<
"!'" << __E__;
4194 std::string accumulatedWarnings;
4203 &accumulatedWarnings
4205 __GEN_COUTTV__(accumulatedWarnings);
4208 std::vector<std::pair<std::string, ConfigurationTree>> entries =
4211 for(
auto& entry : entries)
4213 if(entry.first.find(
"Context") == std::string::npos &&
4214 entry.first.find(
"Iterat") == std::string::npos)
4215 retSet.emplace(entry.first);
4222 std::set<std::string >
4224 const std::string& otherSubsystemUID,
const std::string& otherSubsystemFsmName)
4226 std::set<std::string> retSet;
4228 std::map<std::string ,
4230 retMap = getOtherSubsystemActiveTableGroups(otherSubsystemUID);
4233 auto it = retMap.find(
4235 if(it == retMap.end())
4238 <<
"No active Backbone group found in the active groups of remote subsystem '"
4239 << otherSubsystemUID <<
"!'" << __E__;
4242 auto it2 = retMap.find(
4244 if(it2 == retMap.end())
4247 <<
"No active Context group found in the active groups of remote subsystem '"
4248 << otherSubsystemUID <<
"!'" << __E__;
4252 std::string accumulatedWarnings;
4261 &accumulatedWarnings
4268 &accumulatedWarnings
4270 __GEN_COUTTV__(accumulatedWarnings);
4273 std::vector<std::pair<std::string, ConfigurationTree>> entries =
4278 std::string stateMachineAliasFilter =
"*";
4283 otherGatewayNode.
getNode(
"LinkToStateMachineTable")
4284 .
getNode(otherSubsystemFsmName +
"/SystemAliasFilter");
4286 stateMachineAliasFilter = fsmFilterNode.
getValue<std::string>();
4288 __GEN_COUT_INFO__ <<
"FSM has no SystemAliasFilter value." << __E__;
4290 catch(std::runtime_error& e)
4292 __COUT__ <<
"Ignoring unsetup SystemAliasFilter value: " << e.what() << __E__;
4296 __COUT__ <<
"Ignoring unsetup SystemAliasFilter value." << __E__;
4299 __COUT__ <<
"Applying alias filter for other user_data path FSM '"
4300 << otherSubsystemFsmName
4301 <<
"' and stateMachineAliasFilter = " << stateMachineAliasFilter << __E__;
4308 stateMachineAliasFilter.size() && stateMachineAliasFilter[0] ==
'!';
4309 std::vector<std::string> filterArr;
4316 while((f = stateMachineAliasFilter.find(
'*', i)) != std::string::npos)
4318 tmp = stateMachineAliasFilter.substr(i, f - i);
4320 filterArr.push_back(tmp);
4321 __COUTS__(20) << filterArr[filterArr.size() - 1] <<
" " << i <<
" of "
4322 << stateMachineAliasFilter.size() << __E__;
4324 if(i <= stateMachineAliasFilter.size())
4326 tmp = stateMachineAliasFilter.substr(i);
4327 filterArr.push_back(tmp);
4328 __COUTS__(20) << filterArr[filterArr.size() - 1] <<
" last." << __E__;
4333 for(
auto& aliasMapPair : entries)
4335 __COUTS__(20) <<
"aliasMapPair.first: " << aliasMapPair.first << __E__;
4339 if(filterArr.size() == 1)
4341 if(filterArr[0] !=
"" && filterArr[0] !=
"*" &&
4342 aliasMapPair.first != filterArr[0])
4343 filterMatch =
false;
4348 for(f = 0; f < filterArr.size(); ++f)
4350 if(!filterArr[f].size())
4355 if((i = aliasMapPair.first.find(filterArr[f])) != 0)
4357 filterMatch =
false;
4361 else if(f == filterArr.size() - 1)
4363 if(aliasMapPair.first.rfind(filterArr[f]) !=
4364 aliasMapPair.first.size() - filterArr[f].size())
4366 filterMatch =
false;
4370 else if((i = aliasMapPair.first.find(filterArr[f])) ==
4373 filterMatch =
false;
4380 filterMatch = !filterMatch;
4382 __COUTS__(20) <<
"filterMatch=" << filterMatch << __E__;
4387 retSet.emplace(aliasMapPair.first);
4399 const std::string& otherSubsystemUID,
4400 const std::string& configAlias,
4401 std::pair<std::string, TableGroupKey>& groupTranslation,
4402 std::string& groupComment,
4403 std::string& groupAuthor,
4404 std::string& groupCreationTime)
4406 __GEN_COUTV__(otherSubsystemUID);
4408 std::map<std::string ,
4410 retMap = getOtherSubsystemActiveTableGroups(otherSubsystemUID);
4413 auto it = retMap.find(
4415 if(it == retMap.end())
4418 <<
"No active Backbone group found in the active groups of remote subsystem '"
4419 << otherSubsystemUID <<
"!'" << __E__;
4422 auto it2 = retMap.find(
4424 if(it2 == retMap.end())
4427 <<
"No active Context group found in the active groups of remote subsystem '"
4428 << otherSubsystemUID <<
"!'" << __E__;
4432 std::string accumulatedWarnings;
4441 &accumulatedWarnings
4443 __GEN_COUTTV__(accumulatedWarnings);
4450 getNode(ConfigurationManager::GROUP_ALIASES_TABLE_NAME).
getNode(configAlias);
4452 groupTranslation = std::pair<std::string, TableGroupKey>(
4455 __COUT__ <<
"Found " << configAlias <<
" translates to " << groupTranslation.first
4456 <<
"(" << groupTranslation.second <<
")" << __E__;
4462 groupTranslation.second,
4466 &accumulatedWarnings,
4474 __COUT_WARN__ <<
"Failed to load group metadata." << __E__;
4476 __COUT__ <<
"Found " << configAlias <<
" author: " << groupAuthor
4477 <<
", createTime: " << groupCreationTime <<
", comment: " << groupComment
4482 __GEN_SS__ <<
"Did not find the Configuration Alias '" << configAlias
4483 <<
"' in the active Backbone group of remote subsystem '"
4484 << otherSubsystemUID <<
"!'" << __E__;
4492 TableBase* ConfigurationManager::getDesktopIconTable(
void)
4494 if(nameToTableMap_.find(DESKTOP_ICON_TABLE_NAME) == nameToTableMap_.end())
4496 __SS__ <<
"Desktop icon table not found!" << __E__;
4501 return nameToTableMap_.at(DESKTOP_ICON_TABLE_NAME);
4505 void ConfigurationManager::saveGroupNameAndKey(
4506 const std::pair<std::string /*group name*/, TableGroupKey>& theGroup,
4507 const std::string& fileName)
4509 std::string fullPath =
4510 ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/" + fileName;
4512 std::ofstream groupFile(fullPath.c_str());
4513 if(!groupFile.is_open())
4515 __SS__ <<
"Error. Can't open file to save group activity: " << fullPath << __E__;
4518 std::stringstream outss;
4519 outss << theGroup.first <<
"\n" << theGroup.second <<
"\n" << time(0);
4520 groupFile << outss.str().c_str();
4532 std::string& returnedTimeString)
4534 std::string fullPath =
4535 ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/" + fileName;
4537 FILE* groupFile = fopen(fullPath.c_str(),
"r");
4540 __COUT__ <<
"Can't open file: " << fullPath << __E__;
4542 __COUT__ <<
"Returning empty groupName and key -1" << __E__;
4551 fgets(line, 500, groupFile);
4552 if(strlen(line) && line[strlen(line) - 1] ==
'\n')
4553 line[strlen(line) - 1] =
'\0';
4554 theGroup.first = line;
4556 fgets(line, 500, groupFile);
4558 sscanf(line,
"%d", &key);
4559 theGroup.second = key;
4561 fgets(line, 500, groupFile);
4563 sscanf(line,
"%ld", ×tamp);
4570 __COUT__ <<
"theGroup.first=" << theGroup.first
4571 <<
" theGroup.second=" << theGroup.second << __E__;
virtual std::map< std::string, TableVersion > getTableGroupMembers(std::string const &, bool=false) const
std::map< std::string, std::map< std::string, TableVersion > > getVersionAliases(void) const
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 onlyLoadIfBackboneOrContext=ConfigurationManager::LoadGroupType::ALL_TYPES, bool ignoreVersionTracking=false)
static const unsigned int PROCESSOR_COUNT
Static members.
static const std::string & convertGroupTypeToName(const ConfigurationManager::GroupType &groupTypeId)
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.
std::set< std::string > configurationMemberNames_
list of 'active' configuration members
void loadMemberMap(const std::map< std::string, TableVersion > &memberMap, std::string *accumulateWarnings=0)
void dumpActiveConfiguration(const std::string &filePath, const std::string &dumpType, const std::string &configurationAlias, const std::string &logEntry, const std::string &activeUsers, std::ostream &altOut=std::cout)
std::map< std::string, TableVersion > getActiveVersions(void) const
getActiveVersions
ConfigurationManager(bool initForWriteAccess=false, bool initializeFromFhicl=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)
ConfigurationTree getNode(const std::string &nodeString, bool doNotThrowOnBrokenUIDLinks=false) const
"root/parent/parent/"
static const std::set< std::string > contextMemberNames_
list of context members
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)
static const std::set< std::string > backboneMemberNames_
list of backbone members
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.
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
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.
static const std::set< std::string > iterateMemberNames_
list of iterate members
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)
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="")
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 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)