#include <CondCore/IOVService/src/IOVServiceImpl.h>
Public Member Functions | |
void | deleteAll (bool withPayload) |
std::string | exportIOVRangeWithPayload (cond::PoolTransaction &destDB, const std::string &iovToken, const std::string &destToken, cond::Time_t since, cond::Time_t till) |
std::string | exportIOVWithPayload (cond::PoolTransaction &destDB, const std::string &iovToken) |
cond::Time_t | globalSince () const |
cond::Time_t | globalTill () const |
IOVServiceImpl (cond::PoolTransaction &pooldb) | |
bool | isValid (const std::string &iovToken, cond::Time_t currenttime) |
std::string | payloadContainerName (const std::string &iovtoken) |
std::string | payloadToken (const std::string &iovToken, cond::Time_t currenttime) |
cond::TimeType | timeType () const |
std::pair< cond::Time_t, cond::Time_t > | validity (const std::string &iovToken, cond::Time_t currenttime) |
~IOVServiceImpl () | |
Private Attributes | |
std::map< std::string, cond::IOV * > | m_iovcache |
cond::PoolTransaction * | m_pooldb |
Definition at line 12 of file IOVServiceImpl.h.
cond::IOVServiceImpl::IOVServiceImpl | ( | cond::PoolTransaction & | pooldb | ) |
cond::IOVServiceImpl::~IOVServiceImpl | ( | ) |
Definition at line 14 of file IOVServiceImpl.cc.
References iter, and m_iovcache.
00014 { 00015 for(std::map< std::string,cond::IOV* >::const_iterator iter= m_iovcache.begin(); 00016 iter!=m_iovcache.end();++iter){ 00017 if(iter->second) delete iter->second; 00018 } 00019 00020 }
Definition at line 103 of file IOVServiceImpl.cc.
References cond::classID(), cond::IOVNames::container(), cond::ContainerIterator< DataT >::dataRef(), it, m_pooldb, cond::GenericRef::markDelete(), cond::TypedRef< T >::markDelete(), cond::ContainerIterator< DataT >::next(), and cond::GenericRef::reset().
Referenced by cond::IOVService::deleteAll().
00103 { 00104 cond::ContainerIterator<cond::IOV> it(*m_pooldb,cond::IOVNames::container()); 00105 while ( it.next() ) { 00106 if(withPayload){ 00107 std::string tokenStr; 00108 IOV::iterator payloadIt; 00109 IOV::iterator payloadItEnd=it.dataRef()->iov.end(); 00110 for(payloadIt=it.dataRef()->iov.begin();payloadIt!=payloadItEnd;++payloadIt){ 00111 tokenStr=payloadIt->second; 00112 pool::Token token; 00113 const pool::Guid& classID=token.fromString(tokenStr).classID(); 00114 cond::GenericRef ref(*m_pooldb,tokenStr,pool::DbReflex::forGuid(classID).TypeInfo()); 00115 ref.markDelete(); 00116 ref.reset(); 00117 } 00118 } 00119 it.dataRef().markDelete(); 00120 } 00121 }
std::string cond::IOVServiceImpl::exportIOVRangeWithPayload | ( | cond::PoolTransaction & | destDB, | |
const std::string & | iovToken, | |||
const std::string & | destToken, | |||
cond::Time_t | since, | |||
cond::Time_t | till | |||
) |
Definition at line 156 of file IOVServiceImpl.cc.
References cond::IOV::add(), cond::PoolTransaction::commit(), cond::IOVNames::container(), cond::TimeTypeSpecs::endValue, Exception, cond::GenericRef::exportTo(), cond::IOV::find(), cond::IOV::firstsince, cond::IOV::iov, it, m_iovcache, m_pooldb, max, cond::reflexTypeByToken(), cond::PoolTransaction::start(), cond::IOV::timetype, and cond::timeTypeSpecs.
Referenced by cond::IOVService::exportIOVRangeWithPayload().
00160 { 00161 00162 { 00163 cond::TypedRef<cond::IOV> iov(*m_pooldb,iovToken); 00164 std::string ptok = iov->iov.front().second; 00165 m_pooldb->commit(); 00166 cond::reflexTypeByToken(ptok); 00167 m_pooldb->start(true); 00168 } 00169 00170 00171 std::map< std::string,cond::IOV* >::iterator it=m_iovcache.find(iovToken); 00172 cond::IOV* iov=0; 00173 if(it==m_iovcache.end()){ 00174 iov = new cond::IOV(*cond::TypedRef<cond::IOV>(*m_pooldb,iovToken)); 00175 m_iovcache.insert(std::make_pair(iovToken,iov)); 00176 } else { 00177 iov = it->second; 00178 } 00179 IOV::const_iterator ifirstTill=iov->find(since); 00180 IOV::const_iterator isecondTill=iov->find(till); 00181 if( isecondTill!=iov->iov.end() ){ 00182 isecondTill++; 00183 } 00184 00185 if (ifirstTill==isecondTill) 00186 throw cond::Exception("IOVServiceImpl::exportIOVRangeWithPayload Error: empty input range"); 00187 00188 IOV::const_iterator iprev=ifirstTill; 00189 00190 // compute since 00191 since = std::max(since,(iprev==iov->iov.begin()) ? iov->firstsince : (--iprev)->first+1); 00192 00193 cond::TypedRef<cond::IOV> newiovref; 00194 00195 cond::Time_t lastIOV = cond::timeTypeSpecs[iov->timetype].endValue; 00196 00197 00198 if (destToken.empty()) { 00199 // create a new one 00200 newiovref = cond::TypedRef<cond::IOV>(destDB,new cond::IOV); 00201 newiovref.markWrite(cond::IOVNames::container()); 00202 newiovref->timetype= iov->timetype; 00203 newiovref->firstsince = since; 00204 } else { 00205 newiovref = cond::TypedRef<cond::IOV>(destDB,destToken); 00206 newiovref.markUpdate(); 00207 if (since <= newiovref->firstsince 00208 || (newiovref->iov.size()>1 && since <= (++(newiovref->iov.rbegin()))->first) 00209 ) { 00210 throw cond::Exception("IOVServiceImpl::exportIOVRangeWithPayload Error: since time out of range, below last since"); 00211 00212 } 00213 // update last till 00214 lastIOV = newiovref->iov.back().first; 00215 newiovref->iov.back().first=since-1; 00216 } 00217 00218 cond::IOV & newiov = *newiovref; 00219 for( IOV::const_iterator it=ifirstTill; 00220 it!=isecondTill; ++it){ 00221 cond::GenericRef payloadRef(*m_pooldb,it->second); 00222 std::string newPtoken=payloadRef.exportTo(destDB); 00223 newiov.add(it->first,newPtoken); 00224 } 00225 // close (well open) IOV 00226 newiovref->iov.back().first = std::max(lastIOV, newiovref->iov.back().first); 00227 return newiovref.token(); 00228 }
std::string cond::IOVServiceImpl::exportIOVWithPayload | ( | cond::PoolTransaction & | destDB, | |
const std::string & | iovToken | |||
) |
Definition at line 124 of file IOVServiceImpl.cc.
References cond::IOV::add(), cond::IOVNames::container(), cond::GenericRef::exportTo(), cond::IOV::firstsince, cond::IOV::iov, it, m_iovcache, m_pooldb, cond::TypedRef< T >::markWrite(), cond::IOV::timetype, and cond::TypedRef< T >::token().
Referenced by cond::IOVService::exportIOVWithPayload().
00125 { 00126 00127 std::map< std::string,cond::IOV* >::iterator it=m_iovcache.find(iovToken); 00128 cond::IOV* iov=0; 00129 if(it==m_iovcache.end()){ 00130 iov = new cond::IOV(*cond::TypedRef<cond::IOV>(*m_pooldb,iovToken)); 00131 m_iovcache.insert(std::make_pair(iovToken,iov)); 00132 } else { 00133 iov = it->second; 00134 } 00135 00136 cond::IOV* newiov=new cond::IOV; 00137 newiov->timetype= iov->timetype; 00138 newiov->firstsince=iov->firstsince; 00139 00140 for( IOV::iterator it=iov->iov.begin(); 00141 it!=iov->iov.end(); ++it){ 00142 cond::GenericRef payloadRef(*m_pooldb,it->second); 00143 std::string newPToken=payloadRef.exportTo(destDB); 00144 newiov->add(it->first,newPToken); 00145 } 00146 cond::TypedRef<cond::IOV> newiovref(destDB,newiov); 00147 newiovref.markWrite(cond::IOVNames::container()); 00148 return newiovref.token(); 00149 }
cond::Time_t cond::IOVServiceImpl::globalSince | ( | ) | const |
cond::Time_t cond::IOVServiceImpl::globalTill | ( | ) | const |
bool cond::IOVServiceImpl::isValid | ( | const std::string & | iovToken, | |
cond::Time_t | currenttime | |||
) |
Definition at line 41 of file IOVServiceImpl.cc.
References cond::IOV::firstsince, it, m_iovcache, m_pooldb, and HLT_VtxMuL3::result.
Referenced by cond::IOVService::isValid().
00042 { 00043 std::map< std::string,cond::IOV* >::iterator it=m_iovcache.find(iovToken); 00044 cond::IOV* iov=0; 00045 if(it==m_iovcache.end()){ 00046 iov = new cond::IOV(*cond::TypedRef<cond::IOV>(*m_pooldb,iovToken)); 00047 m_iovcache.insert(std::make_pair(iovToken,iov)); 00048 } else { 00049 iov = it->second; 00050 } 00051 bool result; 00052 00053 if( currenttime >= iov->firstsince && 00054 currenttime <= iov->iov.back().first ){ 00055 result=true; 00056 }else{ 00057 result=false; 00058 } 00059 return result; 00060 }
std::string cond::IOVServiceImpl::payloadContainerName | ( | const std::string & | iovtoken | ) |
Definition at line 85 of file IOVServiceImpl.cc.
References cond::IOV::iov, it, m_iovcache, m_pooldb, and HLT_VtxMuL3::result.
Referenced by cond::IOVService::payloadContainerName().
00085 { 00086 std::map< std::string,cond::IOV* >::iterator it=m_iovcache.find(iovToken); 00087 cond::IOV* iov=0; 00088 if(it==m_iovcache.end()){ 00089 iov = new cond::IOV(*cond::TypedRef<cond::IOV>(*m_pooldb,iovToken)); 00090 m_iovcache.insert(std::make_pair(iovToken,iov)); 00091 } else { 00092 iov = it->second; 00093 } 00094 std::string payloadtokstr=iov->iov.begin()->second; 00095 pool::Token* theTok = new pool::Token; 00096 theTok->fromString(payloadtokstr); 00097 std::string result=theTok->contID(); 00098 theTok->release(); 00099 return result; 00100 }
std::string cond::IOVServiceImpl::payloadToken | ( | const std::string & | iovToken, | |
cond::Time_t | currenttime | |||
) |
Definition at line 23 of file IOVServiceImpl.cc.
References cond::IOV::find(), cond::IOV::iov, it, m_iovcache, and m_pooldb.
Referenced by cond::IOVService::payloadToken().
00024 { 00025 std::map< std::string,cond::IOV* >::iterator it=m_iovcache.find(iovToken); 00026 cond::IOV* iov=0; 00027 if(it==m_iovcache.end()){ 00028 iov = new cond::IOV(*cond::TypedRef<cond::IOV>(*m_pooldb,iovToken)); 00029 m_iovcache.insert(std::make_pair(iovToken,iov)); 00030 } else { 00031 iov = it->second; 00032 } 00033 cond::IOV::const_iterator iEnd=iov->find(currenttime); 00034 if( iEnd==iov->iov.end() ){ 00035 return ""; 00036 }else{ 00037 return iEnd->second; 00038 } 00039 }
cond::TimeType cond::IOVServiceImpl::timeType | ( | ) | const |
std::pair< cond::Time_t, cond::Time_t > cond::IOVServiceImpl::validity | ( | const std::string & | iovToken, | |
cond::Time_t | currenttime | |||
) |
Definition at line 63 of file IOVServiceImpl.cc.
References cond::IOV::find(), cond::IOV::firstsince, cond::IOV::iov, it, iter, m_iovcache, and m_pooldb.
Referenced by cond::IOVService::validity().
00063 { 00064 std::map< std::string,cond::IOV* >::iterator it=m_iovcache.find(iovToken); 00065 cond::IOV* iov=0; 00066 if(it==m_iovcache.end()){ 00067 iov = new cond::IOV(*cond::TypedRef<cond::IOV>(*m_pooldb,iovToken)); 00068 m_iovcache.insert(std::make_pair(iovToken,iov)); 00069 } else { 00070 iov = it->second; 00071 } 00072 00073 cond::Time_t since=iov->firstsince; 00074 cond::Time_t till=iov->iov.back().first; 00075 IOV::const_iterator iter=iov->find(currenttime); 00076 if (iter!=iov->iov.end()) till=iter->first; 00077 if( iter!=iov->iov.begin() ){ 00078 --iter; 00079 since=iter->first+1; 00080 } 00081 return std::make_pair<cond::Time_t, cond::Time_t>(since,till); 00082 }
std::map< std::string,cond::IOV* > cond::IOVServiceImpl::m_iovcache [private] |
Definition at line 46 of file IOVServiceImpl.h.
Referenced by exportIOVRangeWithPayload(), exportIOVWithPayload(), isValid(), payloadContainerName(), payloadToken(), validity(), and ~IOVServiceImpl().
Definition at line 45 of file IOVServiceImpl.h.
Referenced by deleteAll(), exportIOVRangeWithPayload(), exportIOVWithPayload(), isValid(), payloadContainerName(), payloadToken(), and validity().