Classes | Enumerations | Functions

IVD Helper Service
[Common modules]

Collaboration diagram for IVD Helper Service:

Classes

class  i_UploadAgent_i
class  i_DownloadAgent_i
class  ivd_DD_Result
 Class for passing dd exitcode & output from dd thread to Agent. More...
class  ivd_DD
 Class for dd thread (for Backup and Restore Agent). More...
class  i_BackupAgent_i
class  i_RestoreAgent_i
struct  svc_execString
class  i_Service_i

Enumerations

enum  svc_Binaries_e {
  SVC_IVDRM, SVC_IVDPM,
  SVC_IVDFSEVTMGR, SVC_IVDHSM,
  SVC_IVDBEA, SVC_IVDLAS,
  SVC_IVDLAM, SVC_ECHO,
  SVC_SENTINEL
}

Functions

 i_UploadAgent_i::i_UploadAgent_i (i_DirectoryType_e a_dtType, const char *a_relName)
virtual i_UploadAgent_i::~i_UploadAgent_i ()
void i_UploadAgent_i::Write (const i_DataBlock_t &a_block, i_BlkSize_t a_size)
 Write methods has built in retries for a predefined amount of time for cases when target disk gets full.
void i_UploadAgent_i::Close ()
 i_DownloadAgent_i::i_DownloadAgent_i (i_DirectoryType_e a_dtType, const char *a_relName)
virtual i_DownloadAgent_i::~i_DownloadAgent_i ()
void i_DownloadAgent_i::Read (i_DataBlock_t_out a_block, i_BlkSize_t &a_size)
void i_DownloadAgent_i::Close ()
 ivd_DD_Result::ivd_DD_Result ()
void ivd_DD_Result::SetResult (long a_exitCode, const string &a_outputStr)
long ivd_DD_Result::GetResult (string &a_outputStr)
 ivd_DD::ivd_DD (const string &a_device, const string &a_pipe, UInt32_t a_blkSize, bool a_write, ivd_DD_Result *a_result)
virtual void ivd_DD::Run (void *a_arg)
 i_BackupAgent_i::i_BackupAgent_i (const char *a_device, const char *a_pipe, i_BlkSize_t a_blkSize)
virtual i_BackupAgent_i::~i_BackupAgent_i ()
CORBA::Long i_BackupAgent_i::GetResult (CORBA::String_out a_outputStr)
 i_RestoreAgent_i::i_RestoreAgent_i (const char *a_device, const char *a_pipe, i_BlkSize_t a_blkSize)
virtual i_RestoreAgent_i::~i_RestoreAgent_i ()
CORBA::Long i_RestoreAgent_i::GetResult (CORBA::String_out a_outputStr)

Enumeration Type Documentation

Enumerator:
SVC_IVDRM 
SVC_IVDPM 
SVC_IVDFSEVTMGR 
SVC_IVDHSM 
SVC_IVDBEA 
SVC_IVDLAS 
SVC_IVDLAM 
SVC_ECHO 
SVC_SENTINEL 

Definition at line 37 of file svc_defines.h.

             {
    SVC_IVDRM, 
    SVC_IVDPM,
    SVC_IVDFSEVTMGR,
    SVC_IVDHSM,
    SVC_IVDBEA,
    SVC_IVDLAS,
    SVC_IVDLAM,
    
    SVC_ECHO, //just for ut 

    SVC_SENTINEL
} svc_Binaries_e ;


Function Documentation

void i_UploadAgent_i::Close ( void   )  [inherited]

Definition at line 130 of file i_netio_impl.cpp.

References cmn_File::CloseF(), dbg_LOW, cmn_File::GetCurrentPosF(), log_DBG_m, log_FUNC_m, i_UploadAgent_i::m_target, and cmn_File::TruncF().

Referenced by i_UploadAgent_i::~i_UploadAgent_i().

                            {

    log_FUNC_m(Close);

    try {
        // Only valid amount of data in the block is written to the file
        // We have to prolong the last block of the file to be divisable
        // with the block size.
        ivd_FilePosition_t eofPos = m_target.GetCurrentPosF();
        log_DBG_m(dbg_LOW, "Setting EOF at " << eofPos);
        m_target.TruncF(eofPos);
        m_target.CloseF();
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_DownloadAgent_i::Close ( void   )  [inherited]

Definition at line 205 of file i_netio_impl.cpp.

References cmn_File::CloseF(), log_FUNC_m, and i_DownloadAgent_i::m_source.

                              {

    log_FUNC_m(Close);

    try {
        m_source.CloseF();
    }
    ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

CORBA::Long i_BackupAgent_i::GetResult ( CORBA::String_out  a_outputStr  )  [inherited]

Definition at line 344 of file i_netio_impl.cpp.

References ivd_DD_Result::GetResult(), log_FUNC_m, and i_BackupAgent_i::m_ddResult.

                                                                {

    log_FUNC_m(GetResult);

    string outStr;
    CORBA::Long ret = m_ddResult.GetResult(outStr);

    a_outputStr = CORBA::string_dup(outStr.c_str());
    return ret;
}

Here is the call graph for this function:

CORBA::Long i_RestoreAgent_i::GetResult ( CORBA::String_out  a_outputStr  )  [inherited]

Definition at line 378 of file i_netio_impl.cpp.

References ivd_DD_Result::GetResult(), log_FUNC_m, and i_RestoreAgent_i::m_ddResult.

                                                                 {

    log_FUNC_m(GetResult);

    string outStr;
    CORBA::Long ret = m_ddResult.GetResult(outStr);

    a_outputStr = CORBA::string_dup(outStr.c_str());
    return ret;
}

Here is the call graph for this function:

long ivd_DD_Result::GetResult ( string &  a_outputStr  )  [inherited]

Definition at line 237 of file i_netio_impl.cpp.

References log_FUNC_m, ivd_DD_Result::m_exitCode, ivd_DD_Result::m_exited, ivd_DD_Result::m_outputStr, ivd_DD_Result::m_result_c, ivd_DD_Result::m_result_x, and cmn_Condition::Wait().

Referenced by i_RestoreAgent_i::GetResult(), and i_BackupAgent_i::GetResult().

                                                 {
    log_FUNC_m(GetResult);

    cmn_MutexLock l(m_result_x);

    while (!m_exited) {
        m_result_c.Wait();
    }

    a_outputStr = m_outputStr;
    return m_exitCode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

i_BackupAgent_i::i_BackupAgent_i ( const char *  a_device,
const char *  a_pipe,
i_BlkSize_t  a_blkSize 
) [inherited]

Definition at line 321 of file i_netio_impl.cpp.

References dbg_NORM, fom_WRITE, g_cmn, cmn_File::GetFullPathRef(), log_DBG_m, log_FUNC_m, i_BackupAgent_i::m_dd, i_BackupAgent_i::m_ddResult, ivd_Product::m_nameShortLC, i_UploadAgent_i::m_target, cmn_File::OpenF(), cmn_Global::prod, and cmn_Thread::Start().

                                                                        :
    i_UploadAgent_i(dt_PIPE, a_relName) {

    log_FUNC_m(i_BackupAgent_i);

    log_DBG_m(dbg_NORM, "Create " << g_cmn.prod.m_nameShortLC 
                                  << "-dd thread for write...");
    m_dd = new ivd_DD(a_device, m_target.GetFullPathRef(), a_blkSize,
                         true, &m_ddResult);

    m_dd->Start();

    // ivd-dd is started, now we can open pipe...
    m_target.OpenF(fom_WRITE);
}

Here is the call graph for this function:

i_DownloadAgent_i::i_DownloadAgent_i ( i_DirectoryType_e  a_dtType,
const char *  a_relName 
) [inherited]

Definition at line 150 of file i_netio_impl.cpp.

References cmn_File::CreatePipe(), cmn_Global::dirs, ivd_Directories::diskbuf, dt_DISKBUF, dt_PIPE, dt_TMP, fom_OPEN_EXISTING, fom_READ, g_cmn, ie_INVALID_ARG, log_FUNC_m, i_DownloadAgent_i::m_source, cmn_File::OpenF(), cmn_File::SetFullPath(), and ivd_Directories::tmp.

                                   {

    log_FUNC_m(i_DownloadAgent_i);

    switch (a_dtType) {
        case dt_DISKBUF:
            m_source.SetFullPath(g_cmn.dirs.diskbuf + string(a_relName));
            m_source.OpenF(fom_READ | fom_OPEN_EXISTING);
            break;
        case dt_TMP:
            m_source.SetFullPath(g_cmn.dirs.tmp + string(a_relName));
            m_source.OpenF(fom_READ | fom_OPEN_EXISTING);
            break;
        case dt_PIPE:
            m_source.SetFullPath(string(a_relName)); 
            m_source.CreatePipe();
            // file will be opened explicitly later (when other side is ready)
            break;
        default:
            throw ivd_InternalError(ie_INVALID_ARG, "Wrong data transfer type.");
    }
}

Here is the call graph for this function:

i_RestoreAgent_i::i_RestoreAgent_i ( const char *  a_device,
const char *  a_pipe,
i_BlkSize_t  a_blkSize 
) [inherited]

Definition at line 356 of file i_netio_impl.cpp.

References dbg_NORM, fom_READ, g_cmn, cmn_File::GetFullPathRef(), log_DBG_m, log_FUNC_m, i_RestoreAgent_i::m_dd, i_RestoreAgent_i::m_ddResult, ivd_Product::m_nameShortLC, i_DownloadAgent_i::m_source, cmn_File::OpenF(), cmn_Global::prod, and cmn_Thread::Start().

                                                                        :
    i_DownloadAgent_i(dt_PIPE, a_relName) {

    log_FUNC_m(i_RestoreAgent_i);

    log_DBG_m(dbg_NORM, "Create " << g_cmn.prod.m_nameShortLC 
                                  << "-dd thread for read...");
    m_dd = new ivd_DD(a_device, m_source.GetFullPathRef(), a_blkSize,
                         false, &m_ddResult);
    m_dd->Start();

    // ivd-dd is started, now we can open pipe...
    m_source.OpenF(fom_READ);
}

Here is the call graph for this function:

i_UploadAgent_i::i_UploadAgent_i ( i_DirectoryType_e  a_dtType,
const char *  a_relName 
) [inherited]

Definition at line 59 of file i_netio_impl.cpp.

References cmn_File::CreatePipe(), cmn_Global::dirs, ivd_Directories::diskbuf, dt_DISKBUF, dt_PIPE, dt_TMP, fom_CREATE_NEW, fom_WRITE, g_cmn, ie_INVALID_ARG, log_FUNC_A_m, i_UploadAgent_i::m_target, cmn_File::OpenF(), cmn_File::SetFullPath(), and ivd_Directories::tmp.

                                   {

    log_FUNC_A_m(i_UploadAgent_i, "name: " << a_relName);

    switch (a_dtType) {
        case dt_DISKBUF:
            m_target.SetFullPath(g_cmn.dirs.diskbuf + string(a_relName));
            m_target.OpenF(fom_WRITE | fom_CREATE_NEW);
            break;
        case dt_TMP:
            m_target.SetFullPath(g_cmn.dirs.tmp + string(a_relName));
            m_target.OpenF(fom_WRITE | fom_CREATE_NEW);
            break;
        case dt_PIPE:
            m_target.SetFullPath(string(a_relName));
            m_target.CreatePipe();
            // file will be opened explicitly later (when other side is ready)
            break;
        default:
            throw ivd_InternalError(ie_INVALID_ARG, "Wrong data transfer type.");
    }
}

Here is the call graph for this function:

ivd_DD::ivd_DD ( const string &  a_device,
const string &  a_pipe,
UInt32_t  a_blkSize,
bool  a_write,
ivd_DD_Result a_result 
) [inherited]

Definition at line 251 of file i_netio_impl.cpp.

                                                      :
    m_device(a_device),
    m_pipe(a_pipe),
    m_blkSize(a_blkSize),
    m_write(a_write),
    m_result(a_result) {

}

ivd_DD_Result::ivd_DD_Result (  )  [inherited]

Definition at line 217 of file i_netio_impl.cpp.

                             :
    m_result_c(&m_result_x),
    m_exited(false),
    m_exitCode(-1) {
}

void i_DownloadAgent_i::Read ( i_DataBlock_t_out  a_block,
i_BlkSize_t a_size 
) [inherited]

Definition at line 179 of file i_netio_impl.cpp.

References log_FUNC_m, i_DownloadAgent_i::m_dataBlock, i_DownloadAgent_i::m_source, and cmn_File::ReadF().

                                                                           {

    log_FUNC_m(Read);

    try {
        if (m_dataBlock.size() == 0 || m_dataBlock.size() < a_size) {
            // (Re)allocate buffer.
            m_dataBlock.resize(a_size, 0);
        }

        ivd_FileRetSize_t readBytes = m_source.ReadF(&(m_dataBlock[0]), a_size);

        i_DataBlock_t_var data(new i_DataBlock_t(
                readBytes, readBytes,
                (CORBA::Octet*)(&(m_dataBlock[0])), 0) );

        a_block = data._retn();

        // Logical block size is the same as requested by the call.
        // a_size = a_size;
    }
    ipc_CATCH_IVD_THROW_CORBA_m;

}

Here is the call graph for this function:

void ivd_DD::Run ( void *  a_arg  )  [virtual, inherited]

Reimplemented from cmn_Thread.

Definition at line 262 of file i_netio_impl.cpp.

References cmn_EXEC_WAIT, cmn_ExecCommand(), cmn_Num2Str(), cmn_Global::dbg, dbg_NORM, cmn_Global::dirs, g_cmn, log_Debugger::GetArgFile(), log_Debugger::GetArgFlags(), log_Debugger::GetArgLevel(), ivd_BaseException::GetFriendly(), ivd_Directories::lbin, log_DBG_m, log_FUNC_m, log_WriteEvent(), ivd_DD::m_blkSize, ivd_DD::m_device, ivd_Product::m_nameShortLC, ivd_DD::m_pipe, ivd_DD::m_result, ivd_DD::m_write, cmn_Global::prod, and ivd_DD_Result::SetResult().

                            {

    log_FUNC_m(Run);

    log_DBG_m(dbg_NORM, g_cmn.prod.m_nameShortLC << "-dd thread started...");

    long ret = 0;
    string ddCmd = g_cmn.dirs.lbin + (g_cmn.prod.m_nameShortLC + "-dd"); // First add strings then paths.
    string outStr;
    vector<string> argVec;
    
    if (m_write) {
        argVec.push_back("--write");
    }
    else {
        argVec.push_back("--read");
    }
    argVec.push_back(m_device);
    argVec.push_back(m_pipe);
    argVec.push_back(cmn_Num2Str(m_blkSize/1024));

    // append End-Of-Medium script options
    argVec.push_back("--eom");
    ostringstream sstr;
    sstr << "/usr/bin/python " << g_cmn.dirs.lbin;
    if (m_write) {
         sstr << g_cmn.prod.m_nameShortLC << "-backup.py --change-medium";
    }
    else {
         sstr << g_cmn.prod.m_nameShortLC << "-restore.py --change-medium";
    }

    argVec.push_back(sstr.str());

    if (g_cmn.dbg.GetArgLevel() != "") {
        argVec.push_back("--dbg");
        argVec.push_back(g_cmn.dbg.GetArgLevel());
        argVec.push_back(g_cmn.dbg.GetArgFile());
        argVec.push_back(g_cmn.dbg.GetArgFlags());
    }

    try {
        ret = cmn_ExecCommand(ddCmd, argVec, cmn_EXEC_WAIT);
    }
    catch (ivd_Exception &e) {
        ostringstream sstr;
        sstr << "ERROR: Cannot execute " << ddCmd 
             << " (" << e.GetFriendly() << ").";
        log_WriteEvent(sstr.str());
        m_result->SetResult(-1, outStr);
        return;
    }

    m_result->SetResult(ret, outStr);
}

Here is the call graph for this function:

void ivd_DD_Result::SetResult ( long  a_exitCode,
const string &  a_outputStr 
) [inherited]

Definition at line 224 of file i_netio_impl.cpp.

References cmn_Condition::Broadcast(), log_FUNC_m, ivd_DD_Result::m_exitCode, ivd_DD_Result::m_exited, ivd_DD_Result::m_outputStr, ivd_DD_Result::m_result_c, and ivd_DD_Result::m_result_x.

Referenced by ivd_DD::Run().

                                                                        {
    log_FUNC_m(SetResult);

    cmn_MutexLock l(m_result_x);

    m_exited = true;
    m_exitCode = a_exitCode;
    m_outputStr = a_outputStr;

    m_result_c.Broadcast();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_UploadAgent_i::Write ( const i_DataBlock_t a_block,
i_BlkSize_t  a_size 
) [inherited]

Write methods has built in retries for a predefined amount of time for cases when target disk gets full.

Definition at line 101 of file i_netio_impl.cpp.

References ie_FILE_ERROR, ivd_Error, log_FUNC_m, i_UploadAgent_i::m_target, cmn_File::SeekRelF(), and cmn_File::WriteF().

                                                                            {

    log_FUNC_m(Write);

    try {
        UInt32_t dataLen = a_block.length();
        if (dataLen > 0) {
            UInt32_t bytesWritten = m_target.WriteF(a_block.get_buffer(), dataLen);
            if (bytesWritten != dataLen) {
                ostringstream sstr;
                sstr
                    << "Written differs from requested: "
                    << bytesWritten << " != " << dataLen << ".";

                throw ivd_Error(ie_FILE_ERROR, sstr.str(), true);
            }
        }

        // valid amount of data might be smaller than block size
        // move forward to the end of block size
        if (a_size > dataLen) {
            m_target.SeekRelF(a_size - dataLen);
        }
    }
    ipc_CATCH_IVD_THROW_CORBA_m;

}

Here is the call graph for this function:

i_BackupAgent_i::~i_BackupAgent_i (  )  [protected, virtual, inherited]

Definition at line 339 of file i_netio_impl.cpp.

References log_FUNC_m.

i_DownloadAgent_i::~i_DownloadAgent_i (  )  [protected, virtual, inherited]

Definition at line 175 of file i_netio_impl.cpp.

References log_FUNC_m.

i_RestoreAgent_i::~i_RestoreAgent_i (  )  [protected, virtual, inherited]

Definition at line 373 of file i_netio_impl.cpp.

References log_FUNC_m.

i_UploadAgent_i::~i_UploadAgent_i (  )  [protected, virtual, inherited]

Definition at line 84 of file i_netio_impl.cpp.

References i_UploadAgent_i::Close(), cmn_File::IsOpen(), log_FUNC_m, log_WRN_m, and i_UploadAgent_i::m_target.

                                  {
    log_FUNC_m(~i_UploadAgent_i);
    if (m_target.IsOpen()) {
        try {
            Close();
        }
        catch(...) {
            // Ignore everything in dtor.
            log_WRN_m("Exception in dtor ignored.");
        }
    }
}

Here is the call graph for this function: