Public Member Functions | Private Member Functions | Private Attributes

i_BackupJob_i Class Reference
[Management Interface]

#include <i_adminjob_impl.h>

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

List of all members.

Public Member Functions

 i_BackupJob_i (mif_JobManager &jobManager, const char *a_barcode)
virtual ~i_BackupJob_i ()
void MediumOperationComplete (i_Index_t beaNumber, i_CompletionStatus_e a_status)
virtual void CompleteJob (i_CompletionStatus_e status)
virtual void Remove ()
void GetNewResources (i_Index_t resourceNumber)
void PrepareResource ()
void AllocateDiskBuffer (i_FileSize_t a_size)

Private Member Functions

i_JobRequestList_tGetFiles ()
i_FSC_ptr GetFSC ()
void Execute ()

Private Attributes

 log_CLASSID_m
cmn_Mutex m_backupJob_x
cmn_Condition m_backupJob_c
UInt64_t m_diskBufferSize
i_MediaPool_t m_bkpPool
bool m_toSpecificMedium

Detailed Description

Definition at line 167 of file i_adminjob_impl.h.


Constructor & Destructor Documentation

i_BackupJob_i::i_BackupJob_i ( mif_JobManager jobManager,
const char *  a_barcode 
)

Definition at line 55 of file i_backupjob_impl.cpp.

References i_JobParams::bufType, dbg_LOW, evt_BACKUPJOB, i_Job_i::GetResources(), i_SUCCEDED, ie_PRECONDITION, ipc_EXEC_m, ivd_Error, i_JobParams::jobID, i_JobParams::jobType, log_DBG_m, log_FUNC_m, log_WriteEvent(), log_WRN_m, ipc_Log::LogJobParams(), ipc_Log::LogResources(), i_Job_i::m_activeBeas, m_bkpPool, i_Job_i::m_iJobParams, i_Job_i::m_rm, m_toSpecificMedium, i_MediaPool_t::mediaPoolKey, i_MediaPool_t::mediaPoolName, i_JobParams::partUUID, pt_Backup, ipc_Init::ResourceInit(), rmdb_MEDIUM_OFFLINE, rmdb_MEDIUM_UNRELIABLE, rmdb_MEDIUM_UNUSABLE, i_Job_i::SetCompletionStatus(), and i_Job_i::SetResources().

    :   i_Job_i(a_jobManager),
        m_backupJob_c(&m_backupJob_x),
        m_diskBufferSize(0)
        {
    log_FUNC_m(i_BackupJob_i);

    m_iJobParams.jobType          = jt_BACKUP;
    m_iJobParams.bufType          = i_DISK_BUF;

    SetCompletionStatus(i_SUCCEDED);

    if (strlen(a_barCode) > 0) {
        m_toSpecificMedium = true;
    }
    else {
        m_toSpecificMedium = false;
    }

    i_ResourceList_t resources;
    resources.length(1);
    ipc_Init::ResourceInit(resources[0]);

    i_MediaPoolSeq_t_var allPools;
    try {
        ipc_EXEC_m(allPools = m_rm->SelectAllMediaPools();)
    } catch (ivd_Exception &e){
        log_DBG_m(dbg_LOW,e);
        throw;
    }

    bool foundFirst(false);
    for (UInt32_t i(0); i < allPools->length(); i++){
        if (allPools[i].mediaPoolType == pt_Backup) {
            if (foundFirst){
                log_WRN_m("There are two Backup pools defined in RMDB. Only first will be used.")
            }
            foundFirst = true;
            m_iJobParams.partUUID       = allPools[i].partitionUUIDString;
            m_bkpPool = allPools[i];
        }
    }
    resources[0].poolKey = m_bkpPool.mediaPoolKey;

    if (strlen(a_barCode) > 0) {
        resources[0].barcode = CORBA::string_dup(a_barCode);

        //Check if medium exists
        i_Medium_t_var medium;
        try {
            ipc_EXEC_m(medium = m_rm->SelectMedium(a_barCode);)
        }
        catch (ivd_Exception &e){
            log_DBG_m(dbg_LOW,e);
            throw ivd_Error(ie_PRECONDITION, "Requested medium does not exist.");
        }
        resources[0].mediumKey = medium->mediumKey;
        //Check if medium is usable
        if (medium->status & rmdb_MEDIUM_UNRELIABLE ){
            throw ivd_Error(ie_PRECONDITION, "Medium is marked as UNRELIABLE.", true);
        }
        if (medium->status & rmdb_MEDIUM_UNUSABLE){
            throw ivd_Error(ie_PRECONDITION, "Medium is marked as UNUSABLE.", true);
        }
        if (medium->status & rmdb_MEDIUM_OFFLINE) {
            throw ivd_Error(ie_PRECONDITION, "Medium is marked as offline.", true);
        }
        if (strcmp(medium->mediaPoolName, m_bkpPool.mediaPoolName) != 0 ){
            throw ivd_Error(ie_PRECONDITION, "Medium does not belong to backup pool.", true);
        }

        //Check if medium is initialized
        i_MediumVolSeq_t_var mediumVols;
        try {
            ipc_EXEC_m(mediumVols = m_rm->SelectAllMediumVolByBarcode(a_barCode);)
        }
        catch (ivd_Exception &e){
            log_DBG_m(dbg_LOW,e);
            throw ivd_Error(ie_PRECONDITION, "Selecting volumes failed.");
        }
        if (mediumVols->length() == 0 ){
            throw ivd_Error(ie_PRECONDITION, "Medium does not have initialized volumes.", true);
        }
    }

    SetResources(resources);

    m_activeBeas.resize(GetResources().length());

    log_DBG_m(dbg_LOW, "" << endl <<
        "Backup Job Created:" << endl <<
        ipc_Log::LogJobParams(m_iJobParams) << endl <<
        ipc_Log::LogResources(GetResources()) << endl);

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

} //i_BackupJob_i::i_BackupJob_i

Here is the call graph for this function:

i_BackupJob_i::~i_BackupJob_i (  )  [virtual]

Definition at line 154 of file i_backupjob_impl.cpp.

References log_FUNC_m.

                              {
    log_FUNC_m(~i_BackupJob_i);
} // i_BackupJob_i::~i_BackupJob_i


Member Function Documentation

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

Reimplemented from i_Job_i.

Definition at line 210 of file i_backupjob_impl.cpp.

References log_FUNC_m, i_Job_i::m_rm, and i_Job_i::RequestDiskBuffer().

                                                         {
    log_FUNC_m(AllocateDiskBuffer);
    UInt64_t allocated(0);

    try {
        string mif("mif");
        UInt64_t maxDiskBuff = m_rm->GetMaxDiskBufferSize(mif.c_str());
        RequestDiskBuffer(a_size, a_size, allocated, maxDiskBuff);
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

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

Implements i_Job_i.

Definition at line 295 of file i_backupjob_impl.cpp.

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

                                                           {
    log_FUNC_m(CompleteJob);
        if (IsAborted()) {
        Remove();
    }
}

Here is the call graph for this function:

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

Implements i_Job_i.

Definition at line 338 of file i_backupjob_impl.cpp.

References cmn_Condition::Broadcast(), dbg_DETAIL, i_Job_i::GetResources(), ipc_EXEC_m, i_Job_i::IsAborted(), i_Job_i::IsFinished(), i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, i_Job_i::m_activate_c, i_Job_i::m_activate_x, m_backupJob_c, m_backupJob_x, i_Job_i::m_iJobParams, PrepareResource(), and cmn_Condition::Wait().

                            {
    log_FUNC_m(Execute);

    try {

        ipc_EXEC_m(
            cmn_MutexLock l(m_activate_x);

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

                if (GetResources()[0].resAssigned &&
                    !GetResources()[0].resProcessed &&
                    !IsAborted()){

                    PrepareResource();
                    log_DBG_m(dbg_DETAIL,"Will unlock m_backupJob_x");

                    cmn_MutexLock l(m_backupJob_x);
                    m_backupJob_c.Broadcast();
                }
                if ( !IsFinished() && !IsAborted() ) {
                    log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
                        "] " <<  " waiting for resources ...");
                    m_activate_c.Wait();
                    log_DBG_m(dbg_DETAIL,"m_activate_c.Wait() retuned");

                }
            }
        )
    }
    catch (ivd_Exception &ex) {
        log_ERR_m("Caught exception in executor->Run(): " << ex);
        throw;
    }
    catch (ivd_InternalError &ie){
        log_ERR_m("Caught internal Error in executor->Run(): " << ie);
        throw;
    }
    catch (...) {
        log_ERR_m("Caught unknown error in executor->Run().");
        throw;
    }
}

Here is the call graph for this function:

i_JobRequestList_t * i_BackupJob_i::GetFiles ( void   )  [private, virtual]

Implements i_Job_i.

Definition at line 383 of file i_backupjob_impl.cpp.

References ie_IMPOSSIBLE, ipc_CATCH_IVD_THROW_CORBA_m, ivd_Error, and log_FUNC_m.

                                            {
    log_FUNC_m(GetFiles);
    try {
        throw ivd_Error(ie_IMPOSSIBLE);
    }
    ipc_CATCH_IVD_THROW_CORBA_m
} // i_BackupJob_i::GetFiles

i_FSC_ptr i_BackupJob_i::GetFSC ( void   )  [private, virtual]

Implements i_Job_i.

Definition at line 392 of file i_backupjob_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_BackupJob_i::GetFSC

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

Implements i_Job_i.

Definition at line 223 of file i_backupjob_impl.cpp.

References i_Job_i::GetResources(), ie_PRECONDITION, ipc_CATCH_IVD_THROW_CORBA_m, ipc_EXEC_m, ivd_Error, job_MED_PROC, log_ERR_m, log_FUNC_m, m_backupJob_c, m_backupJob_x, i_Job_i::m_iJobParams, i_Job_i::m_rm, i_Job_i::m_status, i_JobParams::phase, i_Job_i::SetResRequested(), i_Job_i::SetStatus(), and cmn_Condition::Wait().

                                                      {
    log_FUNC_m(GetNewResources);

    //a_resNum is always 0 for Backup job
    try {
        ipc_EXEC_m(

            if( GetResources()[0].resRequested == true ||
                GetResources()[0].resAllocated == true){
                    throw ivd_Error(ie_PRECONDITION, "Previous resources were not freed yet.");
                }
            m_iJobParams.phase++;
        )
        try {
            SetStatus(job_MED_PROC);

            ipc_EXEC_m(
                SetResRequested(0);
                m_rm->GetResources(this->_this(), m_iJobParams, GetResources());
            );
        }
        catch (ivd_Exception &ex) {
            log_ERR_m("Catched Exception when calling RM GetResources " << ex);
            m_status = i_RESOURCE_ERROR;
            throw;
        }

        //wait for resources to be allocated and prepared

        cmn_MutexLock l(m_backupJob_x);
        m_backupJob_c.Wait();

    } ipc_CATCH_IVD_THROW_CORBA_m
} // i_BackupJob_i::GetResources

Here is the call graph for this function:

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

Implements i_Job_i.

void i_BackupJob_i::PrepareResource (  ) 

Definition at line 159 of file i_backupjob_impl.cpp.

References i_Job_i::GetResources(), ipc_EXEC_m, i_Job_i::LoadUnload(), log_ERR_m, log_FUNC_m, i_Job_i::m_rm, i_Job_i::m_status, i_Job_i::SetDriveProperties(), i_Job_i::SetResources(), and i_Job_i::SetResProcessed().

Referenced by Execute().

                                   {
    log_FUNC_m(PrepareResource);

    try {
        // Select the medium volume to use
        // Assumption: Backup medium has only one volume
        i_MediumVol_t_var volume;

        i_ResourceList_t resources;
        resources.length(1);
        resources[0] = GetResources()[0];

        ipc_EXEC_m(
            volume = m_rm->SelectMediumVol(
                CORBA::string_dup(resources[0].barcode),
                1);
        );
        resources[0].medVolNr = volume->medVolNr;
        resources[0].medVolId = CORBA::string_dup(volume->medVolId);
        resources[0].medVolType = volume->volType;
        SetResources(resources);
    }
    catch (ivd_Error& e) {
        log_ERR_m("Caught Exception when selecting volume ID" << e);
        m_status = i_RESOURCE_ERROR;
        throw;
    }

    try {
        ipc_EXEC_m(
            LoadUnload(0);
        )
    }
    catch (ivd_Error& e) {
        log_ERR_m("Caught Exception when calling Library Agent " << e);
        m_status = i_LA_ERROR;
        throw;
    }

    try {
        SetDriveProperties(0);
        SetResProcessed(0);
    }
    catch (ivd_Error& e) {
        log_ERR_m("Caught Exception when setting Drive properties" << e);
        m_status = i_RESOURCE_ERROR;
        throw;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_BackupJob_i::Remove (  )  [virtual]

Reimplemented from i_Job_i.

Definition at line 302 of file i_backupjob_impl.cpp.

References cmn_Condition::Broadcast(), evt_BACKUPJOB, evt_ERROR, evt_WARNING, i_SUCCEDED, ipc_CATCH_IVD_THROW_CORBA_m, i_JobParams::jobID, log_FUNC_m, log_WriteEvent(), i_Job_i::m_aborted, i_Job_i::m_activate_c, i_Job_i::m_activate_x, m_backupJob_c, m_backupJob_x, i_Job_i::m_iJobParams, and i_Job_i::m_status.

Referenced by CompleteJob().

                           {
    log_FUNC_m(Remove);

    try {

        {
            //unlock backup waiting mutex
            cmn_MutexLock l(m_backupJob_x);
            m_backupJob_c.Broadcast();
        }

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

        if (m_status == i_SUCCEDED) {
            log_WriteEvent("Finished.", evt_BACKUPJOB, m_iJobParams.jobID);
        }
        else if (m_aborted) {
            log_WriteEvent(evt_WARNING, "Aborted.",
                           evt_BACKUPJOB, m_iJobParams.jobID);
        }
        else {
            ostringstream msg;
            msg << "Failed (" << m_status << ").";
            log_WriteEvent(evt_ERROR, msg.str(),
                           evt_BACKUPJOB, m_iJobParams.jobID);
        }
        i_Job_i::Remove();
    }
    ipc_CATCH_IVD_THROW_CORBA_m
} // i_BackupJob_i::Remove

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 189 of file i_adminjob_impl.h.

Definition at line 196 of file i_adminjob_impl.h.

Referenced by Execute(), GetNewResources(), and Remove().

Definition at line 195 of file i_adminjob_impl.h.

Referenced by Execute(), GetNewResources(), and Remove().

Definition at line 199 of file i_adminjob_impl.h.

Referenced by i_BackupJob_i().

Definition at line 198 of file i_adminjob_impl.h.

Definition at line 200 of file i_adminjob_impl.h.

Referenced by i_BackupJob_i().


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