32 addConnectOption(
"destConnect",
"d",
"destionation connection string(required)");
33 addOption<std::string>(
"inputTag",
"i",
"tag to export( default = destination tag)");
34 addOption<std::string>(
"destTag",
"t",
"destination tag (required)");
35 addOption<cond::Time_t>(
"beginTime",
"b",
"begin time (first since) (optional)");
36 addOption<cond::Time_t>(
"endTime",
"e",
"end time (last till) (optional)");
37 addOption<bool>(
"outOfOrder",
"o",
"allow out of order merge (optional, default=false)");
38 addOption<size_t>(
"bunchSize",
"n",
"iterate with bunches of specific size (optional)");
39 addOption<std::string>(
"usertext",
"x",
"user text, to be included in usertext column (optional, must be enclosed in double quotes)");
48 std::string sourceConnect = getOptionValue<std::string>(
"sourceConnect");
49 std::string destConnect = getOptionValue<std::string>(
"destConnect");
51 std::string destTag = getOptionValue<std::string>(
"destTag");
53 if( hasOptionValue(
"inputTag") ) inputTag = getOptionValue<std::string>(
"inputTag");
55 if( hasOptionValue(
"usertext")) usertext = getOptionValue<std::string>(
"usertext");
56 bool doLog = hasOptionValue(
"logDB");
59 if( hasOptionValue(
"beginTime" )) since = getOptionValue<cond::Time_t>(
"beginTime");
61 if( hasOptionValue(
"endTime" )) till = getOptionValue<cond::Time_t>(
"endTime");
64 if(hasOptionValue(
"bunchSize")) bunchSize = getOptionValue<size_t>(
"bunchSize");
67 bool debug=hasDebug();
68 bool outOfOrder = hasOptionValue(
"outOfOrder");
78 std::auto_ptr<cond::Logger> logDb;
89 logDb->createLogDBIfNonExist();
97 sourceIovToken=sourceMetadata.
getToken(inputTag);
98 if(sourceIovToken.empty())
102 std::cout<<
"source iov token "<<sourceIovToken<<std::endl;
106 sourceIov.
load( sourceIovToken );
107 sourceIovType = sourceIov.
timetype();
110 std::cout<<
"source iov type "<<sourceIovType<<std::endl;
115 iovSize = sourceIov.
size();
116 std::ostringstream stream;
117 std::copy(pclasses.begin(), pclasses.end(), std::ostream_iterator<std::string>(stream,
", "));
118 payloadClasses = stream.str();
124 transaction.
start(
false);
132 if( destMetadata.
hasTag(destTag) ){
133 destIovToken=destMetadata.
getToken(destTag);
134 destIov.
load( destIovToken );
136 if (sourceIovType!=destIov.
timetype()) {
137 throw std::runtime_error(
"iov type in source and dest differs");
142 destMetadata.
addMapping(destTag,destIovToken,sourceIovType);
146 std::cout<<
"dest iov token "<<destIovToken<<std::endl;
147 std::cout<<
"dest iov type "<<sourceIovType<<std::endl;
153 boost::shared_ptr<IOVImportIterator> importIterator = destIov.
importIterator();
154 importIterator->setUp( sourceIov, since, till, outOfOrder, bunchSize );
156 size_t totalImported = 0;
158 unsigned int iter = 0;
159 while( importIterator->hasMoreElements() ){
166 size_t imported = importIterator->importMoreElements();
167 totalImported += imported;
168 std::cout <<
"Iteration #"<<iter<<
": "<<imported<<
" element(s)."<<std::endl;
171 totalImported = importIterator->importAll();
173 std::cout <<totalImported<<
" element(s) exported."<<std::endl;
181 std::ostringstream stream;
183 payloadClasses = stream.str();
184 iovSize = diov.
size();
185 ncopied = iovSize-oldSize;
189 payloadToken=last.
token();
192 if (newIOV) a.
usertext+=
"new tag;";
193 std::ostringstream
ss;
194 ss <<
"since="<< since <<
", till="<< till <<
", " << usertext <<
";";
195 ss <<
" copied="<< ncopied <<
";";
197 logDb->logOperationNow(a,destConnect,payloadClasses,payloadToken,destTag,timetypestr,iovSize-1,since);
203 if (newIOV) a.
usertext+=
"new tag;";
204 std::ostringstream
ss;
205 ss <<
"since="<< since <<
", till="<< till <<
", " << usertext <<
";";
206 ss <<
" copied="<< ncopied <<
";";
208 logDb->logFailedOperationNow(a,destConnect,payloadClasses,payloadToken,destTag,timetypestr,iovSize-1,since,
std::string(er.
what()));
virtual char const * what() const
const TimeTypeSpecs timeTypeSpecs[]
cond::Time_t lastTill() const
std::string create(cond::TimeType timetype)
IOVSequence const & iov() const
void load(const std::string &token)
std::string classNameForItem(const std::string &objectId)
std::string token() const
DbTransaction & transaction()
int commit()
commit transaction.
Container const & iovs() const
std::string const & metadata() const
void load(const std::string &token)
std::set< std::string > const & payloadClasses() const
void setScope(cond::IOVSequence::ScopeType scope)
set the scope
bool lockContainer(const std::string &name)
int start(bool readOnly=false)
start transaction
unsigned long long Time_t
TimeType timetype() const
void addAuthenticationOptions()
static const std::string COND_WRITER_ROLE
void addSQLOutputOption()
void addConfigFileOption()
int start(bool readOnly=false)
start transaction
ExportIOVUtilities(std::string const &name)
static const std::string COND_READER_ROLE
bool createIOVContainerIfNecessary()
cond::IOVProxy proxy() const
void addDictionaryOption()
static std::string container()
TimeType timetype() const
boost::shared_ptr< IOVImportIterator > importIterator()
int commit()
commit transaction. Will disconnect from database if connection timeout==0 or connectted time close t...
ora::Database & storage()