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

i_VvCopyJob_i Class Reference
[Management Interface]

#include <i_vvcopyjob_impl.h>

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

List of all members.

Public Member Functions

 i_VvCopyJob_i (mif_JobManager &a_jobManager, const char *a_vVolID, const char *a_barcode,::CORBA::Long a_volNum, const char *a_targetPath,::CORBA::Long a_priority, i_UIMessageServer_ptr &a_UIMS_p)
virtual ~i_VvCopyJob_i ()
void AbortJob ()
void CompleteJob (i_CompletionStatus_e a_jobStatus)
void GetNewResources (i_Index_t a_resourceNumber)
i_JobRequestList_tGetFiles (void)
i_FSC_ptr GetFSC (void)
void MediumOperationComplete (i_Index_t a_index, i_CompletionStatus_e a_completionStatus)

Public Attributes

 log_CLASSID_m

Protected Member Functions

void Execute ()

Protected Attributes

string m_vVolID
string m_barcode
UInt32_t m_volNum
cmn_Path m_targetPath
UInt32_t m_priority
ui_MsgWriter m_ui

Private Member Functions

bool IsDiskMediumOnUNC (const string &a_barcode)
cmn_Path GetDiskMediumPath (const string &a_barcode)
string VolDirName (UInt32_t a_volNum)

Detailed Description

Definition at line 39 of file i_vvcopyjob_impl.h.


Constructor & Destructor Documentation

i_VvCopyJob_i::i_VvCopyJob_i ( mif_JobManager a_jobManager,
const char *  a_vVolID,
const char *  a_barcode,
::CORBA::Long  a_volNum,
const char *  a_targetPath,
::CORBA::Long  a_priority,
i_UIMessageServer_ptr &  a_UIMS_p 
)

Definition at line 51 of file i_vvcopyjob_impl.cpp.

References log_FUNC_m.

                                                        :
    i_Job_i(a_jobManager),
    m_vVolID(a_vVolID),
    m_barcode(a_barcode),
    m_volNum(a_volNum),
    m_targetPath(cmn_Path(a_targetPath) + VolDirName(a_volNum)),
    m_priority(a_priority),
    m_ui(a_UIMS_p){
    log_FUNC_m(i_VvCopyJob_i);
}

i_VvCopyJob_i::~i_VvCopyJob_i (  )  [virtual]

Definition at line 69 of file i_vvcopyjob_impl.cpp.

References log_FUNC_m.

                             {
    log_FUNC_m(~i_VvCopyJob_i);
    //NYI
}


Member Function Documentation

void i_VvCopyJob_i::AbortJob (  )  [virtual]

Reimplemented from i_Job_i.

Definition at line 75 of file i_vvcopyjob_impl.cpp.

References log_FUNC_m.

void i_VvCopyJob_i::CompleteJob ( i_CompletionStatus_e  a_jobStatus  )  [virtual]

Implements i_Job_i.

Definition at line 82 of file i_vvcopyjob_impl.cpp.

                                                               {
    //NYI
}

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

Implements i_Job_i.

Definition at line 115 of file i_vvcopyjob_impl.cpp.

References vvol_Volume::Copy(), dbg_DETAIL, dbg_LOW, dbg_NORM, ui_MsgWriter::DisplayError(), ui_MsgWriter::DisplayMessage(), cmn_File::Exists(), i_Job_i::Finished(), ivd_BaseException::GetError(), ivd_BaseException::GetFriendly(), vvol_Volume::GetHash(), i_Job_i::GetJobTypeText(), i_Job_i::GetResources(), ie_FATAL_ERROR, ie_STD_EXCEPTION, ipc_EXEC_m, i_Job_i::IsAborted(), i_Job_i::IsFinished(), ivd_Error, 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_barcode, i_Job_i::m_iJobParams, m_priority, i_Job_i::m_rm, i_Job_i::m_status, m_targetPath, m_ui, m_volNum, m_vVolID, i_Job_i::NeedsProcess(), NULL, i_Job_i::SetResources(), i_Job_i::SetResRequested(), i_Job_i::SetStatus(), and cmn_Condition::Wait().

                           {
    log_FUNC_m(Execute);
    m_status = i_FAILED;
    try {        
        ostringstream msg;
        // Precondition: Target path must exist
        cmn_File targetPath(m_targetPath);
        if(!targetPath.Exists()) {
            msg << "Path " << m_targetPath << " does not exist. copy failed.";
            log_DBG_m(dbg_LOW,msg.str());
            m_ui.DisplayError(msg.str().c_str());
            return;
        }

        msg << "Getting a valid copy for" << m_vVolID << "...";
        m_ui.DisplayMessage(msg.str());
        log_WriteEvent(msg.str(), GetJobTypeText(), m_iJobParams.jobID);
        msg.str("");


        i_MediumVol_t_var mv;
        try {
            ipc_EXEC_m(mv = m_rm->SelectMediumVol(m_barcode.c_str(), m_volNum););
        } catch (ivd_Exception &e) {
            log_DBG_m(dbg_NORM, e);
            if (e.GetError() == ie_RMDB_NOTFOUND) {
                ostringstream msg;
                msg << "Medium barcode:" << m_barcode;
                msg << ", volNum: " << m_volNum << " not found.";
                log_DBG_m(dbg_LOW, msg.str());
                m_ui.DisplayError(msg.str().c_str());
                return;
            }
            else {
                throw;
            }
        }

        // Precondition: Volume needs to be virtual
        if ((mv->volType & rmdb_VIRTUAL_VOLUME) != rmdb_VIRTUAL_VOLUME ) {
            ostringstream msg;
            msg << "Medium barcode:" << m_barcode;
            msg << ", volNum: " << m_volNum << " is not virtualized yet.";
            log_DBG_m(dbg_LOW, msg.str());
            m_ui.DisplayError(msg.str().c_str());
            return;
        }

        msg << "Getting resources for " << m_vVolID << "...";
        m_ui.DisplayMessage(msg.str());
        log_WriteEvent(msg.str(), GetJobTypeText(), m_iJobParams.jobID);

        i_Resource_t vvRes;
        vvRes.barcode = m_barcode.c_str();
        vvRes.medVolNr = m_volNum;
        vvRes.medVolType = vt_VIRTUAL_VOLUME;
        SetResources(vvRes);
        
        SetStatus(job_MED_PROC);

        SetResRequested(0);
        ipc_EXEC_m( m_rm->GetResources(this->_this(), m_iJobParams, GetResources()););

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

            cmn_MutexLock l(m_activate_x);
            if (NeedsProcess(0)) {
                    
                log_DBG_m(dbg_NORM,"[" << m_iJobParams.jobID <<
                                    "] " << "Resources assigned:" << boolalpha <<
                                        GetResources()[0].resAssigned <<
                                        " copy processed:" << boolalpha <<
                                        GetResources()[0].resProcessed);
                msg << "Starting copy for VV " << m_vVolID << "...";
                m_ui.DisplayMessage(msg.str());
                log_WriteEvent(msg.str(), GetJobTypeText(), m_iJobParams.jobID);
                msg.str("");
                cmn_Path src(vvRes.virtualVolPath);
                vvol_Volume vvFile(src);
                vvFile.Copy(m_targetPath);

                msg << "Copying files finished for VV " << m_vVolID << "adding to database...";
                m_ui.DisplayMessage(msg.str());
                log_WriteEvent(msg.str(), GetJobTypeText(), m_iJobParams.jobID);
                msg.str("");
                Finished();

                i_VirtualVol_t vv;

                vv.mediumBarcode = CORBA::string_dup(mv->mediumBarcode);
                vv.medVolNr = mv->medVolNr;
                vv.vvCopyNum = 1;
                vv.status = 0;
                vv.priority = m_priority;

                vv.checksum = CORBA::string_dup(vvFile.GetHash().c_str());
                ivd_Time_t now  = time(NULL);
                vv.created = (i_Time_t)now;

                m_rm->AddVirtualVol(vv); 

            }
            if (!IsFinished() &&
                !IsAborted()) {

                log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
                                        "] " <<  " waiting for resources ...");
                m_activate_c.Wait();
            }
        }
        
// FIXME: SET m_priority
        
        msg << "Copy finished sucessfully for VV " << m_vVolID << ".";
        m_ui.DisplayMessage(msg.str());
        log_WriteEvent(msg.str(), GetJobTypeText(), m_iJobParams.jobID);
        msg.str("");
    }
    catch (ivd_Exception &e) {
        ostringstream msg;
        msg << "Virtual volume copy failed for VV " << m_vVolID << ". " << e.GetFriendly();
        m_ui.DisplayMessage(msg.str());
        throw;
    }
    catch (std::exception &stde) {
        log_ERR_m(stde.what());
        throw ivd_Error(ie_STD_EXCEPTION, stde.what());
    }
    catch (...) {
        throw ivd_InternalError(ie_FATAL_ERROR, "Unknown exception caught");
    }
    m_status = i_SUCCEDED;    
}

Here is the call graph for this function:

cmn_Path i_VvCopyJob_i::GetDiskMediumPath ( const string &  a_barcode  )  [private]
i_JobRequestList_t * i_VvCopyJob_i::GetFiles ( void   )  [virtual]

Implements i_Job_i.

Definition at line 91 of file i_vvcopyjob_impl.cpp.

References ie_IMPOSSIBLE, ipc_CATCH_IVD_THROW_CORBA_m, ivd_Error, log_FUNC_m, and NULL.

i_FSC_ptr i_VvCopyJob_i::GetFSC ( void   )  [virtual]

Implements i_Job_i.

Definition at line 101 of file i_vvcopyjob_impl.cpp.

References ie_IMPOSSIBLE, ipc_CATCH_IVD_THROW_CORBA_m, ivd_Error, log_FUNC_m, and NULL.

                                   {
    i_FSC_ptr dummy(NULL);
    log_FUNC_m(GetFSC);
    try {
        throw ivd_Error(ie_IMPOSSIBLE);
    }
    ipc_CATCH_IVD_THROW_CORBA_m
    return(dummy);
}

void i_VvCopyJob_i::GetNewResources ( i_Index_t  a_resourceNumber  )  [virtual]

Implements i_Job_i.

Definition at line 87 of file i_vvcopyjob_impl.cpp.

                                                             {
    //NYI
}

bool i_VvCopyJob_i::IsDiskMediumOnUNC ( const string &  a_barcode  )  [private]
void i_VvCopyJob_i::MediumOperationComplete ( i_Index_t  a_index,
i_CompletionStatus_e  a_completionStatus 
) [virtual]

Implements i_Job_i.

Definition at line 111 of file i_vvcopyjob_impl.cpp.

                                                                                      {
}

string i_VvCopyJob_i::VolDirName ( UInt32_t  a_volNum  )  [private]

Definition at line 253 of file i_vvcopyjob_impl.cpp.

                                                  {
    ostringstream sstr;
    sstr
        << std::setw(8) 
        << std::setfill('0')
        << a_volNum;
    return sstr.str();
}


Member Data Documentation

Reimplemented from i_Job_i.

Definition at line 60 of file i_vvcopyjob_impl.h.

string i_VvCopyJob_i::m_barcode [protected]

Definition at line 65 of file i_vvcopyjob_impl.h.

Referenced by Execute().

Definition at line 68 of file i_vvcopyjob_impl.h.

Referenced by Execute().

Definition at line 67 of file i_vvcopyjob_impl.h.

Referenced by Execute().

Definition at line 69 of file i_vvcopyjob_impl.h.

Referenced by Execute().

Definition at line 66 of file i_vvcopyjob_impl.h.

Referenced by Execute().

string i_VvCopyJob_i::m_vVolID [protected]

Definition at line 64 of file i_vvcopyjob_impl.h.

Referenced by Execute().


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