Public Member Functions | Private Member Functions | Private Attributes

i_AdminJob_i Class Reference
[Management Interface]

#include <i_adminjob_impl.h>

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

List of all members.

Public Member Functions

 i_AdminJob_i (mif_JobManager &a_jobManager, bool a_doFormat, bool a_doInit, bool a_doFri, bool a_doMic, bool a_doVolumeClose, bool a_forced, const char *a_barcode, const i_VolNumList_t &a_volumes, i_UIMessageServer_ptr &a_UIMS_p, CORBA::Boolean a_into=false, const char *a_intoPath="")
virtual ~i_AdminJob_i ()
void InitJob ()
void FormatAndInitCheck ()
void RecreateFRIandMICCheck ()
void CloseVolumeCheck ()
void AllocateDiskBuffer (i_FileSize_t a_size)
void MediumOperationComplete (i_Index_t beaNumber, i_CompletionStatus_e a_status)
virtual void CompleteJob (i_CompletionStatus_e status)
void GetNewResources (i_Index_t resourceNumber)
i_JobRequestList_tGetFiles ()
i_FSC_ptr GetFSC ()

Private Member Functions

void DetectVolumeHeader (i_VolInfo_t_var &a_volInfo, Int32_t a_volumeNr)
void InitializeSingleVolume (Int32_t volumeNr)
void DoInitialize (Int32_t a_volumeNr, Int32_t a_size)
void OperateLA (rm_Resource_t &resource)
void StartBEA ()
void DeleteMedVolFromRMDB (string a_barcode, Int32_t a_medVolNum)
void Format ()
void Initialize ()
void RecreateFRIandMIC ()
 Generates new FRI on disk from specified data medium volume.
void CloseVolume ()
void SetSysVolIdx (UInt32_t a_numOfVol)
void Execute ()
void CheckMedium ()
void CheckPool ()
void CheckPartition ()
void CheckVolumesForFormatAndInit (bool a_log=true)
void CheckVolumesForFriMicJob ()
void CheckVolumesForVolumeClose ()
void SetVolumes ()
UInt32_t FindVolInRMDB (UInt32_t a_volNum)
void SetResourceBusyStatus (i_Index_t a_resNum, i_ResourceBusy_e a_resStatus)

Private Attributes

bool m_doFormat
bool m_doInit
bool m_doFri
bool m_doMic
bool m_doCloseVolume
bool m_initAllVol
bool m_forced
UInt32_t m_lastAccessedVolume
ui_MsgWriter m_ui
i_MediumVolSeq_t m_medVolInRmdb
vector< UInt32_tm_initVol
bool m_makeSysVol
Int32_t m_idxSysVol
bool m_initSucceeded
bool m_jobValid
string m_barcode
i_Medium_t m_medium
i_MediaPool_t m_mediaPool
bool m_into
string m_intoPath
 log_CLASSID_m

Detailed Description

Definition at line 52 of file i_adminjob_impl.h.


Constructor & Destructor Documentation

i_AdminJob_i::i_AdminJob_i ( mif_JobManager a_jobManager,
bool  a_doFormat,
bool  a_doInit,
bool  a_doFri,
bool  a_doMic,
bool  a_doVolumeClose,
bool  a_forced,
const char *  a_barcode,
const i_VolNumList_t a_volumes,
i_UIMessageServer_ptr &  a_UIMS_p,
CORBA::Boolean  a_into = false,
const char *  a_intoPath = "" 
)

Definition at line 55 of file i_adminjob_impl.cpp.

References i_JobParams::bufType, dbg_LOW, i_JobParams::jobType, log_DBG_m, log_FUNC_m, i_Job_i::m_iJobParams, and m_initVol.

    :   i_Job_i(a_jobManager, true),
        m_doFormat(a_doFormat),
        m_doInit(a_doInit),
        m_doFri(a_doFri),
        m_doMic(a_doMic),
        m_doCloseVolume(a_doCloseVolume),
        m_initAllVol(a_volumes.length() == 0),
        m_forced(a_forced),
        m_lastAccessedVolume(0),
        m_ui(a_UIMS_p),
        m_makeSysVol(false),
        m_idxSysVol(0),
        m_initSucceeded(false),
        m_barcode(a_barcode),
        m_into(a_into),
        m_intoPath(a_intoPath)
        {
    log_FUNC_m(i_AdminJob_i);
    // copy i_VolNumList_t& a_volumes to member m_initVol
    for (UInt32_t i(0); i < a_volumes.length(); i++){
        log_DBG_m(dbg_LOW, "Volume: " << a_volumes[i]);
        m_initVol.push_back(a_volumes[i]);
    }
    m_iJobParams.jobType          = jt_ADMIN;
    m_iJobParams.bufType          = i_DISK_BUF;

} //i_AdminJob_i::i_AdminJob_i

i_AdminJob_i::~i_AdminJob_i (  )  [virtual]

Definition at line 97 of file i_adminjob_impl.cpp.

References i_Medium_t::barcode, ui_MsgWriter::DisplayMessage(), ui_MsgWriter::DisplayWarning(), evt_WARNING, ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, log_FUNC_m, log_WriteEvent(), i_Job_i::m_iJobParams, m_medium, i_Job_i::m_rm, and m_ui.

                            {
    log_FUNC_m(~i_AdminJob_i);

    // do any other necessary cleanups.
    try {
        ipc_EXEC_m(m_rm->UseNewResource();)
    }
    catch (...) {
        //ignore any exceptions
    }

    if ( IsAborted() ) {
        ostringstream msg;
        msg << "Aborted.";
        log_WriteEvent(evt_WARNING, msg.str(), evt_ADMINJOB,
                       m_iJobParams.jobID, string(m_medium.barcode));
        ipc_EXEC_m(m_ui.DisplayWarning(msg.str());)
    }
    else {
        ostringstream msg;
        msg << "Finished.";
        log_WriteEvent(msg.str(), evt_ADMINJOB,
                       m_iJobParams.jobID, string(m_medium.barcode));
        ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)
    }

} // i_AdminJob_i::~i_AdminJob_i

Here is the call graph for this function:


Member Function Documentation

void i_AdminJob_i::AllocateDiskBuffer ( i_FileSize_t  a_size  )  [virtual]

Reimplemented from i_Job_i.

Definition at line 1922 of file i_adminjob_impl.cpp.

References ie_IMPOSSIBLE.

void i_AdminJob_i::CheckMedium (  )  [private]

Definition at line 1429 of file i_adminjob_impl.cpp.

References dbg_DETAIL, ie_PRECONDITION, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_m, m_barcode, i_Job_i::m_rm, rmdb_MEDIUM_OFFLINE, rmdb_MEDIUM_UNRELIABLE, and rmdb_MEDIUM_UNUSABLE.

Referenced by CloseVolumeCheck(), Execute(), FormatAndInitCheck(), and RecreateFRIandMICCheck().

                              {
    log_FUNC_m(CheckMedium);
    i_Medium_t_var medium;
    try {
        ipc_EXEC_m(
            medium = m_rm->SelectMedium(m_barcode.c_str());
            log_DBG_m(dbg_DETAIL, "Medium with barcode " << m_barcode <<
                                  " selected!");
        )
    }
    catch (ivd_Exception) {
        throw ivd_Error(ie_PRECONDITION, "Could not find medium.", true);
    }

    m_medium = medium;

    // Check if medium is Usable for any operation
    if (   m_medium.status & rmdb_MEDIUM_UNRELIABLE
        || m_medium.status & rmdb_MEDIUM_UNUSABLE) {

        throw ivd_Error(ie_PRECONDITION, "Medium marked as UNRELIABLE or UNUSABLE.", true);
    }

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

Here is the caller graph for this function:

void i_AdminJob_i::CheckPartition (  )  [private]

Definition at line 1497 of file i_adminjob_impl.cpp.

References dbg_LOW, evt_WARNING, ie_PRECONDITION, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_m, log_WriteEvent(), m_mediaPool, i_Job_i::m_rm, i_MediaPool_t::mediaPoolName, and i_MediaPool_t::partitionUUIDString.

Referenced by FormatAndInitCheck().

                                  {
    log_FUNC_m(CheckPartition);

    i_PartSeq_t_var partitionSeq;

    // check if pool has partition associated.
    bool partitionFound(false);
    ipc_EXEC_m(partitionSeq = m_rm->SelectAllPartition();)

    string poolPartUUID(m_mediaPool.partitionUUIDString);

    for (UInt32_t i(0); i < partitionSeq->length(); i++) {
        if (string(partitionSeq[i].partitionUUIDString) == poolPartUUID) {
            partitionFound = true;
            break;
        }
    }

    if  (!partitionFound)  {
        ostringstream msg;
        msg << "Cannot initialize medium "  << m_medium.barcode <<
            " belonging to Pool " << m_mediaPool.mediaPoolName;
        msg << " which is not assigned to any partition.";
        log_DBG_m(dbg_LOW," msg : " << msg.str());
        log_WriteEvent(evt_WARNING, msg.str(), "", 0, string(m_medium.barcode));
        throw ivd_Error(ie_PRECONDITION, msg.str() ,true);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::CheckPool (  )  [private]

Definition at line 1460 of file i_adminjob_impl.cpp.

References dbg_DETAIL, dbg_LOW, ie_PRECONDITION, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_m, ipc_Log::LogMediaPool(), m_doCloseVolume, m_doFormat, m_doInit, m_mediaPool, i_Job_i::m_rm, i_MediaPool_t::mediaPoolType, and pt_Backup.

Referenced by CloseVolumeCheck(), FormatAndInitCheck(), and RecreateFRIandMICCheck().

                            {
    log_FUNC_m(CheckPool);

    i_MediaPool_t_var pool;
    // retrieve medium pool struct.

    try {
        ipc_EXEC_m(
            pool = m_rm->SelectMediaPool(m_medium.mediaPoolName);
        );
    } catch (ivd_Exception &e){
        log_DBG_m(dbg_LOW, e);
        ostringstream msg;
        if (m_doInit){
            msg << "Can not initialize medium "  << m_medium.barcode;
        } else if (m_doFormat) {
            msg << "Can not format medium "  << m_medium.barcode;
        }
        msg << " which is not assigned to any pool.";
        log_DBG_m(dbg_LOW," msg : " << msg.str());
        throw ivd_Error(ie_PRECONDITION, msg.str(), true);
    }

    m_mediaPool = pool;
    log_DBG_m(dbg_DETAIL, "Medium pool is configured. " << endl <<
                            ipc_Log::LogMediaPool(m_mediaPool));

    if (   (m_mediaPool.mediaPoolType == pt_Backup)
        && (m_doCloseVolume == true) ){
        ostringstream mssg;
        mssg << "Can not close volume on medium assigned to backup pool.";
        throw ivd_Error(ie_PRECONDITION, mssg.str(), true);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::CheckVolumesForFormatAndInit ( bool  a_log = true  )  [private]

Definition at line 1648 of file i_adminjob_impl.cpp.

References dbg_LOW, dbg_NORM, ui_MsgWriter::DisplayMessage(), evt_WARNING, FindVolInRMDB(), ie_PRECONDITION, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_m, log_WriteEvent(), m_doFormat, m_doInit, m_forced, m_initAllVol, m_initVol, m_mediaPool, m_medVolInRmdb, m_ui, i_MediaPool_t::mediaPoolType, pt_Backup, rmdb_MEDVOL_FULL, rmdb_MEDVOL_REORG_RECYCLED, i_MediumVol_t::status, svl_NONE, i_MediaPool_t::sysVolLocation, and i_MediumVol_t::volUsed.

Referenced by Execute(), and FormatAndInitCheck().

                                                          {
    log_FUNC_m(CheckVolumesForFormatAndInit);

    ostringstream opMsg;
    if (m_doFormat) {
        opMsg << "format ";
    }
    else if (m_doInit) {
        opMsg << "initialize ";
    }
    else if (m_doFormat & m_doInit){
        opMsg << "format and initialize ";
    }

    if ((m_mediaPool.mediaPoolType == pt_Backup) && m_forced ){
        //allow init of backup medium if --forced is used
        if (a_log){
            ostringstream msg;
            msg << "Admin Job will initialize backup medium "
                << m_medium.barcode;

            log_WriteEvent(msg.str(), "", 0, string(m_medium.barcode));
            ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)
                log_DBG_m(dbg_NORM, msg.str());
        }
        return;
    }

    if (m_initAllVol){
        // check if medium is initialized
        if (m_medVolInRmdb.length() > 0 && !m_forced ){
            //medium is initialized (forced option was not used)

            ostringstream msg;

            msg << "Cannot " << opMsg.str() << " medium "
                << m_medium.barcode << ": there are "
                << m_medVolInRmdb.length()
                << " volumes in RMDB. Use force option.";


            log_DBG_m(dbg_LOW," msg : " << msg.str());
            log_WriteEvent( evt_WARNING, msg.str(), "", 0,
                            string(m_medium.barcode));
            m_ui.DisplayMessage(msg.str());

            throw ivd_Error(ie_PRECONDITION, msg.str(), true);
        }
        if (m_medVolInRmdb.length() > 0 &&
            ivd_IsMediumTypeWORM(
                static_cast<ivd_MediaType_e>(m_medium.mediumType))){
            //medium is WORM and can not be initialized

            ostringstream msg;

            msg << "Cannot " << opMsg.str() <<
                   " already initialized WORM medium.";

            log_DBG_m(dbg_LOW," msg : " << msg.str());
            log_WriteEvent( evt_WARNING, msg.str(), "", 0,
                            string(m_medium.barcode));

            throw ivd_Error(ie_PRECONDITION, msg.str(), true);

        }

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

            if (m_medVolInRmdb[i].status & rmdb_MEDVOL_REORG_RECYCLED){
                if (a_log){
                    ostringstream msg;
                    msg << "Initializing recycled medium "  << m_medium.barcode
                        << " Volume Num: " << m_medVolInRmdb[i].medVolNr;
                    log_DBG_m(dbg_LOW," msg : " << msg.str());
                    log_WriteEvent(msg.str(), "", 0, string(m_medium.barcode));
                    m_ui.DisplayMessage(msg.str());
                }

            }
            else if ( m_medVolInRmdb[i].volUsed > 0 ||
                      m_medVolInRmdb[i].status & rmdb_MEDVOL_FULL){

                ostringstream msg;
                msg << "Can not " << opMsg.str() << "medium "  << m_medium.barcode
                    << " Volume Num: " << m_medVolInRmdb[i].medVolNr
                    << " contains data.";

                log_DBG_m(dbg_LOW," msg : " << msg.str());
                log_WriteEvent( evt_WARNING, msg.str(), "", 0,
                                string(m_medium.barcode));
                m_ui.DisplayMessage(msg.str());

                throw ivd_Error(ie_PRECONDITION, msg.str(), true);
            }
        }
    } else {
        log_DBG_m(dbg_NORM, "init particular volume(s): #" << m_initVol.size());

        if ( (m_mediaPool.sysVolLocation != svl_NONE) && (m_medium.idxOfSysVol == 0) ){

            ostringstream msg;
            msg << "Can not initialize single volume on medium with system volume "
                << m_medium.barcode << ". Initialize whole medium.";

            log_DBG_m(dbg_LOW," msg : " << msg.str());
            log_WriteEvent(evt_WARNING, msg.str(), "", 0,
                            string(m_medium.barcode));
            m_ui.DisplayMessage(msg.str());
            throw ivd_Error(ie_PRECONDITION, msg.str(), true);
        }

        for (UInt32_t i(0); i < m_initVol.size(); i++){

            UInt32_t volNum(m_initVol[i]);
            UInt32_t volIdxInRmdb(0);
            bool found(false);
            try {
                volIdxInRmdb = FindVolInRMDB(volNum);
                found = true;
            }
            catch (ivd_Error) {
                //found stays false
            }
            if (found){
                i_MediumVol_t &mv = m_medVolInRmdb[volIdxInRmdb];
                log_DBG_m(dbg_NORM, "Volume exists in rmdb");

                if (ivd_IsMediumTypeWORM(
                        static_cast<ivd_MediaType_e>(m_medium.mediumType))){
                    //medium is WORM and can not be initialized

                    ostringstream msg;

                    msg << "Cannot " << opMsg.str() <<
                        " already initialized WORM medium.";

                    log_DBG_m(dbg_LOW," msg : " << msg.str());
                    log_WriteEvent( evt_WARNING, msg.str(), "", 0,
                        string(m_medium.barcode));

                    throw ivd_Error(ie_PRECONDITION, msg.str(), true);
                }
                if (mv.status & rmdb_MEDVOL_REORG_RECYCLED){
                    if (a_log){
                        ostringstream msg;
                        msg << "Initializing recycled medium "  << m_medium.barcode
                            << " Volume Num: " << volNum;
                        log_DBG_m(dbg_LOW," msg : " << msg.str());

                        log_WriteEvent(msg.str(), "", 0, string(m_medium.barcode));

                        m_ui.DisplayMessage(msg.str());
                    }
                }
                else if ( mv.volUsed > 0 || mv.status & rmdb_MEDVOL_FULL ){

                    ostringstream msg;
                    msg << "Can not initialize medium "  << m_medium.barcode
                        << " Volume Num: " <<  volNum << " contains Data.";

                    log_WriteEvent(evt_WARNING, msg.str(), "", 0,
                        string(m_medium.barcode));
                    m_ui.DisplayMessage(msg.str());

                    throw ivd_Error(ie_PRECONDITION, msg.str(), true);

                } else if (!m_forced){

                    ostringstream msg;
                    msg << "Can not initialize medium "  << m_medium.barcode
                        << " Volume " << volNum << " exists in RMDB. Use force option.";

                    log_WriteEvent(evt_WARNING, msg.str(), "", 0,
                                    string(m_medium.barcode));

                    m_ui.DisplayMessage(msg.str());
                    throw ivd_Error(ie_PRECONDITION, msg.str(), true);
                }
            } else {
                log_DBG_m(dbg_NORM, "Volume does NOT exist in rmdb");
            }
            if (a_log){
                ostringstream msg;
                msg << "Admin Job will initialize medium "  << m_medium.barcode
                    << " Volume Num: " << volNum;
                log_WriteEvent(msg.str(), "", 0, string(m_medium.barcode));
                ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)
                log_DBG_m(dbg_NORM, msg.str());
            }
        } //for each in m_initVol
    }
} //CheckVolumesForFormatAndInit

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::CheckVolumesForFriMicJob (  )  [private]

Definition at line 1529 of file i_adminjob_impl.cpp.

References dbg_DETAIL, dbg_LOW, ui_MsgWriter::DisplayWarning(), evt_WARNING, FindVolInRMDB(), ie_PRECONDITION, ipc_EXEC_m, ivd_Error, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogMediumVol(), m_initAllVol, m_initVol, m_medVolInRmdb, i_Job_i::m_rm, m_ui, i_MediumVol_t::medVolNr, rmdb_MEDVOL_EMPTY, rmdb_MEDVOL_REORG_SCANNED, rmdb_SYSTEM_VOLUME, i_MediumVol_t::status, and i_MediumVol_t::volType.

Referenced by RecreateFRIandMICCheck().

                                            {
    log_FUNC_m(CheckVolumesForFriMicJob);

    if ( m_medVolInRmdb.length() == 0 ) {
        //can not recreate FRI if Volume is missing
        ostringstream msgErr;
        msgErr << "Medium has no initialized Volumes. CanÝt recreate FRI/MIC ";
        log_DBG_m(dbg_LOW," msg : " << msgErr.str());
        throw ivd_Error(ie_PRECONDITION, msgErr.str());
    }

    if (m_initAllVol){
        for (UInt32_t i(0); i < m_medVolInRmdb.length(); i++){
            i_MediumVol_t& mv = m_medVolInRmdb[i];
            if ((mv.status != rmdb_MEDVOL_EMPTY ) &&
                (mv.volType != rmdb_SYSTEM_VOLUME)){

                m_initVol.push_back(mv.medVolNr);
                log_DBG_m(dbg_LOW,"Will recreate FRI/MIC for volume: " <<
                                    mv.medVolNr);
            }
            else {
                ostringstream msgDbg;
                msgDbg << i << " skipping Volume " << mv.medVolNr
                       << " Status = " << mv.status
                       << " volType = " << mv.volType;
                log_DBG_m(dbg_LOW, msgDbg.str());
            }
        }
    }

    // check if there are any volumes on the list
    if ( 0 == m_initVol.size() ){
        //can not recreate FRI if Volume empty
        ostringstream msgErr;
        msgErr << "Medium does not have a single volume containing FRI relevant data.";
        log_DBG_m(dbg_LOW," msg : " << msgErr.str());
        throw ivd_Error(ie_PRECONDITION, msgErr.str());
    }

    for (UInt32_t i = 0; i < m_initVol.size(); i++){
        UInt32_t& volNum = m_initVol[i];

        UInt32_t idxRmdb;
        try {
            idxRmdb = FindVolInRMDB(volNum);
        }
        catch (ivd_Error) {
            ostringstream msgWrn;
            msgWrn << "Volume: " << volNum << " not found in RMDB." ;
            log_DBG_m(dbg_LOW," msg : " << msgWrn.str());
            log_WriteEvent(evt_WARNING, msgWrn.str(), "", 0,
                string(m_medium.barcode));
            ipc_EXEC_m(
                m_ui.DisplayWarning(msgWrn.str());
            );
            throw ivd_Error(ie_PRECONDITION, msgWrn.str());
        }

        i_MediumVol_t& mv = m_medVolInRmdb[idxRmdb];
        ipc_EXEC_m(
            if (mv.volType & rmdb_SYSTEM_VOLUME){
                ostringstream msgWrn;
                msgWrn << "Can not recreate FRI/MIC on System Volume: " <<
                            mv.medVolNr << "." ;
                log_DBG_m(dbg_LOW," msg : " << msgWrn.str());
                throw ivd_Error(ie_PRECONDITION, msgWrn.str());
            }

            if ( mv.status == rmdb_MEDVOL_EMPTY ){
                //can not recreate FRI if Volume empty
                ostringstream msgWrn;
                msgWrn << "Can not recreate FRI/MIC on empty Volume:"  <<
                            mv.medVolNr << ".";
                log_DBG_m(dbg_LOW," msg : " << msgWrn.str());
                throw ivd_Error(ie_PRECONDITION, msgWrn.str());
            }
        )

        // clear reorg scanned flag
        try{
            log_DBG_m(dbg_DETAIL,
                "Clearing reorg scanned flag for volume: " << endl <<
                ipc_Log::LogMediumVol(mv));
            ipc_EXEC_m (
                m_rm->MedVolStatusClear(
                mv.medVolId,
                rmdb_MEDVOL_REORG_SCANNED
                );
            )
        } catch (...){
            log_ERR_m("Clearing reorg scanned flag failed for volume '"
                << mv.medVolId << "' (BC: " << mv.mediumBarcode
                << ", Vol.: " << mv.medVolId << ")");
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::CheckVolumesForVolumeClose (  )  [private]

Definition at line 1844 of file i_adminjob_impl.cpp.

References dbg_NORM, ui_MsgWriter::DisplayMessage(), evt_WARNING, FindVolInRMDB(), ie_PRECONDITION, ivd_Error, log_DBG_m, log_FUNC_m, log_WriteEvent(), m_initVol, m_medVolInRmdb, m_ui, rmdb_MEDVOL_EMPTY, rmdb_MEDVOL_FULL, rmdb_SYSTEM_VOLUME, i_MediumVol_t::status, and i_MediumVol_t::volType.

Referenced by CloseVolumeCheck().

                                             {
    log_FUNC_m(CheckVolumesForVolumeClose);

    if (m_initVol.size() > 1){
        ostringstream msg;
        msg << "Can not close several volumes at once. "  << m_medium.barcode;

        log_WriteEvent(evt_WARNING, msg.str(), "", 0,
            string(m_medium.barcode));
        m_ui.DisplayMessage(msg.str());
        throw ivd_Error(ie_PRECONDITION, msg.str(), true);
    } else if (m_initVol.size() != 1) {
        throw ivd_Error(ie_PRECONDITION, "Number of volumes should be 1.", true);
    }

    log_DBG_m(dbg_NORM, "Will close volume:" << m_initVol[0]);

    UInt32_t volIdxinRmdb(0);
    try {
        volIdxinRmdb = this->FindVolInRMDB(m_initVol[0]);
    }
    catch (ivd_Error){
        ostringstream msg;
        msg << "Can not close volume. Volume is not initialized.";

        log_WriteEvent(evt_WARNING, msg.str(), "", 0,
            string(m_medium.barcode));
        m_ui.DisplayMessage(msg.str());
        throw ivd_Error(ie_PRECONDITION, msg.str(), true);
    }

    i_MediumVol_t &mv = m_medVolInRmdb[volIdxinRmdb];

    if (mv.status & rmdb_MEDVOL_FULL){
        ostringstream msg;
        msg << "Can not close volume. Volume already closed.";

        log_WriteEvent(evt_WARNING, msg.str(), "", 0,
            string(m_medium.barcode));
        m_ui.DisplayMessage(msg.str());
        throw ivd_Error(ie_PRECONDITION, msg.str(), true);
    }

    if (mv.status == rmdb_MEDVOL_EMPTY){
        ostringstream msg;
        msg << "Can not close volume. Volume is empty.";

        log_WriteEvent(evt_WARNING, msg.str(), "", 0,
            string(m_medium.barcode));
        m_ui.DisplayMessage(msg.str());
        throw ivd_Error(ie_PRECONDITION, msg.str(), true);
    }

    if (mv.volType == rmdb_SYSTEM_VOLUME) {
        ostringstream msg;
        msg << "Can not close system volume. ";

        log_WriteEvent(evt_WARNING, msg.str(), "", 0,
            string(m_medium.barcode));
        m_ui.DisplayMessage(msg.str());
        throw ivd_Error(ie_PRECONDITION, msg.str(), true);
    }
}//CheckVolumesForVolumeClose

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::CloseVolume (  )  [private]

Definition at line 1233 of file i_adminjob_impl.cpp.

References dbg_DETAIL, dbg_LOW, ui_MsgWriter::DisplayError(), ui_MsgWriter::DisplayMessage(), evt_ERROR, ivd_BaseException::GetFriendly(), i_Job_i::GetResources(), ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_activeBeas, i_Job_i::m_iJobParams, m_initVol, i_Job_i::m_rm, m_ui, i_MediumVol_t::medVolId, i_Resource_t::medVolId, and i_Resource_t::medVolNr.

Referenced by Execute().

                              {
    log_FUNC_m(CloseVolume);

    i_Resource_t tmpRes;
    tmpRes = GetResources()[0];

    for (UInt32_t i = 0; i < m_initVol.size(); ++i) {
        ostringstream msgBase;
        msgBase <<  "Medium " << m_medium.barcode
                << ", volume " << m_initVol[i] << ": ";

        ostringstream msg;
        try {
            log_DBG_m(dbg_LOW,
                "[" << m_iJobParams.jobID << "] " << "Volume Close:" );
            //
            // close Volume for volume.
            if (IsAborted()) return;

            //send message to cli
            ostringstream msg;
            msg << msgBase.str() << "Closing volume...";
            ipc_EXEC_m(m_ui.DisplayMessage(msg.str()););

            log_WriteEvent(msg.str(), evt_ADMINJOB, m_iJobParams.jobID);

            ipc_EXEC_m( m_activeBeas[0]->CloseMediumVolume(m_initVol[i]); );

            log_DBG_m(dbg_DETAIL, "[" << m_iJobParams.jobID <<
                                "] " << "BEA->CloseMediumVolume() returned");
        } catch (ivd_Exception &e){
            // mark volume as closed
            try {
                ipc_EXEC_m( m_rm->VolumeFull(GetResources()[0].medVolId); );
            } catch (ivd_Error &e) {
                log_ERR_m("[" << m_iJobParams.jobID <<
                    "] " << "VolumeClose Failed to mark Volume as Full" << endl << e);
            }
            log_ERR_m("[" << m_iJobParams.jobID <<
                                      "] " << "VolumeClose Failed:" << endl << e);
            msg << msgBase.str() << "VolumeClose failed (" << e.GetFriendly() << ").";
            log_WriteEvent(evt_ERROR, msg.str(), evt_ADMINJOB,
                           m_iJobParams.jobID, string(m_medium.barcode));

            ipc_EXEC_m( m_ui.DisplayError(msg.str()); )
        }
        msg.str("");

        if ( i+1 < m_initVol.size() ) {
            // Get medium volume ID for next volume and sent data to BEA
            // to be able to use the resources properly.
            ipc_EXEC_m(
                i_MediumVol_t_var medVol(
                m_rm->SelectMediumVol(m_medium.barcode, m_initVol[i+1]) );
                tmpRes.medVolId = CORBA::string_dup(medVol->medVolId);
                tmpRes.medVolNr = m_initVol[i+1];
            );
            m_activeBeas[0]->UseResources(tmpRes);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::CloseVolumeCheck (  ) 

Definition at line 206 of file i_adminjob_impl.cpp.

References CheckMedium(), CheckPool(), CheckVolumesForVolumeClose(), log_FUNC_m, and SetVolumes().

Referenced by InitJob().

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::CompleteJob ( i_CompletionStatus_e  status  )  [virtual]

Implements i_Job_i.

Definition at line 232 of file i_adminjob_impl.cpp.

References ipc_CATCH_IVD_THROW_CORBA_m, log_FUNC_m, and i_Job_i::Remove().

                                                            {

    log_FUNC_m(CompleteJob);
    try {
        Remove();
    }
    ipc_CATCH_IVD_THROW_CORBA_m
} // i_AdminJob_i::CompleteJob

Here is the call graph for this function:

void i_AdminJob_i::DeleteMedVolFromRMDB ( string  a_barcode,
Int32_t  a_medVolNum 
) [private]

Definition at line 352 of file i_adminjob_impl.cpp.

References i_Medium_t::barcode, dbg_NORM, ipc_EXEC_m, i_JobParams::jobID, log_DBG_m, log_FUNC_m, log_WRN_m, i_Job_i::m_iJobParams, m_medium, and i_Job_i::m_rm.

Referenced by Format(), and Initialize().

                                                                             {
    log_FUNC_m(DeleteMedVolFromRMDB);
    log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                        "] " << "Removing volume " << a_medVolNum
                        << " on medium " << a_barcode );
    try {
        ipc_EXEC_m(m_rm->RemoveMediumVol(
                                    m_medium.barcode,
                                    a_medVolNum);
        )
    } catch (ivd_Exception& e){
        log_WRN_m("[" << m_iJobParams.jobID <<
                  "] " << "ADMIN JOB: Error Deleting Volume in RMDB" << e); //log and ignore
    }
}

Here is the caller graph for this function:

void i_AdminJob_i::DetectVolumeHeader ( i_VolInfo_t_var &  a_volInfo,
Int32_t  a_volumeNr 
) [private]

Definition at line 797 of file i_adminjob_impl.cpp.

References dbg_DETAIL, dbg_LOW, ui_MsgWriter::DisplayError(), ui_MsgWriter::DisplayMessage(), evt_ERROR, g_cmn, ivd_BaseException::GetFriendly(), i_VOL_BLANK, i_VOL_ECMA, i_VOL_IVD, i_VOL_IVD_NT, i_VOL_OTHER, i_VOL_TAR, ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogVolInfo(), i_Job_i::m_activeBeas, i_Job_i::m_iJobParams, m_lastAccessedVolume, ivd_Product::m_nameShort, m_ui, and cmn_Global::prod.

Referenced by Format(), and InitializeSingleVolume().

                                                                                   {
    log_FUNC_m(DetectVolumeHeader);
    ostringstream msgBase;
    msgBase <<  "Medium " << m_medium.barcode << ", volume " << a_volumeNr << ": ";
    ostringstream msg;
    msg << msgBase.str();
    try {
        ipc_EXEC_m(
            a_volInfo = m_activeBeas[0]->GetVolInfo(a_volumeNr);
            m_lastAccessedVolume = a_volumeNr;
        )
    } catch (ivd_Exception &e){
        log_ERR_m("[" << m_iJobParams.jobID <<
            "] " << "Get volume info failed:" << endl << e);
        msg << "Get volume size failed (" << e.GetFriendly() << ").";
        log_WriteEvent(evt_ERROR, msg.str(), evt_ADMINJOB,
            m_iJobParams.jobID, string(m_medium.barcode));
        m_ui.DisplayError(msg.str());
        throw;
    }

    if (IsAborted()) return;
    log_DBG_m(dbg_DETAIL,   "[" << m_iJobParams.jobID <<
                            "] " << "Found volume" <<
                            endl << ipc_Log::LogVolInfo(a_volInfo));

    msg.str("");
    msg << msgBase.str();
    switch (a_volInfo->type) {
        case i_VOL_BLANK:
            msg << "Blank volume detected.";
            break;
        case i_VOL_IVD:
            msg << g_cmn.prod.m_nameShort << " volume detected.";
            break;
        case i_VOL_ECMA:
            msg << "ECMA volume detected.";
            break;
        case i_VOL_TAR:
            msg << "TAR volume detected.";
            break;
        case i_VOL_IVD_NT:
            msg << "IVD NT volume detected.";
            break;
        case i_VOL_OTHER:
            msg<< "Unknown volume type detected.";
            break;
    }
    log_DBG_m(dbg_LOW,  "[" << m_iJobParams.jobID <<
                        "] " << msg.str());
    ipc_EXEC_m( m_ui.DisplayMessage(msg.str());)
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::DoInitialize ( Int32_t  a_volumeNr,
Int32_t  a_size 
) [private]

Definition at line 978 of file i_adminjob_impl.cpp.

References i_MediumVol_t::accessNr, i_VolInfo_t::accessNum, i_MediumVol_t::accessTime, i_VolInfo_t::appendNum, i_MediaPool_t::blockSize, i_VolInfo_t::blockSize, dbg_DETAIL, dbg_LOW, dbg_NORM, ui_MsgWriter::DisplayError(), ui_MsgWriter::DisplayMessage(), evt_ERROR, FindVolInRMDB(), ivd_BaseException::GetFriendly(), i_VolInfo_t::implID, i_MediumVol_t::initTime, ipc_EXEC_m, ipc_nilStr, i_JobParams::jobID, i_MediumVol_t::lastVerification, log_DBG_m, log_ERR_m, log_FUNC_A_m, log_WriteEvent(), ipc_Log::LogMediumVol(), ipc_Log::LogVolInfo(), i_Job_i::m_activeBeas, m_doFormat, m_idxSysVol, i_Job_i::m_iJobParams, m_mediaPool, m_medVolInRmdb, i_Job_i::m_rm, m_ui, i_MediumVol_t::mediumBarcode, i_VolInfo_t::medVolID, i_MediumVol_t::medVolId, i_MediumVol_t::medVolNr, NULL, 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, rmdb_DATA_VOLUME, rmdb_SYSTEM_VOLUME, i_VolInfo_t::size, i_MediumVol_t::status, i_VolInfo_t::sysVolNum, cmn_UUID_t::ToString(), i_MediumVol_t::totalData, i_VolInfo_t::type, i_MediumVol_t::validData, i_VolInfo_t::volNum, i_MediumVol_t::volSize, i_MediumVol_t::volType, i_MediumVol_t::volUsed, i_MediumVol_t::writeNr, and i_MediumVol_t::writeTime.

Referenced by InitializeSingleVolume().

                                                {
    log_FUNC_A_m(DoInitialize, "[" << m_iJobParams.jobID <<
                                  "] " << "a_volumeNr=" << a_volumeNr <<
                               " a_size=" << a_size);
    cmn_UUID_t uuid;
    ivd_Time_t now  = time(NULL);

    //is there a medVol Record already in RMDB for this volume?
    bool found(false);
    i_MediumVol_t medVol;
    try {
        medVol = m_medVolInRmdb[FindVolInRMDB(a_volumeNr)];
        found = true;
    }
    catch (ivd_Error) {
        found = false;
    }

    if (!found){
        medVol.mediumBarcode    = m_medium.barcode;
        medVol.medVolNr         = a_volumeNr;
        medVol.status           = 0;
        medVol.accessNr         = 0;
        medVol.owriteNr         = 0;
        medVol.writeNr          = 0;
    }

    medVol.medVolId         = CORBA::string_dup(uuid.ToString().c_str());
    medVol.volType          = (a_volumeNr == m_idxSysVol) ?
                              rmdb_SYSTEM_VOLUME : rmdb_DATA_VOLUME ;
    medVol.status           = rmdb_MEDVOL_EMPTY;
    medVol.volUsed          = 0;
    medVol.volSize          = a_size;
    medVol.initTime         = now;           
    medVol.accessTime       = 0;             
    medVol.writeTime        = 0;             
    medVol.owriteTime       = now;             
    medVol.owriteNr         += 1;           // nw: are there any issues when reaching the top?
    medVol.lastVerification = 0;             
    medVol.totalData        = 0;
    medVol.validData        = 0;
    log_DBG_m(dbg_LOW, "[" << m_iJobParams.jobID <<
                       "] " << "Init:" << endl << ipc_Log::LogMediumVol(medVol));

    i_VolInfo_t volInfo;
    volInfo.volNum      = a_volumeNr;
    volInfo.implID      = CORBA::string_dup(ipc_nilStr);
    volInfo.size        = 0;
    volInfo.type        = i_VOL_IVD;
    volInfo.sysVolNum   = m_idxSysVol;
    volInfo.medVolID    = CORBA::string_dup(uuid.ToString().c_str());
    log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
                         "] " << "MediaPoolUUID : " << m_mediaPool.poolUUIDString);

    volInfo.poolID      = m_mediaPool.poolUUIDString;
    volInfo.partID      = m_iJobParams.partUUID;
    volInfo.blockSize   = m_mediaPool.blockSize;

    volInfo.accessNum   = 0;
    volInfo.appendNum   = 0;
    volInfo.owriteNum   = 0;

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

    try {
        ipc_EXEC_m(
            m_activeBeas[0]->Init(volInfo);
            log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                  "] " << "BEA->Init() returned");

        );
        if (a_volumeNr == m_idxSysVol){
            //Update Medium Record with SysVol
            i_Medium_t_var iMed;
            ipc_EXEC_m(iMed = m_rm->SelectMedium(m_medium.barcode););
            m_medium = iMed;
            m_medium.idxOfSysVol = m_idxSysVol;
            ipc_EXEC_m(m_rm->UpdateMedium(m_medium););
        }
    } catch (ivd_Exception &e){
        log_ERR_m("[" << m_iJobParams.jobID <<
                                  "] " << "Init Failed:" << endl << e);
        msg << msgBase.str() << "Init failed (" << e.GetFriendly() << ").";
        log_WriteEvent(evt_ERROR, msg.str(), evt_ADMINJOB,
                       m_iJobParams.jobID, string(m_medium.barcode));
        m_ui.DisplayError(msg.str());
        return;
    }



    try {
        ipc_EXEC_m(
            if (found && !m_doFormat) { //format deletes all Volumes
                m_rm->UpdateMediumVol(medVol);
            } else {
                // add volume record to RMDB.
                m_rm->AddMediumVol(medVol);
            }
        )
    } catch (ivd_Exception &e){
        msg << msgBase.str()
            << "Insert/update of new volume failed ("
            << e.GetFriendly() << ").";
        log_ERR_m("[" << m_iJobParams.jobID <<
                  "] " << msg.str() << endl << e);
        log_WriteEvent(evt_ERROR, msg.str(), evt_ADMINJOB,
                       m_iJobParams.jobID, string(m_medium.barcode));
        m_ui.DisplayError(msg.str());
        return;
    }

    msg << msgBase.str() << "Volume initialized.";
    ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)

} // i_AdminJob_i::DoInitialize

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements i_Job_i.

Definition at line 1299 of file i_adminjob_impl.cpp.

References CheckMedium(), CheckVolumesForFormatAndInit(), CloseVolume(), dbg_DETAIL, dbg_NORM, ui_MsgWriter::DisplayMessage(), i_Job_i::Finished(), Format(), i_Job_i::GetResources(), Initialize(), ipc_EXEC_m, i_Job_i::IsAborted(), i_Job_i::IsFinished(), job_MED_PROC, i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_activate_c, i_Job_i::m_activate_x, m_doCloseVolume, m_doFormat, m_doFri, m_doInit, m_doMic, i_Job_i::m_iJobParams, i_Job_i::m_rm, i_Job_i::m_status, m_ui, i_Job_i::NeedsProcess(), OperateLA(), RecreateFRIandMIC(), i_Job_i::SetDriveProperties(), i_Job_i::SetResProcessed(), i_Job_i::SetResRequested(), i_Job_i::SetStatus(), SetVolumes(), StartBEA(), and cmn_Condition::Wait().

                          {
    log_FUNC_m(Execute);
    try {
        try {
            ipc_EXEC_m(
                ostringstream msg;
                msg << "Started.";

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

                log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                    "] " << "ADMIN JOB: Started.");

                log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                    "] " << " waiting for resource allocation.");

                msg.str("");
                msg << "Requesting resources...";
                m_ui.DisplayMessage(msg.str());
                SetStatus(job_MED_PROC);

                SetResRequested(0);
                m_rm->GetResources(this->_this(), m_iJobParams, GetResources());
            )
        }
        catch (ivd_Exception &ex) {
            log_ERR_m("[" << m_iJobParams.jobID << "] "
                        "Caught exception in n calling RM GetResources: " << ex);
            m_status = i_RESOURCE_ERROR;
            throw;
        }
        ipc_EXEC_m(

            while ( !IsFinished() &&
                    !IsAborted() ) {

                cmn_MutexLock l(m_activate_x);

                if (!IsAborted()){
                    for (UInt32_t i = 0 ; i < GetResources().length(); i++){
                        log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                                            "] " << "Processing copyNum:" << i <<
                                             " resources assigned:" << boolalpha <<
                                             GetResources()[i].resAssigned <<
                                             " copy processed:" << boolalpha <<
                                             GetResources()[i].resProcessed);

                        if (NeedsProcess(i)) {

                            if( m_doFormat || m_doInit ){
                                CheckMedium();
                                SetVolumes();
                                CheckVolumesForFormatAndInit(false);
                            }
                            SetDriveProperties(i);

                            if (IsAborted()) return;

                            rm_Resource_t rmRes;
                            rmRes = GetResources()[i];
                            OperateLA(rmRes);

                            if (IsAborted()) return;

                            StartBEA();
                            //
                            // format (partition) medium.
                            if (IsAborted()) return;

                            SetResProcessed(i);
                            if (m_doFormat) {
                                Format();
                            }

                            if (IsAborted()) return;
                            //
                            // initialize medium volume(s).
                            if (m_doInit) {
                                Initialize();
                            };

                            if (IsAborted()) return;
                            //
                            // Recreate FRI.
                            if (m_doFri || m_doMic) {
                                RecreateFRIandMIC();
                            };

                            if (m_doCloseVolume) {
                                CloseVolume();

                        }
                        Finished();
                        break;
                    }
                }
                if (!IsFinished() &&
                    !IsAborted()) {

                    log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
                                            "] " <<  " waiting for resources ...");
                    m_activate_c.Wait();
                }

                }
            }
            m_status = i_SUCCEDED;
        )
    }
    catch (ivd_Exception &ex) {
        log_ERR_m("Caught exception in Execute(): " << ex);
        m_status = i_FAILED;
        throw;
    }
    catch (ivd_InternalError &ie){
        log_ERR_m("Caught internal Error in Execute(): " << ie);
        m_status = i_FAILED;
        throw;
    }
    catch (...) {
        log_ERR_m("Caught unknown error in Execute().");
        m_status = i_FAILED;
        throw;
    }
} // mif_AdminJobExecutor::Run

Here is the call graph for this function:

UInt32_t i_AdminJob_i::FindVolInRMDB ( UInt32_t  a_volNum  )  [private]

Definition at line 1911 of file i_adminjob_impl.cpp.

References ie_NOTFOUND, ivd_Error, log_FUNC_m, and m_medVolInRmdb.

Referenced by CheckVolumesForFormatAndInit(), CheckVolumesForFriMicJob(), CheckVolumesForVolumeClose(), DoInitialize(), InitializeSingleVolume(), and RecreateFRIandMIC().

                                                     {
    log_FUNC_m(FindVolInRMDB);
    for (UInt32_t i(0); i < m_medVolInRmdb.length(); i++){
        if (static_cast<UInt32_t>(m_medVolInRmdb[i].medVolNr) == a_volNum){
            return i;
        }
    }
    throw ivd_Error(ie_NOTFOUND, "Volume Number not found in RMDB");
}

Here is the caller graph for this function:

void i_AdminJob_i::Format (  )  [private]

The formula:

input:

  • N data partitions
  • SS sys partition size (and position)
  • TS tape size (in MB)

calculation OH = 262 (overhead per partition) MC = 1.138 (factor by which the specified size is increased by AIT drive; Murphy constant ;) ) TS = 50972 MB (AIT-2 in AIT mode)

SS' = SS/MC DS = (TS-SS-N*OH)/N

DS'=DS/MC

Definition at line 392 of file i_adminjob_impl.cpp.

References i_Medium_t::barcode, cfg_MAX_VOLUME_NUM, i_Medium_t::currentVolume, dbg_LOW, dbg_NORM, DeleteMedVolFromRMDB(), DetectVolumeHeader(), ui_MsgWriter::DisplayError(), ui_MsgWriter::DisplayMessage(), ui_MsgWriter::DisplayWarning(), evt_ERROR, evt_WARNING, ivd_BaseException::GetFriendly(), i_VOL_OTHER, i_Medium_t::idxOfSysVol, ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_activeBeas, m_doInit, m_forced, m_idxSysVol, i_Job_i::m_iJobParams, m_mediaPool, m_medium, m_medVolInRmdb, i_Job_i::m_rm, m_ui, i_Medium_t::mediumType, MIF_MEDIUM_AIT2_VOLUME_OVERHEAD, MIF_MEDIUM_AIT2_VOLUMESIZE_FACTOR, mt_DISK, i_MediaPool_t::numOfVolumes, i_Medium_t::numOfVolumes, SetSysVolIdx(), i_MediaPool_t::sizeOfSysVol, i_MediaPool_t::sizeOfVolume, i_Medium_t::status, svl_NONE, and i_MediaPool_t::sysVolLocation.

Referenced by Execute().

                          {
    log_FUNC_m(Format);

    if (IsAborted()) return;
    // delete all medium volume entries.
    try {
        ipc_EXEC_m(
            i_Medium_t_var iMed = m_rm->SelectMedium(m_medium.barcode);
            m_medium = iMed;
            m_medium.currentVolume = 0;
            m_medium.numOfVolumes = 0;
            m_medium.idxOfSysVol = 0;
            m_medium.status = m_medium.status & ~rmdb_MEDIUM_OPEN;
            m_rm->UpdateMedium(m_medium);
        )
    } catch (ivd_Exception &e){
        log_ERR_m("[" << m_iJobParams.jobID << "] " << e);
    }

    for (UInt32_t ct = 0; ct < m_medVolInRmdb.length(); ct++) {
        try {
            ipc_EXEC_m(
                if (IsAborted()) return;
                DeleteMedVolFromRMDB(   string(m_medium.barcode),
                                        m_medVolInRmdb[ct].medVolNr);
            )
        } catch (ivd_Exception &e){
            log_ERR_m("[" << m_iJobParams.jobID << "] " << e);
        }
    }

    // calculate whole medium size.
    UInt32_t wholeSize(0);
    UInt32_t numOfVolOnMed(0);
    i_VolSizes_t newVolSizes;

    //Check if there are some volumes
    i_VolSizes_t_var volumeSizes;
    ipc_EXEC_m(
        volumeSizes = m_activeBeas[0]->GetVolumeSizes();
    );

    numOfVolOnMed = volumeSizes->length();
    log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
        "] " << "Medium volumes found: " << numOfVolOnMed << ".");

    if (m_medium.mediumType == mt_DISK) {
        i_VolSize_t medSize;
        ipc_EXEC_m(
            medSize = m_activeBeas[0]->GetMediumSize();
            log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                "] " << "Medium Size: " << medSize << ".");
        );
        UInt32_t volNum = medSize / m_mediaPool.sizeOfVolume;
        if (volNum > cfg_MAX_VOLUME_NUM){
            ostringstream msg;
            msg << "Medium " << m_medium.barcode
                << ": only 255 volumes will be created "
                <<"(not all disk space will be used).";

            ipc_EXEC_m(m_ui.DisplayWarning(msg.str()););
            log_WriteEvent(evt_WARNING, msg.str(), "", m_iJobParams.jobID);
            volNum = cfg_MAX_VOLUME_NUM;
        }
        if (volNum > 0){
            newVolSizes.length(volNum);
        } else {
            newVolSizes.length(1);
        }
        for (UInt32_t j(0); j < newVolSizes.length(); j++){
            newVolSizes[j] = m_mediaPool.sizeOfVolume;
            log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                "] " << "New volSize["<< j << "] " << newVolSizes[j] << ".");
        }
    }
    else {
        for (UInt32_t ct = 0; ct < numOfVolOnMed; ct++) {
            //wholeSize += (volumeSizes[ct] + MIF_MEDIUM_AIT2_VOLUME_OVERHEAD);
                wholeSize += volumeSizes[ct];
        };
        wholeSize += ( numOfVolOnMed - 1 ) * MIF_MEDIUM_AIT2_VOLUME_OVERHEAD;
        log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                "] "  <<
                                "Medium total size [MB]: " << wholeSize << ".");
        if (IsAborted()){
            return;
        }

        //
        // generate structure with volume sizes.
        log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                            "] " << "Calculating volume sizes, which will be passed to BEA.");


        newVolSizes.length(m_mediaPool.numOfVolumes);

        UInt32_t dataVolumeSize(0);

        // media pool has system volume.
        if ( (m_mediaPool.numOfVolumes > 1) && (m_mediaPool.sysVolLocation != svl_NONE) ) {
            dataVolumeSize = (
                                wholeSize
                                - m_mediaPool.sizeOfSysVol
                                - (m_mediaPool.numOfVolumes - 1) * MIF_MEDIUM_AIT2_VOLUME_OVERHEAD

                            ) / (m_mediaPool.numOfVolumes - 1);


            UInt32_t sysVolumeSize = UInt32_t(m_mediaPool.sizeOfSysVol
                                    / MIF_MEDIUM_AIT2_VOLUMESIZE_FACTOR);

            log_DBG_m(dbg_LOW,"[" << m_iJobParams.jobID <<
                            "] " << "sysVolumeSize = " << sysVolumeSize);

            dataVolumeSize = UInt32_t(dataVolumeSize
                                    / MIF_MEDIUM_AIT2_VOLUMESIZE_FACTOR);

            log_DBG_m(dbg_LOW,"[" << m_iJobParams.jobID <<
                            "] " << "dataVolumeSize = " << dataVolumeSize);
            SetSysVolIdx(m_mediaPool.numOfVolumes);

            for (UInt32_t ct = 0; ct < m_mediaPool.numOfVolumes - 1; ct++) {
                //counter is from 0 to numOfVol - 1,
                //m_idxSysVol is absolute number on medium (1 - numofVol)
                if (ct == (UInt32_t(m_idxSysVol) - 1) ) {
                    newVolSizes[ct] = sysVolumeSize;
                    log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                    "] " << "System volume, BEA-passed size [MB]: " <<
                                        sysVolumeSize);
                } else {
                    newVolSizes[ct] = dataVolumeSize;
                    log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                    "] " << "Volume " << ct + 1 <<
                                        ", BEA-passed size [MB]: " << dataVolumeSize);
                }
            }
        }
        else { // media pool does not have system volume.
            dataVolumeSize = UInt32_t(((wholeSize
                            - m_mediaPool.numOfVolumes * MIF_MEDIUM_AIT2_VOLUME_OVERHEAD)
                            / m_mediaPool.numOfVolumes)
                            / MIF_MEDIUM_AIT2_VOLUMESIZE_FACTOR);

            for (UInt32_t ct = 0; ct < m_mediaPool.numOfVolumes - 1; ct++) {
                newVolSizes[ct] = dataVolumeSize;
                log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                    "] " << "Volume " << ct + 1 <<
                                    ", BEA-passed size [MB]: " << dataVolumeSize);
            }
        }
        newVolSizes[m_mediaPool.numOfVolumes - 1] = 1;
        log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                    "] " << "Volume, real BEA size [MB]: 1");

        ostringstream msg;
        msg << "Medium " << m_medium.barcode << ": Formatting started.";
        ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)
    }


    // Check if volume is initialized
    i_VolInfo_t_var volInfo;
    bool foundHdr(false);
    if (!m_forced && (numOfVolOnMed > 0)) {
        DetectVolumeHeader(volInfo, 1);
        foundHdr = (volInfo->type != i_VOL_BLANK) && (volInfo->type != i_VOL_OTHER);
    } else log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                               "] " << "No need to detect volume header");

    if ( (numOfVolOnMed == 0) || !foundHdr || m_forced ){
        try {
            ipc_EXEC_m(
                log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                    "] " << "Structure passed to BEA, size " <<
                                    newVolSizes.length() );
                m_activeBeas[0]->Format(newVolSizes, false);
            )
        } catch (ivd_Exception &e){
            log_ERR_m("[" << m_iJobParams.jobID <<
                    "] " << "Format failed:" << endl << e);
            ostringstream msg;
            msg << "Format failed (" << e.GetFriendly() << ").";
            log_WriteEvent(evt_ERROR, msg.str(), evt_ADMINJOB,
                        m_iJobParams.jobID, string(m_medium.barcode));
            m_ui.DisplayError(msg.str());
            m_doInit = false;
            return;
        }
    } else {
        ostringstream msg;
        msg << "[" << m_iJobParams.jobID <<
                "] " << "Format failed. Medium contains HSM/ECMA header";
        log_WriteEvent(evt_ERROR, msg.str(), evt_ADMINJOB,
            m_iJobParams.jobID, string(m_medium.barcode));
        m_ui.DisplayError(msg.str());
        m_doInit = false;
        return;
    }

    ostringstream msg;
    msg << "Medium " << m_medium.barcode
        << ": Formatting finished successfully, "
        << newVolSizes.length() << " volumes created.";
    ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)

    //
    // print actually written volume sizes.
    i_VolSizes_t_var volSizesAfterFmt;
    ipc_EXEC_m(
        volSizesAfterFmt = m_activeBeas[0]->GetVolumeSizes();
    );

    for (UInt32_t ct = 0; ct < volSizesAfterFmt->length(); ct++) {
        log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                            "] " << "Volume " << ct + 1 <<
                            ", actual size on medium [MB]: " << volSizesAfterFmt[ct]);
    }


    try {
        ipc_EXEC_m(
            i_Medium_t_var iMed = m_rm->SelectMedium(m_medium.barcode);
            m_medium = iMed;
            // update medium record in RMDB with actual medium status after formatting.

            m_medium.numOfVolumes = volSizesAfterFmt->length();
            m_medium.idxOfSysVol = 0; //this will be set when SysVol is initialized
            m_rm->UpdateMedium(m_medium);
        )
    } catch (ivd_Exception& e){
        log_ERR_m("[" << m_iJobParams.jobID <<
                  "] " << "Error While updating medium record after Format" << e)
    }

} // i_AdminJob_i::Format()

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::FormatAndInitCheck (  ) 

Definition at line 180 of file i_adminjob_impl.cpp.

References CheckMedium(), CheckPartition(), CheckPool(), CheckVolumesForFormatAndInit(), log_FUNC_m, m_doInit, m_mediaPool, i_MediaPool_t::mediaPoolType, pt_Backup, and SetVolumes().

Referenced by InitJob().

Here is the call graph for this function:

Here is the caller graph for this function:

i_JobRequestList_t * i_AdminJob_i::GetFiles ( void   )  [virtual]

Implements i_Job_i.

Definition at line 243 of file i_adminjob_impl.cpp.

References ie_FATAL_ERROR, ipc_CATCH_IVD_THROW_CORBA_m, and log_FUNC_m.

                                           {
    log_FUNC_m(GetFiles);
    try {
        throw ivd_InternalError(ie_FATAL_ERROR);
    }
    ipc_CATCH_IVD_THROW_CORBA_m
} // i_AdminJob_i::GetFiles

i_FSC_ptr i_AdminJob_i::GetFSC ( void   )  [virtual]

Implements i_Job_i.

Definition at line 253 of file i_adminjob_impl.cpp.

References ie_IMPOSSIBLE, ipc_CATCH_IVD_THROW_CORBA_m, ivd_Error, and log_FUNC_m.

                               {
    log_FUNC_m(GetFSC);
    try {
        i_FSC_ptr dummy;
        throw ivd_Error(ie_IMPOSSIBLE);
        return dummy;
    }
    ipc_CATCH_IVD_THROW_CORBA_m
} // i_AdminJob_i::GetFSC

void i_AdminJob_i::GetNewResources ( i_Index_t  resourceNumber  )  [virtual]

Implements i_Job_i.

Definition at line 129 of file i_adminjob_impl.cpp.

References i_Job_i::GetResources(), ie_FATAL_ERROR, and log_FUNC_m.

                                                     {
    log_FUNC_m(GetResources);
    try {
        throw ivd_InternalError(ie_FATAL_ERROR);
    } ipc_CATCH_IVD_THROW_CORBA_m;
} // i_AdminJob_i::GetResources

Here is the call graph for this function:

void i_AdminJob_i::Initialize ( void   )  [private]

Definition at line 649 of file i_adminjob_impl.cpp.

References i_Medium_t::barcode, i_MediaPool_t::blockSize, dbg_DETAIL, dbg_LOW, dbg_NORM, DeleteMedVolFromRMDB(), ui_MsgWriter::DisplayError(), ui_MsgWriter::DisplayMessage(), ui_MsgWriter::DisplayWarning(), evt_ERROR, ivd_BaseException::GetFriendly(), i_Medium_t::idxOfSysVol, InitializeSingleVolume(), ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), log_WRN_m, i_Job_i::m_activeBeas, m_doFormat, m_idxSysVol, i_Job_i::m_iJobParams, m_initAllVol, m_initSucceeded, m_initVol, m_makeSysVol, m_mediaPool, m_medium, m_medVolInRmdb, i_Job_i::m_rm, m_ui, mt_DISK, i_MediaPool_t::numOfVolumes, i_Medium_t::numOfVolumes, rmdb_INIT_MEDIUM_STATUS, SetSysVolIdx(), svl_NONE, and i_MediaPool_t::sysVolLocation.

Referenced by Execute().

                              {
    log_FUNC_m(Initialize);

    if (IsAborted()) return;
    ostringstream msg;
    UInt32_t numOfVolOnMed;
    //
    // get number of volumes on medium.
    i_VolSizes_t_var volumeSizes;
    try {
        ipc_EXEC_m(
            volumeSizes = m_activeBeas[0]->GetVolumeSizes();
            numOfVolOnMed = volumeSizes->length();
        )
    } catch (ivd_Exception &e){
        log_ERR_m("[" << m_iJobParams.jobID <<
                  "] " << "Get Volume Sizes Failed:" << endl << e);
        msg << "Get volume sizes failed (" << e.GetFriendly() << ").";
        log_WriteEvent(evt_ERROR, msg.str(), evt_ADMINJOB,
                       m_iJobParams.jobID, string(m_medium.barcode));
        m_ui.DisplayError(msg.str());
        return;
    }

    log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                        "] " << " Found " << numOfVolOnMed
                        << " volumes on medium.");

    if ( (m_mediaPool.sysVolLocation != svl_NONE) && (numOfVolOnMed > 1)) { //there should be a SysVol on this medium
        m_makeSysVol = true;
        log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
                             "] " << "SysVol will be created");
        if ( (m_medium.idxOfSysVol == 0) || m_initAllVol) {
            SetSysVolIdx(numOfVolOnMed);
        } else {
            m_idxSysVol = m_medium.idxOfSysVol;
            log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
                                  "] " << "m_idxSysVol=" << m_idxSysVol);
        }
    } else {
        m_makeSysVol = false;
        log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
                              "] " << "SysVol will NOT be created");
    }
    if (IsAborted()) {
        return;
    }

    // update medium record in RMDB with actual volume status on medium.
    i_Medium_t_var iMed;
    ipc_EXEC_m(
        iMed = m_rm->SelectMedium(m_medium.barcode);
    );
    m_medium = iMed;
    m_medium.numOfVolumes = numOfVolOnMed;
    m_medium.blockSize = m_mediaPool.blockSize;
    m_medium.status = rmdb_INIT_MEDIUM_STATUS | rmdb_MEDIUM_IN_USE;
    ipc_EXEC_m(
        m_rm->UpdateMedium(m_medium);
    );

    if (numOfVolOnMed == 0) {
        msg << "No volumes found on the medium.";
        ipc_EXEC_m(m_ui.DisplayError(msg.str());)
        return;
    }

    msg << "Medium " << m_medium.barcode
        << ": " << numOfVolOnMed << " volumes found.";
    ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)
    msg.str("");

    if (   m_mediaPool.numOfVolumes != numOfVolOnMed
        && m_medium.mediumType != mt_DISK) {

        msg << m_mediaPool.numOfVolumes <<
            " volumes defined in media pool, " << numOfVolOnMed <<
            " volumes found on medium!";
        ipc_EXEC_m(m_ui.DisplayWarning(msg.str());)
        msg.str("");
    }

    if (m_initAllVol) {
        //init sysVolFirst (if configured)
        if (m_idxSysVol > 0) {
            try {
                InitializeSingleVolume(m_idxSysVol);
            } catch (ivd_Exception &e){
                log_DBG_m(dbg_LOW, e);
                throw;
            }
        }

        for (UInt32_t i = 0; i < volumeSizes->length(); i++) {
            if (IsAborted()) return;

            if ((i + 1) != UInt32_t(m_idxSysVol)) {
                try {
                    InitializeSingleVolume(i + 1);
                    m_initSucceeded = true;
                } catch (ivd_Exception){
                    //ignore
                }
            }
        }
        for (UInt32_t j = 0; j < m_medVolInRmdb.length(); j++) {
            if (    !m_doFormat &&
                    (
                        static_cast<UInt32_t>(m_medVolInRmdb[j].medVolNr) >
                        volumeSizes->length()
                    )
                ){

                DeleteMedVolFromRMDB(string(m_medium.barcode),
                                            m_medVolInRmdb[j].medVolNr);
            }
        }

    } else {
        for (UInt32_t i = 0; i < m_initVol.size(); i++) {
            log_DBG_m(dbg_NORM, "m_initVol[i]:" << m_initVol[i]
                                << " volumeSizes->length():"
                                << volumeSizes->length());
            if (m_initVol[i] <= volumeSizes->length()){
                if (IsAborted()) return;
                try {
                    InitializeSingleVolume(m_initVol[i]);
                    m_initSucceeded = true;
                } catch (ivd_Exception){
                    //ignore
                }

            } else {
                msg.str("");
                msg << "Can not initialize volume " << m_initVol[i] <<
                       " because medium has only " << volumeSizes->length()
                       << " volumes";
                log_WRN_m("[" << m_iJobParams.jobID <<
                          "] " << msg.str());
                ipc_EXEC_m(m_ui.DisplayWarning(msg.str());)
            }
        }
    }
} // mif_AdminJobExecutor::Initialize()

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::InitializeSingleVolume ( Int32_t  volumeNr  )  [private]

Definition at line 853 of file i_adminjob_impl.cpp.

References dbg_LOW, dbg_NORM, DetectVolumeHeader(), ui_MsgWriter::DisplayError(), ui_MsgWriter::DisplayMessage(), ui_MsgWriter::DisplayWarning(), DoInitialize(), evt_ERROR, evt_WARNING, FindVolInRMDB(), g_cmn, ivd_BaseException::GetFriendly(), i_VOL_BLANK, i_VOL_ECMA, i_VOL_IVD, i_VOL_IVD_NT, i_VOL_OTHER, i_VOL_TAR, ie_PRECONDITION, ipc_EXEC_m, ivd_Error, i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_A_m, log_WriteEvent(), m_forced, cmn_SysInfo::m_hostName, m_idxSysVol, i_Job_i::m_iJobParams, m_initAllVol, m_makeSysVol, m_mediaPool, m_medVolInRmdb, i_Job_i::m_rm, m_ui, i_MediumVol_t::medVolNr, i_MediaPool_t::partitionUUIDString, ipc_Corba::ResolvePMByPartID(), rmdb_MEDVOL_REORG_RECYCLED, cmn_Global::si, and i_MediumVol_t::status.

Referenced by Initialize().

                                                            {

    log_FUNC_A_m(InitializeSingleVolume, "# :" << a_volumeNr);

    // get volume info from medium.
    ostringstream msgBase;
    msgBase <<  "Medium " << m_medium.barcode << ", volume " << a_volumeNr << ": ";
    ostringstream msg;
    msg << msgBase.str() << "Reading volume identification...";
    ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)
    log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID << "] " << msg.str());
    msg.str("");
    i_VolInfo_t_var volInfo;
    DetectVolumeHeader(volInfo, a_volumeNr);
    try {
        // check if volume is in rmdb

        bool found(false);
        i_MediumVol_t medVol;
        UInt32_t findIdx(0);
        try {
            findIdx = FindVolInRMDB(a_volumeNr);
            medVol = m_medVolInRmdb[findIdx];
            found = true;
        }
        catch (ivd_Error) {
            found = false;
        }

        log_DBG_m(dbg_NORM, "Volume in rmdb: " << boolalpha << found <<
                    " medVol.status" << medVol.status);

        // determine, if medium volume may be initialized.
        msg << msgBase.str();
        if ( (volInfo->type == i_VOL_BLANK) ||
            (volInfo->type == i_VOL_OTHER) ||
            (m_forced && (volInfo->type == i_VOL_ECMA
                          || volInfo->type == i_VOL_TAR
                          || volInfo->type == i_VOL_IVD_NT ) ) ) {


            if ( (a_volumeNr == m_idxSysVol) && m_makeSysVol) { //this should be System Volume
                if (!m_initAllVol && (m_medium.idxOfSysVol != m_idxSysVol) ){
                    //but there is already another system volume
                    //do not allow two system volumes
                    msg << "Can not initialize (system volume already exist on medium).";
                    log_ERR_m("[" << m_iJobParams.jobID <<
                                      "] " << msg.str());
                    ipc_EXEC_m(m_ui.DisplayWarning(msg.str());)
                    return;
                } else {
                    log_DBG_m(dbg_LOW, "Invoking init for system volume");
                    DoInitialize(a_volumeNr, volInfo->size );
                }
            } else {
                DoInitialize(a_volumeNr, volInfo->size );
            }
        }
        else if ( m_forced && (volInfo->type == i_VOL_IVD)){
            if (m_initAllVol) { //no problem just do it
                DoInitialize(a_volumeNr, volInfo->size );
            } else {
                if ( (m_idxSysVol == a_volumeNr) && (volInfo->sysVolNum != a_volumeNr) ) {
                    //do not allow two system volumes
                    msg << "Can not initialize (system volume already exist on medium).";
                    log_ERR_m("[" << m_iJobParams.jobID <<
                                      "] " << msg.str());
                    ipc_EXEC_m(m_ui.DisplayWarning(msg.str());)
                    return;
                } else {
                    DoInitialize(a_volumeNr, volInfo->size );
                }
            }
        } else if (found && (medVol.status & rmdb_MEDVOL_REORG_RECYCLED)){


            //resolve PM
            i_Partition_t_var pm =
                m_rm->SelectPartitionByUUID(m_mediaPool.partitionUUIDString);
            i_PartitionManager_var m_iPM;
            ipc_EXEC_m(
                string pmName(pm->partitionName);
                CORBA::Object_var obj = ipc_Corba::ResolvePMByPartID(g_cmn.si.m_hostName, pmName);
                m_iPM = i_PartitionManager::_narrow(obj);
            );

            if (!CORBA::is_nil(m_iPM)){
                DoInitialize(a_volumeNr, volInfo->size);
            } else {
                throw ivd_Error(ie_PRECONDITION, "Initialization of recycled \
                                                 volume requires Partition Manager to be running.");
            }

            //delete entries from FSC
            log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                "] " << "Deleting entries from FSC.");
            msg.str("");
            msg << msgBase.str() << "Deleting entries from FSC ...";
            ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)

            m_iPM->ReleaseVolEntries(m_medium.mediumKey, medVol.medVolNr);

        } else {
            msg << "Initialization of HSM/ECMA/TAR/IVD NT volume not allowed. "
                << "Use force option.";
            log_WriteEvent(
                    evt_WARNING, msg.str(), evt_ADMINJOB, m_iJobParams.jobID);
            ipc_EXEC_m(m_ui.DisplayWarning(msg.str());)
        }

    } catch (ivd_Exception &e){
        log_ERR_m("[" << m_iJobParams.jobID <<
                  "] " << "Get volume info failed:" << endl << e);
        msg << "DoInitialize failed (" << e.GetFriendly() << ").";
        log_WriteEvent(evt_ERROR, msg.str(), evt_ADMINJOB,
                       m_iJobParams.jobID, string(m_medium.barcode));
        m_ui.DisplayError(msg.str());
        throw;
    }


} // i_AdminJob_i::InitializeSingleVolume

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::InitJob (  )  [virtual]

Reimplemented from i_Job_i.

Definition at line 139 of file i_adminjob_impl.cpp.

References i_Medium_t::barcode, i_MediaPool_t::blockSize, CloseVolumeCheck(), ui_MsgWriter::DisplayMessage(), FormatAndInitCheck(), i_Job_i::GetResources(), ie_PRECONDITION, ivd_Error, i_JobParams::jobID, log_FUNC_m, i_Job_i::m_activeBeas, m_doCloseVolume, m_doFormat, m_doFri, m_doInit, m_doMic, i_Job_i::m_iJobParams, m_initVol, m_mediaPool, m_medium, m_medVolInRmdb, m_ui, i_MediaPool_t::mediaFamily, i_MediaPool_t::mediaPoolKey, i_MediaPool_t::mediaPoolType, i_Medium_t::mediumKey, i_MediaPool_t::partitionUUIDString, i_JobParams::partUUID, RecreateFRIandMICCheck(), ipc_Init::ResourceInit(), i_Job_i::SetJobValid(), and i_Job_i::SetResources().

                          {
    log_FUNC_m(InitJob);

    if (m_doInit || m_doFormat){
        FormatAndInitCheck();
    } else if (m_doFri || m_doMic){
        RecreateFRIandMICCheck();
    } else if (m_doCloseVolume){
        CloseVolumeCheck();
    }
    ostringstream msg;
    msg << "Started (JobID: " << m_iJobParams.jobID << ").";
    m_ui.DisplayMessage(msg.str());

    m_iJobParams.partUUID         = m_mediaPool.partitionUUIDString;

    i_ResourceList_t resources;
    resources.length(1);
    ipc_Init::ResourceInit(resources[0]);
    resources[0].poolKey           = m_mediaPool.mediaPoolKey;
    resources[0].poolType          = m_mediaPool.mediaPoolType;
    resources[0].mediumFamily      = m_mediaPool.mediaFamily;
    resources[0].mediumKey         = m_medium.mediumKey;
    resources[0].barcode           = CORBA::string_dup(string(m_medium.barcode).c_str());
    resources[0].blockSize         = m_mediaPool.blockSize;
    if (m_doCloseVolume){
        if (m_medVolInRmdb.length() > 0){
            resources[0].medVolId = CORBA::string_dup(m_medVolInRmdb[0].medVolId);
            resources[0].medVolNr = m_initVol[0];
        } else {
            throw ivd_Error(ie_PRECONDITION, "Volume is not initialized.", true);
        }
    }
    SetResources(resources);
    m_activeBeas.resize(GetResources().length());

    SetJobValid();
}

Here is the call graph for this function:

void i_AdminJob_i::MediumOperationComplete ( i_Index_t  beaNumber,
i_CompletionStatus_e  a_status 
) [virtual]

Implements i_Job_i.

void i_AdminJob_i::OperateLA ( rm_Resource_t resource  )  [private]

Definition at line 265 of file i_adminjob_impl.cpp.

References i_Medium_t::barcode, dbg_DETAIL, ui_MsgWriter::DisplayError(), ui_MsgWriter::DisplayMessage(), rm_Resource_t::driveKey, evt_ERROR, ivd_BaseException::GetFriendly(), ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, rm_Resource_t::load, i_Job_i::LoadUnload(), log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_iJobParams, m_medium, i_Job_i::m_rm, m_ui, rm_Resource_t::mediumFamily, and mf_DISK.

Referenced by Execute().

                                                      {
    log_FUNC_m(OperateLA);

    if (IsAborted() || (a_resource.mediumFamily == mf_DISK)) return;
    string driveName;
    // operate LA.

    ipc_EXEC_m(
        i_Drive_t_var drive;
        drive = m_rm->SelectDriveByKey(a_resource.driveKey);
        driveName = drive->driveName;
    )

    try {
        //
        // check if LA should be operated at all.
        if (a_resource.load) {
            ostringstream msg;
            msg << "Loading medium " << m_medium.barcode <<
                    " to drive " << driveName << ".";
            ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)

            LoadUnload(0);
            log_DBG_m(dbg_DETAIL, "[" << m_iJobParams.jobID <<
                                  "] " << "Some tape moves were done.");
         }
         else {
            ostringstream msg;
            msg << "Medium " << m_medium.barcode <<
                    " is already present in drive " << driveName << ".";
            ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)
         }
     }
     catch (ivd_Exception &e) {
         log_ERR_m("[" << m_iJobParams.jobID << "] " <<  e);

         ostringstream eventText;
         eventText << "Problems with Load/Unload ("
                   << e.GetFriendly() << ").";

         log_WriteEvent(evt_ERROR, eventText.str(), evt_ADMINJOB,
                        m_iJobParams.jobID, string(m_medium.barcode));

         m_ui.DisplayError(eventText.str());
         throw;
     }
} // i_AdminJob_i::OperateLA()

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::RecreateFRIandMIC (  )  [private]

Generates new FRI on disk from specified data medium volume.

Complete volume is rescanned.

Exceptions:
i_IvdException if medium/hardware error occurs or FRI can't be generated.

void GenerateFRIFromMedVol( in string a_tapeDrive, in i_VolInfo_t a_volume) raises (i_IvdException);

Regenerates MIC values for one medium volume. void RecreateMIC(in i_VolInfo_t a_volume) raises (i_IvdException);

Definition at line 1117 of file i_adminjob_impl.cpp.

References i_MediumVol_t::accessNr, i_VolInfo_t::accessNum, i_MediumVol_t::accessTime, i_VolInfo_t::accessTime, i_VolInfo_t::appendNum, i_VolInfo_t::appendTime, i_VolInfo_t::blockSize, dbg_LOW, dbg_NORM, ui_MsgWriter::DisplayError(), ui_MsgWriter::DisplayMessage(), evt_ERROR, FindVolInRMDB(), ivd_BaseException::GetFriendly(), i_SV_APPEND, i_VolInfo_t::implID, ipc_EXEC_m, ipc_nilStr, i_Job_i::IsAborted(), i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogVolInfo(), i_Job_i::m_activeBeas, m_doFri, m_doMic, i_Job_i::m_iJobParams, m_initVol, m_into, m_intoPath, m_mediaPool, m_medVolInRmdb, m_ui, i_MediumVol_t::medVolId, i_VolInfo_t::medVolID, i_MediumVol_t::medVolNr, i_MediumVol_t::owriteNr, i_VolInfo_t::owriteNum, i_MediumVol_t::owriteTime, i_VolInfo_t::owriteTime, i_VolInfo_t::partID, i_JobParams::partUUID, i_VolInfo_t::poolID, i_MediaPool_t::poolUUIDString, rmdb_SYSTEM_VOLUME, i_VolInfo_t::size, i_VolInfo_t::sysVolNum, i_VolInfo_t::type, i_VolInfo_t::volNum, i_MediumVol_t::volSize, i_MediumVol_t::volType, i_MediumVol_t::volUsed, i_MediumVol_t::writeNr, and i_MediumVol_t::writeTime.

Referenced by Execute().

                                    {
    log_FUNC_m(RecreateFRI);

    for (UInt32_t i = 0; i < m_initVol.size(); ++i) {

        i_MediumVol_t &medVol = m_medVolInRmdb[FindVolInRMDB(m_initVol[i])];

        ostringstream msgBase;
        msgBase <<  "Medium " << m_medium.barcode
                << ", volume " << medVol.medVolNr << ": ";

        ostringstream msg;
        try {
            if (medVol.volUsed == 0)  {
                msg.str("");
                msg << msgBase.str() << "Medium volume is empty. Skipped.";
                m_ui.DisplayMessage(msg.str());
                log_DBG_m(dbg_LOW,msg.str());
                msg.str("");
            } else if (medVol.volType == rmdb_SYSTEM_VOLUME){
                msg.str("");
                msg << msgBase.str() << "Medium volume is system. Skipped.";
                m_ui.DisplayMessage(msg.str());
                msg.str("");
            } else {
                ipc_EXEC_m(
                    i_VolInfo_t volInfo;
                    volInfo.volNum      = medVol.medVolNr;
                    volInfo.implID      = CORBA::string_dup(ipc_nilStr);
                    volInfo.size        = medVol.volSize;
                    volInfo.type        = i_VOL_IVD;
                    volInfo.sysVolNum   = m_medium.idxOfSysVol;
                    volInfo.medVolID    = medVol.medVolId;
                    volInfo.poolID      = m_mediaPool.poolUUIDString;

                    volInfo.partID      = m_iJobParams.partUUID;
                    volInfo.blockSize   = m_medium.blockSize;

                    volInfo.accessNum   = medVol.accessNr;
                    volInfo.appendNum   = medVol.writeNr;
                    volInfo.owriteNum   = medVol.owriteNr;

                    volInfo.accessTime  = medVol.accessTime;
                    volInfo.appendTime  = medVol.writeTime;
                    volInfo.owriteTime  = medVol.owriteTime;

                    log_DBG_m(dbg_LOW,
                        "[" << m_iJobParams.jobID <<
                        "] " << "Recreate FRI:" << endl << ipc_Log::LogVolInfo(volInfo));
                    //
                    // recreate FRI for volume.
                    if (IsAborted()) return;
                    if (m_doFri){
                        if (m_into){
                            msg << msgBase.str() << "Recreating FRI into " << m_intoPath << ".";
                            m_ui.DisplayMessage(msg.str());
                            msg.str("");
                        }

                        msg << msgBase.str() << "Recreating FRI started...";
                        m_ui.DisplayMessage(msg.str());
                        msg.str("");
                        i_VolInfoList_t volInfoList;
                        volInfoList.length(1);
                        volInfoList[0] = volInfo;
                        i_BoolList_t emptyList;
                        m_activeBeas[0]->RecreateFastRecoveryInfo(
                                    volInfoList,
                                    false,
                                    emptyList,
                                    i_SV_APPEND,
                                    m_into,
                                    CORBA::string_dup(m_intoPath.c_str())
                        );

                        msg << msgBase.str() << "Recreating FRI finished.";
                        m_ui.DisplayMessage(msg.str());
                        msg.str("");

                        log_DBG_m(dbg_NORM,
                            "[" << m_iJobParams.jobID <<
                            "] " << "BEA->RecreateFastRecoveryInfo() returned");
                    }
                    if (IsAborted()) return;
                    if (m_doMic){
                        msg << msgBase.str() << "Recreating MIC started.";
                        m_ui.DisplayMessage(msg.str());
                        msg.str("");

                        m_activeBeas[0]->RecreateMIC(volInfo);
                        log_DBG_m(dbg_NORM,
                            "[" << m_iJobParams.jobID << "] " << "BEA->GenerateMIC() returned");
                        msg << msgBase.str() << "Recreating MIC finished.";
                        m_ui.DisplayMessage(msg.str());
                        msg.str("");
                    }
                )
//
// Proper system volume action must be specified (see i_bea.idl). Discuss with Luka.
//
            }

        } catch (ivd_Exception &e){
            log_ERR_m("[" << m_iJobParams.jobID <<
                                      "] " << "FRI Recreate Failed:" << endl << e);
            msg << msgBase.str() << "FRI Recreate failed (" << e.GetFriendly() << ").";
            log_WriteEvent(evt_ERROR, msg.str(), evt_ADMINJOB,
                           m_iJobParams.jobID, string(m_medium.barcode));
            m_ui.DisplayError(msg.str());
            msg.str("");
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_AdminJob_i::RecreateFRIandMICCheck (  ) 

Definition at line 194 of file i_adminjob_impl.cpp.

References CheckMedium(), CheckPool(), CheckVolumesForFriMicJob(), log_FUNC_m, and SetVolumes().

Referenced by InitJob().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from i_Job_i.

Definition at line 1927 of file i_adminjob_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(), 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;

        msg << ipc_Log::ResourceBusy(a_resStatus);

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

            msg << " <";


            //waiting for medium <bc: 000123>
            msg << "bc: " <<
            tmpRes.barcode << ">";
        }

        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_AdminJob_i::SetSysVolIdx ( UInt32_t  a_numOfVol  )  [private]

Definition at line 370 of file i_adminjob_impl.cpp.

References dbg_LOW, ie_FATAL_ERROR, i_JobParams::jobID, log_DBG_m, log_FUNC_m, m_idxSysVol, i_Job_i::m_iJobParams, m_mediaPool, svl_FIRST, svl_LAST, svl_MIDDLE, and i_MediaPool_t::sysVolLocation.

Referenced by Format(), and Initialize().

                                                  {
    log_FUNC_m(SetSysVolIdx);
    switch (m_mediaPool.sysVolLocation) {
        case(svl_FIRST):
            m_idxSysVol = 1;
            break;
        case(svl_MIDDLE):
            m_idxSysVol = a_numOfVol/2 + 1;
            break;
        case(svl_LAST):
            m_idxSysVol = a_numOfVol;
            break;
        default:
            throw ivd_InternalError(ie_FATAL_ERROR, "MediaPool sysVolLocation should be set");
    }
    log_DBG_m(dbg_LOW,"[" << m_iJobParams.jobID <<
                      "] " << "m_idxSysVol=" << m_idxSysVol);
}

Here is the caller graph for this function:

void i_AdminJob_i::SetVolumes (  )  [private]

Definition at line 1629 of file i_adminjob_impl.cpp.

References dbg_DETAIL, ipc_EXEC_m, log_DBG_m, log_FUNC_m, m_medVolInRmdb, and i_Job_i::m_rm.

Referenced by CloseVolumeCheck(), Execute(), FormatAndInitCheck(), and RecreateFRIandMICCheck().

                             {
    log_FUNC_m(SetVolumes);

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

    if ( medVolSeq->length() == 0 ) {
        ostringstream msg;
        msg << "WARNING: No initialized volumes on Medium.";
        log_DBG_m(dbg_DETAIL," msg : " << msg.str());
    }

    m_medVolInRmdb = medVolSeq;
}

Here is the caller graph for this function:

void i_AdminJob_i::StartBEA (  )  [private]

Definition at line 315 of file i_adminjob_impl.cpp.

References i_Medium_t::barcode, dbg_NORM, ui_MsgWriter::DisplayError(), ui_MsgWriter::DisplayMessage(), evt_ERROR, ivd_BaseException::GetFriendly(), i_Job_i::GetResources(), ipc_EXEC_m, i_Job_i::IsAborted(), i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_activeBeas, i_Job_i::m_iJobParams, m_medium, m_ui, i_Job_i::StartBea(), and i_Job_i::WaitBea().

Referenced by Execute().

                            {
    log_FUNC_m(StartBEA);

    if (IsAborted()) return;

    try {
        ipc_EXEC_m(
            ostringstream msg;
            msg << "Starting Back End Agent.";
            ipc_EXEC_m(m_ui.DisplayMessage(msg.str());)

            StartBea(string(GetResources()[0].driveHost),
                                GetResources()[0].resNum);
            log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                                  "] " << "BEA started.");

            WaitBea(0);
            ipc_EXEC_m(
                m_activeBeas[0]->UseResources((GetResources())[0]);
            );
        )
    }
    catch (ivd_Exception &ex) {
        log_ERR_m("[" << m_iJobParams.jobID << "] " << "Caught error when starting BEA. " << ex);

        ostringstream eventText;
        eventText << "Problems with Back End Agent ("
                  << ex.GetFriendly() << ").";
        log_WriteEvent(evt_ERROR, eventText.str(), evt_ADMINJOB,
                       m_iJobParams.jobID, string(m_medium.barcode));
        m_ui.DisplayError(eventText.str());
        throw;
    }
} // i_AdminJob_i::StartBEA()

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from i_Job_i.

Definition at line 159 of file i_adminjob_impl.h.

string i_AdminJob_i::m_barcode [private]

Definition at line 120 of file i_adminjob_impl.h.

Referenced by CheckMedium().

Definition at line 102 of file i_adminjob_impl.h.

Referenced by CheckPool(), Execute(), and InitJob().

bool i_AdminJob_i::m_doFormat [private]
bool i_AdminJob_i::m_doFri [private]

Definition at line 100 of file i_adminjob_impl.h.

Referenced by Execute(), InitJob(), and RecreateFRIandMIC().

bool i_AdminJob_i::m_doInit [private]
bool i_AdminJob_i::m_doMic [private]

Definition at line 101 of file i_adminjob_impl.h.

Referenced by Execute(), InitJob(), and RecreateFRIandMIC().

bool i_AdminJob_i::m_forced [private]

Definition at line 104 of file i_adminjob_impl.h.

Referenced by CheckVolumesForFormatAndInit(), Format(), and InitializeSingleVolume().

Definition at line 116 of file i_adminjob_impl.h.

Referenced by Initialize().

bool i_AdminJob_i::m_into [private]

Definition at line 124 of file i_adminjob_impl.h.

Referenced by RecreateFRIandMIC().

string i_AdminJob_i::m_intoPath [private]

Definition at line 125 of file i_adminjob_impl.h.

Referenced by RecreateFRIandMIC().

bool i_AdminJob_i::m_jobValid [private]

Reimplemented from i_Job_i.

Definition at line 117 of file i_adminjob_impl.h.

Definition at line 106 of file i_adminjob_impl.h.

Referenced by DetectVolumeHeader().

Definition at line 113 of file i_adminjob_impl.h.

Referenced by Initialize(), and InitializeSingleVolume().


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