Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions

i_RedundantCopyJob_i Class Reference
[Partition Manager]

#include <i_redundantcopyjob_impl.h>

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

List of all members.

Public Member Functions

 i_RedundantCopyJob_i (pm_JobMgr &a_jobMgr, i_PartitionManager_i &a_iPM, string a_barcode, const i_VolNumList_t &a_volumes,::CORBA::Boolean a_best_effort, i_UIMessageServer_ptr a_uims)
virtual ~i_RedundantCopyJob_i ()
void MediumOperationComplete (i_Index_t a_beaNum, i_CompletionStatus_e a_status)
i_FileLocationDataList_tGetNextRecallSet ()
void CompleteJob (i_CompletionStatus_e a_status)
void GetNewResources (i_Index_t a_resNum)

Public Attributes

 log_CLASSID_m

Protected Member Functions

void ReadSourceData ()
void Execute ()
virtual i_FSC_ptr GetFSC ()
virtual i_JobRequestList_tGetFiles ()

Protected Attributes

i_PartitionManager_im_iPM
string m_barcode
i_Medium_t m_medium
i_MediumVolSeq_t m_mv
i_MediaPool_t m_pool
bool m_best_effort
UInt32_t m_currentMedium
bool m_ccAllVol
vector< UInt32_tm_ccVol
vector< pm_VolStatusm_medStatus_v
vector< UInt32_tm_unavailFilesPerVol
ui_MsgWriter m_ui

Private Member Functions

bool Prepare ()
bool RecallFiles (pm_VolStatus &vol, UInt64_t a_dBuffSize)
void MigrateFiles (pm_VolStatus &vol)
void SetResourceBusyStatus (i_Index_t a_resNum, i_ResourceBusy_e a_resStatus)

Detailed Description

Definition at line 39 of file i_redundantcopyjob_impl.h.


Constructor & Destructor Documentation

i_RedundantCopyJob_i::i_RedundantCopyJob_i ( pm_JobMgr a_jobMgr,
i_PartitionManager_i a_iPM,
string  a_barcode,
const i_VolNumList_t a_volumes,
::CORBA::Boolean  a_best_effort,
i_UIMessageServer_ptr  a_uims 
)

Definition at line 56 of file i_redundantcopyjob_impl.cpp.

References i_Medium_t::barcode, i_Medium_t::blockSize, i_Resource_t::blockSize, i_JobParams::bufId, rm_String::cvalue_p, dbg_LOW, dbg_NORM, ui_MsgWriter::DisplayMessage(), ui_MsgWriter::DisplayWarning(), i_Job_i::GetResources(), ie_FATAL_ERROR, i_Job_i::InitBeaStatus(), ipc_EXEC_m, ivd_Error, i_JobParams::jobID, i_JobParams::jobPriority, i_JobParams::jobType, log_DBG_m, log_FUNC_m, ipc_Log::LogResources(), i_Job_i::m_activeBeas, m_barcode, m_ccAllVol, m_ccVol, i_PartitionManager_i::m_config, i_Job_i::m_iJobParams, m_iPM, i_PartitionManager_i::m_iRM, m_medium, m_mv, m_pool, i_Job_i::m_rm, i_PartitionManager_i::m_rmPart, m_ui, i_MediaPool_t::mediaFamily, i_MediaPool_t::mediaPoolKey, i_MediaPool_t::mediaPoolName, i_Medium_t::mediaPoolName, i_MediaPool_t::mediaPoolType, i_Resource_t::mediumFamily, i_Medium_t::mediumKey, cfg_PMCfg::migrationPriority, cfg_PMCfg::name, rm_Partition::partitionUUIDString, i_JobParams::partName, i_JobParams::partUUID, i_Resource_t::poolKey, i_Resource_t::poolName, i_Resource_t::poolType, i_Resource_t::poolUUID, i_MediaPool_t::poolUUIDString, i_Resource_t::resNum, ipc_Init::ResourceInit(), i_Job_i::SetResources(), and vt_SYSTEM_VOLUME.

    : i_Job_i(a_jobMgr, true),
      m_iPM(a_iPM),
      m_barcode(a_barcode),
      m_currentMedium(0),
      m_ccAllVol(a_volumes.length() == 0),
      m_best_effort(a_best_effort),
      m_ui(a_uims)
{
    log_FUNC_m(i_RedundantCopyJob_i);
    m_iJobParams.jobPriority = m_iPM.m_config.migrationPriority;
    m_iJobParams.partName = CORBA::string_dup(m_iPM.m_config.name.c_str());
    m_iJobParams.partUUID =
        CORBA::string_dup(m_iPM.m_rmPart.partitionUUIDString.cvalue_p);
    m_iJobParams.jobType  = jt_MAINT;
    m_iJobParams.bufId    = m_iJobParams.jobID;


    //select medium
    ipc_EXEC_m(
        i_Medium_t_var med = m_iPM.m_iRM->SelectMedium(m_barcode.c_str());
        m_medium = med;
    );


    ipc_EXEC_m(
        //select all volumes
        i_MediumVolSeq_t_var mv = m_rm->SelectAllMediumVolByBarcode(m_medium.barcode);

        log_DBG_m(dbg_LOW, "mv->length(): " << mv->length());

        if (m_ccAllVol) {
            for (UInt32_t i(0); i < mv->length(); i++){
                log_DBG_m(dbg_LOW, "Volume: " << mv[i].medVolNr);

                if (mv[i].volType != vt_SYSTEM_VOLUME){
                    m_ccVol.push_back(mv[i].medVolNr);
                    m_mv.length(m_mv.length()+1);
                    m_mv[m_mv.length()-1] = mv[i];
                }
            }
        } else {
            for (UInt32_t i(0); i < a_volumes.length(); i++){
                log_DBG_m(dbg_LOW,  "i: " << i <<
                                    " a_volumes.length(): " << a_volumes.length());
                log_DBG_m(dbg_LOW, "Volume: " << a_volumes[i]);

                UInt32_t j(0);
                bool found(false);
                for (; j < mv->length(); j++){
                    log_DBG_m(dbg_LOW, "j: " << j);
                    if ((Int32_t)a_volumes[i] == mv[j].medVolNr) {
                        found = true;
                        break;
                    }
                }
                if (found){
                    if (mv[j].volType != vt_SYSTEM_VOLUME){
                        log_DBG_m(dbg_LOW, "Not sysVol");
                        m_ccVol.push_back(a_volumes[i]);
                        m_mv.length(m_mv.length()+1);
                        m_mv[m_mv.length()-1] = mv[j];
                        log_DBG_m(dbg_LOW, "m_mv.length()" << m_mv.length());
                        log_DBG_m(dbg_LOW, "m_ccVol.size()" << m_ccVol.size());

                    } else {
                        ostringstream msg;
                        msg << "Volume " << a_volumes[i] << " is a system volume. Skipping...";
                        m_ui.DisplayWarning(msg.str());
                    }
                } else {
                    ostringstream msg;
                    msg << "Volume " << a_volumes[i] << " does not exist.";
                    m_ui.DisplayWarning(msg.str());
                }
            }
        }
    );

    sort(m_ccVol.begin(), m_ccVol.end());

    //check
    if (m_ccVol.size() != m_mv.length())
        throw ivd_Error(ie_FATAL_ERROR, "Volume list sizes do not mach");


    //select pool
    ipc_EXEC_m(
        i_MediaPool_t_var pool =
            m_iPM.m_iRM->SelectMediaPool(m_medium.mediaPoolName);
        m_pool = pool;
    );

    //set resources
    i_ResourceList_t resources;
    ipc_EXEC_m(
        resources.length(2);
        //2 because for redundant one source resource and one
        // target resource we be used at one point in time
    );
    m_activeBeas.resize(2);
    InitBeaStatus(2);

    // for each resource prepare row
    for (UInt32_t i(0); i < 2; i++){
        i_Resource_t &allocRow = resources[i];
        //ResourceInit sets all members to 0 or to ipc_nilStr
        ipc_Init::ResourceInit(allocRow);
        allocRow.resNum = i;
        allocRow.poolKey        = m_pool.mediaPoolKey;
        allocRow.poolUUID       = m_pool.poolUUIDString;
        allocRow.poolName       = m_pool.mediaPoolName;
        allocRow.blockSize      = m_medium.blockSize;
        allocRow.mediumFamily   = m_pool.mediaFamily;
        allocRow.poolType       = m_pool.mediaPoolType;
    };
    resources[0].mediumKey = m_medium.mediumKey;
    resources[0].barcode = m_medium.barcode;

    SetResources(resources);

    log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                        "] resources: " << endl <<
                        ipc_Log::LogResources(GetResources()));

    ostringstream msg;
    msg << "Redundant copy job started (JobID: " << m_iJobParams.jobID << ").";
    m_ui.DisplayMessage(msg.str());

}

Here is the call graph for this function:

i_RedundantCopyJob_i::~i_RedundantCopyJob_i (  )  [virtual]

Definition at line 192 of file i_redundantcopyjob_impl.cpp.

References i_Medium_t::barcode, dbg_NORM, i_FSC_i::DeleteEntries(), cmn_File::DeleteF(), cmn_Global::dirs, ui_MsgWriter::DisplayMessage(), evt_ERROR, evt_WARNING, ivd_Directories::fri, g_cmn, i_Job_i::GetJobTypeText(), i_SUCCEDED, ipc_EXEC_m, i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_aborted, m_best_effort, m_ccVol, m_currentMedium, i_PartitionManager_i::m_iFSCi, i_Job_i::m_iJobParams, m_iPM, m_medium, m_medStatus_v, m_mv, i_Job_i::m_rm, i_Job_i::m_status, m_ui, m_unavailFilesPerVol, i_Medium_t::mediumKey, i_Job_i::ReleaseDiskBuffer(), and rmdb_MEDVOL_REORG_RECYCLED.

                                           {
    log_FUNC_m(~i_RedundantCopyJob_i);

    try {

        if (m_currentMedium < m_medStatus_v.size()){
            ReleaseDiskBuffer();
        };

        bool allSucceded(true);
        for (UInt32_t i(0); i < m_medStatus_v.size(); i++){
            if (!m_medStatus_v[i].Succeded()) {
                //some volume did not succede in read or write
                allSucceded = false;
            }
        }

        ostringstream msg;

        if (allSucceded && (m_status == i_SUCCEDED)){

            vector<UInt32_t> volList;
            //check if file could not be found
            for (UInt32_t i(0); i < m_ccVol.size(); i++){
                log_DBG_m(dbg_NORM, "m_ccVol[i]: " << m_ccVol[i]);
                if ( !m_best_effort && (m_unavailFilesPerVol.size() >= m_ccVol[i])){
                    if (m_unavailFilesPerVol[m_ccVol[i]-1] == 0) {
                        volList.push_back(m_ccVol[i]);
                    } else {
                        msg.str("");
                        msg << "Will not delete entries from FSC for volume: " << m_ccVol[i];
                        ipc_EXEC_m( m_ui.DisplayMessage(msg.str()); );
                        log_WriteEvent(msg.str(), evt_MAINTJOB, m_iJobParams.jobID, string(m_medium.barcode));
                    }
                } else {
                    volList.push_back(m_ccVol[i]);
                }
            }

            //Remove entries for that medium
            msg.str("");
            msg << "Deleting entries from FSC ...";
            ipc_EXEC_m( m_ui.DisplayMessage(msg.str()); );
            log_WriteEvent(msg.str(), evt_MAINTJOB, m_iJobParams.jobID, string(m_medium.barcode));

            //delete entries from FSC
            log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                "] " << "Deleting entries from FSC." <<
                "Medium BC: " << m_medium.barcode);

            m_iPM.m_iFSCi->DeleteEntries(m_medium.mediumKey, volList);

            log_DBG_m(dbg_NORM,
                "[" << m_iJobParams.jobID << "] " << "Deleting entries from FSC.");

            for (UInt32_t i(0); i < volList.size(); i++){
                msg.str("");
                msg << "Entries for volume " << volList[i] << " deleted from FSC.";

                ipc_EXEC_m( m_ui.DisplayMessage(msg.str()); );
                log_WriteEvent( msg.str(), evt_MAINTJOB,
                                m_iJobParams.jobID, string(m_medium.barcode));
            }

            for (UInt32_t i(0); i < m_mv.length(); i++){

                bool found(false);
                for (UInt32_t j(0); j < volList.size(); j++){
                    if (m_mv[i].medVolNr == (Int32_t)volList[j]){
                        found = true;
                        break;
                    }
                }

                if (found){
                    // set status to recycled
                    try {
                        ipc_EXEC_m (
                            m_rm->MedVolStatusSet(  m_mv[i].medVolId,
                                                    rmdb_MEDVOL_REORG_RECYCLED);
                        )
                    } catch (...) {
                        //ignore
                    }

                    cmn_Path friPath = g_cmn.dirs.fri + m_mv[i].medVolId;
                    try {
                        cmn_File friFile(friPath);
                        friFile.DeleteF();
                        log_DBG_m(dbg_NORM,
                            "[" << m_iJobParams.jobID << "] " << "FRI file deleted. " << friPath);
                    }
                    catch (...) {
                        //ignore
                        //clean up as much as possible
                    }
                }
            }
        }
        msg.str("");

        if (m_status == i_SUCCEDED) {
            log_WriteEvent("Finished.", GetJobTypeText(), m_iJobParams.jobID);
            msg << "[" << m_iJobParams.jobID <<
                    "] Finished.";
            ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        }
        else if (m_aborted) {
            log_WriteEvent(evt_WARNING, "Aborted.",
                GetJobTypeText(), m_iJobParams.jobID);
            msg << "[" << m_iJobParams.jobID <<
                "] Aborted.";
                ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        }
        else {
            log_WriteEvent(evt_ERROR, "Failed.",
                GetJobTypeText(), m_iJobParams.jobID);
            msg << "[" << m_iJobParams.jobID <<
                "] Failed.";
                ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        }
    } catch (ivd_Exception& e) {
        log_ERR_m(e);
    } catch (...) {
        log_ERR_m("Caught unknown" );
    }
}

Here is the call graph for this function:


Member Function Documentation

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

Implements i_Job_i.

Definition at line 406 of file i_redundantcopyjob_impl.cpp.

References log_ERR_m, log_FUNC_m, i_Job_i::m_status, and i_Job_i::Remove().

                                                                    {
    log_FUNC_m(CompleteJob);

    m_status = a_status;

    try {
        Remove();

    } catch (ivd_Exception& e) {
        log_ERR_m(e);
    } catch (...) {
        log_ERR_m("Caught unknown" );
    }
}

Here is the call graph for this function:

void i_RedundantCopyJob_i::Execute (  )  [protected, virtual]

Implements i_Job_i.

Definition at line 476 of file i_redundantcopyjob_impl.cpp.

References i_Job_i::AllocateDiskBuffer(), dbg_LOW, dbg_NORM, ui_MsgWriter::DisplayMessage(), pm_RecallSetReader::GetCurrentSplitSize(), ivd_BaseException::GetError(), pm_RecallSetReader::GetRemainingBytesToCopy(), i_SUCCEDED, ie_FATAL_ERROR, i_Job_i::IsAborted(), pm_VolStatus::IsRead(), i_JobParams::jobID, log_DBG_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogMediumVol(), ipc_Log::LogStatus(), m_best_effort, pm_VolStatus::m_blockSize, m_currentMedium, i_Job_i::m_iJobParams, m_iPM, i_PartitionManager_i::m_maxDiskBuff, m_medStatus_v, pm_VolStatus::m_medVol, pm_VolStatus::m_recallSetReader, i_Job_i::m_status, m_ui, i_MediumVol_t::mediumBarcode, i_MediumVol_t::medVolId, MigrateFiles(), Prepare(), and RecallFiles().

                                   {
    log_FUNC_m(Execute);

    ostringstream msgBase;
    msgBase << "[" << m_iJobParams.jobID << "] ";

    ostringstream msg;

    if (!Prepare()) {
        return;
    }

    try {
        while(true) {
            log_DBG_m(dbg_NORM, "Entering while. m_currentMedium:" <<
                                m_currentMedium);
            if (m_currentMedium >= m_medStatus_v.size()){
                if(m_best_effort){
                    log_DBG_m(dbg_NORM, "We may not have a single source medium " 
                              <<  "on best effort. "
                              <<  "Job finished.");
                    m_status = i_SUCCEDED;
                    return;
                }
                msg.str("");
                msg << "Accessing beyond vector size " << m_currentMedium;
                throw ivd_InternalError(ie_FATAL_ERROR, msg.str() );
            }
            pm_VolStatus &vol = m_medStatus_v[m_currentMedium];


            log_DBG_m(dbg_NORM, "Processing volume:" << endl <<
                                ipc_Log::LogMediumVol(vol.m_medVol) );

            msg.str("");
            msg << "Will copy content from volume: " <<
                    vol.m_medVol.medVolId;

            log_WriteEvent(msg.str(), evt_MAINTJOB,
                m_iJobParams.jobID, string(vol.m_medVol.mediumBarcode));

            m_ui.DisplayMessage(msg.str());

            // If disk buffer is small do copy content in several iterations
            while (!vol.IsRead()) {

                msg.str("");

                UInt64_t dBuffSize = AllocateDiskBuffer(
                                vol.m_recallSetReader.GetCurrentSplitSize(),
                                vol.m_recallSetReader.GetRemainingBytesToCopy(),
                                m_iPM.m_maxDiskBuff,
                                vol.m_blockSize,
                                m_iPM.m_maxDiskBuff);

                if (!RecallFiles(vol, dBuffSize)) {
                    if (IsAborted()) {
                        return;
                    }
                    continue;
                }

                if (IsAborted()) {
                    return;
                }

                MigrateFiles(vol);

                if (IsAborted()) {
                    return;
                }

            } //while ( !vol.IsRead() )

            if (m_currentMedium < m_medStatus_v.size() - 1) {
                //processing next volume
                m_currentMedium++;
            }
            else {
                //job finished
                m_status = i_SUCCEDED;
                for (UInt32_t i(0); i < m_medStatus_v.size(); i++){
                    if (m_medStatus_v[i].m_writeStatus != i_SUCCEDED){
                        log_DBG_m(dbg_LOW, "Writing of volume " <<
                            m_medStatus_v[i].m_medVol.medVolId <<
                            "failed with status:" <<
                            ipc_Log::LogStatus(m_medStatus_v[i].m_writeStatus));
                        m_status = i_FAILED;
                    }
                }
                return;
            }
        } //while(true)
    } catch (ivd_Error& e) {
        if (e.GetError() == ie_VOL_NOT_FOUND){
            log_DBG_m(dbg_LOW, "copy content read/write finished.");
            //continue
        } else
            throw;
    }
}

Here is the call graph for this function:

i_JobRequestList_t * i_RedundantCopyJob_i::GetFiles ( void   )  [protected, virtual]

Implements i_Job_i.

Definition at line 592 of file i_redundantcopyjob_impl.cpp.

References ie_IMPOSSIBLE, and log_FUNC_m.

                                                   {
    log_FUNC_m(GetFiles);

    try {
        throw ivd_InternalError(ie_IMPOSSIBLE);
    } ipc_CATCH_IVD_THROW_CORBA_m;
    return NULL;
} // i_RecallJob_i::GetFiles()

i_FSC_ptr i_RedundantCopyJob_i::GetFSC ( void   )  [protected, virtual]

Implements i_Job_i.

Definition at line 580 of file i_redundantcopyjob_impl.cpp.

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

                                       {
    log_FUNC_m(GetFSC);
    try {
        ipc_EXEC_m(
            i_FSC_ptr tmpFSC = i_FSC::_duplicate(m_iPM.GetFSC());
        return tmpFSC;
        );
    } ipc_CATCH_IVD_THROW_CORBA_m;

}

Here is the call graph for this function:

void i_RedundantCopyJob_i::GetNewResources ( i_Index_t  a_resNum  )  [virtual]
i_FileLocationDataList_t * i_RedundantCopyJob_i::GetNextRecallSet (  )  [virtual]

Reimplemented from i_Job_i.

Definition at line 401 of file i_redundantcopyjob_impl.cpp.

References log_FUNC_m, m_currentMedium, and m_medStatus_v.

                                                                {
    log_FUNC_m(GetNextRecallSet);
    return m_medStatus_v[m_currentMedium].m_recallSetReader.GetNextRecallSet();
}

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

Implements i_Job_i.

Definition at line 321 of file i_redundantcopyjob_impl.cpp.

References cmn_Condition::Broadcast(), bs_NOT_RUNNING, i_Job_i::ClearResStatus(), dbg_NORM, ui_MsgWriter::DisplayMessage(), i_Job_i::GetResources(), i_SUCCEDED, ie_FATAL_ERROR, ipc_EXEC_m, i_Job_i::IsAborted(), ivd_USleep, i_JobParams::jobID, log_DBG_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogStatus(), i_Job_i::m_activate_c, i_Job_i::m_activate_x, i_Job_i::m_beasStatus_x, m_currentMedium, i_Job_i::m_iJobParams, m_medStatus_v, m_ui, i_Job_i::ReleaseDiskBuffer(), i_Job_i::ReleaseResource(), i_Job_i::SetBeaStatus(), and i_Job_i::SetResMedOpComplete().

                                                                          {

    log_FUNC_m(MediumOperationComplete);
    try {

        log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
            "] " << "MediumOperationComplete called by Bea: " <<
            a_beaNum << "  status: [" << a_status << "]" <<
            ipc_Log::LogStatus(a_status) << endl <<
            m_iJobParams.jobID);

        if (IsAborted()){
            return;
        }

        SetResMedOpComplete(a_beaNum);
        {
            cmn_MutexLock l(m_beasStatus_x);
            SetBeaStatus(a_beaNum, bs_NOT_RUNNING);
        }

        try {
            if (a_beaNum > static_cast<i_Index_t>(GetResources().length() ) ) {
                throw ivd_InternalError(
                    ie_FATAL_ERROR, "Non existing Bea wants to Complete Job??");
            };
        } ipc_CATCH_IVD_THROW_CORBA_m;



        if (a_beaNum == 0) { // reading of source volume finished

            m_medStatus_v[m_currentMedium].ReadFinished(a_status);

            //check completion status
            ostringstream msg;
            msg << "Reading finished, releasing resources.";
            ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
            log_WriteEvent(msg.str(), evt_MAINTJOB,
                m_iJobParams.jobID, string(GetResources()[a_beaNum].barcode));

            if (a_status == i_SUCCEDED){
                {
                    cmn_MutexLock l(m_activate_x);
                    m_activate_c.Broadcast();
                }//unlock l

                log_DBG_m(dbg_NORM, "Let other thread request resource first");
                ivd_USleep(100);
                ReleaseResource(a_beaNum);
            } else {
                //bug 3859
                // release resource first
                // target will anyhow not be allocated
                ReleaseResource(a_beaNum);
                cmn_MutexLock l(m_activate_x);
                m_activate_c.Broadcast();
            }

        } else if (a_beaNum == 1){    //writing finished
            //free up resources
            m_medStatus_v[m_currentMedium].WriteFinished(a_status);

            //delete disk buffer
            ReleaseDiskBuffer();

            {
                cmn_MutexLock l(m_activate_x);
                m_activate_c.Broadcast();
            }//unlock l

            log_DBG_m(dbg_NORM, "Let other thread request resource first");
            ivd_USleep(100);
            ReleaseResource(a_beaNum);
            ClearResStatus(1);
        }
    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

void i_RedundantCopyJob_i::MigrateFiles ( pm_VolStatus vol  )  [private]

Definition at line 891 of file i_redundantcopyjob_impl.cpp.

References i_Job_i::ActivateBea(), i_Resource_t::barcode, bs_PROCESSING, bs_RUNNING, dbg_NORM, ui_MsgWriter::DisplayMessage(), i_Resource_t::driveKey, i_Job_i::GetResources(), ipc_EXEC_m, i_Job_i::IsAborted(), pm_RecallSetReader::IsWriteFinished(), i_JobParams::jobID, i_Resource_t::load, i_Job_i::LoadUnload(), log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogResources(), i_Job_i::m_activate_c, i_Job_i::m_activate_x, i_Job_i::m_activeBeas, i_Job_i::m_beasStatus_x, i_Job_i::m_iJob, i_Job_i::m_iJobParams, pm_VolStatus::m_recallSetReader, i_Job_i::m_rm, i_Job_i::m_status, m_ui, i_Resource_t::mediumFamily, i_Resource_t::medVolNr, mf_DISK, i_Job_i::NeedsProcess(), i_Resource_t::resAllocated, i_Resource_t::resAssigned, i_Resource_t::resBeaStarted, i_Resource_t::resMedOpComplete, i_Resource_t::resProcessed, i_Resource_t::resReleased, i_Resource_t::resRequested, i_Job_i::SetBeaStatus(), i_Job_i::SetResBeaStarted(), i_Job_i::SetResources(), i_Job_i::SetResProcessed(), cmn_Condition::Wait(), and i_Job_i::WaitBeasToFinish().

Referenced by Execute().

                                                         {
    log_FUNC_m(MigrateFiles);

    ostringstream msg;

    try {

        i_Resource_t res = GetResources()[1];
        res.resAllocated = false;
        res.resAssigned = false;
        res.resReleased = false;
        res.resBeaStarted = false;
        res.resProcessed = false;
        res.resMedOpComplete = false;
        res.resRequested = true;
        i_ResourceList_t tmpRes;
        tmpRes.length(1);
        tmpRes[0] = res; //0 - source resource
        SetResources(res);

        ipc_EXEC_m (
            cmn_MutexLock l(m_activate_x);
            msg.str("");
            msg << "Requesting target resources...";

            log_WriteEvent(msg.str(), evt_MAINTJOB,
                m_iJobParams.jobID);
            m_ui.DisplayMessage(msg.str());

            m_rm->GetResources( m_iJob,
                                m_iJobParams,
                                tmpRes);


            //wait for medium to be assigned
            log_DBG_m(dbg_NORM, "Waiting for target medium.");
            m_activate_c.Wait();
            log_DBG_m(dbg_NORM, "Got target medium.");
            msg.str("");
            msg << "Resources allocated.";

            log_WriteEvent(msg.str(), evt_MAINTJOB,
                m_iJobParams.jobID, string(res.barcode));
            m_ui.DisplayMessage(msg.str());
        );
    }
    catch (const ivd_Exception&) {
        log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                            "] " << "RM->GetResources failed.");
        m_status = i_RESOURCE_ERROR;
        throw;
    }
    if (IsAborted()) {
        return;
    }

    bool first(true);


    while (!vol.m_recallSetReader.IsWriteFinished()) {

    i_Resource_t res = GetResources()[1];


        log_DBG_m(dbg_NORM, "Write not completed yet.");
        if ( NeedsProcess(1)) {
            log_DBG_m(dbg_NORM, "Write needs process.");
            cmn_MutexLock l(m_activate_x);
            log_DBG_m(dbg_NORM, "m_activate_x locked.");

            if (res.mediumFamily != mf_DISK){
                string driveName;
                ipc_EXEC_m(
                    i_Drive_t_var drive;
                    drive = m_rm->SelectDriveByKey(res.driveKey);
                    driveName = drive->driveName;
                )

                if (res.load) {
                    msg.str("");
                    msg << "Loading medium " << res.barcode <<
                        " to drive " << driveName << ".";
                    ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
                    log_WriteEvent(msg.str(), evt_MAINTJOB,
                        m_iJobParams.jobID, string(res.barcode));
                    ipc_EXEC_m(LoadUnload(1));
                }
                else {
                    msg.str("");
                    msg << "Medium " << res.barcode <<
                        " is already present in drive " << driveName << ".";
                    ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
                    log_WriteEvent(msg.str(), evt_MAINTJOB,
                        m_iJobParams.jobID, string(res.barcode));
                }
            }

            ipc_EXEC_m(
                if (first){

                    msg.str("");
                    msg << "Starting Back End Agent.";
                    ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
                    log_WriteEvent(msg.str(), evt_MAINTJOB,
                        m_iJobParams.jobID, string(res.barcode));
                }

                cmn_MutexLock l(m_beasStatus_x);

                i_Job_i::ActivateBea(1);
                SetBeaStatus(1, bs_RUNNING);
                SetResBeaStarted(1);
                SetResProcessed(1);

                msg.str("");
                msg << "Medium " << res.barcode << ", volume " <<
                    res.medVolNr << ": Writing...";
                ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
                log_WriteEvent(msg.str(), evt_MAINTJOB,
                    m_iJobParams.jobID, string(res.barcode));
                if (first) {
                    m_activeBeas[1]->Migrate();
                    first = false;
                }
                SetBeaStatus(1, bs_PROCESSING);
            );

            WaitBeasToFinish(5);

            msg.str("");
            msg << "Medium " << res.barcode << ", volume "
                << res.medVolNr << ": Data written to media volume.";

            ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
            log_WriteEvent(msg.str(), evt_MAINTJOB,
                m_iJobParams.jobID, string(res.barcode));

        } else {
            log_ERR_m("Redundant copy Job should need processing" <<
                ipc_Log::LogResources(res));
            return;
        }
        //wait for writer to finish
        log_DBG_m(dbg_NORM, "Writing BEA finished.");

        if (IsAborted()) {
            return;
        }
    } //while (!vol.IsWrite())
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool i_RedundantCopyJob_i::Prepare (  )  [private]

Definition at line 602 of file i_redundantcopyjob_impl.cpp.

References i_Medium_t::barcode, i_Medium_t::blockSize, fsc_RedunCopyResult_t::buffSize, dbg_DETAIL, dbg_IsActive(), dbg_NORM, ui_MsgWriter::DisplayMessage(), evt_ERROR, ie_FATAL_ERROR, ipc_EXEC_m, job_MED_PROC, i_JobParams::jobID, log_DBG_m, log_FUNC_m, log_WriteEvent(), m_best_effort, m_ccVol, i_PartitionManager_i::m_config, cfg_PM::m_globalTree, i_PartitionManager_i::m_iFSCi, i_Job_i::m_iJobParams, m_iPM, m_medium, m_medStatus_v, i_Job_i::m_rm, i_Job_i::m_status, m_ui, m_unavailFilesPerVol, i_MediaPool_t::mediaPoolKey, i_Medium_t::mediaPoolName, i_MediaPool_t::mediaPoolName, fsc_RedunCopyResult_t::mediumKey, i_Medium_t::mediumKey, i_Medium_t::mediumType, fsc_RedunCopyResult_t::medVolNum, mt_DISK, cfg_Tree::pools, i_FSC_i::RedundantCopy(), i_Job_i::SetStatus(), and i_Medium_t::status.

Referenced by Execute().

                                    {
    log_FUNC_m(Prepare);

    ostringstream msgBase;
    msgBase << "[" << m_iJobParams.jobID << "] ";
    ostringstream msg;
    //invoke scan (scan will fill up vector<fsc_MediumStatus_t>

    msg << "Preparing list of source media. ";
    ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
    log_WriteEvent(msg.str(), evt_MAINTJOB,
        m_iJobParams.jobID, string(m_medium.barcode));

    log_DBG_m(dbg_NORM, "" << msgBase << msg.str());

    i_MediumSeq_t_var medSeq;
    ipc_EXEC_m(
        medSeq = m_rm->SelectAllMedia();
    );
    vector<i_MediaPool_t> &pools = m_iPM.m_config.m_globalTree.pools;

    fsc_MediumStatus_v ms;

    UInt32_t maxMedKey(0);
    if (medSeq->length() == 0){
        ostringstream sstr;
        sstr << "No media found at all ???. ";
        throw ivd_InternalError(ie_FATAL_ERROR, sstr.str());
    } else {
        maxMedKey = medSeq[0].mediumKey;
    }

    for (UInt32_t i(1); i < medSeq->length(); ++i){
        if (medSeq[i].mediumKey > maxMedKey){
            maxMedKey = medSeq[i].mediumKey;
        }
    }

    //index is mediumKey
    // index 0 is redundant

    ms.resize(maxMedKey + 1);
    log_DBG_m(dbg_NORM, "" << msgBase << "ms resized to " << ms.size());

    log_DBG_m(dbg_DETAIL, "Num of pools " << pools.size());
    if (dbg_IsActive()) {
        for(UInt32_t j(0); j < pools.size(); ++j){
            i_MediaPool_t &pool = pools[j];
            log_DBG_m(dbg_DETAIL, j
                        << ". pool key " << pool.mediaPoolKey
                        << " mediaPoolName " << pool.mediaPoolName );
        }
    }

    for (UInt32_t i(0); i < medSeq->length(); ++i){

        i_Medium_t& med = medSeq[i];
        //get pool key
        UInt32_t poolKey(0);
        for(UInt32_t j(0); j < pools.size(); ++j) {
            i_MediaPool_t &pool = pools[j];
            if (string(pool.mediaPoolName).compare(med.mediaPoolName) == 0){
                poolKey = pool.mediaPoolKey;
            }
        }
        log_DBG_m(dbg_DETAIL, " medKey " << setw(4) << med.mediumKey
                            << ". poolKey " << poolKey
                            << ", med.status " << med.status
                            << ", med.mediumType " << med.mediumType
                            << ", med.mediaPoolName " << med.mediaPoolName );

        if (med.mediumKey == 0) {
            ostringstream sstr;
            sstr << "mediumKey is zero. " << med.mediumKey;
            throw ivd_InternalError(ie_FATAL_ERROR, sstr.str());
        }
        if (med.mediumKey >= ms.size()) {
            ostringstream sstr;
            sstr << "mediumKey is bigger than vector size. "
                 << med.mediumKey << " > " << ms.size();
            throw ivd_InternalError(ie_FATAL_ERROR, sstr.str());
        }
        log_DBG_m(dbg_DETAIL, "inserting  mediaKey:" << med.mediumKey);
        ms[med.mediumKey] = fsc_MediumStatus_t( poolKey,
                                                med.status,
                                                med.mediumType == mt_DISK ? 2:1);
        // Higher number better medium
    }

    fsc_RedunCopyResult_v result;
    try {
        m_iPM.m_iFSCi->RedundantCopy(result, m_unavailFilesPerVol, ms, m_medium.mediumKey, m_ccVol, m_best_effort);
    }
    catch (const ivd_Error& e){
        msg.str("");
        msg << "Redundant copy scan failed. " << e ;
        ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        log_WriteEvent(evt_ERROR, msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(m_medium.barcode));
        throw;
    }

    //fill up medium Status vector
    for (UInt32_t i(0); i < result.size(); i++) {
        fsc_RedunCopyResult_t res = result[i];
        log_DBG_m(dbg_DETAIL, "res [mediumKey, medVolNum, buffSize]: " <<
                               res.mediumKey << ", " <<
                               res.medVolNum << ", " <<
                               res.buffSize << "]");

        //Insert new mediumVol into MediumStatus
        i_MediumVol_t_var mv = m_rm->SelectMediumVolByKey( result[i].mediumKey,
                                                           result[i].medVolNum);

        m_medStatus_v.push_back(    pm_VolStatus(   mv,
                                                    result[i].mediumKey,
                                                    m_medium.blockSize,
                                                    res.buffSize,
                                                    m_medium.mediumKey) );
    }
    if (m_medStatus_v.size() == 0){
        msg.str("");
        msg << "No media found for redundant copy.";
        ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(m_medium.barcode));
        if(m_best_effort) {
            return true; // continue on best effort;
        }
        else {
            m_status = i_FAILED;
            return false;
       }
    }

    UInt32_t prevMed(0);
    vector<string> medBarcodes;

    for (UInt32_t i(0); i < m_medStatus_v.size(); i++){
        if (m_medStatus_v[i].m_mediaKey != prevMed){
            prevMed = m_medStatus_v[i].m_mediaKey;
            medBarcodes.push_back(string(m_medStatus_v[i].m_medVol.mediumBarcode));
        }
    }
    msg.str("");
    msg << medBarcodes.size() << " media needed for recall (bc: ";
    for (UInt32_t i(0); i < medBarcodes.size(); i++){
        msg << medBarcodes[i];
        if (i == (medBarcodes.size() - 1) ){
            msg << ")";
        }
        else {
            msg << ", ";
        }
    }

    ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
    log_WriteEvent(msg.str(), evt_MAINTJOB,
        m_iJobParams.jobID, string(m_medium.barcode));

    SetStatus(job_MED_PROC);
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_RedundantCopyJob_i::ReadSourceData (  )  [protected]
bool i_RedundantCopyJob_i::RecallFiles ( pm_VolStatus vol,
UInt64_t  a_dBuffSize 
) [private]

Definition at line 767 of file i_redundantcopyjob_impl.cpp.

References i_Resource_t::barcode, dbg_NORM, ui_MsgWriter::DisplayMessage(), i_Job_i::GetResources(), i_SUCCEDED, ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, log_DBG_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_activate_c, i_Job_i::m_activate_x, m_currentMedium, i_Job_i::m_iJob, i_Job_i::m_iJobParams, pm_VolStatus::m_mediaKey, pm_VolStatus::m_medVol, m_pool, pm_VolStatus::m_readStatus, pm_VolStatus::m_recallSetReader, i_Job_i::m_rm, i_Job_i::m_status, m_ui, i_MediumVol_t::mediumBarcode, i_Resource_t::mediumKey, i_MediumVol_t::medVolId, i_Resource_t::medVolId, i_MediumVol_t::medVolNr, i_Resource_t::medVolNr, i_Resource_t::poolUUID, i_MediaPool_t::poolUUIDString, ReadSourceData(), i_Resource_t::resAllocated, i_Resource_t::resAssigned, i_Resource_t::resBeaStarted, i_Resource_t::resMedOpComplete, ipc_Init::ResourceInit(), i_Resource_t::resProcessed, i_Resource_t::resReleased, i_Resource_t::resRequested, pm_RecallSetReader::SetCurrentBuffSize(), i_Job_i::SetResources(), i_Job_i::SetResRequested(), cmn_Condition::Wait(), and i_Job_i::WaitBeasToFinish().

Referenced by Execute().

                                                                              {
    log_FUNC_m(RecallFiles);

    ostringstream msg;

    ostringstream msgBase;
    msgBase << "[" << m_iJobParams.jobID << "] ";

    //allocate source medium for reading
    i_Resource_t tmpRes;
    tmpRes = GetResources()[0]; //0 - source resource
    try {
        if (m_currentMedium > 0) {
            ipc_Init::ResourceInit(tmpRes);
        }
        ipc_EXEC_m(
            tmpRes.mediumKey    = vol.m_mediaKey;
            tmpRes.medVolNr     = vol.m_medVol.medVolNr;
            tmpRes.medVolId     = vol.m_medVol.medVolId;
            tmpRes.poolUUID     = m_pool.poolUUIDString;
            tmpRes.resRequested = false;
            tmpRes.resAllocated = false;
            tmpRes.resAssigned  = false;
            tmpRes.resReleased  = false;
            tmpRes.resBeaStarted = false;
            tmpRes.resProcessed = false;
            tmpRes.resMedOpComplete = false;
            SetResources(tmpRes);

            cmn_MutexLock l(m_activate_x);

            msg.str("");
            msg << "Requesting source resources...";

            log_WriteEvent(msg.str(), evt_MAINTJOB,
                m_iJobParams.jobID, string(vol.m_medVol.mediumBarcode));
            m_ui.DisplayMessage(msg.str());

            m_rm->GetRecallResources(   m_iJob,
                                        m_iJobParams,
                                        tmpRes);
            SetResRequested(0);
            //wait for medium to be assigned
            log_DBG_m(dbg_NORM, "Waiting for source medium.");

            m_activate_c.Wait();
            msg.str("");
            msg << "Resources allocated.";
            tmpRes = GetResources()[0];

            log_WriteEvent(msg.str(), evt_MAINTJOB,
                m_iJobParams.jobID, string(tmpRes.barcode));
            m_ui.DisplayMessage(msg.str());
        );
    }
    catch (const ivd_Exception&) {
        log_DBG_m(dbg_NORM, "" << msgBase.str() <<
                            "RM->GetResources failed.");
        m_status = i_RESOURCE_ERROR;
        throw;
    }

    if (IsAborted()) {
        return false;
    }

    i_MediumVol_t mv = vol.m_medVol;

    msg.str("");
    msg << "Medium " << tmpRes.barcode << ", volume " <<
        tmpRes.medVolNr << " Reading valid files ...";

    log_WriteEvent(msg.str(), evt_MAINTJOB,
        m_iJobParams.jobID, string(tmpRes.barcode));
    m_ui.DisplayMessage(msg.str());

    /* a_dBuffSize is not visible outside this function
    so vol.m_recallSetReader.GetNextRecallSet(dBuffSize)
    cannot be called. Instead, first do:
    vol.m_recallSetReader.SetCurrentBuffSize(dBuffSize);
    and then call
    vol.m_recallSetReader.GetNextRecallSet(),
    it has same effect */
    vol.m_recallSetReader.SetCurrentBuffSize(a_dBuffSize);

    {
        cmn_MutexLock l(m_activate_x);
        ReadSourceData();

        if (IsAborted()) {
            return false;
        }

        WaitBeasToFinish(5);
    }

    if (IsAborted()) {
        return false;
    }

    if (vol.m_readStatus == i_SUCCEDED) {
        msg.str("");
        msg << "Medium " << tmpRes.barcode << ", volume " <<
            tmpRes.medVolNr << " Files written to disk buffer.";

        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(tmpRes.barcode));
        m_ui.DisplayMessage(msg.str());
        return true;
    }
    else {
        msg.str("");
        msg << "Medium " << tmpRes.barcode << ", volume " <<
            tmpRes.medVolNr <<
            " Error. Reading from medium or writing to diskbuffer failed.";

        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(tmpRes.barcode));
        m_ui.DisplayMessage(msg.str());
        return false;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_RedundantCopyJob_i::SetResourceBusyStatus ( i_Index_t  a_resNum,
i_ResourceBusy_e  a_resStatus 
) [private]

Reimplemented from i_Job_i.

Definition at line 1042 of file i_redundantcopyjob_impl.cpp.

References i_Resource_t::barcode, evt_INFO, i_Job_i::GetResources(), i_MEDIUM_BUSY, i_MEDIUM_NOT_AVAILABLE, log_FUNC_m, log_WriteEvent(), i_Resource_t::poolName, ipc_Log::ResourceBusy(), i_Resource_t::resourceBusyStatus, and i_Job_i::SetResources().

                                                                              {
    log_FUNC_m(SetResourceBusyStatus);

    try {
        i_Resource_t tmpRes;
        tmpRes = GetResources()[a_resNum];
        tmpRes.resourceBusyStatus = a_resStatus;
        SetResources(tmpRes);

        ostringstream msg;
        if (a_resNum == 0) {
            msg << "Source resources not ready: ";
        } else {
            msg << "Target resources not ready: ";
        }

        msg << ipc_Log::ResourceBusy(a_resStatus);

        if (a_resStatus == i_MEDIUM_BUSY ||
            a_resStatus == i_MEDIUM_NOT_AVAILABLE){

            msg << " <";

            if (a_resStatus == i_MEDIUM_BUSY ||
            a_resStatus == i_MEDIUM_NOT_AVAILABLE){

                msg << " <";

                if (a_resNum == 0) {
                    //waiting for medium <bc: 000123>
                    msg << "bc: " <<
                    tmpRes.barcode << ">";
                } else {
                    //waiting for medium <pool: pool1>
                    msg << "pool: " <<
                    tmpRes.poolName << ">";
                }
            }
        }
        log_WriteEvent(evt_INFO, msg.str());
        // Workaround for bug 8652 GUI deadlock
        // m_ui.DisplayMessage(msg.str());
    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from i_Job_i.

Definition at line 51 of file i_redundantcopyjob_impl.h.

string i_RedundantCopyJob_i::m_barcode [protected]

Definition at line 68 of file i_redundantcopyjob_impl.h.

Referenced by i_RedundantCopyJob_i().

Definition at line 72 of file i_redundantcopyjob_impl.h.

Referenced by Execute(), Prepare(), and ~i_RedundantCopyJob_i().

Definition at line 75 of file i_redundantcopyjob_impl.h.

Referenced by i_RedundantCopyJob_i().

Definition at line 76 of file i_redundantcopyjob_impl.h.

Referenced by i_RedundantCopyJob_i(), Prepare(), and ~i_RedundantCopyJob_i().

Definition at line 69 of file i_redundantcopyjob_impl.h.

Referenced by i_RedundantCopyJob_i(), Prepare(), and ~i_RedundantCopyJob_i().

Definition at line 70 of file i_redundantcopyjob_impl.h.

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

Definition at line 71 of file i_redundantcopyjob_impl.h.

Referenced by i_RedundantCopyJob_i(), and RecallFiles().

Definition at line 78 of file i_redundantcopyjob_impl.h.

Referenced by Prepare(), and ~i_RedundantCopyJob_i().


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