98 std::cout <<
"last configuration key already copied for run: " 101 std::vector<DTConfigKey> lastKey;
112 std::cout <<
"get last payload" << std::endl;
114 std::cout <<
"get last full key" << std::endl;
115 lastKey = payload->fullKey();
117 std::vector<DTConfigKey>::const_iterator keyIter = lastKey.begin();
118 std::vector<DTConfigKey>::const_iterator keyIend = lastKey.end();
119 while ( keyIter != keyIend ) {
125 std::cout <<
"configure DbConnection" << std::endl;
130 std::cout <<
"create/open DbSession" << std::endl;
132 std::cout <<
"start transaction" << std::endl;
133 isession->transaction().start(
true );
136 std::cout <<
"retrieve CCB map" << std::endl;
137 std::map<int,DTCCBId> ccbMap;
138 coral::ITable& ccbMapTable =
139 isession->nominalSchema().tableHandle(
"CCBMAP" );
140 std::auto_ptr<coral::IQuery>
141 ccbMapQuery( ccbMapTable.newQuery() );
142 ccbMapQuery->addToOutputList(
"CCBID" );
143 ccbMapQuery->addToOutputList(
"WHEEL" );
144 ccbMapQuery->addToOutputList(
"SECTOR" );
145 ccbMapQuery->addToOutputList(
"STATION" );
146 coral::ICursor& ccbMapCursor = ccbMapQuery->execute();
147 while( ccbMapCursor.next() ) {
148 const coral::AttributeList& row = ccbMapCursor.currentRow();
149 int ccb = row[
"CCBID" ].data<
int>();
150 int wheel = row[
"WHEEL" ].data<
int>();
151 int sector = row[
"SECTOR" ].data<
int>();
152 int station = row[
"STATION"].data<
int>();
154 ccbId. wheelId =
wheel;
156 ccbId. sectorId = sector;
157 ccbMap.insert( std::pair<int,DTCCBId>( ccb, ccbId ) );
161 std::cout <<
"retrieve brick types" << std::endl;
162 std::map<int,int> bktMap;
163 coral::AttributeList emptyBindVariableList;
164 std::auto_ptr<coral::IQuery>
165 brickTypeQuery(
isession->nominalSchema().newQuery() );
166 brickTypeQuery->addToTableList(
"CFGBRICKS" );
167 brickTypeQuery->addToTableList(
"BRKT2CSETT" );
168 std::string bTypeCondition =
"CFGBRICKS.BRKTYPE=BRKT2CSETT.BRKTYPE";
169 brickTypeQuery->addToOutputList(
"CFGBRICKS.BRKID" );
170 brickTypeQuery->addToOutputList(
"BRKT2CSETT.CSETTYPE" );
171 brickTypeQuery->setCondition( bTypeCondition, emptyBindVariableList );
172 coral::ICursor& brickTypeCursor = brickTypeQuery->execute();
173 while( brickTypeCursor.next() ) {
174 const coral::AttributeList& row = brickTypeCursor.currentRow();
175 int id = row[
"CFGBRICKS.BRKID" ].data<
int>();
176 int bt = row[
"BRKT2CSETT.CSETTYPE"].data<
short>();
180 bktMap.insert( std::pair<int,int>(
id, bt ) );
184 std::cout <<
"retrieve CCB configuration keys" << std::endl;
185 std::map<int,std::map<int,int>*> keyMap;
186 std::map<int,int> cckMap;
187 coral::ITable& ccbRelTable =
188 isession->nominalSchema().tableHandle(
"CCBRELATIONS" );
189 std::auto_ptr<coral::IQuery>
190 ccbRelQuery( ccbRelTable.newQuery() );
191 ccbRelQuery->addToOutputList(
"CONFKEY" );
192 ccbRelQuery->addToOutputList(
"CCBID" );
193 ccbRelQuery->addToOutputList(
"CONFCCBKEY" );
194 coral::ICursor& ccbRelCursor = ccbRelQuery->execute();
196 while( ccbRelCursor.next() ) {
197 const coral::AttributeList& row = ccbRelCursor.currentRow();
198 int cfg = row[
"CONFKEY" ].data<
int>();
199 int ccb = row[
"CCBID" ].data<
int>();
200 int key = row[
"CONFCCBKEY"].data<
int>();
204 std::map<int,std::map<int,int>*>::const_iterator keyIter =
206 std::map<int,std::map<int,int>*>::const_iterator keyIend =
208 std::map<int,int>* mapPtr =
nullptr;
210 if ( keyIter != keyIend ) mapPtr = keyIter->second;
212 std::pair<
int,std::map<int,int>*>( cfg,
213 mapPtr =
new std::map<int,int> ) );
215 std::map<int,int>& mapRef( *mapPtr );
216 mapRef.insert( std::pair<int,int>( ccb, key ) );
218 if ( cckMap.find( key ) == cckMap.end() )
219 cckMap.insert( std::pair<int,int>( key, ccb ) );
223 std::cout <<
"retrieve CCB configuration bricks" << std::endl;
224 std::map<int,std::vector<int>*> brkMap;
225 coral::ITable& confBrickTable =
226 isession->nominalSchema().tableHandle(
"CFG2BRKREL" );
227 std::auto_ptr<coral::IQuery>
228 confBrickQuery( confBrickTable.newQuery() );
229 confBrickQuery->addToOutputList(
"CONFID" );
230 confBrickQuery->addToOutputList(
"BRKID" );
231 coral::ICursor& confBrickCursor = confBrickQuery->execute();
233 while( confBrickCursor.next() ) {
234 const coral::AttributeList& row = confBrickCursor.currentRow();
235 int key = row[
"CONFID"].data<
int>();
236 int brk = row[
"BRKID" ].data<
int>();
238 if ( cckMap.find( key ) == cckMap.end() )
continue;
239 std::map<int,std::vector<int>*>::const_iterator brkIter =
241 std::map<int,std::vector<int>*>::const_iterator brkIend =
244 std::vector<int>* brkPtr =
nullptr;
245 if ( brkIter != brkIend ) brkPtr = brkIter->second;
247 std::pair<
int,std::vector<int>*>( key,
248 brkPtr =
new std::vector<int> ) );
250 brkPtr->push_back( brk );
257 std::map<int,bool> userBricks;
258 std::map<int,bool>::const_iterator uBrkIter = userBricks.begin();
259 std::map<int,bool>::const_iterator uBrkIend = userBricks.end();
260 std::vector<DTConfigKey>::const_iterator cfgIter =
userConf.begin();
261 std::vector<DTConfigKey>::const_iterator cfgIend =
userConf.end();
262 while ( cfgIter != cfgIend ) {
267 std::map<int,std::map<int,int>*>::const_iterator keyIter =
269 std::map<int,std::map<int,int>*>::const_iterator keyIend =
271 std::map<int,int>* mapPtr =
nullptr;
272 if ( keyIter != keyIend ) mapPtr = keyIter->second;
273 if ( mapPtr ==
nullptr )
continue;
274 std::map<int,int>::const_iterator ccbIter = mapPtr->begin();
275 std::map<int,int>::const_iterator ccbIend = mapPtr->end();
276 while ( ccbIter != ccbIend ) {
277 const std::pair<int,int>& ccbEntry = *ccbIter++;
279 int ccb = ccbEntry.first;
280 int key = ccbEntry.second;
282 std::map<int,DTCCBId>::const_iterator ccbIter = ccbMap.find( ccb );
283 std::map<int,DTCCBId>::const_iterator ccbIend = ccbMap.end();
284 if ( ccbIter == ccbIend )
continue;
285 const DTCCBId& chaId = ccbIter->second;
287 std::map<int,std::vector<int>*>::const_iterator brkIter =
289 std::map<int,std::vector<int>*>::const_iterator brkIend =
291 if ( brkIter == brkIend )
continue;
292 std::vector<int>* brkPtr = brkIter->second;
293 if ( brkPtr ==
nullptr )
continue;
295 std::vector<int> bkList;
296 bkList.reserve( 20 );
297 std::map<int,int>::const_iterator bktIter = bktMap.begin();
298 std::map<int,int>::const_iterator bktIend = bktMap.end();
299 std::vector<int>::const_iterator bkiIter = brkPtr->begin();
300 std::vector<int>::const_iterator bkiIend = brkPtr->end();
301 while ( bkiIter != bkiIend ) {
302 int brickId = *bkiIter++;
303 bktIter = bktMap.find( brickId );
304 if ( bktIter == bktIend )
continue;
305 if ( bktIter->second == cft ) {
306 bkList.push_back( brickId );
307 uBrkIter = userBricks.find( brickId );
308 if ( uBrkIter == uBrkIend )
309 userBricks.insert( std::pair<int,bool>( brickId,
true ) );
320 std::cout <<
"writing payload : " <<
sizeof( *fullConf )
321 <<
" ( " << ( fullConf->
end() - fullConf->
begin() )
322 <<
" ) " << std::endl;
edm::Ref< Container > Ref
std::vector< DTConfigKey > userConf
std::string onlineConnect
std::string onlineAuthentication
const_iterator end() const
OldContainer m_to_transfer
cond::ValidityInterval lastInterval
static cond::persistency::KeyList * keyList
payload
payload postfix for testing
unsigned long long Time_t
void setAuthenticationSystem(int authSysCode)
bool userDiscardedKey(int key)
void chkConfigList(const std::map< int, bool > &userBricks)
std::shared_ptr< coral::ISessionProxy > isession
void setFullKey(const std::vector< DTConfigKey > &)
cond::persistency::ConnectionPool connection
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