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 __GEN_COUT_TYPE__(TLVL_DEBUG + 3)
499 << __COUT_HDR__ <<
"Copying table info for "
500 << tableInfo->tablePtr_->getTableName() << __E__;
501 nameToTableMap_[tableInfo->tablePtr_->getTableName()] =
502 tableInfo->tablePtr_;
503 allTableInfo_[tableInfo->tablePtr_->getTableName()].tablePtr_ =
504 tableInfo->tablePtr_;
505 allTableInfo_[tableInfo->tablePtr_->getTableName()].versions_ =
506 tableInfo->versions_;
509 __GEN_COUT__ <<
"Extracting list of tables complete." << __E__;
513 if(initializeActiveGroups)
515 __GEN_COUT__ <<
"Now initializing..." << __E__;
517 std::string tmpAccumulateWarnings;
520 accumulatedWarnings ? &tmpAccumulateWarnings :
nullptr);
522 if(accumulatedWarnings && errorFilterName ==
"")
523 *accumulatedWarnings += tmpAccumulateWarnings;
525 __GEN_COUT__ <<
"======================================================== "
526 "getAllTableInfo end runTimeSeconds()="
527 << runTimeSeconds() << __E__;
532 allGroupInfo_.clear();
537 std::set<std::string > tableGroups =
538 theInterface_->getAllTableGroupNames();
539 __GEN_COUT__ <<
"Number of Groups: " << tableGroups.size() << __E__;
541 __GEN_COUTT__ <<
"Group Info start runTimeSeconds()=" << runTimeSeconds()
546 for(
const auto& fullName : tableGroups)
549 allGroupInfo_[name].keys_.emplace(key);
552 __GEN_COUTT__ <<
"Group Keys end runTimeSeconds()=" << runTimeSeconds()
560 << numOfThreads <<
" threads." << __E__;
562 for(
auto& groupInfo : allGroupInfo_)
566 groupInfo.second.latestKey_ = groupInfo.second.getLastKey();
569 groupInfo.second.latestKey_,
571 &groupInfo.second.latestKeyMemberMap_ ,
574 &groupInfo.second.latestKeyGroupComment_,
575 &groupInfo.second.latestKeyGroupAuthor_,
576 &groupInfo.second.latestKeyGroupCreationTime_,
578 &groupInfo.second.latestKeyGroupTypeString_);
582 __GEN_COUT_WARN__ <<
"Error occurred loading latest group "
583 "info into cache for '"
584 << groupInfo.first <<
"("
585 << groupInfo.second.latestKey_ <<
")'..."
587 groupInfo.second.latestKey_ = TableGroupKey::INVALID;
588 groupInfo.second.latestKeyGroupComment_ =
589 ConfigurationManager::UNKNOWN_INFO;
590 groupInfo.second.latestKeyGroupAuthor_ =
591 ConfigurationManager::UNKNOWN_INFO;
592 groupInfo.second.latestKeyGroupCreationTime_ =
593 ConfigurationManager::UNKNOWN_TIME;
594 groupInfo.second.latestKeyGroupTypeString_ =
595 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
596 groupInfo.second.latestKeyMemberMap_ = {};
601 int threadsLaunched = 0;
602 int foundThreadIndex = 0;
604 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
605 for(
int i = 0; i < numOfThreads; ++i)
606 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
608 std::vector<std::shared_ptr<ots::GroupInfo>> sharedGroupInfoPtrs;
610 for(
auto& groupInfo : allGroupInfo_)
613 sharedGroupInfoPtrs.push_back(std::make_shared<ots::GroupInfo>());
615 if(threadsLaunched >= numOfThreads)
618 foundThreadIndex = -1;
619 while(foundThreadIndex == -1)
621 for(
int i = 0; i < numOfThreads; ++i)
624 foundThreadIndex = i;
627 if(foundThreadIndex == -1)
629 __GEN_COUTT__ <<
"Waiting for available thread..."
634 threadsLaunched = numOfThreads - 1;
636 __GEN_COUTT__ <<
"Starting thread... " << foundThreadIndex
637 <<
" for " << groupInfo.first <<
"("
638 << groupInfo.second.getLastKey() <<
")" << __E__;
640 *(threadDone[foundThreadIndex]) =
false;
644 std::string theGroupName,
646 std::shared_ptr<ots::GroupInfo> theGroupInfo,
647 std::shared_ptr<std::atomic<bool>> theThreadDone) {
657 groupInfo.second.getLastKey(),
658 sharedGroupInfoPtrs.back(),
659 threadDone[foundThreadIndex])
669 foundThreadIndex = -1;
670 for(
int i = 0; i < numOfThreads; ++i)
671 if(!*(threadDone[i]))
673 foundThreadIndex = i;
676 if(foundThreadIndex != -1)
678 __GEN_COUTT__ <<
"Waiting for thread to finish... "
679 << foundThreadIndex << __E__;
682 }
while(foundThreadIndex != -1);
686 for(
auto& groupInfo : allGroupInfo_)
688 groupInfo.second.latestKey_ = sharedGroupInfoPtrs[i]->latestKey_;
689 groupInfo.second.latestKeyGroupComment_ =
690 sharedGroupInfoPtrs[i]->latestKeyGroupComment_;
691 groupInfo.second.latestKeyGroupAuthor_ =
692 sharedGroupInfoPtrs[i]->latestKeyGroupAuthor_;
693 groupInfo.second.latestKeyGroupCreationTime_ =
694 sharedGroupInfoPtrs[i]->latestKeyGroupCreationTime_;
695 groupInfo.second.latestKeyGroupTypeString_ =
696 sharedGroupInfoPtrs[i]->latestKeyGroupTypeString_;
697 groupInfo.second.latestKeyMemberMap_ =
698 sharedGroupInfoPtrs[i]->latestKeyMemberMap_;
705 catch(
const std::runtime_error& e)
708 <<
"A fatal error occurred reading the info for all table groups. Error: "
709 << e.what() << __E__;
710 __GEN_COUT_ERR__ <<
"Error at time: " << time(0) <<
"\n" << ss.str();
711 if(accumulatedWarnings)
712 *accumulatedWarnings += ss.str();
718 __SS__ <<
"An unknown fatal error occurred reading the info for all table "
725 catch(
const std::exception& e)
727 ss <<
"Exception message: " << e.what();
732 __GEN_COUT_ERR__ <<
"\n" << ss.str();
733 if(accumulatedWarnings)
734 *accumulatedWarnings += ss.str();
738 __GEN_COUTT__ <<
"Group Info end runTimeSeconds()=" << runTimeSeconds() << __E__;
741 __GEN_COUTT__ <<
"Table Info end runTimeSeconds()=" << runTimeSeconds() << __E__;
743 return allTableInfo_;
750 std::string tableName,
752 std::shared_ptr<ots::TableInfo> tableInfo,
753 std::shared_ptr<std::atomic<bool>> threadDone)
756 __COUTT__ <<
"Thread started... table " << tableName << __E__;
759 tableInfo->tablePtr_ = 0;
763 cfgMgr->theInterface_->get(tableInfo->tablePtr_,
769 catch(cet::exception
const&)
771 if(tableInfo->tablePtr_)
772 delete tableInfo->tablePtr_;
773 tableInfo->tablePtr_ = 0;
775 __COUT__ <<
"Skipping! No valid class found for... " << tableName <<
"\n";
776 *(threadDone) =
true;
779 catch(std::runtime_error& e)
781 if(tableInfo->tablePtr_)
782 delete tableInfo->tablePtr_;
783 tableInfo->tablePtr_ = 0;
785 __COUT__ <<
"Skipping! No valid class found for... " << tableName <<
"\n";
786 __COUTT__ <<
"Error: " << e.what() << __E__;
791 if(tableInfo->accumulatedWarnings_ ==
"ALLOW")
793 tableInfo->accumulatedWarnings_ =
"";
796 tableInfo->accumulatedWarnings_ += std::string(
"\nIn table '") +
800 __SS__ <<
"Attempting to allow illegal columns!" << __E__;
801 tableInfo->accumulatedWarnings_ += ss.str();
805 __COUT__ <<
"Attempting to allow illegal columns!" << __E__;
807 std::string returnedAccumulatedErrors;
810 tableInfo->tablePtr_ =
811 new TableBase(tableName, &returnedAccumulatedErrors);
815 __COUT__ <<
"Skipping! Allowing illegal columns didn't work either... "
816 << tableName <<
"\n";
817 *(threadDone) =
true;
820 __COUT_WARN__ <<
"Error (but allowed): " << returnedAccumulatedErrors
824 tableInfo->accumulatedWarnings_ +=
825 std::string(
"\nIn table '") + tableName +
"'..." +
826 returnedAccumulatedErrors;
830 tableInfo->accumulatedWarnings_ =
"";
831 *(threadDone) =
true;
838 __COUTT__ <<
"Copying temporary version from existing table object for "
839 << tableName << __E__;
841 std::set<TableVersion> versions = existingTable->getStoredVersions();
842 for(
auto& version : versions)
843 if(version.isTemporaryVersion())
847 existingTable->setActiveView(version);
848 tableInfo->tablePtr_->copyView(
849 existingTable->getView(),
859 delete existingTable;
863 tableInfo->versions_ = cfgMgr->theInterface_->getVersions(tableInfo->tablePtr_);
867 std::set<TableVersion> versions = tableInfo->tablePtr_->getStoredVersions();
868 for(
auto& version : versions)
869 if(version.isTemporaryVersion())
871 tableInfo->versions_.emplace(version);
874 __COUTT__ <<
"Thread done... table " << tableName << __E__;
875 *(threadDone) =
true;
879 __COUT_ERR__ <<
"Error occurred loading latest table info into cache for '"
880 << tableName <<
"'..." << __E__;
881 *(threadDone) =
true;
888 const std::string& groupName,
891 std::map<std::string /*table name*/, TableVersion>*
894 std::string* accumulatedWarnings ,
895 std::string* groupComment ,
896 std::string* groupAuthor ,
897 std::string* groupCreateTime ,
898 bool doNotLoadMembers ,
899 std::string* groupTypeString ,
900 std::map<std::string /*name*/, std::string /*alias*/>*
902 ConfigurationManager::LoadGroupType
904 bool ignoreVersionTracking )
919 ignoreVersionTracking);
921 if(!groupMembers || !groupMembers->size() || !groupComment || groupKey.
isInvalid() ||
922 !groupAuthor || !groupCreateTime)
926 auto groupInfo = allGroupInfo_.find(groupName);
927 if(groupInfo == allGroupInfo_.end())
930 groupInfo->second.latestKey_ = groupKey;
931 groupInfo->second.latestKeyGroupComment_ = *groupComment;
932 groupInfo->second.latestKeyGroupAuthor_ = *groupAuthor;
933 groupInfo->second.latestKeyGroupCreationTime_ = *groupCreateTime;
935 groupInfo->second.latestKeyGroupTypeString_ = *groupTypeString;
936 groupInfo->second.latestKeyMemberMap_ = *groupMembers;
944 std::string groupName,
946 std::shared_ptr<ots::GroupInfo> groupInfo,
947 std::shared_ptr<std::atomic<bool>> threadDone)
950 __COUTT__ <<
"Thread started... " << groupName <<
"(" << groupKey <<
")" << __E__;
952 groupInfo->latestKey_ = groupKey;
956 &(groupInfo->latestKeyMemberMap_) ,
959 &(groupInfo->latestKeyGroupComment_),
960 &(groupInfo->latestKeyGroupAuthor_),
961 &(groupInfo->latestKeyGroupCreationTime_),
963 &(groupInfo->latestKeyGroupTypeString_));
965 *(threadDone) =
true;
969 __COUT_WARN__ <<
"Error occurred loading latest group info into cache for '"
970 << groupName <<
"(" << groupInfo->latestKey_ <<
")'..." << __E__;
971 groupInfo->latestKey_ = TableGroupKey::INVALID;
972 groupInfo->latestKeyGroupComment_ = ConfigurationManager::UNKNOWN_INFO;
973 groupInfo->latestKeyGroupAuthor_ = ConfigurationManager::UNKNOWN_INFO;
974 groupInfo->latestKeyGroupCreationTime_ = ConfigurationManager::UNKNOWN_TIME;
975 groupInfo->latestKeyGroupTypeString_ = ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
976 groupInfo->latestKeyMemberMap_ = {};
977 *(threadDone) =
true;
986 std::string groupName,
988 const std::map<std::string, TableVersion>& groupMemberMap,
989 const std::map<std::string /*name*/, std::string /*alias*/>& memberTableAliases,
990 std::atomic<bool>* foundIdentical,
992 std::mutex* threadMutex,
993 std::shared_ptr<std::atomic<bool>> threadDone)
996 std::map<std::string ,
TableVersion > compareToMemberMap;
997 std::map<std::string , std::string > compareToMemberTableAliases;
998 std::map<std::string , std::string >*
999 compareToMemberTableAliasesPtr =
nullptr;
1000 if(memberTableAliases
1002 compareToMemberTableAliasesPtr = &compareToMemberTableAliases;
1007 &compareToMemberMap ,
1015 compareToMemberTableAliasesPtr);
1021 for(
auto& memberPair : groupMemberMap)
1022 __COUTS__(9) <<
"member " << memberPair.first <<
" (" << memberPair.second
1024 for(
auto& memberPair : compareToMemberMap)
1025 __COUTS__(9) <<
"compare " << groupName <<
" (" << groupKeyToCompare
1026 <<
") member:" << memberPair.first <<
" (" << memberPair.second
1030 bool isDifferent =
false;
1031 for(
auto& memberPair : groupMemberMap)
1033 if(memberTableAliases.find(memberPair.first) != memberTableAliases.end())
1036 if(compareToMemberTableAliases.find(memberPair.first) ==
1037 compareToMemberTableAliases.end() ||
1038 memberTableAliases.at(memberPair.first) !=
1039 compareToMemberTableAliases.at(memberPair.first))
1043 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare
1044 <<
") on alias " << memberPair.first << __E__;
1050 else if(compareToMemberTableAliases.find(memberPair.first) !=
1051 compareToMemberTableAliases.end())
1056 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare
1057 <<
") on reverse alias " << memberPair.first << __E__;
1061 else if(compareToMemberMap.find(memberPair.first) ==
1062 compareToMemberMap.end() ||
1063 memberPair.second !=
1064 compareToMemberMap.at(memberPair.first))
1069 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare
1070 <<
") on mismatch " << memberPair.first << __E__;
1077 groupMemberMap.size() !=
1084 __COUTT__ <<
"diff " << groupName <<
" (" << groupKeyToCompare <<
") on size "
1090 *foundIdentical =
true;
1091 __COUT__ <<
"=====> Found exact match with key: " << groupKeyToCompare << __E__;
1093 std::lock_guard<std::mutex> lock(*threadMutex);
1094 *identicalKey = groupKeyToCompare;
1097 *(threadDone) =
true;
1101 __COUT_WARN__ <<
"Error occurred comparing group '" << groupName <<
"("
1102 << groupKeyToCompare <<
")'..." << __E__;
1104 *(threadDone) =
true;
1111 std::map<std::string ,
1115 std::map<std::string ,
1121 if(!ConfigurationInterface::isVersionTrackingEnabled())
1122 for(
const auto& tableInfo : allTableInfo_)
1123 for(
const auto& version : tableInfo.second.versions_)
1124 if(version.isScratchVersion())
1125 retMap[tableInfo.first][ConfigurationManager::SCRATCH_VERSION_ALIAS] =
1137 std::string* accumulatedTreeErrors,
1138 std::string* groupTypeString)
1147 accumulatedTreeErrors,
1156 __GEN_COUT_ERR__ <<
"There were errors, so de-activating group: "
1157 << tableGroupName <<
" (" << tableGroupKey <<
")" << __E__;
1168 __GEN_COUT_INFO__ <<
"Updating persistent active groups to "
1171 __COUT_INFO__ <<
"Active Context table group: " << theContextTableGroup_ <<
"("
1172 << (theContextTableGroupKey_
1173 ? theContextTableGroupKey_->toString().c_str()
1176 __COUT_INFO__ <<
"Active Backbone table group: " << theBackboneTableGroup_ <<
"("
1177 << (theBackboneTableGroupKey_
1178 ? theBackboneTableGroupKey_->toString().c_str()
1181 __COUT_INFO__ <<
"Active Iterate table group: " << theIterateTableGroup_ <<
"("
1182 << (theIterateTableGroupKey_
1183 ? theIterateTableGroupKey_->toString().c_str()
1186 __COUT_INFO__ <<
"Active Configuration table group: " << theConfigurationTableGroup_
1188 << (theConfigurationTableGroupKey_
1189 ? theConfigurationTableGroupKey_->toString().c_str()
1194 FILE* fp = fopen(fn.c_str(),
"w");
1197 __SS__ <<
"Fatal Error! Unable to open the file "
1199 <<
" for editing! Is there a permissions problem?" << __E__;
1200 __GEN_COUT_ERR__ << ss.str();
1204 fprintf(fp,
"%s\n", theContextTableGroup_.c_str());
1208 theContextTableGroupKey_ ? theContextTableGroupKey_->toString().c_str() :
"-1");
1209 fprintf(fp,
"%s\n", theBackboneTableGroup_.c_str());
1213 theBackboneTableGroupKey_ ? theBackboneTableGroupKey_->toString().c_str() :
"-1");
1214 fprintf(fp,
"%s\n", theIterateTableGroup_.c_str());
1218 theIterateTableGroupKey_ ? theIterateTableGroupKey_->toString().c_str() :
"-1");
1219 fprintf(fp,
"%s\n", theConfigurationTableGroup_.c_str());
1222 theConfigurationTableGroupKey_
1223 ? theConfigurationTableGroupKey_->toString().c_str()
1230 std::string(tableGroupName), tableGroupKey);
1231 if(theConfigurationTableGroupKey_ &&
1232 theConfigurationTableGroup_ == tableGroupName &&
1233 *theConfigurationTableGroupKey_ == tableGroupKey)
1235 ConfigurationManager::saveGroupNameAndKey(
1237 ConfigurationManager::LAST_ACTIVATED_CONFIG_GROUP_FILE,
1240 ConfigurationManager::saveGroupNameAndKey(
1242 ConfigurationManager::ACTIVATED_CONFIGS_FILE,
1246 else if(theContextTableGroupKey_ && theContextTableGroup_ == tableGroupName &&
1247 *theContextTableGroupKey_ == tableGroupKey)
1249 ConfigurationManager::saveGroupNameAndKey(
1251 ConfigurationManager::LAST_ACTIVATED_CONTEXT_GROUP_FILE,
1254 ConfigurationManager::saveGroupNameAndKey(
1256 ConfigurationManager::ACTIVATED_CONTEXTS_FILE,
1260 else if(theBackboneTableGroupKey_ && theBackboneTableGroup_ == tableGroupName &&
1261 *theBackboneTableGroupKey_ == tableGroupKey)
1263 ConfigurationManager::saveGroupNameAndKey(
1265 ConfigurationManager::LAST_ACTIVATED_BACKBONE_GROUP_FILE,
1268 ConfigurationManager::saveGroupNameAndKey(
1270 ConfigurationManager::ACTIVATED_BACKBONES_FILE,
1274 else if(theIterateTableGroupKey_ && theIterateTableGroup_ == tableGroupName &&
1275 *theIterateTableGroupKey_ == tableGroupKey)
1277 ConfigurationManager::saveGroupNameAndKey(
1279 ConfigurationManager::LAST_ACTIVATED_ITERATE_GROUP_FILE,
1282 ConfigurationManager::saveGroupNameAndKey(
1284 ConfigurationManager::ACTIVATED_ITERATES_FILE,
1299 __GEN_COUT_INFO__ <<
"Creating temporary backbone view from version "
1300 << sourceViewVersion << __E__;
1306 auto backboneMemberNames = ConfigurationManager::getBackboneMemberNames();
1307 for(
auto& name : backboneMemberNames)
1311 if(retTmpVersion < tmpVersion)
1312 tmpVersion = retTmpVersion;
1315 __GEN_COUT__ <<
"Common temporary backbone version found as " << tmpVersion << __E__;
1318 for(
auto& name : backboneMemberNames)
1322 if(retTmpVersion != tmpVersion)
1324 __SS__ <<
"Failure! Temporary view requested was " << tmpVersion
1325 <<
". Mismatched temporary view created: " << retTmpVersion << __E__;
1326 __GEN_COUT_ERR__ << ss.str();
1335 TableBase* ConfigurationManagerRW::getTableByName(
const std::string& tableName)
1337 if(nameToTableMap_.find(tableName) == nameToTableMap_.end())
1339 if(tableName == ConfigurationManager::ARTDAQ_TOP_TABLE_NAME)
1342 <<
"Since target table was the artdaq top configuration level, "
1343 "attempting to help user by appending to core tables file: "
1344 << CORE_TABLE_INFO_FILENAME << __E__;
1345 FILE* fp = fopen((CORE_TABLE_INFO_FILENAME).c_str(),
"a");
1348 fprintf(fp,
"\nARTDAQ/*");
1353 __SS__ <<
"Table not found with name: " << tableName << __E__;
1355 if((f = tableName.find(
' ')) != std::string::npos)
1356 ss <<
"There was a space character found in the table name needle at "
1358 << f <<
" in the string (was this intended?). " << __E__;
1360 ss <<
"\nIf you think this table should exist in the core set of tables, try "
1361 "running 'UpdateOTS.sh --tables' to update your tables, then relaunch ots."
1363 ss <<
"\nTables must be defined at path $USER_DATA/TableInfo/ to exist in ots. "
1364 "Please verify your table definitions, and then restart ots."
1366 __GEN_COUT_ERR__ <<
"\n" << ss.str();
1369 return nameToTableMap_[tableName];
1378 const std::string& tableName,
1380 bool looseColumnMatching ,
1381 std::string* accumulatedErrors ,
1384 auto it = nameToTableMap_.find(tableName);
1385 if(it == nameToTableMap_.end())
1387 __SS__ <<
"\nCan not find table named '" << tableName
1388 <<
"'\n\n\n\nYou need to load the table before it can be used."
1389 <<
"It probably is missing from the member list of the Table "
1390 "Group that was loaded?\n\n\n\n\n"
1398 table->setActiveView(version);
1402 std::stringstream jsonSs;
1403 table->getViewP()->printJSON(jsonSs);
1404 table->getViewP()->doGetSourceRawData(
true);
1410 theInterface_->get(table,
1417 looseColumnMatching,
1435 TableBase* table = getTableByName(tableName);
1440 newVersion = theInterface_->saveNewVersion(table, temporaryVersion);
1442 table->setActiveView(newVersion);
1446 allTableInfo_[tableName].versions_.find(newVersion) !=
1447 allTableInfo_[tableName].versions_.end())
1450 <<
"What happenened!?? ERROR::: new persistent version v" << newVersion
1451 <<
" already exists!? How is it possible? Retrace your steps and "
1459 newVersion = temporaryVersion;
1463 __GEN_COUT_WARN__ <<
"Attempting to recover and use v" << newVersion << __E__;
1467 theInterface_->saveNewVersion(table, temporaryVersion, newVersion);
1469 table->setActiveView(newVersion);
1474 __SS__ <<
"Something went wrong saving the new version v" << newVersion
1475 <<
". What happened?! (duplicates? database error?)" << __E__;
1476 __GEN_COUT_ERR__ <<
"\n" << ss.str();
1481 allTableInfo_[tableName].versions_.insert(newVersion);
1495 TableBase* table = getTableByName(tableName);
1500 if(allTableInfo_.find(tableName) == allTableInfo_.end())
1507 for(
auto it = allTableInfo_[tableName].versions_.begin();
1508 it != allTableInfo_[tableName].versions_.end();
1511 if(it->isTemporaryVersion())
1513 __GEN_COUT__ <<
"Removing '" << tableName <<
"' version info: " << *it
1515 allTableInfo_[tableName].versions_.erase(it++);
1524 auto it = allTableInfo_[tableName].versions_.find(targetVersion);
1525 if(it == allTableInfo_[tableName].versions_.end())
1527 __GEN_COUT__ <<
"Target '" << tableName <<
"' version v" << targetVersion
1528 <<
" was not found in info versions..." << __E__;
1531 allTableInfo_[tableName].versions_.erase(
1532 allTableInfo_[tableName].versions_.find(targetVersion));
1543 TableBase* table = getTableByName(tableName);
1555 for(
auto configInfo : allTableInfo_)
1556 configInfo.second.tablePtr_->trimCache(0);
1562 const std::string& tableName,
TableVersion sourceVersion)
1564 getTableByName(tableName)->reset();
1576 allTableInfo_[tableName].versions_.insert(newTemporaryVersion);
1578 return newTemporaryVersion;
1586 const std::string& groupName,
bool attemptToReloadKeys )
1593 auto it = allGroupInfo_.find(groupName);
1594 if(it == allGroupInfo_.end())
1596 __SS__ <<
"Group name '" << groupName
1597 <<
"' not found in group info! (creating empty info)" << __E__;
1598 __GEN_COUT_WARN__ << ss.str();
1600 return allGroupInfo_[groupName];
1603 if(attemptToReloadKeys)
1605 __GEN_COUT__ <<
"Reloading keys from special db group cache if it exists..."
1608 std::set<TableGroupKey> keys;
1611 bool cacheFailed =
false;
1617 TableBase::GROUP_CACHE_PREPEND + groupName);
1618 auto versions = theInterface_->getVersions(&localGroupMemberCacheLoader);
1619 for(
const auto& version : versions)
1624 __GEN_COUT__ <<
"Ignoring cache loading error. Doing full load of keys..."
1629 if(cacheFailed && 0)
1630 keys = theInterface_->getKeys(groupName);
1634 __GEN_COUT__ <<
"Key from special db group cache were loaded." << __E__;
1635 it->second.keys_ = keys;
1654 const std::string& groupName,
1655 const std::map<std::string, TableVersion>& groupMemberMap,
1656 const std::map<std::string /*name*/, std::string /*alias*/>& memberTableAliases)
1658 if(!groupMemberMap.size() || groupName.empty())
1660 __SS__ <<
"Illegal name/members for requested group of name '" << groupName
1661 <<
"' and member count = " << groupMemberMap.size() << __E__;
1669 std::set<TableGroupKey> keys;
1672 bool cacheFailed =
false;
1678 TableBase::GROUP_CACHE_PREPEND + groupName);
1679 auto versions = theInterface_->getVersions(&localGroupMemberCacheLoader);
1680 for(
const auto& version : versions)
1685 __COUT__ <<
"Ignoring cache loading error. Doing full load of keys..."
1691 keys = theInterface_->getKeys(groupName);
1696 const unsigned int MAX_DEPTH_TO_CHECK = 20;
1697 unsigned int keyMinToCheck = 0;
1700 keyMinToCheck = keys.rbegin()->key();
1701 if(keyMinToCheck > MAX_DEPTH_TO_CHECK)
1703 keyMinToCheck -= MAX_DEPTH_TO_CHECK;
1704 __GEN_COUT__ <<
"Checking groups back to key... " << keyMinToCheck << __E__;
1709 __GEN_COUT__ <<
"Checking all groups." << __E__;
1717 __GEN_COUT__ <<
" PROCESSOR_COUNT " <<
PROCESSOR_COUNT <<
" ==> " << numOfThreads
1718 <<
" threads." << __E__;
1719 if(numOfThreads < 2)
1721 std::map<std::string ,
TableVersion > compareToMemberMap;
1722 std::map<std::string , std::string > compareToMemberTableAliases;
1723 std::map<std::string , std::string >*
1724 compareToMemberTableAliasesPtr =
nullptr;
1725 if(memberTableAliases.size())
1726 compareToMemberTableAliasesPtr = &compareToMemberTableAliases;
1729 for(
const auto& key : keys)
1731 if(key.key() < keyMinToCheck)
1737 &compareToMemberMap ,
1745 compareToMemberTableAliasesPtr);
1747 isDifferent =
false;
1748 for(
auto& memberPair : groupMemberMap)
1750 if(memberTableAliases.find(memberPair.first) != memberTableAliases.end())
1753 if(compareToMemberTableAliases.find(memberPair.first) ==
1754 compareToMemberTableAliases.end() ||
1755 memberTableAliases.at(memberPair.first) !=
1756 compareToMemberTableAliases.at(memberPair.first))
1764 else if(compareToMemberTableAliases.find(memberPair.first) !=
1765 compareToMemberTableAliases.end())
1772 else if(compareToMemberMap.find(memberPair.first) ==
1773 compareToMemberMap.end() ||
1774 memberPair.second !=
1775 compareToMemberMap.at(
1787 if(groupMemberMap.size() != compareToMemberMap.size())
1791 __GEN_COUT__ <<
"Found exact match with key: " << key << __E__;
1795 __GEN_COUT__ <<
"No match found - this group is new!" << __E__;
1801 int threadsLaunched = 0;
1802 int foundThreadIndex = 0;
1803 std::atomic<bool> foundIdentical =
false;
1805 std::mutex threadMutex;
1807 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
1808 for(
int i = 0; i < numOfThreads; ++i)
1809 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
1811 for(
const auto& key : keys)
1815 if(key.key() < keyMinToCheck)
1818 if(threadsLaunched >= numOfThreads)
1821 foundThreadIndex = -1;
1822 while(foundThreadIndex == -1)
1827 for(
int i = 0; i < numOfThreads; ++i)
1828 if(*(threadDone[i]))
1830 foundThreadIndex = i;
1833 if(foundThreadIndex == -1)
1835 __GEN_COUTT__ <<
"Waiting for available thread..." << __E__;
1839 threadsLaunched = numOfThreads - 1;
1844 __GEN_COUTT__ <<
"Starting thread... " << foundThreadIndex << __E__;
1845 *(threadDone[foundThreadIndex]) =
false;
1849 std::string theGroupName,
1851 const std::map<std::string, TableVersion>& groupMemberMap,
1852 const std::map<std::string /*name*/, std::string /*alias*/>&
1854 std::atomic<bool>* theFoundIdentical,
1856 std::mutex* theThreadMutex,
1857 std::shared_ptr<std::atomic<bool>> theThreadDone) {
1876 threadDone[foundThreadIndex])
1886 foundThreadIndex = -1;
1887 for(
int i = 0; i < numOfThreads; ++i)
1888 if(!*(threadDone[i]))
1890 foundThreadIndex = i;
1893 if(foundThreadIndex != -1)
1895 __GEN_COUTT__ <<
"Waiting for thread to finish... " << foundThreadIndex
1899 }
while(foundThreadIndex != -1);
1903 __GEN_COUT__ <<
"Found exact match with key: " << identicalKey << __E__;
1904 return identicalKey;
1921 return &groupMetadataTable_;
1925 std::lock_guard<std::mutex> lock(metaDataTableMutex_);
1928 while(groupMetadataTable_.getView().getNumberOfRows())
1929 groupMetadataTable_.getViewP()->deleteRow(0);
1934 theInterface_->fill(&groupMetadataTable_, fillVersion);
1936 catch(
const std::runtime_error& e)
1938 __GEN_COUT_WARN__ <<
"Failed to load " << groupMetadataTable_.getTableName()
1939 <<
"-v" << fillVersion <<
". Metadata error: " << e.what()
1944 __GEN_COUT_WARN__ <<
"Failed to load " << groupMetadataTable_.getTableName()
1945 <<
"-v" << fillVersion <<
". Ignoring unknown metadata error. "
1950 if(groupMetadataTable_.getView().getNumberOfRows() != 1)
1952 groupMetadataTable_.print();
1953 __GEN_COUT_ERR__ <<
"Ignoring that groupMetadataTable_ v" << fillVersion
1955 "number of rows!' Must "
1956 "be 1. Going with anonymous defaults."
1960 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
1961 groupMetadataTable_.getViewP()->deleteRow(0);
1962 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
1963 groupMetadataTable_.getViewP()->addRow();
1966 return &groupMetadataTable_;
1977 const std::string& groupName,
1978 std::map<std::string, TableVersion>& groupMembers,
1979 const std::string& groupComment,
1980 std::map<std::string /*table*/, std::string /*alias*/>* groupAliases)
1988 if(groupMembers.size() == 0)
1990 __SS__ <<
"Empty group member list. Can not create a group without members!"
1995 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2000 for(
auto& memberPair : groupMembers)
2003 if(allCfgInfo.find(memberPair.first) == allCfgInfo.end())
2005 __GEN_COUT_ERR__ <<
"Group member \"" << memberPair.first
2006 <<
"\" not found in database!";
2008 if(groupMetadataTable_.getTableName() == memberPair.first)
2011 <<
"Looks like this is the groupMetadataTable_ '"
2012 << TableBase::GROUP_METADATA_TABLE_NAME
2013 <<
".' Note that this table is added to the member map when groups "
2015 <<
"It should not be part of member map when calling this function."
2017 __GEN_COUT__ <<
"Attempting to recover." << __E__;
2018 groupMembers.erase(groupMembers.find(memberPair.first));
2022 __SS__ << (
"Group member not found!") << __E__;
2027 if(allCfgInfo[memberPair.first].versions_.find(memberPair.second) ==
2028 allCfgInfo[memberPair.first].versions_.end())
2030 __SS__ <<
"Group member \"" << memberPair.first <<
"\" version \""
2031 << memberPair.second <<
"\" not found in database!";
2036 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2041 for(
auto& aliasPair : *groupAliases)
2044 if(groupMembers.find(aliasPair.first) == groupMembers.end())
2046 __GEN_COUT_ERR__ <<
"Group member \"" << aliasPair.first
2047 <<
"\" not found in group member map!";
2049 __SS__ << (
"Alias table not found in member list!") << __E__;
2057 __GEN_COUT__ <<
"New Key for group: " << groupName <<
" found as " << newKey << __E__;
2058 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2060 time_t groupCreationTime = time(0);
2063 std::map<std::string ,
TableVersion > groupMembersWithoutMeta =
2070 std::string groupAliasesString =
"";
2073 *groupAliases,
"," ,
":" );
2074 __GEN_COUT__ <<
"Metadata: " << username_ <<
" " << groupCreationTime <<
" "
2075 << groupComment <<
" " << groupAliasesString <<
" " << groupType
2080 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
2081 groupMetadataTable_.getViewP()->deleteRow(0);
2082 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
2083 groupMetadataTable_.getViewP()->addRow();
2086 groupMetadataTable_.getViewP()->setValue(
2087 groupAliasesString, 0, ConfigurationManager::METADATA_COL_ALIASES);
2088 groupMetadataTable_.getViewP()->setValue(
2089 groupComment, 0, ConfigurationManager::METADATA_COL_COMMENT);
2090 groupMetadataTable_.getViewP()->setValue(
2091 username_, 0, ConfigurationManager::METADATA_COL_AUTHOR);
2092 groupMetadataTable_.getViewP()->setValue(
2093 groupCreationTime, 0, ConfigurationManager::METADATA_COL_TIMESTAMP);
2097 std::stringstream ss;
2098 groupMetadataTable_.print(ss);
2099 __COUT_MULTI__(2, ss.str());
2106 theInterface_->findLatestVersion(&groupMetadataTable_));
2107 groupMetadataTable_.getViewP()->setVersion(newVersion);
2109 uint16_t retries = 0;
2114 theInterface_->saveActiveVersion(&groupMetadataTable_);
2116 catch(
const std::runtime_error& e)
2118 __GEN_COUT__ <<
"Caught runtime_error exception during table save."
2120 if(std::string(e.what()).find(
"there was a collision") !=
2124 <<
"There was a collision saving the new table "
2125 << groupMetadataTable_ <<
"(" << newVersion
2126 <<
"), trying incremented table version... retries="
2127 << retries << __E__;
2132 groupMetadataTable_.getViewP()->setVersion(newVersion);
2133 __GEN_COUT__ <<
"New version for table: " << groupMetadataTable_
2134 <<
" found as " << newVersion << __E__;
2141 __GEN_COUT__ <<
"Created table: " << groupMetadataTable_ <<
"-v"
2142 << newVersion << __E__;
2147 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2151 groupMembers[groupMetadataTable_.getTableName()] =
2152 groupMetadataTable_.getViewVersion();
2156 uint16_t retries = 0;
2159 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2164 theInterface_->saveTableGroup(
2168 catch(
const std::runtime_error& e)
2170 __GEN_COUT__ <<
"Caught runtime_error exception during group save."
2172 if(std::string(e.what()).find(
"there was a collision") !=
2176 <<
"There was a collision saving the new group " << groupName
2178 <<
"), trying incremented group key... retries=" << retries
2183 __GEN_COUT__ <<
"New Key for group: " << groupName <<
" found as "
2191 __GEN_COUT__ <<
"Created table group: " << groupName <<
"(" << newKey
2197 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2200 catch(std::runtime_error& e)
2202 __GEN_COUT_ERR__ <<
"Failed to create table group: " << groupName <<
"(" << newKey
2204 __GEN_COUT_ERR__ <<
"\n\n" << e.what() << __E__;
2209 __GEN_COUT_ERR__ <<
"Failed to create table group: " << groupName <<
":" << newKey
2214 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2217 allGroupInfo_[groupName].keys_.emplace(newKey);
2219 allGroupInfo_.at(groupName).latestKey_ = newKey;
2220 allGroupInfo_.at(groupName).latestKeyGroupAuthor_ = username_;
2221 allGroupInfo_.at(groupName).latestKeyGroupComment_ = groupComment;
2222 allGroupInfo_.at(groupName).latestKeyGroupCreationTime_ = groupCreationTime;
2223 allGroupInfo_.at(groupName).latestKeyGroupTypeString_ = groupType;
2224 allGroupInfo_.at(groupName).latestKeyMemberMap_ = groupMembersWithoutMeta;
2226 __GEN_COUT__ <<
"Saved " << groupName <<
"(" << newKey <<
") of type " << groupType
2229 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2241 __GEN_COUT_INFO__ <<
"Creating new backbone from temporary version "
2242 << temporaryVersion << __E__;
2247 auto backboneMemberNames = ConfigurationManager::getBackboneMemberNames();
2248 for(
auto& name : backboneMemberNames)
2251 __GEN_COUT__ <<
"New version for backbone member (" << name
2252 <<
"): " << retNewVersion << __E__;
2253 if(retNewVersion > newVersion)
2254 newVersion = retNewVersion;
2257 __GEN_COUT__ <<
"Common new backbone version found as " << newVersion << __E__;
2260 for(
auto& name : backboneMemberNames)
2264 getTableByName(name), temporaryVersion, newVersion);
2265 if(retNewVersion != newVersion)
2267 __SS__ <<
"Failure! New view requested was " << newVersion
2268 <<
". Mismatched new view created: " << retNewVersion << __E__;
2269 __GEN_COUT_ERR__ << ss.str();
2283 const std::string& tableName,
2288 bool ignoreDuplicates ,
2289 bool lookForEquivalent ,
2290 bool* foundEquivalent )
2292 bool needToEraseTemporarySource =
2296 *foundEquivalent =
false;
2299 if(!ignoreDuplicates)
2301 __GEN_COUT__ <<
"Checking for duplicate '" << tableName <<
"' tables..." << __E__;
2309 const std::map<std::string, TableInfo>& allTableInfo =
2312 auto versionReverseIterator =
2313 allTableInfo.at(tableName).versions_.rbegin();
2314 __GEN_COUT__ <<
"Filling up '" << tableName <<
"' cache from "
2318 versionReverseIterator != allTableInfo.at(tableName).versions_.rend();
2319 ++versionReverseIterator)
2321 __GEN_COUTT__ <<
"'" << tableName <<
"' versions in reverse order "
2322 << *versionReverseIterator << __E__;
2326 *versionReverseIterator);
2328 catch(
const std::runtime_error& e)
2331 __COUTT__ <<
"'" << tableName
2332 <<
"' version failed to load: " << *versionReverseIterator
2338 __GEN_COUT__ <<
"Checking '" << tableName <<
"' for duplicate..." << __E__;
2341 temporaryModifiedVersion,
2347 if(lookForEquivalent && !duplicateVersion.
isInvalid())
2350 __GEN_COUT__ <<
"Equivalent '" << tableName <<
"' table found in version v"
2351 << duplicateVersion << __E__;
2356 __GEN_COUT__ <<
"Need persistent. Duplicate '" << tableName
2357 <<
"' version was temporary. "
2358 "Abandoning duplicate."
2370 if(needToEraseTemporarySource)
2374 *foundEquivalent =
true;
2376 __GEN_COUT__ <<
"\t\t Equivalent '" << tableName
2377 <<
"' assigned version: " << duplicateVersion << __E__;
2379 return duplicateVersion;
2385 __SS__ <<
"This version of table '" << tableName
2386 <<
"' is identical to another version currently cached v"
2387 << duplicateVersion <<
". No reason to save a duplicate." << __E__;
2388 __GEN_COUT_ERR__ <<
"\n" << ss.str();
2391 table->eraseView(temporaryModifiedVersion);
2395 __GEN_COUT__ <<
"Check for duplicate '" << tableName <<
"' tables complete."
2400 __GEN_COUT__ <<
"\t\t**************************** Save as temporary '"
2401 << tableName <<
"' table version" << __E__;
2403 __GEN_COUT__ <<
"\t\t**************************** Save as new '" << tableName
2404 <<
"' table version" << __E__;
2407 saveNewTable(tableName, temporaryModifiedVersion, makeTemporary);
2409 __GEN_COUTTV__(table->getView().getComment());
2411 if(needToEraseTemporarySource)
2414 __GEN_COUT__ <<
"\t\t '" << tableName
2415 <<
"' new assigned version: " << newAssignedVersion << __E__;
2416 return newAssignedVersion;
2420 GroupEditStruct::GroupEditStruct(
const ConfigurationManager::GroupType& groupType,
2422 : groupType_(groupType)
2423 , originalGroupName_(cfgMgr->getActiveGroupName(groupType))
2424 , originalGroupKey_(cfgMgr->getActiveGroupKey(groupType))
2426 , mfSubject_(cfgMgr->getUsername())
2428 if(originalGroupName_ ==
"" || originalGroupKey_.isInvalid())
2430 __SS__ <<
"Error! No active group found for type '"
2432 <<
".' There must be an active group to edit the group." << __E__ << __E__
2437 __GEN_COUT__ <<
"Extracting Group-Edit Struct for type "
2442 const std::set<std::string>& memberNames =
2443 groupType == ConfigurationManager::GroupType::CONTEXT_TYPE
2444 ? cfgMgr->getActiveContextMemberNames()
2445 : (groupType == ConfigurationManager::GroupType::BACKBONE_TYPE
2446 ? ConfigurationManager::getBackboneMemberNames()
2449 : cfgMgr->getConfigurationMemberNames()));
2451 for(
auto& memberName : memberNames)
2454 groupMembers_.emplace(
2455 std::make_pair(memberName, activeTables.at(memberName)));
2456 groupTables_.emplace(std::make_pair(
2463 __SS__ <<
"Error! Could not find group member table '" << memberName
2464 <<
"' for group type '"
2466 <<
".' All group members must be present to create the group editing "
2475 GroupEditStruct::~GroupEditStruct()
2477 __GEN_COUT__ <<
"GroupEditStruct from editing '" << originalGroupName_ <<
"("
2478 << originalGroupKey_ <<
")' Destructing..." << __E__;
2480 __GEN_COUT__ <<
"GroupEditStruct from editing '" << originalGroupName_ <<
"("
2481 << originalGroupKey_ <<
")' Desctructed." << __E__;
2489 auto it = groupTables_.find(tableName);
2490 if(it == groupTables_.end())
2492 if(groupType_ == ConfigurationManager::GroupType::CONFIGURATION_TYPE &&
2495 __GEN_COUT__ <<
"Table '" << tableName
2496 <<
"' not found in configuration table members from editing '"
2497 << originalGroupName_ <<
"(" << originalGroupKey_ <<
")..."
2498 <<
" Attempting to add it!" << __E__;
2501 auto newIt = groupTables_.emplace(std::make_pair(
2506 newIt.first->second.modified_ =
2508 groupMembers_.emplace(
2509 std::make_pair(tableName, newIt.first->second.temporaryVersion_));
2510 return newIt.first->second;
2512 __GEN_COUT_ERR__ <<
"Failed to emplace new table..." << __E__;
2515 __SS__ <<
"Table '" << tableName <<
"' not found in table members from editing '"
2516 << originalGroupName_ <<
"(" << originalGroupKey_ <<
")!'" << __E__;
2519 it->second.modified_ =
2525 void GroupEditStruct::dropChanges()
2527 __GEN_COUT__ <<
"Dropping unsaved changes from editing '" << originalGroupName_ <<
"("
2528 << originalGroupKey_ <<
")'..." << __E__;
2533 for(
auto& groupTable : groupTables_)
2534 if(groupTable.second
2535 .createdTemporaryVersion_)
2539 groupTable.second.temporaryVersion_);
2540 groupTable.second.createdTemporaryVersion_ =
false;
2541 groupTable.second.modified_ =
false;
2544 __GEN_COUT__ <<
"Unsaved changes dropped from editing '" << originalGroupName_ <<
"("
2545 << originalGroupKey_ <<
").'" << __E__;
2549 void GroupEditStruct::saveChanges(
const std::string& groupNameToSave,
2551 bool* foundEquivalentGroupKey ,
2552 bool activateNewGroup ,
2553 bool updateGroupAliases ,
2554 bool updateTableAliases ,
2556 bool* foundEquivalentBackboneKey ,
2557 std::string* accumulatedWarnings )
2559 __GEN_COUT__ <<
"Saving changes..." << __E__;
2564 if(foundEquivalentBackboneKey)
2565 *foundEquivalentBackboneKey =
false;
2569 bool anyTableNew =
false;
2570 for(
auto& groupTable : groupTables_)
2572 if(!groupTable.second.modified_)
2575 __GEN_COUT__ <<
"Original version is " << groupTable.second.tableName_ <<
"-v"
2576 << groupTable.second.originalVersion_ << __E__;
2579 groupTable.second.tableName_,
2580 groupTable.second.originalVersion_,
2582 groupTable.second.table_,
2583 groupTable.second.temporaryVersion_,
2586 __GEN_COUT__ <<
"Temporary target version is " << groupTable.second.tableName_
2587 <<
"-v" << groupMembers_.at(groupTable.first) <<
"-v"
2588 << groupTable.second.temporaryVersion_ << __E__;
2591 groupTable.second.tableName_,
2592 groupTable.second.originalVersion_,
2594 groupTable.second.table_,
2595 groupTable.second.temporaryVersion_,
2599 if(groupTable.second.originalVersion_ != groupMembers_.at(groupTable.first))
2602 __GEN_COUT__ <<
"Final NEW target version is " << groupTable.second.tableName_
2603 <<
"-v" << groupMembers_.at(groupTable.first) << __E__;
2606 __GEN_COUT__ <<
"Final target version is " << groupTable.second.tableName_
2607 <<
"-v" << groupMembers_.at(groupTable.first) << __E__;
2609 groupTable.second.modified_ =
false;
2610 groupTable.second.createdTemporaryVersion_ =
false;
2613 for(
auto& table : groupMembers_)
2615 __GEN_COUT__ << table.first <<
" v" << table.second << __E__;
2620 __GEN_COUT__ <<
"Checking for duplicate groups..." << __E__;
2621 newGroupKey = cfgMgr->
findTableGroup(groupNameToSave, groupMembers_);
2624 __GEN_COUT__ <<
"New table found, so no need to check duplicate groups." << __E__;
2628 __GEN_COUT__ <<
"Found equivalent group key (" << newGroupKey <<
") for "
2629 << groupNameToSave <<
"." << __E__;
2630 if(foundEquivalentGroupKey)
2631 *foundEquivalentGroupKey =
true;
2636 __GEN_COUT__ <<
"Saved new Context group key (" << newGroupKey <<
") for "
2637 << groupNameToSave <<
"." << __E__;
2640 bool groupAliasChange =
false;
2641 bool tableAliasChange =
false;
2644 ConfigurationManager::GroupType::
2647 GroupEditStruct backboneGroupEdit(ConfigurationManager::GroupType::BACKBONE_TYPE,
2650 if(groupType_ != ConfigurationManager::GroupType::BACKBONE_TYPE &&
2656 TableEditStruct& groupAliasTable = backboneGroupEdit.getTableEditStruct(
2657 ConfigurationManager::GROUP_ALIASES_TABLE_NAME,
true );
2658 TableView* tableView = groupAliasTable.tableView_;
2661 unsigned int row = 0;
2663 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
2664 cfgMgr->
getNode(ConfigurationManager::GROUP_ALIASES_TABLE_NAME)
2666 std::string groupName, groupKey;
2667 for(
auto& aliasNodePair : aliasNodePairs)
2669 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
2670 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
2672 __GEN_COUT__ <<
"Group Alias: " << aliasNodePair.first <<
" => "
2673 << groupName <<
"(" << groupKey <<
"); row=" << row << __E__;
2675 if(groupName == originalGroupName_ &&
2678 __GEN_COUT__ <<
"Found alias! Changing group key from ("
2679 << originalGroupKey_ <<
") to (" << newGroupKey <<
")"
2682 groupAliasChange =
true;
2691 if(groupAliasChange)
2693 std::stringstream ss;
2694 tableView->print(ss);
2695 __GEN_COUT__ << ss.str();
2699 if(groupType_ != ConfigurationManager::GroupType::BACKBONE_TYPE &&
2705 .getTableEditStruct(ConfigurationManager::VERSION_ALIASES_TABLE_NAME,
2709 for(
auto& groupTable : groupTables_)
2711 if(groupTable.second.originalVersion_ ==
2712 groupMembers_.at(groupTable.second.tableName_))
2715 __GEN_COUT__ <<
"Checking alias... original version is "
2716 << groupTable.second.tableName_ <<
"-v"
2717 << groupTable.second.originalVersion_
2718 <<
" and new version is v"
2719 << groupMembers_.at(groupTable.second.tableName_) << __E__;
2722 unsigned int row = 0;
2724 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
2725 cfgMgr->
getNode(ConfigurationManager::VERSION_ALIASES_TABLE_NAME)
2727 std::string tableName, tableVersion;
2728 for(
auto& aliasNodePair : aliasNodePairs)
2731 aliasNodePair.second.getNode(
"TableName").getValueAsString();
2733 aliasNodePair.second.getNode(
"Version").getValueAsString();
2735 __GEN_COUT__ <<
"Table Alias: " << aliasNodePair.first <<
" => "
2736 << tableName <<
"-v" << tableVersion <<
"" << __E__;
2738 if(tableName == groupTable.second.tableName_ &&
2739 TableVersion(tableVersion) == groupTable.second.originalVersion_)
2741 __GEN_COUT__ <<
"Found alias! Changing icon table version alias."
2744 tableAliasChange =
true;
2747 groupMembers_.at(groupTable.second.tableName_).toString(),
2749 tableView->
findCol(
"Version"));
2756 if(tableAliasChange)
2758 std::stringstream ss;
2759 tableView->print(ss);
2760 __GEN_COUT__ << ss.str();
2766 if(groupAliasChange || tableAliasChange)
2768 for(
auto& table : backboneGroupEdit.groupMembers_)
2770 __GEN_COUT__ << table.first <<
" v" << table.second << __E__;
2772 backboneGroupEdit.saveChanges(
2773 backboneGroupEdit.originalGroupName_,
2774 localNewBackboneKey,
2775 foundEquivalentBackboneKey ? foundEquivalentBackboneKey :
nullptr);
2778 *newBackboneKey = localNewBackboneKey;
2785 <<
"Restoring active table groups, before activating new groups..."
2788 std::string localAccumulatedWarnings;
2792 ConfigurationManager::LoadGroupType::
2794 &localAccumulatedWarnings);
2800 backboneGroupEdit.originalGroupName_,
2801 localNewBackboneKey,
2802 accumulatedWarnings ? accumulatedWarnings :
nullptr);
2811 <<
"Restoring active table groups, before activating new groups..."
2814 std::string localAccumulatedWarnings;
2818 ConfigurationManager::LoadGroupType::
2820 &localAccumulatedWarnings);
2824 if(activateNewGroup)
2827 accumulatedWarnings ? accumulatedWarnings :
nullptr);
2829 __GEN_COUT__ <<
"Changes saved." << __E__;
2838 __GEN_COUTV__(runTimeSeconds());
2840 std::string accumulatedWarningsStr;
2841 std::string* accumulatedWarnings = &accumulatedWarningsStr;
2848 std::string documentNameToLoad =
"XDAQApplicationTable";
2852 std::set<std::string> groupsContainingTable =
2853 theInterface_->findGroupsWithTable(documentNameToLoad,
2854 documentVersionToLoad);
2855 __GEN_COUT__ <<
"Groups containing " << documentNameToLoad <<
"-v"
2856 << documentVersionToLoad
2857 <<
" count: " << groupsContainingTable.size() << __E__;
2858 for(
const auto& group : groupsContainingTable)
2860 __GEN_COUT__ <<
"\t" << group << __E__;
2864 std::string debugGroupName =
"Mu2eHWEmulatorContext";
2869 theInterface_->findLatestGroupKey(debugGroupName);
2870 __GEN_COUTV__(latestGroupKey);
2872 __GEN_COUTV__(runTimeSeconds());
2879 std::set<std::string > tableGroups =
2880 theInterface_->getAllTableGroupNames();
2881 __GEN_COUT__ <<
"Number of Groups: " << tableGroups.size() << __E__;
2883 __GEN_COUTV__(runTimeSeconds());
2888 for(
const auto& fullName : tableGroups)
2891 allGroupInfo_[name].keys_.emplace(key);
2893 if(name == debugGroupName)
2898 __GEN_COUTV__(runTimeSeconds());
2900 std::set<std::string > tableNames = theInterface_->getAllTableNames();
2901 __GEN_COUT__ <<
"Number of Tables: " << tableNames.size() << __E__;
2903 __GEN_COUTV__(runTimeSeconds());
2905 for(
const auto& fullName : tableNames)
2907 if(fullName.find(debugGroupName) != std::string::npos)
2909 __GEN_COUTV__(fullName);
2912 __GEN_COUTV__(runTimeSeconds());
2914 TableGroupKey latestGroupKey = theInterface_->findLatestGroupKey(debugGroupName);
2915 __GEN_COUTV__(latestGroupKey);
2917 __GEN_COUTV__(runTimeSeconds());
2922 TableBase::GROUP_CACHE_PREPEND + debugGroupName);
2924 theInterface_->findLatestVersion(&localGroupMemberCacheSaver);
2925 __GEN_COUTV__(lastestGroupCacheKey);
2927 __GEN_COUTV__(runTimeSeconds());
2933 __GEN_COUT__ <<
"Testing group save of pre-existing " << debugGroupName <<
"("
2934 << groupKey <<
")" << __E__;
2935 std::map<std::string, TableVersion> groupMembers;
2937 theInterface_->saveTableGroup(
2943 __GEN_COUT__ <<
"Exception during group save." << __E__;
2945 __GEN_COUTV__(runTimeSeconds());
2950 std::string debugGroupName =
"testGroupSave";
2952 __GEN_COUT__ <<
"Testing group save of non-existing " << debugGroupName <<
"("
2953 << groupKey <<
")" << __E__;
2954 std::map<std::string, TableVersion> groupMembers;
2956 groupMembers[
"MessageFacilityTable"] =
TableVersion(7);
2957 theInterface_->saveTableGroup(
2963 __GEN_COUT__ <<
"Exception during new group save." << __E__;
2965 __GEN_COUTV__(runTimeSeconds());
2969 std::string documentNameToLoad =
"XDAQApplicationTable";
2972 __GEN_COUT__ <<
"Testing table save of pre-existing " << documentNameToLoad
2977 documentNameToLoad);
2978 localDocLoader.changeVersionAndActivateView(
2980 theInterface_->fill(&localDocLoader, documentVersionToLoad);
2982 localDocLoader.
print(ss);
2983 __GEN_COUTV__(ss.str());
2985 __GEN_COUTV__(runTimeSeconds());
2989 std::string documentNameToSave = documentNameToLoad;
2992 documentNameToSave);
2993 localDocSaver.changeVersionAndActivateView(
2996 std::string json =
"{ }";
2999 __COUTT__ <<
"Saving JSON string: "
3002 __COUTT__ <<
"Saving JSON doc as "
3003 << localDocSaver.getView().getTableName() <<
"("
3004 << localDocSaver.getView().getVersion().
toString() <<
")"
3008 theInterface_->saveActiveVersion(&localDocSaver,
false );
3012 __GEN_COUT__ <<
"Exception during table save." << __E__;
3014 __GEN_COUTV__(runTimeSeconds());
3018 documentNameToLoad);
3019 localDocLoader.changeVersionAndActivateView(
3021 theInterface_->fill(&localDocLoader, documentVersionToLoad);
3023 localDocLoader.
print(ss);
3024 __GEN_COUTV__(ss.str());
3026 __GEN_COUTV__(runTimeSeconds());
3028 __GEN_COUTV__(runTimeSeconds());
3032 std::string documentNameToLoad =
"MessageFacilityTable";
3035 documentNameToLoad);
3037 __GEN_COUT__ <<
"Testing table save of non-existing " << documentNameToLoad
3041 localDocLoader.changeVersionAndActivateView(
3043 theInterface_->fill(&localDocLoader, documentVersionToLoad);
3045 localDocLoader.
print(ss);
3046 __GEN_COUTV__(ss.str());
3047 __GEN_COUTV__(runTimeSeconds());
3049 __GEN_COUTV__(runTimeSeconds());
3056 theInterface_->findLatestVersion(&localDocLoader));
3057 localDocLoader.getViewP()->
setVersion(newVersion);
3059 __GEN_COUTT__ <<
"Saving new table as "
3060 << localDocLoader.getView().getTableName() <<
"("
3061 << localDocLoader.getView().getVersion().
toString() <<
")"
3065 "10.226.9.17", 0, 4);
3068 localDocLoader.
print(ss);
3069 __GEN_COUTV__(ss.str());
3072 theInterface_->saveActiveVersion(&localDocLoader,
false );
3076 __GEN_COUT__ <<
"Exception during new table save." << __E__;
3078 __GEN_COUTV__(runTimeSeconds());
3080 __GEN_COUTV__(runTimeSeconds());
3084 for(
auto& groupInfo : allGroupInfo_)
3088 groupInfo.second.latestKey_ = groupInfo.second.getLastKey();
3090 groupInfo.second.latestKey_,
3092 &groupInfo.second.latestKeyMemberMap_ ,
3095 &groupInfo.second.latestKeyGroupComment_,
3096 &groupInfo.second.latestKeyGroupAuthor_,
3097 &groupInfo.second.latestKeyGroupCreationTime_,
3099 &groupInfo.second.latestKeyGroupTypeString_);
3101 catch(
const std::runtime_error& e)
3104 <<
"Error occurred loading latest group info into cache for '"
3105 << groupInfo.first <<
"(" << groupInfo.second.latestKey_ <<
")': \n"
3106 << e.what() << __E__;
3108 groupInfo.second.latestKey_ = TableGroupKey::INVALID;
3109 groupInfo.second.latestKeyGroupComment_ =
3110 ConfigurationManager::UNKNOWN_INFO;
3111 groupInfo.second.latestKeyGroupAuthor_ =
3112 ConfigurationManager::UNKNOWN_INFO;
3113 groupInfo.second.latestKeyGroupCreationTime_ =
3114 ConfigurationManager::UNKNOWN_TIME;
3115 groupInfo.second.latestKeyGroupTypeString_ =
3116 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
3117 groupInfo.second.latestKeyMemberMap_ = {};
3122 <<
"Error occurred loading latest group info into cache for '"
3123 << groupInfo.first <<
"(" << groupInfo.second.latestKey_ <<
")'..."
3126 groupInfo.second.latestKey_ = TableGroupKey::INVALID;
3127 groupInfo.second.latestKeyGroupComment_ =
3128 ConfigurationManager::UNKNOWN_INFO;
3129 groupInfo.second.latestKeyGroupAuthor_ =
3130 ConfigurationManager::UNKNOWN_INFO;
3131 groupInfo.second.latestKeyGroupCreationTime_ =
3132 ConfigurationManager::UNKNOWN_TIME;
3133 groupInfo.second.latestKeyGroupTypeString_ =
3134 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
3135 groupInfo.second.latestKeyMemberMap_ = {};
3138 __GEN_COUTV__(runTimeSeconds());
3140 catch(
const std::runtime_error& e)
3142 __SS__ <<
"A fatal error occurred reading the info for all table groups. Error: "
3143 << e.what() << __E__;
3144 __GEN_COUT_ERR__ <<
"\n" << ss.str();
3145 if(accumulatedWarnings)
3146 *accumulatedWarnings += ss.str();
3152 __SS__ <<
"An unknown fatal error occurred reading the info for all table groups."
3154 __GEN_COUT_ERR__ <<
"\n" << ss.str();
3155 if(accumulatedWarnings)
3156 *accumulatedWarnings += ss.str();
3161 __GEN_COUT__ <<
"testXDAQContext() end runTimeSeconds()=" << runTimeSeconds()
3167 __GEN_COUT__ <<
"Loading table..." << __E__;
3173 __GEN_COUT__ << __E__;
3175 __GEN_COUT__ <<
"Value: " << v << __E__;
3176 __GEN_COUT__ <<
"Value index: " << t.
getValue<
int>() << __E__;
3182 __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())
TableBase * getVersionedTableByName(const std::string &tableName, TableVersion version, bool looseColumnMatching=false, std::string *accumulatedErrors=0, bool getRawData=false)
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
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)
ConfigurationTree getNode(const std::string &nodeString, bool doNotThrowOnBrokenUIDLinks=false) const
"root/parent/parent/"
void init(std::string *accumulatedErrors=0, bool initForWriteAccess=false, std::string *accumulatedWarnings=0)
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.
int fillFromJSON(const std::string &json)
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)