1 #include "otsdaq/ConfigurationInterface/ConfigurationManagerRW.h"
8 #define __MF_SUBJECT__ "ConfigurationManagerRW"
10 #define TABLE_INFO_PATH std::string(__ENV__("TABLE_INFO_PATH")) + "/"
11 #define TABLE_INFO_EXT "Info.xml"
13 #define CORE_TABLE_INFO_FILENAME \
14 ((getenv("SERVICE_DATA_PATH") == NULL) \
15 ? (std::string(__ENV__("USER_DATA")) + "/ServiceData") \
16 : (std::string(__ENV__("SERVICE_DATA_PATH")))) + \
17 "/CoreTableInfoNames.dat"
19 std::atomic<bool> ConfigurationManagerRW::firstTimeConstructed_ =
true;
26 __GEN_COUT__ <<
"Instantiating Config Manager with Write Access! (for " << username
27 <<
") time=" << time(0) <<
" runTimeSeconds()=" << runTimeSeconds()
30 theInterface_ = ConfigurationInterface::getInstance(
31 ConfigurationInterface::CONFIGURATION_MODE::
37 if(firstTimeConstructed_)
39 firstTimeConstructed_ =
false;
42 mkdir((ConfigurationManager::LAST_TABLE_GROUP_SAVE_PATH).c_str(), 0755);
44 const std::set<std::string>& contextMemberNames = getFixedContextMemberNames();
45 const std::set<std::string>& backboneMemberNames = getBackboneMemberNames();
46 const std::set<std::string>& iterateMemberNames = getIterateMemberNames();
48 FILE* fp = fopen((CORE_TABLE_INFO_FILENAME).c_str(),
"r");
52 std::vector<unsigned int> foundVector;
54 for(
const auto& name : contextMemberNames)
56 foundVector.push_back(
false);
58 while(fgets(line, 100, fp))
62 line[strlen(line) - 1] =
'\0';
63 if(strcmp(line, (
"ContextGroup/" + name).c_str()) == 0)
65 foundVector.back() =
true;
71 for(
const auto& name : backboneMemberNames)
73 foundVector.push_back(
false);
75 while(fgets(line, 100, fp))
79 line[strlen(line) - 1] =
'\0';
80 if(strcmp(line, (
"BackboneGroup/" + name).c_str()) == 0)
82 foundVector.back() =
true;
88 for(
const auto& name : iterateMemberNames)
90 foundVector.push_back(
false);
92 while(fgets(line, 100, fp))
96 line[strlen(line) - 1] =
'\0';
97 if(strcmp(line, (
"IterateGroup/" + name).c_str()) == 0)
99 foundVector.back() =
true;
107 foundVector.push_back(
false);
109 while(fgets(line, 100, fp))
113 line[strlen(line) - 1] =
'\0';
116 ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE)
119 foundVector.back() =
true;
128 fp = fopen((CORE_TABLE_INFO_FILENAME).c_str(),
"a");
132 for(
const auto& name : contextMemberNames)
135 fprintf(fp,
"\nContextGroup/%s", name.c_str());
139 for(
const auto& name : backboneMemberNames)
142 fprintf(fp,
"\nBackboneGroup/%s", name.c_str());
146 for(
const auto& name : iterateMemberNames)
149 fprintf(fp,
"\nIterateGroup/%s", name.c_str());
159 ConfigurationManager::CONTEXT_SUBSYSTEM_OPTIONAL_TABLE.c_str());
165 __SS__ <<
"Failed to open core table info file for appending: "
166 << CORE_TABLE_INFO_FILENAME << __E__;
172 fp = fopen((CORE_TABLE_INFO_FILENAME).c_str(),
"w");
175 fprintf(fp,
"ARTDAQ/*");
176 fprintf(fp,
"\nConfigCore/*");
177 for(
const auto& name : contextMemberNames)
178 fprintf(fp,
"\nContextGroup/%s", name.c_str());
179 for(
const auto& name : backboneMemberNames)
180 fprintf(fp,
"\nBackboneGroup/%s", name.c_str());
181 for(
const auto& name : iterateMemberNames)
182 fprintf(fp,
"\nIterateGroup/%s", name.c_str());
187 __SS__ <<
"Failed to open core table info file: "
188 << CORE_TABLE_INFO_FILENAME << __E__;
194 __GEN_COUTV__(runTimeSeconds());
206 std::string* accumulatedWarnings ,
207 const std::string& errorFilterName ,
210 bool initializeActiveGroups )
215 return allTableInfo_;
218 allTableInfo_.clear();
225 __GEN_COUT__ <<
"======================================================== "
226 "getAllTableInfo start runTimeSeconds()="
227 << runTimeSeconds() << __E__;
229 __GEN_COUT__ <<
"Refreshing all! Extracting list of tables..." << __E__;
231 struct dirent* entry;
232 std::string path = TABLE_INFO_PATH;
233 char fileExt[] = TABLE_INFO_EXT;
234 const unsigned char MIN_TABLE_NAME_SZ = 3;
237 __GEN_COUT__ <<
" PROCESSOR_COUNT " <<
PROCESSOR_COUNT <<
" ==> " << numOfThreads
238 <<
" threads." << __E__;
241 if((pDIR = opendir(path.c_str())) != 0)
243 while((entry = readdir(pDIR)) != 0)
246 if(strlen(entry->d_name) < strlen(fileExt) + MIN_TABLE_NAME_SZ)
250 if(strcmp(&(entry->d_name[strlen(entry->d_name) - strlen(fileExt)]),
254 entry->d_name[strlen(entry->d_name) - strlen(fileExt)] =
262 theInterface_->get(table,
268 catch(cet::exception
const&)
274 __GEN_COUT__ <<
"Skipping! No valid class found for... "
275 << entry->d_name <<
"\n";
278 catch(std::runtime_error& e)
284 __GEN_COUT__ <<
"Skipping! No valid class found for... "
285 << entry->d_name <<
"\n";
286 __GEN_COUT__ <<
"Error: " << e.what() << __E__;
291 if(accumulatedWarnings)
293 if(errorFilterName ==
"" || errorFilterName == entry->d_name)
295 *accumulatedWarnings += std::string(
"\nIn table '") +
296 entry->d_name +
"'..." +
299 __SS__ <<
"Attempting to allow illegal columns!" << __E__;
300 *accumulatedWarnings += ss.str();
304 __GEN_COUT__ <<
"Attempting to allow illegal columns!"
307 std::string returnedAccumulatedErrors;
311 &returnedAccumulatedErrors);
315 __GEN_COUT__ <<
"Skipping! Allowing illegal columns "
316 "didn't work either... "
317 << entry->d_name <<
"\n";
321 <<
"Error (but allowed): " << returnedAccumulatedErrors
324 if(errorFilterName ==
"" || errorFilterName == entry->d_name)
325 *accumulatedWarnings +=
326 std::string(
"\nIn table '") + entry->d_name +
"'..." +
327 returnedAccumulatedErrors;
333 if(nameToTableMap_[entry->d_name])
336 std::set<TableVersion> versions =
337 nameToTableMap_[entry->d_name]->getStoredVersions();
338 for(
auto& version : versions)
339 if(version.isTemporaryVersion())
343 nameToTableMap_[entry->d_name]->setActiveView(
346 nameToTableMap_[entry->d_name]->getView(),
357 delete nameToTableMap_[entry->d_name];
358 nameToTableMap_[entry->d_name] = 0;
361 nameToTableMap_[entry->d_name] = table;
363 allTableInfo_[entry->d_name].tablePtr_ = table;
364 allTableInfo_[entry->d_name].versions_ =
365 theInterface_->getVersions(table);
369 std::set<TableVersion> versions =
370 nameToTableMap_[entry->d_name]->getStoredVersions();
371 for(
auto& version : versions)
372 if(version.isTemporaryVersion())
374 allTableInfo_[entry->d_name].versions_.emplace(version);
382 int threadsLaunched = 0;
383 int foundThreadIndex = 0;
384 std::string tableName;
386 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
387 for(
int i = 0; i < numOfThreads; ++i)
388 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
390 std::vector<std::shared_ptr<ots::TableInfo>> sharedTableInfoPtrs;
392 if((pDIR = opendir(path.c_str())) != 0)
394 while((entry = readdir(pDIR)) != 0)
397 if(strlen(entry->d_name) < strlen(fileExt) + MIN_TABLE_NAME_SZ)
401 if(strcmp(&(entry->d_name[strlen(entry->d_name) - strlen(fileExt)]),
405 entry->d_name[strlen(entry->d_name) - strlen(fileExt)] =
412 sharedTableInfoPtrs.push_back(std::make_shared<ots::TableInfo>());
413 sharedTableInfoPtrs.back()->accumulatedWarnings_ =
414 accumulatedWarnings ?
"ALLOW"
417 if(threadsLaunched >= numOfThreads)
420 foundThreadIndex = -1;
422 while(foundThreadIndex == -1)
424 for(
int i = 0; i < numOfThreads; ++i)
427 foundThreadIndex = i;
430 if(foundThreadIndex == -1)
432 __GEN_COUT_TYPE__(TLVL_DEBUG + 2)
434 <<
"Waiting for available thread... iteration # "
438 __GEN_SS__ <<
"Threads seem to be stuck getting "
439 "table info! Timeout while waiting..."
446 threadsLaunched = numOfThreads - 1;
448 __GEN_COUTT__ <<
"Starting thread... " << foundThreadIndex
449 <<
" for table " << tableName << __E__;
451 *(threadDone[foundThreadIndex]) =
false;
454 std::string theTableName,
456 std::shared_ptr<ots::TableInfo> theTableInfo,
457 std::shared_ptr<std::atomic<bool>> theThreadDone) {
466 nameToTableMap_[tableName],
467 sharedTableInfoPtrs.back(),
468 threadDone[foundThreadIndex])
480 foundThreadIndex = -1;
481 for(
int i = 0; i < numOfThreads; ++i)
482 if(!*(threadDone[i]))
484 foundThreadIndex = i;
487 if(foundThreadIndex != -1)
489 __GEN_COUTT__ <<
"Waiting for thread to finish... "
490 << foundThreadIndex << __E__;
493 }
while(foundThreadIndex != -1);
496 for(
auto& tableInfo : sharedTableInfoPtrs)
498 if(tableInfo->tablePtr_ ==
nullptr)
500 __SS__ <<
"Fatal error occurred loading table info into cache! "
501 "Perhaps there is an illegal Table schema definition? "
502 "Check logs to resolve."
506 __GEN_COUT_TYPE__(TLVL_DEBUG + 3)
507 << __COUT_HDR__ <<
"Copying table info for "
508 << tableInfo->tablePtr_->getTableName() << __E__;
509 nameToTableMap_[tableInfo->tablePtr_->getTableName()] =
510 tableInfo->tablePtr_;
511 allTableInfo_[tableInfo->tablePtr_->getTableName()].tablePtr_ =
512 tableInfo->tablePtr_;
513 allTableInfo_[tableInfo->tablePtr_->getTableName()].versions_ =
514 tableInfo->versions_;
517 __GEN_COUT__ <<
"Extracting list of tables complete." << __E__;
521 if(initializeActiveGroups)
523 __GEN_COUT__ <<
"Now initializing..." << __E__;
525 std::string tmpAccumulateWarnings;
528 accumulatedWarnings ? &tmpAccumulateWarnings :
nullptr);
530 if(accumulatedWarnings && errorFilterName ==
"")
531 *accumulatedWarnings += tmpAccumulateWarnings;
533 __GEN_COUT__ <<
"======================================================== "
534 "getAllTableInfo end runTimeSeconds()="
535 << runTimeSeconds() << __E__;
540 allGroupInfo_.clear();
545 std::set<std::string > tableGroups =
546 theInterface_->getAllTableGroupNames();
547 __GEN_COUT__ <<
"Number of Groups: " << tableGroups.size() << __E__;
549 __GEN_COUTT__ <<
"Group Info start runTimeSeconds()=" << runTimeSeconds()
554 for(
const auto& fullName : tableGroups)
557 allGroupInfo_[name].keys_.emplace(key);
560 __GEN_COUTT__ <<
"Group Keys end runTimeSeconds()=" << runTimeSeconds()
568 << numOfThreads <<
" threads." << __E__;
570 for(
auto& groupInfo : allGroupInfo_)
574 groupInfo.second.latestKey_ = groupInfo.second.getLastKey();
577 groupInfo.second.latestKey_,
579 &groupInfo.second.latestKeyMemberMap_ ,
582 &groupInfo.second.latestKeyGroupComment_,
583 &groupInfo.second.latestKeyGroupAuthor_,
584 &groupInfo.second.latestKeyGroupCreationTime_,
586 &groupInfo.second.latestKeyGroupTypeString_);
590 __GEN_COUT_WARN__ <<
"Error occurred loading latest group "
591 "info into cache for '"
592 << groupInfo.first <<
"("
593 << groupInfo.second.latestKey_ <<
")'..."
595 groupInfo.second.latestKey_ = TableGroupKey::INVALID;
596 groupInfo.second.latestKeyGroupComment_ =
597 ConfigurationManager::UNKNOWN_INFO;
598 groupInfo.second.latestKeyGroupAuthor_ =
599 ConfigurationManager::UNKNOWN_INFO;
600 groupInfo.second.latestKeyGroupCreationTime_ =
601 ConfigurationManager::UNKNOWN_TIME;
602 groupInfo.second.latestKeyGroupTypeString_ =
603 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
604 groupInfo.second.latestKeyMemberMap_ = {};
609 int threadsLaunched = 0;
610 int foundThreadIndex = 0;
612 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
613 for(
int i = 0; i < numOfThreads; ++i)
614 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
616 std::vector<std::shared_ptr<ots::GroupInfo>> sharedGroupInfoPtrs;
618 for(
auto& groupInfo : allGroupInfo_)
621 sharedGroupInfoPtrs.push_back(std::make_shared<ots::GroupInfo>());
623 if(threadsLaunched >= numOfThreads)
626 foundThreadIndex = -1;
627 while(foundThreadIndex == -1)
629 for(
int i = 0; i < numOfThreads; ++i)
632 foundThreadIndex = i;
635 if(foundThreadIndex == -1)
637 __GEN_COUTT__ <<
"Waiting for available thread..."
642 threadsLaunched = numOfThreads - 1;
644 __GEN_COUTT__ <<
"Starting thread... " << foundThreadIndex
645 <<
" for " << groupInfo.first <<
"("
646 << groupInfo.second.getLastKey() <<
")" << __E__;
648 *(threadDone[foundThreadIndex]) =
false;
652 std::string theGroupName,
654 std::shared_ptr<ots::GroupInfo> theGroupInfo,
655 std::shared_ptr<std::atomic<bool>> theThreadDone) {
665 groupInfo.second.getLastKey(),
666 sharedGroupInfoPtrs.back(),
667 threadDone[foundThreadIndex])
677 foundThreadIndex = -1;
678 for(
int i = 0; i < numOfThreads; ++i)
679 if(!*(threadDone[i]))
681 foundThreadIndex = i;
684 if(foundThreadIndex != -1)
686 __GEN_COUTT__ <<
"Waiting for thread to finish... "
687 << foundThreadIndex << __E__;
690 }
while(foundThreadIndex != -1);
694 for(
auto& groupInfo : allGroupInfo_)
696 groupInfo.second.latestKey_ = sharedGroupInfoPtrs[i]->latestKey_;
697 groupInfo.second.latestKeyGroupComment_ =
698 sharedGroupInfoPtrs[i]->latestKeyGroupComment_;
699 groupInfo.second.latestKeyGroupAuthor_ =
700 sharedGroupInfoPtrs[i]->latestKeyGroupAuthor_;
701 groupInfo.second.latestKeyGroupCreationTime_ =
702 sharedGroupInfoPtrs[i]->latestKeyGroupCreationTime_;
703 groupInfo.second.latestKeyGroupTypeString_ =
704 sharedGroupInfoPtrs[i]->latestKeyGroupTypeString_;
705 groupInfo.second.latestKeyMemberMap_ =
706 sharedGroupInfoPtrs[i]->latestKeyMemberMap_;
713 catch(
const std::runtime_error& e)
716 <<
"A fatal error occurred reading the info for all table groups. Error: "
717 << e.what() << __E__;
718 __GEN_COUT_ERR__ <<
"Error at time: " << time(0) <<
"\n" << ss.str();
719 if(accumulatedWarnings)
720 *accumulatedWarnings += ss.str();
726 __SS__ <<
"An unknown fatal error occurred reading the info for all table "
733 catch(
const std::exception& e)
735 ss <<
"Exception message: " << e.what();
740 __GEN_COUT_ERR__ <<
"\n" << ss.str();
741 if(accumulatedWarnings)
742 *accumulatedWarnings += ss.str();
746 __GEN_COUTT__ <<
"Group Info end runTimeSeconds()=" << runTimeSeconds() << __E__;
749 __GEN_COUTT__ <<
"Table Info end runTimeSeconds()=" << runTimeSeconds() << __E__;
751 return allTableInfo_;
758 std::string tableName,
760 std::shared_ptr<ots::TableInfo> tableInfo,
761 std::shared_ptr<std::atomic<bool>> threadDone)
764 __COUTT__ <<
"Thread started... table " << tableName << __E__;
767 tableInfo->tablePtr_ = 0;
771 cfgMgr->theInterface_->get(tableInfo->tablePtr_,
777 catch(cet::exception
const&)
779 if(tableInfo->tablePtr_)
780 delete tableInfo->tablePtr_;
781 tableInfo->tablePtr_ = 0;
783 __COUT__ <<
"Skipping! No valid class found for... " << tableName <<
"\n";
784 *(threadDone) =
true;
787 catch(std::runtime_error& e)
789 if(tableInfo->tablePtr_)
790 delete tableInfo->tablePtr_;
791 tableInfo->tablePtr_ = 0;
793 __COUT__ <<
"Skipping! No valid class found for... " << tableName <<
"\n";
794 __COUTT__ <<
"Error: " << e.what() << __E__;
799 if(tableInfo->accumulatedWarnings_ ==
"ALLOW")
801 tableInfo->accumulatedWarnings_ =
"";
804 tableInfo->accumulatedWarnings_ += std::string(
"\nIn table '") +
808 __SS__ <<
"Attempting to allow illegal columns!" << __E__;
809 tableInfo->accumulatedWarnings_ += ss.str();
813 __COUT__ <<
"Attempting to allow illegal columns!" << __E__;
815 std::string returnedAccumulatedErrors;
818 tableInfo->tablePtr_ =
819 new TableBase(tableName, &returnedAccumulatedErrors);
823 __COUT__ <<
"Skipping! Allowing illegal columns didn't work either... "
824 << tableName <<
"\n";
825 *(threadDone) =
true;
828 __COUT_WARN__ <<
"Error (but allowed): " << returnedAccumulatedErrors
832 tableInfo->accumulatedWarnings_ +=
833 std::string(
"\nIn table '") + tableName +
"'..." +
834 returnedAccumulatedErrors;
838 tableInfo->accumulatedWarnings_ =
"";
839 *(threadDone) =
true;
846 __COUTT__ <<
"Copying temporary version from existing table object for "
847 << tableName << __E__;
849 std::set<TableVersion> versions = existingTable->getStoredVersions();
850 for(
auto& version : versions)
851 if(version.isTemporaryVersion())
855 existingTable->setActiveView(version);
856 tableInfo->tablePtr_->copyView(
857 existingTable->getView(),
867 delete existingTable;
871 tableInfo->versions_ = cfgMgr->theInterface_->getVersions(tableInfo->tablePtr_);
875 std::set<TableVersion> versions = tableInfo->tablePtr_->getStoredVersions();
876 for(
auto& version : versions)
877 if(version.isTemporaryVersion())
879 tableInfo->versions_.emplace(version);
882 __COUTT__ <<
"Thread done... table " << tableName << __E__;
883 *(threadDone) =
true;
887 __COUT_ERR__ <<
"Error occurred loading latest table info into cache for '"
888 << tableName <<
"'..." << __E__;
889 *(threadDone) =
true;
896 const std::string& groupName,
899 std::map<std::string /*table name*/, TableVersion>*
902 std::string* accumulatedWarnings ,
903 std::string* groupComment ,
904 std::string* groupAuthor ,
905 std::string* groupCreateTime ,
906 bool doNotLoadMembers ,
907 std::string* groupTypeString ,
908 std::map<std::string /*name*/, std::string /*alias*/>*
910 ConfigurationManager::LoadGroupType
912 bool ignoreVersionTracking )
927 ignoreVersionTracking);
929 if(!groupMembers || !groupMembers->size() || !groupComment || groupKey.
isInvalid() ||
930 !groupAuthor || !groupCreateTime)
934 auto groupInfo = allGroupInfo_.find(groupName);
935 if(groupInfo == allGroupInfo_.end())
938 groupInfo->second.latestKey_ = groupKey;
939 groupInfo->second.latestKeyGroupComment_ = *groupComment;
940 groupInfo->second.latestKeyGroupAuthor_ = *groupAuthor;
941 groupInfo->second.latestKeyGroupCreationTime_ = *groupCreateTime;
943 groupInfo->second.latestKeyGroupTypeString_ = *groupTypeString;
944 groupInfo->second.latestKeyMemberMap_ = *groupMembers;
952 std::string groupName,
954 std::shared_ptr<ots::GroupInfo> groupInfo,
955 std::shared_ptr<std::atomic<bool>> threadDone)
958 __COUTT__ <<
"Thread started... " << groupName <<
"(" << groupKey <<
")" << __E__;
960 groupInfo->latestKey_ = groupKey;
964 &(groupInfo->latestKeyMemberMap_) ,
967 &(groupInfo->latestKeyGroupComment_),
968 &(groupInfo->latestKeyGroupAuthor_),
969 &(groupInfo->latestKeyGroupCreationTime_),
971 &(groupInfo->latestKeyGroupTypeString_));
973 *(threadDone) =
true;
977 __COUT_WARN__ <<
"Error occurred loading latest group info into cache for '"
978 << groupName <<
"(" << groupInfo->latestKey_ <<
")'..." << __E__;
979 groupInfo->latestKey_ = TableGroupKey::INVALID;
980 groupInfo->latestKeyGroupComment_ = ConfigurationManager::UNKNOWN_INFO;
981 groupInfo->latestKeyGroupAuthor_ = ConfigurationManager::UNKNOWN_INFO;
982 groupInfo->latestKeyGroupCreationTime_ = ConfigurationManager::UNKNOWN_TIME;
983 groupInfo->latestKeyGroupTypeString_ = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
984 groupInfo->latestKeyMemberMap_ = {};
985 *(threadDone) =
true;
994 std::string groupName,
996 const std::map<std::string, TableVersion>& groupMemberMap,
997 const std::map<std::string /*name*/, std::string /*alias*/>& memberTableAliases,
998 std::atomic<bool>* foundIdentical,
1000 std::mutex* threadMutex,
1001 std::shared_ptr<std::atomic<bool>> threadDone)
1004 std::map<std::string ,
TableVersion > compareToMemberMap;
1005 std::map<std::string , std::string > compareToMemberTableAliases;
1006 std::map<std::string , std::string >*
1007 compareToMemberTableAliasesPtr =
nullptr;
1008 if(memberTableAliases
1010 compareToMemberTableAliasesPtr = &compareToMemberTableAliases;
1015 &compareToMemberMap ,
1023 compareToMemberTableAliasesPtr);
1029 for(
auto& memberPair : groupMemberMap)
1030 __COUTS__(9) <<
"member " << memberPair.first <<
" (" << memberPair.second
1032 for(
auto& memberPair : compareToMemberMap)
1033 __COUTS__(9) <<
"compare " << groupName <<
" (" << groupKeyToCompare
1034 <<
") member:" << memberPair.first <<
" (" << memberPair.second
1038 bool isDifferent =
false;
1039 for(
auto& memberPair : groupMemberMap)
1043 if(memberTableAliases.find(memberPair.first) != memberTableAliases.end())
1046 if(compareToMemberTableAliases.find(memberPair.first) ==
1047 compareToMemberTableAliases.end() ||
1048 memberTableAliases.at(memberPair.first) !=
1049 compareToMemberTableAliases.at(memberPair.first))
1053 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare
1054 <<
") on alias " << memberPair.first << __E__;
1058 else if(compareToMemberTableAliases.find(memberPair.first) !=
1059 compareToMemberTableAliases.end())
1064 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare
1065 <<
") on reverse alias " << memberPair.first << __E__;
1071 if(compareToMemberMap.find(memberPair.first) ==
1072 compareToMemberMap.end() ||
1073 memberPair.second !=
1074 compareToMemberMap.at(memberPair.first))
1079 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare
1080 <<
") on mismatch " << memberPair.first << __E__;
1087 groupMemberMap.size() !=
1094 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare <<
") on size "
1100 *foundIdentical =
true;
1101 __COUT__ <<
"=====> Found exact match with key: " << groupKeyToCompare << __E__;
1103 std::lock_guard<std::mutex> lock(*threadMutex);
1104 *identicalKey = groupKeyToCompare;
1107 *(threadDone) =
true;
1111 __COUT_WARN__ <<
"Error occurred comparing group '" << groupName <<
"("
1112 << groupKeyToCompare <<
")'..." << __E__;
1114 *(threadDone) =
true;
1121 std::map<std::string ,
1125 std::map<std::string ,
1131 if(!ConfigurationInterface::isVersionTrackingEnabled())
1132 for(
const auto& tableInfo : allTableInfo_)
1133 for(
const auto& version : tableInfo.second.versions_)
1134 if(version.isScratchVersion())
1135 retMap[tableInfo.first][ConfigurationManager::SCRATCH_VERSION_ALIAS] =
1147 std::string* accumulatedTreeErrors,
1148 std::string* groupTypeString)
1157 accumulatedTreeErrors,
1166 __GEN_COUT_ERR__ <<
"There were errors, so de-activating group: "
1167 << tableGroupName <<
" (" << tableGroupKey <<
")" << __E__;
1178 __GEN_COUT_INFO__ <<
"Updating persistent active groups to "
1181 __COUT_INFO__ <<
"Active Context table group: " << theContextTableGroup_ <<
"("
1182 << (theContextTableGroupKey_
1183 ? theContextTableGroupKey_->toString().c_str()
1186 __COUT_INFO__ <<
"Active Backbone table group: " << theBackboneTableGroup_ <<
"("
1187 << (theBackboneTableGroupKey_
1188 ? theBackboneTableGroupKey_->toString().c_str()
1191 __COUT_INFO__ <<
"Active Iterate table group: " << theIterateTableGroup_ <<
"("
1192 << (theIterateTableGroupKey_
1193 ? theIterateTableGroupKey_->toString().c_str()
1196 __COUT_INFO__ <<
"Active Configuration table group: " << theConfigurationTableGroup_
1198 << (theConfigurationTableGroupKey_
1199 ? theConfigurationTableGroupKey_->toString().c_str()
1204 FILE* fp = fopen(fn.c_str(),
"w");
1207 __SS__ <<
"Fatal Error! Unable to open the file "
1209 <<
" for editing! Is there a permissions problem?" << __E__;
1210 __GEN_COUT_ERR__ << ss.str();
1214 fprintf(fp,
"%s\n", theContextTableGroup_.c_str());
1218 theContextTableGroupKey_ ? theContextTableGroupKey_->toString().c_str() :
"-1");
1219 fprintf(fp,
"%s\n", theBackboneTableGroup_.c_str());
1223 theBackboneTableGroupKey_ ? theBackboneTableGroupKey_->toString().c_str() :
"-1");
1224 fprintf(fp,
"%s\n", theIterateTableGroup_.c_str());
1228 theIterateTableGroupKey_ ? theIterateTableGroupKey_->toString().c_str() :
"-1");
1229 fprintf(fp,
"%s\n", theConfigurationTableGroup_.c_str());
1232 theConfigurationTableGroupKey_
1233 ? theConfigurationTableGroupKey_->toString().c_str()
1240 std::string(tableGroupName), tableGroupKey);
1241 if(theConfigurationTableGroupKey_ &&
1242 theConfigurationTableGroup_ == tableGroupName &&
1243 *theConfigurationTableGroupKey_ == tableGroupKey)
1245 ConfigurationManager::saveGroupNameAndKey(
1247 ConfigurationManager::LAST_ACTIVATED_CONFIG_GROUP_FILE,
1250 ConfigurationManager::saveGroupNameAndKey(
1252 ConfigurationManager::ACTIVATED_CONFIGS_FILE,
1256 else if(theContextTableGroupKey_ && theContextTableGroup_ == tableGroupName &&
1257 *theContextTableGroupKey_ == tableGroupKey)
1259 ConfigurationManager::saveGroupNameAndKey(
1261 ConfigurationManager::LAST_ACTIVATED_CONTEXT_GROUP_FILE,
1264 ConfigurationManager::saveGroupNameAndKey(
1266 ConfigurationManager::ACTIVATED_CONTEXTS_FILE,
1270 else if(theBackboneTableGroupKey_ && theBackboneTableGroup_ == tableGroupName &&
1271 *theBackboneTableGroupKey_ == tableGroupKey)
1273 ConfigurationManager::saveGroupNameAndKey(
1275 ConfigurationManager::LAST_ACTIVATED_BACKBONE_GROUP_FILE,
1278 ConfigurationManager::saveGroupNameAndKey(
1280 ConfigurationManager::ACTIVATED_BACKBONES_FILE,
1284 else if(theIterateTableGroupKey_ && theIterateTableGroup_ == tableGroupName &&
1285 *theIterateTableGroupKey_ == tableGroupKey)
1287 ConfigurationManager::saveGroupNameAndKey(
1289 ConfigurationManager::LAST_ACTIVATED_ITERATE_GROUP_FILE,
1292 ConfigurationManager::saveGroupNameAndKey(
1294 ConfigurationManager::ACTIVATED_ITERATES_FILE,
1309 __GEN_COUT_INFO__ <<
"Creating temporary backbone view from version "
1310 << sourceViewVersion << __E__;
1316 auto backboneMemberNames = ConfigurationManager::getBackboneMemberNames();
1317 for(
auto& name : backboneMemberNames)
1321 if(retTmpVersion < tmpVersion)
1322 tmpVersion = retTmpVersion;
1325 __GEN_COUT__ <<
"Common temporary backbone version found as " << tmpVersion << __E__;
1328 for(
auto& name : backboneMemberNames)
1332 if(retTmpVersion != tmpVersion)
1334 __SS__ <<
"Failure! Temporary view requested was " << tmpVersion
1335 <<
". Mismatched temporary view created: " << retTmpVersion << __E__;
1336 __GEN_COUT_ERR__ << ss.str();
1345 TableBase* ConfigurationManagerRW::getTableByName(
const std::string& tableName)
1347 if(nameToTableMap_.find(tableName) == nameToTableMap_.end())
1349 if(tableName == ConfigurationManager::ARTDAQ_TOP_TABLE_NAME)
1352 <<
"Since target table was the artdaq top configuration level, "
1353 "attempting to help user by appending to core tables file: "
1354 << CORE_TABLE_INFO_FILENAME << __E__;
1355 FILE* fp = fopen((CORE_TABLE_INFO_FILENAME).c_str(),
"a");
1358 fprintf(fp,
"\nARTDAQ/*");
1363 __SS__ <<
"Table not found with name: " << tableName << __E__;
1365 if((f = tableName.find(
' ')) != std::string::npos)
1366 ss <<
"There was a space character found in the table name needle at "
1368 << f <<
" in the string (was this intended?). " << __E__;
1370 ss <<
"\nIf you think this table should exist in the core set of tables, try "
1371 "running 'UpdateOTS.sh --tables' to update your tables, then relaunch ots."
1373 ss <<
"\nTables must be defined at path $USER_DATA/TableInfo/ to exist in ots. "
1374 "Please verify your table definitions, and then restart ots."
1376 __GEN_COUT_ERR__ <<
"\n" << ss.str();
1379 return nameToTableMap_[tableName];
1393 TableBase* table = getTableByName(tableName);
1398 newVersion = theInterface_->saveNewVersion(table, temporaryVersion);
1400 table->setActiveView(newVersion);
1404 allTableInfo_[tableName].versions_.find(newVersion) !=
1405 allTableInfo_[tableName].versions_.end())
1408 <<
"What happenened!?? ERROR::: new persistent version v" << newVersion
1409 <<
" already exists!? How is it possible? Retrace your steps and "
1417 newVersion = temporaryVersion;
1421 __GEN_COUT_WARN__ <<
"Attempting to recover and use v" << newVersion << __E__;
1425 theInterface_->saveNewVersion(table, temporaryVersion, newVersion);
1427 table->setActiveView(newVersion);
1432 __SS__ <<
"Something went wrong saving the new version v" << newVersion
1433 <<
". What happened?! (duplicates? database error?)" << __E__;
1434 __GEN_COUT_ERR__ <<
"\n" << ss.str();
1439 allTableInfo_[tableName].versions_.insert(newVersion);
1453 TableBase* table = getTableByName(tableName);
1458 if(allTableInfo_.find(tableName) == allTableInfo_.end())
1465 for(
auto it = allTableInfo_[tableName].versions_.begin();
1466 it != allTableInfo_[tableName].versions_.end();
1469 if(it->isTemporaryVersion())
1471 __GEN_COUT__ <<
"Removing '" << tableName <<
"' version info: " << *it
1473 allTableInfo_[tableName].versions_.erase(it++);
1482 auto it = allTableInfo_[tableName].versions_.find(targetVersion);
1483 if(it == allTableInfo_[tableName].versions_.end())
1485 __GEN_COUT__ <<
"Target '" << tableName <<
"' version v" << targetVersion
1486 <<
" was not found in info versions..." << __E__;
1489 allTableInfo_[tableName].versions_.erase(
1490 allTableInfo_[tableName].versions_.find(targetVersion));
1501 TableBase* table = getTableByName(tableName);
1513 for(
auto configInfo : allTableInfo_)
1514 configInfo.second.tablePtr_->trimCache(0);
1520 const std::string& tableName,
TableVersion sourceVersion)
1522 getTableByName(tableName)->reset();
1527 getVersionedTableByName(tableName,
TableVersion(sourceVersion),
true);
1534 allTableInfo_[tableName].versions_.insert(newTemporaryVersion);
1536 return newTemporaryVersion;
1544 const std::string& groupName,
bool attemptToReloadKeys )
1551 auto it = allGroupInfo_.find(groupName);
1552 if(it == allGroupInfo_.end())
1554 __SS__ <<
"Group name '" << groupName
1555 <<
"' not found in group info! (creating empty info)" << __E__;
1556 __GEN_COUT_WARN__ << ss.str();
1558 return allGroupInfo_[groupName];
1561 if(attemptToReloadKeys)
1563 __GEN_COUT__ <<
"Reloading keys from special db group cache if it exists..."
1566 std::set<TableGroupKey> keys;
1569 bool cacheFailed =
false;
1575 TableBase::GROUP_CACHE_PREPEND + groupName);
1576 auto versions = theInterface_->getVersions(&localGroupMemberCacheLoader);
1577 for(
const auto& version : versions)
1582 __GEN_COUT__ <<
"Ignoring cache loading error. Doing full load of keys..."
1587 if(cacheFailed && 0)
1588 keys = theInterface_->getKeys(groupName);
1592 __GEN_COUT__ <<
"Key from special db group cache were loaded." << __E__;
1593 it->second.keys_ = keys;
1612 const std::string& groupName,
1613 const std::map<std::string, TableVersion>& groupMemberMap,
1614 const std::map<std::string /*name*/, std::string /*alias*/>& memberTableAliases)
1616 if(!groupMemberMap.size() || groupName.empty())
1618 __SS__ <<
"Illegal name/members for requested group of name '" << groupName
1619 <<
"' and member count = " << groupMemberMap.size() << __E__;
1627 std::set<TableGroupKey> keys;
1630 bool cacheFailed =
false;
1636 TableBase::GROUP_CACHE_PREPEND + groupName);
1637 auto versions = theInterface_->getVersions(&localGroupMemberCacheLoader);
1638 for(
const auto& version : versions)
1643 __COUT__ <<
"Ignoring cache loading error. Doing full load of keys..."
1649 keys = theInterface_->getKeys(groupName);
1654 const unsigned int MAX_DEPTH_TO_CHECK = 20;
1655 unsigned int keyMinToCheck = 0;
1658 keyMinToCheck = keys.rbegin()->key();
1659 if(keyMinToCheck > MAX_DEPTH_TO_CHECK)
1661 keyMinToCheck -= MAX_DEPTH_TO_CHECK;
1662 __GEN_COUT__ <<
"Checking groups back to key... " << keyMinToCheck << __E__;
1667 __GEN_COUT__ <<
"Checking all groups." << __E__;
1675 __GEN_COUT__ <<
" PROCESSOR_COUNT " <<
PROCESSOR_COUNT <<
" ==> " << numOfThreads
1676 <<
" threads." << __E__;
1677 if(numOfThreads < 2)
1679 std::map<std::string ,
TableVersion > compareToMemberMap;
1680 std::map<std::string , std::string > compareToMemberTableAliases;
1681 std::map<std::string , std::string >*
1682 compareToMemberTableAliasesPtr =
nullptr;
1683 if(memberTableAliases.size())
1684 compareToMemberTableAliasesPtr = &compareToMemberTableAliases;
1687 for(
const auto& key : keys)
1689 if(key.key() < keyMinToCheck)
1695 &compareToMemberMap ,
1703 compareToMemberTableAliasesPtr);
1705 isDifferent =
false;
1706 for(
auto& memberPair : groupMemberMap)
1708 if(memberTableAliases.find(memberPair.first) != memberTableAliases.end())
1711 if(compareToMemberTableAliases.find(memberPair.first) ==
1712 compareToMemberTableAliases.end() ||
1713 memberTableAliases.at(memberPair.first) !=
1714 compareToMemberTableAliases.at(memberPair.first))
1721 else if(compareToMemberTableAliases.find(memberPair.first) !=
1722 compareToMemberTableAliases.end())
1732 if(compareToMemberMap.find(memberPair.first) ==
1733 compareToMemberMap.end() ||
1734 memberPair.second !=
1735 compareToMemberMap.at(memberPair.first))
1746 if(groupMemberMap.size() != compareToMemberMap.size())
1750 __GEN_COUT__ <<
"Found exact match with key: " << key << __E__;
1754 __GEN_COUT__ <<
"No match found - this group is new!" << __E__;
1760 int threadsLaunched = 0;
1761 int foundThreadIndex = 0;
1762 std::atomic<bool> foundIdentical =
false;
1764 std::mutex threadMutex;
1766 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
1767 for(
int i = 0; i < numOfThreads; ++i)
1768 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
1770 for(
const auto& key : keys)
1774 if(key.key() < keyMinToCheck)
1777 if(threadsLaunched >= numOfThreads)
1780 foundThreadIndex = -1;
1781 while(foundThreadIndex == -1)
1786 for(
int i = 0; i < numOfThreads; ++i)
1787 if(*(threadDone[i]))
1789 foundThreadIndex = i;
1792 if(foundThreadIndex == -1)
1794 __GEN_COUTT__ <<
"Waiting for available thread..." << __E__;
1798 threadsLaunched = numOfThreads - 1;
1803 __GEN_COUTT__ <<
"Starting thread... " << foundThreadIndex << __E__;
1804 *(threadDone[foundThreadIndex]) =
false;
1808 std::string theGroupName,
1810 const std::map<std::string, TableVersion>& groupMemberMap,
1811 const std::map<std::string /*name*/, std::string /*alias*/>&
1813 std::atomic<bool>* theFoundIdentical,
1815 std::mutex* theThreadMutex,
1816 std::shared_ptr<std::atomic<bool>> theThreadDone) {
1835 threadDone[foundThreadIndex])
1845 foundThreadIndex = -1;
1846 for(
int i = 0; i < numOfThreads; ++i)
1847 if(!*(threadDone[i]))
1849 foundThreadIndex = i;
1852 if(foundThreadIndex != -1)
1854 __GEN_COUTT__ <<
"Waiting for thread to finish... " << foundThreadIndex
1858 }
while(foundThreadIndex != -1);
1862 __GEN_COUT__ <<
"Found exact match with key: " << identicalKey << __E__;
1863 return identicalKey;
1880 return &groupMetadataTable_;
1884 std::lock_guard<std::mutex> lock(metaDataTableMutex_);
1887 while(groupMetadataTable_.getView().getNumberOfRows())
1888 groupMetadataTable_.getViewP()->deleteRow(0);
1893 theInterface_->fill(&groupMetadataTable_, fillVersion);
1895 catch(
const std::runtime_error& e)
1897 __GEN_COUT_WARN__ <<
"Failed to load " << groupMetadataTable_.getTableName()
1898 <<
"-v" << fillVersion <<
". Metadata error: " << e.what()
1903 __GEN_COUT_WARN__ <<
"Failed to load " << groupMetadataTable_.getTableName()
1904 <<
"-v" << fillVersion <<
". Ignoring unknown metadata error. "
1909 if(groupMetadataTable_.getView().getNumberOfRows() != 1)
1911 groupMetadataTable_.print();
1912 __GEN_COUT_ERR__ <<
"Ignoring that groupMetadataTable_ v" << fillVersion
1914 "number of rows!' Must "
1915 "be 1. Going with anonymous defaults."
1919 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
1920 groupMetadataTable_.getViewP()->deleteRow(0);
1921 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
1922 groupMetadataTable_.getViewP()->addRow();
1925 return &groupMetadataTable_;
1936 const std::string& groupName,
1937 std::map<std::string, TableVersion>& groupMembers,
1938 const std::string& groupComment,
1939 std::map<std::string /*table*/, std::string /*alias*/>* groupAliases)
1947 if(groupMembers.size() == 0)
1949 __SS__ <<
"Empty group member list. Can not create a group without members!"
1954 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
1959 for(
auto& memberPair : groupMembers)
1962 if(allCfgInfo.find(memberPair.first) == allCfgInfo.end())
1964 __GEN_COUT_ERR__ <<
"Group member \"" << memberPair.first
1965 <<
"\" not found in database!";
1967 if(groupMetadataTable_.getTableName() == memberPair.first)
1970 <<
"Looks like this is the groupMetadataTable_ '"
1971 << TableBase::GROUP_METADATA_TABLE_NAME
1972 <<
".' Note that this table is added to the member map when groups "
1974 <<
"It should not be part of member map when calling this function."
1976 __GEN_COUT__ <<
"Attempting to recover." << __E__;
1977 groupMembers.erase(groupMembers.find(memberPair.first));
1981 __SS__ << (
"Group member not found!") << __E__;
1986 if(allCfgInfo[memberPair.first].versions_.find(memberPair.second) ==
1987 allCfgInfo[memberPair.first].versions_.end())
1989 __SS__ <<
"Group member \"" << memberPair.first <<
"\" version \""
1990 << memberPair.second <<
"\" not found in database!";
1995 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2000 for(
auto& aliasPair : *groupAliases)
2003 if(groupMembers.find(aliasPair.first) == groupMembers.end())
2005 __GEN_COUT_ERR__ <<
"Group member \"" << aliasPair.first
2006 <<
"\" not found in group member map!";
2008 __SS__ << (
"Alias table not found in member list!") << __E__;
2016 __GEN_COUT__ <<
"New Key for group: " << groupName <<
" found as " << newKey << __E__;
2017 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2019 time_t groupCreationTime = time(0);
2022 std::map<std::string ,
TableVersion > groupMembersWithoutMeta =
2029 std::string groupAliasesString =
"";
2032 *groupAliases,
"," ,
":" );
2033 __GEN_COUT__ <<
"Metadata: " << username_ <<
" " << groupCreationTime <<
" "
2034 << groupComment <<
" " << groupAliasesString <<
" " << groupType
2039 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
2040 groupMetadataTable_.getViewP()->deleteRow(0);
2041 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
2042 groupMetadataTable_.getViewP()->addRow();
2045 groupMetadataTable_.getViewP()->setValue(
2046 groupAliasesString, 0, ConfigurationManager::METADATA_COL_ALIASES);
2047 groupMetadataTable_.getViewP()->setValue(
2048 groupComment, 0, ConfigurationManager::METADATA_COL_COMMENT);
2049 groupMetadataTable_.getViewP()->setValue(
2050 username_, 0, ConfigurationManager::METADATA_COL_AUTHOR);
2051 groupMetadataTable_.getViewP()->setValue(
2052 groupCreationTime, 0, ConfigurationManager::METADATA_COL_TIMESTAMP);
2056 std::stringstream ss;
2057 groupMetadataTable_.print(ss);
2058 __COUT_MULTI__(2, ss.str());
2065 theInterface_->findLatestVersion(&groupMetadataTable_));
2066 groupMetadataTable_.getViewP()->setVersion(newVersion);
2068 uint16_t retries = 0;
2073 theInterface_->saveActiveVersion(&groupMetadataTable_);
2075 catch(
const std::runtime_error& e)
2077 __GEN_COUT__ <<
"Caught runtime_error exception during table save."
2079 if(std::string(e.what()).find(
"there was a collision") !=
2083 <<
"There was a collision saving the new table "
2084 << groupMetadataTable_ <<
"(" << newVersion
2085 <<
"), trying incremented table version... retries="
2086 << retries << __E__;
2091 groupMetadataTable_.getViewP()->setVersion(newVersion);
2092 __GEN_COUT__ <<
"New version for table: " << groupMetadataTable_
2093 <<
" found as " << newVersion << __E__;
2100 __GEN_COUT__ <<
"Created table: " << groupMetadataTable_ <<
"-v"
2101 << newVersion << __E__;
2106 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2110 groupMembers[groupMetadataTable_.getTableName()] =
2111 groupMetadataTable_.getViewVersion();
2115 uint16_t retries = 0;
2118 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2123 theInterface_->saveTableGroup(
2127 catch(
const std::runtime_error& e)
2129 __GEN_COUT__ <<
"Caught runtime_error exception during group save."
2131 if(std::string(e.what()).find(
"there was a collision") !=
2135 <<
"There was a collision saving the new group " << groupName
2137 <<
"), trying incremented group key... retries=" << retries
2142 __GEN_COUT__ <<
"New Key for group: " << groupName <<
" found as "
2150 __GEN_COUT__ <<
"Created table group: " << groupName <<
"(" << newKey
2156 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2159 catch(std::runtime_error& e)
2161 __GEN_COUT_ERR__ <<
"Failed to create table group: " << groupName <<
"(" << newKey
2163 __GEN_COUT_ERR__ <<
"\n\n" << e.what() << __E__;
2168 __GEN_COUT_ERR__ <<
"Failed to create table group: " << groupName <<
":" << newKey
2173 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2176 allGroupInfo_[groupName].keys_.emplace(newKey);
2178 allGroupInfo_.at(groupName).latestKey_ = newKey;
2179 allGroupInfo_.at(groupName).latestKeyGroupAuthor_ = username_;
2180 allGroupInfo_.at(groupName).latestKeyGroupComment_ = groupComment;
2181 allGroupInfo_.at(groupName).latestKeyGroupCreationTime_ = groupCreationTime;
2182 allGroupInfo_.at(groupName).latestKeyGroupTypeString_ = groupType;
2183 allGroupInfo_.at(groupName).latestKeyMemberMap_ = groupMembersWithoutMeta;
2185 __GEN_COUT__ <<
"Saved " << groupName <<
"(" << newKey <<
") of type " << groupType
2188 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2200 __GEN_COUT_INFO__ <<
"Creating new backbone from temporary version "
2201 << temporaryVersion << __E__;
2206 auto backboneMemberNames = ConfigurationManager::getBackboneMemberNames();
2207 for(
auto& name : backboneMemberNames)
2210 __GEN_COUT__ <<
"New version for backbone member (" << name
2211 <<
"): " << retNewVersion << __E__;
2212 if(retNewVersion > newVersion)
2213 newVersion = retNewVersion;
2216 __GEN_COUT__ <<
"Common new backbone version found as " << newVersion << __E__;
2219 for(
auto& name : backboneMemberNames)
2223 getTableByName(name), temporaryVersion, newVersion);
2224 if(retNewVersion != newVersion)
2226 __SS__ <<
"Failure! New view requested was " << newVersion
2227 <<
". Mismatched new view created: " << retNewVersion << __E__;
2228 __GEN_COUT_ERR__ << ss.str();
2242 const std::string& tableName,
2247 bool ignoreDuplicates ,
2248 bool lookForEquivalent ,
2249 bool* foundEquivalent )
2251 bool needToEraseTemporarySource =
2255 *foundEquivalent =
false;
2258 if(!ignoreDuplicates)
2260 __GEN_COUT__ <<
"Checking for duplicate '" << tableName <<
"' tables..." << __E__;
2268 const std::map<std::string, TableInfo>& allTableInfo =
2271 auto versionReverseIterator =
2272 allTableInfo.at(tableName).versions_.rbegin();
2273 __GEN_COUT__ <<
"Filling up '" << tableName <<
"' cache from "
2277 versionReverseIterator != allTableInfo.at(tableName).versions_.rend();
2278 ++versionReverseIterator)
2280 __GEN_COUTT__ <<
"'" << tableName <<
"' versions in reverse order "
2281 << *versionReverseIterator << __E__;
2284 getVersionedTableByName(tableName,
2285 *versionReverseIterator);
2287 catch(
const std::runtime_error& e)
2290 __COUTT__ <<
"'" << tableName
2291 <<
"' version failed to load: " << *versionReverseIterator
2297 __GEN_COUT__ <<
"Checking '" << tableName <<
"' for duplicate..." << __E__;
2300 temporaryModifiedVersion,
2306 if(lookForEquivalent && !duplicateVersion.
isInvalid())
2309 __GEN_COUT__ <<
"Equivalent '" << tableName <<
"' table found in version v"
2310 << duplicateVersion << __E__;
2315 __GEN_COUT__ <<
"Need persistent. Duplicate '" << tableName
2316 <<
"' version was temporary. "
2317 "Abandoning duplicate."
2329 if(needToEraseTemporarySource)
2333 *foundEquivalent =
true;
2335 __GEN_COUT__ <<
"\t\t Equivalent '" << tableName
2336 <<
"' assigned version: " << duplicateVersion << __E__;
2338 return duplicateVersion;
2344 __SS__ <<
"This version of table '" << tableName
2345 <<
"' is identical to another version currently cached v"
2346 << duplicateVersion <<
". No reason to save a duplicate." << __E__;
2347 __GEN_COUT_ERR__ <<
"\n" << ss.str();
2350 table->eraseView(temporaryModifiedVersion);
2354 __GEN_COUT__ <<
"Check for duplicate '" << tableName <<
"' tables complete."
2359 __GEN_COUT__ <<
"\t\t**************************** Save as temporary '"
2360 << tableName <<
"' table version" << __E__;
2362 __GEN_COUT__ <<
"\t\t**************************** Save as new '" << tableName
2363 <<
"' table version" << __E__;
2366 saveNewTable(tableName, temporaryModifiedVersion, makeTemporary);
2368 __GEN_COUTTV__(table->getView().getComment());
2370 if(needToEraseTemporarySource)
2373 __GEN_COUT__ <<
"\t\t '" << tableName
2374 <<
"' new assigned version: " << newAssignedVersion << __E__;
2375 return newAssignedVersion;
2379 GroupEditStruct::GroupEditStruct(
const ConfigurationManager::GroupType& groupType,
2381 : groupType_(groupType)
2382 , originalGroupName_(cfgMgr->getActiveGroupName(groupType))
2383 , originalGroupKey_(cfgMgr->getActiveGroupKey(groupType))
2385 , mfSubject_(cfgMgr->getUsername())
2387 if(originalGroupName_ ==
"" || originalGroupKey_.isInvalid())
2389 __SS__ <<
"Error! No active group found for type '"
2391 <<
".' There must be an active group to edit the group." << __E__ << __E__
2396 __GEN_COUT__ <<
"Extracting Group-Edit Struct for type "
2401 const std::set<std::string>& memberNames =
2402 groupType == ConfigurationManager::GroupType::CONTEXT_TYPE
2403 ? cfgMgr->getActiveContextMemberNames()
2404 : (groupType == ConfigurationManager::GroupType::BACKBONE_TYPE
2405 ? ConfigurationManager::getBackboneMemberNames()
2408 : cfgMgr->getConfigurationMemberNames()));
2410 for(
auto& memberName : memberNames)
2413 groupMembers_.emplace(
2414 std::make_pair(memberName, activeTables.at(memberName)));
2415 groupTables_.emplace(std::make_pair(
2422 __SS__ <<
"Error! Could not find group member table '" << memberName
2423 <<
"' for group type '"
2425 <<
".' All group members must be present to create the group editing "
2434 GroupEditStruct::~GroupEditStruct()
2436 __GEN_COUT__ <<
"GroupEditStruct from editing '" << originalGroupName_ <<
"("
2437 << originalGroupKey_ <<
")' Destructing..." << __E__;
2439 __GEN_COUT__ <<
"GroupEditStruct from editing '" << originalGroupName_ <<
"("
2440 << originalGroupKey_ <<
")' Desctructed." << __E__;
2448 auto it = groupTables_.find(tableName);
2449 if(it == groupTables_.end())
2451 if(groupType_ == ConfigurationManager::GroupType::CONFIGURATION_TYPE &&
2454 __GEN_COUT__ <<
"Table '" << tableName
2455 <<
"' not found in configuration table members from editing '"
2456 << originalGroupName_ <<
"(" << originalGroupKey_ <<
")..."
2457 <<
" Attempting to add it!" << __E__;
2460 auto newIt = groupTables_.emplace(std::make_pair(
2465 newIt.first->second.modified_ =
2467 groupMembers_.emplace(
2468 std::make_pair(tableName, newIt.first->second.temporaryVersion_));
2469 return newIt.first->second;
2471 __GEN_COUT_ERR__ <<
"Failed to emplace new table..." << __E__;
2474 __SS__ <<
"Table '" << tableName <<
"' not found in table members from editing '"
2475 << originalGroupName_ <<
"(" << originalGroupKey_ <<
")!'" << __E__;
2478 it->second.modified_ =
2484 void GroupEditStruct::dropChanges()
2486 __GEN_COUT__ <<
"Dropping unsaved changes from editing '" << originalGroupName_ <<
"("
2487 << originalGroupKey_ <<
")'..." << __E__;
2492 for(
auto& groupTable : groupTables_)
2493 if(groupTable.second
2494 .createdTemporaryVersion_)
2498 groupTable.second.temporaryVersion_);
2499 groupTable.second.createdTemporaryVersion_ =
false;
2500 groupTable.second.modified_ =
false;
2503 __GEN_COUT__ <<
"Unsaved changes dropped from editing '" << originalGroupName_ <<
"("
2504 << originalGroupKey_ <<
").'" << __E__;
2508 void GroupEditStruct::saveChanges(
const std::string& groupNameToSave,
2510 bool* foundEquivalentGroupKey ,
2511 bool activateNewGroup ,
2512 bool updateGroupAliases ,
2513 bool updateTableAliases ,
2515 bool* foundEquivalentBackboneKey ,
2516 std::string* accumulatedWarnings )
2518 __GEN_COUT__ <<
"Saving changes..." << __E__;
2523 if(foundEquivalentBackboneKey)
2524 *foundEquivalentBackboneKey =
false;
2528 bool anyTableNew =
false;
2529 for(
auto& groupTable : groupTables_)
2531 if(!groupTable.second.modified_)
2534 __GEN_COUT__ <<
"Original version is " << groupTable.second.tableName_ <<
"-v"
2535 << groupTable.second.originalVersion_ << __E__;
2538 groupTable.second.tableName_,
2539 groupTable.second.originalVersion_,
2541 groupTable.second.table_,
2542 groupTable.second.temporaryVersion_,
2545 __GEN_COUT__ <<
"Temporary target version is " << groupTable.second.tableName_
2546 <<
"-v" << groupMembers_.at(groupTable.first) <<
"-v"
2547 << groupTable.second.temporaryVersion_ << __E__;
2550 groupTable.second.tableName_,
2551 groupTable.second.originalVersion_,
2553 groupTable.second.table_,
2554 groupTable.second.temporaryVersion_,
2558 if(groupTable.second.originalVersion_ != groupMembers_.at(groupTable.first))
2561 __GEN_COUT__ <<
"Final NEW target version is " << groupTable.second.tableName_
2562 <<
"-v" << groupMembers_.at(groupTable.first) << __E__;
2565 __GEN_COUT__ <<
"Final target version is " << groupTable.second.tableName_
2566 <<
"-v" << groupMembers_.at(groupTable.first) << __E__;
2568 groupTable.second.modified_ =
false;
2569 groupTable.second.createdTemporaryVersion_ =
false;
2572 for(
auto& table : groupMembers_)
2574 __GEN_COUT__ << table.first <<
" v" << table.second << __E__;
2579 __GEN_COUT__ <<
"Checking for duplicate groups..." << __E__;
2580 newGroupKey = cfgMgr->
findTableGroup(groupNameToSave, groupMembers_);
2583 __GEN_COUT__ <<
"New table found, so no need to check duplicate groups." << __E__;
2587 __GEN_COUT__ <<
"Found equivalent group key (" << newGroupKey <<
") for "
2588 << groupNameToSave <<
"." << __E__;
2589 if(foundEquivalentGroupKey)
2590 *foundEquivalentGroupKey =
true;
2595 __GEN_COUT__ <<
"Saved new Context group key (" << newGroupKey <<
") for "
2596 << groupNameToSave <<
"." << __E__;
2599 bool groupAliasChange =
false;
2600 bool tableAliasChange =
false;
2603 ConfigurationManager::GroupType::
2606 GroupEditStruct backboneGroupEdit(ConfigurationManager::GroupType::BACKBONE_TYPE,
2609 if(groupType_ != ConfigurationManager::GroupType::BACKBONE_TYPE &&
2615 TableEditStruct& groupAliasTable = backboneGroupEdit.getTableEditStruct(
2616 ConfigurationManager::GROUP_ALIASES_TABLE_NAME,
true );
2617 TableView* tableView = groupAliasTable.tableView_;
2620 unsigned int row = 0;
2622 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
2623 cfgMgr->
getNode(ConfigurationManager::GROUP_ALIASES_TABLE_NAME)
2625 std::string groupName, groupKey;
2626 for(
auto& aliasNodePair : aliasNodePairs)
2628 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
2629 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
2631 __GEN_COUT__ <<
"Group Alias: " << aliasNodePair.first <<
" => "
2632 << groupName <<
"(" << groupKey <<
"); row=" << row << __E__;
2634 if(groupName == originalGroupName_ &&
2637 __GEN_COUT__ <<
"Found alias! Changing group key from ("
2638 << originalGroupKey_ <<
") to (" << newGroupKey <<
")"
2641 groupAliasChange =
true;
2650 if(groupAliasChange)
2652 std::stringstream ss;
2653 tableView->print(ss);
2654 __GEN_COUT__ << ss.str();
2658 if(groupType_ != ConfigurationManager::GroupType::BACKBONE_TYPE &&
2664 .getTableEditStruct(ConfigurationManager::VERSION_ALIASES_TABLE_NAME,
2668 for(
auto& groupTable : groupTables_)
2670 if(groupTable.second.originalVersion_ ==
2671 groupMembers_.at(groupTable.second.tableName_))
2674 __GEN_COUT__ <<
"Checking alias... original version is "
2675 << groupTable.second.tableName_ <<
"-v"
2676 << groupTable.second.originalVersion_
2677 <<
" and new version is v"
2678 << groupMembers_.at(groupTable.second.tableName_) << __E__;
2681 unsigned int row = 0;
2683 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
2684 cfgMgr->
getNode(ConfigurationManager::VERSION_ALIASES_TABLE_NAME)
2686 std::string tableName, tableVersion;
2687 for(
auto& aliasNodePair : aliasNodePairs)
2690 aliasNodePair.second.getNode(
"TableName").getValueAsString();
2692 aliasNodePair.second.getNode(
"Version").getValueAsString();
2694 __GEN_COUT__ <<
"Table Alias: " << aliasNodePair.first <<
" => "
2695 << tableName <<
"-v" << tableVersion <<
"" << __E__;
2697 if(tableName == groupTable.second.tableName_ &&
2698 TableVersion(tableVersion) == groupTable.second.originalVersion_)
2700 __GEN_COUT__ <<
"Found alias! Changing icon table version alias."
2703 tableAliasChange =
true;
2706 groupMembers_.at(groupTable.second.tableName_).toString(),
2708 tableView->
findCol(
"Version"));
2715 if(tableAliasChange)
2717 std::stringstream ss;
2718 tableView->print(ss);
2719 __GEN_COUT__ << ss.str();
2725 if(groupAliasChange || tableAliasChange)
2727 for(
auto& table : backboneGroupEdit.groupMembers_)
2729 __GEN_COUT__ << table.first <<
" v" << table.second << __E__;
2731 backboneGroupEdit.saveChanges(
2732 backboneGroupEdit.originalGroupName_,
2733 localNewBackboneKey,
2734 foundEquivalentBackboneKey ? foundEquivalentBackboneKey :
nullptr);
2737 *newBackboneKey = localNewBackboneKey;
2744 <<
"Restoring active table groups, before activating new groups..."
2747 std::string localAccumulatedWarnings;
2751 ConfigurationManager::LoadGroupType::
2753 &localAccumulatedWarnings);
2759 backboneGroupEdit.originalGroupName_,
2760 localNewBackboneKey,
2761 accumulatedWarnings ? accumulatedWarnings :
nullptr);
2770 <<
"Restoring active table groups, before activating new groups..."
2773 std::string localAccumulatedWarnings;
2777 ConfigurationManager::LoadGroupType::
2779 &localAccumulatedWarnings);
2783 if(activateNewGroup)
2786 accumulatedWarnings ? accumulatedWarnings :
nullptr);
2788 __GEN_COUT__ <<
"Changes saved." << __E__;
2797 __GEN_COUTV__(runTimeSeconds());
2799 std::string accumulatedWarningsStr;
2800 std::string* accumulatedWarnings = &accumulatedWarningsStr;
2807 std::string documentNameToLoad =
"XDAQApplicationTable";
2811 std::set<std::string> groupsContainingTable =
2812 theInterface_->findGroupsWithTable(documentNameToLoad,
2813 documentVersionToLoad);
2814 __GEN_COUT__ <<
"Groups containing " << documentNameToLoad <<
"-v"
2815 << documentVersionToLoad
2816 <<
" count: " << groupsContainingTable.size() << __E__;
2817 for(
const auto& group : groupsContainingTable)
2819 __GEN_COUT__ <<
"\t" << group << __E__;
2823 std::string debugGroupName =
"Mu2eHWEmulatorContext";
2828 theInterface_->findLatestGroupKey(debugGroupName);
2829 __GEN_COUTV__(latestGroupKey);
2831 __GEN_COUTV__(runTimeSeconds());
2838 std::set<std::string > tableGroups =
2839 theInterface_->getAllTableGroupNames();
2840 __GEN_COUT__ <<
"Number of Groups: " << tableGroups.size() << __E__;
2842 __GEN_COUTV__(runTimeSeconds());
2847 for(
const auto& fullName : tableGroups)
2850 allGroupInfo_[name].keys_.emplace(key);
2852 if(name == debugGroupName)
2857 __GEN_COUTV__(runTimeSeconds());
2859 std::set<std::string > tableNames = theInterface_->getAllTableNames();
2860 __GEN_COUT__ <<
"Number of Tables: " << tableNames.size() << __E__;
2862 __GEN_COUTV__(runTimeSeconds());
2864 for(
const auto& fullName : tableNames)
2866 if(fullName.find(debugGroupName) != std::string::npos)
2868 __GEN_COUTV__(fullName);
2871 __GEN_COUTV__(runTimeSeconds());
2873 TableGroupKey latestGroupKey = theInterface_->findLatestGroupKey(debugGroupName);
2874 __GEN_COUTV__(latestGroupKey);
2876 __GEN_COUTV__(runTimeSeconds());
2881 TableBase::GROUP_CACHE_PREPEND + debugGroupName);
2883 theInterface_->findLatestVersion(&localGroupMemberCacheSaver);
2884 __GEN_COUTV__(lastestGroupCacheKey);
2886 __GEN_COUTV__(runTimeSeconds());
2892 __GEN_COUT__ <<
"Testing group save of pre-existing " << debugGroupName <<
"("
2893 << groupKey <<
")" << __E__;
2894 std::map<std::string, TableVersion> groupMembers;
2896 theInterface_->saveTableGroup(
2902 __GEN_COUT__ <<
"Exception during group save." << __E__;
2904 __GEN_COUTV__(runTimeSeconds());
2909 std::string debugGroupName =
"testGroupSave";
2911 __GEN_COUT__ <<
"Testing group save of non-existing " << debugGroupName <<
"("
2912 << groupKey <<
")" << __E__;
2913 std::map<std::string, TableVersion> groupMembers;
2915 groupMembers[
"MessageFacilityTable"] =
TableVersion(7);
2916 theInterface_->saveTableGroup(
2922 __GEN_COUT__ <<
"Exception during new group save." << __E__;
2924 __GEN_COUTV__(runTimeSeconds());
2928 std::string documentNameToLoad =
"XDAQApplicationTable";
2931 __GEN_COUT__ <<
"Testing table save of pre-existing " << documentNameToLoad
2936 documentNameToLoad);
2937 localDocLoader.changeVersionAndActivateView(
2939 theInterface_->fill(&localDocLoader, documentVersionToLoad);
2941 localDocLoader.
print(ss);
2942 __GEN_COUTV__(ss.str());
2944 __GEN_COUTV__(runTimeSeconds());
2948 std::string documentNameToSave = documentNameToLoad;
2951 documentNameToSave);
2952 localDocSaver.changeVersionAndActivateView(
2955 std::string json =
"{ }";
2958 __COUTT__ <<
"Saving JSON string: "
2961 __COUTT__ <<
"Saving JSON doc as "
2962 << localDocSaver.getView().getTableName() <<
"("
2963 << localDocSaver.getView().getVersion().
toString() <<
")"
2967 theInterface_->saveActiveVersion(&localDocSaver,
false );
2971 __GEN_COUT__ <<
"Exception during table save." << __E__;
2973 __GEN_COUTV__(runTimeSeconds());
2977 documentNameToLoad);
2978 localDocLoader.changeVersionAndActivateView(
2980 theInterface_->fill(&localDocLoader, documentVersionToLoad);
2982 localDocLoader.
print(ss);
2983 __GEN_COUTV__(ss.str());
2985 __GEN_COUTV__(runTimeSeconds());
2987 __GEN_COUTV__(runTimeSeconds());
2991 std::string documentNameToLoad =
"MessageFacilityTable";
2994 documentNameToLoad);
2996 __GEN_COUT__ <<
"Testing table save of non-existing " << documentNameToLoad
3000 localDocLoader.changeVersionAndActivateView(
3002 theInterface_->fill(&localDocLoader, documentVersionToLoad);
3004 localDocLoader.
print(ss);
3005 __GEN_COUTV__(ss.str());
3006 __GEN_COUTV__(runTimeSeconds());
3008 __GEN_COUTV__(runTimeSeconds());
3015 theInterface_->findLatestVersion(&localDocLoader));
3016 localDocLoader.getViewP()->
setVersion(newVersion);
3018 __GEN_COUTT__ <<
"Saving new table as "
3019 << localDocLoader.getView().getTableName() <<
"("
3020 << localDocLoader.getView().getVersion().
toString() <<
")"
3024 "10.226.9.17", 0, 4);
3027 localDocLoader.
print(ss);
3028 __GEN_COUTV__(ss.str());
3031 theInterface_->saveActiveVersion(&localDocLoader,
false );
3035 __GEN_COUT__ <<
"Exception during new table save." << __E__;
3037 __GEN_COUTV__(runTimeSeconds());
3039 __GEN_COUTV__(runTimeSeconds());
3043 for(
auto& groupInfo : allGroupInfo_)
3047 groupInfo.second.latestKey_ = groupInfo.second.getLastKey();
3049 groupInfo.second.latestKey_,
3051 &groupInfo.second.latestKeyMemberMap_ ,
3054 &groupInfo.second.latestKeyGroupComment_,
3055 &groupInfo.second.latestKeyGroupAuthor_,
3056 &groupInfo.second.latestKeyGroupCreationTime_,
3058 &groupInfo.second.latestKeyGroupTypeString_);
3060 catch(
const std::runtime_error& e)
3063 <<
"Error occurred loading latest group info into cache for '"
3064 << groupInfo.first <<
"(" << groupInfo.second.latestKey_ <<
")': \n"
3065 << e.what() << __E__;
3067 groupInfo.second.latestKey_ = TableGroupKey::INVALID;
3068 groupInfo.second.latestKeyGroupComment_ =
3069 ConfigurationManager::UNKNOWN_INFO;
3070 groupInfo.second.latestKeyGroupAuthor_ =
3071 ConfigurationManager::UNKNOWN_INFO;
3072 groupInfo.second.latestKeyGroupCreationTime_ =
3073 ConfigurationManager::UNKNOWN_TIME;
3074 groupInfo.second.latestKeyGroupTypeString_ =
3075 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
3076 groupInfo.second.latestKeyMemberMap_ = {};
3081 <<
"Error occurred loading latest group info into cache for '"
3082 << groupInfo.first <<
"(" << groupInfo.second.latestKey_ <<
")'..."
3085 groupInfo.second.latestKey_ = TableGroupKey::INVALID;
3086 groupInfo.second.latestKeyGroupComment_ =
3087 ConfigurationManager::UNKNOWN_INFO;
3088 groupInfo.second.latestKeyGroupAuthor_ =
3089 ConfigurationManager::UNKNOWN_INFO;
3090 groupInfo.second.latestKeyGroupCreationTime_ =
3091 ConfigurationManager::UNKNOWN_TIME;
3092 groupInfo.second.latestKeyGroupTypeString_ =
3093 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
3094 groupInfo.second.latestKeyMemberMap_ = {};
3097 __GEN_COUTV__(runTimeSeconds());
3099 catch(
const std::runtime_error& e)
3101 __SS__ <<
"A fatal error occurred reading the info for all table groups. Error: "
3102 << e.what() << __E__;
3103 __GEN_COUT_ERR__ <<
"\n" << ss.str();
3104 if(accumulatedWarnings)
3105 *accumulatedWarnings += ss.str();
3111 __SS__ <<
"An unknown fatal error occurred reading the info for all table groups."
3113 __GEN_COUT_ERR__ <<
"\n" << ss.str();
3114 if(accumulatedWarnings)
3115 *accumulatedWarnings += ss.str();
3120 __GEN_COUT__ <<
"testXDAQContext() end runTimeSeconds()=" << runTimeSeconds()
3126 __GEN_COUT__ <<
"Loading table..." << __E__;
3132 __GEN_COUT__ << __E__;
3134 __GEN_COUT__ <<
"Value: " << v << __E__;
3135 __GEN_COUT__ <<
"Value index: " << t.
getValue<
int>() << __E__;
3141 __GEN_COUT__ <<
"Failed to load table..." << __E__;
TableVersion saveNewVersion(TableBase *table, TableVersion temporaryVersion, TableVersion newVersion=TableVersion())
TableVersion saveNewTable(const std::string &tableName, TableVersion temporaryVersion=TableVersion(), bool makeTemporary=false)
modifiers of generic TableBase
TableGroupKey findTableGroup(const std::string &groupName, const std::map< std::string, TableVersion > &groupMembers, const std::map< std::string, std::string > &groupAliases=std::map< std::string, std::string >())
void testXDAQContext(void)
for debugging
TableVersion saveNewBackbone(TableVersion temporaryVersion=TableVersion())
const GroupInfo & getGroupInfo(const std::string &groupName, bool attemptToReloadKeys=false)
public group cache handling
void clearAllCachedVersions(void)
const std::map< std::string, TableInfo > & getAllTableInfo(bool refresh=false, std::string *accumulatedWarnings=0, const std::string &errorFilterName="", bool getGroupKeys=false, bool getGroupInfo=false, bool initializeActiveGroups=false)
void loadTableGroup(const std::string &tableGroupName, const TableGroupKey &tableGroupKey, bool doActivate=false, std::map< std::string, TableVersion > *groupMembers=0, ProgressBar *progressBar=0, std::string *accumulateWarnings=0, std::string *groupComment=0, std::string *groupAuthor=0, std::string *groupCreateTime=0, bool doNotLoadMember=false, std::string *groupTypeString=0, std::map< std::string, std::string > *groupAliases=0, ConfigurationManager::LoadGroupType groupTypeToLoad=ConfigurationManager::LoadGroupType::ALL_TYPES, bool ignoreVersionTracking=false)
TableVersion copyViewToCurrentColumns(const std::string &tableName, TableVersion sourceVersion)
copyViewToCurrentColumns
TableGroupKey saveNewTableGroup(const std::string &groupName, std::map< std::string, TableVersion > &groupMembers, const std::string &groupComment=TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT, std::map< std::string, std::string > *groupAliases=0)
modifiers of a table group based on alias, e.g. "Physics"
void activateTableGroup(const std::string &tableGroupName, TableGroupKey tableGroupKey, std::string *accumulatedTreeErrors=0, std::string *groupTypeString=0)
modifiers of table groups
TableBase * getMetadataTable(TableVersion fillVersion=TableVersion())
created for use in otsdaq_flatten_system_aliases and otsdaq_export_system_aliases,...
TableVersion saveModifiedVersion(const std::string &tableName, TableVersion originalVersion, bool makeTemporary, TableBase *config, TableVersion temporaryModifiedVersion, bool ignoreDuplicates=false, bool lookForEquivalent=false, bool *foundEquivalent=nullptr)
TableVersion createTemporaryBackboneView(TableVersion sourceViewVersion=TableVersion())
-1, from MockUp, else from valid backbone view version
void clearCachedVersions(const std::string &tableName)
std::map< std::string, std::map< std::string, TableVersion > > getVersionAliases(void) const
void eraseTemporaryVersion(const std::string &tableName, TableVersion targetVersion=TableVersion())
static void compareTableGroupThread(ConfigurationManagerRW *cfgMgr, std::string groupName, ots::TableGroupKey groupKeyToCompare, const std::map< std::string, TableVersion > &groupMemberMap, const std::map< std::string, std::string > &memberTableAliases, std::atomic< bool > *theFoundIdentical, ots::TableGroupKey *theIdenticalKey, std::mutex *theThreadMutex, std::shared_ptr< std::atomic< bool >> theThreadDone)
static void loadTableGroupThread(ConfigurationManagerRW *cfgMgr, std::string groupName, ots::TableGroupKey groupKey, std::shared_ptr< ots::GroupInfo > theGroupInfo, std::shared_ptr< std::atomic< bool >> theThreadDone)
loadTableGroupThread()
static void loadTableInfoThread(ConfigurationManagerRW *cfgMgr, std::string tableName, TableBase *existingTable, std::shared_ptr< ots::TableInfo > tableInfo, std::shared_ptr< std::atomic< bool >> threadDone)
loadTableInfoThread()
std::map< std::string, std::map< std::string, TableVersion > > getVersionAliases(void) const
static const unsigned int PROCESSOR_COUNT
Static members.
static const std::string & convertGroupTypeToName(const ConfigurationManager::GroupType &groupTypeId)
void restoreActiveTableGroups(bool throwErrors=false, const std::string &pathToActiveGroupsFile="", ConfigurationManager::LoadGroupType onlyLoadIfBackboneOrContext=ConfigurationManager::LoadGroupType::ALL_TYPES, std::string *accumulatedWarnings=0)
std::map< std::string, TableVersion > getActiveVersions(void) const
getActiveVersions
ConfigurationTree getNode(const std::string &nodeString, bool doNotThrowOnBrokenUIDLinks=false) const
"root/parent/parent/"
void loadTableGroup(const std::string &tableGroupName, const TableGroupKey &tableGroupKey, bool doActivate=false, std::map< std::string, TableVersion > *groupMembers=0, ProgressBar *progressBar=0, std::string *accumulateWarnings=0, std::string *groupComment=0, std::string *groupAuthor=0, std::string *groupCreateTime=0, bool doNotLoadMember=false, std::string *groupTypeString=0, std::map< std::string, std::string > *groupAliases=0, ConfigurationManager::LoadGroupType groupTypeToLoad=ConfigurationManager::LoadGroupType::ALL_TYPES, bool ignoreVersionTracking=false, std::map< std::string, TableVersion > mergeInTables={}, std::map< std::string, TableVersion > overrideTables={})
void init(std::string *accumulatedErrors=0, bool initForWriteAccess=false, std::string *accumulatedWarnings=0)
static const std::string & getTypeNameOfGroup(const std::map< std::string, TableVersion > &memberMap)
void destroyTableGroup(const std::string &theGroup="", bool onlyDeactivate=false)
static const std::string ACTIVE_GROUPS_FILENAME
added env check for otsdaq_flatten_active_to_version to function
const TableBase * getTableByName(const std::string &configurationName) const
friend class ConfigurationManagerRW
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
TableVersion createTemporaryView(TableVersion sourceViewVersion=TableVersion(), TableVersion destTemporaryViewVersion=TableVersion::getNextTemporaryVersion())
source of -1, from MockUp, else from valid view version
void trimTemporary(TableVersion targetVersion=TableVersion())
unsigned int getNumberOfStoredViews(void) const
TableVersion checkForDuplicate(TableVersion needleVersion, TableVersion ignoreVersion=TableVersion()) const
TableView * getTemporaryView(TableVersion temporaryVersion)
const unsigned int MAX_VIEWS_IN_CACHE
TableVersion getNextVersion(void) const
TableVersion copyView(const TableView &sourceView, TableVersion destinationVersion, const std::string &author, bool looseColumnMatching=false)
void print(std::ostream &out=std::cout) const
always prints active view
TableVersion getNextTemporaryVersion(void) const
void trimCache(unsigned int trimSize=-1)
std::string toString(void) const
toString
static TableGroupKey getNextKey(const TableGroupKey &key=TableGroupKey())
static void getGroupNameAndKey(const std::string &fullGroupString, std::string &groupName, TableGroupKey &key)
requires fullGroupString created as name + "_v" + key + ""
bool isInvalid(void) const
isInvalid
static std::string getFullGroupString(const std::string &groupName, const TableGroupKey &key, const std::string &preKey="_v", const std::string &postKey="")
std::string toString(void) const
toString
bool isInvalid(void) const
isInvalid
static TableVersion getNextVersion(const TableVersion &version=TableVersion())
bool isScratchVersion(void) const
bool isTemporaryVersion(void) const
static TableVersion getNextTemporaryVersion(const TableVersion &version=TableVersion())
void setValueAsString(const std::string &value, unsigned int row, unsigned int col)
void setVersion(const T &version)
< in included .icc source
const std::string & getCustomStorageData(void) const
Getters.
unsigned int findCol(const std::string &name) const
void setCustomStorageData(const std::string &storageData)
defines used also by OtsConfigurationWizardSupervisor
TableEditStruct & getTableEditStruct(const std::string &tableName, bool markModified=false)
Note: if markModified, and table not found in group, this function will try to add it to group.
static std::string setToString(const std::set< T > &setToReturn, const std::string &delimeter=", ")
setToString ~
static std::string mapToString(const std::map< std::string, T > &mapToReturn, const std::string &primaryDelimeter=", ", const std::string &secondaryDelimeter=": ")
static std::string stackTrace(void)