#include <bea_fri.h>


Definition at line 75 of file bea_fri.h.
Public Member Functions | |
| bea_FRIThread (i_BackEndAgent_i &a_bea, bea_Drive *const a_drive, const i_VolInfoList_t &a_volumes, UInt32_t a_sysVolNum, bool a_create, bool a_recovery=true, i_SysVolAction_e a_svAction=i_SV_NOTHING) | |
| bea_FRIThread (i_BackEndAgent_i &a_bea, bea_Drive *const a_drive, const i_VolInfoList_t &a_volumes, UInt32_t a_sysVolNum, bool a_create, const i_BoolList_t &a_openVolList, bool a_recovery=true, i_SysVolAction_e a_svAction=i_SV_NOTHING, bool a_recreateInto=false, cmn_Path a_intoPath="") | |
| virtual | ~bea_FRIThread () |
| virtual void | Run (void *arg) |
| void | EraseSysVol () |
| string | SetWorkDir () |
| void | CreateFRI (bea_Volume *const a_vol, bool a_closed, cmn_Path &a_workDir) |
| bool | IsClosed (bea_Volume *const a_vol) |
| bool | CheckFRI (bea_Volume *const a_vol, bea_Medium *a_med, cmn_Path &a_workDir) |
| void | ReadFRI (bea_Volume *const a_vol, cmn_Path &a_workDir) |
Private Member Functions | |
| void | ReadFromSysVol () |
| void | ProcessFromDataVol () |
Private Attributes | |
| log_CLASSID_m | |
| i_BackEndAgent_i & | m_bea |
| bea_Drive *const | m_drive_p |
| i_VolInfoList_t | m_volumes |
| UInt32_t | m_sysVolNum |
| bool | m_create |
| const i_BoolList_t | m_openVolList |
| bool | m_recovery |
| i_SysVolAction_e | m_svAction |
| bool | m_recreateInto |
| cmn_Path | m_intoPath |
| i_CompletionStatus_e | m_status |
| bea_FRIThread::bea_FRIThread | ( | i_BackEndAgent_i & | a_bea, | |
| bea_Drive *const | a_drive, | |||
| const i_VolInfoList_t & | a_volumes, | |||
| UInt32_t | a_sysVolNum, | |||
| bool | a_create, | |||
| bool | a_recovery = true, |
|||
| i_SysVolAction_e | a_svAction = i_SV_NOTHING | |||
| ) |
Definition at line 41 of file bea_frithread.cpp.
References cmn_ThreadCounter::Inc(), log_FUNC_m, m_bea, and i_BackEndAgent_i::m_threadCounter.
00050 : m_bea(a_bea), 00051 m_drive_p(a_drive_p), 00052 m_volumes(a_volumes), 00053 m_sysVolNum(a_sysVolNum), 00054 m_create(a_create), 00055 m_recovery(a_recovery), 00056 m_svAction(a_svAction), 00057 m_recreateInto(false), 00058 m_status(i_UNKNOWN) 00059 { 00060 00061 log_FUNC_m(bea_FRIThread); 00062 00063 m_bea.m_threadCounter.Inc(); 00064 }

| bea_FRIThread::bea_FRIThread | ( | i_BackEndAgent_i & | a_bea, | |
| bea_Drive *const | a_drive, | |||
| const i_VolInfoList_t & | a_volumes, | |||
| UInt32_t | a_sysVolNum, | |||
| bool | a_create, | |||
| const i_BoolList_t & | a_openVolList, | |||
| bool | a_recovery = true, |
|||
| i_SysVolAction_e | a_svAction = i_SV_NOTHING, |
|||
| bool | a_recreateInto = false, |
|||
| cmn_Path | a_intoPath = "" | |||
| ) |
Definition at line 68 of file bea_frithread.cpp.
References cmn_CreatePathNoException(), dbg_NORM, cmn_ThreadCounter::Inc(), log_DBG_m, log_FUNC_m, log_WRN_m, m_bea, m_intoPath, m_recreateInto, and i_BackEndAgent_i::m_threadCounter.
00080 : m_bea(a_bea), 00081 m_drive_p(a_drive_p), 00082 m_volumes(a_volumes), 00083 m_sysVolNum(a_sysVolNum), 00084 m_create(a_create), 00085 m_openVolList(a_openVolList), 00086 m_recovery(a_recovery), 00087 m_svAction(a_svAction), 00088 m_recreateInto(a_recreateInto), 00089 m_intoPath(a_intoPath), 00090 m_status(i_UNKNOWN) { 00091 00092 log_FUNC_m(bea_FRIThread); 00093 00094 // Create path 00095 UInt32_t res = cmn_CreatePathNoException(m_intoPath); 00096 log_DBG_m(dbg_NORM, "Path " << m_intoPath << " created."); 00097 log_DBG_m(dbg_NORM, "m_recreateInto " << boolalpha << m_recreateInto); 00098 00099 if (res != 0) { 00100 log_WRN_m("Creating Path failed.") 00101 } 00102 00103 m_bea.m_threadCounter.Inc(); 00104 }

| bea_FRIThread::~bea_FRIThread | ( | ) | [virtual] |
Definition at line 107 of file bea_frithread.cpp.
References dbg_LOW, cmn_ThreadCounter::Dec(), i_BackEndAgent_i::GetBEANumber(), i_BackEndAgent_i::GetJob(), i_HW_ERROR, i_MEDIUM_ERROR, i_SUCCEDED, ipc_EXEC_m, i_BackEndAgent_i::IsAborted(), log_DBG_m, log_FUNC_m, m_bea, m_recovery, m_status, and i_BackEndAgent_i::m_threadCounter.
00107 { 00108 00109 log_FUNC_m(~bea_FRIThread); 00110 00111 if (m_recovery) { 00112 // Complete job 00113 00114 if (m_status != i_MEDIUM_ERROR && m_status != i_HW_ERROR) { 00115 log_DBG_m(dbg_LOW, 00116 "Non hardware and non medium errors are not reported to job."); 00117 m_status = i_SUCCEDED; 00118 } 00119 00120 try { 00121 if (m_bea.IsAborted()) { 00122 log_DBG_m(dbg_LOW, "FRI job aborted. Won't contact job."); 00123 } 00124 else { 00125 ipc_EXEC_m( 00126 if( !CORBA::is_nil(m_bea.GetJob()) ) { 00127 log_DBG_m(dbg_LOW, "Completion status: " << m_status); 00128 i_Job_var job = m_bea.GetJob(); 00129 job->MediumOperationComplete(m_bea.GetBEANumber(), m_status); 00130 }; 00131 ); 00132 } 00133 } 00134 catch(...) { 00135 // Ignore all exceptions at this point. 00136 } 00137 } 00138 else { 00139 log_DBG_m(dbg_LOW, 00140 "Not in recovery more --> Will not call MediumOperationComplete()."); 00141 } 00142 00143 m_bea.m_threadCounter.Dec(); 00144 }

| void bea_FRIThread::Run | ( | void * | arg | ) | [virtual] |
Reimplemented from cmn_Thread.
Definition at line 148 of file bea_frithread.cpp.
References bea_OPREAD, dbg_DETAIL, dbg_LOW, evt_ERROR, i_BackEndAgent_i::GetBarcode(), i_BackEndAgent_i::GetJobID(), i_BackEndAgent_i::HandleError(), i_SUCCEDED, i_UNKNOWN, log_DBG_m, log_FUNC_m, log_WriteEvent(), m_bea, m_create, m_recovery, m_recreateInto, m_status, ProcessFromDataVol(), and ReadFromSysVol().
00148 { 00149 log_FUNC_m(Run); 00150 00151 try { 00152 if (!m_recreateInto){ 00153 if (!m_create) { 00154 ReadFromSysVol(); 00155 } 00156 ProcessFromDataVol(); 00157 } else { 00158 ReadFromSysVol(); 00159 ProcessFromDataVol(); 00160 } 00161 m_status = i_SUCCEDED; 00162 log_DBG_m(dbg_LOW, "Completed FRI handling."); 00163 } 00164 catch(ivd_Error &ie) { 00165 m_status = m_bea.HandleError(ie, bea_OPREAD); 00166 if (!m_recovery) { 00167 log_DBG_m(dbg_DETAIL, 00168 "Not in recovery. Throw the exception down the stack."); 00169 throw; 00170 } 00171 } 00172 catch(const std::exception& ie) { 00173 ostringstream sstr; 00174 sstr << "Operation failed: " << ie.what(); 00175 00176 log_WriteEvent(evt_ERROR, sstr.str(), "", 00177 m_bea.GetJobID(), m_bea.GetBarcode() ); 00178 00179 if (m_status == i_SUCCEDED) { 00180 m_status = i_UNKNOWN; 00181 } 00182 if (!m_recovery) { 00183 log_DBG_m(dbg_DETAIL, 00184 "Not in recovery. Throw the exception down the stack."); 00185 throw; 00186 } 00187 } 00188 catch(...) { 00189 log_WriteEvent(evt_ERROR, "Operation failed. Unknown error.", "", 00190 m_bea.GetJobID(), m_bea.GetBarcode() ); 00191 00192 if (m_status == i_SUCCEDED) { 00193 m_status = i_UNKNOWN; 00194 } 00195 if (!m_recovery) { 00196 log_DBG_m(dbg_DETAIL, 00197 "Not in recovery. Throw the exception down the stack."); 00198 throw; 00199 } 00200 } 00201 }

| void bea_FRIThread::EraseSysVol | ( | ) |
Definition at line 460 of file bea_frithread.cpp.
References bea_Medium::ChangeVolume(), dbg_LOW, i_BackEndAgent_i::GetBarcode(), bea_Medium::GetBarcode(), i_BackEndAgent_i::GetJobID(), bea_Drive::GetMedium(), bea_Medium::GetSysVolNumber(), bea_Medium::GetVolume(), i_SV_OVERWRITE, i_SV_REPLACE, bea_Medium::IsWORM(), log_DBG_m, log_FUNC_m, log_WriteEvent(), m_bea, m_create, m_drive_p, m_svAction, i_BackEndAgent_i::SysVolErased(), and i_BackEndAgent_i::WasSysVolErased().
Referenced by ProcessFromDataVol().
00460 { 00461 log_FUNC_m(EraseSysVol); 00462 bea_Medium* med = m_drive_p->GetMedium(); 00463 if (m_create && !m_bea.WasSysVolErased()) { 00464 if (med->IsWORM()) { 00465 log_DBG_m(dbg_LOW, "System volume on WORM medium won't be erased."); 00466 } 00467 else if (m_svAction == i_SV_OVERWRITE) { 00468 if (med->GetSysVolNumber() > 0) { 00469 00470 // TODO: Check system volume ID! 00471 00472 ostringstream sstr; 00473 sstr 00474 << "Erasing system volume on medium " 00475 << med->GetBarcode(); 00476 00477 log_WriteEvent(sstr.str(), "FRI", 00478 m_bea.GetJobID(), m_bea.GetBarcode() ); 00479 00480 bea_Volume *const sv = med->GetVolume(med->GetSysVolNumber()); 00481 med->ChangeVolume(med->GetSysVolNumber()); 00482 sv->Rewind(); 00483 sv->SeekFileMark(1); 00484 sv->Erase(); 00485 00486 m_bea.SysVolErased(); 00487 } 00488 } 00489 else if (m_svAction == i_SV_REPLACE) { 00490 // *************************************** 00491 // Replace shall copy the contents of 00492 // current system volume to the disk 00493 // and replace only those FRIs that 00494 // have been created. 00495 // Current implementation behaves just like 00496 // i_SV_OVERWRITE. 00497 // *************************************** 00498 if (med->GetSysVolNumber() > 0) { 00499 00500 // TODO: Check system volume ID! 00501 00502 ostringstream sstr; 00503 sstr 00504 << "Erasing system volume on medium " 00505 << med->GetBarcode(); 00506 00507 log_WriteEvent(sstr.str(), "FRI", 00508 m_bea.GetJobID(), m_bea.GetBarcode() ); 00509 00510 bea_Volume *const sv = med->GetVolume(med->GetSysVolNumber()); 00511 med->ChangeVolume(med->GetSysVolNumber()); 00512 sv->Rewind(); 00513 sv->SeekFileMark(1); 00514 sv->Erase(); 00515 00516 m_bea.SysVolErased(); 00517 } 00518 } 00519 } 00520 }


| string bea_FRIThread::SetWorkDir | ( | ) |
Definition at line 524 of file bea_frithread.cpp.
References cmn_Global::dirs, ivd_Directories::fri, g_cmn, log_FUNC_m, m_intoPath, m_recovery, m_recreateInto, and ivd_Directories::tmp.
Referenced by ProcessFromDataVol(), and ReadFromSysVol().
00524 { 00525 log_FUNC_m(SetWorkDir); 00526 00527 if (m_recreateInto){ 00528 return m_intoPath; 00529 } else { 00530 if (m_recovery) { 00531 return g_cmn.dirs.tmp + cmn_Path("fri"); 00532 } else { 00533 return g_cmn.dirs.fri; 00534 } 00535 } 00536 00537 }

| void bea_FRIThread::CreateFRI | ( | bea_Volume *const | a_vol, | |
| bool | a_closed, | |||
| cmn_Path & | a_workDir | |||
| ) |
Definition at line 540 of file bea_frithread.cpp.
References bea_FRI::CreateFRI(), friAppendRecreated_c(), log_FUNC_m, m_bea, and m_recreateInto.
Referenced by ProcessFromDataVol().
00540 { 00541 log_FUNC_m(CreateFRI); 00542 bea_FRI fri(m_bea, a_vol, a_workDir, m_recreateInto, friAppendRecreated_c); 00543 fri.CreateFRI(a_closed); 00544 }


| bool bea_FRIThread::IsClosed | ( | bea_Volume *const | a_vol | ) |
Definition at line 547 of file bea_frithread.cpp.
References i_BackEndAgent_i::GetBarcode(), i_BackEndAgent_i::GetRM(), bea_Volume::GetVolumeNumber(), ipc_EXEC_m, log_FUNC_m, m_bea, m_openVolList, and rmdb_MEDVOL_FULL.
Referenced by ProcessFromDataVol().
00547 { 00548 log_FUNC_m(IsClosed); 00549 bool closed(false); 00550 // Check the passed list of volumes first 00551 if (m_openVolList.length() > a_vol->GetVolumeNumber()) { 00552 closed = !m_openVolList[a_vol->GetVolumeNumber()]; 00553 } 00554 else { 00555 i_MediumVol_t_var rmvol; 00556 ipc_EXEC_m( 00557 i_ResourceManager_var rm = m_bea.GetRM(); 00558 rmvol = rm->SelectMediumVol( 00559 CORBA::string_dup(m_bea.GetBarcode().c_str()), 00560 a_vol->GetVolumeNumber()); 00561 ); 00562 closed = (rmvol->status & rmdb_MEDVOL_FULL) == rmdb_MEDVOL_FULL; 00563 } 00564 return closed; 00565 }


| bool bea_FRIThread::CheckFRI | ( | bea_Volume *const | a_vol, | |
| bea_Medium * | a_med, | |||
| cmn_Path & | a_workDir | |||
| ) |
Definition at line 569 of file bea_frithread.cpp.
References cmn_UUID_t::Clear(), dbg_LOW, bea_FRI::DeleteFRIOnVolume(), evt_WARNING, i_BackEndAgent_i::GetBarcode(), bea_Medium::GetBarcode(), ivd_BaseException::GetFriendly(), i_BackEndAgent_i::GetJobID(), bea_Volume::GetVolumeID(), bea_Volume::GetVolumeNumber(), cmn_UUID_t::IsNull(), log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), log_WRN_m, m_bea, m_create, bea_FRI::PositionToStartOfFRI(), and bea_FRI::ReadFRIStart().
Referenced by ProcessFromDataVol().
00569 { 00570 log_FUNC_m(CheckFRI); 00571 00572 bea_FRI fri(m_bea, a_vol, a_workDir); 00573 00574 try { 00575 // Position to the beginning of FRI or the end of medium 00576 bool atFRI = fri.PositionToStartOfFRI(); 00577 if (!m_create && !atFRI) { 00578 log_DBG_m(dbg_LOW, 00579 "No FRI on volume to be read: " << a_vol->GetVolumeNumber()); 00580 return true; 00581 } 00582 } 00583 catch (const ivd_Exception& ie) { 00584 log_ERR_m( 00585 "Can't position to FRI: " << 00586 a_med->GetBarcode() << "/" << a_vol->GetVolumeNumber() << endl << 00587 ". Error: " << ie.GetFriendly() << endl << 00588 " Will try with next volume on the medium."); 00589 00590 return true; 00591 } 00592 00593 cmn_UUID_t volUUID; 00594 volUUID.Clear(); 00595 if (fri.ReadFRIStart(volUUID) == true) { 00596 log_WRN_m("FRI filemark on volume, but no FRI. " << 00597 a_med->GetBarcode() << "/" << a_vol->GetVolumeNumber() << endl << 00598 " Will try with next volume on the medium."); 00599 return true; 00600 } 00601 00602 if (volUUID.IsNull()) { 00603 log_DBG_m(dbg_LOW, "No volume UUID read. Continue."); 00604 return true; 00605 } 00606 else if (a_vol->GetVolumeID() != volUUID) { 00607 ostringstream sstr; 00608 sstr 00609 << "Vol " << a_vol->GetVolumeNumber() << ": " 00610 << "Found FRI of wrong volume. Expected ID: " 00611 << a_vol->GetVolumeID() << ", found " 00612 << volUUID; 00613 00614 log_WriteEvent(evt_WARNING, sstr.str(), "FRI", 00615 m_bea.GetJobID(), m_bea.GetBarcode() ); 00616 00617 fri.DeleteFRIOnVolume(); 00618 return true; 00619 } 00620 log_DBG_m(dbg_LOW, "OK."); 00621 return false; 00622 }


| void bea_FRIThread::ReadFRI | ( | bea_Volume *const | a_vol, | |
| cmn_Path & | a_workDir | |||
| ) |
Definition at line 627 of file bea_frithread.cpp.
References evt_WARNING, friAppendDataVol_c(), i_BackEndAgent_i::GetBarcode(), i_BackEndAgent_i::GetJobID(), bea_Volume::GetPosition(), bea_Volume::GetVolumeID(), bea_Volume::GetVolumeNumber(), log_FUNC_m, log_WriteEvent(), m_bea, m_recreateInto, bea_FRI::ReadFRI(), and bea_Volume::SeekBlock().
Referenced by ProcessFromDataVol().
00627 { 00628 log_FUNC_m(ReadFRI); 00629 00630 bea_FRI fri(m_bea, a_vol, a_workDir, m_recreateInto, friAppendDataVol_c); 00631 00632 // Seek back to the start of FRI 00633 a_vol->SeekBlock(a_vol->GetPosition() - 1); 00634 00635 bool filemark = fri.ReadFRI(a_vol->GetVolumeID()); 00636 00637 if (filemark) { 00638 ostringstream sstr; 00639 sstr 00640 << "Vol " << a_vol->GetVolumeNumber() << ": " 00641 << "Found unexpected file mark after the FRI."; 00642 00643 log_WriteEvent(evt_WARNING, sstr.str(), "FRI", 00644 m_bea.GetJobID(), m_bea.GetBarcode() ); 00645 00646 // TODO: Delete FRI on data volume if filemark? 00647 } 00648 00649 // TODO: Shall exceptions from ReadFRI (medium/HW errors) be caught 00650 // and continue with FRI on the next volume. 00651 00652 00653 }


| void bea_FRIThread::ReadFromSysVol | ( | ) | [private] |
Definition at line 205 of file bea_frithread.cpp.
References bea_Medium::ChangeVolume(), cmn_UUID_t::Clear(), dbg_DETAIL, dbg_LOW, friAppendSysVol_c(), i_BackEndAgent_i::GetBEANumber(), bea_Medium::GetCurrentVolume(), ivd_BaseException::GetError(), i_BackEndAgent_i::GetJob(), i_BackEndAgent_i::GetJobID(), bea_Drive::GetMedium(), bea_Volume::GetPosition(), bea_Medium::GetSysVolNumber(), ie_MEDIUM_EOD, ipc_EXEC_m, i_BackEndAgent_i::IsAborted(), cmn_UUID_t::IsNull(), bea_Volume::IsSysVolume(), log_DBG_m, log_FUNC_m, m_bea, m_drive_p, m_recreateInto, m_sysVolNum, m_volumes, bea_FRI::ReadFRI(), bea_FRI::ReadFRIStart(), bea_Volume::ReadVolInfoFromHeader(), bea_Volume::Rewind(), bea_Volume::SeekBlock(), bea_Volume::SeekFileMark(), SetWorkDir(), and i_BackEndAgent_i::WaitForResources().
Referenced by Run().
00205 { 00206 log_FUNC_m(ReadFromSysVol); 00207 00208 log_DBG_m(dbg_LOW, 00209 "Started reading FRI from system volume. Job ID: " << m_bea.GetJobID()); 00210 00211 m_bea.WaitForResources(); 00212 00213 if (m_bea.IsAborted()) { 00214 log_DBG_m(dbg_LOW, "Job aborted. Exit."); 00215 return; 00216 }; 00217 00218 bea_Medium* med = m_drive_p->GetMedium(); 00219 if (med->GetSysVolNumber() != 0) { 00220 // Try the on-medium info first 00221 med->ChangeVolume(med->GetSysVolNumber()); 00222 } 00223 else if (m_sysVolNum > 0) { 00224 // Try the passed number second 00225 med->ChangeVolume(m_sysVolNum); 00226 med->GetCurrentVolume()->ReadVolInfoFromHeader(); 00227 } 00228 00229 bea_Volume *const vol = med->GetCurrentVolume(); 00230 if (!vol->IsSysVolume()) { 00231 log_DBG_m(dbg_LOW, "No system volume on the medium."); 00232 return; 00233 } 00234 00235 vol->Rewind(); 00236 00237 cmn_Path workDir = SetWorkDir(); 00238 00239 log_DBG_m(dbg_DETAIL, "Using workDir: " << workDir); 00240 00241 bea_FRI fri(m_bea, vol, workDir, m_recreateInto, friAppendSysVol_c); 00242 bool detectedFM(false); 00243 00244 i_Job_var job = m_bea.GetJob(); 00245 00246 cmn_UUID_t volUUID; 00247 volUUID.Clear(); 00248 00249 vector<UInt32_t> readFRIs; 00250 00251 while (!m_bea.IsAborted()) { 00252 // Read block and parse the contents to get the 00253 // media volume UUID. 00254 00255 if (volUUID.IsNull()) { 00256 // Starting position is first block (medium Header) 00257 // Skip header and go to first FRI 00258 // Then skip FRI one by one (until finding the right one) 00259 log_DBG_m(dbg_LOW, "Seeking to next FRI..."); 00260 try { 00261 vol->SeekFileMark(1); 00262 } 00263 catch (const ivd_Error& ie) { 00264 if (ie.GetError() == ie_MEDIUM_EOD) { 00265 log_DBG_m(dbg_LOW, "End of volume. Stop reading."); 00266 break; 00267 } 00268 else { 00269 throw; 00270 } 00271 } 00272 } 00273 00274 if (fri.ReadFRIStart(volUUID) == true) { 00275 log_DBG_m(dbg_LOW, "End of volume. Stop reading."); 00276 break; 00277 } 00278 if (volUUID.IsNull()) { 00279 //thats not the right FRI 00280 //process next 00281 continue; 00282 } 00283 00284 // Find volume number in requested list. 00285 Int32_t volIndex(-1); 00286 for (UInt32_t i = 0; i < m_volumes.length(); ++i) { 00287 if (volUUID == cmn_UUID_t(string(m_volumes[i].medVolID)) ) { 00288 volIndex = i; 00289 break; 00290 } 00291 }; 00292 00293 if (volIndex == -1) { 00294 log_DBG_m(dbg_LOW, "Skipping FRI. Not on the list."); 00295 volUUID.Clear(); 00296 } 00297 else { 00298 if (m_volumes[volIndex].volNum == -1) { 00299 // WORM medium might contain multiple copies of FRI for the same 00300 // volume if they are recreated for any reason. 00301 log_DBG_m(dbg_LOW, "Already processed at least once. Overwriting."); 00302 } 00303 log_DBG_m(dbg_LOW, "Reading FRI."); 00304 vol->SeekBlock(vol->GetPosition() - 1); 00305 detectedFM = fri.ReadFRI(volUUID); 00306 00307 if (!detectedFM) { 00308 log_DBG_m(dbg_LOW, "End of volume. Stop reading."); 00309 break; 00310 } 00311 00312 // More than one instance of the FRI can reside on system volume 00313 // FRIReadSuccess can't be called immediatelly. 00314 if (m_volumes[volIndex].volNum != -1) { 00315 readFRIs.push_back(m_volumes[volIndex].volNum); 00316 } 00317 00318 // ********************************* 00319 // WARNING: 00320 // Volume number abused to indicate 00321 // that the volume was already processed. 00322 // 00323 // ********************************* 00324 m_volumes[volIndex].volNum = -1; 00325 00326 } 00327 }; // while 00328 00329 if (!m_bea.IsAborted()) { 00330 // Inform job about successfully read FRIs. 00331 for (UInt32_t i = 0; i < readFRIs.size(); ++i) { 00332 ipc_EXEC_m( 00333 log_DBG_m(dbg_LOW, 00334 "Calling FRIReadSuccess(" << 00335 m_bea.GetBEANumber() << ", " << 00336 readFRIs[i] << "," << 0 << ")" ); 00337 00338 job->FRIReadSuccess(m_bea.GetBEANumber(), readFRIs[i], 0); 00339 ); 00340 } 00341 } 00342 00343 log_DBG_m(dbg_LOW, "Sucessfully completed reading/creating FRI."); 00344 }


| void bea_FRIThread::ProcessFromDataVol | ( | ) | [private] |
Definition at line 348 of file bea_frithread.cpp.
References bea_Medium::ChangeVolume(), CheckFRI(), cmn_Num2Str(), CreateFRI(), dbg_DETAIL, dbg_LOW, EraseSysVol(), error(), i_BackEndAgent_i::GetBarcode(), i_BackEndAgent_i::GetBEANumber(), bea_Medium::GetCurrentVolume(), bea_FRI::GetFRIStartPosition(), i_BackEndAgent_i::GetJob(), i_BackEndAgent_i::GetJobID(), bea_Drive::GetMedium(), bea_Volume::GetStartOfDataPosition(), bea_Volume::GetVolumeID(), bea_Volume::GetVolumeNumber(), ie_FATAL_ERROR, ipc_EXEC_m, i_BackEndAgent_i::IsAborted(), IsClosed(), log_DBG_m, log_FUNC_m, log_MARKLINE_m, log_WRN_m, m_bea, m_create, m_drive_p, m_recovery, m_recreateInto, m_volumes, bea_FRI::PositionToStartOfFRI(), ReadFRI(), bea_Volume::ReadVolInfoFromHeader(), SetWorkDir(), and i_BackEndAgent_i::WaitForResources().
Referenced by Run().
00348 { 00349 log_FUNC_m(ProcessFromDataVol); 00350 00351 if (m_create || m_recreateInto) { 00352 log_DBG_m(dbg_LOW, 00353 "Started creating FRI from data volumes. Job ID: " << m_bea.GetJobID()); 00354 } 00355 else { 00356 log_DBG_m(dbg_LOW, 00357 "Started reading FRI from data volumes. Job ID: " << m_bea.GetJobID()); 00358 }; 00359 00360 m_bea.WaitForResources(); 00361 00362 if (m_bea.IsAborted()) { 00363 log_DBG_m(dbg_LOW, "Job aborted. Exit."); 00364 return; 00365 }; 00366 00367 if (!m_recreateInto){ 00368 EraseSysVol(); 00369 } 00370 00371 i_Job_var job = m_bea.GetJob(); 00372 bea_Medium* med = m_drive_p->GetMedium(); 00373 00374 for (UInt32_t i = 0; i < m_volumes.length(); i++) { 00375 00376 if (m_volumes[i].volNum == -1) { 00377 log_DBG_m(dbg_DETAIL, "Skipping FRI. Already processed.."); 00378 continue; 00379 }; 00380 00381 if (m_bea.IsAborted()) { 00382 log_DBG_m(dbg_DETAIL, "Operation aborted."); 00383 break; 00384 } 00385 00386 med->ChangeVolume(m_volumes[i].volNum); 00387 00388 bea_Volume *const vol = med->GetCurrentVolume(); 00389 cmn_UUID_t volid = cmn_UUID_t(string(m_volumes[i].medVolID)); 00390 00391 vol->ReadVolInfoFromHeader(); 00392 if (vol->GetVolumeID() != volid) { 00393 log_WRN_m( 00394 m_bea.GetBarcode() << ":" << (i+1) << 00395 " Reading FRI. Volume UUID doesn't match. Expected: " << volid << 00396 " read: " << vol->GetVolumeID() ); 00397 continue; 00398 00399 // TODO: Should an exception be thrown in this case? 00400 }; 00401 00402 cmn_Path workDir = SetWorkDir(); 00403 log_DBG_m(dbg_DETAIL, "Using workDir: " << workDir); 00404 00405 bool closed = IsClosed(vol); 00406 00407 if (m_create || m_recreateInto) { 00408 CreateFRI(vol, closed, workDir); 00409 } 00410 if (!m_create || m_recreateInto) { 00411 00412 bool error = CheckFRI(vol, med, workDir); 00413 00414 if (error) { 00415 continue; 00416 } 00417 ReadFRI(vol, workDir); 00418 } 00419 00420 if (m_recovery) { 00421 UInt32_t lastDataPos(0); 00422 bea_FRI fri(m_bea, vol, workDir); 00423 fri.PositionToStartOfFRI(); 00424 if (fri.GetFRIStartPosition() > vol->GetStartOfDataPosition()) { 00425 lastDataPos = fri.GetFRIStartPosition() - 2; 00426 } 00427 else if (closed) { 00428 log_MARKLINE_m; 00429 throw ivd_InternalError( 00430 ie_FATAL_ERROR, 00431 "Invalid FRI start position of closed volume: " + 00432 cmn_Num2Str(fri.GetFRIStartPosition()) ); 00433 } 00434 00435 log_DBG_m(dbg_LOW, 00436 "Calling FRIReadSuccess(" << 00437 m_bea.GetBEANumber() << ", " << lastDataPos << ")" ); 00438 00439 ipc_EXEC_m( 00440 job->FRIReadSuccess( 00441 m_bea.GetBEANumber(), 00442 vol->GetVolumeNumber(), 00443 lastDataPos); 00444 ); 00445 } 00446 00447 // ********************************* 00448 // WARNING: 00449 // Volume number abused to indicate 00450 // that the volume was already processed. 00451 // 00452 // ********************************* 00453 m_volumes[i].volNum = -1; 00454 } 00455 log_DBG_m(dbg_LOW, "Completed reading/creating FRI."); 00456 }


bea_FRIThread::log_CLASSID_m [private] |
i_BackEndAgent_i& bea_FRIThread::m_bea [private] |
Definition at line 117 of file bea_fri.h.
Referenced by bea_FRIThread(), CheckFRI(), CreateFRI(), EraseSysVol(), IsClosed(), ProcessFromDataVol(), ReadFRI(), ReadFromSysVol(), Run(), and ~bea_FRIThread().
bea_Drive* const bea_FRIThread::m_drive_p [private] |
Definition at line 118 of file bea_fri.h.
Referenced by EraseSysVol(), ProcessFromDataVol(), and ReadFromSysVol().
i_VolInfoList_t bea_FRIThread::m_volumes [private] |
UInt32_t bea_FRIThread::m_sysVolNum [private] |
bool bea_FRIThread::m_create [private] |
Definition at line 122 of file bea_fri.h.
Referenced by CheckFRI(), EraseSysVol(), ProcessFromDataVol(), and Run().
const i_BoolList_t bea_FRIThread::m_openVolList [private] |
bool bea_FRIThread::m_recovery [private] |
Definition at line 124 of file bea_fri.h.
Referenced by ProcessFromDataVol(), Run(), SetWorkDir(), and ~bea_FRIThread().
i_SysVolAction_e bea_FRIThread::m_svAction [private] |
bool bea_FRIThread::m_recreateInto [private] |
Definition at line 127 of file bea_fri.h.
Referenced by bea_FRIThread(), CreateFRI(), ProcessFromDataVol(), ReadFRI(), ReadFromSysVol(), Run(), and SetWorkDir().
cmn_Path bea_FRIThread::m_intoPath [private] |
i_CompletionStatus_e bea_FRIThread::m_status [private] |
1.5.6