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

i_MigrationJob_i Class Reference
[Partition Manager]

#include <i_migrationjob_impl.h>

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

List of all members.

Public Member Functions

 i_MigrationJob_i (i_PartitionManager_i &a_iPM, pm_JobMgr &a_jobMgr, const pm_FileList &a_files, UInt64_t a_migId, UInt64_t a_majColId, UInt64_t a_minColId, UInt32_t a_flags)
virtual ~i_MigrationJob_i ()
virtual void GetNewResources (i_Index_t a_resNum)
virtual void MediumOperationComplete (i_Index_t a_beaNum, i_CompletionStatus_e a_status)
virtual void CompleteJob (i_CompletionStatus_e a_status)
void AssignResources (const i_ResourceList_t &a_resources)
virtual i_JobRequestList_tGetFiles ()
i_FSC_ptr GetFSC ()
virtual void Execute ()

Protected Attributes

i_PartitionManager_im_iPM

Private Member Functions

void Process (Int32_t a_copyNum)
 Non-interface function.

Private Attributes

bool m_allBeaSuccess
i_UploadAgent_var m_uploadAgent
pm_FileList m_files
UInt32_t m_numOfBeas
UInt64_t m_majColId
UInt64_t m_minColId
UInt32_t m_flags
 log_CLASSID_m

Friends

class pm_AssignResThread

Detailed Description

Definition at line 66 of file i_migrationjob_impl.h.


Constructor & Destructor Documentation

i_MigrationJob_i::i_MigrationJob_i ( i_PartitionManager_i a_iPM,
pm_JobMgr a_jobMgr,
const pm_FileList a_files,
UInt64_t  a_migId,
UInt64_t  a_majColId,
UInt64_t  a_minColId,
UInt32_t  a_flags 
)

Definition at line 54 of file i_migrationjob_impl.cpp.

References i_Resource_t::blockSize, i_JobParams::bufId, i_JobParams::bufType, i_Resource_t::collocation, i_JobParams::copies, rm_String::cvalue_p, dbg_LOW, i_Job_i::GetJobTypeText(), i_Job_i::GetResources(), ie_CFG_INVALID, i_Job_i::InitBeaStatus(), ipc_EXEC_m, ivd_Error, i_JobParams::jobID, i_JobParams::jobPriority, i_JobParams::jobType, log_DBG_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogJobParams(), ipc_Log::LogResources(), i_Job_i::m_activeBeas, i_PartitionManager_i::m_config, i_PartitionManager_i::m_externalClient, m_files, cfg_PM::m_globalTree, i_Job_i::m_iJobParams, m_iPM, m_numOfBeas, i_PartitionManager_i::m_rmPart, i_Resource_t::majColId, i_Resource_t::mediumFamily, i_JobParams::migID, cfg_PMCfg::migrationPriority, i_Resource_t::minColId, i_Resource_t::minFlags, cfg_PMCfg::name, pm_FileList::NumOfFiles(), rm_Partition::partitionUUIDString, i_JobParams::partName, i_JobParams::partUUID, i_Resource_t::poolKey, i_Resource_t::poolName, cfg_Tree::pools, i_Resource_t::poolType, i_Resource_t::poolUUID, i_Resource_t::resNum, ipc_Init::ResourceInit(), and i_Job_i::SetResources().

    : i_Job_i(a_jobMgr),
        m_iPM(a_iPM),
        m_allBeaSuccess(true),
        m_files(a_files),
        m_majColId(a_majColId),
        m_minColId(a_minColId),
        m_flags(a_flags)

{
    log_FUNC_m(i_MigrationJob_i);
    
    ipc_EXEC_m(
        m_iJobParams.migID = a_migID;

        m_iJobParams.jobPriority = m_iPM.m_config.migrationPriority;
        
        m_iJobParams.partName =
            CORBA::string_dup(m_iPM.m_config.name.c_str());
        
        m_iJobParams.partUUID =
            CORBA::string_dup(m_iPM.m_rmPart.partitionUUIDString.cvalue_p);

        m_iJobParams.copies   = m_iPM.m_config.m_globalTree.pools.size();
    );
    
    m_iJobParams.jobType  = jt_MIGRATION;
    
    if (m_iPM.m_externalClient) {
        m_iJobParams.bufType  = i_REMOTE_BUF;
    }
    else {
        m_iJobParams.bufType  = i_DISK_BUF;
    }
    m_iJobParams.bufId    = m_iJobParams.jobID;

    //set length of allocation table to number of pools
    i_ResourceList_t resources;
    ipc_EXEC_m(        
        resources.length(m_iPM.m_config.m_globalTree.pools.size());
    );
    
    // for each copy prepare row
    for (UInt32_t i(0); i < m_iPM.m_config.m_globalTree.pools.size(); i++){

        //check if block size is equal for all pools
        if (i > 0) {
            if (m_iPM.m_config.m_globalTree.pools[i].blockSize !=
                m_iPM.m_config.m_globalTree.pools[i-1].blockSize) {
                    throw ivd_Error(
                        ie_CFG_INVALID,
                        "Media Pools for same set of copies "
                        "can not have different block size");
            }
        }

        i_Resource_t &allocRow = resources[i];
        //sets all memebers to 0 or to ipc_nilStr
        ipc_Init::ResourceInit(allocRow); 

        allocRow.resNum         = i;
        // Set to true if collocation IDs are present
        if (a_majColId > 0) {
            allocRow.collocation = true;
            allocRow.majColId = a_majColId;
            allocRow.minColId = a_minColId;
            allocRow.minFlags = a_flags;
        } 
        else {
            allocRow.collocation = false;
        }

        ipc_EXEC_m(
            allocRow.poolKey = 
                    m_iPM.m_config.m_globalTree.pools[i].mediaPoolKey;

            allocRow.poolUUID = 
                    CORBA::string_dup (
                        m_iPM.m_config.m_globalTree.pools[i].poolUUIDString
                    );
            allocRow.poolName = 
                    CORBA::string_dup (
                        m_iPM.m_config.m_globalTree.pools[i].mediaPoolName
                    );

            allocRow.blockSize = 
                    m_iPM.m_config.m_globalTree.pools[i].blockSize;

            allocRow.mediumFamily = 
                    m_iPM.m_config.m_globalTree.pools[i].mediaFamily;

            allocRow.poolType = 
                    m_iPM.m_config.m_globalTree.pools[i].mediaPoolType;
        );

    };
    SetResources(resources);
    
    log_DBG_m(dbg_LOW, "" << endl <<
        "Migration Job Created:" << endl <<
        ipc_Log::LogJobParams(m_iJobParams) << endl <<
        ipc_Log::LogResources(GetResources()) << endl);
    
    ostringstream os;
    os  
        << "Started (#files: " << m_files.NumOfFiles()
        << ", mig. ID:" << a_migID << ")." ;

    log_WriteEvent(os.str(), GetJobTypeText(), m_iJobParams.jobID);
        
    m_numOfBeas = (GetResources()).length();
    m_activeBeas.resize(m_numOfBeas);
    InitBeaStatus(m_numOfBeas);
}

Here is the call graph for this function:

i_MigrationJob_i::~i_MigrationJob_i (  )  [virtual]

Definition at line 182 of file i_migrationjob_impl.cpp.

References dbg_DETAIL, evt_WARNING, i_Job_i::GetJobTypeText(), i_Job_i::IsAborted(), i_JobParams::jobID, log_DBG_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_iJobParams, m_uploadAgent, and i_Job_i::ReleaseDiskBuffer().

                                   {
    log_FUNC_m(~i_MigrationJob_i);
    
    if (!CORBA::is_nil(m_uploadAgent)) {
        try {
            m_uploadAgent->Remove();
        }
        catch (...) {
            log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
                "] m_uploadAgent->Remove() failed. Ignored.");
        };
    }
    ReleaseDiskBuffer();
        
    if (IsAborted()){
        log_WriteEvent( evt_WARNING, 
                        "Aborted.", 
                        GetJobTypeText(), 
                        m_iJobParams.jobID);
    }

}

Here is the call graph for this function:


Member Function Documentation

void i_MigrationJob_i::AssignResources ( const i_ResourceList_t a_resources  )  [virtual]

Reimplemented from i_Job_i.

Definition at line 483 of file i_migrationjob_impl.cpp.

References dbg_LOW, i_JobParams::jobID, log_DBG_m, log_FUNC_m, ipc_Log::LogResources(), i_Job_i::m_activate_x, i_Job_i::m_iJobParams, pm_AssignResThread, and cmn_Thread::Start().

                                                                         {
    log_FUNC_m(AssignResources);

    log_DBG_m(dbg_LOW,"[" << m_iJobParams.jobID <<
        "] " << "  got Resources:" << endl <<
        ipc_Log::LogResources(a_resources) );

    try {
        pm_AssignResThread * assignThread = new pm_AssignResThread(
                                                        *this, 
                                                        a_resources,
                                                        m_activate_x);
        assignThread->Start();
    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

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

Implements i_Job_i.

Definition at line 301 of file i_migrationjob_impl.cpp.

References i_JobParams::bufType, pm_FileList::ConvertToCorba(), dbg_NORM, evt_ERROR, evt_WARNING, i_PartitionManager_i::GetHSM(), i_Job_i::GetJobTypeText(), i_Job_i::GetResources(), i_ABORTED, i_BEA_ERROR, i_CLIENT_ERROR, i_CLIENT_NOFILES, i_DATA_ERROR, i_FAILED, i_HW_ERROR, i_LA_ERROR, i_MEDIUM_ERROR, i_NO_HOST, i_RESOURCE_ERROR, i_SUCCEDED, i_SVC_ERROR, ipc_EXEC_m, i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogStatus(), i_Job_i::m_aborted, m_files, m_flags, i_Job_i::m_iJobParams, m_iPM, m_majColId, m_minColId, m_numOfBeas, i_Job_i::m_rm, i_Job_i::m_status, i_JobParams::migID, i_PartitionManager_i::Migrate(), and i_Job_i::Remove().

Referenced by MediumOperationComplete().

                                                                 {
    log_FUNC_m(CompleteJob);
    
#if TGT_OS_linux
#warning: CompleteJob called only with status: i_SUCCEDED
#endif
    m_status = a_status;
    
    try {
        if (a_status == i_SUCCEDED){
            try {
                ipc_EXEC_m(
                    // Notify HSM about the status os the
                    // completed migration
                    i_HSM_var hsm = m_iPM.GetHSM();
                    if (!CORBA::is_nil(hsm)){
                        hsm->CompleteMigration(
                                m_iJobParams.bufType,
                                m_iJobParams.jobID,
                                a_status);
                    }
                );
            } catch (ivd_Exception& e){
                log_ERR_m("[" << m_iJobParams.jobID << 
                           "] " << "Caught Exception when " <<
                           "calling hsm->CompleteMigration" << e);
            }
                
            if (a_status == i_SUCCEDED) {
                log_WriteEvent("Finished.", GetJobTypeText(), m_iJobParams.jobID);
            }
            else if (m_aborted) {
                log_WriteEvent(evt_WARNING, "Aborted.", 
                               GetJobTypeText(), m_iJobParams.jobID);
            } 
            else {
                log_WriteEvent(evt_ERROR, "Failed.", 
                               GetJobTypeText(), m_iJobParams.jobID);
            }
            Remove();
       
        } else {
           
            switch (a_status) {
                case(i_DATA_ERROR):
                case(i_HW_ERROR):
                case(i_MEDIUM_ERROR):
                //Create new Migration Job, when job completes with error
                    {
                        i_JobRequestList_t_var files(m_files.ConvertToCorba());
                        ipc_EXEC_m(
                            m_iPM.Migrate(files, m_iJobParams.migID, m_majColId, m_minColId, m_flags);
                        );
                    }
                    break;

                case(i_CLIENT_ERROR): //if client failed just remove job
                    break;
                case(i_CLIENT_NOFILES): //if client has no files for migration
                    m_numOfBeas = 0;
                case(i_LA_ERROR):
                case(i_SVC_ERROR):
                case(i_NO_HOST): //if LA, SVC or NOHOST ERROR Release resources

                case(i_BEA_ERROR):
                case(i_RESOURCE_ERROR):
                case(i_FAILED):
                case(i_ABORTED): {
                    log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                        "] " << "Will call Client CompleteMigration");
                    try {
                        ipc_EXEC_m(
                            i_HSM_var hsm = m_iPM.GetHSM();
                            if (!CORBA::is_nil(hsm)){
                                hsm->CompleteMigration(
                                    m_iJobParams.bufType,
                                    m_iJobParams.jobID,
                                    i_FAILED);
                            }
                        );
                    } catch (ivd_Exception& e){
                        log_ERR_m("[" << m_iJobParams.jobID <<
                                  "] " << "Caught Exception when " <<
                                  "calling hsm->CompleteMigration:" <<
                                  endl << e);
                    }

                    break;
                }

                default:
                    log_ERR_m("Job removed with unhandled status " << a_status);
            }

            m_numOfBeas = 0;
            i_ResourceList_t resources = GetResources();
            bool resRequested(false);
            for (UInt32_t i = 0; i < resources.length(); ++i){
                if (resources[i].resRequested) 
                    resRequested = true;
            }
            if (resRequested) {
                try {
                    ipc_EXEC_m(
                        m_rm->CancelGetResource(m_iJobParams.jobID);
                    );
                }
                catch (ivd_Exception &ie) {
                    log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                        "] " << "Error on canceling resources: " << ie);
                    // Ignore all exceptions and 
                    // try to do as much cleanup as possible
                }
                catch (...) {
                    log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                        "] " << "Error on canceling resources.");
                    // Ignore all exceptions and 
                    //try to do as much cleanup as possible
                }
            }
            
            if ( a_status != i_CLIENT_NOFILES){
                ostringstream os;
                os << "Failed (" << ipc_Log::LogStatus(a_status) << ").";
                log_WriteEvent( evt_ERROR, 
                                os.str(), 
                                GetJobTypeText(), 
                                m_iJobParams.jobID);
            } else {
                ostringstream os;
                os << "Finished (no files migrated).";
                log_WriteEvent( evt_WARNING, 
                                os.str(), 
                                GetJobTypeText(), 
                                m_iJobParams.jobID);
            }

            ipc_EXEC_m( Remove(); );
            return;
        }
        
    } catch (ivd_Exception& e) {
        log_ERR_m(e);
    } catch (ivd_InternalError& ie) {
        log_ERR_m(ie);
    } catch (...) {
        log_ERR_m("Caught unknown" );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_MigrationJob_i::Execute (  )  [virtual]

First step: Client -> invoke writing data to buffer

Implements i_Job_i.

Definition at line 578 of file i_migrationjob_impl.cpp.

References i_JobParams::bufType, pm_FileList::ConvertToCorba(), i_JobParams::copies, dbg_DETAIL, dbg_LOW, dbg_NORM, i_JobParams::diskBufferFS, dt_DISKBUF, evt_ERROR, g_cmn, i_Job_i::GetDiskBufferFileName(), ivd_BaseException::GetFriendly(), i_PartitionManager_i::GetHSM(), i_Job_i::GetJobTypeText(), pm_FileList::GetListSize(), i_Job_i::GetResources(), i_FAILED, ie_NO_FILES, ie_PRECONDITION, ipc_EXEC_m, i_Job_i::IsAborted(), i_Job_i::IsFinished(), ivd_Error, ivd_Sleep, job_MED_PROC, i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), i_Job_i::m_activate_x, i_PartitionManager_i::m_externalClient, m_files, cmn_SysInfo::m_hostName, i_Job_i::m_iJob, i_Job_i::m_iJobParams, m_iPM, i_PartitionManager_i::m_maxDiskBuff, i_Job_i::m_rm, i_Job_i::m_status, m_uploadAgent, i_JobParams::migID, i_Job_i::NeedsProcess(), Process(), i_Job_i::ReleaseDiskBuffer(), i_Job_i::RequestDiskBuffer(), ipc_Corba::ResolveSvc(), i_Job_i::SetDiskBufferWritten(), i_Job_i::SetResProcessed(), i_Job_i::SetResRequested(), i_Job_i::SetStatus(), cmn_Global::si, WAIT_FOR_DOMIG_RETRY, and i_Job_i::WaitBeasToFinish().

                               {
    log_FUNC_m(Execute);


    Int32_t numOfFiles = 0;
    i_HSM_var hsm = m_iPM.GetHSM();

    if (CORBA::is_nil(hsm)){
        throw ivd_Error(ie_PRECONDITION, "HSM is not running.");
    }

    // Reserve Disk Buffer
    UInt64_t fileSize(m_files.GetListSize());
    UInt64_t allocated(0);
    RequestDiskBuffer(fileSize, fileSize, allocated, m_iPM.m_maxDiskBuff);

    if (m_iPM.m_externalClient) {
        ipc_EXEC_m(
            CORBA::Object_var obj = ipc_Corba::ResolveSvc(g_cmn.si.m_hostName);
        i_Service_var svc = i_Service::_narrow(obj);
        i_UploadAgent_var uagt = svc->CreateUploadAgent(
            dt_DISKBUF,
            GetDiskBufferFileName().c_str() );

        m_uploadAgent = i_UploadAgent::_duplicate(uagt);
        );
    };

    log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID << "] " << 
                        "Number of copies: " << m_iJobParams.copies);
    try {
    
        ipc_EXEC_m(
            SetDiskBufferWritten();
            i_JobRequestList_t_var files(m_files.ConvertToCorba());
            numOfFiles = hsm->DoMigrationJob(
                m_iJobParams.bufType,
                m_iJobParams.diskBufferFS,
                m_iJobParams.jobID,
                GetResources()[0].blockSize,
                m_iJobParams.copies,
                m_iJobParams.migID,
                files,
                i_UploadAgent::_duplicate(m_uploadAgent) );

            if (!CORBA::is_nil(m_uploadAgent)) {
                m_uploadAgent->Remove();
                m_uploadAgent = i_UploadAgent::_nil();
            };
        );
    } catch (ivd_Exception) {

        log_DBG_m(dbg_LOW, "[" << m_iJobParams.jobID <<
                           "] " << "DoMigrationJob failed." <<
                           " Trying one more time.");
        // NOTE: If dDoMigration failed we should try to
        //  find out why it failed
        //  Then we can adjust waiting time or even skip retry
        //  There should be a more advance retry procedure here
        ivd_Sleep(WAIT_FOR_DOMIG_RETRY);

        if(IsAborted())
            return;

        ReleaseDiskBuffer();
        
        try {
            ipc_EXEC_m(
                i_JobRequestList_t_var files(m_files.ConvertToCorba());
                numOfFiles = hsm->DoMigrationJob(
                            m_iJobParams.bufType,
                            m_iJobParams.diskBufferFS,
                            m_iJobParams.jobID,
                            GetResources()[0].blockSize,
                            m_iJobParams.copies,
                            m_iJobParams.migID,
                            files,
                            i_UploadAgent::_duplicate(m_uploadAgent) );

                SetDiskBufferWritten();
                if (!CORBA::is_nil(m_uploadAgent)) {
                    m_uploadAgent->Remove();
                    m_uploadAgent = i_UploadAgent::_nil();
                };
            );
        } catch (ivd_Exception& e) {
            log_ERR_m("[" << m_iJobParams.jobID <<
                      "] " << "Caught Exception in second " <<
                      "DoMigration Retry: " << e);
                      
             log_WriteEvent(evt_ERROR,
                            e.GetFriendly(),
                            GetJobTypeText(),
                            m_iJobParams.jobID);
                      
            m_status = i_CLIENT_ERROR;
            throw;
        }
    }

    if (numOfFiles == 0) {
        log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                            "] " <<
                            "No files written to disk buffer. " <<
                            "Complete job.")

        m_status = i_CLIENT_NOFILES;
        throw ivd_Error(ie_NO_FILES);
    }

    if (IsAborted()) {
        return;
    }
    

    log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                       "] " <<"DoMigJob Finished, will call RM->GetResources");

    SetStatus(job_MED_PROC);
    try {
        ipc_EXEC_m(

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

                i_ResourceList_t tmpRes;
                tmpRes.length(1);
                tmpRes[0] = GetResources()[i];
                tmpRes[0].resRequested = true;

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

                SetResRequested(i);
            }

        );
    } catch (ivd_Exception& e){
        log_DBG_m(dbg_NORM, "[" << m_iJobParams.jobID <<
                            "] " << "RM->GetResources failed.");

        log_WriteEvent(evt_ERROR, 
                       e.GetFriendly(),
                       GetJobTypeText(), 
                       m_iJobParams.jobID);

        m_status = i_RESOURCE_ERROR;
        throw;
    }


    try {

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

                if ( NeedsProcess(i)) {
                    Process(i);
                    SetResProcessed(i);
                    i = 0; //start from begining
                }
            }

            if (IsAborted() || (m_status == i_FAILED) ) {
                return;
            }

            bool gotRes(false);

            log_DBG_m(dbg_DETAIL,
                "[" << m_iJobParams.jobID <<
                "] locking mutex.");

            cmn_MutexLock l(m_activate_x);

            log_DBG_m(dbg_DETAIL,
                "[" << m_iJobParams.jobID <<
                "] Mutex locked.");

            for (UInt32_t i(0); i < GetResources().length(); i++){
                if (NeedsProcess(i)) {
                    gotRes = true;
                }
            }

            if (!gotRes){
                WaitBeasToFinish(5);
            }

            if (IsAborted() || (m_status == i_FAILED) ) {
                return;
            }
        }
    } catch (ivd_Exception& e){

        log_WriteEvent(evt_ERROR,
                       e.GetFriendly(),
                       GetJobTypeText(),
                       m_iJobParams.jobID);

        m_status = i_FAILED;
        throw;
    }
}

Here is the call graph for this function:

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

Implements i_Job_i.

Definition at line 573 of file i_migrationjob_impl.cpp.

References pm_FileList::ConvertToCorba(), and m_files.

                                               {
    return m_files.ConvertToCorba();
}

Here is the call graph for this function:

i_FSC_ptr i_MigrationJob_i::GetFSC ( void   )  [virtual]

Implements i_Job_i.

Definition at line 563 of file i_migrationjob_impl.cpp.

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

                                   {
    log_FUNC_m(GetFSC);

    try {
        i_FSC_var tmpFSC = i_FSC::_duplicate(m_iPM.GetFSC());
        return tmpFSC._retn();
    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

void i_MigrationJob_i::GetNewResources ( i_Index_t  a_resNum  )  [virtual]
void i_MigrationJob_i::MediumOperationComplete ( i_Index_t  a_beaNum,
i_CompletionStatus_e  a_status 
) [virtual]

Implements i_Job_i.

Definition at line 205 of file i_migrationjob_impl.cpp.

References cmn_Condition::Broadcast(), bs_NOT_RUNNING, CompleteJob(), dbg_NORM, evt_ERROR, i_Job_i::GetJobTypeText(), i_Job_i::GetResources(), i_DATA_ERROR, i_FAILED, i_HW_ERROR, i_SUCCEDED, ie_FATAL_ERROR, ipc_EXEC_m, i_Job_i::IsAborted(), job_POST_MED_PROC, i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), ipc_Log::LogStatus(), i_Job_i::m_activate_c, i_Job_i::m_activate_x, m_allBeaSuccess, i_Job_i::m_beasStatus_x, i_Job_i::m_iJobParams, m_numOfBeas, i_Job_i::m_rm, i_Job_i::m_status, i_JobParams::phase, i_Job_i::ReleaseResource(), i_Job_i::SetBeaStatus(), i_Job_i::SetResMedOpComplete(), and i_Job_i::SetStatus().

                                                                   {

    log_FUNC_m(MediumOperationComplete);
    log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                        "] " << "Migration MediumOperationComplete called by Bea: " << 
                        a_beaNum << "  status: [" << a_status << "]" <<
                        ipc_Log::LogStatus(a_status) << endl <<
                        m_iJobParams.jobID);
    
    if (IsAborted()){
        return;
    }
    SetResMedOpComplete(a_beaNum);

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

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

    //free up resources
    ReleaseResource(a_beaNum);
            
    if (m_numOfBeas > 1) { // are there any more beas active
        m_numOfBeas--;     // decrease bea counter
        ostringstream os;
        os << "Copy num:" << a_beaNum << " failed";

        switch (a_status){
            case(i_SUCCEDED):
                
                //log_ERR_m("BEA num:" << a_beaNum << " SUCCEDED");
                break;
            case(i_FAILED):
                m_allBeaSuccess = false;
                os << ".";
                log_ERR_m( os.str() );
                log_WriteEvent( evt_ERROR, 
                                os.str(), 
                                GetJobTypeText(), 
                                m_iJobParams.jobID);
                break;
            case(i_HW_ERROR):
                m_allBeaSuccess = false;
                os << " (HW ERROR).";
                log_ERR_m( os.str() );
                log_WriteEvent( evt_ERROR, 
                                os.str(), 
                                GetJobTypeText(), 
                                m_iJobParams.jobID);
                break;
            case(i_DATA_ERROR):
                m_allBeaSuccess = false;
                os << " (DATA ERROR).";
                log_ERR_m( os.str() );
                log_WriteEvent( evt_ERROR, 
                                os.str(), 
                                GetJobTypeText(), 
                                m_iJobParams.jobID);
                break;
            default:
                log_ERR_m(  "Unhandled bea completion status " << 
                            ipc_Log::LogStatus(a_status));

                m_allBeaSuccess = false;
                os << " (" << ipc_Log::LogStatus(a_status) << ").";
                log_ERR_m( os.str() );
                log_WriteEvent( os.str(),
                                GetJobTypeText(),
                                m_iJobParams.jobID);

        }
        ipc_EXEC_m(m_rm->SetPhase(m_iJobParams.jobID, m_iJobParams.phase++););
    }
    else {    //no more beas active
        if (m_allBeaSuccess && (a_status == i_SUCCEDED)) {
            //if all previous bea succeeded
            CompleteJob(i_SUCCEDED);

        } else {
            m_status = i_FAILED;
            cmn_MutexLock l(m_activate_x);
            m_activate_c.Broadcast();
        }
        SetStatus(job_POST_MED_PROC);
    }
}

Here is the call graph for this function:

void i_MigrationJob_i::Process ( Int32_t  a_copyNum  )  [private]

Non-interface function.

Definition at line 538 of file i_migrationjob_impl.cpp.

References i_Job_i::ActivateBea(), bs_PROCESSING, ipc_EXEC_m, i_Job_i::IsAborted(), i_Job_i::LoadUnload(), log_FUNC_m, i_Job_i::m_activeBeas, i_Job_i::m_beasStatus_x, and i_Job_i::SetBeaStatus().

Referenced by Execute().

                                               {
    log_FUNC_m(Process);

    if (IsAborted()){
        return;
    }
    
    ipc_EXEC_m(
        LoadUnload(a_copyNum);
        cmn_MutexLock l(m_beasStatus_x);
        if (CORBA::is_nil(m_activeBeas[a_copyNum])) {
            i_Job_i::ActivateBea(a_copyNum);
            m_activeBeas[a_copyNum]->Migrate();
        }
        else {
            // ActivateBea will set the drive properties
            i_Job_i::ActivateBea(a_copyNum);
        }
        SetBeaStatus(a_copyNum, bs_PROCESSING);
    );

}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class pm_AssignResThread [friend]

Definition at line 68 of file i_migrationjob_impl.h.

Referenced by AssignResources().


Member Data Documentation

Reimplemented from i_Job_i.

Definition at line 115 of file i_migrationjob_impl.h.

Definition at line 103 of file i_migrationjob_impl.h.

Referenced by MediumOperationComplete().

Definition at line 107 of file i_migrationjob_impl.h.

Referenced by CompleteJob(), Execute(), GetFiles(), and i_MigrationJob_i().

Definition at line 113 of file i_migrationjob_impl.h.

Referenced by CompleteJob().

Definition at line 98 of file i_migrationjob_impl.h.

Referenced by CompleteJob(), Execute(), GetFSC(), and i_MigrationJob_i().

Definition at line 110 of file i_migrationjob_impl.h.

Referenced by CompleteJob().

Definition at line 111 of file i_migrationjob_impl.h.

Referenced by CompleteJob().

Definition at line 108 of file i_migrationjob_impl.h.

Referenced by CompleteJob(), i_MigrationJob_i(), and MediumOperationComplete().

i_UploadAgent_var i_MigrationJob_i::m_uploadAgent [private]

Definition at line 105 of file i_migrationjob_impl.h.

Referenced by Execute(), and ~i_MigrationJob_i().


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