00001 #include "otsdaq-core/ConfigurationInterface/ConfigurationManagerRW.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include<dirent.h>
00026
00027 using namespace ots;
00028
00029
00030 #undef __MF_SUBJECT__
00031 #define __MF_SUBJECT__ "ConfigurationManagerRW"
00032
00033 #define CONFIGURATION_INFO_PATH std::string(getenv("CONFIGURATION_INFO_PATH")) + "/"
00034 #define CONFIGURATION_INFO_EXT "Info.xml"
00035
00036
00037
00038 ConfigurationManagerRW::ConfigurationManagerRW(std::string username)
00039 : ConfigurationManager(username)
00040 {
00041 __MOUT__ << "Using Config Mgr with Write Access! (for " << username << ")" << std::endl;
00042
00043
00044
00045 theInterface_ = ConfigurationInterface::getInstance(false);
00046
00047 }
00048
00049
00050
00051
00052
00053
00054
00055 const std::map<std::string, ConfigurationInfo>& ConfigurationManagerRW::getAllConfigurationInfo(
00056 bool refresh, std::string *accumulatedErrors, const std::string &errorFilterName)
00057 {
00058
00059
00060 if(accumulatedErrors) *accumulatedErrors = "";
00061
00062 if(!refresh) return allConfigurationInfo_;
00063
00064
00065 allConfigurationInfo_.clear();
00066
00067 ConfigurationBase* configuration;
00068
00069
00070
00071
00072 __MOUT__ << "Extracting list of Configuration tables" << std::endl;
00073 DIR *pDIR;
00074 struct dirent *entry;
00075 std::string path = CONFIGURATION_INFO_PATH;
00076 char fileExt[] = CONFIGURATION_INFO_EXT;
00077 const unsigned char MIN_CONFIG_NAME_SZ = 3;
00078 if( (pDIR=opendir( path.c_str() )) != 0 )
00079 {
00080 while((entry = readdir(pDIR)) != 0)
00081 {
00082
00083 if(strlen(entry->d_name) < strlen(fileExt)+MIN_CONFIG_NAME_SZ)
00084 continue;
00085
00086
00087 if( strcmp(
00088 &(entry->d_name[strlen(entry->d_name) - strlen(fileExt)]),
00089 fileExt) != 0)
00090 continue;
00091
00092
00093 entry->d_name[strlen(entry->d_name) - strlen(fileExt)] = '\0';
00094
00095
00096
00097
00098 configuration = 0;
00099
00100 try
00101 {
00102 theInterface_->get(configuration,
00103 entry->d_name,
00104 0, 0,
00105 true);
00106 }
00107 catch(cet::exception)
00108 {
00109 if(configuration) delete configuration;
00110 configuration = 0;
00111
00112 __MOUT__ << "Skipping! No valid class found for... " << entry->d_name << "\n";
00113 continue;
00114 }
00115 catch(std::runtime_error &e)
00116 {
00117 if(configuration) delete configuration;
00118 configuration = 0;
00119
00120 __MOUT__ << "Skipping! No valid class found for... " << entry->d_name << "\n";
00121 __MOUT__ << "Error: " << e.what() << std::endl;
00122
00123
00124
00125
00126
00127 if(accumulatedErrors)
00128 {
00129
00130 if(errorFilterName == "" ||
00131 errorFilterName == entry->d_name)
00132 {
00133 *accumulatedErrors += std::string("\nIn table '") + entry->d_name +
00134 "'..." + e.what();
00135
00136 __SS__ << "Attempting to allow illegal columns!" << std::endl;
00137 *accumulatedErrors += ss.str();
00138 }
00139
00140
00141 __MOUT__ << "Attempting to allow illegal columns!" << std::endl;
00142
00143
00144 std::string returnedAccumulatedErrors;
00145 try
00146 {
00147
00148 configuration = new ConfigurationBase(entry->d_name, &returnedAccumulatedErrors);
00149 }
00150 catch(...)
00151 {
00152 __MOUT__ << "Skipping! Allowing illegal columns didn't work either... " <<
00153 entry->d_name << "\n";
00154 continue;
00155 }
00156 __MOUT__ << "Error (but allowed): " << returnedAccumulatedErrors << std::endl;
00157
00158 if(errorFilterName == "" ||
00159 errorFilterName == entry->d_name)
00160 *accumulatedErrors += std::string("\nIn table '") + entry->d_name +
00161 "'..." + returnedAccumulatedErrors;
00162 }
00163 else
00164 continue;
00165 }
00166
00167
00168
00169 if(nameToConfigurationMap_[entry->d_name])
00170 {
00171
00172 std::set<ConfigurationVersion> versions =
00173 nameToConfigurationMap_[entry->d_name]->getStoredVersions();
00174 for(auto &version:versions)
00175 if(version.isTemporaryVersion())
00176 {
00177 __MOUT__ << "copying tmp = " << version << std::endl;
00178
00179 try
00180 {
00181 nameToConfigurationMap_[entry->d_name]->setActiveView(version);
00182 configuration->copyView(
00183 nameToConfigurationMap_[entry->d_name]->getView(),
00184 version,
00185 username_);
00186 }
00187 catch(...)
00188 {}
00189 }
00190
00191 delete nameToConfigurationMap_[entry->d_name];
00192 nameToConfigurationMap_[entry->d_name] = 0;
00193 }
00194
00195 nameToConfigurationMap_[entry->d_name] = configuration;
00196
00197 allConfigurationInfo_[entry->d_name].configurationPtr_ = configuration;
00198 allConfigurationInfo_[entry->d_name].versions_ = theInterface_->getVersions(configuration);
00199
00200
00201
00202 std::set<ConfigurationVersion> versions =
00203 nameToConfigurationMap_[entry->d_name]->getStoredVersions();
00204 for(auto &version:versions)
00205 if(version.isTemporaryVersion())
00206 {
00207 __MOUT__ << "surviving tmp = " << version << std::endl;
00208 allConfigurationInfo_[entry->d_name].versions_.emplace(version);
00209 }
00210 }
00211 closedir(pDIR);
00212 }
00213 __MOUT__ << "Extracting list of Configuration tables complete" << std::endl;
00214
00215
00216 init(accumulatedErrors);
00217
00218 return allConfigurationInfo_;
00219 }
00220
00221
00222
00223
00224 std::map<std::string,std::map<std::string,ConfigurationVersion> >
00225 ConfigurationManagerRW::getActiveVersionAliases(void) const
00226 {
00227 __MOUT__ << "getActiveVersionAliases()" << std::endl;
00228 std::map<std::string,std::map<std::string,ConfigurationVersion> > retMap;
00229
00230 std::map<std::string, ConfigurationVersion> activeVersions = getActiveVersions();
00231 std::string versionAliasesTableName = "VersionAliasesConfiguration";
00232 if(activeVersions.find(versionAliasesTableName) == activeVersions.end())
00233 {
00234 __SS__ << "Active version of VersionAliases missing!" <<
00235 "Make sure you have a valid active Backbone Group." << std::endl;
00236 __MOUT_WARN__ << "\n" << ss.str();
00237 return retMap;
00238 }
00239
00240 __MOUT__ << "activeVersions[\"VersionAliasesConfiguration\"]=" <<
00241 activeVersions[versionAliasesTableName] << std::endl;
00242
00243
00244 if(!ConfigurationInterface::isVersionTrackingEnabled())
00245 for(const auto &tableInfo:allConfigurationInfo_)
00246 for(const auto &version:tableInfo.second.versions_)
00247 if(version.isScratchVersion())
00248 retMap[tableInfo.first][ConfigurationManager::SCRATCH_VERSION_ALIAS] =
00249 ConfigurationVersion(ConfigurationVersion::SCRATCH);
00250
00251 std::vector<std::pair<std::string,ConfigurationTree> > aliasNodePairs =
00252 getNode(versionAliasesTableName).getChildren();
00253
00254
00255
00256
00257 std::string configName, versionAlias;
00258 for(auto& aliasNodePair:aliasNodePairs)
00259 {
00260 configName = aliasNodePair.second.getNode(
00261 "ConfigurationName").getValueAsString();
00262 versionAlias = aliasNodePair.second.getNode(
00263 "VersionAlias").getValueAsString();
00264
00265 if(retMap.find(configName) != retMap.end() &&
00266 retMap[configName].find(versionAlias) != retMap[configName].end())
00267 continue;
00268
00269
00270 retMap[configName][versionAlias] = ConfigurationVersion(
00271 aliasNodePair.second.getNode("Version").getValueAsString());
00272 }
00273
00274 return retMap;
00275 }
00276
00277
00278
00279
00280
00281 void ConfigurationManagerRW::activateConfigurationGroup(const std::string &configGroupName,
00282 ConfigurationGroupKey configGroupKey, std::string *accumulatedTreeErrors)
00283 {
00284 loadConfigurationGroup(configGroupName,configGroupKey,
00285 true,
00286 0,
00287 accumulatedTreeErrors);
00288
00289 if(accumulatedTreeErrors &&
00290 *accumulatedTreeErrors != "")
00291 {
00292 __MOUT_ERR__ << "Errors were accumulated so de-activating group: " <<
00293 configGroupName << " (" << configGroupKey << ")" << std::endl;
00294 try
00295 { destroyConfigurationGroup(configGroupName,true); }
00296 catch(...){}
00297 }
00298
00299 __MOUT_INFO__ << "Updating persistent active groups to " <<
00300 ConfigurationManager::ACTIVE_GROUP_FILENAME << " ..." << std::endl;
00301
00302 std::string fn = ConfigurationManager::ACTIVE_GROUP_FILENAME;
00303 FILE *fp = fopen(fn.c_str(),"w");
00304 if(!fp)
00305 {
00306 __SS__ << "Fatal Error! Unable to open the file " <<
00307 ConfigurationManager::ACTIVE_GROUP_FILENAME << " for editing! Is there a permissions problem?" << std::endl;
00308 __MOUT_ERR__ << ss.str();
00309 throw std::runtime_error(ss.str());
00310 return;
00311 }
00312
00313 __MOUT__ << theContextGroup_ << "(" <<
00314 (theContextGroupKey_?theContextGroupKey_->toString().c_str():"-1") << ")" << std::endl;
00315 __MOUT__ << theBackboneGroup_ << "(" <<
00316 (theBackboneGroupKey_?theBackboneGroupKey_->toString().c_str():"-1") << ")" << std::endl;
00317 __MOUT__ << theConfigurationGroup_ << "(" <<
00318 (theConfigurationGroupKey_?theConfigurationGroupKey_->toString().c_str():"-1") << ")" << std::endl;
00319
00320 fprintf(fp,"%s\n",theContextGroup_.c_str());
00321 fprintf(fp,"%s\n",theContextGroupKey_?theContextGroupKey_->toString().c_str():"-1");
00322 fprintf(fp,"%s\n",theBackboneGroup_.c_str());
00323 fprintf(fp,"%s\n",theBackboneGroupKey_?theBackboneGroupKey_->toString().c_str():"-1");
00324 fprintf(fp,"%s\n",theConfigurationGroup_.c_str());
00325 fprintf(fp,"%s\n",theConfigurationGroupKey_?theConfigurationGroupKey_->toString().c_str():"-1");
00326 fclose(fp);
00327 }
00328
00329
00330
00331
00332
00333 ConfigurationVersion ConfigurationManagerRW::createTemporaryBackboneView(ConfigurationVersion sourceViewVersion)
00334 {
00335 __MOUT_INFO__ << "Creating temporary backbone view from version " <<
00336 sourceViewVersion << std::endl;
00337
00338
00339 ConfigurationVersion tmpVersion = ConfigurationVersion::getNextTemporaryVersion();
00340 ConfigurationVersion retTmpVersion;
00341 auto backboneMemberNames = ConfigurationManager::getBackboneMemberNames();
00342 for (auto& name : backboneMemberNames)
00343 {
00344 retTmpVersion = ConfigurationManager::getConfigurationByName(name)->getNextTemporaryVersion();
00345 if(retTmpVersion < tmpVersion)
00346 tmpVersion = retTmpVersion;
00347 }
00348
00349 __MOUT__ << "Common temporary backbone version found as " <<
00350 tmpVersion << std::endl;
00351
00352
00353 for (auto& name : backboneMemberNames)
00354 {
00355 retTmpVersion = getConfigurationByName(name)->createTemporaryView(sourceViewVersion, tmpVersion);
00356 if(retTmpVersion != tmpVersion)
00357 {
00358 __MOUT_ERR__ << "Failure! Temporary view requested was " <<
00359 tmpVersion << ". Mismatched temporary view created: " << retTmpVersion << std::endl;
00360 throw std::runtime_error("Mismatched temporary view created!");
00361 }
00362 }
00363
00364 return tmpVersion;
00365 }
00366
00367
00368
00369
00370 ConfigurationBase* ConfigurationManagerRW::getConfigurationByName(const std::string &configurationName)
00371 {
00372 if(nameToConfigurationMap_.find(configurationName) == nameToConfigurationMap_.end())
00373 {
00374 __SS__ << "\nConfiguration not found with name: " << configurationName << std::endl;
00375 __MOUT_ERR__ << "\n" << ss.str();
00376 throw std::runtime_error(ss.str());
00377 }
00378 return nameToConfigurationMap_[configurationName];
00379 }
00380
00381
00382
00383
00384
00385
00386 ConfigurationBase* ConfigurationManagerRW::getVersionedConfigurationByName(const std::string &configurationName,
00387 ConfigurationVersion version, bool looseColumnMatching)
00388 {
00389 auto it = nameToConfigurationMap_.find(configurationName);
00390 if(it == nameToConfigurationMap_.end())
00391 {
00392 __SS__ << "\nCan not find configuration named '" <<
00393 configurationName <<
00394 "'\n\n\n\nYou need to load the configuration before it can be used." <<
00395 "It probably is missing from the member list of the Configuration Group that was loaded?\n\n\n\n\n"
00396 << std::endl;
00397 throw std::runtime_error(ss.str());
00398 }
00399 ConfigurationBase* configuration = it->second;
00400 theInterface_->get(configuration, configurationName, 0 , 0,
00401 false,
00402 version,
00403 false,
00404 looseColumnMatching);
00405 return configuration;
00406 }
00407
00408
00409
00410
00411 ConfigurationVersion ConfigurationManagerRW::saveNewConfiguration(const std::string &configurationName,
00412 ConfigurationVersion temporaryVersion, bool makeTemporary)
00413 {
00414 ConfigurationVersion newVersion(temporaryVersion);
00415
00416
00417 ConfigurationBase *config = getConfigurationByName(configurationName);
00418 config->getTemporaryView(temporaryVersion)->setAuthor(username_);
00419
00420
00421 if(!makeTemporary)
00422 newVersion = theInterface_->saveNewVersion(config, temporaryVersion);
00423 else
00424 config->setActiveView(newVersion);
00425
00426
00427 while(!newVersion.isScratchVersion() && allConfigurationInfo_[configurationName].versions_.find(newVersion) !=
00428 allConfigurationInfo_[configurationName].versions_.end())
00429 {
00430 __MOUT_ERR__ << "What happenened!?? ERROR::: newVersion v" << newVersion <<
00431 " already exists!? How is it possible? Retrace your steps and tell an admin." << std::endl;
00432
00433
00434 temporaryVersion = config->createTemporaryView(newVersion);
00435
00436 if(newVersion.isTemporaryVersion())
00437 newVersion = temporaryVersion;
00438 else
00439 newVersion = ConfigurationVersion::getNextVersion(newVersion);
00440
00441 __MOUT_WARN__ << "Attempting to recover and use v" << newVersion << std::endl;
00442
00443
00444 if(!makeTemporary)
00445 newVersion = theInterface_->saveNewVersion(config, temporaryVersion, newVersion);
00446 else
00447 config->setActiveView(newVersion);
00448 }
00449
00450 if(newVersion.isInvalid())
00451 {
00452 __SS__ << "Something went wrong saving the new version v" << newVersion <<
00453 ". What happened?! (duplicates? database error?)" << std::endl;
00454 __MOUT_ERR__ << "\n" << ss.str();
00455 throw std::runtime_error(ss.str());
00456 }
00457
00458
00459 allConfigurationInfo_[configurationName].versions_.insert(newVersion);
00460
00461 __MOUT__ << "New version added to info " << newVersion << std::endl;
00462
00463 return newVersion;
00464 }
00465
00466
00467
00468
00469
00470
00471 void ConfigurationManagerRW::eraseTemporaryVersion(const std::string &configurationName,
00472 ConfigurationVersion targetVersion)
00473 {
00474 ConfigurationBase* config = getConfigurationByName(configurationName);
00475
00476 config->trimTemporary(targetVersion);
00477
00478
00479 if(allConfigurationInfo_.find(configurationName) ==
00480 allConfigurationInfo_.end()) return;
00481
00482
00483 if(targetVersion.isInvalid())
00484 {
00485
00486 for(auto it = allConfigurationInfo_[configurationName].versions_.begin();
00487 it != allConfigurationInfo_[configurationName].versions_.end(); )
00488 {
00489 if(it->isTemporaryVersion())
00490 {
00491 __MOUT__ << "Removing version info: " << *it << std::endl;
00492 allConfigurationInfo_[configurationName].versions_.erase(it++);
00493 }
00494 else
00495 ++it;
00496 }
00497 }
00498 else
00499 {
00500 __MOUT__ << "Removing version info: " << targetVersion << std::endl;
00501 auto it = allConfigurationInfo_[configurationName].versions_.find(targetVersion);
00502 if(it == allConfigurationInfo_[configurationName].versions_.end())
00503 {
00504 __MOUT__ << "Target version was not found in info versions..." << std::endl;
00505 return;
00506 }
00507 allConfigurationInfo_[configurationName].versions_.erase(
00508 allConfigurationInfo_[configurationName].versions_.find(targetVersion));
00509 __MOUT__ << "Target version was erased from info." << std::endl;
00510 }
00511 }
00512
00513
00514
00515
00516
00517
00518 void ConfigurationManagerRW::clearCachedVersions(const std::string &configurationName)
00519 {
00520 ConfigurationBase* config = getConfigurationByName(configurationName);
00521
00522 config->trimCache(0);
00523 }
00524
00525
00526
00527
00528
00529
00530 void ConfigurationManagerRW::clearAllCachedVersions()
00531 {
00532 for(auto configInfo: allConfigurationInfo_)
00533 configInfo.second.configurationPtr_->trimCache(0);
00534 }
00535
00536
00537
00538 ConfigurationVersion ConfigurationManagerRW::copyViewToCurrentColumns(const std::string &configurationName,
00539 ConfigurationVersion sourceVersion)
00540 {
00541 getConfigurationByName(configurationName)->reset();
00542
00543
00544
00545 ConfigurationBase *config = getVersionedConfigurationByName(configurationName,
00546 ConfigurationVersion(sourceVersion), true);
00547
00548
00549 ConfigurationVersion newTemporaryVersion = config->copyView(config->getView(),
00550 ConfigurationVersion(),username_);
00551
00552
00553 allConfigurationInfo_[configurationName].versions_.insert(newTemporaryVersion);
00554
00555 return newTemporaryVersion;
00556 }
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569 ConfigurationGroupKey ConfigurationManagerRW::findConfigurationGroup(const std::string &groupName,
00570 const std::map<std::string, ConfigurationVersion> &groupMemberMap)
00571 {
00572 std::set<std::string > groupNames =
00573 theInterface_->getAllConfigurationGroupNames(groupName);
00574 std::string name;
00575 ConfigurationGroupKey key;
00576 std::map<std::string , ConfigurationVersion > compareToMemberMap;
00577 bool isDifferent;
00578 for(const std::string& fullName: groupNames)
00579 {
00580 ConfigurationGroupKey::getGroupNameAndKey(fullName,name,key);
00581
00582
00583 if( name != groupName) continue;
00584
00585
00586 compareToMemberMap = theInterface_->getConfigurationGroupMembers(fullName);
00587
00588 isDifferent = false;
00589 for(auto &memberPair: groupMemberMap)
00590 {
00591
00592 if(compareToMemberMap.find(memberPair.first) == compareToMemberMap.end() ||
00593 memberPair.second != compareToMemberMap[memberPair.first])
00594 {
00595
00596 isDifferent = true;
00597 break;
00598 }
00599 }
00600 if(isDifferent) continue;
00601
00602
00603 if(groupMemberMap.size() != compareToMemberMap.size()) continue;
00604
00605 __MOUT__ << "Found exact match with key: " << key << std::endl;
00606
00607 return key;
00608 }
00609 __MOUT__ << "No match found - this group is new!" << std::endl;
00610
00611 return ConfigurationGroupKey();
00612 }
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622 ConfigurationGroupKey ConfigurationManagerRW::saveNewConfigurationGroup(const std::string &groupName,
00623 std::map<std::string, ConfigurationVersion> &groupMembers,
00624 ConfigurationGroupKey previousVersion, const std::string &groupComment)
00625 {
00626
00627
00628
00629
00630
00631
00632
00633 ConfigurationGroupKey newKey;
00634 if(!previousVersion.isInvalid())
00635 newKey = ConfigurationGroupKey::getNextKey(previousVersion);
00636 else
00637 {
00638 std::set<ConfigurationGroupKey> keys = theInterface_->getKeys(groupName);
00639 if(keys.size())
00640 newKey = ConfigurationGroupKey::getNextKey(*(keys.crbegin()));
00641 else
00642 newKey = ConfigurationGroupKey::getDefaultKey();
00643 }
00644
00645 __MOUT__ << "New Key for group: " << groupName << " found as " << newKey << std::endl;
00646
00647
00648
00649 std::map<std::string, ConfigurationInfo> allCfgInfo = getAllConfigurationInfo();
00650 for(auto &memberPair : groupMembers )
00651 {
00652
00653 if(allCfgInfo.find(memberPair.first) == allCfgInfo.end())
00654 {
00655 __MOUT_ERR__ << "Group member \"" << memberPair.first << "\" not found in configuration!";
00656
00657 if(groupMetadataTable_.getConfigurationName() ==
00658 memberPair.first)
00659 {
00660 __MOUT_WARN__ << "Looks like this is the groupMetadataTable_. " <<
00661 "Note that this table is added to the member map when groups are saved." <<
00662 "It should not be part of member map when calling this function." << std::endl;
00663 __MOUT__ << "Attempting to recover." << std::endl;
00664 groupMembers.erase(groupMembers.find(memberPair.first));
00665 }
00666 else
00667 throw std::runtime_error("Group member not found!");
00668 }
00669
00670 if(allCfgInfo[memberPair.first].versions_.find(memberPair.second) ==
00671 allCfgInfo[memberPair.first].versions_.end())
00672 {
00673 __MOUT_ERR__ << "Group member \"" << memberPair.first << "\" version \"" <<
00674 memberPair.second << "\" not found in configuration!";
00675 throw std::runtime_error("Group member version not found!");
00676 }
00677 }
00678
00679
00680 try
00681 {
00682
00683
00684
00685
00686 groupMetadataTable_.getViewP()->setValue(groupComment,0,1);
00687 groupMetadataTable_.getViewP()->setValue(username_,0,2);
00688 groupMetadataTable_.getViewP()->setValue(time(0),0,3);
00689
00690
00691 groupMetadataTable_.getViewP()->setVersion(
00692 ConfigurationVersion::getNextVersion(theInterface_->findLatestVersion(&groupMetadataTable_))
00693 );
00694
00695
00696
00697 theInterface_->saveActiveVersion(&groupMetadataTable_);
00698
00699
00700 groupMembers[groupMetadataTable_.getConfigurationName()] =
00701 groupMetadataTable_.getViewVersion();
00702
00703 theInterface_->saveConfigurationGroup(groupMembers,
00704 ConfigurationGroupKey::getFullGroupString(groupName,newKey));
00705 __MOUT__ << "Created config group: " << groupName << ":" << newKey << std::endl;
00706 }
00707 catch(std::runtime_error &e)
00708 {
00709 __MOUT_ERR__ << "Failed to create config group: " << groupName << ":" << newKey << std::endl;
00710 __MOUT_ERR__ << "\n\n" << e.what() << std::endl;
00711 throw;
00712 }
00713 catch(...)
00714 {
00715 __MOUT_ERR__ << "Failed to create config group: " << groupName << ":" << newKey << std::endl;
00716 throw;
00717 }
00718
00719
00720 return newKey;
00721 }
00722
00723
00724
00725
00726
00727 ConfigurationVersion ConfigurationManagerRW::saveNewBackbone(ConfigurationVersion temporaryVersion)
00728 {
00729 __MOUT_INFO__ << "Creating new backbone from temporary version " <<
00730 temporaryVersion << std::endl;
00731
00732
00733 ConfigurationVersion newVersion(ConfigurationVersion::DEFAULT);
00734 ConfigurationVersion retNewVersion;
00735 auto backboneMemberNames = ConfigurationManager::getBackboneMemberNames();
00736 for (auto& name : backboneMemberNames)
00737 {
00738 retNewVersion = ConfigurationManager::getConfigurationByName(name)->getNextVersion();
00739 __MOUT__ << "New version for backbone member (" << name << "): " <<
00740 retNewVersion << std::endl;
00741 if(retNewVersion > newVersion)
00742 newVersion = retNewVersion;
00743 }
00744
00745 __MOUT__ << "Common new backbone version found as " <<
00746 newVersion << std::endl;
00747
00748
00749 for (auto& name : backboneMemberNames)
00750 {
00751
00752 retNewVersion = getConfigurationInterface()->saveNewVersion(
00753 getConfigurationByName(name), temporaryVersion, newVersion);
00754 if(retNewVersion != newVersion)
00755 {
00756 __MOUT_ERR__ << "Failure! New view requested was " <<
00757 newVersion << ". Mismatched new view created: " << retNewVersion << std::endl;
00758 throw std::runtime_error("Mismatched temporary view created!");
00759 }
00760 }
00761
00762 return newVersion;
00763 }
00764
00765
00766 void ConfigurationManagerRW::testXDAQContext()
00767 {
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920 try
00921 {
00922 __MOUT__ << "Loading config..." << std::endl;
00923 loadConfigurationGroup("FETest",ConfigurationGroupKey(2));
00924 ConfigurationTree t = getNode("/FEConfiguration/DEFAULT/FrontEndType");
00925
00926 std::string v;
00927
00928 __MOUT__ << std::endl;
00929 t.getValue(v);
00930 __MOUT__ << "Value: " << v << std::endl;
00931 __MOUT__ << "Value index: " << t.getValue<int>() << std::endl;
00932
00933 return;
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970 }
00971 catch(...)
00972 {
00973 __MOUT__ << "Failed to load config..." << std::endl;
00974 }
00975
00976
00977 }
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990