hsm_Recall Class Reference
[G_new_group]

#include <hsm_Recall.h>

Inheritance diagram for hsm_Recall:

Inheritance graph
[legend]
Collaboration diagram for hsm_Recall:

Collaboration graph
[legend]

List of all members.


Detailed Description

Object from class hsm_Recall can be created only if number of i_RecallList_t members is greter that 0.

The class does not check member count by itself.

How Group recall works? hsm_Recall object have df_BlockProxy reader that take care of data source hsm_JobElemVecMgr where FH's pointers of group recall job are stored i_RecallList_t recall list contail files that are packed in DF buffer.

Action diagram: record reader reads DF data and call ProcRec* virtual method that hsm_Recall handle it. ProcRecFileHdr() method checks if file has to be recalled. File has to be recall ed if its fileID and migID match to same fields in m_currentFileToRecall record. If file has to be recalled then m_FH_p is set. m_FH_p is set by using m_currentFileToRecall.fileIdx that point to FH in m_jobElemVecMgr Others ProcRec* methods check m_FH_p pointer to prepare and write data to destination. Whether to HSMFS or to some other place in case of recall into.

Recall into is not possible, because cannot asure that DF buffers comes in sequence. On Windows platform backup write is used.

Definition at line 57 of file hsm_Recall.h.


Public Member Functions

 hsm_Recall (df_BlockProxy *a_reader, hsm_JobElemVecMgr &a_jobElemVecMgr, UInt64_t a_pmJobId, const i_RecallList_t &a_recallList)
 ~hsm_Recall (void)
virtual void ProcRecFileHdr (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecFileEnd (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecBSStart (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecEmbData (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecRawData (const UInt8_t *a_block_p)
virtual void ProcRecBSEnd (const df_RecCmn_t *a_recCmn_p)
UInt64_t GetSizeOfRecalledData ()
UInt32_t GetNumOfRecalledFiles ()

Private Member Functions

bool IsFileFromDFforRecall (ivd_FileID_t a_fileID, ivd_MigrationID_t a_migID)
void RecallOfFileCanceled ()
void FileRecalledCheck ()

Private Attributes

 log_CLASSID_m
 Macro to add class name member s_className.
hsm_JobElemVecMgrm_jobElemVecMgr
const UInt64_t m_pmJobId
const i_RecallList_tm_recallList
int m_recalledUpToIdx
hsm_FileHeaderm_FH_p
hsm_RecallInfoGrpm_recallFileMgr_p
bool m_recallData
UInt64_t m_sizeOfRecalledData
UInt32_t m_numOfRecalledFiles

Constructor & Destructor Documentation

hsm_Recall::hsm_Recall ( df_BlockProxy a_reader,
hsm_JobElemVecMgr a_jobElemVecMgr,
UInt64_t  a_pmJobId,
const i_RecallList_t a_recallList 
)

Definition at line 35 of file hsm_Recall.cpp.

References log_FUNC_m.

00039     :
00040     df_RecReader(a_reader),
00041     m_jobElemVecMgr(a_jobElemVecMgr),
00042     m_pmJobId(a_pmJobId),
00043     m_recallList(a_recallList),
00044     m_recalledUpToIdx(0),
00045     m_FH_p(NULL),
00046     m_recallFileMgr_p(NULL),
00047     m_recallData(false),
00048     m_sizeOfRecalledData(0),
00049     m_numOfRecalledFiles(0)
00050 {
00051     log_FUNC_m(hsm_Recall);
00052 }
//============================================================================//

hsm_Recall::~hsm_Recall ( void   ) 

Definition at line 55 of file hsm_Recall.cpp.

References log_FUNC_m.

00055                             {
00056     log_FUNC_m(~hsm_Recall);
00057 }


Member Function Documentation

void hsm_Recall::ProcRecFileHdr ( const df_RecCmn_t a_recCmn_p  )  [virtual]

Reimplemented from df_RecReader.

Definition at line 60 of file hsm_Recall.cpp.

References dbg_NORM, df_RecFile_t::idFile, df_RecFile_t::idMig, IsFileFromDFforRecall(), log_DBG_m, log_FUNC_m, and ntoh().

00060                                                             {
00061     log_FUNC_m(ProcRecFileHdr);
00062     const df_RecFile_t *file_p = df_GetSpecificRec<df_RecFile_t>(a_recCmn_p);
00063 
00064     ivd_FileID_t      fileID = (ivd_FileID_t)ntoh(file_p->idFile);
00065     ivd_MigrationID_t migID  = ntoh(file_p->idMig);
00066 
00067     if ( !IsFileFromDFforRecall(fileID, migID)) {
00068         
00069         log_DBG_m (dbg_NORM, "  Unpacker SKIPPED wrong fileId or MigID. " << endl <<
00070                                 "\t\t\t\tFileID: " << fileID << " MigID: " << migID);
00071         return;
00072     }
00073 //    cmn_Path fileName(g_rootPath + a_recCmn_p->GetVarDataNet(file_p->name));
00074 }

Here is the call graph for this function:

void hsm_Recall::ProcRecFileEnd ( const df_RecCmn_t a_recCmn_p  )  [virtual]

Reimplemented from df_RecReader.

Definition at line 77 of file hsm_Recall.cpp.

References hsm_RecallInfoGrp::Close(), FileRecalledCheck(), log_FUNC_m, m_FH_p, m_numOfRecalledFiles, m_recallData, and m_recallFileMgr_p.

00077                                                             {
00078     log_FUNC_m(ProcRecFileEnd);
00079     if (!m_FH_p) {
00080         return;
00081     }
00082     if (m_recallData) {
00083         m_recallData = false;
00084         m_recallFileMgr_p->Close();
00085     }
00086     m_numOfRecalledFiles++;
00087     FileRecalledCheck();
00088 }

Here is the call graph for this function:

void hsm_Recall::ProcRecBSStart ( const df_RecCmn_t a_recCmn_p  )  [virtual]

Reimplemented from df_RecReader.

Definition at line 91 of file hsm_Recall.cpp.

References cmn_Num2Str(), dbg_DETAIL, dbg_NORM, df_ST_DATA, evt_WARNING, g_fs_api_p, cmn_File::GetFileType(), hsm_FileHeader::GetInode(), hsm_FileHeader::GetRecallJobIdx(), ivd_FileSystemAPI::GetRootPath(), ift_FILE, log_DBG_m, log_FUNC_m, log_WriteEvent(), df_RecReader::m_curStreamType, m_FH_p, m_pmJobId, m_recallData, m_recallFileMgr_p, hsm_FileHeader::MakePath(), ntoh(), hsm_RecallInfoGrp::OpenF(), RecallOfFileCanceled(), hsm_RecallInfoGrp::SeekF(), and df_RecByteStreamStart_t::streamOffset.

00091                                                              {
00092     log_FUNC_m(ProcRecBSStart);
00093     
00094     if (  !m_FH_p
00095        ||  m_curStreamType != df_ST_DATA ) {
00096         return;
00097     }
00098     
00099     // always recall data stream...
00100     m_recallData = true; 
00101         
00102     const df_RecByteStreamStart_t *bss_p = df_GetSpecificRec<df_RecByteStreamStart_t>(a_recCmn_p);
00103 
00104     try {
00105         cmn_Path filePath = g_fs_api_p->GetRootPath() + m_FH_p->MakePath();
00106         cmn_File fileN(filePath);
00107         if ( fileN.GetFileType()  != ift_FILE){
00108             ostringstream sstr;
00109             sstr << ".inode/" + m_FH_p->GetInode();
00110             cmn_Path inodeP( sstr.str() );
00111             filePath = g_fs_api_p->GetRootPath() + inodeP;
00112         }
00113         log_DBG_m(dbg_NORM, "Opening file " << filePath << " for RECALL.");
00114         m_recallFileMgr_p->OpenF(filePath);
00115 //        m_FH_p->OpenFile(*m_recallFileMgr_p, ivd_FS_File::e_Recall);
00116         // We go the data to recall
00117         log_DBG_m(dbg_DETAIL, "  Data of file " << filePath << " IS_FOUND. RECALL proceed.");
00118         // TODO Seek and set data chunk
00119         m_recallFileMgr_p->SeekF(m_pmJobId, ntoh(bss_p->streamOffset));
00120     }
00121     catch (ivd_SysError) {
00122         ostringstream sstr;
00123         sstr << "Cannot open a file for recall. File is probably deleted. "
00124              <<  m_FH_p->MakePath();
00125         log_WriteEvent(evt_WARNING,
00126             sstr.str(), "RECALL",
00127             m_pmJobId,
00128             cmn_Num2Str(m_FH_p->GetRecallJobIdx()));
00129         RecallOfFileCanceled();
00130         return;
00131     }
00132 }

Here is the call graph for this function:

void hsm_Recall::ProcRecEmbData ( const df_RecCmn_t a_recCmn_p  )  [virtual]

Reimplemented from df_RecReader.

Definition at line 135 of file hsm_Recall.cpp.

References cmn_Num2Str(), df_RecEmbeddedData_t::data, df_ST_DATA, evt_WARNING, hsm_FileHeader::GetRecallJobIdx(), hsm_RecallInfoGrp::GetStreamSize(), df_RecCmn_t::GetVarDataNet(), hsm_RecallInfoGrp::IsRecallFailed(), log_FUNC_m, log_WriteEvent(), log_WRN_m, df_RecReader::m_curStreamType, m_FH_p, m_pmJobId, m_recallFileMgr_p, m_sizeOfRecalledData, hsm_FileHeader::MakePath(), ntoh(), RecallOfFileCanceled(), ivd_VarData_t::size, size, and hsm_RecallInfoGrp::WriteF().

00135                                                              {
00136     log_FUNC_m(ProcRecEmbData);
00137 
00138     if (  !m_FH_p
00139        ||  m_curStreamType != df_ST_DATA ) {
00140         return;
00141     }
00142 
00143     const df_RecEmbeddedData_t *embData_p = df_GetSpecificRec<df_RecEmbeddedData_t>(a_recCmn_p);
00144     
00145     Int32_t size = ntoh(embData_p->data.size);
00146     ivd_FileRetSize_t ret = 
00147         m_recallFileMgr_p->WriteF(
00148             a_recCmn_p->GetVarDataNet(embData_p->data), 
00149             size);
00150 
00151     if (ret != size) {
00152         ostringstream sstr;
00153         sstr << "HSMFS is full! Cannot recall a file: "
00154              << m_FH_p->MakePath();
00155         log_WriteEvent(evt_WARNING,
00156             sstr.str(), "RECALL",
00157             m_pmJobId,
00158             cmn_Num2Str(m_FH_p->GetRecallJobIdx()));
00159             
00160         sstr << endl << " Try to write: " << size
00161              << ", but " << ret << " bytes is written.";
00162         log_WRN_m(sstr.str());
00163         
00164         RecallOfFileCanceled();
00165         m_sizeOfRecalledData += size; // stream size is already increased by size.
00166         m_sizeOfRecalledData -= m_recallFileMgr_p->GetStreamSize();
00167         return;
00168     }
00169     
00170     if (!m_recallFileMgr_p->IsRecallFailed()) {
00171         m_sizeOfRecalledData += size;
00172     }
00173 }

Here is the call graph for this function:

void hsm_Recall::ProcRecRawData ( const UInt8_t a_block_p  )  [virtual]

Reimplemented from df_RecReader.

Definition at line 176 of file hsm_Recall.cpp.

References cmn_Num2Str(), df_ST_DATA, evt_WARNING, df_RecReader::GetBlkSize(), hsm_FileHeader::GetRecallJobIdx(), hsm_RecallInfoGrp::GetStreamSize(), hsm_RecallInfoGrp::IsRecallFailed(), log_FUNC_m, log_WriteEvent(), log_WRN_m, df_RecReader::m_curStreamType, m_FH_p, m_pmJobId, m_recallFileMgr_p, m_sizeOfRecalledData, hsm_FileHeader::MakePath(), RecallOfFileCanceled(), and hsm_RecallInfoGrp::WriteF().

00176                                                         {
00177     log_FUNC_m(ProcRecRawData);
00178 
00179     if (  !m_FH_p
00180        ||  m_curStreamType != df_ST_DATA ) {
00181         return;
00182     }
00183 
00184     UInt32_t blkSize = GetBlkSize();
00185     ivd_FileRetSize_t ret = m_recallFileMgr_p->WriteF(a_block_p, blkSize);
00186     if (ret != blkSize) {
00187         ostringstream sstr;
00188         sstr << "HSMFS is full! Cannot recall a file: "
00189              << m_FH_p->MakePath();
00190         log_WriteEvent(evt_WARNING,
00191             sstr.str(), "RECALL",
00192             m_pmJobId,
00193             cmn_Num2Str(m_FH_p->GetRecallJobIdx()));
00194             
00195         sstr << endl << " Try to write: " << blkSize
00196              << ", but " << ret << " bytes is written.";
00197         log_WRN_m(sstr.str());
00198         
00199         RecallOfFileCanceled();
00200         m_sizeOfRecalledData += blkSize; // stream size is already increased by size.
00201         m_sizeOfRecalledData -= m_recallFileMgr_p->GetStreamSize();
00202         return;
00203     }
00204     if (!m_recallFileMgr_p->IsRecallFailed()) {
00205         m_sizeOfRecalledData += blkSize;
00206     }
00207 }

Here is the call graph for this function:

void hsm_Recall::ProcRecBSEnd ( const df_RecCmn_t a_recCmn_p  )  [virtual]

Reimplemented from df_RecReader.

Definition at line 210 of file hsm_Recall.cpp.

References hsm_RecallInfoGrp::Close(), df_ST_DATA, log_FUNC_m, df_RecReader::m_curStreamType, m_FH_p, m_recallData, and m_recallFileMgr_p.

00210                                                            {
00211     log_FUNC_m(ProcRecBSEnd);
00212 
00213     if (  !m_FH_p
00214        ||  m_curStreamType != df_ST_DATA ) {
00215         return;
00216     }
00217 
00218 //    const df_RecByteStreamEnd_t *bse_p = df_GetSpecificRec<df_RecByteStreamEnd_t>(a_recCmn_p);
00219     m_recallData = false;
00220     m_recallFileMgr_p->Close();
00221 }

Here is the call graph for this function:

UInt64_t hsm_Recall::GetSizeOfRecalledData (  )  [inline]

Definition at line 73 of file hsm_Recall.h.

References m_sizeOfRecalledData.

Referenced by i_HSM_i::EfficientRecall().

00073 { return m_sizeOfRecalledData; };

Here is the caller graph for this function:

UInt32_t hsm_Recall::GetNumOfRecalledFiles (  )  [inline]

Definition at line 74 of file hsm_Recall.h.

References m_numOfRecalledFiles.

Referenced by i_HSM_i::EfficientRecall().

00074 { return m_numOfRecalledFiles; };

Here is the caller graph for this function:

bool hsm_Recall::IsFileFromDFforRecall ( ivd_FileID_t  a_fileID,
ivd_MigrationID_t  a_migID 
) [private]

Definition at line 224 of file hsm_Recall.cpp.

References hsm_JobElemVecMgr::At(), dbg_DETAIL, dbg_LOW, evt_ERROR, i_Recall_t::fileID, i_Recall_t::fileIdx, hsm_FileHeader::GetRecallInfoGrp(), ie_FATAL_ERROR, log_DBG_m, log_FUNC_m, log_WriteEvent(), m_FH_p, m_jobElemVecMgr, hsm_JobElemVecMgr::m_jobElemVecMgr_x, m_recalledUpToIdx, m_recallFileMgr_p, m_recallList, i_Recall_t::migrationID, and NULL.

Referenced by ProcRecFileHdr().

00224                                                                                        {
00225     log_FUNC_m(IsFileFromDFforRecall);
00226     
00227     //TODO improve searching by using block offset.
00228     
00229     log_DBG_m (dbg_DETAIL, "m_recallList.length(): " << m_recallList.length()
00230                         << ", a_fileID: " << a_fileID
00231                         << ", a_migID: " << a_migID
00232                         << ", sizeof i_Recall_t: " << sizeof(i_Recall_t)
00233                         << ", m_recalledUpToIdx: " << m_recalledUpToIdx);
00234 
00235     int listLen = m_recallList.length();
00236     const i_Recall_t *pi = &m_recallList[m_recalledUpToIdx];    
00237     log_DBG_m (dbg_DETAIL, "pi: " << hex << pi << dec);
00238     
00239     const i_Recall_t *pe = &m_recallList[0] + listLen;
00240     log_DBG_m (dbg_DETAIL, "pe: " << hex << pe << dec);
00241     for (;pi != pe; ++pi) {
00242         if (   pi->fileID      == a_fileID
00243             && pi->migrationID == a_migID) {
00244 
00245             log_DBG_m (dbg_DETAIL, "File needs to be recalled." << *pi);
00246 
00247             // NOTE:
00248             // Temporary fix to prevent crashing of HSM if
00249             // the fileIdx is set to -1.
00250             //
00251             if (pi->fileIdx == -1) {
00252                 ostringstream sstr;
00253                 sstr
00254                     << "File ID: " << a_fileID << ", mig ID: " << a_migID << ". "
00255                     << "Recall can't complete: file split already marked as processed. "
00256                     << "Please remount HSMFS and contact support.";
00257                 log_WriteEvent(evt_ERROR, sstr.str(), "RECALL");
00258                 break;
00259             }
00260             // End of temporary fix.
00261 
00262             {
00263                 cmn_MutexLock l(m_jobElemVecMgr.m_jobElemVecMgr_x);
00264                 m_FH_p = m_jobElemVecMgr.At(pi->fileIdx);
00265 
00266                 if (m_FH_p == NULL) {
00267                     log_DBG_m(dbg_LOW,
00268                         "File header not found in job list. "
00269                         << "Already aborted/failed job for file ID: " << pi->fileID);
00270                     break;
00271                 }
00272 
00273                 m_recallFileMgr_p = m_FH_p->GetRecallInfoGrp();
00274                 if (m_recallFileMgr_p == NULL) {
00275                     ostringstream sstr;
00276                     sstr << "Recall file is not set. " << *m_FH_p;
00277                     throw ivd_InternalError(ie_FATAL_ERROR, sstr.str(), true);        
00278                 }
00279             } // lock to here
00280 
00281             if (listLen > 1) { // single recall, optimization not needed
00282                 const_cast<i_Recall_t *>(pi)->fileIdx = -1; // this file is already handled
00283                 while (   m_recalledUpToIdx < listLen
00284                     && m_recallList[m_recalledUpToIdx].fileIdx == -1) {
00285                     ++m_recalledUpToIdx;
00286                 }
00287             }
00288             return true;
00289         }
00290     }
00291     return false;
00292 }

Here is the call graph for this function:

Here is the caller graph for this function:

void hsm_Recall::RecallOfFileCanceled (  )  [private]

Definition at line 295 of file hsm_Recall.cpp.

References g_hsm_fhLock, hsm_FileHeader::GetInode(), hsm_FileHeader::IsDeleted(), ivd_USleep, log_FUNC_m, log_WRN_m, m_FH_p, m_recallFileMgr_p, hsm_FileHeader::MakePath(), hsm_RecallInfoGrp::SetRecallFailed(), and hsm_FileHeader::TruncateFile().

Referenced by ProcRecBSStart(), ProcRecEmbData(), and ProcRecRawData().

00295                                       {
00296     log_FUNC_m(RecallOfFileCanceled);
00297     
00298     ivd_GenInode_t inode = m_FH_p->GetInode();
00299     while (!g_hsm_fhLock.CanLockByID(inode)) {
00300         ivd_USleep(10000); // wait a 10 mili sec
00301     }
00302 
00303     try {
00304         // free already written data.
00305         m_FH_p->TruncateFile();
00306         // NOTE!!! Complete recall must be call when all splits are got.
00307         // So set file as recall-failed,
00308         // disable write to it
00309         // and call Recalled(false) at the end
00310         m_recallFileMgr_p->SetRecallFailed();
00311     }
00312     catch (ivd_SysError) {
00313         if (m_FH_p->IsDeleted()) { 
00314             ostringstream sstr;
00315             sstr << "Cannot cancel recall, file " 
00316                 << m_FH_p->MakePath() << " is deleted. ";
00317             log_WRN_m(sstr.str());
00318         }       
00319     }
00320 
00321     g_hsm_fhLock.UnLockByID(inode);
00322 }

Here is the call graph for this function:

Here is the caller graph for this function:

void hsm_Recall::FileRecalledCheck (  )  [private]

Definition at line 325 of file hsm_Recall.cpp.

References g_hsm_fhLock, hsm_FileHeader::GetInode(), hsm_RecallInfoGrp::IsFileRecalled(), hsm_RecallInfoGrp::IsRecallFailed(), ivd_USleep, log_FUNC_m, m_FH_p, m_recallFileMgr_p, and hsm_FileHeader::Recalled().

Referenced by ProcRecFileEnd().

00325                                    {
00326     log_FUNC_m(FileRecalledCheck);
00327 
00328     if (!m_recallFileMgr_p->IsFileRecalled()) {
00329         return;
00330     }
00331     ivd_GenInode_t inode = m_FH_p->GetInode();
00332     while (!g_hsm_fhLock.CanLockByID(inode)) {
00333         ivd_USleep(10000); // wait a 10 mili sec
00334     }
00335 
00336     m_FH_p->Recalled(!m_recallFileMgr_p->IsRecallFailed());
00337 
00338     g_hsm_fhLock.UnLockByID(inode);
00339 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Macro to add class name member s_className.

Reimplemented from df_RecReader.

Definition at line 80 of file hsm_Recall.h.

Definition at line 82 of file hsm_Recall.h.

Referenced by IsFileFromDFforRecall().

Definition at line 85 of file hsm_Recall.h.

Referenced by ProcRecBSStart(), ProcRecEmbData(), and ProcRecRawData().

Definition at line 87 of file hsm_Recall.h.

Referenced by IsFileFromDFforRecall().

Definition at line 92 of file hsm_Recall.h.

Referenced by IsFileFromDFforRecall().

bool hsm_Recall::m_recallData [private]

Definition at line 103 of file hsm_Recall.h.

Referenced by ProcRecBSEnd(), ProcRecBSStart(), and ProcRecFileEnd().

Definition at line 105 of file hsm_Recall.h.

Referenced by GetSizeOfRecalledData(), ProcRecEmbData(), and ProcRecRawData().

Definition at line 106 of file hsm_Recall.h.

Referenced by GetNumOfRecalledFiles(), and ProcRecFileEnd().


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

Generated on Mon Feb 27 19:29:12 2012 for OPENARCHIVE by  doxygen 1.5.6