Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

i_LibraryAgentManual_i Class Reference
[IVD Library Agent]

#include <i_la-m_impl.h>

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

List of all members.

Public Member Functions

 i_LibraryAgentManual_i (string a_libName)
virtual ~i_LibraryAgentManual_i ()
void Inventory (CORBA::Boolean a_force)
void Load (const char *a_slot, const char *a_drive, const char *a_barcode, i_JobID_t a_jobID)
void Unload (const char *a_drive, const char *a_slot, const char *a_barcode, i_JobID_t a_jobID)
void ConfirmMountRequest (const char *a_drive, CORBA::Boolean a_ok)
void Reconfigure (const i_Library_t &a_libCfg)
void Remove ()

Private Member Functions

void ReadDriveInfo ()

Private Attributes

 log_CLASSID_m
string m_libName
string m_libHost
vector< la_ManualDrivem_drives
i_ResourceManager_var m_iRM
void(* m_methodFunc )(string a_addr, string a_lib, string a_host, string a_what, string a_drive, string a_bc, string a_slot)
string m_methodAddr

Static Private Attributes

static cmn_Mutex m_lib_x
static cmn_Condition m_lib_c

Detailed Description

Definition at line 50 of file i_la-m_impl.h.


Constructor & Destructor Documentation

i_LibraryAgentManual_i::i_LibraryAgentManual_i ( string  a_libName  ) 

Definition at line 97 of file i_la-m_impl.cpp.

References dbg_LOW, ipc_EXEC_m, log_DBG_m, log_ERR_m, log_FUNC_A_m, m_iRM, Reconfigure(), and ipc_Corba::ResolveRM().

  : m_libName (a_libName) {

    log_FUNC_A_m(i_LibraryAgentManual_i, "libName: " << a_libName);

    ipc_EXEC_m(
        CORBA::Object_var obj = ipc_Corba::ResolveRM();
        m_iRM = i_ResourceManager::_narrow(obj);
    );

    i_Library_t_var lib;
    try {
        ipc_EXEC_m(
            lib = m_iRM->SelectLibrary( CORBA::string_dup(a_libName.c_str()) );
        );
    }
    catch (...) {
        log_ERR_m(
            "Can't get library's control device for " <<
            a_libName);

        throw;
    }

    Reconfigure(lib);

    log_DBG_m(dbg_LOW, endl <<
        "** Starting library agent **" << endl <<
        " - Name      : " << a_libName << endl );
}

Here is the call graph for this function:

i_LibraryAgentManual_i::~i_LibraryAgentManual_i (  )  [virtual]

Definition at line 129 of file i_la-m_impl.cpp.

References log_FUNC_m, and ipc_Corba::Shutdown().

Here is the call graph for this function:


Member Function Documentation

void i_LibraryAgentManual_i::ConfirmMountRequest ( const char *  a_drive,
CORBA::Boolean  a_ok 
)

Definition at line 294 of file i_la-m_impl.cpp.

References cmn_Condition::Broadcast(), dbg_NORM, ie_LA_UNCONFIGURED, ivd_Error, log_DBG_m, log_FUNC_A_m, m_drives, m_lib_c, m_lib_x, la_ManualDrive::mountConfirmed, and la_ManualDrive::mountOK.

                                                                    {
    log_FUNC_A_m(ConfirmMountRequest, "drive: " << a_drive << " ok: " << a_ok);

    cmn_MutexLock l(m_lib_x);
    try {
        la_ManualDrive *drive = NULL;
        for (UInt32_t i=0; i < m_drives.size(); ++i) {
            if (m_drives[i].driveName == a_drive) {
                drive = &m_drives[i];
                break;
            }
        }

        if (!drive) {
            log_DBG_m(dbg_NORM, "Drive not configured: " << a_drive);
            ostringstream sstr;
            sstr << "drive: " << a_drive;
            throw ivd_Error(ie_LA_UNCONFIGURED, sstr.str().c_str());
        }

        drive->mountConfirmed = true;
        drive->mountOK = a_ok;

        log_DBG_m(dbg_NORM, "Sending signal for drive: " << a_drive);
        m_lib_c.Broadcast();

    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

void i_LibraryAgentManual_i::Inventory ( CORBA::Boolean  a_force  ) 

Definition at line 137 of file i_la-m_impl.cpp.

References dbg_NORM, log_DBG_m, log_FUNC_A_m, and ReadDriveInfo().

                                                          {
    log_FUNC_A_m(Inventory, "force: " << a_force);

    log_DBG_m(dbg_NORM, "Inventory requested - rereading drives");
    ReadDriveInfo();
}

Here is the call graph for this function:

void i_LibraryAgentManual_i::Load ( const char *  a_slot,
const char *  a_drive,
const char *  a_barcode,
i_JobID_t  a_jobID 
)

Definition at line 145 of file i_la-m_impl.cpp.

References dbg_NORM, la_ManualDrive::driveName, evt_ERROR, ivd_BaseException::GetFriendly(), ie_FATAL_ERROR, ie_LA_MOUNTDENY, ie_LA_UNCONFIGURED, ipc_CATCH_IVD_THROW_CORBA_m, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_A_m, log_WriteEvent(), m_drives, m_iRM, m_lib_c, m_lib_x, m_libHost, m_libName, m_methodAddr, m_methodFunc, la_ManualDrive::mountConfirmed, la_ManualDrive::mountOK, and cmn_Condition::Wait().

                       {

    log_FUNC_A_m(Load,
        "slot: " << a_slot <<
        " drive: " << a_drive <<
        " barcode: " << a_barcode <<
        " job: " << a_jobID);

    cmn_MutexLock l(m_lib_x);

    try {
    
        la_ManualDrive *drive = NULL;
        for (UInt32_t i=0; i < m_drives.size(); ++i) {
            if (m_drives[i].driveIndex == a_drive) {
                drive = &m_drives[i];
                break;
            }
        }

        if (!drive) {
            log_DBG_m(dbg_NORM, "Drive not configured: " << a_drive);
            ostringstream sstr;
            sstr << "driveIdx: " << a_drive;
            throw ivd_Error(ie_LA_UNCONFIGURED, sstr.str().c_str());
        }

        try {
            string what = "load";
            m_methodFunc(m_methodAddr, m_libName, m_libHost, what,
                         drive->driveName, a_barcode, a_slot);

            // now wait for signal the mount request passed
            log_DBG_m(dbg_NORM, "Wait mount confirmation for drive: " << a_drive);
            drive->mountConfirmed = false;
            drive->mountOK = false;

            while (!drive->mountConfirmed) {
                m_lib_c.Wait();
                log_DBG_m(dbg_NORM, "Got signal on drive: " << a_drive);
            }

            log_DBG_m(dbg_NORM, "Got mount confirmation for drive: " << a_drive);

            if (drive->mountOK) {
                ipc_EXEC_m(
                    m_iRM->MediumLoaded(
                        CORBA::string_dup(m_libName.c_str()),
                        CORBA::string_dup(a_barcode),
                        CORBA::string_dup(a_drive) );
                );

                ostringstream sstr;
                sstr << "Move: D=" << a_drive << " <- S=none.";
                log_WriteEvent(sstr.str(), "", a_jobID, a_barcode);
            } 
            else {
                throw ivd_Error(ie_LA_MOUNTDENY, "Load failed");
            }
        }
        catch (ivd_Exception &ie) {
            ostringstream sstr;
            sstr
                << "Move: D=" << a_drive << " <- S=none FAILED ("
                << ie.GetFriendly() << ").";
            log_WriteEvent(evt_ERROR, sstr.str(), "", a_jobID, a_barcode);

            throw;
        }
        catch (...) {
            ostringstream sstr;
            sstr << "Move: D=" << a_drive << " <- S=none FAILED.";
            log_WriteEvent(evt_ERROR, sstr.str(), "", a_jobID, a_barcode);

            throw ivd_Error(
                ie_FATAL_ERROR, "Unknown exception performing Load.");
        }
    } ipc_CATCH_IVD_THROW_CORBA_m
}

Here is the call graph for this function:

void i_LibraryAgentManual_i::ReadDriveInfo (  )  [private]

Definition at line 53 of file i_la-m_impl.cpp.

References dbg_DETAIL, la_ManualDrive::driveIndex, i_Drive_t::driveIndex, la_ManualDrive::driveName, i_Drive_t::driveName, ipc_EXEC_m, i_Drive_t::libraryName, log_DBG_m, log_FUNC_m, log_WRN_m, m_drives, m_iRM, and m_libName.

Referenced by Inventory(), and Reconfigure().

                                           {
    log_FUNC_m(ReadDriveInfo);

    try {
        m_drives.clear();

        i_DriveSeq_t_var drives;
        ipc_EXEC_m(
            drives = m_iRM->SelectAllDrives();
        );

        for (UInt32_t i = 0; i < drives->length(); i++) {

            i_Drive_t drive = drives[i];

            if (m_libName == string(drive.libraryName) ) {

                log_DBG_m(dbg_DETAIL,
                    "Got drive: " << drive.driveIndex <<
                    " : " << drive.driveName);

                la_ManualDrive manDrive;

                manDrive.driveName  = drive.driveName;
                manDrive.driveIndex = drive.driveIndex;

                m_drives.push_back(manDrive);
            } // if (m_lib
        } // for
    }
    catch (ivd_Exception &ie) {
        log_WRN_m(
            "Library Agent can't get tape drive info from RM." <<
            endl << "Error: " << ie);
        throw;
    }
    catch (...) {
        log_WRN_m(
            "Library Agent can't get tape drive info from RM." <<
            endl << "Error unknown.");
        throw;
    }
}

Here is the caller graph for this function:

void i_LibraryAgentManual_i::Reconfigure ( const i_Library_t a_libCfg  ) 

Definition at line 324 of file i_la-m_impl.cpp.

References i_Library_t::controlDevice, dbg_LOW, i_Library_t::host, ie_FATAL_ERROR, ivd_Error, log_DBG_m, log_ERR_m, log_FUNC_m, m_libHost, m_methodAddr, m_methodFunc, and ReadDriveInfo().

Referenced by i_LibraryAgentManual_i().

                                                                    {
    log_FUNC_m(Reconfigure);

    try {
        m_libHost = string(a_libCfg.host);
        string methodStr = string(a_libCfg.controlDevice);

        if (methodStr.substr(0, 7) == string("mailto:")) {
            m_methodFunc = SendEmail;
            m_methodAddr = methodStr.substr(7);
        }
        else if (methodStr.substr(0, 8) == string("writeto:")) {
            m_methodFunc = SendMsg;
            m_methodAddr = methodStr.substr(8);
        }
        else {
            log_ERR_m("Manual robot method not supported: " << methodStr);

            throw ivd_Error(
                ie_FATAL_ERROR, "Invalid method for Manual Robot");
        }

        // now read all drive connected to this library
        ReadDriveInfo();

        log_DBG_m(dbg_LOW, endl <<
            " - Method    : " << methodStr );

    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void i_LibraryAgentManual_i::Remove (  )  [virtual]

Reimplemented from i_Component_i.

Definition at line 355 of file i_la-m_impl.cpp.

References log_FUNC_m.

void i_LibraryAgentManual_i::Unload ( const char *  a_drive,
const char *  a_slot,
const char *  a_barcode,
i_JobID_t  a_jobID 
)

Definition at line 230 of file i_la-m_impl.cpp.

References dbg_NORM, evt_ERROR, ivd_BaseException::GetFriendly(), ie_FATAL_ERROR, ie_LA_UNCONFIGURED, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_A_m, log_WriteEvent(), m_drives, m_iRM, m_lib_x, and m_libName.

                         {

    log_FUNC_A_m(Unload,
        "drive: " << a_drive <<
        " slot: " << a_slot <<
        " barcode: " << a_barcode <<
        " job: " << a_jobID);

    cmn_MutexLock l(m_lib_x);
    try {
    
        la_ManualDrive *drive = NULL;
        for (UInt32_t i=0; i < m_drives.size(); ++i) {
            if (m_drives[i].driveIndex == a_drive) {
                drive = &m_drives[i];
                break;
            }
        }

        if (!drive) {
            log_DBG_m(dbg_NORM, "Drive not configured: " << a_drive);
            ostringstream sstr;
            sstr << "driveIdx: " << a_drive;
            throw ivd_Error(ie_LA_UNCONFIGURED, sstr.str().c_str());
        }
    
        try {
            ipc_EXEC_m(
                m_iRM->MediumUnLoaded(
                    CORBA::string_dup(m_libName.c_str()),
                    CORBA::string_dup(a_barcode),
                    CORBA::string_dup(a_slot),
                    rmdb_REP_SLOT_TYPE_ID );
            );

            ostringstream sstr;
            sstr << "Move: D=" << a_drive << " -> S=none.";
            log_WriteEvent(sstr.str(), "", a_jobID, a_barcode);
        }
        catch (ivd_Exception &ie) {
            ostringstream sstr;
            sstr
                << "Move: D=" << a_drive << " -> S=none FAILED ("
                << ie.GetFriendly() << ").";
            log_WriteEvent(evt_ERROR, sstr.str(), "", a_jobID, a_barcode);

            throw;
        }
        catch (...) {
            ostringstream sstr;
            sstr << "Move: D=" << a_drive << " -> S=none FAILED.";
            log_WriteEvent(evt_ERROR, sstr.str(), "", a_jobID, a_barcode);

            throw ivd_Error(
                ie_FATAL_ERROR, "Unknown exception performing Unload.");
        }
    } ipc_CATCH_IVD_THROW_CORBA_m;
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from i_Component_i.

Definition at line 55 of file i_la-m_impl.h.

Definition at line 63 of file i_la-m_impl.h.

Referenced by ConfirmMountRequest(), Load(), ReadDriveInfo(), and Unload().

i_ResourceManager_var i_LibraryAgentManual_i::m_iRM [private]

Definition at line 65 of file i_la-m_impl.h.

Referenced by i_LibraryAgentManual_i(), Load(), ReadDriveInfo(), and Unload().

Definition at line 58 of file i_la-m_impl.h.

Referenced by ConfirmMountRequest(), and Load().

Definition at line 57 of file i_la-m_impl.h.

Referenced by ConfirmMountRequest(), Load(), and Unload().

Definition at line 61 of file i_la-m_impl.h.

Referenced by Load(), and Reconfigure().

Definition at line 60 of file i_la-m_impl.h.

Referenced by Load(), ReadDriveInfo(), and Unload().

Definition at line 70 of file i_la-m_impl.h.

Referenced by Load(), and Reconfigure().

void(* i_LibraryAgentManual_i::m_methodFunc)(string a_addr, string a_lib, string a_host, string a_what, string a_drive, string a_bc, string a_slot) [private]

Definition at line 67 of file i_la-m_impl.h.

Referenced by Load(), and Reconfigure().


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