#include <bea_volumereader.h>


Definition at line 23 of file bea_volumereader.h.
Public Member Functions | |
| bea_VolumeReader (df_BlockManager &a_blkMgr, bea_Volume *const a_medVol_p, bool &a_fmDetected) | |
| virtual | ~bea_VolumeReader () |
Protected Member Functions | |
| virtual void | Run (void *a_arg) |
Protected Attributes | |
| df_MgrWriter | m_mgrWriter |
| bea_Volume *const | m_medVol_p |
| bool & | m_fmDetected |
Private Attributes | |
| log_CLASSID_m | |
| bea_VolumeReader::bea_VolumeReader | ( | df_BlockManager & | a_blkMgr, | |
| bea_Volume *const | a_medVol_p, | |||
| bool & | a_fmDetected | |||
| ) |
Definition at line 32 of file bea_volumereader.cpp.
References log_FUNC_m.
00036 : m_mgrWriter(a_blkMgr), 00037 m_medVol_p(a_medVol_p), 00038 m_fmDetected(a_fmDetected) { 00039 00040 log_FUNC_m(bea_VolumeReader); 00041 }
| bea_VolumeReader::~bea_VolumeReader | ( | ) | [virtual] |
Definition at line 43 of file bea_volumereader.cpp.
References log_FUNC_m.
00043 { 00044 log_FUNC_m(~bea_VolumeReader); 00045 }
| void bea_VolumeReader::Run | ( | void * | a_arg | ) | [protected, virtual] |
Reimplemented from cmn_Thread.
Definition at line 47 of file bea_volumereader.cpp.
References dbg_DETAIL, dbg_LOW, dbg_NORM, bea_Volume::DoMediumLogging(), df_MgrWriter::Flush(), bea_Medium::GetBarcode(), ivd_BaseException::GetContext(), ivd_BaseException::GetDetailed(), ivd_BaseException::GetError(), df_MgrWriter::GetFree(), df_DataBlock::GetFreeSize(), bea_Volume::GetJobID(), bea_Volume::GetMedium(), cmn_Time::GetMilliTime(), df_DataBlock::GetPosition(), bea_Volume::GetPosition(), cmn_Time::GetTime_t(), bea_Volume::GetVolumeID(), bea_Volume::GetVolumeNumber(), ie_DATA_CORRUPTION, ie_MEDIUM_EOD, ie_MEDIUM_EOM, ie_MEDIUM_FILEMARK, ivd_Error, log_DBG_m, log_FUNC_m, log_MARKLINE_m, log_WriteEvent(), m_fmDetected, m_medVol_p, m_mgrWriter, df_DataBlock::Move(), NULL, bea_Volume::Read(), df_DataBlock::SetBlockID(), and df_MgrWriter::SetError().
00047 { 00048 log_FUNC_m(Run); 00049 00050 log_DBG_m(dbg_LOW, "Medium reader thread started."); 00051 00052 UInt32_t blocks(0); 00053 UInt64_t friSize(0); 00054 UInt32_t pos(m_medVol_p->GetPosition()); 00055 const UInt32_t positionCheckInterval_c(10000); 00056 00057 cmn_Time startTime; 00058 00059 try { 00060 while(true) { 00061 df_DataBlock *blk = m_mgrWriter.GetFree(); 00062 if (blk == NULL) { 00063 log_DBG_m(dbg_NORM, "Readers went down. Finish writing."); 00064 break; 00065 } 00066 00067 UInt8_t *buf (blk->GetPosition()); 00068 UInt32_t bufSize (blk->GetFreeSize()); 00069 00070 if ( (pos % positionCheckInterval_c) == 0) { 00071 UInt32_t mediumPos(m_medVol_p->GetPosition()); 00072 log_DBG_m(dbg_NORM, 00073 "Verifying position. " << 00074 "Counted : " << pos << 00075 "Actual : " << mediumPos); 00076 00077 if (pos != mediumPos) { 00078 log_MARKLINE_m; 00079 ostringstream sstr; 00080 sstr 00081 << "Counted medium position (" << pos << ")" 00082 << " is different from actual (" << mediumPos << "). " 00083 << "Job: " << m_medVol_p->GetJobID() 00084 << "Medium/volume: " 00085 << m_medVol_p->GetMedium()->GetBarcode() << "/" 00086 << m_medVol_p->GetVolumeNumber(); 00087 00088 throw ivd_InternalError(ie_DATA_CORRUPTION, sstr.str()); 00089 } 00090 } 00091 00092 blk->SetBlockID(pos); 00093 log_DBG_m(dbg_DETAIL, "Medium read position: " << pos); 00094 try { 00095 // medium drive has block size already specified 00096 // and will read block_size bytes to the allocated buffer 00097 // BEA's block size MUST be the same as used here otherwise 00098 // it is a BUG. 00099 m_medVol_p->Read(buf); 00100 ++blocks, ++pos; 00101 friSize += bufSize; 00102 blk->Move(bufSize); 00103 m_mgrWriter.Flush(); 00104 } 00105 catch (const ivd_Error &ie) { 00106 switch (ie.GetError()) { 00107 case ie_MEDIUM_FILEMARK: 00108 // File mark increases position. 00109 m_fmDetected = true, ++pos; 00110 log_DBG_m(dbg_LOW, 00111 "File mark detected ==> stop reading data."); 00112 goto STOP; 00113 break; 00114 case ie_MEDIUM_EOD: 00115 log_DBG_m(dbg_LOW, 00116 "End of data detected ==> stop reading data."); 00117 goto STOP; 00118 break; 00119 case ie_MEDIUM_EOM: 00120 log_DBG_m(dbg_LOW, 00121 "Early end of medium detected ==> continue."); 00122 break; 00123 00124 default: 00125 log_DBG_m(dbg_LOW, 00126 "Unknown exception while reading FRI ==> re-throw."); 00127 m_mgrWriter.SetError( 00128 new ivd_Error( 00129 ie.GetError(), ie.GetContext(), ie.GetDetailed()) ); 00130 throw; 00131 } 00132 } 00133 catch (ivd_SysError &ie) { 00134 m_mgrWriter.SetError( 00135 new ivd_SysError( 00136 ie.GetError(), ie.GetContext(), ie.GetDetailed()) ); 00137 throw; 00138 } 00139 catch (ivd_Exception &ie) { 00140 m_mgrWriter.SetError( 00141 new ivd_Error( 00142 ie.GetError(), ie.GetContext(), ie.GetDetailed()) ); 00143 throw; 00144 } 00145 }; 00146 STOP: 00147 log_DBG_m(dbg_DETAIL, "End of reading the data."); 00148 00149 if (pos % positionCheckInterval_c) { 00150 UInt32_t mediumPos(m_medVol_p->GetPosition()); 00151 log_DBG_m(dbg_NORM, 00152 "Verifying position. " << 00153 "Counted: " << pos << 00154 "Actual: " << mediumPos); 00155 00156 if (pos != mediumPos) { 00157 log_MARKLINE_m; 00158 ostringstream sstr; 00159 sstr 00160 << "Counted medium position (" << pos << ")" 00161 << " is different from actual (" << mediumPos << "). " 00162 << "Job: " << m_medVol_p->GetJobID() 00163 << "Medium/volume: " 00164 << m_medVol_p->GetMedium()->GetBarcode() << "/" 00165 << m_medVol_p->GetVolumeNumber(); 00166 00167 throw ivd_InternalError(ie_DATA_CORRUPTION, sstr.str()); 00168 } 00169 } 00170 } 00171 catch (ivd_Error &ie) { 00172 log_DBG_m(dbg_LOW, 00173 "Problems reading from medium drive. Thread going down." << endl << 00174 "Error: " << ie); 00175 } 00176 catch (ivd_BaseException &ie) { 00177 log_DBG_m(dbg_LOW, 00178 "Problems reading from medium drive. Thread going down." << 00179 "Error: " << ie); 00180 } 00181 catch (std::exception &se) { 00182 log_DBG_m(dbg_LOW, 00183 "Problems reading from medium drive. Thread going down." << 00184 "std::exception: " << se.what() ); 00185 }; 00186 00187 cmn_Time endTime; 00188 cmn_Time diffTime = endTime - startTime; 00189 00190 UInt64_t msecDiff = 00191 UInt64_t(diffTime.GetTime_t()) * 1000 + 00192 diffTime.GetMilliTime(); 00193 00194 if (msecDiff == 0) { 00195 msecDiff = 1; 00196 } 00197 00198 UInt64_t speed = (friSize * 1000) / (msecDiff * 1024); 00199 00200 if (m_medVol_p->DoMediumLogging()) { 00201 // log recreate FRI statistics 00202 ostringstream sstr; 00203 sstr 00204 << "Vol " << m_medVol_p->GetVolumeNumber() 00205 << ": FRI recreated for " << m_medVol_p->GetVolumeID() 00206 << " : " << friSize / 1024 << " KB (" << speed << " KB/s)."; 00207 00208 log_WriteEvent( 00209 sstr.str(), "", 00210 m_medVol_p->GetJobID(), 00211 m_medVol_p->GetMedium()->GetBarcode()); 00212 } 00213 00214 log_DBG_m(dbg_LOW, 00215 "Read " << blocks << " blocks from medium."); 00216 00217 log_DBG_m(dbg_LOW,"End of data."); 00218 }

df_MgrWriter bea_VolumeReader::m_mgrWriter [protected] |
bea_Volume* const bea_VolumeReader::m_medVol_p [protected] |
bool& bea_VolumeReader::m_fmDetected [protected] |
bea_VolumeReader::log_CLASSID_m [private] |
1.5.6