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 = getContextMemberNames();
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__ <<
"\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)
1234 ConfigurationManager::saveGroupNameAndKey(activatedGroup,
1235 LAST_ACTIVATED_CONFIG_GROUP_FILE);
1236 else if(theContextTableGroupKey_ && theContextTableGroup_ == tableGroupName &&
1237 *theContextTableGroupKey_ == tableGroupKey)
1238 ConfigurationManager::saveGroupNameAndKey(activatedGroup,
1239 LAST_ACTIVATED_CONTEXT_GROUP_FILE);
1240 else if(theBackboneTableGroupKey_ && theBackboneTableGroup_ == tableGroupName &&
1241 *theBackboneTableGroupKey_ == tableGroupKey)
1242 ConfigurationManager::saveGroupNameAndKey(activatedGroup,
1243 LAST_ACTIVATED_BACKBONE_GROUP_FILE);
1244 else if(theIterateTableGroupKey_ && theIterateTableGroup_ == tableGroupName &&
1245 *theIterateTableGroupKey_ == tableGroupKey)
1246 ConfigurationManager::saveGroupNameAndKey(activatedGroup,
1247 LAST_ACTIVATED_ITERATOR_GROUP_FILE);
1259 __GEN_COUT_INFO__ <<
"Creating temporary backbone view from version "
1260 << sourceViewVersion << __E__;
1266 auto backboneMemberNames = ConfigurationManager::getBackboneMemberNames();
1267 for(
auto& name : backboneMemberNames)
1271 if(retTmpVersion < tmpVersion)
1272 tmpVersion = retTmpVersion;
1275 __GEN_COUT__ <<
"Common temporary backbone version found as " << tmpVersion << __E__;
1278 for(
auto& name : backboneMemberNames)
1282 if(retTmpVersion != tmpVersion)
1284 __SS__ <<
"Failure! Temporary view requested was " << tmpVersion
1285 <<
". Mismatched temporary view created: " << retTmpVersion << __E__;
1286 __GEN_COUT_ERR__ << ss.str();
1295 TableBase* ConfigurationManagerRW::getTableByName(
const std::string& tableName)
1297 if(nameToTableMap_.find(tableName) == nameToTableMap_.end())
1299 if(tableName == ConfigurationManager::ARTDAQ_TOP_TABLE_NAME)
1302 <<
"Since target table was the artdaq top configuration level, "
1303 "attempting to help user by appending to core tables file: "
1304 << CORE_TABLE_INFO_FILENAME << __E__;
1305 FILE* fp = fopen((CORE_TABLE_INFO_FILENAME).c_str(),
"a");
1308 fprintf(fp,
"\nARTDAQ/*");
1313 __SS__ <<
"Table not found with name: " << tableName << __E__;
1315 if((f = tableName.find(
' ')) != std::string::npos)
1316 ss <<
"There was a space character found in the table name needle at "
1318 << f <<
" in the string (was this intended?). " << __E__;
1320 ss <<
"\nIf you think this table should exist in the core set of tables, try "
1321 "running 'UpdateOTS.sh --tables' to update your tables, then relaunch ots."
1323 ss <<
"\nTables must be defined at path $USER_DATA/TableInfo/ to exist in ots. "
1324 "Please verify your table definitions, and then restart ots."
1326 __GEN_COUT_ERR__ <<
"\n" << ss.str();
1329 return nameToTableMap_[tableName];
1338 const std::string& tableName,
1340 bool looseColumnMatching ,
1341 std::string* accumulatedErrors ,
1344 auto it = nameToTableMap_.find(tableName);
1345 if(it == nameToTableMap_.end())
1347 __SS__ <<
"\nCan not find table named '" << tableName
1348 <<
"'\n\n\n\nYou need to load the table before it can be used."
1349 <<
"It probably is missing from the member list of the Table "
1350 "Group that was loaded?\n\n\n\n\n"
1358 table->setActiveView(version);
1362 std::stringstream jsonSs;
1363 table->getViewP()->printJSON(jsonSs);
1364 table->getViewP()->doGetSourceRawData(
true);
1370 theInterface_->get(table,
1377 looseColumnMatching,
1395 TableBase* table = getTableByName(tableName);
1400 newVersion = theInterface_->saveNewVersion(table, temporaryVersion);
1402 table->setActiveView(newVersion);
1406 allTableInfo_[tableName].versions_.find(newVersion) !=
1407 allTableInfo_[tableName].versions_.end())
1410 <<
"What happenened!?? ERROR::: new persistent version v" << newVersion
1411 <<
" already exists!? How is it possible? Retrace your steps and "
1419 newVersion = temporaryVersion;
1423 __GEN_COUT_WARN__ <<
"Attempting to recover and use v" << newVersion << __E__;
1427 theInterface_->saveNewVersion(table, temporaryVersion, newVersion);
1429 table->setActiveView(newVersion);
1434 __SS__ <<
"Something went wrong saving the new version v" << newVersion
1435 <<
". What happened?! (duplicates? database error?)" << __E__;
1436 __GEN_COUT_ERR__ <<
"\n" << ss.str();
1441 allTableInfo_[tableName].versions_.insert(newVersion);
1455 TableBase* table = getTableByName(tableName);
1460 if(allTableInfo_.find(tableName) == allTableInfo_.end())
1467 for(
auto it = allTableInfo_[tableName].versions_.begin();
1468 it != allTableInfo_[tableName].versions_.end();
1471 if(it->isTemporaryVersion())
1473 __GEN_COUT__ <<
"Removing '" << tableName <<
"' version info: " << *it
1475 allTableInfo_[tableName].versions_.erase(it++);
1484 auto it = allTableInfo_[tableName].versions_.find(targetVersion);
1485 if(it == allTableInfo_[tableName].versions_.end())
1487 __GEN_COUT__ <<
"Target '" << tableName <<
"' version v" << targetVersion
1488 <<
" was not found in info versions..." << __E__;
1491 allTableInfo_[tableName].versions_.erase(
1492 allTableInfo_[tableName].versions_.find(targetVersion));
1503 TableBase* table = getTableByName(tableName);
1515 for(
auto configInfo : allTableInfo_)
1516 configInfo.second.tablePtr_->trimCache(0);
1522 const std::string& tableName,
TableVersion sourceVersion)
1524 getTableByName(tableName)->reset();
1536 allTableInfo_[tableName].versions_.insert(newTemporaryVersion);
1538 return newTemporaryVersion;
1546 const std::string& groupName,
bool attemptToReloadKeys )
1553 auto it = allGroupInfo_.find(groupName);
1554 if(it == allGroupInfo_.end())
1556 __SS__ <<
"Group name '" << groupName
1557 <<
"' not found in group info! (creating empty info)" << __E__;
1558 __GEN_COUT_WARN__ << ss.str();
1560 return allGroupInfo_[groupName];
1563 if(attemptToReloadKeys)
1565 __GEN_COUT__ <<
"Reloading keys from special db group cache if it exists..."
1568 std::set<TableGroupKey> keys;
1571 bool cacheFailed =
false;
1577 TableBase::GROUP_CACHE_PREPEND + groupName);
1578 auto versions = theInterface_->getVersions(&localGroupMemberCacheLoader);
1579 for(
const auto& version : versions)
1584 __GEN_COUT__ <<
"Ignoring cache loading error. Doing full load of keys..."
1589 if(cacheFailed && 0)
1590 keys = theInterface_->getKeys(groupName);
1594 __GEN_COUT__ <<
"Key from special db group cache were loaded." << __E__;
1595 it->second.keys_ = keys;
1614 const std::string& groupName,
1615 const std::map<std::string, TableVersion>& groupMemberMap,
1616 const std::map<std::string /*name*/, std::string /*alias*/>& memberTableAliases)
1622 std::set<TableGroupKey> keys;
1625 bool cacheFailed =
false;
1631 TableBase::GROUP_CACHE_PREPEND + groupName);
1632 auto versions = theInterface_->getVersions(&localGroupMemberCacheLoader);
1633 for(
const auto& version : versions)
1638 __COUT__ <<
"Ignoring cache loading error. Doing full load of keys..."
1644 keys = theInterface_->getKeys(groupName);
1649 const unsigned int MAX_DEPTH_TO_CHECK = 20;
1650 unsigned int keyMinToCheck = 0;
1653 keyMinToCheck = keys.rbegin()->key();
1654 if(keyMinToCheck > MAX_DEPTH_TO_CHECK)
1656 keyMinToCheck -= MAX_DEPTH_TO_CHECK;
1657 __GEN_COUT__ <<
"Checking groups back to key... " << keyMinToCheck << __E__;
1662 __GEN_COUT__ <<
"Checking all groups." << __E__;
1670 __GEN_COUT__ <<
" PROCESSOR_COUNT " <<
PROCESSOR_COUNT <<
" ==> " << numOfThreads
1671 <<
" threads." << __E__;
1672 if(numOfThreads < 2)
1674 std::map<std::string ,
TableVersion > compareToMemberMap;
1675 std::map<std::string , std::string > compareToMemberTableAliases;
1676 std::map<std::string , std::string >*
1677 compareToMemberTableAliasesPtr =
nullptr;
1678 if(memberTableAliases.size())
1679 compareToMemberTableAliasesPtr = &compareToMemberTableAliases;
1682 for(
const auto& key : keys)
1684 if(key.key() < keyMinToCheck)
1690 &compareToMemberMap ,
1698 compareToMemberTableAliasesPtr);
1700 isDifferent =
false;
1701 for(
auto& memberPair : groupMemberMap)
1703 if(memberTableAliases.find(memberPair.first) != memberTableAliases.end())
1706 if(compareToMemberTableAliases.find(memberPair.first) ==
1707 compareToMemberTableAliases.end() ||
1708 memberTableAliases.at(memberPair.first) !=
1709 compareToMemberTableAliases.at(memberPair.first))
1717 else if(compareToMemberTableAliases.find(memberPair.first) !=
1718 compareToMemberTableAliases.end())
1725 else if(compareToMemberMap.find(memberPair.first) ==
1726 compareToMemberMap.end() ||
1727 memberPair.second !=
1728 compareToMemberMap.at(
1740 if(groupMemberMap.size() != compareToMemberMap.size())
1744 __GEN_COUT__ <<
"Found exact match with key: " << key << __E__;
1748 __GEN_COUT__ <<
"No match found - this group is new!" << __E__;
1754 int threadsLaunched = 0;
1755 int foundThreadIndex = 0;
1756 std::atomic<bool> foundIdentical =
false;
1758 std::mutex threadMutex;
1760 std::vector<std::shared_ptr<std::atomic<bool>>> threadDone;
1761 for(
int i = 0; i < numOfThreads; ++i)
1762 threadDone.push_back(std::make_shared<std::atomic<bool>>(
true));
1764 for(
const auto& key : keys)
1768 if(key.key() < keyMinToCheck)
1771 if(threadsLaunched >= numOfThreads)
1774 foundThreadIndex = -1;
1775 while(foundThreadIndex == -1)
1780 for(
int i = 0; i < numOfThreads; ++i)
1781 if(*(threadDone[i]))
1783 foundThreadIndex = i;
1786 if(foundThreadIndex == -1)
1788 __GEN_COUTT__ <<
"Waiting for available thread..." << __E__;
1792 threadsLaunched = numOfThreads - 1;
1797 __GEN_COUTT__ <<
"Starting thread... " << foundThreadIndex << __E__;
1798 *(threadDone[foundThreadIndex]) =
false;
1802 std::string theGroupName,
1804 const std::map<std::string, TableVersion>& groupMemberMap,
1805 const std::map<std::string /*name*/, std::string /*alias*/>&
1807 std::atomic<bool>* theFoundIdentical,
1809 std::mutex* theThreadMutex,
1810 std::shared_ptr<std::atomic<bool>> theThreadDone) {
1829 threadDone[foundThreadIndex])
1839 foundThreadIndex = -1;
1840 for(
int i = 0; i < numOfThreads; ++i)
1841 if(!*(threadDone[i]))
1843 foundThreadIndex = i;
1846 if(foundThreadIndex != -1)
1848 __GEN_COUTT__ <<
"Waiting for thread to finish... " << foundThreadIndex
1852 }
while(foundThreadIndex != -1);
1856 __GEN_COUT__ <<
"Found exact match with key: " << identicalKey << __E__;
1857 return identicalKey;
1874 return &groupMetadataTable_;
1878 std::lock_guard<std::mutex> lock(metaDataTableMutex_);
1881 while(groupMetadataTable_.getView().getNumberOfRows())
1882 groupMetadataTable_.getViewP()->deleteRow(0);
1887 theInterface_->fill(&groupMetadataTable_, fillVersion);
1889 catch(
const std::runtime_error& e)
1891 __GEN_COUT_WARN__ <<
"Failed to load " << groupMetadataTable_.getTableName()
1892 <<
"-v" << fillVersion <<
". Metadata error: " << e.what()
1897 __GEN_COUT_WARN__ <<
"Failed to load " << groupMetadataTable_.getTableName()
1898 <<
"-v" << fillVersion <<
". Ignoring unknown metadata error. "
1903 if(groupMetadataTable_.getView().getNumberOfRows() != 1)
1905 groupMetadataTable_.print();
1906 __GEN_COUT_ERR__ <<
"Ignoring that groupMetadataTable_ v" << fillVersion
1908 "number of rows!' Must "
1909 "be 1. Going with anonymous defaults."
1913 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
1914 groupMetadataTable_.getViewP()->deleteRow(0);
1915 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
1916 groupMetadataTable_.getViewP()->addRow();
1919 return &groupMetadataTable_;
1930 const std::string& groupName,
1931 std::map<std::string, TableVersion>& groupMembers,
1932 const std::string& groupComment,
1933 std::map<std::string /*table*/, std::string /*alias*/>* groupAliases)
1941 if(groupMembers.size() == 0)
1943 __SS__ <<
"Empty group member list. Can not create a group without members!"
1948 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
1953 for(
auto& memberPair : groupMembers)
1956 if(allCfgInfo.find(memberPair.first) == allCfgInfo.end())
1958 __GEN_COUT_ERR__ <<
"Group member \"" << memberPair.first
1959 <<
"\" not found in database!";
1961 if(groupMetadataTable_.getTableName() == memberPair.first)
1964 <<
"Looks like this is the groupMetadataTable_ '"
1965 << TableBase::GROUP_METADATA_TABLE_NAME
1966 <<
".' Note that this table is added to the member map when groups "
1968 <<
"It should not be part of member map when calling this function."
1970 __GEN_COUT__ <<
"Attempting to recover." << __E__;
1971 groupMembers.erase(groupMembers.find(memberPair.first));
1975 __SS__ << (
"Group member not found!") << __E__;
1980 if(allCfgInfo[memberPair.first].versions_.find(memberPair.second) ==
1981 allCfgInfo[memberPair.first].versions_.end())
1983 __SS__ <<
"Group member \"" << memberPair.first <<
"\" version \""
1984 << memberPair.second <<
"\" not found in database!";
1989 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
1994 for(
auto& aliasPair : *groupAliases)
1997 if(groupMembers.find(aliasPair.first) == groupMembers.end())
1999 __GEN_COUT_ERR__ <<
"Group member \"" << aliasPair.first
2000 <<
"\" not found in group member map!";
2002 __SS__ << (
"Alias table not found in member list!") << __E__;
2010 __GEN_COUT__ <<
"New Key for group: " << groupName <<
" found as " << newKey << __E__;
2011 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2013 time_t groupCreationTime = time(0);
2016 std::map<std::string ,
TableVersion > groupMembersWithoutMeta =
2023 std::string groupAliasesString =
"";
2026 *groupAliases,
"," ,
":" );
2027 __GEN_COUT__ <<
"Metadata: " << username_ <<
" " << groupCreationTime <<
" "
2028 << groupComment <<
" " << groupAliasesString <<
" " << groupType
2033 while(groupMetadataTable_.getViewP()->getNumberOfRows() > 1)
2034 groupMetadataTable_.getViewP()->deleteRow(0);
2035 if(groupMetadataTable_.getViewP()->getNumberOfRows() == 0)
2036 groupMetadataTable_.getViewP()->addRow();
2039 groupMetadataTable_.getViewP()->setValue(
2040 groupAliasesString, 0, ConfigurationManager::METADATA_COL_ALIASES);
2041 groupMetadataTable_.getViewP()->setValue(
2042 groupComment, 0, ConfigurationManager::METADATA_COL_COMMENT);
2043 groupMetadataTable_.getViewP()->setValue(
2044 username_, 0, ConfigurationManager::METADATA_COL_AUTHOR);
2045 groupMetadataTable_.getViewP()->setValue(
2046 groupCreationTime, 0, ConfigurationManager::METADATA_COL_TIMESTAMP);
2050 std::stringstream ss;
2051 groupMetadataTable_.print(ss);
2052 __COUT_MULTI__(2, ss.str());
2059 theInterface_->findLatestVersion(&groupMetadataTable_));
2060 groupMetadataTable_.getViewP()->setVersion(newVersion);
2062 uint16_t retries = 0;
2067 theInterface_->saveActiveVersion(&groupMetadataTable_);
2069 catch(
const std::runtime_error& e)
2071 __GEN_COUT__ <<
"Caught runtime_error exception during table save."
2073 if(std::string(e.what()).find(
"there was a collision") !=
2077 <<
"There was a collision saving the new table "
2078 << groupMetadataTable_ <<
"(" << newVersion
2079 <<
"), trying incremented table version... retries="
2080 << retries << __E__;
2085 groupMetadataTable_.getViewP()->setVersion(newVersion);
2086 __GEN_COUT__ <<
"New version for table: " << groupMetadataTable_
2087 <<
" found as " << newVersion << __E__;
2094 __GEN_COUT__ <<
"Created table: " << groupMetadataTable_ <<
"-v"
2095 << newVersion << __E__;
2100 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2104 groupMembers[groupMetadataTable_.getTableName()] =
2105 groupMetadataTable_.getViewVersion();
2109 uint16_t retries = 0;
2112 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2117 theInterface_->saveTableGroup(
2121 catch(
const std::runtime_error& e)
2123 __GEN_COUT__ <<
"Caught runtime_error exception during group save."
2125 if(std::string(e.what()).find(
"there was a collision") !=
2129 <<
"There was a collision saving the new group " << groupName
2131 <<
"), trying incremented group key... retries=" << retries
2136 __GEN_COUT__ <<
"New Key for group: " << groupName <<
" found as "
2144 __GEN_COUT__ <<
"Created table group: " << groupName <<
"(" << newKey
2150 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds()
2153 catch(std::runtime_error& e)
2155 __GEN_COUT_ERR__ <<
"Failed to create table group: " << groupName <<
"(" << newKey
2157 __GEN_COUT_ERR__ <<
"\n\n" << e.what() << __E__;
2162 __GEN_COUT_ERR__ <<
"Failed to create table group: " << groupName <<
":" << newKey
2167 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2170 allGroupInfo_[groupName].keys_.emplace(newKey);
2172 allGroupInfo_.at(groupName).latestKey_ = newKey;
2173 allGroupInfo_.at(groupName).latestKeyGroupAuthor_ = username_;
2174 allGroupInfo_.at(groupName).latestKeyGroupComment_ = groupComment;
2175 allGroupInfo_.at(groupName).latestKeyGroupCreationTime_ = groupCreationTime;
2176 allGroupInfo_.at(groupName).latestKeyGroupTypeString_ = groupType;
2177 allGroupInfo_.at(groupName).latestKeyMemberMap_ = groupMembersWithoutMeta;
2179 __GEN_COUT__ <<
"Saved " << groupName <<
"(" << newKey <<
") of type " << groupType
2182 __GEN_COUTT__ <<
"saveNewTableGroup runTimeSeconds()=" << runTimeSeconds() << __E__;
2194 __GEN_COUT_INFO__ <<
"Creating new backbone from temporary version "
2195 << temporaryVersion << __E__;
2200 auto backboneMemberNames = ConfigurationManager::getBackboneMemberNames();
2201 for(
auto& name : backboneMemberNames)
2204 __GEN_COUT__ <<
"New version for backbone member (" << name
2205 <<
"): " << retNewVersion << __E__;
2206 if(retNewVersion > newVersion)
2207 newVersion = retNewVersion;
2210 __GEN_COUT__ <<
"Common new backbone version found as " << newVersion << __E__;
2213 for(
auto& name : backboneMemberNames)
2217 getTableByName(name), temporaryVersion, newVersion);
2218 if(retNewVersion != newVersion)
2220 __SS__ <<
"Failure! New view requested was " << newVersion
2221 <<
". Mismatched new view created: " << retNewVersion << __E__;
2222 __GEN_COUT_ERR__ << ss.str();
2236 const std::string& tableName,
2241 bool ignoreDuplicates ,
2242 bool lookForEquivalent ,
2243 bool* foundEquivalent )
2245 bool needToEraseTemporarySource =
2249 *foundEquivalent =
false;
2252 if(!ignoreDuplicates)
2254 __GEN_COUT__ <<
"Checking for duplicate '" << tableName <<
"' tables..." << __E__;
2262 const std::map<std::string, TableInfo>& allTableInfo =
2265 auto versionReverseIterator =
2266 allTableInfo.at(tableName).versions_.rbegin();
2267 __GEN_COUT__ <<
"Filling up '" << tableName <<
"' cache from "
2271 versionReverseIterator != allTableInfo.at(tableName).versions_.rend();
2272 ++versionReverseIterator)
2274 __GEN_COUTT__ <<
"'" << tableName <<
"' versions in reverse order "
2275 << *versionReverseIterator << __E__;
2279 *versionReverseIterator);
2281 catch(
const std::runtime_error& e)
2284 __COUTT__ <<
"'" << tableName
2285 <<
"' version failed to load: " << *versionReverseIterator
2291 __GEN_COUT__ <<
"Checking '" << tableName <<
"' for duplicate..." << __E__;
2294 temporaryModifiedVersion,
2300 if(lookForEquivalent && !duplicateVersion.
isInvalid())
2303 __GEN_COUT__ <<
"Equivalent '" << tableName <<
"' table found in version v"
2304 << duplicateVersion << __E__;
2309 __GEN_COUT__ <<
"Need persistent. Duplicate '" << tableName
2310 <<
"' version was temporary. "
2311 "Abandoning duplicate."
2323 if(needToEraseTemporarySource)
2327 *foundEquivalent =
true;
2329 __GEN_COUT__ <<
"\t\t Equivalent '" << tableName
2330 <<
"' assigned version: " << duplicateVersion << __E__;
2332 return duplicateVersion;
2338 __SS__ <<
"This version of table '" << tableName
2339 <<
"' is identical to another version currently cached v"
2340 << duplicateVersion <<
". No reason to save a duplicate." << __E__;
2341 __GEN_COUT_ERR__ <<
"\n" << ss.str();
2344 table->eraseView(temporaryModifiedVersion);
2348 __GEN_COUT__ <<
"Check for duplicate '" << tableName <<
"' tables complete."
2353 __GEN_COUT__ <<
"\t\t**************************** Save as temporary '"
2354 << tableName <<
"' table version" << __E__;
2356 __GEN_COUT__ <<
"\t\t**************************** Save as new '" << tableName
2357 <<
"' table version" << __E__;
2360 saveNewTable(tableName, temporaryModifiedVersion, makeTemporary);
2362 __GEN_COUTTV__(table->getView().getComment());
2364 if(needToEraseTemporarySource)
2367 __GEN_COUT__ <<
"\t\t '" << tableName
2368 <<
"' new assigned version: " << newAssignedVersion << __E__;
2369 return newAssignedVersion;
2373 GroupEditStruct::GroupEditStruct(
const ConfigurationManager::GroupType& groupType,
2375 : groupType_(groupType)
2376 , originalGroupName_(cfgMgr->getActiveGroupName(groupType))
2377 , originalGroupKey_(cfgMgr->getActiveGroupKey(groupType))
2379 , mfSubject_(cfgMgr->getUsername())
2381 if(originalGroupName_ ==
"" || originalGroupKey_.isInvalid())
2383 __SS__ <<
"Error! No active group found for type '"
2385 <<
".' There must be an active group to edit the group." << __E__ << __E__
2390 __GEN_COUT__ <<
"Extracting Group-Edit Struct for type "
2395 const std::set<std::string>& memberNames =
2396 groupType == ConfigurationManager::GroupType::CONTEXT_TYPE
2397 ? ConfigurationManager::getContextMemberNames()
2402 : cfgMgr->getConfigurationMemberNames()));
2404 for(
auto& memberName : memberNames)
2407 groupMembers_.emplace(
2408 std::make_pair(memberName, activeTables.at(memberName)));
2409 groupTables_.emplace(std::make_pair(
2416 __SS__ <<
"Error! Could not find group member table '" << memberName
2417 <<
"' for group type '"
2419 <<
".' All group members must be present to create the group editing "
2428 GroupEditStruct::~GroupEditStruct()
2430 __GEN_COUT__ <<
"GroupEditStruct from editing '" << originalGroupName_ <<
"("
2431 << originalGroupKey_ <<
")' Destructing..." << __E__;
2433 __GEN_COUT__ <<
"GroupEditStruct from editing '" << originalGroupName_ <<
"("
2434 << originalGroupKey_ <<
")' Desctructed." << __E__;
2442 auto it = groupTables_.find(tableName);
2443 if(it == groupTables_.end())
2445 if(groupType_ == ConfigurationManager::GroupType::CONFIGURATION_TYPE &&
2448 __GEN_COUT__ <<
"Table '" << tableName
2449 <<
"' not found in configuration table members from editing '"
2450 << originalGroupName_ <<
"(" << originalGroupKey_ <<
")..."
2451 <<
" Attempting to add it!" << __E__;
2454 auto newIt = groupTables_.emplace(std::make_pair(
2459 newIt.first->second.modified_ =
2461 groupMembers_.emplace(
2462 std::make_pair(tableName, newIt.first->second.temporaryVersion_));
2463 return newIt.first->second;
2465 __GEN_COUT_ERR__ <<
"Failed to emplace new table..." << __E__;
2468 __SS__ <<
"Table '" << tableName <<
"' not found in table members from editing '"
2469 << originalGroupName_ <<
"(" << originalGroupKey_ <<
")!'" << __E__;
2472 it->second.modified_ =
2478 void GroupEditStruct::dropChanges()
2480 __GEN_COUT__ <<
"Dropping unsaved changes from editing '" << originalGroupName_ <<
"("
2481 << originalGroupKey_ <<
")'..." << __E__;
2486 for(
auto& groupTable : groupTables_)
2487 if(groupTable.second
2488 .createdTemporaryVersion_)
2492 groupTable.second.temporaryVersion_);
2493 groupTable.second.createdTemporaryVersion_ =
false;
2494 groupTable.second.modified_ =
false;
2497 __GEN_COUT__ <<
"Unsaved changes dropped from editing '" << originalGroupName_ <<
"("
2498 << originalGroupKey_ <<
").'" << __E__;
2502 void GroupEditStruct::saveChanges(
const std::string& groupNameToSave,
2504 bool* foundEquivalentGroupKey ,
2505 bool activateNewGroup ,
2506 bool updateGroupAliases ,
2507 bool updateTableAliases ,
2509 bool* foundEquivalentBackboneKey ,
2510 std::string* accumulatedWarnings )
2512 __GEN_COUT__ <<
"Saving changes..." << __E__;
2517 if(foundEquivalentBackboneKey)
2518 *foundEquivalentBackboneKey =
false;
2522 bool anyTableNew =
false;
2523 for(
auto& groupTable : groupTables_)
2525 if(!groupTable.second.modified_)
2528 __GEN_COUT__ <<
"Original version is " << groupTable.second.tableName_ <<
"-v"
2529 << groupTable.second.originalVersion_ << __E__;
2532 groupTable.second.tableName_,
2533 groupTable.second.originalVersion_,
2535 groupTable.second.table_,
2536 groupTable.second.temporaryVersion_,
2539 __GEN_COUT__ <<
"Temporary target version is " << groupTable.second.tableName_
2540 <<
"-v" << groupMembers_.at(groupTable.first) <<
"-v"
2541 << groupTable.second.temporaryVersion_ << __E__;
2544 groupTable.second.tableName_,
2545 groupTable.second.originalVersion_,
2547 groupTable.second.table_,
2548 groupTable.second.temporaryVersion_,
2552 if(groupTable.second.originalVersion_ != groupMembers_.at(groupTable.first))
2555 __GEN_COUT__ <<
"Final NEW target version is " << groupTable.second.tableName_
2556 <<
"-v" << groupMembers_.at(groupTable.first) << __E__;
2559 __GEN_COUT__ <<
"Final target version is " << groupTable.second.tableName_
2560 <<
"-v" << groupMembers_.at(groupTable.first) << __E__;
2562 groupTable.second.modified_ =
false;
2563 groupTable.second.createdTemporaryVersion_ =
false;
2566 for(
auto& table : groupMembers_)
2568 __GEN_COUT__ << table.first <<
" v" << table.second << __E__;
2573 __GEN_COUT__ <<
"Checking for duplicate groups..." << __E__;
2574 newGroupKey = cfgMgr->
findTableGroup(groupNameToSave, groupMembers_);
2577 __GEN_COUT__ <<
"New table found, so no need to check duplicate groups." << __E__;
2581 __GEN_COUT__ <<
"Found equivalent group key (" << newGroupKey <<
") for "
2582 << groupNameToSave <<
"." << __E__;
2583 if(foundEquivalentGroupKey)
2584 *foundEquivalentGroupKey =
true;
2589 __GEN_COUT__ <<
"Saved new Context group key (" << newGroupKey <<
") for "
2590 << groupNameToSave <<
"." << __E__;
2593 bool groupAliasChange =
false;
2594 bool tableAliasChange =
false;
2597 ConfigurationManager::GroupType::
2600 GroupEditStruct backboneGroupEdit(ConfigurationManager::GroupType::BACKBONE_TYPE,
2603 if(groupType_ != ConfigurationManager::GroupType::BACKBONE_TYPE &&
2609 TableEditStruct& groupAliasTable = backboneGroupEdit.getTableEditStruct(
2610 ConfigurationManager::GROUP_ALIASES_TABLE_NAME,
true );
2611 TableView* tableView = groupAliasTable.tableView_;
2614 unsigned int row = 0;
2616 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
2617 cfgMgr->
getNode(ConfigurationManager::GROUP_ALIASES_TABLE_NAME)
2619 std::string groupName, groupKey;
2620 for(
auto& aliasNodePair : aliasNodePairs)
2622 groupName = aliasNodePair.second.getNode(
"GroupName").getValueAsString();
2623 groupKey = aliasNodePair.second.getNode(
"GroupKey").getValueAsString();
2625 __GEN_COUT__ <<
"Group Alias: " << aliasNodePair.first <<
" => "
2626 << groupName <<
"(" << groupKey <<
"); row=" << row << __E__;
2628 if(groupName == originalGroupName_ &&
2631 __GEN_COUT__ <<
"Found alias! Changing group key from ("
2632 << originalGroupKey_ <<
") to (" << newGroupKey <<
")"
2635 groupAliasChange =
true;
2644 if(groupAliasChange)
2646 std::stringstream ss;
2647 tableView->print(ss);
2648 __GEN_COUT__ << ss.str();
2652 if(groupType_ != ConfigurationManager::GroupType::BACKBONE_TYPE &&
2658 .getTableEditStruct(ConfigurationManager::VERSION_ALIASES_TABLE_NAME,
2662 for(
auto& groupTable : groupTables_)
2664 if(groupTable.second.originalVersion_ ==
2665 groupMembers_.at(groupTable.second.tableName_))
2668 __GEN_COUT__ <<
"Checking alias... original version is "
2669 << groupTable.second.tableName_ <<
"-v"
2670 << groupTable.second.originalVersion_
2671 <<
" and new version is v"
2672 << groupMembers_.at(groupTable.second.tableName_) << __E__;
2675 unsigned int row = 0;
2677 std::vector<std::pair<std::string, ConfigurationTree>> aliasNodePairs =
2678 cfgMgr->
getNode(ConfigurationManager::VERSION_ALIASES_TABLE_NAME)
2680 std::string tableName, tableVersion;
2681 for(
auto& aliasNodePair : aliasNodePairs)
2684 aliasNodePair.second.getNode(
"TableName").getValueAsString();
2686 aliasNodePair.second.getNode(
"Version").getValueAsString();
2688 __GEN_COUT__ <<
"Table Alias: " << aliasNodePair.first <<
" => "
2689 << tableName <<
"-v" << tableVersion <<
"" << __E__;
2691 if(tableName == groupTable.second.tableName_ &&
2692 TableVersion(tableVersion) == groupTable.second.originalVersion_)
2694 __GEN_COUT__ <<
"Found alias! Changing icon table version alias."
2697 tableAliasChange =
true;
2700 groupMembers_.at(groupTable.second.tableName_).toString(),
2702 tableView->
findCol(
"Version"));
2709 if(tableAliasChange)
2711 std::stringstream ss;
2712 tableView->print(ss);
2713 __GEN_COUT__ << ss.str();
2719 if(groupAliasChange || tableAliasChange)
2721 for(
auto& table : backboneGroupEdit.groupMembers_)
2723 __GEN_COUT__ << table.first <<
" v" << table.second << __E__;
2725 backboneGroupEdit.saveChanges(
2726 backboneGroupEdit.originalGroupName_,
2727 localNewBackboneKey,
2728 foundEquivalentBackboneKey ? foundEquivalentBackboneKey :
nullptr);
2731 *newBackboneKey = localNewBackboneKey;
2738 <<
"Restoring active table groups, before activating new groups..."
2741 std::string localAccumulatedWarnings;
2745 ConfigurationManager::LoadGroupType::
2747 &localAccumulatedWarnings);
2753 backboneGroupEdit.originalGroupName_,
2754 localNewBackboneKey,
2755 accumulatedWarnings ? accumulatedWarnings :
nullptr);
2764 <<
"Restoring active table groups, before activating new groups..."
2767 std::string localAccumulatedWarnings;
2771 ConfigurationManager::LoadGroupType::
2773 &localAccumulatedWarnings);
2777 if(activateNewGroup)
2780 accumulatedWarnings ? accumulatedWarnings :
nullptr);
2782 __GEN_COUT__ <<
"Changes saved." << __E__;
2791 __GEN_COUTV__(runTimeSeconds());
2793 std::string accumulatedWarningsStr;
2794 std::string* accumulatedWarnings = &accumulatedWarningsStr;
2799 std::string debugGroupName =
"Mu2eHWEmulatorContext";
2804 theInterface_->findLatestGroupKey(debugGroupName);
2805 __GEN_COUTV__(latestGroupKey);
2807 __GEN_COUTV__(runTimeSeconds());
2814 std::set<std::string > tableGroups =
2815 theInterface_->getAllTableGroupNames();
2816 __GEN_COUT__ <<
"Number of Groups: " << tableGroups.size() << __E__;
2818 __GEN_COUTV__(runTimeSeconds());
2823 for(
const auto& fullName : tableGroups)
2826 allGroupInfo_[name].keys_.emplace(key);
2828 if(name == debugGroupName)
2833 __GEN_COUTV__(runTimeSeconds());
2835 std::set<std::string > tableNames = theInterface_->getAllTableNames();
2836 __GEN_COUT__ <<
"Number of Tables: " << tableNames.size() << __E__;
2838 __GEN_COUTV__(runTimeSeconds());
2840 for(
const auto& fullName : tableNames)
2842 if(fullName.find(debugGroupName) != std::string::npos)
2844 __GEN_COUTV__(fullName);
2847 __GEN_COUTV__(runTimeSeconds());
2849 TableGroupKey latestGroupKey = theInterface_->findLatestGroupKey(debugGroupName);
2850 __GEN_COUTV__(latestGroupKey);
2852 __GEN_COUTV__(runTimeSeconds());
2857 TableBase::GROUP_CACHE_PREPEND + debugGroupName);
2859 theInterface_->findLatestVersion(&localGroupMemberCacheSaver);
2860 __GEN_COUTV__(lastestGroupCacheKey);
2862 __GEN_COUTV__(runTimeSeconds());
2868 __GEN_COUT__ <<
"Testing group save of pre-existing " << debugGroupName <<
"("
2869 << groupKey <<
")" << __E__;
2870 std::map<std::string, TableVersion> groupMembers;
2872 theInterface_->saveTableGroup(
2878 __GEN_COUT__ <<
"Exception during group save." << __E__;
2880 __GEN_COUTV__(runTimeSeconds());
2885 std::string debugGroupName =
"testGroupSave";
2887 __GEN_COUT__ <<
"Testing group save of non-existing " << debugGroupName <<
"("
2888 << groupKey <<
")" << __E__;
2889 std::map<std::string, TableVersion> groupMembers;
2891 groupMembers[
"MessageFacilityTable"] =
TableVersion(7);
2892 theInterface_->saveTableGroup(
2898 __GEN_COUT__ <<
"Exception during new group save." << __E__;
2900 __GEN_COUTV__(runTimeSeconds());
2904 std::string documentNameToLoad =
"XDAQApplicationTable";
2907 __GEN_COUT__ <<
"Testing table save of pre-existing " << documentNameToLoad
2912 documentNameToLoad);
2913 localDocLoader.changeVersionAndActivateView(
2915 theInterface_->fill(&localDocLoader, documentVersionToLoad);
2917 localDocLoader.
print(ss);
2918 __GEN_COUTV__(ss.str());
2920 __GEN_COUTV__(runTimeSeconds());
2924 std::string documentNameToSave = documentNameToLoad;
2927 documentNameToSave);
2928 localDocSaver.changeVersionAndActivateView(
2931 std::string json =
"{ }";
2934 __COUTT__ <<
"Saving JSON string: "
2937 __COUTT__ <<
"Saving JSON doc as "
2938 << localDocSaver.getView().getTableName() <<
"("
2939 << localDocSaver.getView().getVersion().
toString() <<
")"
2943 theInterface_->saveActiveVersion(&localDocSaver,
false );
2947 __GEN_COUT__ <<
"Exception during table save." << __E__;
2949 __GEN_COUTV__(runTimeSeconds());
2953 documentNameToLoad);
2954 localDocLoader.changeVersionAndActivateView(
2956 theInterface_->fill(&localDocLoader, documentVersionToLoad);
2958 localDocLoader.
print(ss);
2959 __GEN_COUTV__(ss.str());
2961 __GEN_COUTV__(runTimeSeconds());
2963 __GEN_COUTV__(runTimeSeconds());
2967 std::string documentNameToLoad =
"MessageFacilityTable";
2970 documentNameToLoad);
2972 __GEN_COUT__ <<
"Testing table save of non-existing " << documentNameToLoad
2976 localDocLoader.changeVersionAndActivateView(
2978 theInterface_->fill(&localDocLoader, documentVersionToLoad);
2980 localDocLoader.
print(ss);
2981 __GEN_COUTV__(ss.str());
2982 __GEN_COUTV__(runTimeSeconds());
2984 __GEN_COUTV__(runTimeSeconds());
2991 theInterface_->findLatestVersion(&localDocLoader));
2992 localDocLoader.getViewP()->
setVersion(newVersion);
2994 __GEN_COUTT__ <<
"Saving new table as "
2995 << localDocLoader.getView().getTableName() <<
"("
2996 << localDocLoader.getView().getVersion().
toString() <<
")"
3000 "10.226.9.17", 0, 4);
3003 localDocLoader.
print(ss);
3004 __GEN_COUTV__(ss.str());
3011 __GEN_COUT__ <<
"Exception during new table save." << __E__;
3013 __GEN_COUTV__(runTimeSeconds());
3015 __GEN_COUTV__(runTimeSeconds());
3019 for(
auto& groupInfo : allGroupInfo_)
3023 groupInfo.second.latestKey_ = groupInfo.second.getLastKey();
3025 groupInfo.second.latestKey_,
3027 &groupInfo.second.latestKeyMemberMap_ ,
3030 &groupInfo.second.latestKeyGroupComment_,
3031 &groupInfo.second.latestKeyGroupAuthor_,
3032 &groupInfo.second.latestKeyGroupCreationTime_,
3034 &groupInfo.second.latestKeyGroupTypeString_);
3036 catch(
const std::runtime_error& e)
3039 <<
"Error occurred loading latest group info into cache for '"
3040 << groupInfo.first <<
"(" << groupInfo.second.latestKey_ <<
")': \n"
3041 << e.what() << __E__;
3043 groupInfo.second.latestKey_ = TableGroupKey::INVALID;
3044 groupInfo.second.latestKeyGroupComment_ =
3045 ConfigurationManager::UNKNOWN_INFO;
3046 groupInfo.second.latestKeyGroupAuthor_ =
3047 ConfigurationManager::UNKNOWN_INFO;
3048 groupInfo.second.latestKeyGroupCreationTime_ =
3049 ConfigurationManager::UNKNOWN_TIME;
3050 groupInfo.second.latestKeyGroupTypeString_ =
3051 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
3052 groupInfo.second.latestKeyMemberMap_ = {};
3057 <<
"Error occurred loading latest group info into cache for '"
3058 << groupInfo.first <<
"(" << groupInfo.second.latestKey_ <<
")'..."
3061 groupInfo.second.latestKey_ = TableGroupKey::INVALID;
3062 groupInfo.second.latestKeyGroupComment_ =
3063 ConfigurationManager::UNKNOWN_INFO;
3064 groupInfo.second.latestKeyGroupAuthor_ =
3065 ConfigurationManager::UNKNOWN_INFO;
3066 groupInfo.second.latestKeyGroupCreationTime_ =
3067 ConfigurationManager::UNKNOWN_TIME;
3068 groupInfo.second.latestKeyGroupTypeString_ =
3069 ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN;
3070 groupInfo.second.latestKeyMemberMap_ = {};
3073 __GEN_COUTV__(runTimeSeconds());
3075 catch(
const std::runtime_error& e)
3077 __SS__ <<
"A fatal error occurred reading the info for all table groups. Error: "
3078 << e.what() << __E__;
3079 __GEN_COUT_ERR__ <<
"\n" << ss.str();
3080 if(accumulatedWarnings)
3081 *accumulatedWarnings += ss.str();
3087 __SS__ <<
"An unknown fatal error occurred reading the info for all table groups."
3089 __GEN_COUT_ERR__ <<
"\n" << ss.str();
3090 if(accumulatedWarnings)
3091 *accumulatedWarnings += ss.str();
3096 __GEN_COUT__ <<
"testXDAQContext() end runTimeSeconds()=" << runTimeSeconds()
3102 __GEN_COUT__ <<
"Loading table..." << __E__;
3108 __GEN_COUT__ << __E__;
3110 __GEN_COUT__ <<
"Value: " << v << __E__;
3111 __GEN_COUT__ <<
"Value index: " << t.
getValue<
int>() << __E__;
3117 __GEN_COUT__ <<
"Failed to load table..." << __E__;
TableVersion saveNewVersion(TableBase *configuration, 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)
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)