81 std::cout <<
"last configuration key already copied for run: " 84 std::vector<DTConfigKey> lastKey;
85 std::cout <<
"check for last " << std::endl;
95 std::cout <<
"get last payload" << std::endl;
97 std::cout <<
"get last full key" << std::endl;
98 lastKey = payload->fullKey();
100 std::vector<DTConfigKey>::const_iterator keyIter = lastKey.begin();
101 std::vector<DTConfigKey>::const_iterator keyIend = lastKey.end();
102 while ( keyIter != keyIend ) {
105 << cfgKeyList.
confKey << std::endl;
118 std::cout <<
"check for new runs since " << lastRun << std::endl;
120 std::cout <<
"configure DbConnection" << std::endl;
125 std::cout <<
"create/open DbSession" << std::endl;
127 std::cout <<
"start transaction" << std::endl;
128 isession->transaction().start(
true );
133 std::cout <<
"get run config..." << std::endl;
134 std::map<int,std::vector<int>*> runMap;
135 std::map<int,std::vector<DTConfigKey>*> rhcMap;
136 coral::ITable& runHistoryTable =
137 isession->nominalSchema().tableHandle(
"RUNHISTORY" );
138 std::auto_ptr<coral::IQuery>
139 runHistoryQuery( runHistoryTable.newQuery() );
140 runHistoryQuery->addToOutputList(
"RUN" );
141 runHistoryQuery->addToOutputList(
"RHID" );
142 coral::ICursor& runHistoryCursor = runHistoryQuery->execute();
143 while( runHistoryCursor.next() ) {
144 const coral::AttributeList& row = runHistoryCursor.currentRow();
145 int runId = row[
"RUN"].data<
int>();
146 int rhcId =
static_cast<int>( row[
"RHID"].data<
int>() );
148 if ( static_cast<unsigned>( runId ) <=
lastRun )
continue;
152 std::cout <<
"schedule config key copy for run " 153 << runId <<
" ---> RHID " << rhcId << std::endl;
155 std::vector<int>* rhlPtr =
nullptr;
156 std::map<int,std::vector<int>*>::const_iterator runIter;
157 if ( ( runIter = runMap.find( runId ) ) != runMap.end() )
158 rhlPtr = runIter->second;
159 else runMap.insert( std::pair<
int,std::vector<int>*>( runId,
160 rhlPtr =
new std::vector<int> ) );
162 rhlPtr->push_back( rhcId );
164 if ( rhcMap.find( rhcId ) == rhcMap.end() )
165 rhcMap.insert( std::pair<
int,std::vector<DTConfigKey>*>( rhcId,
166 new std::vector<DTConfigKey> ) );
168 if ( runMap.empty() )
std::cout <<
"no new run found" << std::endl;
171 std::cout <<
"retrieve CCB map" << std::endl;
172 std::map<int,DTCCBId> ccbMap;
173 coral::ITable& ccbMapTable =
174 isession->nominalSchema().tableHandle(
"CCBMAP" );
175 std::auto_ptr<coral::IQuery>
176 ccbMapQuery( ccbMapTable.newQuery() );
177 ccbMapQuery->addToOutputList(
"CCBID" );
178 ccbMapQuery->addToOutputList(
"WHEEL" );
179 ccbMapQuery->addToOutputList(
"SECTOR" );
180 ccbMapQuery->addToOutputList(
"STATION" );
181 coral::ICursor& ccbMapCursor = ccbMapQuery->execute();
182 while( ccbMapCursor.next() ) {
183 const coral::AttributeList& row = ccbMapCursor.currentRow();
184 int ccb = row[
"CCBID" ].data<
int>();
185 int wheel = row[
"WHEEL" ].data<
int>();
186 int sector = row[
"SECTOR" ].data<
int>();
187 int station = row[
"STATION"].data<
int>();
189 ccbId. wheelId =
wheel;
191 ccbId. sectorId = sector;
192 ccbMap.insert( std::pair<int,DTCCBId>( ccb, ccbId ) );
196 std::cout <<
"retrieve brick types" << std::endl;
197 std::map<int,int> bktMap;
198 coral::AttributeList emptyBindVariableList;
199 std::auto_ptr<coral::IQuery>
200 brickTypeQuery(
isession->nominalSchema().newQuery() );
201 brickTypeQuery->addToTableList(
"CFGBRICKS" );
202 brickTypeQuery->addToTableList(
"BRKT2CSETT" );
204 std::string bTypeCondition =
"CFGBRICKS.BRKTYPE=BRKT2CSETT.BRKTYPE";
205 brickTypeQuery->addToOutputList(
"CFGBRICKS.BRKID" );
206 brickTypeQuery->addToOutputList(
"BRKT2CSETT.CSETTYPE" );
207 brickTypeQuery->setCondition( bTypeCondition, emptyBindVariableList );
208 coral::ICursor& brickTypeCursor = brickTypeQuery->execute();
209 while( brickTypeCursor.next() ) {
210 const coral::AttributeList& row = brickTypeCursor.currentRow();
211 int id = row[
"CFGBRICKS.BRKID" ].data<
int>();
212 int bt = row[
"BRKT2CSETT.CSETTYPE"].data<
short>();
216 bktMap.insert( std::pair<int,int>(
id, bt ) );
220 std::cout <<
"retrieve RH relations" << std::endl;
221 std::map<int,int> cfgMap;
222 coral::ITable& rhcRelTable =
223 isession->nominalSchema().tableHandle(
"RHRELATIONS" );
224 std::auto_ptr<coral::IQuery>
225 rhcRelQuery( rhcRelTable.newQuery() );
226 rhcRelQuery->addToOutputList(
"RHID" );
227 rhcRelQuery->addToOutputList(
"CONFKEY" );
228 rhcRelQuery->addToOutputList(
"CSETTYPEID" );
229 coral::ICursor& rhcRelCursor = rhcRelQuery->execute();
230 while( rhcRelCursor.next() ) {
231 const coral::AttributeList& row = rhcRelCursor.currentRow();
232 int rhc = row[
"RHID" ].data<
int>();
233 int key = row[
"CONFKEY" ].data<
int>();
234 int cfg = row[
"CSETTYPEID"].data<
int>();
236 std::map<int,std::vector<DTConfigKey>*>::iterator rhcIter =
238 std::map<int,std::vector<DTConfigKey>*>::iterator rhcIend =
240 if ( rhcIter == rhcIend )
continue;
241 std::vector<DTConfigKey>* keyPtr = rhcIter->second;
245 keyPtr->push_back( confList );
247 if ( cfgMap.find( cfg ) == cfgMap.end() )
248 cfgMap.insert( std::pair<int,int>( key, rhc ) );
252 std::cout <<
"retrieve CCB configuration keys" << std::endl;
253 std::map<int,std::map<int,int>*> keyMap;
254 std::map<int,int> cckMap;
255 coral::ITable& ccbRelTable =
256 isession->nominalSchema().tableHandle(
"CCBRELATIONS" );
257 std::auto_ptr<coral::IQuery>
258 ccbRelQuery( ccbRelTable.newQuery() );
259 ccbRelQuery->addToOutputList(
"CONFKEY" );
260 ccbRelQuery->addToOutputList(
"CCBID" );
261 ccbRelQuery->addToOutputList(
"CONFCCBKEY" );
262 coral::ICursor& ccbRelCursor = ccbRelQuery->execute();
263 while( ccbRelCursor.next() ) {
264 const coral::AttributeList& row = ccbRelCursor.currentRow();
265 int cfg = row[
"CONFKEY" ].data<
int>();
266 int ccb = row[
"CCBID" ].data<
int>();
267 int key = row[
"CONFCCBKEY"].data<
int>();
269 if ( cfgMap.find( cfg ) == cfgMap.end() )
continue;
271 std::map<int,int>* mapPtr =
nullptr;
272 std::map<int,std::map<int,int>*>::const_iterator keyIter;
273 if ( ( keyIter = keyMap.find( cfg ) ) != keyMap.end() )
274 mapPtr = keyIter->second;
275 else keyMap.insert( std::pair<
int,std::map<int,int>*>( cfg,
276 mapPtr =
new std::map<int,int> ) );
286 std::map<int,int>& mapRef( *mapPtr );
287 mapRef.insert( std::pair<int,int>( ccb, key ) );
289 if ( cckMap.find( key ) == cckMap.end() )
290 cckMap.insert( std::pair<int,int>( key, ccb ) );
294 std::cout <<
"retrieve CCB configuration bricks" << std::endl;
295 std::map<int,std::vector<int>*> brkMap;
296 coral::ITable& confBrickTable =
297 isession->nominalSchema().tableHandle(
"CFG2BRKREL" );
298 std::auto_ptr<coral::IQuery>
299 confBrickQuery( confBrickTable.newQuery() );
300 confBrickQuery->addToOutputList(
"CONFID" );
301 confBrickQuery->addToOutputList(
"BRKID" );
302 coral::ICursor& confBrickCursor = confBrickQuery->execute();
303 while( confBrickCursor.next() ) {
304 const coral::AttributeList& row = confBrickCursor.currentRow();
305 int key = row[
"CONFID"].data<
int>();
306 int brk = row[
"BRKID" ].data<
int>();
308 if ( cckMap.find( key ) == cckMap.end() )
continue;
314 std::vector<int>* brkPtr =
nullptr;
315 std::map<int,std::vector<int>*>::const_iterator brkIter;
317 if ( ( brkIter = brkMap.find( key ) ) != brkMap.end() )
318 brkPtr = brkIter->second;
319 else brkMap.insert( std::pair<
int,std::vector<int>*>( key,
320 brkPtr =
new std::vector<int> ) );
326 brkPtr->push_back( brk );
330 std::map<int,std::vector<int>*>::const_iterator runIter = runMap.begin();
331 std::map<int,std::vector<int>*>::const_iterator runIend = runMap.end();
332 while ( runIter != runIend ) {
333 const std::pair<int,std::vector<int>*>& runEntry = *runIter++;
335 int run = runEntry.first;
336 std::vector<DTConfigKey> cfl;
338 std::vector<int>* rhlPtr = runEntry.second;
339 std::vector<int>::const_iterator rhlIter = rhlPtr->begin();
340 std::vector<int>::const_iterator rhlIend = rhlPtr->end();
342 while ( rhlIter != rhlIend ) {
343 int rhc = *rhlIter++;
344 std::cout <<
"retrieve configuration bricks for run " << run
345 <<
" ---> RH " << rhc << std::endl;
350 std::map<int,std::vector<DTConfigKey>*>::const_iterator rhcIter;
352 if ( ( rhcIter = rhcMap.find( rhc ) ) == rhcMap.end() )
continue;
353 std::vector<DTConfigKey>* listPtr = rhcIter->second;
355 if ( listPtr ==
nullptr )
continue;
356 std::vector<DTConfigKey>::const_iterator bkiIter = listPtr->begin();
357 std::vector<DTConfigKey>::const_iterator bkiIend = listPtr->end();
358 while ( bkiIter != bkiIend ) cfl.push_back( *bkiIter++ );
367 std::vector<DTConfigKey>::const_iterator cfgIter = cfl.begin();
368 std::vector<DTConfigKey>::const_iterator cfgIend = cfl.end();
369 while ( cfgIter != cfgIend ) {
379 std::map<int,int>* mapPtr =
nullptr;
380 std::map<int,std::map<int,int>*>::const_iterator keyIter;
383 if ( ( keyIter = keyMap.find( cfg ) ) != keyMap.end() )
384 mapPtr = keyIter->second;
385 if ( mapPtr ==
nullptr )
continue;
386 std::map<int,int>::const_iterator ccmIter = mapPtr->begin();
387 std::map<int,int>::const_iterator ccmIend = mapPtr->end();
388 while ( ccmIter != ccmIend ) {
389 const std::pair<int,int>& ccmEntry = *ccmIter++;
391 int ccb = ccmEntry.first;
392 int key = ccmEntry.second;
396 std::map<int,DTCCBId>::const_iterator ccbIter;
399 if ( ( ccbIter = ccbMap.find( ccb ) ) == ccbMap.end() )
continue;
400 const DTCCBId& chaId = ccbIter->second;
407 std::map<int,std::vector<int>*>::const_iterator brkIter;
408 if ( ( brkIter = brkMap.find( key ) ) == brkMap.end() )
continue;
409 std::vector<int>* brkPtr = brkIter->second;
411 if ( brkPtr ==
nullptr )
continue;
413 std::vector<int> bkList;
414 bkList.reserve( 20 );
417 std::map<int,int>::const_iterator bktIter;
418 std::vector<int>::const_iterator bkiIter = brkPtr->begin();
419 std::vector<int>::const_iterator bkiIend = brkPtr->end();
420 while ( bkiIter != bkiIend ) {
421 int brickId = *bkiIter++;
424 if ( ( bktIter = bktMap.find( brickId ) ) == bktMap.end() )
continue;
425 if ( bktIter->second == cft ) bkList.push_back( brickId );
435 std::cout <<
"writing payload : " <<
sizeof( *fullConf )
436 <<
" ( " << ( fullConf->
end() - fullConf->
begin() )
437 <<
" ) " << std::endl;
edm::Ref< Container > Ref
cond::persistency::ConnectionPool connection
const_iterator end() const
OldContainer m_to_transfer
std::string onlineAuthentication
cond::ValidityInterval lastInterval
unsigned long long Time_t
void setAuthenticationSystem(int authSysCode)
std::string onlineConnect
static bool sameConfigList(const std::vector< DTConfigKey > &cfgl, const std::vector< DTConfigKey > &cfgr)
std::shared_ptr< coral::ISessionProxy > isession
void setFullKey(const std::vector< DTConfigKey > &)
const_iterator begin() const
void setAuthenticationPath(const std::string &p)
std::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
int appendConfigKey(int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
cond::TagInfo_t const & tagInfo() const