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

i_ReorgJob_i Class Reference
[Partition Manager]

#include <i_reorgjob_impl.h>

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

List of all members.

Public Member Functions

 i_ReorgJob_i (pm_JobMgr &a_jobMgr, i_PartitionManager_i &a_iPM, string a_barcode, vector< UInt32_t > a_volumes, ivd_MigrationID_t a_migID, i_UIMessageServer_ptr a_uims)
virtual ~i_ReorgJob_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 ReadSourceVolume ()
void Execute ()
void Wait ()
void InitializeSingleVolume (i_MediumVol_t &a_medVol)
void InitializeVolumes ()
void UpdateMediumStatus ()
void DiskBufferCleanup ()
i_FSC_ptr GetFSC ()
i_JobRequestList_tGetFiles ()
void ReorgStatusCleanup (vector< UInt32_t > a_volumes)

Protected Attributes

i_PartitionManager_im_iPM
string m_barcode
i_Medium_t m_medium
i_MediaPool_t m_pool
pm_ReorgVolStatus m_volStatus
ui_MsgWriter m_ui

Private Member Functions

bool RecallFiles (UInt64_t a_dBuffSize)
void MigrateFiles ()
void SetResourceBusyStatus (i_Index_t a_resNum, i_ResourceBusy_e a_resStatus)

Detailed Description

Definition at line 39 of file i_reorgjob_impl.h.


Constructor & Destructor Documentation

i_ReorgJob_i::i_ReorgJob_i ( pm_JobMgr a_jobMgr,
i_PartitionManager_i a_iPM,
string  a_barcode,
vector< UInt32_t a_volumes,
ivd_MigrationID_t  a_migID,
i_UIMessageServer_ptr  a_uims 
)

Definition at line 57 of file i_reorgjob_impl.cpp.

References i_Medium_t::barcode, i_MediaPool_t::blockSize, i_Medium_t::blockSize, i_Resource_t::blockSize, i_JobParams::bufId, fsc_DataCollectorStorage::CheckHeader(), rm_String::cvalue_p, dbg_NORM, ui_MsgWriter::DisplayMessage(), evt_ERROR, ivd_BaseException::GetError(), i_Job_i::GetJobTypeText(), i_Job_i::GetResources(), ie_ALREADY_IN_REORG, ie_PRECONDITION, pm_ReorgVolStatus::Init(), i_Job_i::InitBeaStatus(), pm_ReorgVolStatus::Insert(), ipc_EXEC_m, ivd_Error, i_JobParams::jobID, i_JobParams::jobPriority, i_JobParams::jobType, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogMediumVol(), ipc_Log::LogResources(), i_Job_i::m_activeBeas, m_barcode, i_PartitionManager_i::m_config, i_Job_i::m_iJobParams, m_iPM, m_medium, m_pool, i_Job_i::m_rm, i_PartitionManager_i::m_rmPart, m_ui, m_volStatus, 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, i_JobParams::migID, cfg_PMCfg::migrationPriority, cfg_PMCfg::name, pm_ReorgVolStatus::NumOfVol(), 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, ReorgStatusCleanup(), i_Resource_t::resNum, ipc_Init::ResourceInit(), rmdb_MEDIUM_OFFLINE, rmdb_MEDIUM_UNUSABLE, rmdb_MEDVOL_REORG_INREORG, rmdb_MEDVOL_REORG_SCANNED, i_Job_i::SetResources(), i_PartitionManager_i::StartReorgJob(), i_Medium_t::status, and i_PartitionManager_i::StopReorgJob().

    : i_Job_i(a_jobMgr, true),
      m_iPM(a_iPM),
      m_barcode(a_barcode),
      m_volStatus(a_iPM.m_config.name),
      m_ui(a_uims)
{
    log_FUNC_m(i_ReorgJob_i);

    m_iPM.StartReorgJob();

    try {
        // Mig ID is used by FSC as identifier for incoming split info
        // records sent by BEA.
        m_iJobParams.migID = a_migID;
        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_REORG;
        m_iJobParams.bufId    = m_iJobParams.jobID;

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

        log_WriteEvent("Started.", GetJobTypeText(), m_iJobParams.jobID);

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

        i_ULongList_t volList;
        volList.length(a_volumes.size());
        for (UInt32_t i(0); i < a_volumes.size(); i++){
            volList[i] = a_volumes[i];
        }


        try {

            //set status for all volumes to INREORG
            ipc_EXEC_m (
                m_rm->VolumeListStatusSet(   m_medium.mediumKey,
                                             volList,
                                             rmdb_MEDVOL_REORG_INREORG);
            )
        } catch (ivd_Error &e) {
            log_DBG_m(dbg_NORM, e);
            if (e.GetError() == ie_PRECONDITION){
                throw ivd_Error(ie_ALREADY_IN_REORG);
            } else {
                throw e;
            }
        }

        //check if medium is unusable
        if (m_medium.status & rmdb_MEDIUM_UNUSABLE) {
            throw ivd_Error(ie_PRECONDITION, "Medium is unusable.");
        }

        //check if medium is offline
        if (m_medium.status & rmdb_MEDIUM_OFFLINE) {
            throw ivd_Error(ie_PRECONDITION, "Medium is offline.");
        }

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

        //set resources
        i_ResourceList_t resources;
        ipc_EXEC_m(
            resources.length(2);
            //2 because for reorg one source and one target medium is needed
        );
        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()));

        m_volStatus.Init(m_medium.mediumKey, m_pool.blockSize);

        //select media volumes
        i_MediumVolSeq_t_var volumes;
        ipc_EXEC_m(
            volumes = m_rm->SelectAllMediumVolByBarcode(m_barcode.c_str());
        );

        if (volumes->length() == 0){
            throw ivd_Error(ie_PRECONDITION, "Media does not contain initialized volumes.");
        } else {
            log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                                "] " << volumes->length() << " found in rmdb.");
        }

        if (a_volumes.empty()){
            //all volumes will get reorganized
            log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                            "] " << "a_volumes.empty(). " <<
                            "All volumes should be reorganized" );
            for (UInt32_t j(0); j < volumes->length(); j++){
                if (volumes[j].status & rmdb_MEDVOL_REORG_SCANNED){
                    log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                                    "] inserting volume: " << endl <<
                                    ipc_Log::LogMediumVol(volumes[j]));
                    try {
                        m_volStatus.Insert(volumes[j]);
                    } catch (ivd_Error &e) {
                        log_ERR_m("An error occurred while inserting volume '"
                            << volumes[j].medVolId << "' for reorg: " << endl << e);
                        throw e;
                    } catch (ivd_SysError &se) {
                        log_ERR_m("A system error occurred while inserting volume '"
                            << volumes[j].medVolId << "' for reorg: " << endl << se);
                        throw se;
                    } catch (...) {
                        log_ERR_m("An unknown error occurred while inserting volume '"
                            << volumes[j].medVolId << "' for reorg.");
                        throw;
                    }
                    try {
                        fsc_ReorgScanReorgVolStorage volReorg( 0,
                                            m_iPM.m_config.name,
                                            m_medium.mediumKey,
                                            volumes[j].medVolNr,
                                            false);
                        volReorg.CheckHeader();
                        fsc_ReorgScanContentVolStorage volCont( 0,
                                            m_iPM.m_config.name,
                                            m_medium.mediumKey,
                                            volumes[j].medVolNr,
                                            false);
                        volCont.CheckHeader();
                    } catch (ivd_Error &e) {

                        msg.str("");
                        msg << "Error while checking .idx files for volume " <<
                                volumes[j].medVolId;
                        log_WriteEvent(evt_ERROR, msg.str(), evt_MAINTJOB,
                                m_iJobParams.jobID, string(m_medium.barcode));
                        ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););

                        log_ERR_m(e);
                        throw e;
                    }
                } else {
                    //clear in reorg flag
                    ipc_EXEC_m (
                        m_rm->MedVolStatusClear(
                                        volumes[j].medVolId,
                                        rmdb_MEDVOL_REORG_INREORG);
                    )

                };
            }
        } else {
            //select only needed volumes
            for (UInt32_t i(0); i < a_volumes.size(); i++){
                bool found = false;
                for (UInt32_t j(0); j < volumes->length(); j++){
                    if (static_cast<Int32_t>(a_volumes[i]) == volumes[j].medVolNr){
                        if (volumes[j].status & rmdb_MEDVOL_REORG_SCANNED){
                            log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                                                "] inserting volume: " << endl <<
                                                ipc_Log::LogMediumVol(volumes[j]));

                            m_volStatus.Insert(volumes[j]);
                            found = true;
                        } else {
                            log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                                "] will NOT insert volume. NOT SCANNED: " << endl <<
                                ipc_Log::LogMediumVol(volumes[j]));
                            //clear in reorg flag
                            ipc_EXEC_m (
                                m_rm->MedVolStatusClear(
                                                    volumes[j].medVolId,
                                                    rmdb_MEDVOL_REORG_INREORG);
                            )
                        }
                    }
                }
                if (!found){
                    throw ivd_Error (ie_PRECONDITION, "No volumes found for reorganization.");
                }
            }
        }

        if (m_volStatus.NumOfVol() == 0){
            throw ivd_Error (ie_PRECONDITION, "No volumes to reorganize");
        };
    } catch (ivd_Error &e) {
        log_DBG_m(dbg_NORM, e);
        m_iPM.StopReorgJob();
        if (e.GetError() != ie_ALREADY_IN_REORG){
            log_DBG_m(dbg_NORM, "Cleaning in_reorg status...");
            ReorgStatusCleanup(a_volumes);
        }
        throw e;
    } catch (...){
        m_iPM.StopReorgJob();
        ReorgStatusCleanup(a_volumes);
        throw;
    }
}

Here is the call graph for this function:

i_ReorgJob_i::~i_ReorgJob_i (  )  [virtual]

Definition at line 295 of file i_reorgjob_impl.cpp.

References dbg_LOW, pm_ReorgVolStatus::GetAllReorgVol(), ipc_EXEC_m, i_Job_i::IsAborted(), pm_ReorgVolStatus::IsWriteStarted(), log_DBG_m, log_ERR_m, log_FUNC_m, m_iPM, i_Job_i::m_rm, m_volStatus, rmdb_MEDVOL_REORG_INREORG, rmdb_MEDVOL_REORG_SCANNED, and i_PartitionManager_i::StopReorgJob().

                            {
    log_FUNC_m(~i_ReorgJob_i);

    try {
        vector <i_MediumVol_t> volumes;
        m_volStatus.GetAllReorgVol(volumes);
        for (UInt32_t i(0); i < volumes.size(); i++) {
            // clear status for all reorganized volumes
            if (volumes[i].status & rmdb_MEDVOL_REORG_INREORG) {
                log_DBG_m(dbg_LOW, "Clearing status for volume: " << volumes[i].medVolNr);
                try {
                    ipc_EXEC_m (
                        m_rm->MedVolStatusClear(volumes[i].medVolId, rmdb_MEDVOL_REORG_INREORG);
                    )
                    //clear status if write started but was aborted
                    if (IsAborted() && m_volStatus.IsWriteStarted(volumes[i].medVolNr)) {
                        ipc_EXEC_m (
                            m_rm->MedVolStatusClear(volumes[i].medVolId, rmdb_MEDVOL_REORG_SCANNED);
                        );
                    }
                }
                catch (ivd_Error &e){
                    log_ERR_m("Reorg Job DTOR" << e);
                    //ignore
                }
            }
        }// for (UInt32_t i(0); i < mvSeq->length(); i++)
    }
    catch (...) {
        m_iPM.StopReorgJob();
        throw;
    }
    m_iPM.StopReorgJob();
}

Here is the call graph for this function:


Member Function Documentation

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

Implements i_Job_i.

Definition at line 433 of file i_reorgjob_impl.cpp.

References ui_MsgWriter::DisplayMessage(), evt_ERROR, evt_WARNING, i_Job_i::GetJobTypeText(), i_SUCCEDED, i_JobParams::jobID, log_ERR_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_aborted, i_Job_i::m_iJobParams, i_Job_i::m_status, m_ui, and i_Job_i::Remove().

Referenced by RecallFiles().

                                                             {
    log_FUNC_m(CompleteJob);

    m_status = a_status;

    try {

        ostringstream msg;

        if (a_status == i_SUCCEDED) {
            msg << "Finished.";
            m_ui.DisplayMessage(msg.str());
            log_WriteEvent(msg.str(), GetJobTypeText(), m_iJobParams.jobID);
        }
        else if (m_aborted) {
            msg << "Aborted.";
            m_ui.DisplayMessage(msg.str());
            log_WriteEvent(evt_WARNING, msg.str(),
                            GetJobTypeText(), m_iJobParams.jobID);
        }
        else {
            msg << "Failed.";
            m_ui.DisplayMessage(msg.str());
            log_WriteEvent(evt_ERROR, msg.str(),
                GetJobTypeText(), m_iJobParams.jobID);
        }

        Remove();

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

Here is the call graph for this function:

Here is the caller graph for this function:

void i_ReorgJob_i::DiskBufferCleanup (  )  [protected]

Definition at line 1106 of file i_reorgjob_impl.cpp.

References cfg_MEGABYTE, dbg_LOW, i_JobParams::jobID, log_DBG_m, log_FUNC_m, i_Job_i::m_iJobParams, m_volStatus, i_Job_i::ReleaseDiskBuffer(), and pm_ReorgVolStatus::ValidDataSize().

Referenced by Execute(), MigrateFiles(), and RecallFiles().

                                    {
    log_FUNC_m(DiskBufferCleanup);
    ostringstream msgBase;
    msgBase << "[" << m_iJobParams.jobID << "] ";
    UInt64_t validDataMB( UInt64_t(m_volStatus.ValidDataSize()) * cfg_MEGABYTE);
    log_DBG_m(dbg_LOW, msgBase.str() << " Releasing diskbuffer:" << validDataMB);
    ReleaseDiskBuffer();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements i_Job_i.

Definition at line 564 of file i_reorgjob_impl.cpp.

References i_Job_i::AllocateDiskBuffer(), i_Medium_t::barcode, pm_ReorgVolStatus::Begin(), dbg_LOW, dbg_NORM, DiskBufferCleanup(), ui_MsgWriter::DisplayMessage(), evt_ERROR, pm_ReorgVolStatus::GetCurrentMedVol(), pm_RecallSetReader::GetCurrentSplitSize(), pm_ReorgVolStatus::GetCurrentVol(), ivd_BaseException::GetError(), pm_RecallSetReader::GetRemainingBytesToCopy(), pm_ReorgVolStatus::GetWriteStatus(), i_SUCCEDED, InitializeVolumes(), ipc_EXEC_m, i_Job_i::IsAborted(), pm_VolStatus::IsRead(), job_MED_PROC, i_JobParams::jobID, log_DBG_m, log_FUNC_m, log_WriteEvent(), pm_VolStatus::m_blockSize, i_Job_i::m_iJobParams, m_iPM, i_PartitionManager_i::m_maxDiskBuff, m_medium, pm_VolStatus::m_recallSetReader, i_Job_i::m_status, m_ui, m_volStatus, i_MediumVol_t::medVolNr, MigrateFiles(), pm_ReorgVolStatus::Next(), RecallFiles(), rmdb_MEDVOL_REORG_RECYCLED, pm_ReorgVolStatus::SetReadFinished(), i_Job_i::SetStatus(), pm_ReorgVolStatus::SetWriteFinished(), i_MediumVol_t::status, UpdateMediumStatus(), and pm_ReorgVolStatus::ValidDataSize().

                          {
    log_FUNC_m(Execute);

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

    try {
        SetStatus(job_MED_PROC);
        while(true) {
            if (m_volStatus.ValidDataSize() > 0) {

                i_MediumVol_t mv = m_volStatus.GetCurrentVol();

                if (mv.status & rmdb_MEDVOL_REORG_RECYCLED){
                    // no nead to read, neither write
                    m_volStatus.SetReadFinished(i_SUCCEDED);
                    m_volStatus.SetWriteFinished(i_SUCCEDED);
                    msg.str("");
                    msg << "Volume already recycled. Reading skipped.";

                    log_WriteEvent(msg.str(), evt_MAINTJOB,
                        m_iJobParams.jobID, string(m_medium.barcode));
                    try {
                        m_volStatus.Next();
                        continue;
                    } catch (ivd_Error &e){
                        log_DBG_m(dbg_NORM, e);
                        //no more volumes to reorganize
                        throw;
                    }
                }
                msg.str("");
                msg << "Reorganizing volume: " <<
                        m_volStatus.GetCurrentVol().medVolNr;

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

                m_ui.DisplayMessage(msg.str());

                pm_VolStatus &vol = m_volStatus.GetCurrentMedVol();
                while (!vol.IsRead()) {
                    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(dBuffSize)) {
                        if (IsAborted()) {
                            DiskBufferCleanup();
                            return;
                        }
                        continue;
                    }

                    if (IsAborted()) {
                        DiskBufferCleanup();
                        return;
                    }

                    MigrateFiles();
                    if (IsAborted()) {
                        DiskBufferCleanup();
                        return;
                    }
                }
            }
            else {
                msg.str("");
                msg << "Volume: " << m_volStatus.GetCurrentVol().medVolNr <<
                    " does not contain valid data.";
                m_volStatus.SetReadFinished(i_SUCCEDED);
                m_volStatus.SetWriteFinished(i_SUCCEDED);

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

                m_ui.DisplayMessage(msg.str());
                msg.str("");
            };

            m_volStatus.Next();

        }; //while(m_volStatus.Finished())

    } catch (ivd_Error& e){
        if (e.GetError() == ie_VOL_NOT_FOUND){
            log_DBG_m(dbg_LOW, "reorg read/write finished.");
            //continue
        } else {
            msg.str("");
            msg << e;

            log_WriteEvent(evt_ERROR, msg.str(), evt_MAINTJOB,
                m_iJobParams.jobID, string(m_medium.barcode));

            m_ui.DisplayMessage(msg.str());
            msg.str("");
            DiskBufferCleanup();
            throw;
        }
    }

    bool anyReorged(false);
    m_volStatus.Begin();
    try {
        while(1){
            if (m_volStatus.GetWriteStatus() == i_SUCCEDED){
                anyReorged = true;
            };
            m_volStatus.Next();
        }
    } catch (ivd_Error){
        //ignore
    }


    if (anyReorged){
        //Initialize reorganized volumes
        log_DBG_m(dbg_NORM, "Will initialize media now.");
        msg.str("");
        msg << "Initializing reorganized volumes.";
        ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(m_medium.barcode));

        InitializeVolumes();
        //Update medium status
        UpdateMediumStatus();
        m_status = i_SUCCEDED;
    } else {
        msg.str("");
        msg << "No volume was reorganized.";
        ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(m_medium.barcode));
        m_status = i_FAILED;
    };
}

Here is the call graph for this function:

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

Implements i_Job_i.

Definition at line 1131 of file i_reorgjob_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_ReorgJob_i::GetFSC ( void   )  [protected, virtual]

Implements i_Job_i.

Definition at line 1117 of file i_reorgjob_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_ReorgJob_i::GetNewResources ( i_Index_t  a_resNum  )  [virtual]
i_FileLocationDataList_t * i_ReorgJob_i::GetNextRecallSet (  )  [virtual]
void i_ReorgJob_i::InitializeSingleVolume ( i_MediumVol_t a_medVol  )  [protected]

Definition at line 710 of file i_reorgjob_impl.cpp.

References i_VolInfo_t::accessNum, i_Job_i::ActivateBea(), i_VolInfo_t::appendNum, i_Medium_t::barcode, i_MediaPool_t::blockSize, i_VolInfo_t::blockSize, bs_RUNNING, dbg_LOW, dbg_NORM, ui_MsgWriter::DisplayMessage(), i_Job_i::GetResources(), i_Medium_t::idxOfSysVol, i_VolInfo_t::implID, ipc_EXEC_m, ipc_nilStr, i_JobParams::jobID, log_DBG_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogVolInfo(), i_Job_i::m_activeBeas, i_Job_i::m_beasStatus_x, i_Job_i::m_iJobParams, m_medium, m_pool, i_Job_i::m_rm, m_ui, i_VolInfo_t::medVolID, i_MediumVol_t::medVolId, i_Resource_t::medVolId, i_MediumVol_t::medVolNr, i_Resource_t::medVolNr, i_Resource_t::medVolType, i_MediumVol_t::owriteNr, i_VolInfo_t::owriteNum, i_MediumVol_t::owriteTime, i_VolInfo_t::partID, i_JobParams::partUUID, i_VolInfo_t::poolID, i_MediaPool_t::poolUUIDString, i_Job_i::SetBeaStatus(), i_Job_i::SetResBeaStarted(), i_Job_i::SetResMedOpComplete(), i_Job_i::SetResources(), i_Job_i::SetResProcessed(), i_VolInfo_t::size, i_MediumVol_t::status, i_VolInfo_t::sysVolNum, i_MediumVol_t::totalData, i_VolInfo_t::type, i_MediumVol_t::validData, i_VolInfo_t::volNum, i_MediumVol_t::volSize, i_MediumVol_t::volType, and i_MediumVol_t::volUsed.

Referenced by InitializeVolumes().

                                                                 {
    log_FUNC_m(InitializeSingleVolume);

    i_Resource_t tmpResSetVol;
    tmpResSetVol = GetResources()[0];
    tmpResSetVol.medVolNr     = a_medVol.medVolNr;
    tmpResSetVol.medVolId     = a_medVol.medVolId;
    tmpResSetVol.medVolType   = a_medVol.volType;
    SetResources(tmpResSetVol);

    {
        cmn_MutexLock l(m_beasStatus_x);
        i_Job_i::ActivateBea(0);
        SetBeaStatus(0, bs_RUNNING);
    }

    SetResBeaStarted(0);

    // TODO: Potential improvement: the information from BEA could be read
    //       and compared to the info from RMDB at this point.

    i_VolInfo_t volInfo;
    volInfo.volNum      = a_medVol.medVolNr;
    volInfo.implID      = CORBA::string_dup(ipc_nilStr);
    volInfo.size        = a_medVol.volSize;
    volInfo.type        = i_VOL_IVD;
    volInfo.sysVolNum   = m_medium.idxOfSysVol;
    volInfo.medVolID    = a_medVol.medVolId;
    volInfo.poolID      = m_pool.poolUUIDString;
    volInfo.partID      = m_iJobParams.partUUID;
    volInfo.blockSize   = m_pool.blockSize;

    volInfo.accessNum   = 0;
    volInfo.appendNum   = 0;
    volInfo.owriteNum   = ++a_medVol.owriteNr;

    log_DBG_m(dbg_LOW, "[" << m_iJobParams.jobID <<
            "] " << "Init:" << endl << ipc_Log::LogVolInfo(volInfo));

    //
    // initialize volume.
    ostringstream msgBase;
    msgBase
        <<  "Medium " << m_medium.barcode <<
        ", volume " << a_medVol.medVolNr << ": ";

    bool isSystemVolume = (volInfo.volNum == volInfo.sysVolNum);
    ostringstream msg;
    if (isSystemVolume) {
        msg << "Initializing system volume ";
    }
    else {
        msg << "Initializing volume ";
    }
    msg << a_medVol.medVolNr << " ...";
    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, "[" << m_iJobParams.jobID << "] " << msg.str());
    SetResProcessed(0);

    ipc_EXEC_m(m_activeBeas[0]->Init(volInfo););

    SetResMedOpComplete(0);

    log_DBG_m(dbg_NORM,
        "[" << m_iJobParams.jobID << "] " << "BEA->Init() returned.");

    msg.str("");
    if (isSystemVolume) {
        msg << "System volume ";
    }
    else {
        msg << "Volume ";
    }
    msg << "(" << a_medVol.medVolNr << ") initialization finished.";

    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, "[" << m_iJobParams.jobID << "] " << msg.str());

    //update medVol in rmdb
    a_medVol.volUsed = 0;
    a_medVol.validData = 0;
    a_medVol.totalData = 0;
    a_medVol.status = rmdb_MEDVOL_EMPTY;
    a_medVol.owriteNr++;
    a_medVol.owriteTime = cmn_Time().GetTime_t();

    ipc_EXEC_m(m_rm->UpdateMediumVol(a_medVol););
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_ReorgJob_i::InitializeVolumes (  )  [protected]

Definition at line 809 of file i_reorgjob_impl.cpp.

References i_Medium_t::barcode, i_Resource_t::barcode, pm_ReorgVolStatus::Begin(), i_Medium_t::blockSize, i_Resource_t::blockSize, dbg_LOW, dbg_NORM, cmn_File::DeleteF(), cmn_Global::dirs, ui_MsgWriter::DisplayMessage(), evt_ERROR, ivd_Directories::fri, g_cmn, pm_ReorgVolStatus::GetCurrentVol(), ivd_BaseException::GetError(), pm_ReorgVolStatus::GetReadStatus(), i_Job_i::GetResources(), ivd_BaseException::GetText(), pm_ReorgVolStatus::GetWriteStatus(), i_Medium_t::idxOfSysVol, InitializeSingleVolume(), ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, i_Job_i::LoadUnload(), log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogMediumVol(), i_Job_i::m_activate_c, i_Job_i::m_activate_x, i_PartitionManager_i::m_iFSCi, i_Job_i::m_iJob, i_Job_i::m_iJobParams, m_iPM, m_medium, m_pool, i_Job_i::m_rm, m_ui, m_volStatus, i_MediaPool_t::mediaFamily, i_MediaPool_t::mediaPoolKey, i_MediaPool_t::mediaPoolName, i_MediaPool_t::mediaPoolType, i_Resource_t::mediumFamily, i_Medium_t::mediumKey, i_Resource_t::mediumKey, i_Medium_t::mediumType, i_MediumVol_t::medVolId, i_MediumVol_t::medVolNr, pm_ReorgVolStatus::Next(), i_Resource_t::poolKey, i_Resource_t::poolName, i_Resource_t::poolType, i_Resource_t::poolUUID, i_MediaPool_t::poolUUIDString, i_FSC_i::ReleaseVolEntries(), i_Resource_t::resNum, ipc_Init::ResourceInit(), i_Resource_t::resRequested, rmdb_SYSTEM_VOLUME, i_Job_i::SetResources(), and cmn_Condition::Wait().

Referenced by Execute().

                                    {
    log_FUNC_m(InitializeVolumes);

    try {
        bool sysVolProcessed(false);
        bool mediumIsWORM(
                ivd_IsMediumTypeWORM(
                    static_cast<ivd_MediaType_e>(m_medium.mediumType)
                ));
        m_volStatus.Begin();

        ostringstream msg;
        //allocate resources
        cmn_MutexLock l(m_activate_x);

        i_ResourceList_t tmpResAllocate;
        tmpResAllocate.length(1);
        i_Resource_t tmpRes;
        ipc_Init::ResourceInit(tmpRes);
        tmpRes.resNum       = 0;
        tmpRes.poolKey      = m_pool.mediaPoolKey;
        tmpRes.poolUUID     = m_pool.poolUUIDString;
        tmpRes.poolName     = m_pool.mediaPoolName;
        tmpRes.blockSize    = m_medium.blockSize;
        tmpRes.mediumFamily = m_pool.mediaFamily;
        tmpRes.poolType     = m_pool.mediaPoolType;

        tmpRes.mediumKey    = m_medium.mediumKey;
        tmpRes.barcode      = m_medium.barcode;
        tmpRes.resRequested = true;
        SetResources(tmpRes);
        tmpResAllocate[0] = tmpRes;

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

        msg.str("");
        msg << "Waiting for resources ...";
        ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(m_medium.barcode));

        m_activate_c.Wait();
        if (IsAborted()) {
            return;
        }

        log_DBG_m(dbg_NORM, "resources allocated");
        msg.str("");
        msg << "Resources allocated.";
        ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(m_medium.barcode));

        //start Bea
        ipc_EXEC_m(
            if (GetResources()[0].load){
                // operate LA.
                string driveName;
                if (GetResources()[0].driveKey > 0) {
                    ipc_EXEC_m(
                        i_Drive_t_var drive;
                        drive = m_rm->SelectDriveByKey(GetResources()[0].driveKey);
                        driveName = drive->driveName;
                    )
                } else {
                    log_ERR_m("Drive not defined, unable to load.")
                }

                msg.str("");
                msg << "Loading medium " << m_medium.barcode <<
                    " to drive " << driveName << ".";
                ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
                log_WriteEvent(msg.str(), evt_MAINTJOB,
                    m_iJobParams.jobID, string(m_medium.barcode));

                //Start Bea
                LoadUnload(0);
            }

        );

        //initialize system volume
        if (m_medium.idxOfSysVol > 0 && !mediumIsWORM){
            i_MediumVol_t_var sysVol;
            ipc_EXEC_m(
                sysVol = m_rm->SelectMediumVolByKey(m_medium.mediumKey,
                                                    m_medium.idxOfSysVol);
            );
            InitializeSingleVolume(sysVol);
        }

        while (1) {

            i_MediumVol_t mv = m_volStatus.GetCurrentVol();

            if ( (m_volStatus.GetReadStatus() != i_SUCCEDED) ||
                 (m_volStatus.GetWriteStatus() != i_SUCCEDED) ){
                msg.str("");
                msg <<  "Medium " << m_medium.barcode <<
                        ", volume " << mv.medVolNr << ": ";

                msg << "Reorganization of Volume " << mv.medVolNr
                    << " failed." << " Volume will not be initialized";

                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, "[" << m_iJobParams.jobID <<
                                    "] " << "volume NOT initialized. " <<
                                    ipc_Log::LogMediumVol(mv) );
                m_volStatus.Next();
                continue;
            }
            log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                "] " << "Next volume to be initialized. " <<
                                ipc_Log::LogMediumVol(mv) );

            if (mediumIsWORM){
                //will not initialize WORM medium
                msg.str("");
                msg << "WORM Medium " << m_medium.barcode <<
                        " Volume " << mv.medVolNr <<
                        " was reorganized. Volume cannot be initialized.";
                ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
                log_WriteEvent(msg.str(), evt_MAINTJOB,
                    m_iJobParams.jobID, string(m_medium.barcode));

                //Remove volume record
                try {
                    ipc_EXEC_m(
                        i_Medium_t_var med = m_rm->SelectMedium(m_medium.barcode);
                        med->currentVolume = 0;
                        m_rm->UpdateMedium(med);
                        m_rm->RemoveMediumVol(m_medium.barcode, mv.medVolNr);
                    );

                    i_MediumVolSeq_t_var medVolSeq;
                    medVolSeq = m_rm->SelectAllMediumVolByBarcode(m_medium.barcode);

                    if (medVolSeq->length() == 0){
                        msg.str("");
                        msg << "WORM Medium " << m_medium.barcode <<
                            " was reorganized. Remove medium. Use ivdmedium -r " <<
                            m_medium.barcode << ".";

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

                    }

                    if (m_medium.idxOfSysVol > 0 && !sysVolProcessed) {
                        for (UInt32_t i(0); i < medVolSeq->length(); i++){
                            if (medVolSeq[i].volType == rmdb_SYSTEM_VOLUME){
                                ipc_EXEC_m(
                                    m_rm->RemoveMediumVol(m_medium.barcode,
                                                          medVolSeq[i].medVolNr);
                                )
                            }
                        }
                        sysVolProcessed = true;
                    }
                }
                catch (const ivd_Error &e){
                    log_ERR_m("Deleting of reorganized volume failed." <<
                        endl << e);
                }
            }
            else {
                InitializeSingleVolume(mv);
            }

            if (m_medium.idxOfSysVol != mv.medVolNr) {

                msg.str("");
                msg << "Initialization finished. 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 <<
                    "MedVolNr.:" << mv.medVolNr);

                try {
                    m_iPM.m_iFSCi->ReleaseVolEntries(
                        m_medium.mediumKey,
                        mv.medVolNr);
                } catch (const ivd_Error& e){
                    msg.str("");
                    msg << "Error while releasing entries from FSC: " << e.GetText();
                    log_WriteEvent(evt_ERROR, msg.str(), evt_MAINTJOB,
                            m_iJobParams.jobID, string(m_medium.barcode));
                    throw;
                }

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

                msg.str("");
                msg << "Entries for volume " << mv.medVolNr << " deleted from FSC.";

                ipc_EXEC_m( m_ui.DisplayMessage(msg.str()); );

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

                //delete fri file
                cmn_Path friPath = g_cmn.dirs.fri + mv.medVolId;
                try {
                    cmn_File friFile(friPath);
                    friFile.DeleteF();
                    log_DBG_m(dbg_NORM,
                        "[" << m_iJobParams.jobID << "] " << "FRI file deleted. " << friPath);
                }
                catch (...) {
                    //ignore
                }
            }
            else {
                log_DBG_m(dbg_LOW, "Volume is system. FSC entries not deleted.");
            }

            m_volStatus.Next();

        }; //while(1) loop until exception ie_VOL_NOT_FOUND

    }
    catch (const ivd_Error& e) {
        if (e.GetError() == ie_VOL_NOT_FOUND){
            log_DBG_m(dbg_LOW, "reorg init finished.");
            //continue
        }
        else {
            throw;
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements i_Job_i.

Definition at line 331 of file i_reorgjob_impl.cpp.

References i_Medium_t::barcode, cmn_Condition::Broadcast(), bs_RUNNING, 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, i_Job_i::m_iJobParams, m_medium, i_Job_i::m_rm, m_ui, m_volStatus, i_JobParams::phase, i_Job_i::ReleaseResource(), i_Job_i::SetBeaStatus(), pm_ReorgVolStatus::SetReadFinished(), i_Job_i::SetResMedOpComplete(), and pm_ReorgVolStatus::SetWriteFinished().

                                                                          {

    log_FUNC_m(MediumOperationComplete);
    log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
        "] " << "Migration 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_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_volStatus.SetReadFinished(a_status);
        //Check if other volumes should be read ?

        //check completion status
        ipc_EXEC_m(m_rm->SetPhase(m_iJobParams.jobID, m_iJobParams.phase++););
        ostringstream msg;
        if (a_status == i_SUCCEDED) {
            msg << "Reading finished, releasing resources.";
        } else {
            msg << "Reading failed. (" << ipc_Log::LogStatus(a_status) <<
                    "). Releasing resources.";
        }

        ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(m_medium.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
        ostringstream msg;
        if (a_status == i_SUCCEDED) {
            msg << "Writing finished, releasing resources.";
        } else {
            msg << "Writing failed. (" << ipc_Log::LogStatus(a_status) <<
                "). Releasing resources";
        }

        ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(GetResources()[1].barcode));

        //free up resources
        m_volStatus.SetWriteFinished(a_status);
        {
            //broadcast to executor to continue with next volume
            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);
    }
}

Here is the call graph for this function:

void i_ReorgJob_i::MigrateFiles (  )  [private]

Definition at line 1210 of file i_reorgjob_impl.cpp.

References i_Job_i::ActivateBea(), i_Resource_t::barcode, i_Medium_t::barcode, i_Medium_t::blockSize, i_Resource_t::blockSize, bs_PROCESSING, bs_RUNNING, i_Resource_t::collocation, dbg_DETAIL, dbg_NORM, DiskBufferCleanup(), ui_MsgWriter::DisplayMessage(), i_Resource_t::driveKey, i_MinorCol_t::flags, pm_ReorgVolStatus::GetCurrentMedVol(), pm_ReorgVolStatus::GetCurrentVol(), pm_ReorgVolStatus::GetReadStatus(), i_Job_i::GetResources(), pm_ReorgVolStatus::GetWriteStatus(), ipc_EXEC_m, i_Job_i::IsAborted(), pm_VolStatus::IsRead(), 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, m_medium, m_pool, pm_VolStatus::m_recallSetReader, i_Job_i::m_rm, i_Job_i::m_status, m_ui, m_volStatus, i_MinorCol_t::majColId, i_Resource_t::majColId, i_MediaPool_t::mediaFamily, i_MediaPool_t::mediaPoolKey, i_MediaPool_t::mediaPoolName, i_MediaPool_t::mediaPoolType, i_Resource_t::mediumFamily, i_Resource_t::mediumKey, i_Medium_t::mediumType, i_MediumVol_t::medVolId, i_Resource_t::medVolNr, i_Resource_t::minColId, i_Resource_t::minFlags, mt_DISK, i_Job_i::NeedsProcess(), 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_Resource_t::resRequested, rmdb_MEDVOL_REORG_RECYCLED, i_Job_i::SetBeaStatus(), i_Job_i::SetResources(), i_Job_i::SetResProcessed(), i_Job_i::SetResRequested(), cmn_Condition::Wait(), i_Job_i::WaitBeasToFinish(), and pm_VolStatus::WriteStarted().

Referenced by Execute().

                                {
    log_FUNC_m(MigrateFiles);

    ostringstream msg;

    i_MediumVol_t mv = m_volStatus.GetCurrentVol();
    pm_VolStatus &vol = m_volStatus.GetCurrentMedVol();

    if(m_volStatus.GetReadStatus() == i_SUCCEDED){
        //allocate target medium
        try {
            ipc_EXEC_m(
                i_ResourceList_t tmpRes;
                tmpRes.length(1);
                i_Resource_t srcRes = GetResources()[0];
                log_DBG_m(dbg_NORM, "Source resource: " << endl << ipc_Log::LogResources(srcRes));
                tmpRes[0] = GetResources()[0]; //0 - source resource
                ipc_Init::ResourceInit(tmpRes[0]);
                tmpRes[0].resRequested = true;

                tmpRes[0].resNum         = 1;
                tmpRes[0].poolKey        = m_pool.mediaPoolKey;
                tmpRes[0].poolUUID       = m_pool.poolUUIDString;
                tmpRes[0].poolName       = m_pool.mediaPoolName;
                tmpRes[0].blockSize      = m_medium.blockSize;
                tmpRes[0].mediumFamily   = m_pool.mediaFamily;
                tmpRes[0].poolType       = m_pool.mediaPoolType;

                i_ColMediaVolSeq_t_var i_cmv = m_rm->SelectAllColVolumes();
                log_DBG_m(dbg_NORM, "Num of colVol: " << i_cmv->length() <<
                                    ", srcRes medkey: " << srcRes.mediumKey <<
                                    ", volNr: " << srcRes.medVolNr);
                for (UInt32_t i (0); i < i_cmv->length(); i++) {
                    log_DBG_m(dbg_DETAIL, "medKey: " << i_cmv[i].mediaKey <<
                                          " medVolNr: " << i_cmv[i].medVolNr);
                    if ((srcRes.mediumKey == i_cmv[i].mediaKey) && (srcRes.medVolNr == i_cmv[i].medVolNr)) {
                        tmpRes[0].minColId    = i_cmv[i].minColId;
                        log_DBG_m(dbg_DETAIL, "selected minColID: " << tmpRes[0].minColId);

                        i_MinorCol_t i_mc = m_rm->SelectMinorCol(tmpRes[0].minColId);
                        tmpRes[0].majColId = i_mc.majColId;
                        tmpRes[0].minFlags = i_mc.flags;
                        tmpRes[0].collocation = true;
                        log_DBG_m(dbg_DETAIL, "majColId: " << tmpRes[0].majColId <<
                                              " flags: " << tmpRes[0].minFlags);

                    }
                }
                SetResources(tmpRes[0]);

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

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


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

                SetResRequested(1);
                //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(m_medium.barcode));
                m_ui.DisplayMessage(msg.str());
            );
        } catch (ivd_Exception){
            log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                "] " << "RM->GetResources failed.");
            m_status = i_RESOURCE_ERROR;
            DiskBufferCleanup();
            throw;
        }

        if (IsAborted()) {
            return;
        }

        UInt32_t splitNumber(0);

        vol.WriteStarted();
        //invoke writing on target medium

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

            log_DBG_m(dbg_NORM, "Write not completed yet.");
            if (IsAborted()) {
                return;
            }

            i_Resource_t res = GetResources()[1];
            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.");

                string driveName;
                if (res.load){ //load is required

                    // operate LA.
                    if (GetResources()[1].driveKey > 0) {
                        ipc_EXEC_m(
                            i_Drive_t_var drive;
                            drive = m_rm->SelectDriveByKey(res.driveKey);
                            driveName = drive->driveName;
                        );
                    } else {
                        log_ERR_m("Drive not defined, unable to 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));
                }
                else if (m_medium.mediumType != mt_DISK){
                    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(LoadUnload(1));

                ipc_EXEC_m(
                    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));

                    ++splitNumber;
                    cmn_MutexLock l(m_beasStatus_x);
                    i_Job_i::ActivateBea(1);
                    SetBeaStatus(1, bs_RUNNING);

                    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));

                    log_DBG_m(dbg_NORM,
                        "Processing split number: " << splitNumber);

                    // Detect the split at this point to prevent multiple
                    // calls of Migrate().
                    if (splitNumber == 1) {
                        m_activeBeas[1]->Migrate();
                    }
                    else {
                        log_DBG_m(dbg_NORM,
                           "bea->Migrate() is not called for splits.");
                    }
                    SetBeaStatus(1, bs_PROCESSING);
                );
                SetResProcessed(1);
                //wait for writer to finish
                log_DBG_m(dbg_NORM, "Waiting for bea to finish.");
                //m_activate_c.Wait();
                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("BUG:Resources should need processing.???" <<
                    ipc_Log::LogResources(res));
                return;
            };
        } // while (!vol.m_recallSetReader.IsWriteFinished())
    }
    //check status of write
    if ( (m_volStatus.GetWriteStatus() == i_SUCCEDED) && (vol.IsRead()) ) {
        //set status to reorganized
        ipc_EXEC_m (
            m_rm->MedVolStatusSet(  mv.medVolId,
                                    rmdb_MEDVOL_REORG_RECYCLED);
        )
    }
    DiskBufferCleanup();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_ReorgJob_i::ReadSourceVolume (  )  [protected]

Definition at line 501 of file i_reorgjob_impl.cpp.

References i_Job_i::ActivateBea(), i_Medium_t::barcode, bs_PROCESSING, bs_RUNNING, ui_MsgWriter::DisplayMessage(), pm_ReorgVolStatus::GetCurrentVol(), i_Job_i::GetResources(), ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, i_Job_i::LoadUnload(), log_ERR_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_activeBeas, m_barcode, i_Job_i::m_beasStatus_x, i_Job_i::m_iJobParams, m_medium, i_Job_i::m_rm, m_ui, m_volStatus, i_MediumVol_t::medVolNr, i_Job_i::SetBeaStatus(), and i_Job_i::SetDiskBufferWritten().

Referenced by RecallFiles().

                                   {
    log_FUNC_m(ReadSourceVolume);

    ostringstream msg;
    if (GetResources()[0].load){
        // operate LA.
        string driveName;
        if (GetResources()[0].driveKey > 0) {
            ipc_EXEC_m(
                i_Drive_t_var drive;
                drive = m_rm->SelectDriveByKey(GetResources()[0].driveKey);
                driveName = drive->driveName;
            )
        } else {
            log_ERR_m("Drive not defined, unable to load.")
        }

        msg << "Loading medium " << m_medium.barcode <<
            " to drive " << driveName << ".";
        ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););
        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(m_medium.barcode));

        //Start Bea
        LoadUnload(0);
    }

    try {
        ipc_EXEC_m(
            cmn_MutexLock l(m_beasStatus_x);
            i_Job_i::ActivateBea(0);
            SetBeaStatus(0, bs_RUNNING);

            if (IsAborted()){
                return;
            }
            msg.str("");
            msg << "Medium " << m_barcode << ", volume " <<
                m_volStatus.GetCurrentVol().medVolNr << " Reading valid files...";

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

            SetDiskBufferWritten();
            m_activeBeas[0]->Recall();
            SetBeaStatus(0, bs_PROCESSING);
        );
    } catch (ivd_Exception& e){
        log_ERR_m("[" << m_iJobParams.jobID <<
            "] Catched Exception when calling Bea->Recall " << e);
        throw;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool i_ReorgJob_i::RecallFiles ( UInt64_t  a_dBuffSize  )  [private]

Definition at line 1411 of file i_reorgjob_impl.cpp.

References i_Medium_t::barcode, i_Job_i::ClearResStatus(), CompleteJob(), dbg_NORM, DiskBufferCleanup(), ui_MsgWriter::DisplayMessage(), pm_ReorgVolStatus::GetCurrentMedVol(), pm_ReorgVolStatus::GetCurrentVol(), pm_ReorgVolStatus::GetReadStatus(), i_Job_i::GetResources(), i_UNKNOWN, 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_barcode, i_Job_i::m_iJob, i_Job_i::m_iJobParams, m_medium, pm_VolStatus::m_recallSetReader, i_Job_i::m_rm, i_Job_i::m_status, m_ui, m_volStatus, i_Medium_t::mediumKey, i_Resource_t::mediumKey, i_Resource_t::medVolId, i_MediumVol_t::medVolId, i_Resource_t::medVolNr, i_MediumVol_t::medVolNr, pm_ReorgVolStatus::Next(), ReadSourceVolume(), i_Job_i::ReleaseResource(), i_Resource_t::resRequested, rmdb_MEDVOL_REORG_SCANNED, pm_RecallSetReader::SetCurrentBuffSize(), pm_ReorgVolStatus::SetMedVol(), pm_ReorgVolStatus::SetReadFinished(), i_Job_i::SetResMedOpComplete(), i_Job_i::SetResources(), i_Job_i::SetResProcessed(), i_Job_i::SetResRequested(), pm_ReorgVolStatus::SetWriteFinished(), i_MediumVol_t::status, cmn_Condition::Wait(), and i_Job_i::WaitBeasToFinish().

Referenced by Execute().

                                                   {
    log_FUNC_m(RecallFiles);

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

    ostringstream msg;

    i_MediumVol_t mv = m_volStatus.GetCurrentVol();
    try {
        ipc_EXEC_m(
            i_Resource_t tmpRes;
            ClearResStatus(0);
            tmpRes = GetResources()[0]; //0 - source resource

            tmpRes.resRequested = true;
            cmn_MutexLock l(m_activate_x);

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

            log_WriteEvent(msg.str(), evt_MAINTJOB,
                m_iJobParams.jobID, string(m_medium.barcode));
            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();

            if (IsAborted()) {
                return false;
            }
            msg.str("");
            msg << "Resources allocated.";

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

    //read volume info again
    ipc_EXEC_m (
        i_MediumVol_t_var tmpVol = m_rm->SelectMediumVol(
                                                m_medium.barcode,
                                                mv.medVolNr);
        m_volStatus.SetMedVol(tmpVol);
        mv = tmpVol;
    );


    if (mv.status & rmdb_MEDVOL_REORG_SCANNED) {
        // ok, continue
    }
    else {
        msg.str("");
        msg << "Reorganization for Volume: " <<
                mv.medVolId << " not possible. " <<
                "Volume status changed " <<
                "(probably migration happened. Skipped.)";

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

        m_ui.DisplayMessage(msg.str());

        m_volStatus.SetReadFinished(i_UNKNOWN);
        m_volStatus.SetWriteFinished(i_UNKNOWN);
        try {
            m_volStatus.Next();
            return false;
        } catch (ivd_Error &e){
            log_DBG_m(dbg_NORM, e);
            //no more volumes to reorganize
            //release resources
            ReleaseResource(0);
            throw;
        }
    }

    /*[11:42:09] Medium 050003, volume 1: Reading valid files
    [12:20:58] Medium 050003, volume 1: Valid files written to disk buffer.
*/

    //Set Resources for reading

    i_Resource_t tmpRes = GetResources()[0];
    tmpRes.mediumKey    = m_medium.mediumKey;
    tmpRes.medVolNr     = mv.medVolNr;
    tmpRes.medVolId     = mv.medVolId;

    SetResources(tmpRes);

    pm_VolStatus &vol = m_volStatus.GetCurrentMedVol();
     /* 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);

    ReadSourceVolume();

    if (IsAborted()) {
        return false;
    }

    SetResProcessed(0);

    {
        cmn_MutexLock l(m_activate_x);
        WaitBeasToFinish(5);
    }

    if (IsAborted()) {
        return false;
    }

    if (m_volStatus.GetReadStatus() == i_SUCCEDED){
        msg.str("");
        msg <<  "Medium " << m_barcode << ", volume " <<
            m_volStatus.GetCurrentVol().medVolNr <<
            " Valid files written to disk buffer.";
    } else {
        msg.str("");
        msg <<  "Medium " << m_barcode << ", volume " <<
            m_volStatus.GetCurrentVol().medVolNr <<
            " Reading of valid files failed.";
        // do job cleanup in case of error
        log_WriteEvent(msg.str(), evt_MAINTJOB,
            m_iJobParams.jobID, string(m_medium.barcode));
        m_ui.DisplayMessage(msg.str());
        SetResMedOpComplete(0);
        CompleteJob(m_volStatus.GetReadStatus());
        return false;
    }


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

    SetResMedOpComplete(0);
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_ReorgJob_i::ReorgStatusCleanup ( vector< UInt32_t a_volumes  )  [protected]

Definition at line 1141 of file i_reorgjob_impl.cpp.

References dbg_NORM, ie_PRECONDITION, ipc_EXEC_m, ivd_Error, i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, ipc_Log::LogMediumVol(), m_barcode, i_Job_i::m_iJobParams, i_Job_i::m_rm, and rmdb_MEDVOL_REORG_INREORG.

Referenced by i_ReorgJob_i().

                                                               {
    log_FUNC_m(ReorgStatusCleanup);
    try {
        //select media volumes
        i_MediumVolSeq_t_var volumes;
        ipc_EXEC_m(
            volumes = m_rm->SelectAllMediumVolByBarcode(m_barcode.c_str());
        );
        if (a_volumes.empty()) {
            // all volumes
            log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                "] " << "a_volumes.empty(). " <<
                "All volumes will have in_reorg status cleared." );
            for (UInt32_t j(0); j < volumes->length(); j++){
                if (volumes[j].status & rmdb_MEDVOL_REORG_INREORG){
                    log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                        "] Clearing in reorg flag for volume: " << endl <<
                        ipc_Log::LogMediumVol(volumes[j]));
                    //clear in reorg flag
                    ipc_EXEC_m (
                        m_rm->MedVolStatusClear(
                        volumes[j].medVolId,
                        rmdb_MEDVOL_REORG_INREORG);
                    );
                }
            }
        } else {
            // only needed volumes
            for (UInt32_t i(0); i < a_volumes.size(); i++){
                bool found = false;
                for (UInt32_t j(0); j < volumes->length(); j++){
                    if (static_cast<Int32_t>(a_volumes[i]) == volumes[j].medVolNr){
                        if (volumes[j].status & rmdb_MEDVOL_REORG_INREORG){
                            log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                                "] Clearing in reorg flag for volume: " << endl <<
                                ipc_Log::LogMediumVol(volumes[j]));

                            //clear in reorg flag
                            ipc_EXEC_m (
                                m_rm->MedVolStatusClear(
                                volumes[j].medVolId,
                                rmdb_MEDVOL_REORG_INREORG);
                            )
                            found = true;
                        } else {
                            log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                                "] Will NOT clear in reorg flag for volume. NOT SCANNED: " << endl <<
                                ipc_Log::LogMediumVol(volumes[j]));
                        }
                    }
                }
                if (!found){
                    throw ivd_Error (ie_PRECONDITION,
                        "No volumes found for clearing in reorg flag, but an "
                        "error 'volumes are already being reorganized' reported.");
                }
            }
        }
    // Any exception will not be re-thrown (cleanup due to another exception)
    // but it will be logged in error log
    } catch (ivd_Error &e) {
        log_ERR_m("An error occurred while clearing in reorg flag.'"
            << endl << e);
    } catch (...) {
        log_ERR_m("An unknown error occurred while clearing in reorg flag.");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from i_Job_i.

Definition at line 1569 of file i_reorgjob_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_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:

void i_ReorgJob_i::UpdateMediumStatus (  )  [protected]

Definition at line 1057 of file i_reorgjob_impl.cpp.

References dbg_DETAIL, ipc_EXEC_m, log_DBG_m, log_FUNC_m, m_barcode, i_Job_i::m_rm, rmdb_MEDVOL_FULL, and rmdb_MEDVOL_USED.

Referenced by Execute().

                                     {
    log_FUNC_m(UpdateMediumStatus);
    //select media volumes
    i_MediumVolSeq_t_var volumes;
    ipc_EXEC_m(
        volumes = m_rm->SelectAllMediumVolByBarcode(m_barcode.c_str());
    );
    bool allFull(true);
    bool allEmpty(true);
    for (UInt32_t i(0); i < volumes->length();i++){
        if (!(volumes[i].status & rmdb_MEDVOL_FULL)){
            log_DBG_m(dbg_DETAIL, "Volume: " << i << " is not Full");

            allFull = false;
        }
        if ((volumes[i].status & rmdb_MEDVOL_FULL)
            ||
            (volumes[i].status & rmdb_MEDVOL_USED)){
            log_DBG_m(dbg_DETAIL, "Volume: " << i << " is Full or Used");
            allEmpty = false;
        }
    }

    i_Medium_t_var med;
    ipc_EXEC_m (
        med = m_rm->SelectMedium(m_barcode.c_str());
    );
    if (volumes->length() == 0){
        med->status = med->status & ~rmdb_MEDIUM_FULL; //clear full status
        med->status = med->status & ~rmdb_MEDIUM_OPEN; //clear open status
    } else if (allFull) {
        //Update Medium Set to Full
        med->status = med->status | rmdb_MEDIUM_FULL; //set Full status
        med->status = med->status & ~rmdb_MEDIUM_OPEN; //clear open status
    } else if (allEmpty) {
        //Update Medium Set to Empty
        med->status = med->status & ~rmdb_MEDIUM_FULL; //clear full status
        med->status = med->status & ~rmdb_MEDIUM_OPEN; //clear open status
    } else {
        //Update medium is open
        med->status = med->status | rmdb_MEDIUM_OPEN; //set Open status
        med->status = med->status & ~rmdb_MEDIUM_FULL; //clear Full status
    }
    ipc_EXEC_m (
        m_rm->UpdateMedium(med);
    )
}

Here is the caller graph for this function:

void i_ReorgJob_i::Wait (  )  [protected]

Definition at line 557 of file i_reorgjob_impl.cpp.

References log_FUNC_m, i_Job_i::m_activate_c, i_Job_i::m_activate_x, and cmn_Condition::Wait().

Here is the call graph for this function:


Member Data Documentation

Reimplemented from i_Job_i.

Definition at line 51 of file i_reorgjob_impl.h.

string i_ReorgJob_i::m_barcode [protected]

Definition at line 67 of file i_reorgjob_impl.h.

Referenced by Execute(), GetFSC(), i_ReorgJob_i(), InitializeVolumes(), and ~i_ReorgJob_i().


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