i_EfficientRecallJob_i Class Reference
[Partition Manager]

#include <i_recalljob_impl.h>

Inheritance diagram for i_EfficientRecallJob_i:

Inheritance graph
[legend]
Collaboration diagram for i_EfficientRecallJob_i:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 133 of file i_recalljob_impl.h.


Public Member Functions

 i_EfficientRecallJob_i (i_PartitionManager_i &a_iPM, pm_JobMgr &a_jobMgr, ivd_MediaKey_t a_mediumKey, fsc_FLSPerMedia *a_fileLocPerVolume_p, i_JobID_t a_hsmJobIndexID)
virtual void GetNewResources (i_Index_t a_resNum)
i_RecallList_tPrepareRecallListSeq ()
void PrepareFailedRecallListSeq (i_RecallList_t &a_seqOfFailedFiles)
virtual void MediumOperationComplete (i_Index_t a_beaNum, i_CompletionStatus_e a_status)
virtual void CompleteJob (i_CompletionStatus_e a_status)
i_FileLocationDataList_tGetNextRecallSet ()
i_FSC_ptr GetFSC ()
virtual i_JobRequestList_tGetFiles ()

Public Attributes

ivd_FileSize_t m_fileSize

Protected Attributes

i_PartitionManager_im_iPM

Private Member Functions

virtual ~i_EfficientRecallJob_i ()
void Process ()
 Non-interface function.
void Execute ()
bool SetNextVolume ()
bool PrepareResource ()
void CleanUp ()
void RecallRetry ()
void ReleaseResources ()
void AbortRecallOnHsm ()

Private Attributes

i_JobID_t m_hsmJobIndexID
ivd_MediaKey_t m_mediumKey
ivd_MedVolNum_t m_medVolNum
fsc_FLSPerMediam_fileLoc_p
pm_VolStatus_m m_mediaVolStatus_m
fsc_FLSPerVolumem_currentVolumeFLS_p
UInt32_t m_firstBlockOffset
pm_EfficientRecallClientThreadm_recallClientThread
cmn_ThreadCounter m_recallCounter
bool m_beaGotSplit
bool m_hsmRecallCalled
 log_CLASSID_m

Friends

class pm_EfficientRecallClientThread

Constructor & Destructor Documentation

i_EfficientRecallJob_i::~i_EfficientRecallJob_i (  )  [private, virtual]

Definition at line 96 of file i_efficientrecalljob_impl.cpp.

References CleanUp(), and log_FUNC_m.

00096                                                {
00097     log_FUNC_m(~i_EfficientRecallJob_i);
00098     CleanUp();
00099 }

Here is the call graph for this function:

i_EfficientRecallJob_i::i_EfficientRecallJob_i ( i_PartitionManager_i a_iPM,
pm_JobMgr a_jobMgr,
ivd_MediaKey_t  a_mediumKey,
fsc_FLSPerMedia a_fileLocPerVolume_p,
i_JobID_t  a_hsmJobIndexID 
)

Definition at line 38 of file i_efficientrecalljob_impl.cpp.

References i_JobParams::bufId, i_JobParams::bufType, i_JobParams::copies, rm_String::cvalue_p, i_Job_i::GetJobTypeText(), i_DISK_BUF, i_REMOTE_BUF, ie_INVALID_ARG, i_Job_i::InitBeaStatus(), ipc_EXEC_m, i_JobParams::jobID, i_JobParams::jobPriority, i_JobParams::jobType, jt_RECALL, log_FUNC_m, log_WriteEvent(), i_Job_i::m_activeBeas, i_PartitionManager_i::m_config, i_PartitionManager_i::m_externalClient, m_hsmJobIndexID, i_Job_i::m_iJobParams, m_iPM, i_PartitionManager_i::m_rmPart, cfg_PMCfg::name, rm_Partition::partitionUUIDString, i_JobParams::partName, i_JobParams::partUUID, cfg_PMCfg::recallPriority, ipc_Init::ResourceInit(), and i_Job_i::SetResources().

00045         :   i_Job_i(a_jobMgr),
00046             m_fileSize(0),
00047             m_iPM(a_iPM),
00048             m_hsmJobIndexID(a_hsmJobIndexID),
00049             m_mediumKey(a_mediumKey),
00050             m_fileLoc_p(a_fileLoc_p),
00051             m_currentVolumeFLS_p(NULL),
00052             m_firstBlockOffset(3),
00053             m_beaGotSplit(false),
00054             m_hsmRecallCalled(false){
00055 
00056     log_FUNC_m(i_EfficientRecallJob_i);
00057     
00058     if (m_hsmJobIndexID == 0) {
00059         throw ivd_InternalError(ie_INVALID_ARG, "HSM job index ID is 0.");
00060     }
00061     
00062     ostringstream os;
00063     os << "Started. ";
00064 
00065     m_iJobParams.jobType = jt_RECALL;
00066     log_WriteEvent(os.str(), GetJobTypeText(), m_iJobParams.jobID);
00067 
00068     ipc_EXEC_m(
00069         m_iJobParams.jobPriority   = m_iPM.m_config.recallPriority;
00070         m_iJobParams.partName      =
00071             CORBA::string_dup(m_iPM.m_config.name.c_str());
00072         m_iJobParams.partUUID      =
00073             CORBA::string_dup(m_iPM.m_rmPart.partitionUUIDString.cvalue_p);
00074     );
00075 
00076     if (m_iPM.m_externalClient) {
00077         m_iJobParams.bufType  = i_REMOTE_BUF;
00078     }
00079     else {
00080         m_iJobParams.bufType  = i_DISK_BUF;
00081     }
00082     m_iJobParams.bufId         = m_iJobParams.jobID;
00083     m_iJobParams.copies        = 0;
00084 
00085     i_ResourceList_t resources;
00086     resources.length(1);
00087 
00088     ipc_Init::ResourceInit(resources[0]); //sets all members to 0 or to ipc_nilStr
00089     SetResources(resources);
00090 
00091     m_activeBeas.resize(1); //recall has always one Bea
00092     InitBeaStatus(1);
00093 }

Here is the call graph for this function:


Member Function Documentation

void i_EfficientRecallJob_i::GetNewResources ( i_Index_t  a_resNum  )  [virtual]

Implements i_Job_i.

Definition at line 746 of file i_efficientrecalljob_impl.cpp.

References ie_IMPOSSIBLE, ipc_CATCH_IVD_THROW_CORBA_m, and log_FUNC_m.

00746                                                               {
00747     log_FUNC_m(GetNewResources);
00748     try {
00749         throw ivd_InternalError(ie_IMPOSSIBLE);
00750     } ipc_CATCH_IVD_THROW_CORBA_m;
00751 }

i_RecallList_t * i_EfficientRecallJob_i::PrepareRecallListSeq (  ) 

Definition at line 203 of file i_efficientrecalljob_impl.cpp.

References pm_RecallSetReader::GetCurrentRecallSet(), i_JobParams::jobID, log_ERR_m, log_FUNC_m, i_Job_i::m_iJobParams, m_mediaVolStatus_m, and pm_VolStatus::m_recallSetReader.

Referenced by MediumOperationComplete(), and RecallRetry().

00203                                                              {
00204     log_FUNC_m(PrepareRecallListSeq);
00205 
00206     try {
00207         
00208         pm_VolStatus *vol = m_mediaVolStatus_m[m_iJobParams.jobID];
00209 
00210         i_RecallList_t_var recallList(vol->m_recallSetReader.GetCurrentRecallSet());
00211 
00212         if (recallList->length() == 0) {
00213             log_ERR_m("Recall sequence list is empty.");
00214         }
00215         return recallList._retn();
00216     }
00217     catch (ivd_Exception& e) {
00218         log_ERR_m(e);
00219         throw;
00220     }
00221     catch (ivd_InternalError& ie) {
00222         log_ERR_m(ie);
00223         throw;
00224     }
00225     catch (...) {
00226         log_ERR_m("Caught unknown" );
00227         throw;
00228     }             
00229 }

Here is the call graph for this function:

Here is the caller graph for this function:

void i_EfficientRecallJob_i::PrepareFailedRecallListSeq ( i_RecallList_t a_seqOfFailedFiles  ) 

Definition at line 411 of file i_efficientrecalljob_impl.cpp.

References dbg_LOW, ivd_FileLocationData_t::fileID, i_Recall_t::fileID, ivd_FileLocationData_t::fileIdx, i_Recall_t::fileIdx, i_Recall_t::fileSize, fsc_FLSPerVolume::GetRefOfFileLocDataVec(), log_DBG_m, log_FUNC_m, m_currentVolumeFLS_p, ivd_FileLocationData_t::migrationID, i_Recall_t::migrationID, and NULL.

Referenced by AbortRecallOnHsm().

00411                                                                                           {
00412     log_FUNC_m(PrepareFailedRecallListSeq);
00413 
00414     if (m_currentVolumeFLS_p == NULL){
00415         return;
00416     }
00417 
00418     ivd_FileLocationData_t_v_t& fldVec = m_currentVolumeFLS_p->GetRefOfFileLocDataVec();
00419     log_DBG_m(dbg_LOW, "fldVec.size():" <<  fldVec.size());
00420 
00421     UInt32_t currentLength(a_seqOfFailedFiles.length());
00422     a_seqOfFailedFiles.length(currentLength + fldVec.size());
00423 
00424     log_DBG_m(dbg_LOW, "a_seqOfFailedFiles.length():" <<  a_seqOfFailedFiles.length());
00425 
00426     for (unsigned int i = currentLength; i < a_seqOfFailedFiles.length(); ++i) {
00427         i_Recall_t &recallStr = a_seqOfFailedFiles[i];
00428         ivd_FileLocationData_t &fldSour = fldVec[i - currentLength];
00429 
00430         recallStr.fileID      = fldSour.fileID;
00431         recallStr.migrationID = fldSour.migrationID;
00432         // Get Copies set it to split size.
00433         // HSM set it to file size to be checked in FSC. Not checked if 0.
00434         recallStr.fileSize    = 0;
00435         recallStr.fileIdx     = fldSour.fileIdx;
00436     }
00437 }

Here is the call graph for this function:

Here is the caller graph for this function:

void i_EfficientRecallJob_i::MediumOperationComplete ( i_Index_t  a_beaNum,
i_CompletionStatus_e  a_status 
) [virtual]

Implements i_Job_i.

Definition at line 231 of file i_efficientrecalljob_impl.cpp.

References cmn_Condition::Broadcast(), bs_RUNNING, i_JobParams::bufType, CompleteJob(), dbg_DETAIL, dbg_LOW, dbg_NORM, i_JobParams::diskBufferFS, dt_DISKBUF, pm_RecallSetReader::EndOfCurrentVolume(), evt_ERROR, g_cmn, i_Job_i::GetDiskBufferFileName(), ivd_BaseException::GetFriendly(), i_PartitionManager_i::GetHSM(), i_Job_i::GetJobTypeText(), i_Job_i::GetResources(), i_FAILED, i_SUCCEDED, ipc_CATCH_IVD_THROW_CORBA_m, ipc_EXEC_m, i_Job_i::IsAborted(), job_POST_MED_PROC, i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogStatus(), i_Job_i::m_activate_c, i_Job_i::m_activate_x, m_beaGotSplit, i_Job_i::m_beasStatus_x, i_PartitionManager_i::m_externalClient, cmn_SysInfo::m_hostName, m_hsmJobIndexID, i_Job_i::m_iJobParams, m_iPM, m_mediaVolStatus_m, m_mediumKey, m_medVolNum, pm_VolStatus::m_recallSetReader, i_Job_i::m_status, PrepareRecallListSeq(), PrepareResource(), pm_VolStatus::ReadFinished(), i_Job_i::ReleaseDiskBuffer(), ReleaseResources(), ipc_Corba::ResolveSvc(), i_Job_i::SetBeaStatus(), i_Job_i::SetDiskBufferWritten(), i_Job_i::SetResMedOpComplete(), i_Job_i::SetStatus(), cmn_Global::si, and pm_VolStatus::WriteFinished().

00233                                                        {
00234 
00235     log_FUNC_m(MediumOperationComplete);
00236 
00237     pm_VolStatus *vol = m_mediaVolStatus_m[m_iJobParams.jobID];
00238     {
00239         cmn_MutexLock l(m_beasStatus_x);
00240         SetBeaStatus(a_beaNum, bs_RUNNING);
00241     }
00242 
00243     log_DBG_m(dbg_NORM,
00244         "[" << m_iJobParams.jobID << "] " <<
00245         "Recall CompleteJob called by Bea: " <<
00246         a_beaNum << "  status: " <<
00247         ipc_Log::LogStatus(a_status) );
00248 
00249     try {
00250             m_beaGotSplit = false;
00251             SetStatus(job_POST_MED_PROC);
00252 
00253             // Recall retry problem, bug ID 6673
00254             // Just call completeJob if failed, without retrying
00255         
00256             //if ( (a_status == i_MEDIUM_ERROR) || (a_status == i_HW_ERROR) ){
00257             //    RecallRetry();
00258              
00259             //    m_activate_c.Broadcast();
00260             //    return;
00261             //} else {
00262 
00263             if (a_status != i_SUCCEDED) {
00264                 CompleteJob(a_status);
00265                 return;
00266             }
00267 
00268             //};
00269 
00270             try {
00271                 SetDiskBufferWritten();
00272                 vol->ReadFinished(a_status);
00273                 // copy recalled files to m_seqRecallList
00274                 i_RecallList_t* seqRecallList = PrepareRecallListSeq();
00275 
00276                 i_DownloadAgent_var dagt;
00277                 // Send file to HSM
00278                 if (m_iPM.m_externalClient) {
00279                     ipc_EXEC_m(
00280                         CORBA::Object_var obj = ipc_Corba::ResolveSvc(g_cmn.si.m_hostName);
00281                         i_Service_var svc = i_Service::_narrow(obj);
00282                         dagt = svc->CreateDownloadAgent(
00283                             dt_DISKBUF,
00284                             GetDiskBufferFileName().c_str() );
00285                     );
00286                 };
00287 
00288                 try {
00289                     ipc_EXEC_m(
00290 
00291                         log_DBG_m(dbg_DETAIL, "m_seqRecallList.length(): "
00292                                 << seqRecallList->length() );
00293 
00294                         m_iPM.GetHSM()->EfficientRecall(
00295                             *seqRecallList,
00296                             m_iJobParams.jobID,
00297                             m_hsmJobIndexID,
00298                             GetResources()[0].blockSize,
00299                             m_iJobParams.bufType,
00300                             m_iJobParams.diskBufferFS,
00301                             true,
00302                             dagt);
00303 
00304                         if (!CORBA::is_nil(dagt)) {
00305                             dagt->Remove();
00306                             dagt = i_DownloadAgent::_nil();
00307                         }
00308                     );
00309 
00310                     m_status = i_SUCCEDED;
00311                     ReleaseDiskBuffer();
00312                     vol->WriteFinished(a_status);
00313 
00314                 } catch (ivd_Exception &e){
00315                     ostringstream os;
00316                     os << "Failed (" << e.GetFriendly() << ").";
00317                     log_WriteEvent(evt_ERROR, os.str(),
00318                         GetJobTypeText(), m_iJobParams.jobID);
00319                     log_ERR_m(  "[" << m_iJobParams.jobID << "] " <<
00320                         "Caught Exception when calling HSM->Recall: " << e);
00321                     m_status = i_FAILED;
00322                 }
00323 
00324                 if (!CORBA::is_nil(dagt)) {
00325                     try {
00326                         dagt->Remove();
00327                     }
00328                     catch (...) {
00329                         log_DBG_m(dbg_DETAIL, "m_downloadAgent->Remove() failed. Ignored.");
00330                     };
00331                 }
00332             }
00333             catch (...) {
00334                 log_DBG_m(dbg_LOW, "unknown exception caught");
00335                 //ignore
00336             }
00337 
00338         if (IsAborted()) {
00339             return;
00340         }
00341 
00342         if (vol->m_recallSetReader.EndOfCurrentVolume()) {
00343             log_DBG_m(dbg_LOW, "[" << m_iJobParams.jobID << "] "
00344                 << "End of current volume" 
00345                 << " (mediumKey:" << m_mediumKey
00346                 << " medVolNum:" << m_medVolNum << ")");
00347             if (PrepareResource()) {
00348                 log_DBG_m(dbg_LOW, "[" << m_iJobParams.jobID << "] "
00349                     << "Starting next volume..."
00350                     << " (mediumKey:" << m_mediumKey
00351                     << " medVolNum:" << m_medVolNum << ")");
00352 
00353                 cmn_MutexLock l(m_activate_x);
00354                 m_activate_c.Broadcast();
00355             } else { //no more volumes
00356                 SetResMedOpComplete(a_beaNum);
00357                 SetStatus(job_POST_MED_PROC);
00358                 ReleaseResources();
00359                 CompleteJob(m_status);
00360                 log_WriteEvent("Finished.",
00361                     GetJobTypeText(), m_iJobParams.jobID);
00362             }
00363         }
00364         else {
00365             log_DBG_m(dbg_LOW, "[" << m_iJobParams.jobID << "] "
00366                 << "Finished current set, starting next set..."
00367                 << " (mediumKey:" << m_mediumKey
00368                 << " medVolNum:" << m_medVolNum << ")");
00369             cmn_MutexLock l(m_activate_x);
00370             m_activate_c.Broadcast();
00371         }
00372     } ipc_CATCH_IVD_THROW_CORBA_m;
00373 }

Here is the call graph for this function:

void i_EfficientRecallJob_i::CompleteJob ( i_CompletionStatus_e  a_status  )  [virtual]

Implements i_Job_i.

Definition at line 478 of file i_efficientrecalljob_impl.cpp.

References AbortRecallOnHsm(), dbg_LOW, dbg_NORM, i_SUCCEDED, ipc_EXEC_m, ipc_ObjectExists(), i_Job_i::IsAborted(), i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, ipc_Log::LogStatus(), i_Job_i::m_activeBeas, i_Job_i::m_iJobParams, i_Job_i::ReleaseDiskBuffer(), and i_Job_i::Remove().

Referenced by MediumOperationComplete().

00478                                                                      {
00479     log_FUNC_m(CompleteJob);
00480 
00481     try {
00482         log_DBG_m(dbg_LOW, "[" << m_iJobParams.jobID << "] " <<
00483             "~i_EfficientRecallJob_i finished" );
00484 
00485         if ( a_status != i_SUCCEDED ){
00486             //job failed!!
00487             log_ERR_m(
00488                 "[" << m_iJobParams.jobID << "] " <<
00489                 "Could not recall." << " " <<
00490                 ipc_Log::LogStatus(a_status) );
00491 
00492             try {
00493                 ipc_EXEC_m(
00494                     if (ipc_ObjectExists(m_activeBeas[0])) {
00495                         m_activeBeas[0]->Remove();
00496                     }
00497                     else {
00498                         log_DBG_m(dbg_NORM, "Bea not running. Skip m_activeBeas[0]->Remove()");
00499                     }
00500                 );
00501             } catch (...){
00502                 //ignore
00503             }
00504         }
00505         if (IsAborted() || (a_status != i_SUCCEDED)){
00506             AbortRecallOnHsm();
00507             ReleaseDiskBuffer();
00508         }
00509 
00510         //remove job
00511         ipc_EXEC_m(Remove(););
00512 
00513     } catch (ivd_Exception& e) {
00514         log_ERR_m("[" << m_iJobParams.jobID <<"] " << e);
00515     } catch (ivd_InternalError& ie) {
00516         log_ERR_m("[" << m_iJobParams.jobID << "] " << ie);
00517     } catch (...) {
00518         log_ERR_m("[" << m_iJobParams.jobID << "] " << "Caught unknown" );
00519     }
00520 }

Here is the call graph for this function:

Here is the caller graph for this function:

i_FileLocationDataList_t * i_EfficientRecallJob_i::GetNextRecallSet (  )  [virtual]

Reimplemented from i_Job_i.

Definition at line 125 of file i_efficientrecalljob_impl.cpp.

References dbg_LOW, pm_RecallSetReader::GetNextRecallSet(), ipc_CATCH_IVD_THROW_CORBA_m, i_JobParams::jobID, log_DBG_m, log_FUNC_m, i_Job_i::m_iJobParams, m_mediaVolStatus_m, pm_VolStatus::m_recallSetReader, and i_JobParams::phase.

00125                                                                   {
00126     log_FUNC_m(GetNextRecallSet);
00127     try {
00128         m_iJobParams.phase++;
00129 
00130         pm_VolStatus *vol = m_mediaVolStatus_m[m_iJobParams.jobID];
00131         log_DBG_m(dbg_LOW,  "Get next recall set for job: [" <<
00132                             m_iJobParams.jobID <<
00133                             "]");
00134 
00135         return vol->m_recallSetReader.GetNextRecallSet();
00136 
00137     } ipc_CATCH_IVD_THROW_CORBA_m
00138 }

Here is the call graph for this function:

i_FSC_ptr i_EfficientRecallJob_i::GetFSC (  )  [virtual]

Implements i_Job_i.

Definition at line 522 of file i_efficientrecalljob_impl.cpp.

References i_PartitionManager_i::GetFSC(), ipc_CATCH_IVD_THROW_CORBA_m, ipc_EXEC_m, log_FUNC_m, and m_iPM.

00522                                          {
00523     log_FUNC_m(GetFSC);
00524     try {
00525         ipc_EXEC_m(
00526             i_FSC_ptr tmpFSC = i_FSC::_duplicate(m_iPM.GetFSC());
00527             return tmpFSC;
00528         );
00529     } ipc_CATCH_IVD_THROW_CORBA_m;
00530 
00531 }

Here is the call graph for this function:

i_JobRequestList_t * i_EfficientRecallJob_i::GetFiles (  )  [virtual]

Implements i_Job_i.

Definition at line 753 of file i_efficientrecalljob_impl.cpp.

References ie_IMPOSSIBLE, ipc_CATCH_IVD_THROW_CORBA_m, log_FUNC_m, and NULL.

00753                                                     {
00754     log_FUNC_m(GetFiles);
00755 
00756     try {
00757         throw ivd_InternalError(ie_IMPOSSIBLE);
00758     } ipc_CATCH_IVD_THROW_CORBA_m;
00759     return NULL;
00760 } // i_EfficientRecallJob_i::GetFiles()

void i_EfficientRecallJob_i::Process (  )  [private]

Non-interface function.

Definition at line 143 of file i_efficientrecalljob_impl.cpp.

References i_Job_i::ActivateBea(), i_Resource_t::blockOffset, bs_PROCESSING, bs_RUNNING, dbg_DETAIL, pm_RecallSetReader::EndOfCurrentVolume(), ivd_BaseException::GetError(), i_Job_i::GetResources(), ie_MEDIUM_HWERR, ie_MEDIUM_MEDERR, ie_MEDIUM_PROTECTED, ie_SCSI_HOST, ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, i_Job_i::LoadUnload(), log_DBG_m, log_ERR_m, log_FUNC_m, i_Job_i::m_activeBeas, i_Job_i::m_beasStatus_x, i_Job_i::m_iJobParams, m_mediaVolStatus_m, m_medVolNum, pm_VolStatus::m_recallSetReader, i_Job_i::m_rm, i_Resource_t::mediumKey, i_Resource_t::medVolId, i_Resource_t::medVolNr, RecallRetry(), ReleaseResources(), i_Job_i::SetBeaStatus(), i_Job_i::SetResources(), and i_Job_i::SetResProcessed().

Referenced by Execute().

00143                                     {
00144     log_FUNC_m(Process);
00145 
00146     i_Resource_t tmpRes = GetResources()[0];
00147     tmpRes.medVolNr = m_medVolNum;
00148 
00149     i_MediumVol_t_var iMV;
00150 
00151     ipc_EXEC_m(
00152         iMV = m_rm->SelectMediumVolByKey(tmpRes.mediumKey,
00153                                          tmpRes.medVolNr);
00154     );
00155 
00156     tmpRes.blockOffset = 3;
00157     tmpRes.medVolId = iMV->medVolId;
00158 
00159     log_DBG_m(dbg_DETAIL, "Dump of tmpRes record.  medVolNr: " << tmpRes.medVolNr
00160                          << ", mediumKey: " << tmpRes.mediumKey
00161                          << ", blockOffset: " << tmpRes.blockOffset
00162                          << ", medVolId: " << tmpRes.medVolId);
00163 
00164     SetResources(tmpRes);
00165 
00166     LoadUnload(0);
00167 
00168     try {
00169         cmn_MutexLock l(m_beasStatus_x);
00170         ipc_EXEC_m(ActivateBea(0););
00171         SetBeaStatus(0, bs_RUNNING);
00172 
00173         if (IsAborted()){
00174             return;
00175         }
00176         pm_VolStatus *vol = m_mediaVolStatus_m[m_iJobParams.jobID];
00177 
00178         if (vol->m_recallSetReader.EndOfCurrentVolume()) {
00179             SetResProcessed(0);
00180         }
00181         ipc_EXEC_m(m_activeBeas[0]->Recall(););
00182 
00183         SetBeaStatus(0, bs_PROCESSING);
00184     } catch (ivd_Exception& e){
00185         log_ERR_m("[" << m_iJobParams.jobID <<
00186                     "] Catched Exception when calling Bea->Recall " << e);
00187         switch (e.GetError()){
00188             case(ie_MEDIUM_MEDERR):
00189             case(ie_MEDIUM_PROTECTED):
00190             case(ie_MEDIUM_HWERR):
00191             case(ie_SCSI_HOST):
00192                 {
00193                     ReleaseResources();
00194                     RecallRetry();
00195                     break;
00196                 }
00197             default:
00198                 throw;
00199         }
00200     }
00201 }

Here is the call graph for this function:

Here is the caller graph for this function:

void i_EfficientRecallJob_i::Execute (  )  [private, virtual]

Implements i_Job_i.

Definition at line 675 of file i_efficientrecalljob_impl.cpp.

References i_Job_i::AllocateDiskBuffer(), dbg_DETAIL, dbg_LOW, pm_RecallSetReader::EndOfCurrentVolume(), pm_RecallSetReader::GetCurrentSplitSize(), pm_RecallSetReader::GetRemainingBytesToCopy(), i_FAILED, i_Job_i::IsAborted(), i_Job_i::IsFinished(), pm_RecallSetReader::IsWriteFinished(), i_JobParams::jobID, log_DBG_m, log_FUNC_m, i_Job_i::m_activate_x, pm_VolStatus::m_blockSize, i_Job_i::m_iJobParams, m_iPM, i_PartitionManager_i::m_maxDiskBuff, m_mediaVolStatus_m, pm_VolStatus::m_recallSetReader, i_Job_i::m_status, i_Job_i::NeedsProcess(), NULL, PrepareResource(), Process(), pm_RecallSetReader::SetCurrentBuffSize(), and i_Job_i::WaitBeasToFinish().

00675                                      {
00676     log_FUNC_m(Execute);
00677 
00678     log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
00679                           "] " << "Running Efficient Recall job.");
00680     try {
00681         cmn_MutexLock l(m_activate_x);
00682         PrepareResource();
00683 
00684         if (IsAborted()) {
00685             return;
00686         }
00687 
00688         pm_VolStatus *vol = m_mediaVolStatus_m[m_iJobParams.jobID];
00689         bool first (true);
00690 
00691         while (!IsFinished()) {
00692 
00693             WaitBeasToFinish(5);
00694 
00695             log_DBG_m(dbg_LOW,"[" << m_iJobParams.jobID <<
00696                                 "] " << "waiting finished, resuming...");
00697 
00698             if (IsFinished()) {
00699                 break;
00700             }
00701 
00702             if (vol->m_recallSetReader.EndOfCurrentVolume()
00703                 && vol->m_recallSetReader.IsWriteFinished()) {
00704                     log_DBG_m(dbg_LOW,"[" << m_iJobParams.jobID <<
00705                                 "] " << "deleting current vol pointer");
00706 
00707                     pm_VolStatus *tmpVol = vol;
00708                     vol = NULL;
00709                     delete tmpVol;
00710 
00711                     log_DBG_m(dbg_LOW,"[" << m_iJobParams.jobID <<
00712                                 "] " << "get new media vol status pointer");
00713 
00714                     vol = m_mediaVolStatus_m[m_iJobParams.jobID];
00715                     first = true;
00716             }
00717 
00718             if ( first || vol->m_recallSetReader.IsWriteFinished() ) {
00719                 if ( NeedsProcess(0) ) {
00720                     UInt64_t allocated(0);
00721                     allocated = AllocateDiskBuffer(
00722                                 vol->m_recallSetReader.GetCurrentSplitSize(),
00723                                 vol->m_recallSetReader.GetRemainingBytesToCopy(),
00724                                 m_iPM.m_maxDiskBuff,
00725                                 vol->m_blockSize,
00726                                 m_iPM.m_maxDiskBuff);
00727                     vol->m_recallSetReader.SetCurrentBuffSize(allocated);
00728 
00729                     if (IsAborted()) {
00730                         return;
00731                         }
00732 
00733                     Process();
00734                 }
00735                 first = false;
00736             }
00737         } //while (!IsFinished())
00738     } catch (ivd_Exception& e){
00739         log_DBG_m(dbg_LOW, e);
00740         m_status = i_FAILED;
00741         throw;
00742     }
00743 }

Here is the call graph for this function:

bool i_EfficientRecallJob_i::SetNextVolume (  )  [private]

Definition at line 534 of file i_efficientrecalljob_impl.cpp.

References dbg_DETAIL, fsc_FLSPerMedia::GetNextFSLPerVolume(), log_DBG_m, log_FUNC_m, m_currentVolumeFLS_p, m_fileLoc_p, m_mediumKey, m_medVolNum, and NULL.

Referenced by AbortRecallOnHsm().

00534                                           {
00535     log_FUNC_m(SetNextVolume);
00536     //delete data location vector
00537     if (m_currentVolumeFLS_p !=  NULL){
00538         log_DBG_m(dbg_DETAIL, "deleting m_currentVolumeFLS_p.");
00539         delete m_currentVolumeFLS_p;
00540     }
00541 
00542     //set next volume for data location
00543     m_currentVolumeFLS_p = m_fileLoc_p->GetNextFSLPerVolume(m_mediumKey,
00544         m_medVolNum);
00545 
00546     if (m_currentVolumeFLS_p ==  NULL){
00547         log_DBG_m(dbg_DETAIL, "No more volumes to process.");
00548         return false;
00549     } else {
00550         return true;
00551     }
00552 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool i_EfficientRecallJob_i::PrepareResource (  )  [private]

Definition at line 554 of file i_efficientrecalljob_impl.cpp.

References i_Medium_t::barcode, i_Resource_t::barcode, i_Resource_t::blockOffset, ivd_FileLocationData_t::blockOffset, i_Resource_t::blockSize, i_Medium_t::blockSize, dbg_DETAIL, dbg_LOW, dbg_NORM, fsc_FLSPerMedia::GetNextFSLPerVolume(), fsc_FLSPerVolume::GetRefOfFileLocDataVec(), i_Job_i::GetResources(), i_RMCOPYPOS_ERROR, ipc_EXEC_m, job_MED_PROC, i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, m_currentVolumeFLS_p, m_fileLoc_p, m_fileSize, m_firstBlockOffset, i_Job_i::m_iJob, i_Job_i::m_iJobParams, m_iPM, i_PartitionManager_i::m_iRM, m_mediaVolStatus_m, m_mediumKey, m_medVolNum, i_Job_i::m_rm, i_Job_i::m_status, i_Medium_t::mediaPoolName, i_Resource_t::mediumFamily, i_Resource_t::mediumKey, i_Resource_t::medVolNr, NULL, i_Resource_t::poolKey, i_Resource_t::poolType, i_Resource_t::resAllocated, i_Resource_t::resBeaStarted, i_Resource_t::resNum, i_Resource_t::resProcessed, i_Resource_t::resRequested, i_Job_i::SetResources(), i_Job_i::SetResRequested(), i_Job_i::SetStatus(), i_Resource_t::splitOffset, and ivd_FileLocationData_t::splitSize.

Referenced by Execute(), and MediumOperationComplete().

00554                                             {
00555     log_FUNC_m(PrepareResource);
00556 
00557     try {
00558         //delete data location vector
00559         if (m_currentVolumeFLS_p !=  NULL){
00560             log_DBG_m(dbg_DETAIL, "deleting m_currentVolumeFLS_p.");
00561             delete m_currentVolumeFLS_p;
00562         }
00563 
00564         //set next volume for data location
00565         m_currentVolumeFLS_p = m_fileLoc_p->GetNextFSLPerVolume(m_mediumKey,
00566                                                                 m_medVolNum);
00567 
00568 
00569         if (m_currentVolumeFLS_p ==  NULL){
00570             log_DBG_m(dbg_DETAIL, "No more volumes to process.");
00571             return false;
00572         }
00573 
00574         ivd_FileLocationData_t_v_t& fldVec = m_currentVolumeFLS_p->GetRefOfFileLocDataVec();
00575 
00576         m_fileSize = 0;
00577 
00578         for (UInt32_t i = 0; i < fldVec.size(); i++){
00579             ivd_FileLocationData_t &fld = fldVec[i];
00580 
00581 
00582             log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
00583                                  "] " << "m_iCopiesPos[" << i << "],  " <<
00584                                  fld.blockOffset << "," <<
00585                                  fld.splitSize);
00586             m_fileSize += fld.splitSize;
00587         }
00588 
00589         log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID
00590             << "] " << " m_fileSize:" << m_fileSize);
00591 
00592         log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID
00593             << "] " << " mediumKey:" << m_mediumKey
00594             << " medVolNum:" << m_medVolNum);
00595 
00596         SetStatus(job_MED_PROC);
00597 
00598         i_Resource_t tmpRes;
00599         tmpRes = GetResources()[0];
00600         i_MediumVol_t mv;
00601         try {
00602             ipc_EXEC_m (
00603                 i_MediumVol_t_var medVol =
00604                     m_rm->SelectMediumVolByKey(
00605                             m_mediumKey,
00606                             m_medVolNum
00607                     );
00608                 tmpRes.barcode= medVol->mediumBarcode;
00609                 mv = medVol;
00610             );
00611         } catch (ivd_Error &e){
00612             log_ERR_m(e);
00613         }
00614 
00615         i_Medium_t medium;
00616         ipc_EXEC_m(
00617             i_Medium_t_var med = m_iPM.m_iRM->SelectMedium(tmpRes.barcode);
00618             medium = med;
00619         );
00620 
00621         m_mediaVolStatus_m[m_iJobParams.jobID] = new pm_VolStatus(mv,
00622                                                                   medium.blockSize,
00623                                                                   fldVec.begin(),
00624                                                                   fldVec.end());
00625 
00626         ivd_FileLocationData_t &fldFirstFile = fldVec[0];
00627 
00628         tmpRes.mediumKey    = m_mediumKey;
00629         tmpRes.medVolNr     = m_medVolNum;
00630         tmpRes.blockOffset  = fldFirstFile.blockOffset;
00631         tmpRes.splitOffset  = m_firstBlockOffset;
00632         tmpRes.resRequested = true;
00633         tmpRes.resProcessed = false;
00634         tmpRes.resBeaStarted= false;       
00635 
00636         SetResources(tmpRes);
00637 
00638         if (!tmpRes.resAllocated) {
00639            log_DBG_m(dbg_LOW,"[" << m_iJobParams.jobID <<
00640                 "] " << "Getting Recall Resources from RM");
00641             ipc_EXEC_m(
00642                 i_MediaPool_t_var mpool;
00643                 mpool = m_rm->SelectMediaPool(medium.mediaPoolName);
00644                 
00645                 SetResRequested(0);
00646 
00647                 tmpRes.resNum       = 0;                
00648                 tmpRes.barcode      = CORBA::string_dup(string(medium.barcode).c_str());
00649                 tmpRes.blockSize    = medium.blockSize;
00650                 tmpRes.poolKey      = mpool->mediaPoolKey;
00651                 tmpRes.poolType     = mpool->mediaPoolType;
00652                 tmpRes.mediumFamily = mpool->mediaFamily;
00653                 SetResources(tmpRes);
00654 
00655                 m_rm->GetRecallResources(m_iJob,
00656                                         m_iJobParams,
00657                                         GetResources()[0]);
00658                 /* 
00659                 There should be no resource manipulation after 
00660                 this point until end of function. AssignResource will 
00661                 be called by RM and in some cases it can finish before
00662                 this function causing recall thread to freeze.
00663                 */
00664            );
00665         }
00666     } catch (ivd_Exception& e){
00667         log_DBG_m(dbg_LOW, e);
00668         m_status = i_RMCOPYPOS_ERROR;
00669         throw;
00670     }
00671     return true;
00672 }

Here is the call graph for this function:

Here is the caller graph for this function:

void i_EfficientRecallJob_i::CleanUp (  )  [private]

Definition at line 101 of file i_efficientrecalljob_impl.cpp.

References log_ERR_m, log_FUNC_m, m_currentVolumeFLS_p, m_fileLoc_p, m_mediaVolStatus_m, and NULL.

Referenced by ~i_EfficientRecallJob_i().

00101                                     {
00102     log_FUNC_m(CleanUp);
00103 
00104     if (m_fileLoc_p != NULL) {
00105         delete m_fileLoc_p;
00106         m_fileLoc_p = NULL;
00107     }
00108 
00109     if (m_currentVolumeFLS_p != NULL) {
00110         delete m_currentVolumeFLS_p;
00111         m_currentVolumeFLS_p = NULL;
00112     }
00113 
00114     try {
00115         pm_VolStatus_m::iterator p;
00116         for (p = m_mediaVolStatus_m.begin(); p != m_mediaVolStatus_m.end();) {
00117             m_mediaVolStatus_m.erase(p++);
00118         }
00119     } catch (ivd_Exception& e){
00120         log_ERR_m(  "Catch exception while erasing m_mediaVolStatus_m: " <<
00121                     e);
00122     }
00123 }

Here is the caller graph for this function:

void i_EfficientRecallJob_i::RecallRetry (  )  [private]

Definition at line 404 of file i_efficientrecalljob_impl.cpp.

References i_PartitionManager_i::EfficientRecall(), log_FUNC_m, m_hsmJobIndexID, m_iPM, and PrepareRecallListSeq().

Referenced by Process().

00404                                         {
00405     log_FUNC_m(RecallRetry);
00406 
00407     i_RecallList_t* seqRecallList = PrepareRecallListSeq();
00408     m_iPM.EfficientRecall(*seqRecallList, m_hsmJobIndexID);
00409 }

Here is the call graph for this function:

Here is the caller graph for this function:

void i_EfficientRecallJob_i::ReleaseResources (  )  [private]

Definition at line 375 of file i_efficientrecalljob_impl.cpp.

References dbg_LOW, dbg_NORM, i_Job_i::GetResources(), ipc_EXEC_m, i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, i_Job_i::m_iJobParams, i_Job_i::m_rm, and i_Job_i::SetResReleased().

Referenced by MediumOperationComplete(), and Process().

00375                                              {
00376     log_FUNC_m(ReleaseResources);
00377     try {
00378         ipc_EXEC_m(
00379             //resource are released because hsm->recall can last long time
00380             log_DBG_m(dbg_LOW, "[" << m_iJobParams.jobID <<
00381             "] " << "ReleaseResource for jobId");
00382             i_ResourceList_t res = GetResources();
00383             try {
00384                 ipc_EXEC_m(m_rm->ReleaseResource(m_iJobParams, res));
00385             } catch (ivd_Error &e){
00386                 log_ERR_m("Releasing FAILED for jobID: " <<
00387                            m_iJobParams.jobID << endl << e)
00388             }
00389 
00390             for (UInt32_t i = 0 ; i < res.length(); ++i) {
00391                 SetResReleased(i);
00392             }
00393         log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
00394             "] " << "Resources Released for job");
00395 
00396         );
00397     } catch (ivd_Exception& e){
00398         log_ERR_m(
00399             "[" << m_iJobParams.jobID << "] " <<
00400             "Catched Exception when calling rm->ReleaseResource" << e);
00401     }
00402 }

Here is the call graph for this function:

Here is the caller graph for this function:

void i_EfficientRecallJob_i::AbortRecallOnHsm (  )  [private]

Definition at line 439 of file i_efficientrecalljob_impl.cpp.

References dbg_DETAIL, dbg_LOW, i_JobParams::diskBufferFS, i_PartitionManager_i::GetHSM(), i_Job_i::GetJobId(), i_DISK_BUF, log_DBG_m, log_FUNC_m, m_hsmJobIndexID, i_Job_i::m_iJobParams, m_iPM, PrepareFailedRecallListSeq(), and SetNextVolume().

Referenced by CompleteJob().

00439                                               {
00440     log_FUNC_m(AbortRecallOnHsm);
00441 
00442     i_RecallList_t seqOfFailedFiles;
00443     
00444     while (1){
00445         PrepareFailedRecallListSeq(seqOfFailedFiles);
00446 
00447         if (SetNextVolume()){
00448             log_DBG_m(dbg_DETAIL, "continue");
00449             continue;
00450         }
00451         else {
00452             log_DBG_m(dbg_DETAIL, "break");
00453             //no more volumes
00454             break;
00455         }
00456     }
00457     log_DBG_m(dbg_DETAIL, "calling hsm");
00458 
00459     log_DBG_m(dbg_LOW, "Aborting #files:" <<  seqOfFailedFiles.length());
00460 
00461     if (seqOfFailedFiles.length() > 0){
00462         for (UInt32_t i(0); i < seqOfFailedFiles.length(); i++){
00463             log_DBG_m(dbg_LOW, "fileID:" << seqOfFailedFiles[i].fileID );
00464         }
00465         m_iPM.GetHSM()->EfficientRecall(
00466             seqOfFailedFiles,
00467             GetJobId(),
00468             m_hsmJobIndexID,
00469             0,
00470             i_DISK_BUF,
00471             m_iJobParams.diskBufferFS,
00472             false,
00473             i_DownloadAgent::_nil());
00474     }
00475 }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class pm_EfficientRecallClientThread [friend]

Definition at line 139 of file i_recalljob_impl.h.


Member Data Documentation

Definition at line 163 of file i_recalljob_impl.h.

Referenced by PrepareResource().

Definition at line 181 of file i_recalljob_impl.h.

Referenced by MediumOperationComplete(), PrepareResource(), and SetNextVolume().

Definition at line 186 of file i_recalljob_impl.h.

Referenced by CleanUp(), PrepareResource(), and SetNextVolume().

Definition at line 190 of file i_recalljob_impl.h.

Referenced by PrepareResource().

Definition at line 192 of file i_recalljob_impl.h.

Definition at line 193 of file i_recalljob_impl.h.

Definition at line 194 of file i_recalljob_impl.h.

Referenced by MediumOperationComplete().

Definition at line 195 of file i_recalljob_impl.h.

Reimplemented from i_Job_i.

Definition at line 197 of file i_recalljob_impl.h.


The documentation for this class was generated from the following files:

Generated on Mon Feb 27 19:32:00 2012 for OPENARCHIVE by  doxygen 1.5.6