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 ,
119 __GEN_COUTTV__(runTimeSeconds());
120 theInterface_ = ConfigurationInterface::getInstance(
121 ConfigurationInterface::CONFIGURATION_MODE::
124 __GEN_COUTTV__(runTimeSeconds());
139 ConfigurationInterface::GROUP_METADATA_TABLE_NAME);
140 std::vector<TableViewColumnInfo>* colInfo =
141 groupMetadataTable_.getMockupViewP()->getColumnsInfoP();
155 TableViewColumnInfo::DATATYPE_STRING,
162 TableViewColumnInfo::TYPE_COMMENT,
163 TableViewColumnInfo::COL_NAME_COMMENT,
164 "COMMENT_DESCRIPTION",
165 TableViewColumnInfo::DATATYPE_STRING,
172 TableViewColumnInfo::TYPE_AUTHOR,
175 TableViewColumnInfo::DATATYPE_STRING,
183 "GROUP_CREATION_TIME",
184 TableViewColumnInfo::DATATYPE_TIME,
191 groupMetadataTable_.setActiveView(tmpVersion);
193 groupMetadataTable_.getViewP()->
addRow();
196 if(doInitializeFromFhicl)
199 initializeFromFhicl(__ENV__(
"CONFIGURATION_INIT_FCL"));
204 __GEN_COUTTV__(runTimeSeconds());
205 if(!initForWriteAccess)
206 init(0 , initForWriteAccess);
207 __GEN_COUTTV__(runTimeSeconds());
215 __GEN_COUT_INFO__ <<
"Private constructor for write access called." << __E__;
217 mfSubject_ = username;
218 username_ = username;
222 ConfigurationManager::~ConfigurationManager() { destroy(); }
231 bool initForWriteAccess ,
232 std::string* accumulatedWarnings )
244 __GEN_COUTTV__(username_);
249 ConfigurationManager::LoadGroupType onlyLoadIfBackboneOrContext =
250 ConfigurationManager::LoadGroupType::ALL_TYPES;
251 if(username_ == ConfigurationManager::READONLY_USER && !initForWriteAccess)
252 onlyLoadIfBackboneOrContext =
253 ConfigurationManager::LoadGroupType::ONLY_BACKBONE_OR_CONTEXT_TYPES;
258 onlyLoadIfBackboneOrContext,
259 accumulatedWarnings);
262 catch(std::runtime_error& e)
264 __GEN_COUT_ERR__ <<
"Error caught in init(): " << e.what();
265 if(accumulatedErrors)
266 *accumulatedErrors += e.what();
283 const std::string& pathToActiveGroupsFile ,
284 ConfigurationManager::LoadGroupType
285 onlyLoadIfBackboneOrContext ,
286 std::string* accumulatedWarnings )
292 FILE* fp = fopen(fn.c_str(),
"r");
294 __GEN_COUT__ <<
"ACTIVE_GROUPS_FILENAME = " << fn << __E__;
295 __GEN_COUT__ <<
"ARTDAQ_DATABASE_URI = "
296 << std::string(__ENV__(
"ARTDAQ_DATABASE_URI")) << __E__;
300 __GEN_COUT_WARN__ <<
"No active groups file found at " << fn << __E__;
309 std::string groupName;
310 std::string errorStr =
"";
315 while(fgets(tmp, 500, fp))
320 sscanf(tmp,
"%d", &numberCheck);
324 <<
"Out of sync with active groups file lines, attempting to resync."
331 sscanf(tmp,
"%s", strVal);
332 for(
unsigned int j = 0; j < strlen(strVal); ++j)
333 if(!((strVal[j] >=
'a' && strVal[j] <=
'z') ||
334 (strVal[j] >=
'A' && strVal[j] <=
'Z') ||
335 (strVal[j] >=
'0' && strVal[j] <=
'9')))
338 __GEN_COUT_INFO__ <<
"Illegal character found in group name '" << strVal
339 <<
"', so skipping! Check active groups file: " << fn
351 sscanf(tmp,
"%s", strVal);
353 for(
unsigned int j = 0; j < strlen(strVal); ++j)
354 if(!((strVal[j] >=
'0' && strVal[j] <=
'9')))
358 if(groupName.size() > 3)
360 <<
"Skipping active group with illegal character in group key '"
361 << strVal <<
".' Check active groups file: " << fn << __E__;
367 if(groupName.size() <= 3)
380 <<
"illegal group according to TableGroupKey::getFullGroupString... "
381 "Check active groups file: "
392 std::string groupAccumulatedErrors =
"";
394 if(accumulatedWarnings)
395 __GEN_COUT__ <<
"Ignoring warnings while loading and activating group '"
396 << groupName <<
"(" << strVal <<
")'" << __E__;
404 (accumulatedWarnings ? &groupAccumulatedErrors
412 onlyLoadIfBackboneOrContext
415 if(accumulatedWarnings)
416 *accumulatedWarnings += groupAccumulatedErrors;
418 catch(std::runtime_error& e)
420 ss <<
"Failed to load group in ConfigurationManager::init() with name '"
421 << groupName <<
"(" << strVal
422 <<
")' specified active by active groups file: " << fn << __E__;
423 ss << e.what() << __E__;
425 errorStr += ss.str();
429 ss <<
"Failed to load group in ConfigurationManager::init() with name '"
430 << groupName <<
"(" << strVal
431 <<
")' specified active by active groups file: " << fn << __E__;
436 catch(
const std::exception& e)
438 ss <<
"Exception message: " << e.what();
443 errorStr += ss.str();
449 if(throwErrors && errorStr !=
"")
451 __SS__ <<
"\n" << errorStr;
454 else if(errorStr !=
"")
455 __GEN_COUT_INFO__ <<
"\n" << errorStr;
468 bool isContext = theGroup ==
"" || theGroup == theContextTableGroup_;
469 bool isBackbone = theGroup ==
"" || theGroup == theBackboneTableGroup_;
470 bool isIterate = theGroup ==
"" || theGroup == theIterateTableGroup_;
471 bool isConfiguration = theGroup ==
"" || theGroup == theConfigurationTableGroup_;
473 if(!isContext && !isBackbone && !isIterate && !isConfiguration)
475 __SS__ <<
"Invalid configuration group to destroy: " << theGroup << __E__;
476 __GEN_COUT_ERR__ << ss.str();
480 std::string dbgHeader = onlyDeactivate ?
"Deactivating" :
"Destroying";
484 __GEN_COUT__ << dbgHeader <<
" Context group: " << theGroup << __E__;
486 __GEN_COUT__ << dbgHeader <<
" Backbone group: " << theGroup << __E__;
488 __GEN_COUT__ << dbgHeader <<
" Iterate group: " << theGroup << __E__;
490 __GEN_COUT__ << dbgHeader <<
" Configuration group: " << theGroup << __E__;
493 std::set<std::string>::const_iterator contextFindIt, backboneFindIt, iterateFindIt;
494 for(
auto it = nameToTableMap_.begin(); it != nameToTableMap_.end();
508 CONTEXT_SUBSYSTEM_OPTIONAL_TABLE) ||
513 it->first != ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE &&
523 it->second->deactivate();
529 nameToTableMap_.erase(it++);
538 theConfigurationTableGroup_ =
"";
539 if(theConfigurationTableGroupKey_ != 0)
541 __GEN_COUT__ <<
"Destroying Configuration Key: "
542 << *theConfigurationTableGroupKey_ << __E__;
543 theConfigurationTableGroupKey_.reset();
550 theBackboneTableGroup_ =
"";
551 if(theBackboneTableGroupKey_ != 0)
553 __GEN_COUT__ <<
"Destroying Backbone Key: " << *theBackboneTableGroupKey_
555 theBackboneTableGroupKey_.reset();
560 theIterateTableGroup_ =
"";
561 if(theIterateTableGroupKey_ != 0)
563 __GEN_COUT__ <<
"Destroying Iterate Key: " << *theIterateTableGroupKey_
565 theIterateTableGroupKey_.reset();
570 theContextTableGroup_ =
"";
571 if(theContextTableGroupKey_ != 0)
573 __GEN_COUT__ <<
"Destroying Context Key: " << *theContextTableGroupKey_
575 theContextTableGroupKey_.reset();
581 void ConfigurationManager::destroy(
void)
597 const ConfigurationManager::GroupType& groupTypeId)
599 return groupTypeId == ConfigurationManager::GroupType::CONTEXT_TYPE
600 ? ConfigurationManager::GROUP_TYPE_NAME_CONTEXT
601 : (groupTypeId == ConfigurationManager::GroupType::BACKBONE_TYPE
602 ? ConfigurationManager::GROUP_TYPE_NAME_BACKBONE
603 : (groupTypeId == ConfigurationManager::GroupType::ITERATE_TYPE
604 ? ConfigurationManager::GROUP_TYPE_NAME_ITERATE
605 : (groupTypeId == ConfigurationManager::GroupType::
607 ? ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION
608 : ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)));
619 const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap)
621 bool isContext =
true;
622 bool isBackbone =
true;
623 bool isIterate =
true;
625 bool inContext =
false;
626 bool inBackbone =
false;
627 bool inIterate =
false;
628 unsigned int matchCount = 0;
630 for(
auto& memberPair : memberMap)
635 if(memberPair.first == CONTEXT_SUBSYSTEM_OPTIONAL_TABLE)
642 if(memberPair.first == contextMemberString)
654 __SS__ <<
"This group is an incomplete match to a Context group.\n";
655 ss <<
"\nTo be a Context group, the members must exactly match "
656 <<
"the following members (w/ or wo/ the optional table "
657 << CONTEXT_SUBSYSTEM_OPTIONAL_TABLE <<
"):\n";
660 ss << ++i <<
". " << memberName <<
"\n";
661 ss <<
"\nThe members are as follows::\n";
663 for(
const auto& memberPairTmp : memberMap)
664 ss << ++i <<
". " << memberPairTmp.first <<
"\n";
672 if(memberPair.first == backboneMemberString)
684 __SS__ <<
"This group is an incomplete match to a Backbone group.\n";
685 ss <<
"\nTo be a Backbone group, the members must exactly match "
686 <<
"the following members:\n";
689 ss << ++i <<
". " << memberName <<
"\n";
690 ss <<
"\nThe members are as follows::\n";
692 for(
const auto& memberPairTmp : memberMap)
693 ss << ++i <<
". " << memberPairTmp.first <<
"\n";
702 if(memberPair.first == iterateMemberString)
714 __SS__ <<
"This group is an incomplete match to a Iterate group.\n";
715 ss <<
"\nTo be a Iterate group, the members must exactly match "
716 <<
"the following members:\n";
719 ss << ++i <<
". " << memberName <<
"\n";
720 ss <<
"\nThe members are as follows::\n";
722 for(
const auto& memberPairTmp : memberMap)
723 ss << ++i <<
". " << memberPairTmp.first <<
"\n";
732 __SS__ <<
"This group is an incomplete match to a Context group: "
733 <<
" Size=" << matchCount <<
" but should be "
735 ss <<
"\nThe members currently are...\n";
737 for(
auto& memberPair : memberMap)
738 ss << ++i <<
". " << memberPair.first <<
"\n";
739 ss <<
"\nThe expected Context members are...\n";
742 ss << ++i <<
". " << memberName <<
"\n";
749 __SS__ <<
"This group is an incomplete match to a Backbone group: "
750 <<
" Size=" << matchCount <<
" but should be "
752 ss <<
"\nThe members currently are...\n";
754 for(
auto& memberPair : memberMap)
755 ss << ++i <<
". " << memberPair.first <<
"\n";
756 ss <<
"\nThe expected Backbone members are...\n";
759 ss << ++i <<
". " << memberName <<
"\n";
766 __SS__ <<
"This group is an incomplete match to a Iterate group: "
767 <<
" Size=" << matchCount <<
" but should be "
769 ss <<
"\nThe members currently are...\n";
771 for(
auto& memberPair : memberMap)
772 ss << ++i <<
". " << memberPair.first <<
"\n";
773 ss <<
"\nThe expected Iterate members are...\n";
776 ss << ++i <<
". " << memberName <<
"\n";
782 ? ConfigurationManager::GroupType::CONTEXT_TYPE
784 ? ConfigurationManager::GroupType::BACKBONE_TYPE
786 ? ConfigurationManager::GroupType::ITERATE_TYPE
787 : ConfigurationManager::GroupType::CONFIGURATION_TYPE));
794 const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap)
805 #define OUT out << tabStr << commentStr
806 #define PUSHTAB tabStr += "\t"
807 #define POPTAB tabStr.resize(tabStr.size() - 1)
808 #define PUSHCOMMENT commentStr += "# "
809 #define POPCOMMENT commentStr.resize(commentStr.size() - 2)
811 void ConfigurationManager::dumpMacroMakerModeFhicl()
813 std::string filepath =
814 __ENV__(
"USER_DATA") + std::string(
"/") +
"MacroMakerModeConfigurations";
815 mkdir(filepath.c_str(), 0755);
816 filepath +=
"/MacroMakerModeFhiclDump.fcl";
817 __GEN_COUT__ <<
"dumpMacroMakerModeFhicl: " << filepath << __E__;
823 std::string tabStr =
"";
824 std::string commentStr =
"";
826 out.open(filepath, std::fstream::out | std::fstream::trunc);
829 __SS__ <<
"Failed to open MacroMaker mode fcl file for configuration dump: "
830 << filepath << __E__;
836 std::vector<std::pair<std::string, ConfigurationTree>> fes =
842 if(!fe.second.status())
847 OUT << fe.first <<
": {" << __E__;
852 OUT <<
"FEInterfacePluginName"
854 <<
"\"" << fe.second.getNode(
"FEInterfacePluginName").getValueAsString()
857 recursiveTreeToFhicl(
858 fe.second.getNode(
"LinkToFETypeTable"), out, tabStr, commentStr);
861 OUT <<
"} //end " << fe.first << __E__ << __E__;
867 __SS__ <<
"Failed to complete MacroMaker mode fcl "
868 "file configuration dump due to error."
874 catch(
const std::runtime_error& e)
876 ss <<
"Exception message: " << e.what();
878 catch(
const std::exception& e)
880 ss <<
"Exception message: " << e.what();
882 __GEN_COUT_ERR__ << ss.str();
900 std::string& tabStr ,
901 std::string& commentStr ,
906 __COUT__ << __COUT_HDR_P__ <<
"Depth limit reached. Ending recursion." << __E__;
912 if(depth == (
unsigned int)-1)
932 std::vector<std::pair<std::string, ConfigurationTree>> children =
934 for(
auto& child : children)
935 recursiveTreeToFhicl(child.second, out, tabStr, commentStr, depth - 1);
939 <<
" group link record" << __E__;
951 std::vector<std::pair<std::string, ConfigurationTree>> fields =
955 for(
unsigned int i = 0; i < fields.size() - 3; ++i)
959 if(fields[i].second.isLinkNode())
961 recursiveTreeToFhicl(
962 fields[i].second, out, tabStr, commentStr, depth - 1);
967 OUT << fields[i].second.getFieldName() <<
": \t";
968 if(fields[i].second.isValueNumberDataType())
969 OUT << fields[i].second.getValueAsString() << __E__;
971 OUT <<
"\"" << fields[i].second.getValueAsString() <<
"\"" << __E__;
984 <<
" link record" << __E__;
993 const std::string& dumpType,
994 const std::string& configurationAlias,
995 const std::string& logEntry,
996 const std::string& activeUsers,
997 std::ostream& altOut )
999 time_t rawtime = time(0);
1000 __GEN_COUT__ <<
"filePath = " << filePath << __E__;
1001 __GEN_COUT__ <<
"dumpType = " << dumpType << __E__;
1005 fs.open(filePath, std::fstream::out | std::fstream::trunc);
1016 __SS__ <<
"Invalid file path to dump active configuration. File " << filePath
1017 <<
" could not be opened!" << __E__;
1018 __GEN_COUT_ERR__ << ss.str();
1024 (*out) <<
"#################################" << __E__;
1025 (*out) <<
"This is an ots configuration dump.\n" << __E__;
1026 (*out) <<
"Source database is $ARTDAQ_DATABASE_URI: "
1027 << __ENV__(
"ARTDAQ_DATABASE_URI") << __E__;
1029 (*out) <<
"Original location of dump: " << __ENV__(
"HOSTNAME")
1030 <<
":" << filePath << __E__;
1031 (*out) <<
"\nActive ots users: \t"
1032 << (activeUsers.size() ? activeUsers :
"no active users") << __E__;
1033 (*out) <<
"Type of dump: \t\t" << dumpType << __E__;
1034 (*out) <<
"Time of dump: \t\t" << rawtime;
1036 struct tm* timeinfo = localtime(&rawtime);
1038 strftime(buffer, 100,
"%c %Z", timeinfo);
1039 (*out) <<
" \t" << buffer << __E__;
1043 std::pair<std::string, ots::TableGroupKey> configurationTableGroup =
1045 (*out) <<
"Configuration Alias: \t\t\t" << configurationAlias <<
"\n";
1046 (*out) <<
"Configuration Alias translation: \t" << configurationTableGroup.first
1047 <<
"(" << configurationTableGroup.second <<
")\n\n";
1050 (*out) <<
"User Log Entry (" << logEntry.size() <<
" chars):\n"
1051 << logEntry << __E__;
1060 std::ostream* out) {
1061 std::map<std::string, std::pair<std::string, TableGroupKey>> activeGroups =
1064 (*out) <<
"\n\n************************" << __E__;
1065 (*out) <<
"Active Groups:" << __E__;
1066 for(
auto& group : activeGroups)
1068 (*out) <<
"\t" << group.first <<
" := " << group.second.first <<
" ("
1069 << group.second.second <<
")" << __E__;
1074 std::ostream* out) {
1077 (*out) <<
"\n\n************************" << __E__;
1078 (*out) <<
"Active Tables:" << __E__;
1079 (*out) <<
"Active Tables count = " << activeTables.size() << __E__;
1082 for(
auto& table : activeTables)
1084 (*out) <<
"\t" << ++i <<
". " << table.first <<
"-v" << table.second << __E__;
1089 std::ostream* out) {
1090 std::map<std::string, std::pair<std::string, TableGroupKey>> activeGroups =
1092 (*out) <<
"\n\n************************" << __E__;
1093 (*out) <<
"Active Group Members:" << __E__;
1095 for(
auto& group : activeGroups)
1097 (*out) <<
"\t" << group.first <<
" := " << group.second.first <<
" ("
1098 << group.second.second <<
")" << __E__;
1100 if(group.second.first ==
"")
1103 <<
"Empty group name. Assuming no active group." << __E__;
1108 std::map<std::string , std::string > groupAliases;
1109 std::string groupComment;
1110 std::string groupAuthor;
1111 std::string groupCreateTime;
1112 time_t groupCreateTime_t;
1115 group.second.second,
1127 (*out) <<
"\t\tGroup Comment: \t" << groupComment << __E__;
1128 (*out) <<
"\t\tGroup Author: \t" << groupAuthor << __E__;
1130 sscanf(groupCreateTime.c_str(),
"%ld", &groupCreateTime_t);
1131 (*out) <<
"\t\tGroup Create Time: \t" << ctime(&groupCreateTime_t) << __E__;
1135 (*out) <<
"\t\tMember table count = " << memberMap.size() << __E__;
1136 tableCount += memberMap.size();
1139 for(
auto& member : memberMap)
1141 (*out) <<
"\t\t\t" << ++i <<
". " << member.first <<
"-v" << member.second
1145 (*out) <<
"\nActive Group Members total table count = " << tableCount << __E__;
1149 std::ostream* out) {
1152 (*out) <<
"\n\n************************" << __E__;
1153 (*out) <<
"Active Table Contents (table count = " << activeTables.size()
1156 for(
auto& table : activeTables)
1158 (*out) <<
"\n\n=============================================================="
1161 (*out) <<
"=================================================================="
1164 (*out) <<
"\t" << ++i <<
". " << table.first <<
"-v" << table.second << __E__;
1166 cfgMgr->nameToTableMap_.find(table.first)->second->print(*out);
1170 if(dumpType ==
"GroupKeys")
1172 localDumpActiveGroups(
this, out);
1174 else if(dumpType ==
"TableVersions")
1176 localDumpActiveTables(
this, out);
1178 else if(dumpType ==
"GroupKeysAndTableVersions")
1180 localDumpActiveGroups(
this, out);
1181 localDumpActiveTables(
this, out);
1183 else if(dumpType ==
"All")
1185 localDumpActiveGroups(
this, out);
1186 localDumpActiveGroupMembers(
this, out);
1187 localDumpActiveTables(
this, out);
1188 localDumpActiveTableContents(
this, out);
1193 <<
"Invalid dump type '" << dumpType
1194 <<
"' given during dumpActiveConfiguration(). Valid types are as follows:\n"
1202 <<
"GroupsKeysAndTableVersions"
1207 "\n\nPlease change the State Machine configuration to a valid dump type."
1224 const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap,
1225 std::string* accumulatedWarnings )
1227 __GEN_COUTTV__(runTimeSeconds());
1232 bool usingCache =
false;
1233 if(memberMap.size() > 10 && nameToTableMap_.size() &&
1234 nameToTableMap_.find(memberMap.begin()->first) != nameToTableMap_.end() &&
1235 nameToTableMap_.at(memberMap.begin()->first)->isStored(memberMap.begin()->second))
1240 __GEN_COUTT__ <<
"Using cache!" << __E__;
1244 const int numOfThreads =
1246 if(memberMap.size() <= 2 || usingCache ||
1251 for(
auto& memberPair : memberMap)
1263 tmpTableBasePtr =
nullptr;
1264 if(nameToTableMap_.find(memberPair.first) != nameToTableMap_.end())
1265 tmpTableBasePtr = nameToTableMap_.at(memberPair.first);
1267 std::string getError =
"";
1270 theInterface_->get(tmpTableBasePtr,
1279 catch(
const std::runtime_error& e)
1281 __SS__ <<
"Failed to load member table '" << memberPair.first <<
"-v"
1282 << memberPair.second <<
"' - here is the error: \n\n"
1283 << e.what() << __E__;
1285 ss <<
"\nIf the table '" << memberPair.first
1286 <<
"' should not exist, then please remove it from the group. If it "
1287 "should exist, then it "
1288 <<
"seems to have a problem; use the Table Editor to fix the table "
1290 "edit the table content to match the table definition."
1294 if(accumulatedWarnings)
1295 getError = ss.str();
1301 __SS__ <<
"Failed to load member table '" << memberPair.first <<
" -v"
1302 << memberPair.second <<
"' due to unknown error!" << __E__;
1307 catch(
const std::exception& e)
1309 ss <<
"Exception message: " << e.what();
1315 ss <<
"\nIf the table '" << memberPair.first
1316 <<
"' should not exist, then please remove it from the group. If it "
1317 "should exist, then it "
1318 <<
"seems to have a problem; use the Table Editor to fix the table "
1320 "edit the table content to match the table definition."
1324 if(accumulatedWarnings)
1325 getError = ss.str();
1331 if(!tmpTableBasePtr)
1333 __SS__ <<
"Null pointer returned for table '" << memberPair.first <<
" -v"
1334 << memberPair.second <<
".' Was the table info deleted?" << __E__;
1335 __GEN_COUT_ERR__ << ss.str();
1337 nameToTableMap_.erase(memberPair.first);
1338 if(accumulatedWarnings)
1340 *accumulatedWarnings += ss.str();
1347 nameToTableMap_[memberPair.first] = tmpTableBasePtr;
1348 if(nameToTableMap_[memberPair.first]->getViewP())
1353 if(accumulatedWarnings && getError !=
"")
1355 __SS__ <<
"Error caught during '" << memberPair.first <<
" -v"
1356 << memberPair.second <<
"' table retrieval: \n"
1357 << getError << __E__;
1358 __GEN_COUT_ERR__ << ss.str();
1359 *accumulatedWarnings += ss.str();
1364 __SS__ << nameToTableMap_[memberPair.first]->getTableName() <<
" -v"
1365 << memberPair.second <<
": View version not activated properly!";
1372 __GEN_COUT__ <<
" PROCESSOR_COUNT " <<
PROCESSOR_COUNT <<
" ==> " << numOfThreads
1373 <<
" threads for loading member map of size " << memberMap.size()
1376 int threadsLaunched = 0;
1377 int foundThreadIndex = 0;
1378 std::string threadErrors;
1379 std::mutex threadMutex;
1380 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
1381 for(
int i = 0; i < numOfThreads; ++i)
1382 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
1383 std::vector<TableBase*> tmpTableBasePtrs;
1384 for(
int i = 0; i < numOfThreads; ++i)
1385 tmpTableBasePtrs.push_back(
nullptr);
1387 for(
auto& memberPair : memberMap)
1389 if(threadsLaunched >= numOfThreads)
1392 foundThreadIndex = -1;
1393 while(foundThreadIndex == -1)
1395 for(
int i = 0; i < numOfThreads; ++i)
1396 if(*(threadDone[i]))
1398 foundThreadIndex = i;
1401 if(foundThreadIndex == -1)
1403 __GEN_COUTT__ <<
"Waiting for available thread..." << __E__;
1407 threadsLaunched = numOfThreads - 1;
1409 __GEN_COUTT__ <<
"Starting filling thread... " << foundThreadIndex <<
" for "
1410 << memberPair.first <<
" -v" << memberPair.second << __E__;
1411 *(threadDone[foundThreadIndex]) =
false;
1419 tmpTableBasePtrs[foundThreadIndex] =
nullptr;
1420 if(nameToTableMap_.find(memberPair.first) != nameToTableMap_.end())
1421 tmpTableBasePtrs[foundThreadIndex] = nameToTableMap_.at(memberPair.first);
1425 std::map<std::string, ots::TableBase*>* theNameToTableMap,
1427 std::string theTableName,
1429 std::string* theThreadErrors,
1430 std::mutex* theThreadMutex,
1431 std::shared_ptr<std::atomic<bool>> theThreadDone) {
1432 ConfigurationManager::fillTableThread(theInterface,
1443 tmpTableBasePtrs[foundThreadIndex],
1448 threadDone[foundThreadIndex])
1458 foundThreadIndex = -1;
1459 for(
int i = 0; i < numOfThreads; ++i)
1460 if(!*(threadDone[i]))
1462 foundThreadIndex = i;
1465 if(foundThreadIndex != -1)
1467 __GEN_COUT_TYPE__(TLVL_DEBUG + 2)
1468 << __COUT_HDR__ <<
"Waiting for thread to finish... "
1469 << foundThreadIndex << __E__;
1472 }
while(foundThreadIndex != -1);
1473 __GEN_COUTT__ <<
"All threads done." << __E__;
1475 if(threadErrors !=
"")
1477 __SS__ <<
"Error identified in threads during loading of member map: \n"
1478 << threadErrors << __E__;
1479 __GEN_COUTT__ <<
"\n" << ss.str() << __E__;
1480 if(accumulatedWarnings)
1481 *accumulatedWarnings += ss.str();
1487 __GEN_COUTT__ <<
"loadMemberMap end runTimeSeconds()=" << runTimeSeconds() << __E__;
1513 const std::string& groupName,
1516 std::map<std::string /*table name*/, TableVersion>*
1519 std::string* accumulatedWarnings ,
1520 std::string* groupComment ,
1521 std::string* groupAuthor ,
1522 std::string* groupCreateTime ,
1523 bool doNotLoadMembers ,
1524 std::string* groupTypeString ,
1525 std::map<std::string /*name*/, std::string /*alias*/>*
1527 ConfigurationManager::LoadGroupType
1528 onlyLoadIfBackboneOrContext ,
1529 bool ignoreVersionTracking )
1533 *groupComment = ConfigurationManager::UNKNOWN_INFO;
1535 *groupAuthor = ConfigurationManager::UNKNOWN_INFO;
1537 *groupCreateTime = ConfigurationManager::UNKNOWN_TIME;
1539 *groupTypeString = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
1541 __GEN_COUTT__ <<
"No group type requested." << __E__;
1568 __GEN_COUTT__ <<
"Loading Table Group: " << groupName <<
"(" << groupKey <<
")"
1581 progressBar->
step();
1584 auto metaTablePair =
1585 memberMap.find(ConfigurationInterface::GROUP_METADATA_TABLE_NAME);
1586 if(metaTablePair != memberMap.end())
1589 if(groupAliases || groupComment || groupAuthor || groupCreateTime)
1591 std::lock_guard<std::mutex> lock(metaDataTableMutex_);
1594 while(groupMetadataTable_.getView().getNumberOfRows())
1595 groupMetadataTable_.getViewP()->
deleteRow(0);
1600 theInterface_->fill(&groupMetadataTable_, metaTablePair->second);
1602 catch(
const std::runtime_error& e)
1605 <<
"Failed to load " << groupMetadataTable_.
getTableName() <<
"-v"
1606 << metaTablePair->second <<
". Metadata error: " << e.what()
1612 <<
"Failed to load " << groupMetadataTable_.
getTableName() <<
"-v"
1613 << metaTablePair->second <<
". Ignoring unknown metadata error. "
1618 if(groupMetadataTable_.getView().getNumberOfRows() != 1)
1620 groupMetadataTable_.
print();
1621 __GEN_COUT_ERR__ <<
"Ignoring that groupMetadataTable_ has wrong "
1622 "number of rows for '"
1623 << groupName <<
"(" << groupKey
1625 "be 1. Going with anonymous defaults."
1629 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
1630 groupMetadataTable_.getViewP()->
deleteRow(0);
1631 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
1632 groupMetadataTable_.getViewP()->
addRow();
1641 0, ConfigurationManager::METADATA_COL_ALIASES),
1645 0, ConfigurationManager::METADATA_COL_COMMENT);
1648 0, ConfigurationManager::METADATA_COL_AUTHOR);
1651 0, ConfigurationManager::METADATA_COL_TIMESTAMP);
1655 memberMap.erase(metaTablePair);
1660 __GEN_COUT_ERR__ <<
"Ignoring that groupMetadataTable_ is missing for group '"
1661 << groupName <<
"(" << groupKey
1662 <<
"). Going with anonymous defaults." << __E__;
1673 std::map<std::string, std::string>& aliasMap = *groupAliases;
1674 std::map<std::string , std::map<std::string ,
TableVersion>>
1684 for(
auto& aliasPair : aliasMap)
1687 if(memberMap.find(aliasPair.first) != memberMap.end())
1689 __GEN_COUT__ <<
"Group member '" << aliasPair.first
1690 <<
"' was found in group member map!" << __E__;
1691 __GEN_COUT__ <<
"Looking for alias '" << aliasPair.second
1692 <<
"' in active version aliases..." << __E__;
1694 if(versionAliases.find(aliasPair.first) == versionAliases.end() ||
1695 versionAliases[aliasPair.first].find(aliasPair.second) ==
1696 versionAliases[aliasPair.first].end())
1698 __SS__ <<
"Group '" << groupName <<
"(" << groupKey
1699 <<
")' requires table version alias '" << aliasPair.first
1700 <<
":" << aliasPair.second
1701 <<
",' which was not found in the active Backbone!"
1706 memberMap[aliasPair.first] =
1707 versionAliases[aliasPair.first][aliasPair.second];
1708 __GEN_COUT__ <<
"Version alias translated to " << aliasPair.first
1715 *groupMembers = memberMap;
1718 progressBar->
step();
1720 ConfigurationManager::GroupType groupType =
1721 ConfigurationManager::GroupType::CONFIGURATION_TYPE;
1730 __GEN_COUTT__ <<
"No group type requested." << __E__;
1732 if(doNotLoadMembers)
1736 if(!groupTypeString)
1739 if(onlyLoadIfBackboneOrContext ==
1740 ConfigurationManager::LoadGroupType::ONLY_BACKBONE_OR_CONTEXT_TYPES &&
1741 groupType != ConfigurationManager::GroupType::CONTEXT_TYPE &&
1742 groupType != ConfigurationManager::GroupType::BACKBONE_TYPE)
1744 __GEN_COUT__ <<
"Not loading group because it is not of type Context or "
1745 "Backbone (it is type '"
1749 else if(onlyLoadIfBackboneOrContext ==
1750 ConfigurationManager::LoadGroupType::ONLY_BACKBONE_TYPE &&
1751 groupType != ConfigurationManager::GroupType::BACKBONE_TYPE)
1753 __GEN_COUT__ <<
"Not loading group because it is not of type "
1754 "Backbone (it is type '"
1761 <<
"------------------------------------- init start \t [for all "
1769 std::string groupToDeactivate =
1770 groupType == ConfigurationManager::GroupType::CONTEXT_TYPE
1771 ? theContextTableGroup_
1772 : (groupType == ConfigurationManager::GroupType::BACKBONE_TYPE
1773 ? theBackboneTableGroup_
1775 ConfigurationManager::GroupType::ITERATE_TYPE
1776 ? theIterateTableGroup_
1777 : theConfigurationTableGroup_));
1780 if(groupToDeactivate !=
"")
1794 progressBar->
step();
1799 progressBar->
step();
1801 __GEN_COUTT__ <<
"loadMemberMap() completed." << __E__;
1803 if(accumulatedWarnings)
1808 if(*accumulatedWarnings !=
"")
1811 <<
"Errors detected while loading Table Group: " << groupName
1812 <<
"(" << groupKey <<
"). Ignoring the following errors: "
1814 << *accumulatedWarnings << __E__;
1819 progressBar->
step();
1821 __GEN_COUTT__ <<
"Tree view check complete." << __E__;
1829 << numOfThreads <<
" threads for initializing tables."
1831 if(groupType != ConfigurationManager::GroupType::CONFIGURATION_TYPE ||
1834 for(
auto& memberPair : memberMap)
1837 if(!ignoreVersionTracking &&
1838 ConfigurationInterface::isVersionTrackingEnabled() &&
1839 memberPair.second.isScratchVersion())
1842 <<
"Error while activating member Table '"
1843 << nameToTableMap_[memberPair.first]->getTableName()
1844 <<
"-v" << memberPair.second <<
" for Table Group '"
1845 << groupName <<
"(" << groupKey
1846 <<
")'. When version tracking is enabled, Scratch views"
1847 <<
" are not allowed! Please only use unique, persistent "
1848 "versions when version tracking is enabled."
1857 nameToTableMap_.at(memberPair.first)->init(
this);
1859 catch(std::runtime_error& e)
1861 __SS__ <<
"Error detected calling " << memberPair.first
1862 <<
".init()!\n\n " << e.what() << __E__;
1864 if(accumulatedWarnings)
1866 *accumulatedWarnings += ss.str();
1876 __SS__ <<
"Unknown Error detected calling "
1877 << memberPair.first <<
".init()!\n\n " << __E__;
1882 catch(
const std::exception& e)
1884 ss <<
"Exception message: " << e.what();
1891 if(accumulatedWarnings)
1893 *accumulatedWarnings += ss.str();
1896 __GEN_COUT_WARN__ << ss.str();
1902 int threadsLaunched = 0;
1903 int foundThreadIndex = 0;
1904 std::mutex threadMutex;
1905 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
1906 for(
int i = 0; i < numOfThreads; ++i)
1907 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
1909 if(!ignoreVersionTracking &&
1910 ConfigurationInterface::isVersionTrackingEnabled())
1911 for(
auto& memberPair : memberMap)
1914 if(memberPair.second.isScratchVersion())
1917 <<
"Error while activating member Table '"
1918 << nameToTableMap_[memberPair.first]->getTableName()
1919 <<
"-v" << memberPair.second <<
" for Table Group '"
1920 << groupName <<
"(" << groupKey
1921 <<
")'. When version tracking is enabled, Scratch "
1923 <<
" are not allowed! Please only use unique, "
1925 "versions when version tracking is enabled."
1931 for(
auto& memberPair : memberMap)
1933 if(threadsLaunched >= numOfThreads)
1936 foundThreadIndex = -1;
1937 while(foundThreadIndex == -1)
1939 for(
int i = 0; i < numOfThreads; ++i)
1940 if(*(threadDone[i]))
1942 foundThreadIndex = i;
1945 if(foundThreadIndex == -1)
1947 __GEN_COUTT__ <<
"Waiting for available thread..."
1952 threadsLaunched = numOfThreads - 1;
1954 __GEN_COUTT__ <<
"Starting init table thread... "
1955 << foundThreadIndex <<
" for " << memberPair.first
1957 *(threadDone[foundThreadIndex]) =
false;
1962 std::string* theAccumulatedWarnings,
1963 std::mutex* theThreadMutex,
1964 std::shared_ptr<std::atomic<bool>> theThreadDone) {
1965 ConfigurationManager::initTableThread(
1968 theAccumulatedWarnings,
1973 nameToTableMap_.at(memberPair.first),
1974 accumulatedWarnings,
1976 threadDone[foundThreadIndex])
1986 foundThreadIndex = -1;
1987 for(
int i = 0; i < numOfThreads; ++i)
1988 if(!*(threadDone[i]))
1990 foundThreadIndex = i;
1993 if(foundThreadIndex != -1)
1995 __GEN_COUTT__ <<
"Waiting for thread to finish... "
1996 << foundThreadIndex << __E__;
1999 }
while(foundThreadIndex != -1);
2005 progressBar->
step();
2014 if(groupType == ConfigurationManager::GroupType::CONTEXT_TYPE)
2020 theContextTableGroup_ = groupName;
2021 theContextTableGroupKey_ =
2022 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2024 else if(groupType == ConfigurationManager::GroupType::BACKBONE_TYPE)
2029 theBackboneTableGroup_ = groupName;
2030 theBackboneTableGroupKey_ =
2031 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2033 else if(groupType == ConfigurationManager::GroupType::ITERATE_TYPE)
2039 theIterateTableGroup_ = groupName;
2040 theIterateTableGroupKey_ =
2041 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2048 theConfigurationTableGroup_ = groupName;
2049 theConfigurationTableGroupKey_ =
2050 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2055 progressBar->
step();
2059 <<
"------------------------------------- init complete \t [for all "
2069 std::pair<std::string, TableGroupKey>(groupName,
TableGroupKey(groupKey));
2075 catch(
const std::runtime_error& e)
2077 __SS__ <<
"Error occurred while loading table group '" << groupName <<
"("
2078 << groupKey <<
")': \n"
2079 << e.what() << __E__;
2081 if(accumulatedWarnings)
2082 *accumulatedWarnings += ss.str();
2088 __SS__ <<
"An unknown error occurred while loading table group '"
2089 << groupName <<
"(" << groupKey <<
")." << __E__;
2094 catch(
const std::exception& e)
2096 ss <<
"Exception message: " << e.what();
2101 if(accumulatedWarnings)
2102 *accumulatedWarnings += ss.str();
2108 __GEN_COUTT__ <<
"loadTableGroup() complete." << __E__;
2110 std::make_pair(std::make_pair(groupName,
TableGroupKey(groupKey)), memberMap);
2115 __GEN_COUTT__ <<
"loadTableGroup() failed." << __E__;
2118 lastFailedGroupLoad_[ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN] =
2119 std::pair<std::string, TableGroupKey>(groupName,
TableGroupKey(groupKey));
2125 catch(
const std::runtime_error& e)
2127 __SS__ <<
"Error occurred while loading table group '" << groupName <<
"("
2128 << groupKey <<
")': \n"
2129 << e.what() << __E__;
2131 if(accumulatedWarnings)
2132 *accumulatedWarnings += ss.str();
2138 __SS__ <<
"An unknown error occurred while loading table group '" << groupName
2139 <<
"(" << groupKey <<
")." << __E__;
2144 catch(
const std::exception& e)
2146 ss <<
"Exception message: " << e.what();
2153 if(accumulatedWarnings)
2154 *accumulatedWarnings += ss.str();
2166 const std::map<std::string, TableVersion>& memberMap,
2167 const std::string& groupName ,
2170 bool ignoreVersionTracking )
2175 ConfigurationManager::GroupType groupType =
getTypeOfGroup(memberMap);
2179 __GEN_COUT__ <<
"------------------------------------- cacheCopy init start "
2181 "plug-ins in member map"
2186 std::string groupToDeactivate =
2187 groupType == ConfigurationManager::GroupType::CONTEXT_TYPE
2188 ? theContextTableGroup_
2189 : (groupType == ConfigurationManager::GroupType::BACKBONE_TYPE
2190 ? theBackboneTableGroup_
2191 : (groupType == ConfigurationManager::GroupType::ITERATE_TYPE
2192 ? theIterateTableGroup_
2193 : theConfigurationTableGroup_));
2196 if(groupToDeactivate !=
"")
2213 for(
auto& memberPair : memberMap)
2215 __GEN_COUTT__ <<
"Copying " << memberPair.first <<
"-v" << memberPair.second
2219 if(nameToTableMap_.find(memberPair.first) == nameToTableMap_.end())
2222 theInterface_->get(table,
2229 nameToTableMap_[memberPair.first] = table;
2231 nameToTableMap_.at(memberPair.first)
2233 ->getView(memberPair.second),
2236 ->getView(memberPair.second)
2244 __GEN_COUTT__ <<
"Done with member copy loop." << __E__;
2250 std::string accumulatedWarnings;
2253 << numOfThreads <<
" threads for initializing tables." << __E__;
2254 if(groupType != ConfigurationManager::GroupType::CONFIGURATION_TYPE ||
2257 for(
auto& memberPair : memberMap)
2260 if(!ignoreVersionTracking &&
2261 ConfigurationInterface::isVersionTrackingEnabled() &&
2262 memberPair.second.isScratchVersion())
2264 __SS__ <<
"Error while activating member Table '"
2265 << nameToTableMap_[memberPair.first]->getTableName()
2266 <<
"-v" << memberPair.second
2267 <<
" for member map. When version tracking is enabled, "
2269 <<
" are not allowed! Please only use unique, persistent "
2270 "versions when version tracking is enabled."
2279 nameToTableMap_.at(memberPair.first)->init(
this);
2281 catch(std::runtime_error& e)
2283 __SS__ <<
"Error detected calling " << memberPair.first
2284 <<
".init()!\n\n " << e.what() << __E__;
2285 accumulatedWarnings += ss.str();
2289 __SS__ <<
"Unknown Error detected calling " << memberPair.first
2290 <<
".init()!\n\n " << __E__;
2295 catch(
const std::exception& e)
2297 ss <<
"Exception message: " << e.what();
2302 accumulatedWarnings += ss.str();
2308 int threadsLaunched = 0;
2309 int foundThreadIndex = 0;
2310 std::mutex threadMutex;
2311 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
2312 for(
int i = 0; i < numOfThreads; ++i)
2313 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
2315 if(!ignoreVersionTracking &&
2316 ConfigurationInterface::isVersionTrackingEnabled())
2317 for(
auto& memberPair : memberMap)
2320 if(memberPair.second.isScratchVersion())
2323 <<
"Error while activating member Table '"
2324 << nameToTableMap_[memberPair.first]->getTableName()
2325 <<
"-v" << memberPair.second
2326 <<
" for member map. When version tracking is enabled, "
2328 <<
" are not allowed! Please only use unique, persistent "
2329 "versions when version tracking is enabled."
2335 for(
auto& memberPair : memberMap)
2337 if(threadsLaunched >= numOfThreads)
2340 foundThreadIndex = -1;
2341 while(foundThreadIndex == -1)
2343 for(
int i = 0; i < numOfThreads; ++i)
2344 if(*(threadDone[i]))
2346 foundThreadIndex = i;
2349 if(foundThreadIndex == -1)
2351 __GEN_COUTT__ <<
"Waiting for available thread..."
2356 threadsLaunched = numOfThreads - 1;
2358 __GEN_COUTT__ <<
"Starting init table thread... " << foundThreadIndex
2359 <<
" for " << memberPair.first << __E__;
2360 *(threadDone[foundThreadIndex]) =
false;
2365 std::string* theAccumulatedWarnings,
2366 std::mutex* theThreadMutex,
2367 std::shared_ptr<std::atomic<bool>> theThreadDone) {
2368 ConfigurationManager::initTableThread(cfgMgr,
2370 theAccumulatedWarnings,
2375 nameToTableMap_.at(memberPair.first),
2376 &accumulatedWarnings,
2378 threadDone[foundThreadIndex])
2388 foundThreadIndex = -1;
2389 for(
int i = 0; i < numOfThreads; ++i)
2390 if(!*(threadDone[i]))
2392 foundThreadIndex = i;
2395 if(foundThreadIndex != -1)
2397 __GEN_COUTT__ <<
"Waiting for thread to finish... "
2398 << foundThreadIndex << __E__;
2401 }
while(foundThreadIndex != -1);
2405 if(accumulatedWarnings !=
"")
2407 __GEN_COUT__ <<
"Activating the member map after copying cache had the "
2408 "following warnings: "
2409 << accumulatedWarnings << __E__;
2420 if(groupType == ConfigurationManager::GroupType::CONTEXT_TYPE)
2426 theContextTableGroup_ = groupName;
2427 theContextTableGroupKey_ =
2428 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2430 else if(groupType == ConfigurationManager::GroupType::BACKBONE_TYPE)
2435 theBackboneTableGroup_ = groupName;
2436 theBackboneTableGroupKey_ =
2437 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2439 else if(groupType == ConfigurationManager::GroupType::ITERATE_TYPE)
2445 theIterateTableGroup_ = groupName;
2446 theIterateTableGroupKey_ =
2447 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2454 theConfigurationTableGroup_ = groupName;
2455 theConfigurationTableGroupKey_ =
2456 std::shared_ptr<TableGroupKey>(
new TableGroupKey(groupKey));
2461 __GEN_COUT__ <<
"------------------------------------- cacheCopy init "
2462 "complete \t [for all "
2463 "plug-ins in member map"
2466 __GEN_COUTT__ <<
"Completed cache copy." << __E__;
2469 make_pair(make_pair(groupName,
TableGroupKey(groupKey)), memberMap);
2473 __GEN_COUT__ <<
"Unknown failure in cache copy." << __E__;
2476 std::pair<std::string, TableGroupKey>(groupName,
TableGroupKey(groupKey));
2483 ConfigurationManager::getGroupOfLoadedTable(
const std::string& tableName)
const
2485 for(
const auto& loadedGroup : lastGroupLoad_)
2486 if(loadedGroup.second.second.find(tableName) != loadedGroup.second.second.end())
2487 return loadedGroup.second.first;
2488 return std::make_pair(
"",
TableGroupKey(TableGroupKey::INVALID));
2495 std::string* accumulatedWarnings,
2496 std::mutex* threadMutex,
2497 std::shared_ptr<std::atomic<bool>> threadDone)
2504 table->
init(cfgMgr);
2506 catch(std::runtime_error& e)
2508 __SS__ <<
"Error detected calling " << table->
getTableName() <<
".init()!\n\n "
2509 << e.what() << __E__;
2511 if(accumulatedWarnings)
2513 std::lock_guard<std::mutex> lock(*threadMutex);
2514 *accumulatedWarnings += ss.str();
2524 __SS__ <<
"Unknown Error detected calling " << table->
getTableName()
2525 <<
".init()!\n\n " << __E__;
2530 catch(
const std::exception& e)
2532 ss <<
"Exception message: " << e.what();
2538 if(accumulatedWarnings)
2540 std::lock_guard<std::mutex> lock(*threadMutex);
2541 *accumulatedWarnings += ss.str();
2544 __COUT_WARN__ << ss.str();
2547 *(threadDone) =
true;
2551 __COUT_WARN__ <<
"Error occurred initializing table '" << table->
getTableName()
2554 *(threadDone) =
true;
2559 void ConfigurationManager::fillTableThread(
2561 std::map<std::string, ots::TableBase*>* nameToTableMap,
2563 std::string tableName,
2565 std::string* threadErrors,
2566 std::mutex* threadMutex,
2567 std::shared_ptr<std::atomic<bool>> threadDone)
2570 __COUTT__ <<
"Thread fill of " << tableName <<
"-v" << version << __E__;
2580 std::string getError =
"";
2585 theInterface->get(table,
2594 catch(
const std::runtime_error& e)
2596 __SS__ <<
"Failed to load member table '" << tableName <<
"-v" << version
2597 <<
"' - here is the error: \n\n"
2598 << e.what() << __E__;
2600 ss <<
"\nIf the table '" << tableName
2601 <<
"' should not exist, then please remove it from the group. If it "
2602 "should exist, then it "
2603 <<
"seems to have a problem; use the Table Editor to fix the table "
2605 "edit the table content to match the table definition."
2610 getError = ss.str();
2616 __SS__ <<
"Failed to load member table '" << tableName <<
"-v" << version
2617 <<
"' due to unknown error!" << __E__;
2622 catch(
const std::exception& e)
2624 ss <<
"Exception message: " << e.what();
2629 ss <<
"\nIf the table '" << tableName
2630 <<
"' should not exist, then please remove it from the group. If it "
2631 "should exist, then it "
2632 <<
"seems to have a problem; use the Table Editor to fix the table "
2634 "edit the table content to match the table definition."
2639 getError = ss.str();
2645 __COUTV__(getError);
2647 __COUT_TYPE__(TLVL_TRACE + 1)
2648 << __COUT_HDR__ <<
"Checking ptr.. " << (table ?
"GOOD" :
"BAD") << __E__;
2651 __SS__ <<
"Null pointer returned for table '" << tableName
2652 <<
".' Was the table info deleted?" << __E__;
2653 __COUT_ERR__ << ss.str();
2655 std::lock_guard<std::mutex> lock(*threadMutex);
2656 nameToTableMap->erase(tableName);
2660 *threadErrors += ss.str();
2661 *(threadDone) =
true;
2669 std::lock_guard<std::mutex> lock(*threadMutex);
2670 (*nameToTableMap)[tableName] = table;
2673 if(nameToTableMap->at(tableName)->getViewP())
2675 __COUT_TYPE__(TLVL_TRACE + 1)
2677 <<
"Activated version: " << nameToTableMap->at(tableName)->getViewVersion()
2680 if(threadErrors && getError !=
"")
2682 __SS__ <<
"Error caught during '" << tableName <<
"' table retrieval: \n"
2683 << getError << __E__;
2684 __COUT_ERR__ << ss.str();
2685 std::lock_guard<std::mutex> lock(*threadMutex);
2686 *threadErrors += ss.str();
2691 __SS__ << tableName <<
": View version not activated properly!";
2695 __COUTT__ <<
"end Thread fill of " << tableName <<
"-v" << version << __E__;
2696 *(threadDone) =
true;
2698 catch(
const std::runtime_error& e)
2700 __SS__ <<
"Error occurred filling table '" << tableName <<
"-v" << version
2701 <<
"': " << e.what() << __E__;
2702 __COUT_ERR__ << ss.str();
2703 std::lock_guard<std::mutex> lock(*threadMutex);
2704 *threadErrors += ss.str();
2706 *(threadDone) =
true;
2710 __SS__ <<
"Unknwon error occurred filling table '" << tableName <<
"-v" << version
2716 catch(
const std::exception& e)
2718 ss <<
"Exception message: " << e.what();
2723 __COUT_ERR__ << ss.str();
2724 std::lock_guard<std::mutex> lock(*threadMutex);
2725 *threadErrors += ss.str();
2727 *(threadDone) =
true;
2736 std::map<std::string, std::pair<std::string, TableGroupKey>>
2740 std::map<std::string, std::pair<std::string, TableGroupKey>> retMap;
2742 retMap[ConfigurationManager::GROUP_TYPE_NAME_CONTEXT] =
2743 std::pair<std::string, TableGroupKey>(
2744 theContextTableGroup_,
2745 theContextTableGroupKey_ ? *theContextTableGroupKey_ :
TableGroupKey());
2746 retMap[ConfigurationManager::GROUP_TYPE_NAME_BACKBONE] =
2747 std::pair<std::string, TableGroupKey>(
2748 theBackboneTableGroup_,
2749 theBackboneTableGroupKey_ ? *theBackboneTableGroupKey_ :
TableGroupKey());
2750 retMap[ConfigurationManager::GROUP_TYPE_NAME_ITERATE] =
2751 std::pair<std::string, TableGroupKey>(
2752 theIterateTableGroup_,
2753 theIterateTableGroupKey_ ? *theIterateTableGroupKey_ :
TableGroupKey());
2754 retMap[ConfigurationManager::GROUP_TYPE_NAME_CONFIGURATION] =
2755 std::pair<std::string, TableGroupKey>(theConfigurationTableGroup_,
2756 theConfigurationTableGroupKey_
2757 ? *theConfigurationTableGroupKey_
2763 const std::string& ConfigurationManager::getActiveGroupName(
2764 const ConfigurationManager::GroupType& type)
const
2766 if(type == ConfigurationManager::GroupType::CONFIGURATION_TYPE)
2767 return theConfigurationTableGroup_;
2768 else if(type == ConfigurationManager::GroupType::CONTEXT_TYPE)
2769 return theContextTableGroup_;
2770 else if(type == ConfigurationManager::GroupType::BACKBONE_TYPE)
2771 return theBackboneTableGroup_;
2772 else if(type == ConfigurationManager::GroupType::ITERATE_TYPE)
2773 return theIterateTableGroup_;
2775 __SS__ <<
"IMPOSSIBLE! Invalid type requested '" << (int)type <<
"'" << __E__;
2781 const ConfigurationManager::GroupType& type)
const
2783 if(type == ConfigurationManager::GroupType::CONFIGURATION_TYPE)
2784 return theConfigurationTableGroupKey_ ? *theConfigurationTableGroupKey_
2786 else if(type == ConfigurationManager::GroupType::CONTEXT_TYPE)
2787 return theContextTableGroupKey_ ? *theContextTableGroupKey_ :
TableGroupKey();
2788 else if(type == ConfigurationManager::GroupType::BACKBONE_TYPE)
2789 return theBackboneTableGroupKey_ ? *theBackboneTableGroupKey_ :
TableGroupKey();
2790 else if(type == ConfigurationManager::GroupType::ITERATE_TYPE)
2791 return theIterateTableGroupKey_ ? *theIterateTableGroupKey_ :
TableGroupKey();
2793 __SS__ <<
"IMPOSSIBLE! Invalid type requested '" << (int)type <<
"'" << __E__;
2799 const std::string& contextUID,
const std::string& )
const
2807 const std::string& contextUID,
const std::string& applicationUID)
const
2810 contextUID +
"/LinkToApplicationTable/" + applicationUID);
2815 const std::string& contextUID,
const std::string& applicationUID)
const
2818 contextUID +
"/LinkToApplicationTable/" + applicationUID +
2819 "/LinkToSupervisorTable");
2826 auto contextChildren =
2829 for(
const auto& contextChild : contextChildren)
2831 auto appChildren = contextChild.second.getNode(
"LinkToApplicationTable")
2833 for(
const auto& appChild : appChildren)
2835 if(appChild.second.getNode(
"Class").getValue() ==
2836 "ots::GatewaySupervisor")
2837 return appChild.second;
2840 __SS__ <<
"No Gateway Supervisor node found!" << __E__;
2846 bool doNotThrowOnBrokenUIDLinks)
const
2851 if(nodeString.length() < 1)
2853 __SS__ << (
"Invalid empty node name") << __E__;
2858 size_t startingIndex = 0;
2859 while(startingIndex < nodeString.length() && nodeString[startingIndex] ==
'/')
2861 size_t endingIndex = nodeString.find(
'/', startingIndex);
2862 if(endingIndex == std::string::npos)
2863 endingIndex = nodeString.length();
2865 std::string nodeName = nodeString.substr(startingIndex, endingIndex - startingIndex);
2867 if(nodeName.length() < 1)
2877 std::string childPath =
2878 (endingIndex >= nodeString.length() ?
"" : nodeString.substr(endingIndex));
2884 if(childPath.length() > 1)
2885 return configTree.
getNode(childPath, doNotThrowOnBrokenUIDLinks);
2891 std::map<std::string, ConfigurationTree> ConfigurationManager::getNodes(
2892 const std::string& nodeString)
const
2904 std::string path =
"/";
2915 std::map<std::string, TableVersion>* memberMap,
2916 std::string* accumulatedTreeErrors)
const
2918 std::vector<std::pair<std::string, ConfigurationTree>> retVector;
2923 bool filtering = memberMap && memberMap->size();
2926 for(
auto& tablePair : nameToTableMap_)
2931 if(memberMap->find(tablePair.first) == memberMap->end())
2937 if(!tablePair.second->isActive())
2939 __SS__ <<
"Get Children with member map requires a child '"
2940 << tablePair.first <<
"' that is not active!" << __E__;
2944 catch(
const std::runtime_error& e)
2946 if(accumulatedTreeErrors)
2948 *accumulatedTreeErrors += e.what();
2949 __GEN_COUT_ERR__ <<
"Skipping " << tablePair.first
2950 <<
" since the table "
2959 if(!tablePair.second->isActive())
2963 if(accumulatedTreeErrors)
2967 std::vector<std::pair<std::string, ConfigurationTree>> newNodeChildren =
2969 for(
auto& newNodeChild : newNodeChildren)
2971 if(newNodeChild.second.getTableName() ==
2972 ConfigurationManager::DESKTOP_ICON_TABLE_NAME &&
2973 !newNodeChild.second.isEnabled())
2976 std::vector<std::pair<std::string, ConfigurationTree>>
2977 twoDeepChildren = newNodeChild.second.getChildren();
2979 for(
auto& twoDeepChild : twoDeepChildren)
2984 if(twoDeepChild.second.isLinkNode() &&
2985 twoDeepChild.second.isDisconnected() &&
2986 twoDeepChild.second.getDisconnectedTableName() !=
2987 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
2989 __SS__ <<
"At node '" + tablePair.first +
2990 "' with entry UID '" + newNodeChild.first +
2991 "' there is a disconnected child node at link "
2993 twoDeepChild.first +
"'" +
2994 " that points to table named '" +
2995 twoDeepChild.second.getDisconnectedTableName() +
2997 *accumulatedTreeErrors += ss.str();
3002 catch(std::runtime_error& e)
3004 __SS__ <<
"At node '" + tablePair.first +
3005 "' error detected descending through children:\n" +
3007 *accumulatedTreeErrors += ss.str();
3011 retVector.push_back(
3012 std::pair<std::string, ConfigurationTree>(tablePair.first, newNode));
3026 std::string* accumulatedTreeErrors)
const
3033 bool filtering = memberMap && memberMap->size();
3036 for(
auto& tablePair : nameToTableMap_)
3041 if(memberMap->find(tablePair.first) == memberMap->end())
3047 if(!tablePair.second->isActive())
3049 __SS__ <<
"Get Children with member map requires a child '"
3050 << tablePair.first <<
"' that is not active!" << __E__;
3054 catch(
const std::runtime_error& e)
3056 if(accumulatedTreeErrors)
3058 *accumulatedTreeErrors += e.what();
3059 __GEN_COUT_ERR__ <<
"Skipping " << tablePair.first
3060 <<
" since the table "
3069 if(!tablePair.second->isActive())
3073 if(accumulatedTreeErrors)
3077 std::vector<std::pair<std::string, ConfigurationTree>> newNodeChildren =
3079 for(
auto& newNodeChild : newNodeChildren)
3081 if(newNodeChild.second.getTableName() ==
3082 ConfigurationManager::DESKTOP_ICON_TABLE_NAME &&
3083 !newNodeChild.second.isEnabled())
3086 std::vector<std::pair<std::string, ConfigurationTree>>
3087 twoDeepChildren = newNodeChild.second.getChildren();
3089 for(
auto& twoDeepChild : twoDeepChildren)
3094 if(twoDeepChild.second.isLinkNode() &&
3095 twoDeepChild.second.isDisconnected() &&
3096 twoDeepChild.second.getDisconnectedTableName() !=
3097 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
3099 __SS__ <<
"At node '" + tablePair.first +
3100 "' with entry UID '" + newNodeChild.first +
3101 "' there is a disconnected child node at link "
3103 twoDeepChild.first +
"'" +
3104 " that points to table named '" +
3105 twoDeepChild.second.getDisconnectedTableName() +
3107 *accumulatedTreeErrors += ss.str();
3112 catch(std::runtime_error& e)
3114 __SS__ <<
"At node '" + tablePair.first +
3115 "' error detected descending through children:\n" +
3117 *accumulatedTreeErrors += ss.str();
3122 std::pair<std::string, ConfigurationTree>(tablePair.first, newNode));
3135 std::map<std::string, TableBase*>::const_iterator it;
3136 if((it = nameToTableMap_.find(tableName)) == nameToTableMap_.end())
3138 __SS__ <<
"Can not find table named '" << tableName
3139 <<
"' - you need to load the table before it can be used.";
3141 if(nameToTableMap_.size() == 0)
3142 ss <<
"\n\nAll tables are missing. Your configuration database connection "
3143 "may have been interrupted. Did an ssh tunnel disconnect?"
3147 ss <<
" It probably is missing from the member list of the Table "
3148 "Group that was loaded.\n"
3149 <<
"\nYou may need to enter wiz mode to remedy the situation, use the "
3151 <<
"\n\t StartOTS.sh --wiz"
3173 if(!theBackboneTableGroupKey_)
3175 __GEN_COUT_WARN__ <<
"getTableGroupKey() Failed! No active backbone currently."
3181 loadTableGroup(theBackboneTableGroup_, *theBackboneTableGroupKey_);
3183 return *theBackboneTableGroupKey_;
3200 std::string systemAlias,
ProgressBar* progressBar)
3210 progressBar->
step();
3212 if(systemAlias.find(
"GROUP:") == 0)
3215 progressBar->
step();
3217 unsigned int i = strlen(
"GROUP:");
3218 unsigned int j = systemAlias.find(
':', i);
3221 progressBar->
step();
3223 return std::pair<std::string, TableGroupKey>(
3224 systemAlias.substr(i, j - i),
TableGroupKey(systemAlias.substr(j + 1)));
3226 return std::pair<std::string, TableGroupKey>(
"",
TableGroupKey());
3232 progressBar->
step();
3238 getNode(ConfigurationManager::GROUP_ALIASES_TABLE_NAME).
getNode(systemAlias);
3241 progressBar->
step();
3243 return std::pair<std::string, TableGroupKey>(
3254 progressBar->
step();
3256 return std::pair<std::string, TableGroupKey>(
"",
TableGroupKey());
3262 std::map<std::string , std::pair<std::string ,
TableGroupKey>>
3268 ConfigurationManager::LoadGroupType::
3269 ONLY_BACKBONE_TYPE);
3272 std::map<std::string ,
3276 std::vector<std::pair<std::string, ConfigurationTree>> entries =
3278 for(
auto& entryPair : entries)
3280 retMap[entryPair.first] = std::pair<std::string, TableGroupKey>(
3281 entryPair.second.getNode(
"GroupName").getValueAsString(),
3282 TableGroupKey(entryPair.second.getNode(
"GroupKey").getValueAsString()));
3290 std::map<std::string ,
3296 std::map<std::string ,
3301 std::string versionAliasesTableName =
3302 ConfigurationManager::VERSION_ALIASES_TABLE_NAME;
3303 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
3305 __SS__ <<
"Active version of VersionAliases missing!"
3306 <<
" Make sure you have a valid active Backbone Group." << __E__;
3307 __GEN_COUT_WARN__ <<
"\n" << ss.str();
3313 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
3319 std::string tableName, versionAlias;
3320 for(
auto& aliasNodePair : aliasNodePairs)
3322 tableName = aliasNodePair.second.getNode(
"TableName").getValueAsString();
3323 versionAlias = aliasNodePair.second.getNode(
"VersionAlias").getValueAsString();
3325 if(retMap.find(tableName) != retMap.end() &&
3326 retMap[tableName].find(versionAlias) != retMap[tableName].end())
3331 retMap[tableName][versionAlias] =
3332 TableVersion(aliasNodePair.second.getNode(
"Version").getValueAsString());
3342 std::map<std::string, TableVersion> retMap;
3343 for(
auto& config : nameToTableMap_)
3348 if(config.second && config.second->isActive())
3352 retMap.insert(std::pair<std::string, TableVersion>(
3353 config.first, config.second->getViewVersion()));
3385 if(theConfigurationTableGroupKey_)
3387 if(*theConfigurationTableGroupKey_ != key)
3390 return theConfigurationTableGroupKey_;
3392 return std::shared_ptr<TableGroupKey>(
new TableGroupKey(key));
3396 const std::set<std::string>& ConfigurationManager::getContextMemberNames()
3402 const std::set<std::string>& ConfigurationManager::getBackboneMemberNames()
3408 const std::set<std::string>& ConfigurationManager::getIterateMemberNames()
3413 const std::set<std::string>& ConfigurationManager::getConfigurationMemberNames(
void)
3419 for(
auto& tablePair : activeTables)
3432 void ConfigurationManager::initializeFromFhicl(
const std::string& fhiclPath)
3434 __GEN_COUT__ <<
"Initializing from fhicl: " << fhiclPath << __E__;
3439 fhicl::ParameterSet pset = LoadParameterSet(fhiclPath);
3441 if(pset.get_names().size() == 0)
3443 __GEN_SS__ <<
"Empty fcl configuration parameter set found! File: " << fhiclPath
3475 theInterface_->get(table,
3476 ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME,
3482 nameToTableMap_[ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME] = table;
3485 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3488 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3493 auto colMap = view->getColumnNamesMap();
3495 view->
setValue(
"MacroMakerFEContext", 0, colMap[
"ContextUID"]);
3496 view->
setValue(
"XDAQApplicationTable", 0, colMap[
"LinkToApplicationTable"]);
3497 view->
setValue(
"MacroMakerFEContextApps", 0, colMap[
"LinkToApplicationGroupID"]);
3498 view->
setValue(
"1", 0, colMap[TableViewColumnInfo::COL_NAME_STATUS]);
3500 __GEN_COUT__ <<
"Done adding context record..." << __E__;
3510 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
3516 nameToTableMap_[ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME] = table;
3519 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3522 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3527 auto colMap = view->getColumnNamesMap();
3529 view->
setValue(
"MacroMakerFEContextApps", 0, colMap[
"ApplicationGroupID"]);
3530 view->
setValue(
"MacroMakerFESupervisor", 0, colMap[
"ApplicationUID"]);
3531 view->
setValue(
"FESupervisorTable", 0, colMap[
"LinkToSupervisorTable"]);
3532 view->
setValue(
"MacroMakerFESupervisor", 0, colMap[
"LinkToSupervisorUID"]);
3533 view->
setValue(
"1", 0, colMap[TableViewColumnInfo::COL_NAME_STATUS]);
3534 view->
setValue(__ENV__(
"FE_SUPERVISOR_ID"), 0, colMap[
"Id"]);
3536 __GEN_COUT__ <<
"Done adding application record..." << __E__;
3543 theInterface_->get(table,
3544 "FESupervisorTable",
3550 nameToTableMap_[
"FESupervisorTable"] = table;
3553 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3556 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3561 auto colMap = view->getColumnNamesMap();
3563 view->
setValue(
"MacroMakerFESupervisor", 0, colMap[
"SupervisorUID"]);
3564 view->
setValue(
"FEInterfaceTable", 0, colMap[
"LinkToFEInterfaceTable"]);
3566 "MacroMakerFESupervisorInterfaces", 0, colMap[
"LinkToFEInterfaceGroupID"]);
3568 __GEN_COUT__ <<
"Done adding supervisor record..." << __E__;
3573 recursiveInitFromFhiclPSet(
"FEInterfaceTable" ,
3576 "MacroMakerFESupervisorInterfaces" ,
3580 for(
auto& table : nameToTableMap_)
3582 table.second->getViewP()->
init();
3588 __GEN_COUT__ <<
"================================================" << __E__;
3589 nameToTableMap_[
"FESupervisorTable"]->getViewP()->print();
3590 nameToTableMap_[
"FEInterfaceTable"]->getViewP()->print();
3593 __GEN_COUT__ <<
"Supervisors extracted from fhicl: " << sups.size() << __E__;
3595 __GEN_COUT__ <<
"Front-ends extracted from fhicl: " << fes.size() << __E__;
3597 auto a =
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME);
3598 __GEN_COUTV__(a.getValueAsString());
3600 auto b = a.getNode(
"MacroMakerFEContext");
3601 __GEN_COUTV__(b.getValueAsString());
3603 auto c = b.getNode(
"LinkToApplicationTable");
3604 __GEN_COUTV__(c.getValueAsString());
3606 auto d = c.getNode(
"MacroMakerFESupervisor");
3607 __GEN_COUTV__(d.getValueAsString());
3609 auto e = d.getNode(
"LinkToSupervisorTable");
3610 __GEN_COUTV__(e.getValueAsString());
3612 auto f = e.getNode(
"LinkToFEInterfaceTable");
3613 __GEN_COUTV__(f.getValueAsString());
3615 auto z = f.getChildrenNames();
3617 __GEN_COUTV__(z.size());
3618 auto y = f.getChildrenNames(
false ,
true );
3620 __GEN_COUTV__(y.size());
3621 auto x = f.getChildrenNames(
true ,
true );
3623 __GEN_COUTV__(x.size());
3625 auto g = f.getNode(
"dtc0");
3626 __GEN_COUTV__(g.getValueAsString());
3627 auto h = f.getNode(
"interface0");
3628 __GEN_COUTV__(h.getValueAsString());
3631 getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
3633 "MacroMakerFEContext/LinkToApplicationTable/"
3634 "MacroMakerFESupervisor/LinkToSupervisorTable")
3635 .
getNode(
"LinkToFEInterfaceTable")
3637 __GEN_COUTV__(fes.size());
3649 void ConfigurationManager::recursiveInitFromFhiclPSet(
const std::string& tableName,
3650 const fhicl::ParameterSet& pset,
3651 const std::string& recordName,
3652 const std::string& groupName,
3653 const std::string& groupLinkIndex)
3655 __GEN_COUT__ << __COUT_HDR_P__ <<
"Adding table '" << tableName <<
"' record(s)..."
3662 if(nameToTableMap_.find(tableName) == nameToTableMap_.end())
3664 __GEN_COUT__ <<
"Table not found, so making '" << tableName <<
"' instance..."
3666 theInterface_->get(table,
3673 nameToTableMap_[tableName] = table;
3678 __GEN_COUT__ <<
"Existing table found, so using '" << tableName
3679 <<
"'instance..." << __E__;
3680 table = nameToTableMap_[tableName];
3683 table->setActiveView(
TableVersion(TableVersion::DEFAULT));
3686 __GEN_COUT__ <<
"Activated version: " << view->getVersion() << __E__;
3689 if(recordName !=
"")
3697 __GEN_COUTV__(recordName);
3700 unsigned int r = view->
addRow();
3701 auto colMap = view->getColumnNamesMap();
3711 __GEN_COUT__ <<
"No status column to set for '" << recordName <<
"'"
3717 __GEN_COUT__ <<
"Setting group ID for group link index '"
3718 << groupLinkIndex <<
"'" << __E__;
3721 __GEN_COUT__ <<
"Setting group ID for group link index '"
3722 << groupLinkIndex <<
"' at column " << groupIDCol <<
" to '"
3723 << groupName <<
".'" << __E__;
3725 view->
setValue(groupName, r, groupIDCol);
3729 auto names = pset.get_names();
3730 for(
const auto& colName : names)
3732 if(!pset.is_key_to_atom(colName))
3735 auto colIt = colMap.find(colName);
3736 if(colIt == colMap.end())
3738 __SS__ <<
"Field '" << colName <<
"' of record '" << recordName
3739 <<
"' in table '" << tableName <<
"' was not found in columns."
3740 <<
"\n\nHere are the existing column names:\n";
3742 for(
const auto& col : colMap)
3743 ss <<
"\n" << ++i <<
".\t" << col.first;
3748 if(view->getColumnInfo(colIt->second).
isGroupID())
3751 const std::string value = pset.get<std::string>(colName);
3752 __GEN_COUT__ <<
"Setting '" << recordName <<
"' parameter at column "
3753 << colIt->second <<
", '" << colName <<
"'\t = " << value
3759 for(
const auto& linkName : names)
3761 if(pset.is_key_to_atom(linkName))
3764 __GEN_COUTV__(linkName);
3767 unsigned int c = linkName.size() - 1;
3769 if(linkName[c] ==
'_')
3774 __SS__ <<
"Illegal link name '" << linkName
3775 <<
"' found. The format must be <Column name>_<Target table "
3776 "name>,.. for example '"
3777 <<
"LinkToFETypeTable_FEOtsUDPTemplateInterfaceTable'"
3781 std::string colName = linkName.substr(0, c);
3782 __GEN_COUTV__(colName);
3784 auto colIt = colMap.find(colName);
3785 if(colIt == colMap.end())
3787 __SS__ <<
"Link '" << colName <<
"' of record '" << recordName
3788 <<
"' in table '" << tableName <<
"' was not found in columns."
3789 <<
"\n\nHere are the existing column names:\n";
3791 for(
const auto& col : colMap)
3792 ss <<
"\n" << i <<
".\t" << col.first << __E__;
3797 std::pair<
unsigned int ,
unsigned int >
3800 view->
getChildLink(colIt->second, isGroupLink, linkPair);
3806 std::string linkTableName = linkName.substr(c + 1);
3807 __GEN_COUTV__(linkTableName);
3809 auto linkPset = pset.get<fhicl::ParameterSet>(linkName);
3810 auto linkRecords = linkPset.get_pset_names();
3811 if(!isGroupLink && linkRecords.size() > 1)
3813 __SS__ <<
"A Unique Link can only point to one record. "
3814 <<
"The specified link '" << colName <<
"' of record '"
3815 << recordName <<
"' in table '" << tableName <<
"' has "
3816 << linkRecords.size() <<
" children records specified. "
3821 if(linkRecords.size() == 0)
3823 __GEN_COUT__ <<
"No child records, so leaving link disconnected."
3828 __GEN_COUT__ <<
"Setting Link at columns [" << linkPair.first <<
","
3829 << linkPair.second <<
"]" << __E__;
3830 view->
setValue(linkTableName, r, linkPair.first);
3834 __GEN_COUT__ <<
"Setting up Unique link to " << linkRecords[0]
3837 view->
setValue(linkRecords[0], r, linkPair.second);
3839 recursiveInitFromFhiclPSet(
3841 linkPset.get<fhicl::ParameterSet>(
3848 std::string childLinkIndex =
3850 std::string groupName = recordName +
"Group";
3852 view->
setValue(groupName, r, linkPair.second);
3854 for(
const auto& groupRecord : linkRecords)
3856 __GEN_COUT__ <<
"Setting '" << childLinkIndex
3857 <<
"' Group link to '" << groupName <<
"' record '"
3858 << groupRecord <<
"'" << __E__;
3860 recursiveInitFromFhiclPSet(
3862 linkPset.get<fhicl::ParameterSet>(
3872 else if(groupName !=
"")
3876 __GEN_COUTV__(groupName);
3877 auto psets = pset.get_pset_names();
3878 for(
const auto& ps : psets)
3881 recursiveInitFromFhiclPSet(
3883 pset.get<fhicl::ParameterSet>(ps) ,
3891 __SS__ <<
"Illegal recursive parameters!" << __E__;
3894 __GEN_COUT__ << __COUT_HDR_P__ <<
"Done adding table '" << tableName
3895 <<
"' record(s)..." << __E__;
3902 bool ConfigurationManager::isOwnerFirstAppInContext()
3905 if(ownerContextUID_ ==
"" || ownerAppUID_ ==
"")
3913 auto contextChildren =
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME +
3914 "/" + ownerContextUID_)
3917 bool isFirstAppInContext =
3918 contextChildren.size() == 0 || contextChildren[0] == ownerAppUID_;
3922 return isFirstAppInContext;
3931 void ConfigurationManager::getOtherSubsystemInstanceInfo(
3932 const std::string& otherSubsystemUID,
3933 std::string* userDataPathPtr ,
3934 std::string* hostnamePtr ,
3935 std::string* usernamePtr ,
3936 std::string* fullNamePtr )
3938 __GEN_COUTTV__(otherSubsystemUID);
3941 getNode(ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE)
3943 std::string userPath = node.
getNode(
"SubsystemUserDataPath").
getValue();
3950 if(!splitPath.size() || splitPath.size() > 2)
3952 __GEN_SS__ <<
"Illegal user data path specified for subsystem '"
3953 << otherSubsystemUID <<
"': " << userPath << __E__;
3956 std::string userDataPath = splitPath[splitPath.size() - 1];
3959 for(
unsigned int i = 0; i < userDataPath.length(); ++i)
3960 if(!((userDataPath[i] >=
'a' && userDataPath[i] <=
'z') ||
3961 (userDataPath[i] >=
'A' && userDataPath[i] <=
'Z') ||
3962 (userDataPath[i] >=
'0' && userDataPath[i] <=
'9') ||
3963 userDataPath[i] ==
'-' || userDataPath[i] ==
'_' || userDataPath[i] ==
'/'))
3965 __GEN_SS__ <<
"Illegal user data path specified (no special characters "
3966 "allowed) for subsystem '"
3967 << otherSubsystemUID <<
"': " << userPath << __E__;
3972 *userDataPathPtr = userDataPath;
3974 std::string username, hostname;
3975 if(splitPath.size() == 2)
3978 std::vector<std::string> userHostSplit =
3980 __GEN_COUTTV__(userHostSplit.size());
3981 if(userHostSplit.size() == 1)
3982 hostname = userHostSplit[0];
3983 else if(userHostSplit.size() == 2)
3985 username = userHostSplit[0];
3986 hostname = userHostSplit[1];
3990 __GEN_SS__ <<
"Illegal remote username/host specified for subsystem '"
3991 << otherSubsystemUID <<
"': " << userPath << __E__;
3995 for(
unsigned int i = 0; userHostSplit.size() == 2 && i < username.length(); ++i)
3996 if(!((username[i] >=
'a' && username[i] <=
'z') ||
3997 (username[i] >=
'A' && username[i] <=
'Z') ||
3998 (username[i] >=
'0' && username[i] <=
'9') || username[i] ==
'-' ||
3999 username[i] ==
'_'))
4001 __GEN_SS__ <<
"Illegal remote username specified for subsystem '"
4002 << otherSubsystemUID <<
"': " << userPath << __E__;
4005 unsigned int ii = 0;
4006 for(
unsigned int i = 0; i < hostname.length(); ++i)
4007 if(!((hostname[i] >=
'a' && hostname[i] <=
'z') ||
4008 (hostname[i] >=
'A' && hostname[i] <=
'Z') ||
4009 (hostname[i] >=
'0' && hostname[i] <=
'9') || hostname[i] ==
'-' ||
4010 hostname[i] ==
'_'))
4012 if(hostname[i] ==
'.' && i > ii + 1)
4019 __GEN_SS__ <<
"Illegal remote hostname '" << hostname
4020 <<
"' specified for subsystem '" << otherSubsystemUID
4021 <<
"': " << userPath << __E__;
4026 else if(splitPath.size() == 1)
4028 __GEN_COUT__ <<
"Local user date path identified." << __E__;
4032 __GEN_SS__ <<
"Illegal user data path specified for subsystem '"
4033 << otherSubsystemUID <<
"': " << userPath << __E__;
4038 *hostnamePtr = hostname;
4040 *usernamePtr = username;
4045 std::map<std::string , std::pair<std::string ,
TableGroupKey>>
4046 ConfigurationManager::getOtherSubsystemActiveTableGroups(
4047 const std::string& otherSubsystemUID,
4048 std::string* userDataPathPtr ,
4049 std::string* hostnamePtr ,
4050 std::string* usernamePtr )
4052 std::map<std::string ,
4056 __GEN_COUTTV__(otherSubsystemUID);
4058 std::string userDataPath;
4059 std::string username, hostname;
4061 getOtherSubsystemInstanceInfo(otherSubsystemUID, &userDataPath, &hostname, &username);
4063 __GEN_COUTTV__(userDataPath);
4064 __GEN_COUTTV__(username);
4065 __GEN_COUTTV__(hostname);
4068 *userDataPathPtr = userDataPath;
4070 *hostnamePtr = hostname;
4072 *usernamePtr = username;
4075 std::string filename = userDataPath +
"/ServiceData/ActiveTableGroups.cfg";
4077 std::string cmdResult;
4081 std::string tmpSubsystemFilename =
4083 __GEN_COUTTV__(tmpSubsystemFilename);
4087 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + username +
"@" +
4088 hostname +
":" + filename +
" " + tmpSubsystemFilename +
" 2>&1; cat " +
4089 tmpSubsystemFilename +
" 2>&1")
4094 (
"rm " + tmpSubsystemFilename +
" 2>/dev/null; scp " + hostname +
":" +
4095 filename +
" " + tmpSubsystemFilename +
" 2>&1; cat " +
4096 tmpSubsystemFilename +
" 2>&1")
4101 __GEN_COUT__ <<
"Local user date path identified." << __E__;
4105 __GEN_COUTTV__(cmdResult);
4106 if(cmdResult.find(
"Permission denied") != std::string::npos)
4109 <<
"Permission denied accessing user data path specified for subsystem '"
4110 << otherSubsystemUID <<
"': ";
4112 ss << username <<
"@";
4114 ss << hostname <<
":";
4115 ss << userDataPath << __E__;
4120 cmdResult, {
'\n'} , {
' ',
'\t'} );
4122 __GEN_COUTTV__(subsystemActiveGroupMap.size());
4126 for(
unsigned int i = 0; i + 1 < subsystemActiveGroupMap.size(); i += 2)
4128 if(subsystemActiveGroupMap[i] ==
"" || subsystemActiveGroupMap[i + 1] ==
"-1")
4131 __GEN_COUTT__ <<
"Loading type of subsystem '" << otherSubsystemUID <<
"' group "
4132 << subsystemActiveGroupMap[i] <<
"("
4133 << subsystemActiveGroupMap[i + 1] <<
")" << __E__;
4149 catch(
const std::runtime_error& e)
4151 __GEN_COUT__ <<
"Ignoring error loading subsystem '" << otherSubsystemUID
4152 <<
"' group " << subsystemActiveGroupMap[i] <<
"("
4153 << subsystemActiveGroupMap[i + 1] <<
"): " << __E__ << e.what()
4155 groupType = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
4157 retMap[groupType] = std::make_pair(subsystemActiveGroupMap[i],
4167 std::set<std::string >
4170 std::set<std::string> retSet;
4172 std::map<std::string ,
4174 retMap = getOtherSubsystemActiveTableGroups(otherSubsystemUID);
4177 auto it = retMap.find(
4179 if(it == retMap.end())
4182 <<
"No active Backbone group found in the active groups of remote subsystem '"
4183 << otherSubsystemUID <<
"!'" << __E__;
4186 auto it2 = retMap.find(
4188 if(it2 == retMap.end())
4191 <<
"No active Context group found in the active groups of remote subsystem '"
4192 << otherSubsystemUID <<
"!'" << __E__;
4196 std::string accumulatedWarnings;
4205 &accumulatedWarnings
4207 __GEN_COUTTV__(accumulatedWarnings);
4210 std::vector<std::pair<std::string, ConfigurationTree>> entries =
4213 for(
auto& entry : entries)
4215 if(entry.first.find(
"Context") == std::string::npos &&
4216 entry.first.find(
"Iterat") == std::string::npos)
4217 retSet.emplace(entry.first);
4224 std::set<std::string >
4226 const std::string& otherSubsystemUID,
const std::string& otherSubsystemFsmName)
4228 std::set<std::string> retSet;
4230 std::map<std::string ,
4232 retMap = getOtherSubsystemActiveTableGroups(otherSubsystemUID);
4235 auto it = retMap.find(
4237 if(it == retMap.end())
4240 <<
"No active Backbone group found in the active groups of remote subsystem '"
4241 << otherSubsystemUID <<
"!'" << __E__;
4244 auto it2 = retMap.find(
4246 if(it2 == retMap.end())
4249 <<
"No active Context group found in the active groups of remote subsystem '"
4250 << otherSubsystemUID <<
"!'" << __E__;
4254 std::string accumulatedWarnings;
4263 &accumulatedWarnings
4270 &accumulatedWarnings
4272 __GEN_COUTTV__(accumulatedWarnings);
4275 std::vector<std::pair<std::string, ConfigurationTree>> entries =
4280 std::string stateMachineAliasFilter =
"*";
4285 otherGatewayNode.
getNode(
"LinkToStateMachineTable")
4286 .
getNode(otherSubsystemFsmName +
"/SystemAliasFilter");
4288 stateMachineAliasFilter = fsmFilterNode.
getValue<std::string>();
4290 __GEN_COUT_INFO__ <<
"FSM has no SystemAliasFilter value." << __E__;
4292 catch(std::runtime_error& e)
4294 __COUT__ <<
"Ignoring unsetup SystemAliasFilter value: " << e.what() << __E__;
4298 __COUT__ <<
"Ignoring unsetup SystemAliasFilter value." << __E__;
4301 __COUT__ <<
"Applying alias filter for other user_data path FSM '"
4302 << otherSubsystemFsmName
4303 <<
"' and stateMachineAliasFilter = " << stateMachineAliasFilter << __E__;
4310 stateMachineAliasFilter.size() && stateMachineAliasFilter[0] ==
'!';
4311 std::vector<std::string> filterArr;
4318 while((f = stateMachineAliasFilter.find(
'*', i)) != std::string::npos)
4320 tmp = stateMachineAliasFilter.substr(i, f - i);
4322 filterArr.push_back(tmp);
4323 __COUT_TYPE__(TLVL_DEBUG + 20)
4324 << __COUT_HDR__ << filterArr[filterArr.size() - 1] <<
" " << i <<
" of "
4325 << stateMachineAliasFilter.size() << __E__;
4327 if(i <= stateMachineAliasFilter.size())
4329 tmp = stateMachineAliasFilter.substr(i);
4330 filterArr.push_back(tmp);
4331 __COUT_TYPE__(TLVL_DEBUG + 20)
4332 << __COUT_HDR__ << filterArr[filterArr.size() - 1] <<
" last." << __E__;
4337 for(
auto& aliasMapPair : entries)
4339 __COUT_TYPE__(TLVL_DEBUG + 20)
4340 << __COUT_HDR__ <<
"aliasMapPair.first: " << aliasMapPair.first << __E__;
4344 if(filterArr.size() == 1)
4346 if(filterArr[0] !=
"" && filterArr[0] !=
"*" &&
4347 aliasMapPair.first != filterArr[0])
4348 filterMatch =
false;
4353 for(f = 0; f < filterArr.size(); ++f)
4355 if(!filterArr[f].size())
4360 if((i = aliasMapPair.first.find(filterArr[f])) != 0)
4362 filterMatch =
false;
4366 else if(f == filterArr.size() - 1)
4368 if(aliasMapPair.first.rfind(filterArr[f]) !=
4369 aliasMapPair.first.size() - filterArr[f].size())
4371 filterMatch =
false;
4375 else if((i = aliasMapPair.first.find(filterArr[f])) ==
4378 filterMatch =
false;
4385 filterMatch = !filterMatch;
4387 __COUT_TYPE__(TLVL_DEBUG + 20)
4388 << __COUT_HDR__ <<
"filterMatch=" << filterMatch << __E__;
4393 retSet.emplace(aliasMapPair.first);
4405 const std::string& otherSubsystemUID,
4406 const std::string& configAlias,
4407 std::pair<std::string, TableGroupKey>& groupTranslation,
4408 std::string& groupComment,
4409 std::string& groupAuthor,
4410 std::string& groupCreationTime)
4412 __GEN_COUTV__(otherSubsystemUID);
4414 std::map<std::string ,
4416 retMap = getOtherSubsystemActiveTableGroups(otherSubsystemUID);
4419 auto it = retMap.find(
4421 if(it == retMap.end())
4424 <<
"No active Backbone group found in the active groups of remote subsystem '"
4425 << otherSubsystemUID <<
"!'" << __E__;
4428 auto it2 = retMap.find(
4430 if(it2 == retMap.end())
4433 <<
"No active Context group found in the active groups of remote subsystem '"
4434 << otherSubsystemUID <<
"!'" << __E__;
4438 std::string accumulatedWarnings;
4447 &accumulatedWarnings
4449 __GEN_COUTTV__(accumulatedWarnings);
4456 getNode(ConfigurationManager::GROUP_ALIASES_TABLE_NAME).
getNode(configAlias);
4458 groupTranslation = std::pair<std::string, TableGroupKey>(
4461 __COUT__ <<
"Found " << configAlias <<
" translates to " << groupTranslation.first
4462 <<
"(" << groupTranslation.second <<
")" << __E__;
4468 groupTranslation.second,
4472 &accumulatedWarnings,
4480 __COUT_WARN__ <<
"Failed to load group metadata." << __E__;
4482 __COUT__ <<
"Found " << configAlias <<
" author: " << groupAuthor
4483 <<
", createTime: " << groupCreationTime <<
", comment: " << groupComment
4488 __GEN_SS__ <<
"Did not find the Configuration Alias '" << configAlias
4489 <<
"' in the active Backbone group of remote subsystem '"
4490 << otherSubsystemUID <<
"!'" << __E__;
4498 TableBase* ConfigurationManager::getDesktopIconTable(
void)
4500 if(nameToTableMap_.find(DESKTOP_ICON_TABLE_NAME) == nameToTableMap_.end())
4502 __SS__ <<
"Desktop icon table not found!" << __E__;
4507 return nameToTableMap_.at(DESKTOP_ICON_TABLE_NAME);
4511 void ConfigurationManager::saveGroupNameAndKey(
4512 const std::pair<std::string /*group name*/, TableGroupKey>& theGroup,
4513 const std::string& fileName)
4515 std::string fullPath =
4516 ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/" + fileName;
4518 std::ofstream groupFile(fullPath.c_str());
4519 if(!groupFile.is_open())
4521 __SS__ <<
"Error. Can't open file to save group activity: " << fullPath << __E__;
4524 std::stringstream outss;
4525 outss << theGroup.first <<
"\n" << theGroup.second <<
"\n" << time(0);
4526 groupFile << outss.str().c_str();
4538 std::string& returnedTimeString)
4540 std::string fullPath =
4541 ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH +
"/" + fileName;
4543 FILE* groupFile = fopen(fullPath.c_str(),
"r");
4546 __COUT__ <<
"Can't open file: " << fullPath << __E__;
4548 __COUT__ <<
"Returning empty groupName and key -1" << __E__;
4557 fgets(line, 500, groupFile);
4558 if(strlen(line) && line[strlen(line) - 1] ==
'\n')
4559 line[strlen(line) - 1] =
'\0';
4560 theGroup.first = line;
4562 fgets(line, 500, groupFile);
4564 sscanf(line,
"%d", &key);
4565 theGroup.second = key;
4567 fgets(line, 500, groupFile);
4569 sscanf(line,
"%ld", ×tamp);
4576 __COUT__ <<
"theGroup.first=" << theGroup.first
4577 <<
" 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.
TableVersion createTemporaryView(TableVersion sourceViewVersion=TableVersion(), TableVersion destTemporaryViewVersion=TableVersion::getNextTemporaryVersion())
source of -1, from MockUp, else from valid view version
void setupMockupView(TableVersion version)
virtual void init(ConfigurationManager *configManager)
Methods.
const TableVersion & getViewVersion(void) const
always the active one
void setTableName(const std::string &tableName)
Setters.
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="")
static const std::string DATATYPE_NUMBER
std::string getChildLinkIndex(void) const
getChildLinkIndex
bool isGroupID(void) const
static const std::string TYPE_UID
NOTE: Do NOT put '-' in static const TYPEs because it will mess up javascript handling in the web gui...
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)