Concept An single entry in the Database Log which records all non-automatic updates to the database. More...
#include <TDbiLogEntry.hxx>
Public Member Functions | |
TDbiLogEntry (const string &tableName="", const string &reason="", Int_t detMask=DbiDetector::FullMask(), Int_t simMask=DbiSimFlag::FullMask(), TDbi::Task task=0, Int_t logSeqNoMin=0, Int_t logSeqNoMax=0, Int_t logNumSeqNo=0) | |
virtual | ~TDbiLogEntry () |
virtual TDbiTableRow * | CreateTableRow () const |
Int_t | GetAggregateNo () const |
const string & | GetLogTableName () const |
Int_t | GetDetectorMask () const |
Int_t | GetLogSeqNoMin () const |
Int_t | GetLogSeqNoMax () const |
Int_t | GetLogNumSeqNo () const |
Int_t | GetSimMask () const |
TDbi::Task | GetTask () const |
const string & | GetUserName () const |
const string & | GetProcessName () const |
const string & | GetHostName () const |
const string & | GetServerName () const |
const string & | GetReason () const |
TVldTimeStamp | GetUpdateTime () const |
Bool_t | HasReason () const |
void | SetReason (const string &reason) |
void | SetDetectorMask (Int_t detMask) |
void | SetSimMask (Int_t simMask) |
void | SetTask (TDbi::Task task) |
void | SetUpdateTime (const TVldTimeStamp &updateTime) |
void | Recreate (const string &tableName="", const string &reason="", Int_t detMask=DbiDetector::FullMask(), Int_t simMask=DbiSimFlag::FullMask(), TDbi::Task task=0, Int_t logSeqNoMin=0, Int_t logSeqNoMax=0, Int_t logNumSeqNo=0) |
virtual void | Fill (TDbiInRowStream &rs, const TDbiValidityRec *vrec) |
virtual void | Store (TDbiOutRowStream &ors, const TDbiValidityRec *vrec) const |
Bool_t | Write (UInt_t dbNo, Int_t logSeqNo=0) |
virtual Bool_t | CanL2Cache () const |
Replace this with a function returning true in order to use the level 2 disk cache. | |
TDbiResultSet * | GetOwner () const |
virtual UInt_t | GetIndex (UInt_t defIndex) const |
void | SetOwner (TDbiResultSet *owner) |
Private Member Functions | |
TDbiLogEntry (const TDbiLogEntry &from) | |
void | SetServerName () |
Private Attributes | |
UInt_t | fDbNo |
Database no. written to. =0 if not output. | |
Int_t | fSeqNo |
Seq. No. used to write this object. =0 if not output. | |
string | fLogTableName |
Table being updated. | |
Int_t | fLogDetMask |
Detector type mask of update. | |
Int_t | fLogSimMask |
SimFlag mask of update. | |
TDbi::Task | fLogTask |
Task of update. | |
Int_t | fLogSeqNoMin |
Minimum Seq. No. being updated. | |
Int_t | fLogSeqNoMax |
Maximum Seq. No. being updated. | |
Int_t | fLogNumSeqNo |
Number of Seq. Nos. being updated. | |
TVldTimeStamp | fUpdateTime |
Time of update. | |
string | fUserName |
User performing update. | |
string | fProcessName |
Process performing update. | |
string | fHostName |
Host performing update. | |
string | fServerName |
Db server being updated. | |
string | fReason |
Reason for update. |
Concept An single entry in the Database Log which records all non-automatic updates to the database.
Purpose Capture and present updates together with the reasons for them. Contact: A.Finch@lancaster.ac.uk
Definition at line 49 of file TDbiLogEntry.hxx.
TDbiLogEntry::TDbiLogEntry | ( | const string & | tableName = "" , |
|
const string & | reason = "" , |
|||
Int_t | detMask = DbiDetector::FullMask() , |
|||
Int_t | simMask = DbiSimFlag::FullMask() , |
|||
TDbi::Task | task = 0 , |
|||
Int_t | logSeqNoMin = 0 , |
|||
Int_t | logSeqNoMax = 0 , |
|||
Int_t | logNumSeqNo = 0 | |||
) |
Definition at line 47 of file TDbiLogEntry.cxx.
References fLogNumSeqNo, fLogSeqNoMax, fLogSeqNoMin, fUserName, SetReason(), and SetServerName().
00054 : /* = 0 */ 00055 fDbNo(0), 00056 fSeqNo(0), 00057 fLogTableName(tableName), 00058 fLogDetMask(detMask), 00059 fLogSimMask(simMask), 00060 fLogTask(task), 00061 fLogSeqNoMin(logSeqNoMin), 00062 fLogSeqNoMax(logSeqNoMax), 00063 fLogNumSeqNo(logNumSeqNo), 00064 fUserName("unknown user"), 00065 fProcessName(gProgName), 00066 fHostName(gSystem->HostName()) 00067 { 00068 // 00069 // 00070 // Purpose: Constructor 00071 00072 00073 if ( fLogSeqNoMax == 0 ) fLogSeqNoMax = logSeqNoMin; 00074 if ( fLogNumSeqNo == 0 && logSeqNoMin != 0 00075 ) fLogNumSeqNo = fLogSeqNoMax - fLogSeqNoMin +1; 00076 00077 this->SetServerName(); 00078 this->SetReason(reason); 00079 00080 // Try to get username from the environment. 00081 const char* userName = gSystem->Getenv("USER"); 00082 if ( ! userName ) userName = gSystem->Getenv("USERNAME"); 00083 if ( ! userName ) userName = gSystem->Getenv("LOGNAME"); 00084 if ( userName ) fUserName = userName; 00085 00086 }
TDbiLogEntry::~TDbiLogEntry | ( | ) | [virtual] |
Definition at line 89 of file TDbiLogEntry.cxx.
TDbiLogEntry::TDbiLogEntry | ( | const TDbiLogEntry & | from | ) | [private] |
virtual Bool_t TDbiTableRow::CanL2Cache | ( | ) | const [inline, virtual, inherited] |
Replace this with a function returning true in order to use the level 2 disk cache.
Definition at line 59 of file TDbiTableRow.hxx.
virtual TDbiTableRow* TDbiLogEntry::CreateTableRow | ( | ) | const [inline, virtual] |
Implements TDbiTableRow.
Definition at line 70 of file TDbiLogEntry.hxx.
00070 { 00071 return new TDbiLogEntry; }
void TDbiLogEntry::Fill | ( | TDbiInRowStream & | rs, | |
const TDbiValidityRec * | vrec | |||
) | [virtual] |
Implements TDbiTableRow.
Definition at line 144 of file TDbiLogEntry.cxx.
References fHostName, fLogDetMask, fLogNumSeqNo, fLogSeqNoMax, fLogSeqNoMin, fLogSimMask, fLogTableName, fLogTask, fProcessName, fReason, fServerName, fUpdateTime, fUserName, TVldRange::GetDetectorMask(), TVldRange::GetSimMask(), TDbiValidityRec::GetTask(), TVldRange::GetTimeStart(), and TDbiValidityRec::GetVldRange().
00145 { 00146 // 00147 // 00148 // Purpose: Fill oject from Result Set 00149 00150 rs >> fLogTableName 00151 >> fLogSeqNoMin 00152 >> fLogSeqNoMax 00153 >> fLogNumSeqNo 00154 >> fUserName 00155 >> fProcessName 00156 >> fHostName 00157 >> fServerName 00158 >> fReason; 00159 fLogDetMask = fLogSimMask = fLogTask = 0; 00160 if ( vrec ) { 00161 fLogDetMask = vrec->GetVldRange().GetDetectorMask(); 00162 fLogSimMask = vrec->GetVldRange().GetSimMask(); 00163 fLogTask = vrec->GetTask(); 00164 fUpdateTime = vrec->GetVldRange().GetTimeStart(); 00165 } 00166 }
Int_t TDbiLogEntry::GetAggregateNo | ( | ) | const [inline, virtual] |
Reimplemented from TDbiTableRow.
Definition at line 72 of file TDbiLogEntry.hxx.
Int_t TDbiLogEntry::GetDetectorMask | ( | ) | const [inline] |
Definition at line 76 of file TDbiLogEntry.hxx.
References fLogDetMask.
Referenced by operator<<().
00076 { return fLogDetMask; }
const string& TDbiLogEntry::GetHostName | ( | ) | const [inline] |
Definition at line 84 of file TDbiLogEntry.hxx.
References fHostName.
Referenced by operator<<().
00084 { return fHostName; }
virtual UInt_t TDbiTableRow::GetIndex | ( | UInt_t | defIndex | ) | const [inline, virtual, inherited] |
Reimplemented in TDemo2_DB_Table, and TDemo_DB_Table.
Definition at line 65 of file TDbiTableRow.hxx.
Referenced by TDbiResultSet::BuildLookUpTable().
Int_t TDbiLogEntry::GetLogNumSeqNo | ( | ) | const [inline] |
Definition at line 79 of file TDbiLogEntry.hxx.
References fLogNumSeqNo.
Referenced by operator<<().
00079 { return fLogNumSeqNo; }
Int_t TDbiLogEntry::GetLogSeqNoMax | ( | ) | const [inline] |
Definition at line 78 of file TDbiLogEntry.hxx.
References fLogSeqNoMax.
Referenced by operator<<().
00078 { return fLogSeqNoMax; }
Int_t TDbiLogEntry::GetLogSeqNoMin | ( | ) | const [inline] |
Definition at line 77 of file TDbiLogEntry.hxx.
References fLogSeqNoMin.
Referenced by operator<<().
00077 { return fLogSeqNoMin; }
const string& TDbiLogEntry::GetLogTableName | ( | ) | const [inline] |
Definition at line 75 of file TDbiLogEntry.hxx.
References fLogTableName.
Referenced by operator<<().
00075 { return fLogTableName; }
TDbiResultSet* TDbiTableRow::GetOwner | ( | ) | const [inline, inherited] |
Definition at line 63 of file TDbiTableRow.hxx.
References TDbiTableRow::fOwner.
Referenced by TDbiResultSet::BuildLookUpTable(), and TDbiResultSetAgg::GetValidityRec().
00063 { return fOwner; }
const string& TDbiLogEntry::GetProcessName | ( | ) | const [inline] |
Definition at line 83 of file TDbiLogEntry.hxx.
References fProcessName.
Referenced by operator<<().
00083 { return fProcessName; }
const string& TDbiLogEntry::GetReason | ( | ) | const [inline] |
Definition at line 86 of file TDbiLogEntry.hxx.
References fReason.
Referenced by operator<<().
00086 { return fReason; }
const string& TDbiLogEntry::GetServerName | ( | ) | const [inline] |
Definition at line 85 of file TDbiLogEntry.hxx.
References fServerName.
Referenced by operator<<().
00085 { return fServerName; }
Int_t TDbiLogEntry::GetSimMask | ( | ) | const [inline] |
Definition at line 80 of file TDbiLogEntry.hxx.
References fLogSimMask.
Referenced by operator<<().
00080 { return fLogSimMask; }
TDbi::Task TDbiLogEntry::GetTask | ( | ) | const [inline] |
Definition at line 81 of file TDbiLogEntry.hxx.
References fLogTask.
Referenced by operator<<().
00081 { return fLogTask; }
TVldTimeStamp TDbiLogEntry::GetUpdateTime | ( | ) | const [inline] |
Definition at line 87 of file TDbiLogEntry.hxx.
References fUpdateTime.
Referenced by operator<<().
00087 { return fUpdateTime; }
const string& TDbiLogEntry::GetUserName | ( | ) | const [inline] |
Definition at line 82 of file TDbiLogEntry.hxx.
References fUserName.
Referenced by operator<<().
00082 { return fUserName; }
Bool_t TDbiLogEntry::HasReason | ( | ) | const [inline] |
Definition at line 89 of file TDbiLogEntry.hxx.
References fReason.
Referenced by Write().
00089 { return fReason.size() > 0; }
void TDbiLogEntry::Recreate | ( | const string & | tableName = "" , |
|
const string & | reason = "" , |
|||
Int_t | detMask = DbiDetector::FullMask() , |
|||
Int_t | simMask = DbiSimFlag::FullMask() , |
|||
TDbi::Task | task = 0 , |
|||
Int_t | logSeqNoMin = 0 , |
|||
Int_t | logSeqNoMax = 0 , |
|||
Int_t | logNumSeqNo = 0 | |||
) |
Definition at line 170 of file TDbiLogEntry.cxx.
References fDbNo, fLogDetMask, fLogNumSeqNo, fLogSeqNoMax, fLogSeqNoMin, fLogSimMask, fLogTableName, fLogTask, fSeqNo, DbiSimFlag::FullMask(), DbiDetector::FullMask(), and SetReason().
00178 { 00179 // 00180 // 00181 // Purpose: Recreate, unless new state consistent with old. 00182 00183 if ( fSeqNo > 0 00184 && ( tableName == "" || tableName == fLogTableName ) 00185 && ( detMask == DbiDetector::FullMask() || detMask == fLogDetMask ) 00186 && ( simMask == DbiSimFlag::FullMask() || simMask == fLogSimMask ) 00187 && ( task == 0 || task == fLogTask ) 00188 && ( logSeqNoMin == 0 || logSeqNoMin == fLogSeqNoMin) 00189 && ( logSeqNoMax == 0 || logSeqNoMax == fLogSeqNoMax ) 00190 && ( logNumSeqNo == 0 || logNumSeqNo == fLogNumSeqNo ) 00191 ) { 00192 if ( reason != "" ) this->SetReason(reason); 00193 return; 00194 } 00195 00196 00197 fDbNo = 0; 00198 fSeqNo =0; 00199 fLogTableName = tableName; 00200 fLogDetMask = detMask; 00201 fLogSimMask = simMask; 00202 fLogTask = task; 00203 fLogSeqNoMin = logSeqNoMin; 00204 fLogSeqNoMax = logSeqNoMax; 00205 fLogNumSeqNo = logNumSeqNo; 00206 this->SetReason(reason); 00207 00208 }
void TDbiLogEntry::SetDetectorMask | ( | Int_t | detMask | ) | [inline] |
Definition at line 93 of file TDbiLogEntry.hxx.
References fLogDetMask.
00093 { fLogDetMask = detMask; }
void TDbiTableRow::SetOwner | ( | TDbiResultSet * | owner | ) | [inline, inherited] |
Definition at line 68 of file TDbiTableRow.hxx.
References TDbiTableRow::fOwner.
Referenced by ClassImp().
00068 {fOwner = owner;}
void TDbiLogEntry::SetReason | ( | const string & | reason | ) |
Definition at line 212 of file TDbiLogEntry.cxx.
References fReason, and SK_DBI_Severe.
Referenced by Recreate(), and TDbiLogEntry().
00212 { 00213 // 00214 // 00215 // Purpose: Set reason. 00216 // String can be "@file-containing-reason" in which case 00217 // contents of file is used to define the reason excluding 00218 // any line begining:- 00219 // 00220 // FIXUP-FILE: 00221 // or BROADCAST: 00222 // 00223 // This allows DMauto fix-up files to provide log entries as well 00224 // as updates. 00225 00226 fReason = reason; 00227 00228 // If fReason starts '@' treat remainder as file name 00229 // to be read into fReason. 00230 if ( fReason.size() && fReason[0] == '@' ) { 00231 string fileName(fReason,1); 00232 fReason.clear(); 00233 ifstream reasonFile(fileName.c_str()); 00234 if ( ! reasonFile.is_open() ) { 00235 SK_DBI_Severe( "Cannot read \"Reason File\" " << fileName << " "); 00236 } 00237 else { 00238 string line; 00239 while ( ! reasonFile.eof() ) { 00240 getline(reasonFile,line); 00241 if ( line.substr(0,11) == "FIXUP-FILE:" 00242 || line.substr(0,10) == "BROADCAST:" ) { 00243 continue; 00244 } 00245 if ( fReason.size() ) fReason += '\n'; 00246 fReason += line; 00247 } 00248 reasonFile.close(); 00249 } 00250 } 00251 }
void TDbiLogEntry::SetServerName | ( | ) | [private] |
Definition at line 255 of file TDbiLogEntry.cxx.
References fDbNo, fServerName, TDbiDatabaseManager::GetCascader(), TDbiCascader::GetURL(), and TDbiDatabaseManager::Instance().
Referenced by TDbiLogEntry().
00255 { 00256 // 00257 // 00258 // Purpose: Set DB Server name from cascade number. 00259 00260 string urlStr = TDbiDatabaseManager::Instance().GetCascader().GetURL(fDbNo); 00261 TUrl url(urlStr.c_str()); 00262 fServerName = url.GetHost(); 00263 00264 }
void TDbiLogEntry::SetSimMask | ( | Int_t | simMask | ) | [inline] |
Definition at line 94 of file TDbiLogEntry.hxx.
References fLogSimMask.
00094 { fLogSimMask = simMask; }
void TDbiLogEntry::SetTask | ( | TDbi::Task | task | ) | [inline] |
void TDbiLogEntry::SetUpdateTime | ( | const TVldTimeStamp & | updateTime | ) | [inline] |
Definition at line 96 of file TDbiLogEntry.hxx.
References fUpdateTime.
00096 { 00097 fUpdateTime = updateTime; }
void TDbiLogEntry::Store | ( | TDbiOutRowStream & | ors, | |
const TDbiValidityRec * | vrec | |||
) | const [virtual] |
Reimplemented from TDbiTableRow.
Definition at line 267 of file TDbiLogEntry.cxx.
References fHostName, fLogNumSeqNo, fLogSeqNoMax, fLogSeqNoMin, fLogTableName, fProcessName, fReason, fServerName, and fUserName.
00268 { 00269 // 00270 // 00271 // Purpose: Stream object to output row stream 00272 00273 ors << fLogTableName 00274 << fLogSeqNoMin 00275 << fLogSeqNoMax 00276 << fLogNumSeqNo 00277 << fUserName 00278 << fProcessName 00279 << fHostName 00280 << fServerName 00281 << fReason; 00282 }
Bool_t TDbiLogEntry::Write | ( | UInt_t | dbNo, | |
Int_t | logSeqNo = 0 | |||
) |
Definition at line 286 of file TDbiLogEntry.cxx.
References TDbiSqlValPacket::AddDataRow(), TDbiCascader::AllocateSeqNo(), fDbNo, fLogDetMask, fLogNumSeqNo, fLogSeqNoMax, fLogSeqNoMin, fLogSimMask, fLogTask, fSeqNo, fUpdateTime, TDbiTableProxy::GetCascader(), TDbiValidityRec::GetCreationDate(), TDbiDatabaseManager::GetTableProxy(), TDbiValidityRec::GetTask(), TDbiValidityRec::GetVldRange(), HasReason(), TDbiDatabaseManager::Instance(), TDbiSqlValPacket::Recreate(), TDbiSqlValPacket::SetSeqNo(), SK_DBI_Severe, and TDbiSqlValPacket::Store().
00287 { 00288 // 00289 // 00290 // Purpose: Write, or rewrite this entry, adding logSeqNo to range of 00291 // update SEQNOs if non-zero. 00292 00293 if ( logSeqNo > 0 ) { 00294 if ( fLogNumSeqNo == 0 ) { 00295 fLogSeqNoMin = logSeqNo; 00296 fLogSeqNoMax = logSeqNo; 00297 } 00298 if ( logSeqNo < fLogSeqNoMin ) fLogSeqNoMin = logSeqNo; 00299 if ( logSeqNo > fLogSeqNoMax ) fLogSeqNoMax = logSeqNo; 00300 ++fLogNumSeqNo; 00301 } 00302 00303 if ( ! this->HasReason() || fLogNumSeqNo == 0) { 00304 SK_DBI_Severe( "Cannot write LogEntry - no reason and/or no SEQNOs defined " 00305 << " "); 00306 return kFALSE; 00307 } 00308 00309 if ( fSeqNo != 0 && dbNo != fDbNo ) { 00310 SK_DBI_Severe( "Cannot write LogEntry - attempting to switch from database" 00311 << fDbNo << " to " << dbNo << " "); 00312 return kFALSE; 00313 } 00314 00315 fDbNo = dbNo; 00316 TDbiTableProxy& tblProxy = TDbiDatabaseManager::Instance() 00317 .GetTableProxy("DBILOGENTRY",this); 00318 bool replace = true; 00319 00320 // Allocate SEQNO before first write. 00321 if ( fSeqNo == 0 ) { 00322 replace = false; 00323 int seqNo = tblProxy.GetCascader().AllocateSeqNo("DBILOGENTRY",0,fDbNo); 00324 if ( seqNo <= 0 ) { 00325 SK_DBI_Severe( "Cannot get sequence number for table DBILOGENTRY" << " "); 00326 return kFALSE; 00327 } 00328 fSeqNo = seqNo; 00329 } 00330 00331 // Construct a TDbiValidityRec. 00332 TVldRange vr(fLogDetMask,fLogSimMask,fUpdateTime,fUpdateTime,"TDbiLogEntry"); 00333 TDbiValidityRec vrec(vr,fLogTask,-1,0); 00334 00335 // Now build and output TDbiSqlValPacket. 00336 TDbiSqlValPacket packet; 00337 packet.Recreate("DBILOGENTRY", 00338 vrec.GetVldRange(), 00339 -1, 00340 vrec.GetTask(), 00341 vrec.GetCreationDate()); 00342 packet.AddDataRow(tblProxy,0,*this); 00343 packet.SetSeqNo(fSeqNo); 00344 return packet.Store(fDbNo,replace); 00345 ; 00346 }
UInt_t TDbiLogEntry::fDbNo [private] |
Database no. written to. =0 if not output.
Definition at line 123 of file TDbiLogEntry.hxx.
Referenced by Recreate(), SetServerName(), and Write().
string TDbiLogEntry::fHostName [private] |
Host performing update.
Definition at line 159 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetHostName(), and Store().
Int_t TDbiLogEntry::fLogDetMask [private] |
Detector type mask of update.
Definition at line 132 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetDetectorMask(), Recreate(), SetDetectorMask(), and Write().
Int_t TDbiLogEntry::fLogNumSeqNo [private] |
Number of Seq. Nos. being updated.
Definition at line 147 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetLogNumSeqNo(), Recreate(), Store(), TDbiLogEntry(), and Write().
Int_t TDbiLogEntry::fLogSeqNoMax [private] |
Maximum Seq. No. being updated.
Definition at line 144 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetLogSeqNoMax(), Recreate(), Store(), TDbiLogEntry(), and Write().
Int_t TDbiLogEntry::fLogSeqNoMin [private] |
Minimum Seq. No. being updated.
Definition at line 141 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetLogSeqNoMin(), Recreate(), Store(), TDbiLogEntry(), and Write().
Int_t TDbiLogEntry::fLogSimMask [private] |
SimFlag mask of update.
Definition at line 135 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetSimMask(), Recreate(), SetSimMask(), and Write().
string TDbiLogEntry::fLogTableName [private] |
Table being updated.
Definition at line 129 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetLogTableName(), Recreate(), and Store().
TDbi::Task TDbiLogEntry::fLogTask [private] |
Task of update.
Definition at line 138 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetTask(), Recreate(), SetTask(), and Write().
string TDbiLogEntry::fProcessName [private] |
Process performing update.
Definition at line 156 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetProcessName(), and Store().
string TDbiLogEntry::fReason [private] |
Reason for update.
Definition at line 165 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetReason(), HasReason(), SetReason(), and Store().
Int_t TDbiLogEntry::fSeqNo [private] |
Seq. No. used to write this object. =0 if not output.
Definition at line 126 of file TDbiLogEntry.hxx.
Referenced by Recreate(), and Write().
string TDbiLogEntry::fServerName [private] |
Db server being updated.
Definition at line 162 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetServerName(), SetServerName(), and Store().
TVldTimeStamp TDbiLogEntry::fUpdateTime [private] |
Time of update.
Definition at line 150 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetUpdateTime(), SetUpdateTime(), and Write().
string TDbiLogEntry::fUserName [private] |
User performing update.
Definition at line 153 of file TDbiLogEntry.hxx.
Referenced by Fill(), GetUserName(), Store(), and TDbiLogEntry().