Public Member Functions | |
AlignSplitIOV () | |
int | execute () |
template<class T > | |
std::string | processPayloadContainer (cond::DbSession &sourcedb, cond::DbSession &destdb, const std::string &token, const std::string &containerName) |
~AlignSplitIOV () |
Definition at line 35 of file aligncond_split_iov.cc.
cond::AlignSplitIOV::AlignSplitIOV | ( | ) |
Definition at line 49 of file aligncond_split_iov.cc.
References cond::Utilities::addAuthenticationOptions(), and cond::Utilities::addConnectOption().
:Utilities("aligncond_split_iov") { addConnectOption("sourceConnect","s","source connection string(required)"); addConnectOption("destConnect","d","destionation connection string(required)"); addOption<std::string>("sourceTag","i","tag to export( default = destination tag)"); addOption<std::string>("destTag","t","destination tag (required)"); addAuthenticationOptions(); addOption<bool>("verbose","v","verbose"); }
cond::AlignSplitIOV::~AlignSplitIOV | ( | ) |
Definition at line 60 of file aligncond_split_iov.cc.
{ }
int cond::AlignSplitIOV::execute | ( | ) | [virtual] |
Reimplemented from cond::Utilities.
Definition at line 65 of file aligncond_split_iov.cc.
References cond::MetaData::addMapping(), cond::IOVEditor::append(), cond::IOVProxy::begin(), cond::DbSession::classNameForItem(), cond::DbScopedTransaction::commit(), gather_cfg::cout, cond::IOVEditor::create(), idDealer::editor, cond::IOVProxy::end(), cond::TimeTypeSpecs::endValue, cond::MetaData::getToken(), o2o::iov, max(), min, stor::utils::sleep(), cond::IOVEditor::stamp(), cond::DbTransaction::start(), cond::DbScopedTransaction::start(), AlCaHLTBitMon_QueryRunRegistry::string, cond::IOVProxy::timetype(), cond::timeTypeSpecs, cond::IOVEditor::token(), cond::DbSession::transaction(), python::IdGenerator::transaction, and cond::userInfo().
{ initializePluginManager(); std::string sourceConnect = getOptionValue<std::string>("sourceConnect"); std::string destConnect = getOptionValue<std::string>("destConnect"); std::string destTag = getOptionValue<std::string>("destTag"); std::string sourceTag(destTag); if (hasOptionValue("sourceTag")) sourceTag = getOptionValue<std::string>("sourceTag"); bool verbose = hasOptionValue("verbose"); cond::Time_t since = std::numeric_limits<cond::Time_t>::min(); cond::Time_t till = std::numeric_limits<cond::Time_t>::max(); std::string sourceiovtoken; cond::TimeType sourceiovtype; std::string destiovtoken; cond::DbSession sourcedb = openDbSession("sourceConnect", false); cond::DbSession destdb = openDbSession("destConnect"); sourcedb.transaction().start(false); cond::MetaData sourceMetadata(sourcedb); sourceiovtoken = sourceMetadata.getToken(sourceTag); if (sourceiovtoken.empty()) throw std::runtime_error(std::string("tag ") + sourceTag + std::string(" not found")); if (verbose) std::cout << "source iov token: " << sourceiovtoken << std::endl; cond::IOVProxy iov(sourcedb, sourceiovtoken); sourceiovtype = iov.timetype(); if (verbose) std::cout << "source iov type " << sourceiovtype << std::endl; since = std::max(since, cond::timeTypeSpecs[sourceiovtype].beginValue); till = std::min(till, cond::timeTypeSpecs[sourceiovtype].endValue); unsigned int counter = 0; for (cond::IOVProxy::const_iterator ioviterator = iov.begin(); ioviterator != iov.end(); ++ioviterator) { std::stringstream newTag; newTag << destTag << "_" << counter; std::cout << "iov " << counter << ":\t" << ioviterator->since() << " \t " << ioviterator->till() << std::endl; if (verbose) std::cout << "\t" << ioviterator->token() << std::endl; cond::DbScopedTransaction transaction(destdb); transaction.start(false); std::string payloadContainerName = sourcedb.classNameForItem(ioviterator->token()); std::string objToken; if (payloadContainerName=="Alignments") objToken = processPayloadContainer<Alignments>(sourcedb, destdb, ioviterator->token(), payloadContainerName); else if (payloadContainerName=="AlignmentErrors") objToken = processPayloadContainer<AlignmentErrors>(sourcedb, destdb, ioviterator->token(), payloadContainerName); else if (payloadContainerName=="AlignmentSurfaceDeformations") objToken = processPayloadContainer<AlignmentSurfaceDeformations>(sourcedb, destdb, ioviterator->token(), payloadContainerName); else { return 1; } cond::IOVEditor editor(destdb); editor.create(iov.timetype(), cond::timeTypeSpecs[sourceiovtype].endValue); editor.append(cond::timeTypeSpecs[sourceiovtype].beginValue, objToken); std::string iovToken = editor.token(); editor.stamp(cond::userInfo(),false); cond::MetaData metadata(destdb); metadata.addMapping(newTag.str(), iovToken, sourceiovtype); transaction.commit(); ::sleep(1); ++counter; } std::cout << "Total # of payload objects: " << counter << std::endl; return 0; }
std::string cond::AlignSplitIOV::processPayloadContainer | ( | cond::DbSession & | sourcedb, |
cond::DbSession & | destdb, | ||
const std::string & | token, | ||
const std::string & | containerName | ||
) |
Definition at line 159 of file aligncond_split_iov.cc.
References cond::DbSession::createDatabase(), cond::DbSession::getTypedObject(), and cond::DbSession::storeObject().
{ boost::shared_ptr<T> object = sourcedb.getTypedObject<T>(token); destdb.createDatabase(); return destdb.storeObject(object.get(), containerName); }