Public Member Functions | Private Member Functions | Private Attributes

i_HSM_i Class Reference
[Classes for managing events]

#include <i_hsm_impl.h>

Inheritance diagram for i_HSM_i:
Inheritance graph
[legend]
Collaboration diagram for i_HSM_i:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 i_HSM_i (bool &a_hsmRun)
virtual ~i_HSM_i ()
void Remove ()
i_Count_t ForceMigration (const i_StringList_t &a_fileNames, i_UIMessageServer_ptr a_uims)
i_ActivateResult_t ActivateFiles (const i_StringList_t &a_fileNames, i_UIMessageServer_ptr a_uims)
i_Count_t ForceRelease (const i_StringList_t &a_fileNames)
void Reconfigure (const i_ClientConf_t &a_clientConf)
void GetInfo (i_HsmInfo_t_out a_hsmInfo)
void ShowStatus (i_UIMessageServer_ptr a_uims, i_BitFlag_t a_showFlags)
void GetCfg (i_ClientConf_t_out a_clientConf)
void ChangeLogLevel (CORBA::Char a_lLevel)
void Recall (const i_Recall_t &a_file, i_JobID_t a_pmJobId, i_BlkSize_t a_blockSize, i_BufType_t a_bufType, const char *a_diskBufferFS, CORBA::Boolean a_succeeded, i_DownloadAgent_ptr a_download)
void EfficientRecall (const i_RecallList_t &a_seqRecallList, i_JobID_t a_pmJobId, i_JobID_t a_hsmJobIndexID, i_BlkSize_t a_blockSize, i_BufType_t a_bufType, const char *a_diskBufferFS, CORBA::Boolean a_succeeded, i_DownloadAgent_ptr a_download)
void RunScripts ()
i_Count_t DoMigrationJob (i_BufType_t a_resType, const char *a_diskBufferFS, i_JobID_t a_pmJobId, i_BlkSize_t a_blkSize, i_Count_t a_numCopies, i_MigID_t a_migrationID, const i_JobRequestList_t &a_jobFiles, i_UploadAgent_ptr a_upload)
void CompleteMigration (i_BufType_t a_resType, i_JobID_t a_pmJobId, i_CompletionStatus_e a_status)
void CheckFSCvsIVDFS (i_Count_t a_numFilesPerBatch, CORBA::Short a_sysLoadPct, i_UIMessageServer_ptr a_uims)
CORBA::Boolean IsCheckFSCvsIVDFSRunning ()
void Abort (i_HsmTask_e a_hsmTask)
i_Status_t Suspend ()
void Continue (i_Status_t a_status)
void TrigRecall (const i_FileList_t &a_files, CORBA::Boolean a_byFileName, i_MigID_t a_migID, const char *a_into, i_UIMessageServer_ptr a_uims)
i_Count_t TrigMigration ()
void IVDFSRecover (const i_DataBlock_t &a_friBlock)
CORBA::Long IVDFSPrepareRecovery (bool a_fromScratch, const char *a_incrementalFilePath)
CORBA::Boolean IsHSMReady ()
i_Count_t DoDeletion (const i_FileAgeList_t &a_files, i_Count_t &a_missing)
void SetFullAccess (void)
void MigrateByAPI (CORBA::Long a_flags, const char *a_fileName, CORBA::LongLong a_majorColId, CORBA::LongLong a_minorColId, i_JobIDList_t_out a_jobIDs)
void WriteToDirectoryCollocationTable (const char *a_dir, i_ColID_t a_majorColId, const char *a_partName, bool a_force)
i_ColInfoList_tGetCollocationInfo ()
void WriteToDirectoryHl7InfoTable (const char *a_dir, const char *a_hostname, CORBA::ULong a_port, const char *a_partName, bool a_force)
i_HL7InfoList_tGetHL7Info ()
void SetReady (bool a_ready)
void SetSendTerminateEvent (bool a_sendTerminateEvent)
void SetLastFscFileID (ivd_RecordIDX_t a_lastFscFileID)
ivd_RecordIDX_t GetLastFscFileID ()

Private Member Functions

bool PackFile (CORBA::LongLong a_migrationID, hsm_FileHeader &fh, UInt64_t &migSize, df_Packer &packer)
bool UnPackFile (const i_Recall_t &a_file, ivd_FS_File &recallFile, bool manualRecall, UInt64_t &rclSize, df_Unpacker &unpacker)
void TrigEfficientRecall (const i_FileList_t &a_files, bool a_MigrateAfter, i_UIMessageServer_ptr a_uims)

Private Attributes

UInt32_t m_numForcedRelease
UInt32_t m_numRecalls
UInt32_t m_numMigs
UInt32_t m_upTime
bool m_ready
 ready when filter's events are able to cauth
bool m_shutDownInProgress
cmn_Mutex m_consistencyCheckRun_x
bool m_consistencyCheckRun
bool m_abortCheckFSCvsIVDFS
bool & m_hsmRun
bool m_sendTerminateEvent
auto_ptr< hsm_IVDFSRecovererm_recoverer
ivd_RecordIDX_t m_lastFscFileID
cmn_Mutex m_efficientRecall_x
 log_CLASSID_m

Detailed Description

Definition at line 168 of file i_hsm_impl.h.


Constructor & Destructor Documentation

i_HSM_i::i_HSM_i ( bool &  a_hsmRun  ) 

Definition at line 382 of file i_hsm_impl.cpp.

References m_hsmRun.

    :
    m_numForcedRelease(0),
    m_numRecalls(0),
    m_numMigs(0),
    m_upTime(time(NULL)),   // set Up time
    m_ready(false),
    m_shutDownInProgress(false),
    m_consistencyCheckRun(false),
    m_hsmRun(a_hsmRun),
    m_sendTerminateEvent(false)
{
    m_hsmRun = true;
}

i_HSM_i::~i_HSM_i (  )  [virtual]

Definition at line 398 of file i_hsm_impl.cpp.

References dbg_DETAIL, log_DBG_m, log_FUNC_m, m_hsmRun, and ipc_Corba::Shutdown().

                 {

    log_FUNC_m(~i_HSM_i);
    ipc_Corba::Shutdown();
    log_DBG_m(dbg_DETAIL, "i_HSM IS_DOWN.");
    m_hsmRun = false;
}

Here is the call graph for this function:


Member Function Documentation

void i_HSM_i::Abort ( i_HsmTask_e  a_hsmTask  ) 

Definition at line 2644 of file i_hsm_impl.cpp.

References dbg_LOW, i_htCheckFSCvsIVDFS, log_DBG_m, log_FUNC_m, m_abortCheckFSCvsIVDFS, and m_consistencyCheckRun_x.

                                         {
    log_FUNC_m(Abort);
    log_DBG_m(dbg_LOW, "Abrot called:" << a_hsmTask);
    switch (a_hsmTask) {
    case i_htCheckFSCvsIVDFS :
        {
            cmn_MutexLock l(m_consistencyCheckRun_x);
            m_abortCheckFSCvsIVDFS = true;
        }
        break;
    default : ;
        break;
    }
}

i_ActivateResult_t i_HSM_i::ActivateFiles ( const i_StringList_t a_fileNames,
i_UIMessageServer_ptr  a_uims 
)

Definition at line 537 of file i_hsm_impl.cpp.

References hsm_FileHeader::AddToReleaseCanList(), ClientConf_t::CfgRecallOnly, ivd_FS_File::Close(), cmn_IsSpecialFile(), cmn_StrLowerCase(), dbg_DETAIL, dbg_NORM, hsm_FileHeader::DecrRef(), ivd_FS_File::e_Cache, ivd_FS_File::e_MigrateEvt, file, g_clientConf_p, g_fs_api_p, g_hsmDB_p, ivd_FS_File::GetProperties(), ivd_FileSystemAPI::GetRootPath(), fio_DataBase::GetTransObj(), ie_PRECONDITION, ivd_Error, ivd_NULLCHK_m, log_DBG_m, log_FUNC_m, log_WriteEvent(), ivd_FS_FileProperty_t::m_dirtyFlag, ivd_FS_FileProperty_t::m_fileID, ivd_FS_FileProperty_t::m_offlineFlag, NULL, ivd_FS_File::Open(), path, fio_DataBase::ReleaseTransObj(), cmn_Path::RemoveTrailingPathSeparator(), s_className, and ivd_FS_File::TriggerEvent().

                                                                          {
    log_FUNC_m(ActivateFiles);

    try {
        if (g_clientConf_p->CfgRecallOnly) {
            throw ivd_Error(ie_PRECONDITION, "Operation not allowed in Recall only mode.");
        }
        log_DBG_m(dbg_NORM, "Control Files on mountpoint : " << g_fs_api_p->GetRootPath());
        i_ActivateResult_t_var activateResult;
        activateResult->migListCount = 0;
        activateResult->relListCount = 0;
        activateResult->noListCount = 0;

        for (UInt32_t idx = 0; idx < a_fileNames.length(); idx++){

            cmn_Path path(a_fileNames[idx]);
            path.RemoveTrailingPathSeparator();

            {
                cmn_Path rootPath(g_fs_api_p->GetRootPath());
                rootPath.RemoveTrailingPathSeparator();

                cmn_Path currentPath(path);

#if TGT_OS_windows
                cmn_StrLowerCase(currentPath);
                cmn_StrLowerCase(rootPath);
#endif

                if (currentPath == rootPath) { // skip root activation
                    a_uims->DisplayWarning("Cannot activate root directory.");
                    activateResult->noListCount++;
                    continue;
                }
            }

            if (cmn_IsSpecialFile(path)){
                log_DBG_m(dbg_DETAIL, "Special file: " << path << " Will skip it.");
                activateResult->noListCount++;
                continue;
            }

            log_DBG_m(dbg_NORM, "file to control: " << path);

            try {
                ivd_FS_File file(*g_fs_api_p, path);

                ivd_FS_FileProperty_t fileProp;
                try {
                    file.Open(ivd_FS_File::e_Cache, path);
                    file.GetProperties(fileProp);
                    file.Close();
                }
                catch (ivd_SysError) {
                    log_DBG_m(dbg_NORM, "Can't get general inode of fileID " << fileProp.m_fileID
                                << " Probably not exist.");
                    activateResult->noListCount++;
                    continue; // no file found
                }

                if (fileProp.m_offlineFlag) {
                    log_DBG_m(dbg_NORM, "file is offline, do nothing: " << path);
                    activateResult->noListCount++;
                }
                else if (fileProp.m_dirtyFlag) {
                    log_DBG_m(dbg_NORM, "file is dirty, put to MigCandidate: " << path);
                    file.TriggerEvent(ivd_FS_File::e_MigrateEvt);
                    activateResult->migListCount++;
                }
                else {
                    //file is online
                    fio_Transaction &trans = *g_hsmDB_p->GetTransObj();
                    log_DBG_m(dbg_NORM, "file is online, put to ReleaseCandidate: " << path);

                    hsm_FileHeader *hsmOwnFH    = NULL;
                    hsm_FileHeader *hsmOldOwnFH = NULL;
                    hsm_FileHeader *hsmFH       = NULL;
                    hsm_InoObj     *hsmIObj     = NULL;

                    hsmIObj = new hsm_InoObj(fileProp, 0);

                    ivd_NULLCHK_m(hsmIObj, hsm_InoObj::s_className);

                    hsmFH = new hsm_FileHeader( fileProp.m_fileID,
                                                path,
                                                "",
                                                hsmOwnFH,
                                                hsmOldOwnFH,
                                                hsmIObj);

                    ivd_NULLCHK_m(hsmFH, hsm_FileHeader::s_className);

                    if (hsmOwnFH != NULL) { // now is used, so decrease temporary reference
                        hsmOwnFH->DecrRef();
                    }
                    if (hsmOldOwnFH != NULL) { // now is used, so decrease temporary reference
                        hsmOldOwnFH->DecrRef();
                    }


                    activateResult->relListCount++;
                    hsmFH->AddToReleaseCanList(trans);

                    g_hsmDB_p->ReleaseTransObj(trans);
                }
            }
            catch (...) {
                log_DBG_m(dbg_NORM, "trig migrate failed: " << path);
                activateResult->noListCount++;
                continue;
            }
        }


        ostringstream sstr;
        sstr << "Files put to Migration candidate list by user #files: "
             << activateResult->migListCount << endl;
        sstr << "Files put to Release candidate list by user #files: "
            << activateResult->relListCount << endl;
        sstr << "Files left inactive #files: "
            << activateResult->noListCount << endl;
        log_WriteEvent(sstr.str());

        return activateResult._retn();
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

void i_HSM_i::ChangeLogLevel ( CORBA::Char  a_lLevel  ) 

Definition at line 2317 of file i_hsm_impl.cpp.

References cmn_Global::dbg, dbg_DETAIL, dbg_EXTAPI, dbg_LOW, dbg_NORM, g_cmn, log_Debugger::GetLevel(), log_DBG_m, log_FUNC_m, and log_Debugger::SetLevel().

                                              {

    log_FUNC_m(ChangeLogLevel);

    char lLevel = a_lLevel;

    log_DbgLevel_t setlevel;

    switch (lLevel) {
    case 'L':
        setlevel = dbg_LOW;
        break;
    case 'A':
        setlevel = dbg_EXTAPI;
        break;
    case 'N':
        setlevel = dbg_NORM;
        break;
    default:
        setlevel = dbg_DETAIL;
    }
    switch (g_cmn.dbg.GetLevel()){
    case dbg_LOW:
        log_DBG_m(dbg_LOW, "Changing Log level to " << lLevel);
        break;
    case dbg_EXTAPI:
        log_DBG_m(dbg_EXTAPI, "Changing Log level to " << lLevel);
        break;
    case dbg_NORM:
        log_DBG_m(dbg_NORM, "Changing Log level to " << lLevel);
        break;
    default:
        log_DBG_m(dbg_DETAIL, "Changing Log level to " << lLevel);
    }
    g_cmn.dbg.SetLevel(setlevel);

    log_DBG_m(setlevel, "Changing Log level to " << lLevel << " done.");
}

Here is the call graph for this function:

void i_HSM_i::CheckFSCvsIVDFS ( i_Count_t  a_numFilesPerBatch,
CORBA::Short  a_sysLoadPct,
i_UIMessageServer_ptr  a_uims 
)

Definition at line 2358 of file i_hsm_impl.cpp.

References ClientConf_t::CfgPartitionName, dbg_DETAIL, cmn_Global::dirs, evt_ERROR, evt_WARNING, g_clientConf_p, g_cmn, g_fs_api_p, ivd_BaseException::GetError(), ivd_BaseException::GetFriendly(), ivd_FileSystemAPI::GetRootPath(), ie_HSM_NOTREADY, ie_SINGLETON_EXISTS, ivd_Error, ivd_Directories::log, log_DBG_m, log_FUNC_m, log_WriteEvent(), m_abortCheckFSCvsIVDFS, m_consistencyCheckRun, m_consistencyCheckRun_x, ivd_Product::m_nameShort, m_ready, cmn_Global::prod, and cmn_TreeWalk::Start().

                                    {

    log_FUNC_m(CheckFSCvsIVDFS);
    try {
        ui_MsgWriter msgWrite(g_cmn.dirs.log + ( string("check_hsmfs_fsc_")
                                                + g_clientConf_p->CfgPartitionName
                                                + string(".log")),
                              a_uims, false);
        if (!m_ready) {
            throw ivd_Error(ie_HSM_NOTREADY, "See " + g_cmn.prod.m_nameShort
                                             + ".log to know when ready.");
        }

        {
            cmn_MutexLock l(m_consistencyCheckRun_x);
            if (m_consistencyCheckRun) {
                ostringstream sstr;
                sstr << "HSMFS vs. FSC consistency check already running.";
                log_WriteEvent(evt_WARNING, sstr.str());
                throw ivd_Error(ie_SINGLETON_EXISTS, sstr.str());
            }
            m_consistencyCheckRun  = true;
            m_abortCheckFSCvsIVDFS = false;
        }

        try {
            log_DBG_m(dbg_DETAIL, "generate tree walk object"
                               << " filesPer batch " << a_numFilesPerBatch
                               << " sysLoad " << a_sysLoadPct << "%");


            TreeWalk tw(g_clientConf_p->CfgPartitionName,
                        msgWrite, // where to write out msg
                        a_numFilesPerBatch,
                        a_sysLoadPct,
                        m_abortCheckFSCvsIVDFS);

            log_DBG_m(dbg_DETAIL, "tree walk object is generated");
            tw.Start(g_fs_api_p->GetRootPath());
        }
        catch (ivd_Exception &ie) {
            if (ie.GetError() != ie_ABORT) {
                ostringstream sstr;
                sstr << "Tree-walk failed (" << ie.GetFriendly() << ").";
                log_WriteEvent(evt_ERROR, sstr.str());
            }
        }
        catch (...) {
            log_WriteEvent(evt_ERROR, "Tree-walk failed.");
        }

        {
            cmn_MutexLock l(m_consistencyCheckRun_x);
            m_consistencyCheckRun = false;
        }

/*        ostringstream sstre;
        sstre << "End of tree-walk to check IVDFS with FSC.";
        log_WriteEvent( sstre.str());
*/
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

void i_HSM_i::CompleteMigration ( i_BufType_t  a_resType,
i_JobID_t  a_pmJobId,
i_CompletionStatus_e  a_status 
)

Definition at line 1968 of file i_hsm_impl.cpp.

References hsm_JobElemVecMgr::At(), hsm_FileHeader::CompleteMigIsDone(), dbg_DETAIL, dbg_NORM, g_hsm_fhLock, g_hsm_preJobList_p, g_hsmDB_p, hsm_FileHeader::GetInode(), hsm_ListPos::GetJobElemIdx(), hsm_JobListMgr::GetJobElemVecMgr(), hsm_ListPos::GetJobIdx(), fio_DataBase::GetTransObj(), hjs_COMPLETEMIG, hjs_MIGFAILED, i_SUCCEDED, ie_HSM_OTHERLIST, ie_JOB_NOT_FOUND, ivd_Error, IVD_PRINT_ID_FS, ivd_USleep, cmn_Mutex::Lock(), log_DBG_m, log_ERR_m, log_FUNC_m, hsm_JobElemVecMgr::m_jobElemVecMgr_x, m_numMigs, m_shutDownInProgress, hsm_FileHeader::MakePath(), NULL, hsm_JobListMgr::ReleaseJobIdxWithTest(), fio_DataBase::ReleaseTransObj(), hsm_JobListMgr::SetJobStatus(), hsm_JobElemVecMgr::SetJobStatus(), and cmn_Mutex::Unlock().

                                      {

    log_FUNC_m(CompleteMigration);

    fio_Transaction &trans = *g_hsmDB_p->GetTransObj();
    try {
        if (a_status != i_SUCCEDED){
            log_DBG_m(dbg_NORM, "CompleteMigration: Migration IS_NOT SUCCEDED! Files WILL_BE released from job.");
        }

        // Use iterator on list instead of index on sequence, cause of manipulation.
        // if file header can't be locked then its index goes to the end of list.
        list<Int32_t> postponnedList;
        Int32_t    hsmJobIdx(0);

        hsm_JobElemVecMgr *jobElemVecMgr_p = g_hsm_preJobList_p->GetJobElemVecMgr(a_pmJobId, hsmJobIdx);

        if (jobElemVecMgr_p == NULL) {
            // release transaction
            g_hsmDB_p->ReleaseTransObj(trans);

            ostringstream sstr;
            sstr
                << "Internal data structures for job don't exist any more. "
                << "Job already aborted (?): " << a_pmJobId;
            throw ivd_Error(ie_JOB_NOT_FOUND, sstr.str(), true);
        }

        jobElemVecMgr_p->SetJobStatus(hjs_COMPLETEMIG);

        log_DBG_m(dbg_NORM, "CompleteMigration: Start JobIdx=[" << hsmJobIdx << "] for jobID: " << a_pmJobId);

        for (Int32_t i = 0; i < (Int32_t)jobElemVecMgr_p->size(); i++){
            postponnedList.push_back(i);
        }

        int lastMigLeftCounter = 20;
        list<Int32_t>::iterator iter;

        //
        // Code review by Matej Kenda
        // Bad design: Locking for class' members is used from
        // outside: The object jobElemVecMgr_p should protect it's own members
        // by itself.
        //
// fix lock bug.  Lock list until FH is locked by inode
       jobElemVecMgr_p->m_jobElemVecMgr_x.Lock();
        while ((iter = postponnedList.begin()) != postponnedList.end()) {
            if (m_shutDownInProgress) {
                log_DBG_m (dbg_NORM, "Shut down. Abort CompleteMigration.");
                break;
            }

            Int32_t   fIdx    = *iter;

            log_DBG_m(dbg_DETAIL, "Job at idx [" << hsmJobIdx << ":" << fIdx << "]");

            hsm_FileHeader *tFHobj = jobElemVecMgr_p->At(fIdx);
            if (tFHobj == NULL) {
                // file is removed from list
                log_DBG_m(dbg_DETAIL, "Skip FH, it's NULL");
                postponnedList.erase(iter);
                continue;
            }
            // try to lock FH
            ivd_GenInode_t inode = tFHobj->GetInode();
            if (!g_hsm_fhLock.CanLockByID(inode)) {
                log_DBG_m(dbg_DETAIL, "Postpone FH, it's currently locked.");
                // move it to last in list
                if (postponnedList.size() == 1) {
                    ivd_USleep(100000); // only one left, sleep 0.1 sec for lastMigLeftCounter times
                    lastMigLeftCounter--;
                    if (lastMigLeftCounter == 0) {
// fix bug 490
                        log_ERR_m("CompleteMigration: Can't lock file " << tFHobj->MakePath()
                                   << " Skip it. Inode " << IVD_PRINT_ID_FS(inode));
                        postponnedList.erase(iter);
                        continue;
//                        throw ivd_Error(ie_HSM_LONG_INO_LOCK); // time out
                    }
                }
                else {
                    postponnedList.splice(postponnedList.end(), postponnedList, iter);
                }
                continue;
            }
    // fix lock bug
            jobElemVecMgr_p->m_jobElemVecMgr_x.Unlock();
            // check if job  indeces match
            if (   tFHobj->GetJobIdx()     != hsmJobIdx
                || tFHobj->GetJobElemIdx() != fIdx) {
                // FH is probably moved to other list after FH is got,
                // checket to NULL and lock it
                // another get of FH must be NULL
//                if (g_hsm_preJobList_p->At(hsmJobIdx, fileIdx) != NULL) {
                if (jobElemVecMgr_p->At(fIdx) != NULL) {
                    throw ivd_Error(ie_HSM_OTHERLIST);
                }
                postponnedList.erase(iter);
                g_hsm_fhLock.UnLockByID(inode);
                continue;
            }

            if (tFHobj->CompleteMigIsDone(a_status == i_SUCCEDED, trans)){
                m_numMigs++; // added for statistic by jandrej@hermes.si
            }

            postponnedList.erase(iter);

            g_hsm_fhLock.UnLockByID(inode);


            // fix lock bug.  Lock list until FH is locked by inode
           jobElemVecMgr_p->m_jobElemVecMgr_x.Lock();
        } // for each file
// fix lock bug
        jobElemVecMgr_p->m_jobElemVecMgr_x.Unlock();

        if (hsmJobIdx != -1) {
            if (a_status != i_SUCCEDED){
                g_hsm_preJobList_p->SetJobStatus(hsmJobIdx, hjs_MIGFAILED);
            }
            else {
                g_hsm_preJobList_p->ReleaseJobIdxWithTest(hsmJobIdx);
            }
        }
    }
    ipc_CATCH_IVD_THROW_CORBA_m;

    g_hsmDB_p->ReleaseTransObj(trans);

    log_DBG_m(dbg_NORM, "CompleteMigration: End for jobID: " << a_pmJobId);
}

Here is the call graph for this function:

void i_HSM_i::Continue ( i_Status_t  a_status  ) 

Definition at line 2455 of file i_hsm_impl.cpp.

References fio_DataBase::Continue(), evt_ERROR, g_hsmDB_p, ivd_BaseException::GetDescription(), ivd_BaseException::GetFriendly(), ivd_BaseException::GetText(), log_FUNC_m, and log_WriteEvent().

                                          {
    log_FUNC_m(Continue);
    try {

        try {
            g_hsmDB_p->Continue(a_status);
            log_WriteEvent("HSM DB resumed.");
        }
        catch (ivd_Exception &ie) {
            ostringstream sstr;
            sstr << "HSM DB resume failed (" << ie.GetFriendly() << ").";
            log_WriteEvent(evt_ERROR, sstr.str());
            string throwStr = ie.GetText() + ie.GetDescription();
            throw;
        }
        catch (...) {
            log_WriteEvent(evt_ERROR, "HSM DB resume failed.");
            throw;
        }
    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

i_Count_t i_HSM_i::DoDeletion ( const i_FileAgeList_t a_files,
i_Count_t a_missing 
)

Definition at line 2660 of file i_hsm_impl.cpp.

References dbg_DETAIL, cmn_File::DeleteDir(), evt_WARNING, i_FileAge_t::expAge, file, i_FileAge_t::filePath, g_fs_api_p, ivd_BaseException::GetFriendly(), ivd_FileSystemAPI::GetRootPath(), ift_DIR, log_DBG_m, log_FUNC_m, log_WriteEvent(), NULL, and subcomp_DELETE.

                                                                                  {
    log_FUNC_m(DoDeletion);

    i_Count_t      count = 0;
    i_Count_t      total = a_files.length();
    ivd_FileInfo_t info;
    ivd_Time_t     timeNow;

    a_missing = 0;

    try {

    #if IVD_POSIX_OS
#warning "Use cmn_Time, because it already hides platform differences."
        timeNow = time(NULL);
    #elif TGT_OS_windows
        FILETIME ft;
        // get current time as filetime
        GetSystemTimeAsFileTime(&ft);
        // convert to ivd_Time_t: see ToUInt64 and cmn_File::StatF in cmn_File_WIN32.cpp
        timeNow = ((static_cast<UInt64_t>(ft.dwHighDateTime) << 32) | ft.dwLowDateTime);
    #endif

        log_WriteEvent("Started deletion job.", subcomp_DELETE);
        for (UInt32_t item = 0; item < total; item++) {
            const i_FileAge_t &fileAge = a_files[item];
            cmn_File file(g_fs_api_p->GetRootPath() + string(fileAge.filePath));
            try {
                // check for file existence
                file.StatF(info);
    #if IVD_POSIX_OS
                if ((timeNow - info.timeModify) < fileAge.expAge) {
    #elif TGT_OS_windows
                if (((timeNow - info.timeModify)/10000000) < fileAge.expAge) {
    #endif
                    // file is too young
                    log_WriteEvent("WARNING: File \"" + file.GetFullPathRef()
                                + "\" is younger than FSC thinks.",
                                subcomp_DELETE);
                    continue;
                }
            }
            catch (ivd_SysError) {
                // assume file doesn't exist
                a_missing += 1;
                log_WriteEvent("WARNING: Path \"" + file.GetFullPathRef()
                            + "\" does not exist on file system.",
                            subcomp_DELETE);
                continue;
            }
            // delete file/directory
            try {
                if (info.type == ift_DIR) {
                    cmn_File::DeleteDir(file.GetFullPathRef());
                }
                else {

                    // NOTE: In future it would be better to use libfsapi

    #if TGT_OS_windows
                    UInt32_t attr = file.GetFileAttributes();
                    bool isReadOnly = (attr & FILE_ATTRIBUTE_READONLY);

                    if (isReadOnly) {
                        // Clear RO flag
                        log_DBG_m(dbg_DETAIL, "Clearing " << file.GetFullPathRef() << " RO attribute.")
                            file.SetFileAttributes(attr & !FILE_ATTRIBUTE_READONLY);
                    }
    #endif
                    file.DeleteF();
                }
                count += 1;
            }
            catch (ivd_SysError &se) {
                ostringstream sstr;
                sstr << "A problem accured when deleting \""
                    << file.GetFullPathRef()
                    << "\". System error "
                    << se.GetFriendly();
                log_WriteEvent(evt_WARNING, sstr.str(), subcomp_DELETE);
            }
        }
        ostringstream oss;
        oss << total << " expired files, "
            << count << " deleted files, "
            << a_missing << " files not found.";
        log_DBG_m(dbg_DETAIL, oss.str());
        log_WriteEvent(oss.str(), subcomp_DELETE);
        return count;
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

i_Count_t i_HSM_i::DoMigrationJob ( i_BufType_t  a_resType,
const char *  a_diskBufferFS,
i_JobID_t  a_pmJobId,
i_BlkSize_t  a_blkSize,
i_Count_t  a_numCopies,
i_MigID_t  a_migrationID,
const i_JobRequestList_t a_jobFiles,
i_UploadAgent_ptr  a_upload 
)

Definition at line 1477 of file i_hsm_impl.cpp.

References hsm_JobElemVecMgr::At(), blk_Data_c, cmn_Num2Str(), cmn_Global::dbg, dbg_DETAIL, dbg_LOW, dbg_NORM, eDoMigStart, df_Packer::EndOfData(), eNotInDoMig, g_cmn, g_hsm_fhLock, g_hsm_preJobList_p, hsm_FileHeader::GetInode(), hsm_ListPos::GetJobElemIdx(), hsm_JobListMgr::GetJobElemVecMgr(), hsm_ListPos::GetJobIdx(), log_Debugger::GetLevel(), df_Packer::Go(), hjs_DOMIG, hjs_WAITFORCOMPLETEMIG, i_DISK_BUF, i_REMOTE_BUF, ie_EMPTYLIST, ie_HSM_OTHERLIST, ie_INVALID_ARG, ie_JOB_NOT_FOUND, ivd_Error, IVD_PRINT_ID_FS, ivd_USleep, cmn_Mutex::Lock(), log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), hsm_JobElemVecMgr::m_jobElemVecMgr_x, m_shutDownInProgress, hsm_FileHeader::MakePath(), hsm_FileHeader::MigrationIsDone(), df_Packer::NewDiskBuffer(), df_Packer::NewNetBuffer(), NULL, PackFile(), hsm_FileHeader::SetDataMigStat(), hsm_JobElemVecMgr::SetJobStatus(), hsm_JobElemVecMgr::SetMigJobID(), and cmn_Mutex::Unlock().

                                  {

    log_FUNC_m(DoMigrationJob);

    log_DBG_m(dbg_NORM, "Number of copies: " << a_numCopies);

    UInt32_t        numMigFiles = 0;
    UInt64_t        sizeMigFiles = 0;

    string diskBufferFS(a_diskBufferFS);
    try {
        UInt32_t numFiles = a_jobFiles.length();

        if (numFiles == 0) {
            throw ivd_Error(ie_EMPTYLIST, "DoMigrationJob got empty sequence of files", true);
        }

        const UInt32_t  blkSize_c   = a_blkSize;
        string tjobID = cmn_Num2Str((Int64_t)a_pmJobId);

        Int32_t jobIdx(0);
        hsm_JobElemVecMgr *jobElemVecMgr_p(NULL);

        /*
         * HSM starts job in PM and stores it's job ID in the internal job list.
         * Job might call DoMigrationJob job sooner than the ID is stored.
         * Several retries are done before returning error to the job.
         *
         * NOTE: THIS IS A HACK, because modifying the internal list should be better protected
         * by some kind of locking mechanism: hsm_JobListMgr & Co requires partial rewrite.
         */
        for (int retries(1); retries <= 100; retries++) {
            jobElemVecMgr_p =
                g_hsm_preJobList_p->GetJobElemVecMgr(a_pmJobId, jobIdx);

            if (jobElemVecMgr_p != NULL) {
                break;
            }
            else {
                // The job ID might not be stored in the list yet
                // Do retries in steps of 50ms, 100ms, 150ms, ..., 5s.
                ivd_USleep(retries * 50000);
            }
        }

        if (jobElemVecMgr_p == NULL) {
            ostringstream sstr;
            sstr
                << "Internal data structures for job don't exist any more. "
                << "Job already aborted (?): " << a_pmJobId;
            throw ivd_Error(ie_JOB_NOT_FOUND, sstr.str(), true);
        }

        log_DBG_m(dbg_LOW, "DoMigrationJob: idx [" << jobIdx << "]"  << endl
                            << "MigID=" << a_migrationID
                            << " JobID=" << a_pmJobId << " num files " << numFiles);
        //
        // job id was already set when migration job was created
        // We are setting migration ID at this point
        // TODO: Split setting job ID and migration ID
        //
        jobElemVecMgr_p->SetMigJobID(a_pmJobId, a_migrationID);

        if (g_cmn.dbg.GetLevel() ==  dbg_DETAIL) {
            log_DBG_m(dbg_DETAIL, "  DoMigration list elements");
            for (UInt32_t idx = 0; idx < numFiles; idx++){
                log_DBG_m(dbg_DETAIL,
                    "~~~~~ file at [" << a_jobFiles[idx].fileIdx << "]");
            }
        };

        // Prepare data transfer
        bbt_BufType_t transferType;
        switch (a_resType) {
            case i_DISK_BUF:
                transferType = bbt_DISK_BUF; break;
            case i_REMOTE_BUF:
                transferType = bbt_REMOTE_BUF; break;
            default: throw ivd_InternalError(
                ie_INVALID_ARG, "Unsupported transfer type.");
        };
        df_Packer packer(blk_Data_c, transferType, blkSize_c, UInt16_t(a_numCopies));
        switch (a_resType) {
            case i_DISK_BUF:
                packer.NewDiskBuffer(tjobID, diskBufferFS);
                break;
            case i_REMOTE_BUF:
                packer.NewNetBuffer(a_upload);
                break;
            default:
                throw ivd_InternalError(
                    ie_INVALID_ARG, "Unsupported transfer type.");
        };
        packer.Go();
        log_DBG_m(dbg_DETAIL, "*-DoMigrationJob df_packer created");

        jobElemVecMgr_p->SetJobStatus(hjs_DOMIG);

        // if file header can't be locked then its index goes to skipped list.
        list<UInt32_t> postponnedList;

        for (UInt32_t i = 0; i < numFiles; i++){
            postponnedList.push_back(i);
        }

        int lastMigLeftCounter = 20;
        list<UInt32_t>::iterator iter;
// fix lock bug.  Lock list until FH is locked by inode
       jobElemVecMgr_p->m_jobElemVecMgr_x.Lock();

        while ((iter = postponnedList.begin()) != postponnedList.end()) {
            if (m_shutDownInProgress) {
                log_DBG_m (dbg_NORM, "Shut down. Abort DoMigrationJob.");
                jobElemVecMgr_p->m_jobElemVecMgr_x.Unlock();
                return numMigFiles;
            }

            UInt32_t   fIdx    = *iter;

            Int32_t    fileIdx = a_jobFiles[fIdx].fileIdx;

            if (fileIdx == -1) {
                // file is removed from list
                log_DBG_m(dbg_DETAIL, "Skip, unused field.");
                postponnedList.erase(iter);
                continue;
            }
            hsm_FileHeader *tFHobj = jobElemVecMgr_p->At(fileIdx);
            if (tFHobj == NULL) {
                // file is removed from list
                log_DBG_m(dbg_DETAIL, "Skip FH, it's NULL");
                postponnedList.erase(iter);
                continue;
            }
            ivd_GenInode_t inode = tFHobj->GetInode();
            // try to lock FH
            if (!g_hsm_fhLock.CanLockByID(inode)) {
                log_DBG_m(dbg_DETAIL, "Postpone FH, it's currently locked.");
                // move it to last in list
                if (postponnedList.size() == 1) {
                    ivd_USleep(100000);   // only one left, sleep a while
                    lastMigLeftCounter--;
                    if (lastMigLeftCounter == 0) {
// fix bug 490
                        log_ERR_m("DoMigrationJob: Can't lock file " << tFHobj->MakePath()
                                   << " Skip it. Inode " << IVD_PRINT_ID_FS(inode));
                        postponnedList.erase(iter);
                        continue;
//                        throw ivd_Error(ie_HSM_LONG_INO_LOCK); // time out
                    }
                }
                else {
                    postponnedList.splice(postponnedList.end(), postponnedList, iter);
                }
                continue;
            }
// fix lock bug
            log_DBG_m(dbg_DETAIL, "m_jobElemVecMgr_x.Unlock()");
            jobElemVecMgr_p->m_jobElemVecMgr_x.Unlock();

            // fix bug 491
            // this member is not under mutex, it is set soon after obj lock
            // on other side event manager can set it util wait a while
            // after unsucceed lock see /client/hsm/event.mgr.cpp method AddEvent()
            tFHobj->SetDataMigStat(eDoMigStart);

            // check if job  indexes match
            if (   tFHobj->GetJobIdx()     != jobIdx
                || tFHobj->GetJobElemIdx() != fileIdx) {
                // FH is probably moved to other list after FH is got,
                // checket to NULL and lock it
                // another get of FH must be NULL
                if (jobElemVecMgr_p->At(fileIdx) != NULL) {
// one of bug 469
            // fix bug 491
                    tFHobj->SetDataMigStat(eNotInDoMig);
                    g_hsm_fhLock.UnLockByID(inode);
                    throw ivd_Error(ie_HSM_OTHERLIST);
                }
                postponnedList.erase(iter);
            // fix bug 491
                log_DBG_m(dbg_DETAIL, "postponnedList.erase(iter)");
                tFHobj->SetDataMigStat(eNotInDoMig);
                g_hsm_fhLock.UnLockByID(inode);
                jobElemVecMgr_p->m_jobElemVecMgr_x.Lock();
                continue;
            }

            UInt64_t migSize;
            if (PackFile(a_migrationID, *tFHobj, migSize, packer)) {
                tFHobj->MigrationIsDone();
                //
                // Do not increase the counter if the file is not packed to the
                // disk buffer.
                //
                // PM needs the information about the number of files actually
                // packed in the disk buffer.
                //
                numMigFiles++;
                sizeMigFiles += migSize;
            }

            postponnedList.erase(iter);

            // fix bug 491
            tFHobj->SetDataMigStat(eNotInDoMig);
            g_hsm_fhLock.UnLockByID(inode);

// fix lock bug
           jobElemVecMgr_p->m_jobElemVecMgr_x.Lock();
        } // while (for each file)
// fix lock bug
        jobElemVecMgr_p->m_jobElemVecMgr_x.Unlock();

        packer.EndOfData(); // end of data - flush last block


        jobElemVecMgr_p->SetJobStatus(hjs_WAITFORCOMPLETEMIG);
        log_DBG_m(dbg_LOW, "DoMigrationJob: FINISHED. Waiting for CompleteMigration for JobID "
                            << a_pmJobId
                            << " Num files: " << numMigFiles);
        ostringstream sstr;
        sstr << "Migration (#files: " << numMigFiles
             << ", size: " << sizeMigFiles/1024 << " KB).";
        log_WriteEvent(sstr.str(), "", a_pmJobId);
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
    return numMigFiles;
}

Here is the call graph for this function:

void i_HSM_i::EfficientRecall ( const i_RecallList_t a_seqRecallList,
i_JobID_t  a_pmJobId,
i_JobID_t  a_hsmJobIndexID,
i_BlkSize_t  a_blockSize,
i_BufType_t  a_bufType,
const char *  a_diskBufferFS,
CORBA::Boolean  a_succeeded,
i_DownloadAgent_ptr  a_download 
)

Definition at line 1102 of file i_hsm_impl.cpp.

References hsm_JobElemVecMgr::At(), bbt_DISK_BUF, bbt_REMOTE_BUF, blk_Data_c, cmn_Num2Str(), dbg_DETAIL, dbg_LOW, i_Recall_t::fileIdx, g_hsm_fhLock, g_hsm_preJobList_p, hsm_FileHeader::GetFileID(), hsm_FileHeader::GetInode(), hsm_JobListMgr::GetJobElemVecMgr(), hsm_Recall::GetNumOfRecalledFiles(), hsm_Recall::GetSizeOfRecalledData(), i_DISK_BUF, i_REMOTE_BUF, i_SHMEM_BUF, ie_INVALID_ARG, IVD_PRINT_ID_FS, ivd_USleep, cmn_Mutex::Lock(), log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), log_WRN_m, m_efficientRecall_x, hsm_JobElemVecMgr::m_jobElemVecMgr_x, hsm_FileHeader::MakePath(), df_BlockReader::NewDiskBuffer(), df_BlockReader::NewNetBuffer(), NULL, hsm_FileHeader::Recalled(), hsm_JobListMgr::ReleaseJobIdxWithTest(), cmn_Mutex::Unlock(), and df_RecReader::Unpack().

                                          {

    log_FUNC_m(EfficientRecall);

    cmn_MutexLock l(m_efficientRecall_x);

    string diskBufferFS(a_diskBufferFS);
    string bufId = cmn_Num2Str((Int64_t)a_pmJobId);

    bbt_BufType_t bufType = bbt_DISK_BUF;

    Int32_t jobIdx(0);
    hsm_JobElemVecMgr *jobElemVecMgr_p =
        g_hsm_preJobList_p->GetJobElemVecMgr(a_hsmJobIndexID, jobIdx);


    if (jobElemVecMgr_p == NULL) {
        if (!a_succeeded) {
            log_DBG_m(dbg_LOW,
                "HSM job file list not found. "
                << "The job already failed or was aborted. "
                << "job ID: " << a_pmJobId
                << " hsmJobIndexID: " << a_hsmJobIndexID);
        }
        else {
            log_WRN_m(
                "HSM job file list not found for efficient recall. " << endl
                << "Did the job already fail or was aborted? "
                << "job ID: " << a_pmJobId
                << " hsmJobIndexID: " << a_hsmJobIndexID);
        }
        return;
    }


    if (!a_succeeded) {

        ostringstream errMsg;
        errMsg << "Recall failed. JobID: " << a_pmJobId
               << ". HSM Job Idx: " << jobIdx << ". "
               << "Check server log for details." << endl;

        log_ERR_m(errMsg.str());
        errMsg.clear();


        //list all files that failed
        errMsg << "             Inode    FileID Path relative to mount point" << endl;

        int listLen = a_seqRecallList.length();
        const i_Recall_t *pi = &a_seqRecallList[0];
        log_DBG_m (dbg_DETAIL, "pi: " << hex << pi << dec);

        const i_Recall_t *pe = pi + listLen;
        log_DBG_m (dbg_DETAIL, "pe: " << hex << pe << dec);
        for (;pi != pe; ++pi) {
            log_DBG_m (dbg_DETAIL, "FAILED to recall a file: " << *pi);

            //
            // Code review by Matej Kenda
            // Bad design: Locking for class' members is used from
            // outside: The object jobElemVecMgr_p should protect it's own members
            // by itself.
            //
            jobElemVecMgr_p->m_jobElemVecMgr_x.Lock();
            hsm_FileHeader* fh_p = jobElemVecMgr_p->At(pi->fileIdx);
            jobElemVecMgr_p->m_jobElemVecMgr_x.Unlock();
            if (fh_p == NULL) {
                continue;
            }
            ivd_GenInode_t inode = fh_p->GetInode();
            while (!g_hsm_fhLock.CanLockByID(inode)) {
                ivd_USleep(10000); // wait a 10 mili sec
            }
            errMsg << IVD_PRINT_ID_FS(fh_p->GetInode())
                 << setw(10) << fh_p->GetFileID()
                 << " " << fh_p->MakePath() << endl;
            log_DBG_m(dbg_DETAIL, IVD_PRINT_ID_FS(fh_p->GetInode())
                << setw(10) << fh_p->GetFileID()
                << " " << fh_p->MakePath());


            fh_p->Recalled(false);

            g_hsm_fhLock.UnLockByID(inode);
        }

        log_ERR_m(errMsg.str());

        ostringstream sstr;
        sstr << "(#files: " << a_seqRecallList.length() << ")";

        log_WriteEvent(
            sstr.str(), "Recall failed.",
            a_pmJobId,
            cmn_Num2Str(jobIdx));

        UInt32_t numRclFiles;
        UInt64_t sizeRclFiles;
        g_hsm_preJobList_p->ReleaseJobIdxWithTest(jobIdx, numRclFiles, sizeRclFiles);

        return;
    }

    try {

        log_DBG_m (dbg_DETAIL, "  Efficient RECALL with jobID " << a_pmJobId);

        switch (a_bufType ) {
        case i_DISK_BUF:
            bufType = bbt_DISK_BUF;
            break;
        case i_SHMEM_BUF:
            bufType = bbt_SHMEM_BUF;
            break;
        case i_REMOTE_BUF:
            bufType = bbt_REMOTE_BUF;
            break;
        default:
            throw ivd_InternalError(
                ie_INVALID_ARG,  "Unsupported transfer type.");
        }
        df_BlockReader *blockReader_p = new df_BlockReader(blk_Data_c, bufType, a_blockSize);
        hsm_Recall recallData(
            blockReader_p,
            *jobElemVecMgr_p,
            a_pmJobId,
            a_seqRecallList);

        switch (bufType) {
            case bbt_DISK_BUF:
                blockReader_p->NewDiskBuffer(bufId, diskBufferFS);
                break;
            case bbt_REMOTE_BUF:
                blockReader_p->NewNetBuffer(a_download);
                break;
            default:;
        }

        recallData.Unpack();

        UInt32_t numRclFiles;
        UInt64_t sizeRclFiles;

        log_DBG_m (dbg_DETAIL, "Unpack finished.");

        if (g_hsm_preJobList_p->ReleaseJobIdxWithTest(jobIdx, numRclFiles, sizeRclFiles)) {
            ostringstream sstr;
            sstr << "Finished (#files: " << recallData.GetNumOfRecalledFiles()
                << ", size: " << recallData.GetSizeOfRecalledData()/1024 << " KB";
            sstr << "; Grand total #files: " << numRclFiles
                << ", size: " << sizeRclFiles/1024 << " KB).";

            //log_WriteEvent(sstr.str());
            log_WriteEvent(
                sstr.str(), "RECALL",
                a_pmJobId,
                cmn_Num2Str(jobIdx));
        }
        else {
            ostringstream sstr;
            sstr << " (#files: " << recallData.GetNumOfRecalledFiles()
                << ", size: " << recallData.GetSizeOfRecalledData()/1024 << " KB).";

            //log_WriteEvent(sstr.str());
            log_WriteEvent(
                sstr.str(), "RECALL",
                a_pmJobId,
                cmn_Num2Str(jobIdx));
        }

    }
    catch (ivd_Exception &ie) {
        log_DBG_m(dbg_DETAIL, ie);
    }
    catch (...) {
        log_DBG_m(dbg_DETAIL, "Recall: Error in packer.");
    }
}

Here is the call graph for this function:

i_Count_t i_HSM_i::ForceMigration ( const i_StringList_t a_fileNames,
i_UIMessageServer_ptr  a_uims 
)

Definition at line 434 of file i_hsm_impl.cpp.

References ClientConf_t::CfgRecallOnly, ivd_FS_File::Close(), cmn_IsSpecialFile(), cmn_StrLowerCase(), dbg_NORM, ivd_FS_File::e_Cache, ivd_FS_File::e_MigrateEvt, file, g_clientConf_p, g_fs_api_p, ivd_FS_File::GetProperties(), ivd_FileSystemAPI::GetRootPath(), ie_PRECONDITION, ivd_Error, log_DBG_m, log_FUNC_m, log_WriteEvent(), ivd_FS_FileProperty_t::m_fileID, ivd_FS_FileProperty_t::m_offlineFlag, max, ivd_FS_File::Open(), path, cmn_Path::RemoveTrailingPathSeparator(), TrigEfficientRecall(), and ivd_FS_File::TriggerEvent().

                                                                  {
    log_FUNC_m(ForceMigration);

    try {
        if (g_clientConf_p->CfgRecallOnly) {
            throw ivd_Error(ie_PRECONDITION, "Operation not allowed in Recall only mode.");
        }
        log_DBG_m(dbg_NORM, "Force migration on mountpoint : " << g_fs_api_p->GetRootPath());
        Int32_t numMigrated = 0;

        i_FileList_t toRecall;
        UInt32_t seqIdx  = 0;
        CORBA::ULong max = 16;
        toRecall.length(max);

        for (UInt32_t idx = 0; idx < a_fileNames.length(); idx++){
            cmn_Path path(a_fileNames[idx]);
            path.RemoveTrailingPathSeparator();

            {
                cmn_Path rootPath(g_fs_api_p->GetRootPath());
                rootPath.RemoveTrailingPathSeparator();

                cmn_Path currentPath(path);
#if TGT_OS_windows
                cmn_StrLowerCase(currentPath);
                cmn_StrLowerCase(rootPath);
#endif

                if (currentPath == rootPath) { // skip root migration
                    a_uims->DisplayWarning("Cannot migrate root directory.");
                    numMigrated--;
                    continue;
                }
            }

            if (cmn_IsSpecialFile(path)){
                log_DBG_m(dbg_NORM, "Special file: " << path << " Will skip it.");
                numMigrated--;
                continue;
            }

            log_DBG_m(dbg_NORM, "file to migrate: " << path);

            try {
                ivd_FS_File file(*g_fs_api_p, path);

                ivd_FS_FileProperty_t fileProp;
                try {
                    file.Open(ivd_FS_File::e_Cache, path);
                    file.GetProperties(fileProp);
                    file.Close();
                }
                catch (ivd_SysError &ise) {
                    log_DBG_m(dbg_NORM, "Can't get general inode of fileID " << fileProp.m_fileID
                                << " Probably not exist. " << ise);
                    continue; // no file found
                }
                if (fileProp.m_offlineFlag) {
                    if (seqIdx >= toRecall.maximum()) {
                        max *= 2;
                        toRecall.length(max);
                    }

                    toRecall[seqIdx].fileID = fileProp.m_fileID;
                    toRecall[seqIdx].name = CORBA::string_dup(path.c_str());

                    ++seqIdx;
                }
                else {
                    file.TriggerEvent(ivd_FS_File::e_MigrateEvt);
                }
            }
            catch (...) {
                log_DBG_m(dbg_NORM, "trig migrate failed: " <<
                          path);
                continue;
            }
            numMigrated++;
        }
        if (seqIdx > 0) {
            toRecall.length(seqIdx);
            TrigEfficientRecall(toRecall, true, a_uims);
        }

        if (numMigrated < 0) {
            numMigrated = 0;
        }
        else if (numMigrated > 0) {
            ostringstream sstr;
            sstr << "Migration requested by user (#files: "
                 << numMigrated << ", " << seqIdx << " files are recalled first).";
            log_WriteEvent(sstr.str());
        }
        return (UInt32_t)numMigrated;
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

i_Count_t i_HSM_i::ForceRelease ( const i_StringList_t a_fileNames  ) 

Definition at line 668 of file i_hsm_impl.cpp.

References ivd_FS_File::Close(), dbg_DETAIL, dbg_LOW, dbg_NORM, ivd_FS_File::e_Cache, ivd_FS_File::e_Release, g_fs_api_p, g_hsm_fhLock, ivd_FS_File::GetProperties(), ift_FILE, ivd_FS_File::IsOfflineProlonged(), IVD_PRINT_ID_FS, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), ivd_FS_FileProperty_t::m_dirtyFlag, ivd_FS_FileProperty_t::m_fileID, ivd_FS_FileProperty_t::m_fileSize, ivd_FS_FileProperty_t::m_Inode, m_numForcedRelease, ivd_FS_FileProperty_t::m_offlineFlag, ivd_FS_FileProperty_t::m_type, ivd_FS_File::Open(), ivd_FS_File::Release(), and ivd_FS_File::SetDataOffline().

                                                                 {
    log_FUNC_m(ForceRelease);

    try {
        UInt32_t numReleased = 0;
        UInt64_t sizeReleased = 0;

        for (UInt32_t idx = 0; idx < a_fileNames.length(); idx ++) {

            cmn_Path fullPath = string(a_fileNames[idx]);
            ivd_FS_FileProperty_t fileProp;

            try {
                ivd_FS_File releaseFile(*g_fs_api_p, fullPath);
                try {
                    releaseFile.Open(ivd_FS_File::e_Cache, fullPath);
                    releaseFile.GetProperties(fileProp);
                }
                catch (ivd_Exception &ie) {
                    log_DBG_m(dbg_LOW, "Can't GetProperties before ForceRelease " << ie);
                    continue;
                }
                log_DBG_m(dbg_NORM,
                    "Forced release :" << fullPath <<
                    " inode " << IVD_PRINT_ID_FS(fileProp.m_Inode) <<
                    " file id " << fileProp.m_fileID );

                bool prolonged(false);

                if (   fileProp.m_fileID == 0
                    || fileProp.m_dirtyFlag
                    || fileProp.m_fileSize == 0
                    || fileProp.m_type != ift_FILE
                    || (   fileProp.m_offlineFlag
                       && !(prolonged = releaseFile.IsOfflineProlonged())
                       )
                   ) {

                    log_DBG_m(dbg_NORM,
                        "Can't release file " << fullPath << endl
                      <<  " fileID      = " << fileProp.m_fileID
                      <<  " dirtyFlag = "<< boolalpha  << fileProp.m_dirtyFlag
                      <<  " fileSize  = " << fileProp.m_fileSize
                      <<  " type != ift_FILE = "<< boolalpha  << (fileProp.m_type != ift_FILE)
                      <<  " offlineFlag = " << boolalpha << fileProp.m_offlineFlag
                      <<  " partially recalled = " << boolalpha << prolonged
                      << endl <<  " fileId = 0 or file is dirty or file size is 0 or entry is not a file or not prolonged.");

                    continue;
                };

                if (!g_hsm_fhLock.CanLockByID(fileProp.m_Inode)) {
                    log_DBG_m(dbg_NORM,
                        "Forced Release file " << fullPath << endl <<
                        " FAILED. Cannot Lock by Inode.");

                    continue;
                };

                try {
                    releaseFile.SetDataOffline(0, fileProp.m_fileSize);
                }
                catch (ivd_Exception) {
                    g_hsm_fhLock.UnLockByID(fileProp.m_Inode);
                    continue;
                }
                catch (...) {
                    log_ERR_m(
                        "File " << fullPath <<
                        " can't be set offline!");

                    g_hsm_fhLock.UnLockByID(fileProp.m_Inode);
                    continue;
                }

                log_DBG_m(dbg_DETAIL,
                    "Truncate file " << fullPath << " write offline flag done.");
                //HPUX
                releaseFile.Close();
                releaseFile.Open(ivd_FS_File::e_Release);
                try {
                    releaseFile.Release();
                    releaseFile.Close();
                }
                catch (ivd_Exception &ie) {
                    log_ERR_m(
                        "File " << fullPath <<
                        " was not truncated but marked OFFLINE!" << endl << ie);

                    g_hsm_fhLock.UnLockByID(fileProp.m_Inode);

                    continue;
                }
                catch (...) {
                    log_ERR_m(
                        "File " << fullPath <<
                        " was not truncated but marked OFFLINE!");

                    g_hsm_fhLock.UnLockByID(fileProp.m_Inode);

                    continue;
                }

                log_DBG_m(dbg_NORM,
                    "File released: " << fullPath <<
                    " inode: " << IVD_PRINT_ID_FS(fileProp.m_Inode) <<
                    " file id " << fileProp.m_fileID );

                sizeReleased += fileProp.m_fileSize;
                numReleased++;
            }
            catch (ivd_Exception &ise) {
                log_DBG_m(dbg_NORM,
                    "File " << fullPath <<
                    ". fileId " << fileProp.m_fileID <<
                    " cannot be released. " << ise);
            }
            catch (...) {
                log_DBG_m(dbg_NORM, "->ReleaseFiles caught an exception. Ignore it.");
            }

            g_hsm_fhLock.UnLockByID(fileProp.m_Inode);
        }
        if (numReleased) {
            m_numForcedRelease++;

            ostringstream sstr;
            sstr << "Forced release by user (#files: " << numReleased
                 << ", size: " << sizeReleased/1024 << " KB).";
            log_WriteEvent(sstr.str());

        }
        return numReleased;
    }
    ipc_CATCH_IVD_THROW_CORBA_m;


}

Here is the call graph for this function:

void i_HSM_i::GetCfg ( i_ClientConf_t_out  a_clientConf  ) 

Definition at line 2259 of file i_hsm_impl.cpp.

References ClientConf_t::CfgChunkSize, ClientConf_t::CfgCriticalWaterMark, ClientConf_t::CfgFileHeaderSize, ClientConf_t::CfgHashSize, ClientConf_t::CfgHighWaterMark, ClientConf_t::CfgLowWaterMark, ClientConf_t::CfgMaxMigSize, ClientConf_t::CfgMaxNumFiles, ClientConf_t::CfgMaxWaitTime, ClientConf_t::CfgMFAge, ClientConf_t::CfgMigrateWithCollocation, ClientConf_t::CfgMigRetentionTime, ClientConf_t::CfgMinFileSize, ClientConf_t::CfgMinMigSize, ClientConf_t::CfgMinNumFiles, ClientConf_t::CfgMinWaitTime, ClientConf_t::CfgOperationMode, ClientConf_t::CfgPartitionName, ClientConf_t::CfgPartitionUUID, ClientConf_t::CfgRecallOnOpen, ClientConf_t::CfgRecallRetentionTime, ClientConf_t::CfgRecallTimeOut, ClientConf_t::CfgReleaseInterval, ClientConf_t::CfgSendHL7Messages, ClientConf_t::CfgWORMTimeout, g_clientConf_p, and log_FUNC_m.

                                                   {

    log_FUNC_m(GetCfg);

    try {

        a_clientConf = new i_ClientConf_t;

        a_clientConf->CfgChunkSize           = g_clientConf_p->CfgChunkSize        ;
        a_clientConf->CfgFileHeaderSize      = g_clientConf_p->CfgFileHeaderSize   ;
        a_clientConf->CfgCriticalWaterMark   = g_clientConf_p->CfgCriticalWaterMark;
        a_clientConf->CfgHighWaterMark       = g_clientConf_p->CfgHighWaterMark    ;
        a_clientConf->CfgLowWaterMark        = g_clientConf_p->CfgLowWaterMark     ;
        a_clientConf->CfgReleaseInterval     = g_clientConf_p->CfgReleaseInterval  ;
    //    a_clientConf->CfgStartReleaseNumF    = g_clientConf_p->CfgStartReleaseNumF ;
    //    a_clientConf->CfgStartReleaseTime    = g_clientConf_p->CfgStartReleaseTime ;
        a_clientConf->CfgMaxMigSize          = g_clientConf_p->CfgMaxMigSize       ;
        a_clientConf->CfgMaxNumFiles         = g_clientConf_p->CfgMaxNumFiles      ;
        a_clientConf->CfgMaxWaitTime         = g_clientConf_p->CfgMaxWaitTime      ;
        a_clientConf->CfgMFAge               = g_clientConf_p->CfgMFAge            ;
        a_clientConf->CfgMigRetentionTime    = g_clientConf_p->CfgMigRetentionTime ;
        a_clientConf->CfgMinFileSize         = g_clientConf_p->CfgMinFileSize      ;
        a_clientConf->CfgMinMigSize          = g_clientConf_p->CfgMinMigSize       ;
        a_clientConf->CfgMinNumFiles         = g_clientConf_p->CfgMinNumFiles      ;
    //    a_clientConf->CfgMinNumMigfile       = g_clientConf_p->CfgMinNumMigfile    ;
        a_clientConf->CfgMinWaitTime         = g_clientConf_p->CfgMinWaitTime      ;
        a_clientConf->CfgRecallTimeOut       = g_clientConf_p->CfgRecallTimeOut    ;
    //    a_clientConf->CfgTreeWalkWaitTime    = g_clientConf_p->CfgTreeWalkWaitTime ;
    //    a_clientConf->CfgTreeWalkNumFiles    = g_clientConf_p->CfgTreeWalkNumFiles ;
        a_clientConf->CfgRecallRetentionTime = g_clientConf_p->CfgRecallRetentionTime;
        a_clientConf->CfgHashSize            = g_clientConf_p->CfgHashSize;
        a_clientConf->CfgPartitionName       = CORBA::string_dup(g_clientConf_p->CfgPartitionName.c_str());
        a_clientConf->CfgPartitionUUID       = CORBA::string_dup(g_clientConf_p->CfgPartitionUUID.c_str());

    /*    if (g_clientConf_p->CfgRunTreeWalk == false) {
            a_clientConf->CfgRunTreeWalk = 0;
        }
        else {
            a_clientConf->CfgRunTreeWalk = 1;
        }
        if (g_clientConf_p->CfgStartReleaseEarly == false) {
            a_clientConf->CfgStartReleaseEarly = 0;
        }
        else {
            a_clientConf->CfgStartReleaseEarly = 1;
        }
    */
        a_clientConf->CfgOperationMode  = g_clientConf_p->CfgOperationMode;
        a_clientConf->CfgWORMTimeout = g_clientConf_p->CfgWORMTimeout;
        a_clientConf->CfgRecallOnOpen = g_clientConf_p->CfgRecallOnOpen;
        a_clientConf->CfgMigrateWithCollocation = g_clientConf_p->CfgMigrateWithCollocation;
        a_clientConf->CfgSendHL7Messages = g_clientConf_p->CfgSendHL7Messages;
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

i_ColInfoList_t * i_HSM_i::GetCollocationInfo (  ) 

Definition at line 3302 of file i_hsm_impl.cpp.

References g_clientConf_p, and ClientConf_t::GetCollocationInfo().

                                             {

    map<cmn_Path, UInt64_t> colInfoMap = g_clientConf_p->GetCollocationInfo();
    i_ColInfoList_t_var colInfoList_p = new i_ColInfoList_t;
    map<cmn_Path, UInt64_t>::iterator iter = colInfoMap.begin();
    colInfoList_p->length(colInfoMap.size());
    for (UInt32_t i(0); i < colInfoList_p->length(); i++) {
        colInfoList_p[i].m_path = iter->first.c_str();
        colInfoList_p[i].m_colId = iter->second;
        iter++;
    }
    return colInfoList_p._retn();
}

Here is the call graph for this function:

i_HL7InfoList_t * i_HSM_i::GetHL7Info (  ) 

Definition at line 3333 of file i_hsm_impl.cpp.

References g_clientConf_p, and ClientConf_t::GetHl7Info().

                                     {

    map<cmn_Path, hsm_hl7ServerInfo> hl7InfoMap = g_clientConf_p->GetHl7Info();
    i_HL7InfoList_t_var hl7InfoList_p = new i_HL7InfoList_t;
    map<cmn_Path, hsm_hl7ServerInfo>::iterator iter = hl7InfoMap.begin();
    hl7InfoList_p->length(hl7InfoMap.size());
    for (UInt32_t i(0); i < hl7InfoList_p->length(); i++) {
        hl7InfoList_p[i].m_path = iter->first.c_str();
        hl7InfoList_p[i].m_hostname = iter->second.m_hostname.c_str();
        hl7InfoList_p[i].m_port = iter->second.m_port.c_str();
        iter++;
    }
    return hl7InfoList_p._retn();

}

Here is the call graph for this function:

void i_HSM_i::GetInfo ( i_HsmInfo_t_out  a_hsmInfo  ) 

Definition at line 2110 of file i_hsm_impl.cpp.

References ClientConf_t::CfgPartitionUUID, dbg_DETAIL, g_clientConf_p, g_cmn, g_fs_api_p, g_hsm_dirtyList_p, g_hsm_migcList_p, g_hsm_preJobList_p, g_hsm_relcList_p, hsm_FHmigc::GetFilesListSize(), hsm_JobListMgr::GetNumJobs(), hsm_FHrelc::GetNumTruncations(), ivd_FileSystemAPI::GetRootPath(), hsm_FHrelc::GetWakeUpTime(), hsm_FHmigc::GetWakeUpTime(), ie_HSM_NOTREADY, ivd_Error, log_DBG_m, log_FUNC_m, cmn_SysInfo::m_hostName, ivd_Product::m_nameShort, m_numForcedRelease, m_numMigs, m_numRecalls, m_ready, m_upTime, cmn_Global::prod, and cmn_Global::si.

                                              {

    log_FUNC_m(GetInfo);

    try {
        if (!m_ready) {
            throw ivd_Error(ie_HSM_NOTREADY, "See " + g_cmn.prod.m_nameShort
                                                + ".log to know when ready.");
        }

        a_hsmInfo = new i_HsmInfo_t;

        log_DBG_m(dbg_DETAIL, "Getting Info of HSM:");

        a_hsmInfo->numMig       = m_numMigs;
        a_hsmInfo->numRecall    = m_numRecalls;
        a_hsmInfo->numRelease   = g_hsm_relcList_p->GetNumTruncations();
        a_hsmInfo->upTime       = m_upTime;
        a_hsmInfo->numForcedMig = 0;
        a_hsmInfo->numForcedRelease = m_numForcedRelease;
        a_hsmInfo->mountPoint   = CORBA::string_dup(g_fs_api_p->GetRootPath().c_str());
        a_hsmInfo->host   = CORBA::string_dup(g_cmn.si.m_hostName.c_str());
        a_hsmInfo->fsID         = CORBA::string_dup(g_clientConf_p->CfgPartitionUUID.c_str());

        a_hsmInfo->numDirtyFiles = g_hsm_dirtyList_p->size();

        UInt32_t numMigJob;
        UInt32_t numMigJobPreparation;
        UInt32_t numMigJobWaitForDoMig;
        UInt32_t numMigJobDoMig;
        UInt32_t numMigJobWaitForComplete;
        UInt32_t numMigJobComplete;
        UInt32_t numFailedMigJob;
        UInt32_t numRecJob;

        g_hsm_preJobList_p->GetNumJobs(numMigJob,
                                    numMigJobPreparation,
                                    numMigJobWaitForDoMig,
                                    numMigJobDoMig,
                                    numMigJobWaitForComplete,
                                    numMigJobComplete,
                                    numFailedMigJob,
                                    numRecJob);

        a_hsmInfo->numMigJob                = numMigJob;
        a_hsmInfo->numMigJobPreparation     = numMigJobPreparation;
        a_hsmInfo->numMigJobWaitForDoMig    = numMigJobWaitForDoMig;
        a_hsmInfo->numMigJobDoMig           = numMigJobDoMig;
        a_hsmInfo->numMigJobWaitForComplete = numMigJobWaitForComplete;
        a_hsmInfo->numMigJobComplete        = numMigJobComplete;
        a_hsmInfo->numFailedMigJob          = numFailedMigJob;
        a_hsmInfo->numRecallJob             = numRecJob;

        a_hsmInfo->numMigCndFiles = g_hsm_migcList_p->size();
        a_hsmInfo->sizeMigCndFiles = g_hsm_migcList_p->GetFilesListSize();
        a_hsmInfo->numRelCndFiles = 0;
        a_hsmInfo->wakeUpTimeMigCnd = g_hsm_migcList_p->GetWakeUpTime();
        a_hsmInfo->wakeUpTimeRelCnd = g_hsm_relcList_p->GetWakeUpTime();
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

ivd_RecordIDX_t i_HSM_i::GetLastFscFileID (  )  [inline]

Definition at line 311 of file i_hsm_impl.h.

References m_lastFscFileID.

Referenced by fs_api::EventMounted(), and main().

{ return m_lastFscFileID; };

Here is the caller graph for this function:

CORBA::Boolean i_HSM_i::IsCheckFSCvsIVDFSRunning (  ) 
CORBA::Boolean i_HSM_i::IsHSMReady (  ) 

Definition at line 2639 of file i_hsm_impl.cpp.

References m_ready.

                                 {
    return m_ready;
}

CORBA::Long i_HSM_i::IVDFSPrepareRecovery ( bool  a_fromScratch,
const char *  a_incrementalFilePath 
)

Definition at line 2575 of file i_hsm_impl.cpp.

References cmn_CleanDir(), dbg_DETAIL, cmn_File::DeleteDir(), g_fs_api_p, cmn_Path::GetFileName(), ivd_FileSystemAPI::GetRootPath(), HSMFS_DBDIR, ie_HSM_IVDFS_RECOVERY, ivd_Error, log_DBG_m, log_FUNC_m, log_WriteEvent(), and PATH_SEPARATOR.

                                                                                             {
    log_FUNC_m(IVDFSPrepareRecovery);
    cmn_Path toRemove;
    try {
        // check if FS is empty, remove lost+found if exist
        bool fsEmpty = true;
        cmn_DirLst dirList(g_fs_api_p->GetRootPath(), "");
        string name = dirList.GetNextName();
        while  (name.length() > 0) {
            if (  name == "."
                || name == "..") {
                // empty
            }
#if IVD_POSIX_OS
            else if (name == "lost+found") {
                if (a_fromScratch) {
                    toRemove = g_fs_api_p->GetRootPath() + name;
                }
            }
#endif
#if TGT_OS_hpux
            else if (name == HSMFS_DBDIR) {
                log_DBG_m(dbg_DETAIL, "Found hsmdb directory " HSMFS_DBDIR);
            }
#endif
            else {
                ostringstream sstr;
                sstr << "Found entry " << name;
                log_WriteEvent(sstr.str(), "HSMFS Recovery");

                fsEmpty = false;
                break;
            }
            name = dirList.GetNextName();
            continue;
        } // while  (name.length() > 0)

        if (a_fromScratch
            && !fsEmpty) {
                throw ivd_Error(ie_HSM_IVDFS_RECOVERY, "FS is not empty.", true);
            }
        else if (!a_fromScratch
            && fsEmpty) {
            throw ivd_Error(ie_HSM_IVDFS_RECOVERY,
                "FS is empty and incremental FS recovery is run. Remove "
                + string(a_incrementalFilePath) + " file.", true);
        }

        if (!toRemove.empty()) {
            cmn_CleanDir(toRemove);
            cmn_File::DeleteDir(toRemove);
            ostringstream sstr;
            sstr << "Entry " << toRemove.GetFileName() << " is removed";
            log_WriteEvent(sstr.str(), "HSMFS Recovery");
        }
    }
    ipc_CATCH_IVD_THROW_CORBA_m;

    log_DBG_m(dbg_DETAIL, "pathSeparator = " << PATH_SEPARATOR
              << ", is it slash = "  << boolalpha << (PATH_SEPARATOR == '/'));
    return (PATH_SEPARATOR == '/'); // return 1 if client path separator is slash
}

Here is the call graph for this function:

void i_HSM_i::IVDFSRecover ( const i_DataBlock_t a_friBlock  ) 

Definition at line 2560 of file i_hsm_impl.cpp.

References log_FUNC_m, and m_recoverer.

                                                          {
    log_FUNC_m(IVDFSRecover);
    try {
        if (m_recoverer.get() == NULL) {
            m_recoverer.reset(new hsm_IVDFSRecoverer(a_friBlock.length()));
        }
        else if (m_recoverer->GetBlkSize() != a_friBlock.length()) {
            m_recoverer.reset(new hsm_IVDFSRecoverer(a_friBlock.length()));
        }
        const UInt8_t* block_p = reinterpret_cast<const UInt8_t*>(a_friBlock.get_buffer());
        m_recoverer->Unpack(block_p, 0);
    } ipc_CATCH_IVD_THROW_CORBA_m;
}

void i_HSM_i::MigrateByAPI ( CORBA::Long  a_flags,
const char *  a_fileName,
CORBA::LongLong  a_majorColId,
CORBA::LongLong  a_minorColId,
i_JobIDList_t_out  a_jobIDs 
)

Definition at line 2912 of file i_hsm_impl.cpp.

References MigrateTreewalk::action_CheckPreconditions, MigrateTreewalk::action_TrigMigration, hsm_MigByAPI::AllFilesInJobs(), API_FLAG_EXCLUSIVE, API_FLAG_RECURSIVE, ClientConf_t::CfgReplTargetHost, ClientConf_t::CfgReplTargetPart, Collocation::CheckPreconditions(), hsm_MigByAPI::ClearList(), ivd_FS_File::Close(), cmn_IsPatternValid(), dbg_DETAIL, dbg_LOW, dbg_NORM, hsm_MigByAPI::DumpInputInode(), hsm_MigByAPI::DumpJobInode(), ivd_FS_File::e_Cache, hsm_MigByAPI::EndCall(), cmn_File::Exists(), file, i_MinorCol_t::flags, g_clientConf_p, g_fs_api_p, g_hsm_migcList_p, g_iPM, g_jobList_c, ivd_BaseException::GetError(), cmn_Path::GetFileName(), ivd_FS_File::GetFullPathRef(), hsm_MigByAPI::GetJobs(), MigrateTreewalk::GetProcessedFilesCount(), ivd_FS_File::GetProperties(), ivd_FileSystemAPI::GetRootPath(), ie_HSM_COLLOCATION, ie_HSM_EXCLUSIVE_FLAG, ie_HSM_MIG_RUNNING, ie_INVALID_ARG, ie_NO_HSM, ie_NOTFOUND, ift_DIR, ift_FILE, ipc_EXEC_m, iPM, hsm_MigByAPI::IsRunning(), ivd_Error, IVD_PRINT_ID_FS, ivd_Sleep, log_DBG_m, log_FUNC_m, log_NOTE_m, log_WriteErrorEvent, log_WriteEvent(), log_WRN_m, ivd_FS_FileProperty_t::m_dirtyFlag, ivd_FS_FileProperty_t::m_Inode, hsm_MigByAPI::m_majColId, hsm_MigByAPI::m_minColId, ivd_FS_FileProperty_t::m_type, hsm_MigByAPI::MajColExists(), i_MinorCol_t::majColId, i_MinorCol_t::minColId, ivd_FS_File::Open(), path, cmn_Path::RemoveTrailingPathSeparator(), REPL_JOB_ID_PREFIX, ipc_Corba::ResolveRM(), hsm_MigByAPI::SetColIds(), hsm_MigByAPI::SetMajColList(), cmn_TreeWalk::Start(), hsm_MigByAPI::StartCall(), hsm_FHmigc::TrigMigration(), TrigMigration(), cmn_Path::UpPath(), and cmn_Condition::Wait().

                                                       {
    log_FUNC_m(MigrateByAPI);
    try {
#if TGT_OS_windows
        UInt64_t numRequestedFiles = 0;
        if (g_mig.IsRunning()) {
            throw ivd_Error(ie_HSM_MIG_RUNNING);
        }

        i_HSM_var replHsm;
        bool doReplication(false);
        ipc_EXEC_m(
            doReplication = g_iPM->ReplicationNeeded();
            if (doReplication) {
                i_PartitionManager_var iPM = g_iPM->GetReplicationPM();

                log_DBG_m(dbg_NORM, "Getting HSM reference...");
                replHsm = iPM->GetHSM();
                if (CORBA::is_nil(replHsm)) {
                    throw ivd_Error(ie_NO_HSM, "Partition not mounted or no valid HSM reference on target system.");
                }
                log_DBG_m(dbg_NORM, "Got HSM reference.");
            }
        );
        bool recursive(false);
        if ((a_flags & API_FLAG_RECURSIVE) == API_FLAG_RECURSIVE){
            log_DBG_m(dbg_NORM, "Recursive");
            recursive = true;
            a_flags &= ~API_FLAG_RECURSIVE;
        }
        g_mig.StartCall();

        g_mig.SetColIds(a_majColId, a_minColId, a_flags);

        log_DBG_m(dbg_LOW, "m_majColId: " << g_mig.m_majColId <<
                           ",  m_minColId: " << g_mig.m_minColId <<
                           ",  a_flags: " << a_flags
                           );
        i_ResourceManager_var rm;
        try {
            ipc_EXEC_m(
                CORBA::Object_var obj = ipc_Corba::ResolveRM();
                rm = i_ResourceManager::_narrow(obj);
                log_DBG_m(dbg_DETAIL,"Sucessfully resolved RM");
            );
        }
        catch(ivd_Error) {
            log_DBG_m(dbg_NORM, "Couldn't resolve RM reference.");
            g_mig.EndCall();
            throw;
        }

        //check if majColId exists
        if (!g_mig.MajColExists(a_majColId)){

            //check if it was added to RM
            i_MajorColSeq_t_var mcs = rm->SelectAllMajorCol();

            vector<i_MajorCol_t> mcv;
            for(UInt32_t i(0); i < mcs->length(); i++) {
                mcv.push_back(mcs[i]);
                log_DBG_m(dbg_NORM, "push_back(mcs[i]) for id: " << mcs[i].majColId);
            }
            g_mig.SetMajColList(mcv);
            if (!g_mig.MajColExists(a_majColId)){
                g_mig.EndCall();
                throw ivd_Error(ie_NOTFOUND, "Major Collocation ID not found.");
            }
        }

        //check minorCol
        i_MinorCol_t_var minCol;
        bool found(false);
        try {
            ipc_EXEC_m(minCol = rm->SelectMinorCol(a_minColId));
            found = true;
        }
        catch (ivd_Error &e) {
            if (e.GetError() == ie_RMDB_NOTFOUND) {
                //insert minColId into rmdb
                i_MinorCol_t mc;
                mc.minColId = a_minColId;
                mc.majColId = a_majColId;
                mc.flags = a_flags;
                try {
                    ipc_EXEC_m(rm->AddMinorCol(mc));
                }
                catch (...) {
                    g_mig.EndCall();
                    throw;
                }
            }
            else {
                g_mig.EndCall();
                throw;
            }
        }
        catch (...) {
            g_mig.EndCall();
            throw;
        }

        if (found) {
            log_DBG_m(dbg_DETAIL,"Minor already exists");
            if (minCol->majColId != a_majColId) {
                log_DBG_m(dbg_DETAIL,"Minor has different major.");
                g_mig.EndCall();
                throw ivd_Error(ie_HSM_COLLOCATION, "Migration with different major ID is not allowed.");
            }
            if (minCol->flags != a_flags) {
                ostringstream sstr;
                sstr << "Minor ID: " << a_minColId << " Use old flags(";
                if ((a_flags & API_FLAG_EXCLUSIVE) == API_FLAG_EXCLUSIVE) {
                    sstr << "exclusive)";
                }
                else {
                    sstr << "none)";
                }
                sstr << ".";

                g_mig.EndCall();
                throw ivd_Error(ie_HSM_EXCLUSIVE_FLAG, sstr.str());
            }
            else {
                g_mig.SetColIds(a_majColId, a_minColId, minCol->flags);
            }
        }

        bool singleFileMigration(false);

        cmn_Path mountPoint(g_fs_api_p->GetRootPath());
        mountPoint.RemoveTrailingPathSeparator();
        log_DBG_m(dbg_NORM, "Force migration on mountpoint : " << mountPoint
                            << ",   file: " << a_fileName);
        Int32_t numMigrated = 0;

        cmn_Path path(a_fileName);
        path.RemoveTrailingPathSeparator();
        log_DBG_m(dbg_NORM, "file to migrate: " << path);

        i_JobIDList_t_var jobIDs(new i_JobIDList_t());

        // is fileName a file or directory
        bool isDir(false);
        // check if migration request on mountpoint
        if (path.compare(mountPoint) == 0) {
           log_DBG_m(dbg_NORM, "Migration request on mountpoint ");
           isDir = true;
        }
        else {
            try {
                ivd_FS_FileProperty_t fileProp;
                ivd_FS_File file(*g_fs_api_p, path);
                file.Open(ivd_FS_File::e_Cache, path);
                file.GetProperties(fileProp);
                file.Close();

                if ((fileProp.m_type == ift_FILE) && (!recursive)) {
                    singleFileMigration = true;
                    if (!fileProp.m_dirtyFlag) {
                        log_DBG_m(dbg_DETAIL, "The file not dirty. Skipping. Name: " <<
                            a_fileName << ", inode: " << IVD_PRINT_ID_FS(fileProp.m_Inode));
                    }
                    else {
                        try {
                            Collocation::CheckPreconditions(path, fileProp,
                                a_majColId, a_minColId, doReplication);
                        }
                        catch (ivd_Error) {
                            a_jobIDs = jobIDs._retn();
                            g_mig.EndCall();
                            throw;
                        }
                        log_DBG_m(dbg_DETAIL, "Precondition checks passed. " << file.GetFullPathRef());

                        Collocation::TrigMigration(file, fileProp.m_Inode, a_majColId, a_minColId);
                        numRequestedFiles++;
                    }
                }

                if (fileProp.m_type == ift_DIR) {
                    isDir = true;
                }
            }
            catch (ivd_SysError &ise) {
                log_DBG_m(dbg_DETAIL, "Caught " << ise);
                if (ise.GetError() == ERROR_FILE_NOT_FOUND) {
                    if (!recursive) {
                    ostringstream sstr;
                    sstr << "The file '" << a_fileName << "' requested for migration does not exist.";
                    log_NOTE_m(sstr.str());
                    a_jobIDs = jobIDs._retn();
                    g_mig.EndCall();
                    throw ivd_Error(ie_INVALID_ARG, sstr.str());
                    }
                }
                else if (ise.GetError() == ERROR_INVALID_NAME) {
                    log_DBG_m(dbg_DETAIL, "It seems to be pattern " << path);
                }
                else {
                    ostringstream sstr;
                    sstr << "Unexpected path '" << a_fileName << "' requested for migration.";
                    log_NOTE_m(sstr.str());
                    a_jobIDs = jobIDs._retn();
                    g_mig.EndCall();
                    throw ivd_Error(ie_INVALID_ARG, sstr.str());
                }
            }

        if (!singleFileMigration) {
            string pattern;
            cmn_Path walkPath;

            if (isDir){
                //walk that dir
                walkPath = path;
                //all files in that dir
                pattern = "*";
            }
            else {
                //walk updir with pattern
                walkPath = path.UpPath();
                pattern = path.GetFileName();
                try {
                    cmn_File walkPathFile(walkPath);
                    if(!walkPathFile.Exists()) {
                        ostringstream sstr;
                        sstr << "Path: '" << a_fileName << "' does not exist.";
                        log_NOTE_m(sstr.str());
                        a_jobIDs = jobIDs._retn();
                        g_mig.EndCall();
                        throw ivd_Error(ie_INVALID_ARG, sstr.str());
                    }
                }
                catch (ivd_SysError &ise) {
                    log_DBG_m(dbg_DETAIL, "Caught " << ise);
                    ostringstream sstr;
                    sstr << "Wrong path syntax: " << a_fileName << " specified by API.";
                    log_NOTE_m(sstr.str());
                    a_jobIDs = jobIDs._retn();
                    g_mig.EndCall();
                    throw ivd_Error(ie_INVALID_ARG, sstr.str());
                }
            }

            //pattern validation check
            if (!cmn_IsPatternValid(pattern)){
                ostringstream sstr;
                sstr << "Pattern " << pattern << " in path " << a_fileName << " is not valid!" << endl;
                log_NOTE_m(sstr.str());
                a_jobIDs = jobIDs._retn();
                g_mig.EndCall();
                throw ivd_Error(ie_INVALID_ARG, sstr.str());
            }

            log_DBG_m(dbg_NORM, "isDir: " << boolalpha << isDir
                            << " walkPath: " << walkPath << " pattern: " << pattern);
            bool abort(false);
            try {
                MigrateTreewalk treewalk(pattern, a_majColId, a_minColId, recursive, abort,
                    MigrateTreewalk::action_CheckPreconditions, doReplication);
                treewalk.Start(walkPath);
            }
            catch (...) {
                a_jobIDs = jobIDs._retn();
                g_mig.EndCall();
                throw;
            }
            log_DBG_m(dbg_DETAIL, "Precondition checks passed.");
            try {

                MigrateTreewalk treewalk(pattern, a_majColId, a_minColId, recursive, abort,
                    MigrateTreewalk::action_TrigMigration, doReplication);
                treewalk.Start(walkPath);
                numRequestedFiles = treewalk.GetProcessedFilesCount();
            }
            catch (...) {
                log_DBG_m(dbg_NORM, "trig migrate failed: " << path);
                ostringstream sstr;
                sstr << "Unexpected error during API migration.";
                log_NOTE_m(sstr.str());
                a_jobIDs = jobIDs._retn();
                g_mig.EndCall();
                throw ivd_Error(ie_INVALID_ARG, sstr.str());
            }
        } //if (!singleFileMigration)
    } // else (path.compare(mountPoint) == 0)

    ostringstream sstr;
    sstr << "Migration requested by API (#files: "
         << numRequestedFiles << ").";
    log_WriteEvent(sstr.str());

    if (numRequestedFiles == 0) {
        a_jobIDs = jobIDs._retn();
        g_mig.EndCall();
        return;
    }

    //check if all files are migrated
    UInt32_t i(1);
    while (!g_mig.AllFilesInJobs()) {
        ivd_Sleep(i);

        log_DBG_m(dbg_DETAIL,"before lock");
        cmn_MutexLock l(g_jobList_x);
        numMigrated += g_hsm_migcList_p->TrigMigration();

        log_DBG_m(dbg_NORM, "B4 wait");
        g_jobList_c.Wait();

        i++;
        if (i > 10) {
            log_WRN_m("Incomplete list of files in migration jobs.");
            break;
        }
    } // while (!g_mig.AllFilesInJobs())

    g_mig.DumpInputInode();
    g_mig.DumpJobInode();

    if (numMigrated) {
        ostringstream sstr;
        sstr << "Migration triggered by API (#files: "
             << numMigrated << ").";
        log_WriteEvent(sstr.str());
    }

    {
        vector<UInt64_t> jobList = g_mig.GetJobs();
        g_mig.ClearList();

        UInt32_t jobListSize(jobList.size());

        i_JobIDList_t_var replJobs;
        if (doReplication) {
            log_DBG_m(dbg_NORM, "Triggering migration on replication server "
                << g_clientConf_p->CfgReplTargetHost << " partition "
                << g_clientConf_p->CfgReplTargetPart);
            if (!CORBA::is_nil(replHsm)) {
                try {
                    ipc_EXEC_m(
                        replHsm->MigrateByAPI(a_flags,
                                            CORBA::string_dup(a_fileName),
                                            a_majColId,
                                            a_minColId,
                                            replJobs);
                    );
                }
                catch (...) {
                    g_mig.EndCall();
                    log_DBG_m(dbg_NORM, "Replication migration failed.");
                    throw;
                }
                log_DBG_m(dbg_NORM, "Replication jobs: " << replJobs->length());
                jobListSize += replJobs->length();
            }
            else {
                log_WriteErrorEvent( "Replication HSM is in not available.");
                doReplication = false; // to prevent adding jobs to list
            }
        }

        jobIDs->length(jobListSize);

        for (i = 0; i < jobList.size(); i++) {
            jobIDs[i] = jobList[i];
            log_DBG_m(dbg_NORM, "Started jobs:" << jobList[i]);
        }

        if (doReplication) {
            for (i = 0; i < replJobs->length(); i++) {
                log_DBG_m(dbg_NORM, "job: " << (replJobs[i] + REPL_JOB_ID_PREFIX));
                jobIDs[(jobList.size() + i)] = (replJobs[i] + REPL_JOB_ID_PREFIX);
            }
        }

        a_jobIDs = jobIDs._retn();

    }
    g_mig.EndCall();
#endif
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

bool i_HSM_i::PackFile ( CORBA::LongLong  a_migrationID,
hsm_FileHeader fh,
UInt64_t migSize,
df_Packer packer 
) [private]

Definition at line 1718 of file i_hsm_impl.cpp.

References CHG_CHGFILE_d, CHG_DATA_d, CHG_DELETED_d, ivd_FS_File::Close(), cmn_Num2Str(), cmn_Global::dbg, dbg_DETAIL, dbg_LOW, dbg_NORM, df_FS_COMPLETE, df_SS_ABORTED, df_SS_COMPLETE, ivd_FS_File::e_Cache, ivd_FS_File::e_Migrate, ivd_FS_File::e_MigrateNoData, eJobList, evt_ERROR, file, g_cmn, g_fs_api_p, df_Packer::GetBSData(), hsm_FileHeader::GetChgFlag(), hsm_FileHeader::GetDataMigStat(), ivd_BaseException::GetError(), hsm_FileHeader::GetFileID(), hsm_FileHeader::GetFOwner(), ivd_BaseException::GetFriendly(), hsm_FileHeader::GetFullPath(), hsm_ListPos::GetJobElemIdx(), log_Debugger::GetLevel(), hsm_FileHeader::GetList(), hsm_FileHeader::GetMigAllowedTime(), hsm_FileHeader::GetOldFullPath(), hsm_FileHeader::GetOldOwnFileID(), hsm_FileHeader::GetOwnFileID(), ivd_FS_File::GetProperties(), ivd_FileSystemAPI::GetRootPath(), ivd_FS_File::GetStreamHeader(), ie_IMPOSSIBLE, IVD_PRINT_ID_FS, log_DBG_m, log_FUNC_m, log_WriteEvent(), log_WRN_m, ivd_FS_FileProperty_t::m_chgTime, m_shutDownInProgress, hsm_FileHeader::MakeStat(), NULL, ivd_FS_File::Open(), hsm_FileHeader::OpenFile(), ivd_FS_File::ReadStream(), hsm_FileHeader::SetDataInPacker(), hsm_FileHeader::SetFHChgFlag(), hsm_FileHeader::SetModifyTimeAtMig(), stt_ALTDATA, stt_DATA, stt_META, stt_NONE, df_Packer::WriteBSData(), df_Packer::WriteRecBSEnd(), df_Packer::WriteRecBSStart(), df_Packer::WriteRecFile(), and df_Packer::WriteRecFileEnd().

Referenced by DoMigrationJob().

                                                             {
    log_FUNC_m(PackFile);

    migSize = 0;

    // TODO: it would be nicer if file info (Stat()) would be done thorugh FS API
    ivd_FileInfo_t fInfo;
    try {
        fh.MakeStat(fInfo);
    }
    catch (ivd_Exception &ie) {
        log_DBG_m(dbg_LOW, "PackFile: Cannot STAT File: " << ie.GetFriendly());
        return false; // Skip this file
    }

    ivd_FileID_t fileID = fh.GetFileID();

    cmn_Path name(fh.GetFullPath());
    cmn_Path oldName(fh.GetOldFullPath());
    UInt32_t chgFlags = fh.GetChgFlag();
    ivd_FS_File file(*g_fs_api_p, fInfo.idOnFS, fileID);

    UInt32_t status = df_SS_COMPLETE;

    // check for OwnerID bug 2695, 2722
    if (   fh.GetFOwner() != NULL
        && fh.GetOwnFileID() == 0) {
        ostringstream sstr;
        sstr << "*** NO OWNER set for INO " << IVD_PRINT_ID_FS(fInfo.idOnFS)
             << " fileID= " << fileID
             << " file " << name << endl
             << "*** File must be migrated again!" ;
        log_WriteEvent(evt_ERROR, sstr.str());
    }

    // always store file header
    packer.WriteRecFile(fileID, a_migrationID,
                        fh.GetOwnFileID(), fh.GetOldOwnFileID(),
                        name, oldName, fInfo,
                        chgFlags, 0, 0);

    log_DBG_m(dbg_NORM, "PackFile: [" << fh.GetJobElemIdx() << "]" << endl <<
                        " fileId=" << fileID <<
                        " Inode=" << IVD_PRINT_ID_FS(fInfo.idOnFS) <<
                        " ParentID=" << fh.GetOwnFileID() <<
                        " Size=" << fInfo.size << endl <<
                        " file name=" << name << ", old file name=" << oldName);

    if (g_cmn.dbg.GetLevel() == dbg_DETAIL) {
        cmn_Time migAllowedTime(fh.GetMigAllowedTime());
        log_DBG_m(dbg_DETAIL, "Info type =" << fInfo.type  <<
                              "  changedata = " << hex << chgFlags << dec <<
                              "  migAllowedTime = " << migAllowedTime.Time2hms() <<
                              "  FH list = " << fh.GetList());

    }

    // we need to pack file streams if:
    if (!(chgFlags & CHG_DELETED_d)             // is not deleted (no streams)
        && fh.GetMigAllowedTime() <= time(NULL) // did not change (bug 527)
        && fh.GetList() == eJobList          // is on some job list
        && fh.GetDataMigStat() != eDoMigAbort) {// migration was not aborted

        // get chgTime from filter to verify if file has changed
        ivd_FS_FileProperty_t filePropBefore;
        try {
            //The file needs to be opened ( to be in the kernel cache )
            file.Open(ivd_FS_File::e_Cache,(g_fs_api_p->GetRootPath() + name));
            file.GetProperties(filePropBefore);
            //HPUX
            file.Close();
        }
        catch (ivd_Exception &ie) {
            log_DBG_m(dbg_LOW, "PackFile: Cannot GetProperties before migration: "
                << ie.GetFriendly());
            status = df_SS_ERROR;
            goto end; // Skip this file
        }
        fh.SetModifyTimeAtMig(filePropBefore.m_chgTime);
        try {
            fh.OpenFile(file, (chgFlags & CHG_DATA_d) ?
                               ivd_FS_File::e_Migrate :
                               ivd_FS_File::e_MigrateNoData);
        }
        catch (ivd_Exception &ie) {
            log_DBG_m(dbg_NORM, "Cannot open file: " << ie.GetFriendly());
            status = df_SS_ERROR;
            goto end;
        }

        UInt32_t    badStreams = 0;
        UInt32_t    streamType;
        string      streamName;
        ivd_FilePosition_t streamSize;

        while ((status == df_SS_COMPLETE)
            && (streamType = file.GetStreamHeader(streamName, streamSize))
                != stt_NONE) {

            log_DBG_m(dbg_DETAIL, "Stream: " << streamType <<
                                  "  Size: " << streamSize <<
                                  "  Name: " << streamName);

            UInt32_t dfStreamType(0);
            switch (streamType) {
                case stt_DATA:      dfStreamType = df_ST_DATA;      break;
                case stt_ALTDATA:   dfStreamType = df_ST_ALTDATA;   break;
                case stt_META:      dfStreamType = df_ST_META;      break;
                default:
                    throw ivd_InternalError(ie_IMPOSSIBLE,
                        "Invalid stream type from FS API: " +
                        cmn_Num2Str(streamType));
            }
            packer.WriteRecBSStart(dfStreamType, streamName, streamSize);

            UInt64_t streamLeft = streamSize;

            while (streamLeft > 0) {
                // first check if we are going down...
                if (m_shutDownInProgress) {
                    log_DBG_m (dbg_LOW, "Shut down. Abort DoMigrationJob pack data.");
                    status = df_SS_ABORTED;
                    badStreams++;
                    break;
                }
                // ...or if file migration is aborted...
                if (fh.GetDataMigStat() == eDoMigAbort) {
                    log_DBG_m(dbg_LOW, "Migration aborted. New event occured." << IVD_PRINT_ID_FS(fInfo.idOnFS));
                    status = df_SS_ABORTED;
                    badStreams++;
                    break;
                }

                // allocate DF buffer
                UInt8_t *buf;
                UInt32_t bufSize, bytesRead;
                try {
                    packer.GetBSData(buf, bufSize);
                }
                catch (ivd_Exception &ie) {
                    if (ie.GetError() == ie_DF_SSIZE) {
                        log_DBG_m(dbg_LOW, "Cannot get buffer for stream: " <<
                                  ie.GetFriendly());
                        status = df_SS_ABORTED;
                        badStreams++;
                        break;
                    }
                    else
                        throw;
                }

                // read data from stream
                try {

                    bytesRead = file.ReadStream(buf, bufSize);
                }
                catch (ivd_Exception &ie) {
                    log_DBG_m(dbg_LOW, "Cannot read stream: " << ie.GetFriendly());
                    status = df_SS_ERROR;
                    badStreams++;
                    break;
                }

                // verify if stream is larger than expected (unlikely)
                // relatted on bug 710 and fix bug 722
                if (streamLeft < bytesRead) {
                    log_DBG_m(dbg_LOW, "Migration aborted. File was grown." <<
                                IVD_PRINT_ID_FS(fInfo.idOnFS));
                    status = df_SS_ABORTED;
                    badStreams++;
                    break;
                }

                // commit DF buffer
                packer.WriteBSData();

                streamLeft -= bytesRead;
                migSize += bytesRead;

            } // (streamLeft > 0)

            // Ask fsfilter for change time
            ivd_FS_FileProperty_t filePropAfter;


            try {
                file.GetProperties(filePropAfter);
            }
            catch (ivd_SysError &ise) {
                log_DBG_m(dbg_LOW, "PackFile: Cannot GetProperties after migration: "
                    << ise.GetFriendly() << " Abort mig.");
                status = df_SS_ABORTED;
                badStreams++;
            }

            if (filePropBefore.m_chgTime != filePropAfter.m_chgTime) {
                log_DBG_m(dbg_NORM, "PackFile: File Modified. Abort. " <<
                            IVD_PRINT_ID_FS(fInfo.idOnFS));
                status = df_SS_ABORTED;
                badStreams++;

                //bug 8458
                log_DBG_m(dbg_LOW, "Bug 8458");
                //set change flag CHG_CHGFILE_d
                ostringstream msg;
                msg << "File: " << IVD_PRINT_ID_FS(fInfo.idOnFS) <<
                    " modified while migration in progress. No event detected. Setting CHGFILE event.";

                log_WRN_m(msg.str());
                fh.SetFHChgFlag(CHG_CHGFILE_d);
            }

            try {
                packer.WriteRecBSEnd(status);
            }
            catch (ivd_Exception &ie) {
                if (ie.GetError() == ie_DF_SSIZE) {
                    log_DBG_m(dbg_LOW, "BSEnd error: " << ie.GetFriendly());
                    badStreams++;
                    // end byte stream, with different status -> should succeeed
                    packer.WriteRecBSEnd(df_SS_ABORTED);
                }
                else
                    throw;
            }

        } // (GetNextHeader() != stt_NONE)

        file.Close();

        log_DBG_m(dbg_DETAIL, "* Write for file " << name << " is finished" <<
                                "  Streams with errors: " << badStreams);

        // mark that data was successfuly migrated
        if (badStreams == 0 && (chgFlags & CHG_DATA_d)) {
            fh.SetDataInPacker();
        }
    }

end:
    // df_FS_COMPLETE regardless of fileStatus, as at least file header was written.
    packer.WriteRecFileEnd(df_FS_COMPLETE);

    // at least file header is migrated
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_HSM_i::Recall ( const i_Recall_t a_file,
i_JobID_t  a_pmJobId,
i_BlkSize_t  a_blockSize,
i_BufType_t  a_bufType,
const char *  a_diskBufferFS,
CORBA::Boolean  a_succeeded,
i_DownloadAgent_ptr  a_download 
)

Definition at line 866 of file i_hsm_impl.cpp.

References hsm_JobListMgr::At(), hsm_JobElemVecMgr::At(), bbt_DISK_BUF, bbt_REMOTE_BUF, blk_Data_c, cmn_Num2Str(), dbg_DETAIL, dbg_LOW, i_Recall_t::fileID, g_cmn, g_fs_api_p, g_fsLog, g_hsm_fhLock, g_hsm_preJobList_p, hsm_FileHeader::GetInode(), hsm_JobListMgr::GetJobElemVecMgr(), hsm_FileHeader::GetRecallIntoName(), i_DISK_BUF, i_REMOTE_BUF, i_SHMEM_BUF, ie_INVALID_ARG, ie_NOFINDOBJ, ivd_FS_ERR_Reply, ivd_USleep, log_DBG_m, log_FUNC_m, log_WriteEvent(), log_WRN_m, ivd_Product::m_nameShortLC, m_numRecalls, i_Recall_t::migrationID, df_Unpacker::NewDiskBuffer(), df_BlockReader::NewDiskBuffer(), df_Unpacker::NewNetBuffer(), df_BlockReader::NewNetBuffer(), NULL, cmn_Global::prod, hsm_FileHeader::Recalled(), hsm_JobListMgr::ReleaseElement(), hsm_JobListMgr::ReleaseJobIdx(), hsm_JobListMgr::ReleaseJobIdxWithTest(), hsm_FileHeader::SendReply(), hsm_FileHeader::TruncateFile(), UnPackFile(), and log_ivdfs::Write().

                                    {

    log_FUNC_m(Recall);

    string diskBufferFS(a_diskBufferFS);
    bool recalled = false;
    UInt32_t numRclFiles = 0;
    UInt64_t sizeRclFiles = 0;

    UInt32_t blkSize      = a_blockSize;
    string bufId          = cmn_Num2Str((Int64_t)a_pmJobId);
    bbt_BufType_t bufType = bbt_DISK_BUF;

    auto_ptr<ivd_FS_File> recallFile_p;
    bool manualRecall = false;

    hsm_FileHeader *tFHobj =  NULL;

    try {

        Int32_t jobIdx(0);
        hsm_JobElemVecMgr *jobElemVecMgr_p =
            g_hsm_preJobList_p->GetJobElemVecMgr(a_pmJobId, jobIdx);

        if (jobElemVecMgr_p == NULL) {
            log_WRN_m(
                "HSM job file list not found. "
                << "Did the job already fail or was it aborted: "
                << a_pmJobId);
            return;
        }

        tFHobj = jobElemVecMgr_p->At(0);

        log_DBG_m (dbg_DETAIL, "  RECALL with jobID " << a_pmJobId <<
                               " of file at Job[" << jobIdx << "]" <<
                               "\t\tfileID " << a_file.fileID << " MigID " << a_file.migrationID);

        if (tFHobj == NULL) {
            string  idFileStr = cmn_Num2Str((ivd_FileID_t)((unsigned long)a_file.fileID));
            throw ivd_InternalError(ie_NOFINDOBJ, "Object with fileId: " + idFileStr + " IS_NOT_FOUND", true);
        }

        ivd_GenInode_t inode = tFHobj->GetInode();

        string intoName = tFHobj->GetRecallIntoName();

        if (!intoName.empty()) {
            // File Header for manual recall has into name defined.
            manualRecall = true;
            log_DBG_m(dbg_LOW, "Manually triggerd recall into: " << intoName);
        }
        /*#endif*/

        // fix bug 692 and 736
        if (!a_succeeded){
            log_DBG_m(dbg_LOW,"Recall failed for fileId " << a_file.fileID);
            goto end;
        }

        if (manualRecall) {
            log_DBG_m(dbg_LOW, "Manual Recall for file Id:"
                    << a_file.fileID << " into " << intoName);
            recallFile_p.reset(new ivd_FS_File(*g_fs_api_p, intoName));
        }
        else {
            i_RecallList_t seqRecallList;
            seqRecallList.length(1);
            seqRecallList[0] = a_file;
            log_DBG_m (dbg_DETAIL, "a_file: " << a_file);

            switch (a_bufType ) {
            case i_DISK_BUF:
                bufType = bbt_DISK_BUF;
                break;
            case i_SHMEM_BUF:
                bufType = bbt_SHMEM_BUF;
                break;
            case i_REMOTE_BUF:
                bufType = bbt_REMOTE_BUF;
                break;
            default:
                throw ivd_InternalError(
                    ie_INVALID_ARG,  "Unsupported transfer type.");
            }
            df_BlockReader *blockReader_p = new df_BlockReader(blk_Data_c, bufType, a_blockSize);
            hsm_Recall recallData(blockReader_p,
                                  g_hsm_preJobList_p->At(jobIdx),
                                  a_pmJobId,
                                  seqRecallList);

            switch (bufType) {
                case bbt_DISK_BUF:
                    blockReader_p->NewDiskBuffer(bufId, diskBufferFS);
                    break;
                case bbt_REMOTE_BUF:
                    blockReader_p->NewNetBuffer(a_download);
                    break;
                default:;
            }

            recallData.Unpack();

            UInt32_t numRclFiles;
            UInt64_t sizeRclFiles;

            if (g_hsm_preJobList_p->ReleaseJobIdxWithTest(jobIdx, numRclFiles, sizeRclFiles)) {
                ostringstream sstr;
                sstr << "(#files: " << numRclFiles
                    << ", size: " << sizeRclFiles/1024 << " KB"
                    << ", FileID: " << a_file.fileID << " ).";

                log_WriteEvent(
                    sstr.str(), "RECALL",
                    a_pmJobId,
                    cmn_Num2Str(jobIdx));
            }

            return;
        }

        switch (a_bufType ) {
        case i_DISK_BUF:
            bufType = bbt_DISK_BUF;
            break;
        case i_SHMEM_BUF:
            bufType = bbt_SHMEM_BUF;
            break;
        case i_REMOTE_BUF:
            bufType = bbt_REMOTE_BUF;
            break;
        default:
            throw ivd_InternalError(
                ie_INVALID_ARG,  "Unsupported transfer type.");
        }

        log_DBG_m (dbg_DETAIL,
            " RECALL: to create dfUnpacker for bufType " << bufType << endl <<
            " bufID:" << bufId << endl <<
            " Block size " << a_blockSize << endl
        );

        try {
            UInt64_t rclSize;
            df_Unpacker unpacker(blk_Data_c, bufType, blkSize);
            switch (bufType) {
                case bbt_DISK_BUF:
                    unpacker.NewDiskBuffer(bufId, diskBufferFS);
                    break;
                case bbt_REMOTE_BUF:
                    unpacker.NewNetBuffer(a_download);
                    break;
                default:;
            }
            recalled = UnPackFile(a_file, *recallFile_p.get(), manualRecall,
                rclSize, unpacker);
            intoName = recallFile_p.get()->GetFullPathRef();
            if (!recalled) {
                tFHobj->TruncateFile(*recallFile_p.get());
            }
            else {
                numRclFiles++;
                sizeRclFiles += rclSize;
            }
        }
        catch (ivd_Exception &ie) {
            log_DBG_m(dbg_DETAIL, ie);
        }
        catch (...) {
            log_DBG_m(dbg_DETAIL, "Recall: Error in packer.");
        }

end:
        if (manualRecall) {
            g_hsm_preJobList_p->ReleaseElement(jobIdx, 0);
            ostringstream sstr;
            if (recalled) {
                sstr << "Recalled into. ( MigID : " << a_file.migrationID << " )";
            }
            else {
                sstr << "ERROR: Recall into failed ";
                if (a_succeeded) {
                    sstr << "(" << g_cmn.prod.m_nameShortLC
                         << "-hsm unpacker problem).";
                }
                else {
                    sstr << "(" << g_cmn.prod.m_nameShortLC << "-pm problem).";
                }
            }
            g_fsLog.Write(inode, a_file.fileID, jobIdx, intoName, sstr.str().c_str());
        }
        else {
            // fix bug 537
            while (!g_hsm_fhLock.CanLockByID(inode)) {
                ivd_USleep(10000); // wait a 10 mili sec
            }
            // end fix

            tFHobj->Recalled(recalled);

            g_hsm_fhLock.UnLockByID(inode);
        }

        g_hsm_preJobList_p->ReleaseJobIdx(jobIdx);

        m_numRecalls++; // added for statistic by jandrej@hermes.si

        ostringstream sstr;
        sstr << "(#files: " << numRclFiles
            << ", size: " << sizeRclFiles/1024 << " KB"
            << ", FileID: " << a_file.fileID << " ).";

        log_WriteEvent(
            sstr.str(), "RECALL",
            a_pmJobId,
            cmn_Num2Str(jobIdx));
    }
    catch (ivd_Exception) {
        tFHobj->SendReply(ivd_FS_ERR_Reply);
    }
    catch (ivd_InternalError) {
        tFHobj->SendReply(ivd_FS_ERR_Reply);
    }
    catch (...) {
        tFHobj->SendReply(ivd_FS_ERR_Reply);
    }
}

Here is the call graph for this function:

void i_HSM_i::Reconfigure ( const i_ClientConf_t a_clientConf  ) 

Definition at line 808 of file i_hsm_impl.cpp.

References ClientConf_t::CfgCriticalWaterMark, ClientConf_t::CfgHighWaterMark, ClientConf_t::CfgLowWaterMark, ClientConf_t::CfgMaxMigSize, ClientConf_t::CfgMaxNumFiles, ClientConf_t::CfgMaxWaitTime, ClientConf_t::CfgMFAge, ClientConf_t::CfgMigRetentionTime, ClientConf_t::CfgMinFileSize, ClientConf_t::CfgMinMigSize, ClientConf_t::CfgMinNumFiles, ClientConf_t::CfgMinWaitTime, ClientConf_t::CfgOperationMode, ClientConf_t::CfgRecallOnly, ClientConf_t::CfgRecallOnOpen, ClientConf_t::CfgRecallRetentionTime, ClientConf_t::CfgRecallTimeOut, ClientConf_t::CfgReleaseInterval, ClientConf_t::CfgWORMTimeout, dbg_DETAIL, g_clientConf_p, g_fs_api_p, g_hsm_dirtyList_p, g_hsm_migcList_p, g_hsm_relcList_p, ivd_FileSystemAPI::GetConfiguration(), i_FST_WORM, ClientConf_t::Init(), log_DBG_m, log_FUNC_m, ivd_FS_Cfg_t::operationMode, ivd_FS_Cfg_t::recallOnOpen, hsm_FHdirty::Reconfigure(), hsm_FHmigc::Reconfigure(), hsm_FHrelc::Reconfigure(), hsm_MigByAPI::SetAPIMode(), ivd_FileSystemAPI::SetConfiguration(), ivd_FS_Cfg_t::syncEventTimeout, and ivd_FS_Cfg_t::WORMTimeout.

Here is the call graph for this function:

void i_HSM_i::Remove (  )  [virtual]

Reimplemented from i_Component_i.

Definition at line 407 of file i_hsm_impl.cpp.

References dbg_DETAIL, g_fs_api_p, log_DBG_m, log_FUNC_m, m_abortCheckFSCvsIVDFS, m_consistencyCheckRun_x, m_sendTerminateEvent, m_shutDownInProgress, and ivd_FileSystemAPI::TriggerTerminateEvent().

Referenced by main().

                     {
    log_FUNC_m(Remove);

    {
        cmn_MutexLock l(m_consistencyCheckRun_x);
        m_abortCheckFSCvsIVDFS = true;
    }

    if (m_shutDownInProgress) {
        // Was here.
        log_DBG_m(dbg_DETAIL, "Remove was already called. Do nothing.");
        return;
    }

    m_shutDownInProgress   = true;

    if (m_sendTerminateEvent) {
        log_DBG_m(dbg_DETAIL, "Sending terminate to fsfilter");
        g_fs_api_p->TriggerTerminateEvent();
    }

    // Do any cleanup necessary
    i_Component_i::Remove();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_HSM_i::RunScripts (  ) 

Definition at line 1470 of file i_hsm_impl.cpp.

                        {
  // @todo insert code here and remove the warning
// #warning "Code missing in function <void i_HSM_i::RunScripts()>"
}

void i_HSM_i::SetFullAccess ( void   ) 
void i_HSM_i::SetLastFscFileID ( ivd_RecordIDX_t  a_lastFscFileID  )  [inline]

Definition at line 310 of file i_hsm_impl.h.

References m_lastFscFileID.

Referenced by main().

{m_lastFscFileID = a_lastFscFileID; };

Here is the caller graph for this function:

void i_HSM_i::SetReady ( bool  a_ready  )  [inline]

Definition at line 307 of file i_hsm_impl.h.

References m_ready.

Referenced by fs_api::EventMounted(), and main().

{m_ready = a_ready;};

Here is the caller graph for this function:

void i_HSM_i::SetSendTerminateEvent ( bool  a_sendTerminateEvent  )  [inline]

Definition at line 309 of file i_hsm_impl.h.

References m_sendTerminateEvent.

Referenced by main().

{m_sendTerminateEvent = a_sendTerminateEvent;};

Here is the caller graph for this function:

void i_HSM_i::ShowStatus ( i_UIMessageServer_ptr  a_uims,
i_BitFlag_t  a_showFlags 
)

Definition at line 2173 of file i_hsm_impl.cpp.

References ClientConf_t::CfgPartitionName, ClientConf_t::CfgPartitionUUID, hsm_FHmigc::DumpList(), hsm_FHdirty::DumpList(), hsm_FileHeader::DumpStatus(), hsm_FHdirty::DumpStatus(), hsm_FHmigc::DumpStatus(), hsm_DirWaitList::DumpStatus(), g_clientConf_p, g_cmn, g_fs_api_p, g_hsm_dirtyList_p, g_hsm_dirWaitList_p, g_hsm_migcList_p, g_hsm_preJobList_p, g_hsm_relcList_p, hsm_JobListMgr::GetNumJobs(), hsm_FHrelc::GetNumTruncations(), ivd_FileSystemAPI::GetRootPath(), hsm_FHrelc::GetWakeUpTime(), isf_DETAIL, isf_SH_DIRTY, isf_SH_MIG_CAN, log_FUNC_m, cmn_SysInfo::m_hostName, m_numForcedRelease, m_numMigs, m_numRecalls, m_upTime, NULL, cmn_Global::si, and cmn_Time::Time2YMDhms().

                                                             {

    log_FUNC_m(ShowStatus);

    try {

        ostringstream sstr;

        cmn_Time uptime(m_upTime,0);

        UInt32_t numMigJob;
        UInt32_t numMigJobPreparation;
        UInt32_t numMigJobWaitForDoMig;
        UInt32_t numMigJobDoMig;
        UInt32_t numMigJobWaitForComplete;
        UInt32_t numMigJobComplete;
        UInt32_t numFailedMigJob;
        UInt32_t numRecJob;

        g_hsm_preJobList_p->GetNumJobs(numMigJob,
                                    numMigJobPreparation,
                                    numMigJobWaitForDoMig,
                                    numMigJobDoMig,
                                    numMigJobWaitForComplete,
                                    numMigJobComplete,
                                    numFailedMigJob,
                                    numRecJob);

        sstr << endl<< "Partition " << g_clientConf_p->CfgPartitionName << " is up from " << uptime.Time2YMDhms() << endl;
        sstr << "partition mount point " << g_fs_api_p->GetRootPath() <<
                " with file system ID " << g_clientConf_p->CfgPartitionUUID <<
                " on host " << g_cmn.si.m_hostName << endl;

        if (a_showFlags & isf_SH_DIRTY) {
            g_hsm_dirtyList_p->DumpList(sstr);
            a_uims->DisplayMessage(sstr.str().c_str());
            return;
        }
        if (a_showFlags & isf_SH_MIG_CAN) {
            g_hsm_migcList_p->DumpList(sstr);
            a_uims->DisplayMessage(sstr.str().c_str());
            return;
        }

        sstr << endl << "This partition was done successful:" << endl;
        sstr << "-----------------------------------------------" << endl;
        sstr << "Number of migrated files:  " << m_numMigs << endl;
        sstr << "Number of releases:        " << g_hsm_relcList_p->GetNumTruncations() << endl;
        sstr << "Number of recalled files:  " << m_numRecalls << endl << endl;
        sstr << "Number of forced releases: " << m_numForcedRelease << endl;
        sstr << "-----------------------------------------------" << endl;

        if (a_showFlags & isf_DETAIL) {
            cmn_Time upRtime(g_hsm_relcList_p->GetWakeUpTime() ,0);
            cmn_Time curTime(time(NULL));

            sstr << "Additional info of Partition at the moment: "<< endl;
            sstr << "-----------------------------------------------------------" << endl;
            sstr << "Number of REC jobs at the moment: " << numRecJob << endl;
            sstr << "Number of MIG jobs at the moment: " << numMigJob << endl;
            sstr << "Count by status:     preparation: " << numMigJobPreparation << endl;
            sstr << "           wait for do migration: " << numMigJobWaitForDoMig << endl;
            sstr << "                 on do migration: " << numMigJobDoMig << endl;
            sstr << "           wait for complete mig: " << numMigJobWaitForComplete << endl;
            sstr << "                 on complete mig: " << numMigJobComplete << endl;
            sstr << "Number of FAILED migrations     : " << numFailedMigJob << endl;

            sstr << "Number of files on dirty list        :  " << g_hsm_dirtyList_p->size() << endl;
            g_hsm_dirWaitList_p->DumpStatus(sstr);
            g_hsm_migcList_p->DumpStatus(sstr);
            g_hsm_dirtyList_p->DumpStatus(sstr);
            sstr << "Next Release will wake up at:           " << upRtime.Time2YMDhms() << endl;
            sstr << "                        Current time :  " << curTime.Time2YMDhms() << endl;
    //         sstr << "number of Recall Jobs at the moment:    " << hsmInfo->numRecallJob << endl;
            sstr << "-----------------------------------------------------------" << endl;
            hsm_FileHeader::DumpStatus(sstr);
        }
        // NOTE str duplicate not need, it produce mem leak
        a_uims->DisplayMessage(sstr.str().c_str());
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

i_Status_t i_HSM_i::Suspend (  ) 

Definition at line 2434 of file i_hsm_impl.cpp.

References evt_ERROR, g_hsmDB_p, ivd_BaseException::GetFriendly(), log_FUNC_m, log_WriteEvent(), and fio_DataBase::Suspend().

                            {
    log_FUNC_m(Suspend);
    try {
        g_hsmDB_p->Suspend();
        log_WriteEvent("HSM DB suspended.");
        return 0;
    }
    catch (ivd_Exception &ie) {
        ostringstream sstr;
        sstr << "HSM DB suspend failed (" << ie.GetFriendly() << ").";
        log_WriteEvent(evt_ERROR, sstr.str());
        return 1;
    }
    catch (...) {
        log_WriteEvent(evt_ERROR, "HSM DB suspend failed");
        return 1;
    }
}

Here is the call graph for this function:

void i_HSM_i::TrigEfficientRecall ( const i_FileList_t a_files,
bool  a_MigrateAfter,
i_UIMessageServer_ptr  a_uims 
) [private]

Definition at line 2788 of file i_hsm_impl.cpp.

References ivd_FS_File::Close(), cmn_IsSpecialFile(), cmn_StrLowerCase(), dbg_DETAIL, dbg_LOW, dbg_NORM, hsm_FileHeader::DecrRef(), ivd_FS_File::e_Cache, hsm_FileHeader::EventOffline(), file, i_Recall_t::fileID, i_Recall_t::fileIdx, i_Recall_t::fileSize, g_fs_api_p, g_hsm_fhLock, g_hsm_preJobList_p, g_iPM, hsm_JobListMgr::GetJobIdx(), ivd_FS_File::GetProperties(), ivd_FileSystemAPI::GetRootPath(), hjs_RECALL, hsmGetFH(), ipc_EXEC_m, log_DBG_m, log_FUNC_m, ivd_FS_FileProperty_t::m_fileID, ivd_FS_FileProperty_t::m_Inode, i_Recall_t::migrationID, ivd_FS_File::Open(), hsm_JobListMgr::ReleaseJobIdx(), cmn_Path::RemoveTrailingPathSeparator(), hsm_JobListMgr::SetJobStatus(), and hsm_JobListMgr::SetMigJobID().

Referenced by ForceMigration(), and TrigRecall().

                                                                {

    log_FUNC_m(TrigEfficientRecall);

    try {

        UInt32_t recallJobIdx = 0;
        i_RecallList_t  recallList;
        recallJobIdx = g_hsm_preJobList_p->GetJobIdx(a_files.length());

        g_hsm_preJobList_p->SetJobStatus(recallJobIdx, hjs_RECALL);
        recallList.length(a_files.length());
        log_DBG_m(dbg_DETAIL, "Create job for efficient recall. "
                            << " number of files: " << a_files.length()
                            << ", recallJobIdx: " << recallJobIdx);

        UInt32_t recListIdx = 0;
        for (UInt32_t i = 0; i < a_files.length(); i++){
            log_DBG_m(dbg_DETAIL, a_files[i].name
                << "(" << a_files[i].fileID << ":" << a_files[i].fileIdx << ")");

            //  Recall latest generation, simulate DataOfflineEvent.
            cmn_Path filePath(a_files[i].name);

            {
                cmn_Path rootPath(g_fs_api_p->GetRootPath());
                rootPath.RemoveTrailingPathSeparator();

                cmn_Path currentPath(filePath);
                currentPath.RemoveTrailingPathSeparator();

#if TGT_OS_windows
                cmn_StrLowerCase(currentPath);
                cmn_StrLowerCase(rootPath);
#endif

                if (currentPath == rootPath) { // skip root directory
                    a_uims->DisplayWarning("Cannot recall root directory.");
                    continue;
                }
            }

            if (cmn_IsSpecialFile(filePath)){
                log_DBG_m(dbg_DETAIL, "Special file: " << a_files[i].name << " Will skip it.");
                continue;
            }

            ivd_FS_File file(*g_fs_api_p, filePath);

            ivd_FS_FileProperty_t fileProp;
            try {
                file.Open(ivd_FS_File::e_Cache, filePath);
                file.GetProperties(fileProp);
                file.Close();
            }
            catch (ivd_SysError &ise) {
                log_DBG_m(dbg_NORM, "Can't get general inode of fileID " << fileProp.m_fileID
                            << " Probably not exist."  << ise);
                continue; // no file found
            }
    //                if (!g_hsm_fhLock.CanLockByID(fileProp.m_Inode)) {
    //                }
            g_hsm_fhLock.LockByID(fileProp.m_Inode);

            log_DBG_m(dbg_DETAIL, "Find FH. path: " << filePath);
            // Get FH and add it to cache
            hsm_FileHeader *fileHdr = hsmGetFH(filePath, fileProp);

            log_DBG_m(dbg_DETAIL, "Got FH.");
            i_Recall_t &recallStr = recallList[recListIdx];

            log_DBG_m(dbg_DETAIL, "Set reference to recall structure.");
            // fill up recall structure, remove FH from cache in case of
            // failure or file is already online
            fileHdr->EventOffline(recallJobIdx, recallStr, a_MigrateAfter);
            log_DBG_m(dbg_DETAIL, "    #, fileID,       migID,   fileSize, jIdx, fIdx");
            log_DBG_m(dbg_DETAIL, setw(5) << i
                            << setw(8) << recallStr.fileID
                            << setw(13) << recallStr.migrationID
                            << setw(12) << recallStr.fileSize);

            if (recallStr.fileID > 0) { // file is added to recall list
                ++recListIdx;
            }
            else {
                // TODO remove FH if is not added to recall job.
            }

            // GetFH and constructor increase ref automaticaly,
            // to prevent others to dereference FH before is linked to some list or job
            fileHdr->DecrRef();

            g_hsm_fhLock.UnLockByID(fileProp.m_Inode);
        }

        recallList.length(recListIdx);
        if (recListIdx != 0) {
            i_JobID_t hsmJobIndexID(0);

            ipc_EXEC_m(
                hsmJobIndexID = g_iPM->AllocateNewJobIDforEffRecall();
            );

            log_DBG_m(dbg_LOW, "Created jobs will use the following ID: " << hsmJobIndexID);
            g_hsm_preJobList_p->SetJobStatus(recallJobIdx, hjs_RECALL);
            g_hsm_preJobList_p->SetMigJobID(recallJobIdx, hsmJobIndexID, 0);

            ipc_EXEC_m(
                hsmJobIndexID = g_iPM->EfficientRecall(recallList, hsmJobIndexID);
            );

            ostringstream sstr;
            sstr << "Created job " << hsmJobIndexID << " for efficient recall of " << recListIdx << " files";
            a_uims->DisplayMessage(sstr.str().c_str());
        }
        else { // No files to recall. Release job.
            g_hsm_preJobList_p->ReleaseJobIdx(recallJobIdx);
        }
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

Here is the caller graph for this function:

i_Count_t i_HSM_i::TrigMigration (  ) 

Definition at line 2541 of file i_hsm_impl.cpp.

References ClientConf_t::CfgRecallOnly, g_clientConf_p, g_hsm_migcList_p, ie_PRECONDITION, ivd_Error, log_FUNC_m, log_WriteEvent(), and hsm_FHmigc::TrigMigration().

Referenced by MigrateByAPI().

                                 {
    log_FUNC_m(TrigMigration);
    UInt32_t numMigrated = 0;
    try {
        if (g_clientConf_p->CfgRecallOnly) {
            throw ivd_Error(ie_PRECONDITION, "Operation not allowed in Recall only mode.");
        }
        // collect all orphaned files from HSMDB
        numMigrated = g_hsm_migcList_p->TrigMigration();
        if (numMigrated) {
            ostringstream sstr;
            sstr << "Migration triggered by user (#files: "
                 << numMigrated << ").";
            log_WriteEvent(sstr.str());
        }
    } ipc_CATCH_IVD_THROW_CORBA_m;
    return numMigrated;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_HSM_i::TrigRecall ( const i_FileList_t a_files,
CORBA::Boolean  a_byFileName,
i_MigID_t  a_migID,
const char *  a_into,
i_UIMessageServer_ptr  a_uims 
)

Definition at line 2478 of file i_hsm_impl.cpp.

References dbg_DETAIL, evt_ERROR, i_Recall_t::fileID, i_Recall_t::fileIdx, g_fs_api_p, g_hsm_preJobList_p, g_iPM, hsm_JobListMgr::GetJobIdx(), hjs_RECALL, ie_PRECONDITION, hsm_JobListMgr::Insert(), ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_m, log_WriteEvent(), fs_api::m_fsUUID, hsm_RecallInfoGrp::m_jobElemIdx, hsm_RecallInfoGrp::m_jobIdx, i_Recall_t::migrationID, hsm_JobListMgr::SetJobStatus(), hsm_JobListMgr::SetMigJobID(), str, and TrigEfficientRecall().

                                  {

    log_FUNC_m(TrigRecall);
    try {
        string into(a_into);

        if (!into.empty()) {
            // Check for destination file system.
            string fsID = cmn_File(into).GetFileSystemID();
            if (g_fs_api_p->m_fsUUID.compare(fsID) == 0) {
                string str("Wrong destination file system (" + fsID + ").");
                log_WriteEvent(evt_ERROR, str);

                throw ivd_Error(ie_PRECONDITION,
                    "Recall into hsm file system is not allowed.");
            }
        }
        else {
            TrigEfficientRecall(a_files, false, a_uims);
            return;
        }

        log_DBG_m(dbg_DETAIL, "Manual Recall into '" << a_into
            << "' triggered for " << a_files.length() << " files.");
        log_DBG_m(dbg_DETAIL, "    byName=" << a_byFileName
            << ", migID=" << a_migID);

        for (UInt32_t i = 0; i < a_files.length(); i++){
            log_DBG_m(dbg_DETAIL, a_files[i].name
                << "(" << a_files[i].fileID << ":" << a_files[i].fileIdx << ")");

            // Create new FileHeader w/o owner.
            cmn_Path dstFileName(into);

            hsm_RecallInfoGrp *pRI = new hsm_RecallInfoGrp(
                ivd_FS_File(*g_fs_api_p, dstFileName), 0); // file size is not important

            hsm_FileHeader *pFH = new hsm_FileHeader(pRI);

            pRI->m_jobIdx = g_hsm_preJobList_p->GetJobIdx(1);
            pRI->m_jobElemIdx = g_hsm_preJobList_p->Insert(pRI->m_jobIdx, pFH);

            struct i_Recall_t recallStr;
            recallStr.fileID        = a_files[i].fileID;
            recallStr.migrationID   = a_migID;
            recallStr.fileIdx       = a_files[i].fileIdx;
            ipc_EXEC_m(
                i_JobID_t hsmJobIndexID = g_iPM->Recall(recallStr);
                g_hsm_preJobList_p->SetJobStatus(pRI->m_jobIdx, hjs_RECALL);
                g_hsm_preJobList_p->SetMigJobID(pRI->m_jobIdx, hsmJobIndexID, 0);
                ostringstream sstr;
                sstr << "Created job " << hsmJobIndexID << " for recall of file " << a_files[i].name;
                a_uims->DisplayMessage(sstr.str().c_str());
            );
        }
    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

bool i_HSM_i::UnPackFile ( const i_Recall_t a_file,
ivd_FS_File recallFile,
bool  manualRecall,
UInt64_t rclSize,
df_Unpacker unpacker 
) [private]

Definition at line 1293 of file i_hsm_impl.cpp.

References ivd_FS_File::Close(), cmn_Num2Str(), dbg_DETAIL, dbg_NORM, df_RF_SPLITTED, df_ST_ALTDATA, df_ST_DATA, df_ST_META, ivd_FS_File::e_RecallInto, evt_ERROR, i_Recall_t::fileID, df_Unpacker::GetBSData(), ivd_BaseException::GetFriendly(), ivd_FS_File::GetFullPathRef(), df_Unpacker::GetNextRecord(), ivd_FS_File::GetStreamLeft(), ie_IMPOSSIBLE, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), m_shutDownInProgress, i_Recall_t::migrationID, ivd_FS_File::Open(), df_Unpacker::ReadRecBSEnd(), df_Unpacker::ReadRecBSStart(), df_Unpacker::ReadRecFile(), df_Unpacker::ReadRecFileEnd(), rec_BSEnd_c, rec_BSStart_c, rec_Data_c, rec_FileEnd_c, rec_FileHdr_c, rec_NoRec_c, ivd_FS_File::SetFullPath(), ivd_FS_File::SetStreamHeader(), and ivd_FS_File::WriteStream().

Referenced by Recall().

                                                {
    log_FUNC_m(UnPackFile);

    bool doFile = false;    // set to true when we have found file to recall
    bool doData = false;    // set to true when we have found file's data to recall
    bool dataRecalled = false; // set to true when data was recalled
    UInt32_t  status = 1;   // status of unpacker

    UInt64_t  idFile;       // File ID   *
    UInt64_t  idMig;        // Mig ID  *
    UInt32_t  recType;

    rclSize = 0;

    // used to check amount of recalled data.
    Int64_t  streamSizeLeft = 0;
    UInt64_t sSize = 0;
    string   sName;

    while ((recType = unpacker.GetNextRecord()) != rec_NoRec_c) {
        log_DBG_m (dbg_DETAIL, "  Unpacker Get Next Rec ");
        if (m_shutDownInProgress) {
            log_DBG_m (dbg_NORM, "Shut down. Abort recall.");
            return false;
        }

        if (recType == rec_FileHdr_c) {
            if (doFile) { // file is already opened, got another filheader
                log_DBG_m (dbg_DETAIL, "  New FH at Recall. File is already open. Probably next split.");
                continue;
            }
            UInt64_t  idParent,  idParentOld, chunkSize;
            string    fname, fnameOld;
            UInt32_t  changeFlags, fflags;
            ivd_FileInfo_t  finfo;

            unpacker.ReadRecFile(idFile, idMig, idParent, idParentOld,
                                 fname, fnameOld, finfo,
                                 changeFlags, fflags, chunkSize);

//
// TODO: Sync types in IDL after merge to Cosmos. typedefs for known types in IDL.
//

            if (   a_file.fileID      != idFile
                || a_file.migrationID != idMig) {

                log_DBG_m (dbg_NORM, "  Unpacker SKIPPED wrong fileId or MigID. " << endl <<
                                       "\t\t\t\tFileID: " << idFile << " MigID: " << idMig);
                continue; // skip this file
            }

            doFile = true;

            cmn_Path recallPath = recallFile.GetFullPathRef();
            log_DBG_m(dbg_NORM, "  RECALL data of file " << recallPath);
            log_DBG_m(dbg_NORM, "  stored name:" << fname);

            if (manualRecall) {
                // File was not opened, since we had no name until now.
                recallFile.SetFullPath(recallPath
                    + cmn_Path(fname).GetFileName());
                try {
                    recallFile.Open(ivd_FS_File::e_RecallInto);
                }
                catch (ivd_SysError &se) {
                    ostringstream sstr;
                    sstr << "Cannot open destination file "
                        << recallFile.GetFullPathRef()
                        << " for recall into. "
                        << se.GetFriendly();
                    log_WriteEvent(evt_ERROR, sstr.str());
                    throw;
                }
            }
        }
        else if (recType == rec_FileEnd_c) {
            if (  doFile ) {  // OK, end of file
                UInt32_t  recFlags;
                unpacker.ReadRecFileEnd(idFile, idMig, status, recFlags);
                if (status) { // recall failed
                    log_ERR_m (" There was an ERROR during recall of file."
                              << " Status=" << status
                              << " File='" << recallFile.GetFullPathRef() << "'"
                              << " total stream size " << sSize
                              << " Stream size left=" << streamSizeLeft );
                    break;
                }

                if (!(recFlags & df_RF_SPLITTED)
                   && streamSizeLeft == 0) {  // if splitted expect new stream
                    recallFile.Close();

                    break; // exit loop
                }
            }
        }
        else if (recType == rec_BSStart_c) {
            if (doFile) {
                UInt32_t  sType;
                UInt64_t  streamOffset;

                unpacker.ReadRecBSStart(sType, sName, sSize, streamOffset);

                if (sType == df_ST_DATA     // always recall data stream...
                    || manualRecall) {      // ... and other streams if recall into
                    // We go the data to recall
                    log_DBG_m(dbg_DETAIL, "  Data of file " << recallFile.GetFullPathRef() << " IS_FOUND. RECALL proceed.");
                    doData = true;

                    // if this is start of stream
                    // TODO: is this check required for split files?
                    if (recallFile.GetStreamLeft() == 0 ) {
                        streamSizeLeft = sSize;
                        UInt32_t strType(0);
                        switch (sType) {
                            case df_ST_DATA:    strType = stt_DATA;     break;
                            case df_ST_ALTDATA: strType = stt_ALTDATA;  break;
                            case df_ST_META:    strType = stt_META;     break;
                            default:
                                throw ivd_InternalError(ie_IMPOSSIBLE,
                                    "Invalid stream type from data format: " +
                                    cmn_Num2Str(sType));
                        }
                        recallFile.SetStreamHeader(strType, sName, sSize);
                    }
                }
            }
        }
        else if (recType == rec_BSEnd_c) {
            if (doFile && doData) { // recall complete
                unpacker.ReadRecBSEnd(status);

                if (status != 0) {
                    log_ERR_m(" There was an ERROR during recall of file at BSE."
                              << " Status=" << status
                              << " File='" << recallFile.GetFullPathRef() << "'"
                              << " stream name='" << sName << "'"
                              << " total stream size " << sSize
                              << " Stream size left=" << streamSizeLeft );
                    break;
                }
                if (streamSizeLeft == 0) {
                    doData = false;

                    dataRecalled = true;
                    log_DBG_m(dbg_DETAIL, "  RECALL file " << recallFile.GetFullPathRef() << " FINISHED succesfully");
                }
            }
        }
        else if (recType == rec_Data_c) {
            if (doFile && doData) {
                UInt8_t   *buf;
                UInt32_t  bufsize;

                unpacker.GetBSData(buf, bufsize);
                log_DBG_m(dbg_DETAIL, "RECALL to write data to file " << recallFile.GetFullPathRef() << " bufsize: " << bufsize);

                UInt32_t written;
                written = recallFile.WriteStream(buf, bufsize);
                streamSizeLeft -= bufsize;
                rclSize += written;
                log_DBG_m(dbg_DETAIL, "  data is written to file " << recallFile.GetFullPathRef());
            }
        }
    } // while
    log_DBG_m(dbg_NORM,
        "Unpacker FINISHED: status " << status
        << ", dataRecalled " << boolalpha << dataRecalled
        << ", doFile " << boolalpha << doFile);
    return doFile && dataRecalled && status == 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_HSM_i::WriteToDirectoryCollocationTable ( const char *  a_dir,
i_ColID_t  a_majorColId,
const char *  a_partName,
bool  a_force 
)

Definition at line 3316 of file i_hsm_impl.cpp.

References ClientConf_t::AppendCollocationInfo(), g_clientConf_p, g_iPM, log_FUNC_A_m, i_ColInfo_t::m_colId, and i_ColInfo_t::m_path.

                                                             {
    log_FUNC_A_m(WriteToDirectoryCollocationTable, a_dir << " => " << a_colId);
    try {
        i_ColInfo_t colInfo;
        colInfo.m_path = CORBA::string_dup(a_dir);
        colInfo.m_colId = a_colId;
        g_iPM->WriteCollocationInfo(colInfo);

        g_clientConf_p->AppendCollocationInfo(a_dir, a_colId);

    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

void i_HSM_i::WriteToDirectoryHl7InfoTable ( const char *  a_dir,
const char *  a_hostname,
CORBA::ULong  a_port,
const char *  a_partName,
bool  a_force 
)

Definition at line 3349 of file i_hsm_impl.cpp.

References ClientConf_t::AppendHL7Info(), cmn_Num2Str(), g_clientConf_p, g_iPM, log_FUNC_A_m, hsm_hl7ServerInfo::m_hostname, i_HL7Info_t::m_hostname, i_HL7Info_t::m_path, hsm_hl7ServerInfo::m_port, and i_HL7Info_t::m_port.

                                                          {
    log_FUNC_A_m(WriteToDirectoryHl7InfoTable, a_dir << " => " << a_hostname << ":" << a_port);
    try {
        i_HL7Info_t hl7Info;
        hl7Info.m_path = CORBA::string_dup(a_dir);
        hl7Info.m_hostname = CORBA::string_dup(a_hostname);
        hl7Info.m_port = CORBA::string_dup(cmn_Num2Str(UInt32_t(a_port)).c_str());

        g_iPM->WriteHl7Info(hl7Info);

        hsm_hl7ServerInfo hl7SrvInfo;
        hl7SrvInfo.m_hostname = hl7Info.m_hostname;
        hl7SrvInfo.m_port = hl7Info.m_port;
        g_clientConf_p->AppendHL7Info(a_dir, hl7SrvInfo);

    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from i_Component_i.

Definition at line 199 of file i_hsm_impl.h.

Definition at line 187 of file i_hsm_impl.h.

Referenced by Abort(), CheckFSCvsIVDFS(), and Remove().

Definition at line 185 of file i_hsm_impl.h.

Referenced by CheckFSCvsIVDFS(), and IsCheckFSCvsIVDFSRunning().

Definition at line 184 of file i_hsm_impl.h.

Referenced by Abort(), CheckFSCvsIVDFS(), IsCheckFSCvsIVDFSRunning(), and Remove().

Definition at line 197 of file i_hsm_impl.h.

Referenced by EfficientRecall().

bool& i_HSM_i::m_hsmRun [private]

Definition at line 188 of file i_hsm_impl.h.

Referenced by i_HSM_i(), and ~i_HSM_i().

Definition at line 194 of file i_hsm_impl.h.

Referenced by GetLastFscFileID(), and SetLastFscFileID().

Definition at line 173 of file i_hsm_impl.h.

Referenced by ForceRelease(), GetInfo(), and ShowStatus().

Definition at line 175 of file i_hsm_impl.h.

Referenced by CompleteMigration(), GetInfo(), and ShowStatus().

Definition at line 174 of file i_hsm_impl.h.

Referenced by GetInfo(), Recall(), and ShowStatus().

bool i_HSM_i::m_ready [private]

ready when filter's events are able to cauth

Definition at line 178 of file i_hsm_impl.h.

Referenced by CheckFSCvsIVDFS(), GetInfo(), IsHSMReady(), and SetReady().

Definition at line 192 of file i_hsm_impl.h.

Referenced by IVDFSRecover().

Definition at line 190 of file i_hsm_impl.h.

Referenced by Remove(), and SetSendTerminateEvent().

Definition at line 183 of file i_hsm_impl.h.

Referenced by CompleteMigration(), DoMigrationJob(), PackFile(), Remove(), and UnPackFile().

Definition at line 176 of file i_hsm_impl.h.

Referenced by GetInfo(), and ShowStatus().


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