Public Attributes | Private Member Functions | Private Attributes | Friends

rm_Drive Class Reference
[Resource Manager Database Library]

#include <rmdb.h>

Collaboration diagram for rm_Drive:
Collaboration graph
[legend]

List of all members.

Public Attributes

Int32_t driveKey
Int32_t libraryKey
rm_String driveName
Int32_t status
rm_String driveIndex
Int32_t mediaFamily
Int32_t capabilities
Int32_t dataThroughput
Int32_t loadTime
Int32_t unloadTime
Int32_t aveSeekTime
Int32_t rewindTime
Int32_t usageCount
Int32_t cleanNr
rm_TimeStamp lastClean
Int32_t options
rm_String vendorID
rm_String productID
rm_String serialNo
rm_String firmwareRev
rm_String scsiID

Private Member Functions

void Insert ()
void Update ()
void Remove (Int32_t a_driveKey)
void Select (Int32_t a_driveKey)
void SelectByName (rm_String a_name)
void SelectByAddr (int a_libraryKey, rm_String &a_addr)
vector< rm_DriveSelectByStatus (const UInt32_t &a_status)
vector< rm_DriveSelectForOperation (UInt32_t a_libraryKey, UInt32_t a_mediumFamily, UInt32_t a_requiredCapability, bool a_select_in_use)
vector< rm_DriveSelectAll ()
void StartSelectAll ()
void EndSelectAll ()
rm_DriveNext ()
 rm_Drive ()
 rm_Drive (Int32_t a_driveKey)
bool operator== (const rm_Drive &dr2) const

Private Attributes

 log_CLASSID_m

Friends

class rm_Operator
class rm_Medium

Detailed Description

Definition at line 206 of file rmdb.h.


Constructor & Destructor Documentation

rm_Drive::rm_Drive (  )  [private]
rm_Drive::rm_Drive ( Int32_t  a_driveKey  )  [private]

Member Function Documentation

void rm_Drive::EndSelectAll (  )  [private]

Definition at line 1189 of file librmdb.exx.

References errorDesc(), log_FUNC_m, SQL_CHECKREAD_M, and cmn_Mutex::Unlock().

                           {
    log_FUNC_m(EndSelectAll);

    EXEC SQL
        CLOSE SELECT_ALL_DRIVE;

    g_driveCursor_x.Unlock();
    string sqlErrDesc = errorDesc(SQLCODE,"EXEC SQL CLOSE SELECT_ALL_LIB");
    SQL_CHECKREAD_M(sqlErrDesc);

}// rm_Drive:: EndSelectAll

Here is the call graph for this function:

void rm_Drive::Insert (  )  [private]

Definition at line 853 of file librmdb.exx.

References aveSeekTime, capabilities, cleanNr, rm_String::cvalue_p, dataThroughput, dbg_NORM, driveIndex, driveKey, driveName, errorDesc(), firmwareRev, lastClean, libraryKey, loadTime, log_DBG_m, log_FUNC_m, rm_TimeStamp::m_iscTime, MAX, mediaFamily, NAME, options, productID, rewindTime, serialNo, SQL_CHECK_M, SQL_NOERROR, SQL_UNIQUEVIOLATION, status, unloadTime, usageCount, and vendorID.

Referenced by rm_Operator::Add().

                      {

    log_FUNC_m(Insert);

    if (libraryKey < 1) {
        bi1 = -1;
    }
    else {
        bi1 = 0;
    }

    EXEC SQL
        SET TRANSACTION NAME readWriteTrans;

    Int32_t k(0);
    if ( driveKey == 0 ) {
        EXEC SQL
            SELECT TRANSACTION readWriteTrans
            MAX(driveKey) INTO :k FROM Drive;

        driveKey = ++k;
        log_DBG_m(dbg_NORM,"New drivekey generated: " << driveKey);
    }
    else {
        EXEC SQL SELECT TRANSACTION readWriteTrans
            driveKey INTO :k FROM DRIVE
                    WHERE driveKey = :driveKey;
        if (SQLCODE == SQL_NOERROR) {
                log_DBG_m(dbg_NORM,"key exists");
                throw ivd_DBException( SQL_UNIQUEVIOLATION ,"Drive Key already exists");
        }
    }


    EXEC SQL
        INSERT TRANSACTION readWriteTrans INTO
            DRIVE VALUES(
                    :driveKey,
                    :libraryKey INDICATOR :bi1,
                    :driveName.cvalue_p,
                    :status,
                    :driveIndex.cvalue_p,
                    :mediaFamily,
                    :capabilities,
                    :dataThroughput,
                    :loadTime,
                    :unloadTime,
                    :aveSeekTime,
                    :rewindTime,
                    :usageCount,
                    :cleanNr,
                    :lastClean.m_iscTime,
                    :options,
                    :vendorID.cvalue_p,
                    :productID.cvalue_p,
                    :serialNo.cvalue_p,
                    :serialNo.cvalue_p,
                    :firmwareRev.cvalue_p
                 );

    string sqlErrDesc = errorDesc(SQLCODE,"Insert record into Drive", driveKey);
    SQL_CHECK_M( sqlErrDesc );
}// rm_Drive::Insert()

Here is the call graph for this function:

Here is the caller graph for this function:

rm_Drive & rm_Drive::Next (  )  [private]

Definition at line 1201 of file librmdb.exx.

References aveSeekTime, capabilities, cleanNr, dataThroughput, driveIndex, driveKey, driveName, errorDesc(), firmwareRev, lastClean, libraryKey, loadTime, log_FUNC_m, rm_TimeStamp::m_iscTime, mediaFamily, options, productID, rewindTime, scsiID, serialNo, SQL_CHECKREAD_M, SQL_NOERROR, status, unloadTime, cmn_Mutex::Unlock(), usageCount, and vendorID.

                         {
    log_FUNC_m(Next);

    char driveNameVal[rmdb_MAX_DRIVENAME];
    char driveIndexVal[rmdb_MAX_DRIVEIDX];
    char vendorIDVal[rmdb_MAX_VENDORID];
    char productIDVal[rmdb_MAX_PRODUCTID];
    char serialNoVal[rmdb_MAX_SERIALNO];
    char firmwareRevVal[rmdb_MAX_FIRMWAREREV];
    char scsiIDVal[rmdb_MAX_SCSIID];

    EXEC SQL
        FETCH SELECT_ALL_DRIVE
                    INTO
                        :driveKey,
                        :libraryKey,
                        :driveNameVal,
                        :status,
                        :driveIndexVal,
                        :mediaFamily,
                        :capabilities,
                        :dataThroughput,
                        :loadTime,
                        :unloadTime,
                        :aveSeekTime,
                        :rewindTime,
                        :usageCount,
                        :cleanNr,
                        :lastClean.m_iscTime,
                        :options,
                        :vendorIDVal,
                        :productIDVal,
                        :serialNoVal,
                        :firmwareRevVal,
                        :scsiIDVal;

    if (SQLCODE == SQL_NOERROR) {
        driveName   = driveNameVal;
        driveIndex  = driveIndexVal;
        lastClean   = lastClean.m_iscTime;
        vendorID    = vendorIDVal;
        productID   = productIDVal;
        serialNo    = serialNoVal;
        firmwareRev = firmwareRevVal;
        scsiID      = scsiIDVal;
    }
    else {
        int fetchCode = SQLCODE;
        EXEC SQL
            CLOSE SELECT_ALL_DRIVE;
        g_driveCursor_x.Unlock();
        SQLCODE = fetchCode;
        string sqlErrDesc = errorDesc(fetchCode,"reached end of SELECT_ALL_DRIVE cursor");
        SQL_CHECKREAD_M(sqlErrDesc);
    };

    return *this;
}

Here is the call graph for this function:

bool rm_Drive::operator== ( const rm_Drive dr2  )  const [inline, private]

Definition at line 290 of file rmdb.h.

References capabilities, driveKey, rm_Medium::driveKey, driveName, mediaFamily, productID, serialNo, and vendorID.

                                               {
        return (    ( driveKey == dr2.driveKey          )   &&
                    ( mediaFamily == dr2.mediaFamily    )   &&
                    ( capabilities == dr2.capabilities  )   &&
                    ( driveName == dr2.driveName        )   &&
                    ( vendorID == dr2.vendorID          )   &&
                    ( productID == dr2.productID        )   &&
                    ( serialNo == dr2.serialNo          )   );
    };

void rm_Drive::Remove ( Int32_t  a_driveKey  )  [private]

Definition at line 919 of file librmdb.exx.

References errorDesc(), log_FUNC_m, NAME, and SQL_CHECK_M.

Referenced by rm_Operator::RemoveDrive().

                                        {
    log_FUNC_m(Remove);

    EXEC SQL
        SET TRANSACTION NAME readWriteTrans;

    EXEC SQL
        DELETE TRANSACTION readWriteTrans
        FROM DRIVE WHERE DRIVEKEY = :a_driveKey;

    string sqlErrDesc = errorDesc(SQLCODE,"Remove drive record", a_driveKey);
    SQL_CHECK_M( sqlErrDesc );

} // rm_Drive::Remove

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_Drive::Select ( Int32_t  a_driveKey  )  [private]

Definition at line 983 of file librmdb.exx.

References aveSeekTime, capabilities, cleanNr, dataThroughput, driveIndex, driveKey, driveName, errorDesc(), firmwareRev, lastClean, libraryKey, loadTime, log_FUNC_m, rm_TimeStamp::m_iscTime, mediaFamily, NAME, options, productID, rewindTime, scsiID, serialNo, SQL_CHECKREAD_M, SQL_NOERROR, status, unloadTime, usageCount, and vendorID.

Referenced by rm_Operator::AllocateAdmin(), rm_Drive(), rm_Operator::SelectDrive(), and rm_Operator::SelectDriveForMig().

                                        {
    log_FUNC_m(Select);


    char driveNameVal[rmdb_MAX_DRIVENAME];
    char driveIndexVal[rmdb_MAX_DRIVEIDX];
    char vendorIDVal[rmdb_MAX_VENDORID];
    char productIDVal[rmdb_MAX_PRODUCTID];
    char serialNoVal[rmdb_MAX_SERIALNO];
    char firmwareRevVal[rmdb_MAX_FIRMWAREREV];
    char scsiIDVal[rmdb_MAX_SCSIID];

    EXEC SQL
        SET TRANSACTION NAME readTrans
            READ ONLY
            ISOLATION LEVEL READ COMMITTED;

    EXEC SQL
        SELECT TRANSACTION readTrans
        * INTO
                :driveKey,
                :libraryKey,
                :driveNameVal,
                :status,
                :driveIndexVal,
                :mediaFamily,
                :capabilities,
                :dataThroughput,
                :loadTime,
                :unloadTime,
                :aveSeekTime,
                :rewindTime,
                :usageCount,
                :cleanNr,
                :lastClean.m_iscTime,
                :options,
                :vendorIDVal,
                :productIDVal,
                :serialNoVal,
                :firmwareRevVal,
                :scsiIDVal
       FROM DRIVE WHERE DRIVEKEY = :a_driveKey;

    if ( SQLCODE == SQL_NOERROR ) {
        driveName   = driveNameVal;
        driveIndex  = driveIndexVal;
        vendorID    = vendorIDVal;
        productID   = productIDVal;
        serialNo    = serialNoVal;
        lastClean   = lastClean.m_iscTime;
        firmwareRev     = firmwareRevVal;
        scsiID          = scsiIDVal;
    }

    string sqlErrDesc = errorDesc(SQLCODE,"Select record from Drive", a_driveKey);
    SQL_CHECKREAD_M( sqlErrDesc );

}// rm_Drive::Select

Here is the call graph for this function:

Here is the caller graph for this function:

vector< rm_Drive > rm_Drive::SelectAll (  )  [private]

Definition at line 1501 of file librmdb.exx.

References aveSeekTime, capabilities, cleanNr, cmn_Num2Str(), dataThroughput, dbg_DETAIL, dbg_LOW, dbg_NORM, driveIndex, driveKey, driveName, errorDesc(), firmwareRev, ie_NO_RESOURCE_FOUND, ie_RMDB_ERROR, ivd_Error, lastClean, libraryKey, loadTime, log_DBG_m, log_FUNC_m, rm_TimeStamp::m_iscTime, mediaFamily, NAME, options, productID, rewindTime, scsiID, serialNo, SQL_CHECKREAD_M, SQL_NOERROR, SQL_NOTFOUND, status, unloadTime, usageCount, and vendorID.

Referenced by rm_Operator::SelectAllDrives().

                                    {
    log_FUNC_m(SelectAll);
    cmn_MutexLock l(g_driveCursor_x);

    vector<rm_Drive> selDrive;

    EXEC SQL
        SET TRANSACTION NAME readTrans
            READ ONLY
            ISOLATION LEVEL READ COMMITTED;


    if ( SQLCODE != SQL_NOERROR ) {
        log_DBG_m(dbg_LOW, "SQLERROR: " << SQLCODE);
        throw ivd_Error(ie_RMDB_ERROR," Could not declare cursor SELECT_DRIVE_ALL");
    }
    log_DBG_m(dbg_DETAIL, "declare cursor SELECT_DRIVE_ALL returned sqlcode:" << SQLCODE);

    EXEC SQL
        OPEN TRANSACTION readTrans
        SELECT_ALL_DRIVE;

    if ( SQLCODE != SQL_NOERROR ) {
        throw ivd_Error(ie_RMDB_ERROR," Could not open cursor SELECT_DRIVE_ALL");
    }
    log_DBG_m(dbg_DETAIL, "open cursor SELECT_DRIVE_ALL returned sqlcode:" << SQLCODE);

    bool endOfCursor = false;

    do {
        char driveNameVal[rmdb_MAX_DRIVENAME];
        char driveIndexVal[rmdb_MAX_DRIVEIDX];
        char vendorIDVal[rmdb_MAX_VENDORID];
        char productIDVal[rmdb_MAX_PRODUCTID];
        char serialNoVal[rmdb_MAX_SERIALNO];
        char firmwareRevVal[rmdb_MAX_FIRMWAREREV];
        char scsiIDVal[rmdb_MAX_SCSIID];

        EXEC SQL
            FETCH SELECT_ALL_DRIVE
                        INTO
                            :driveKey,
                            :libraryKey,
                            :driveNameVal,
                            :status,
                            :driveIndexVal,
                            :mediaFamily,
                            :capabilities,
                            :dataThroughput,
                            :loadTime,
                            :unloadTime,
                            :aveSeekTime,
                            :rewindTime,
                            :usageCount,
                            :cleanNr,
                            :lastClean.m_iscTime,
                            :options,
                            :vendorIDVal,
                            :productIDVal,
                            :serialNoVal,
                            :firmwareRevVal,
                            :scsiIDVal;

        if (SQLCODE == SQL_NOERROR) {
            driveName  = driveNameVal;
            driveIndex  = driveIndexVal;
            lastClean   = lastClean.m_iscTime;
            vendorID  = vendorIDVal;
            productID  = productIDVal;
            serialNo = serialNoVal;
            firmwareRev = firmwareRevVal;
            scsiID      = scsiIDVal;
            selDrive.push_back(*this);
        }
        else if (SQLCODE == SQL_NOTFOUND) {
            log_DBG_m(dbg_NORM,"reached end of cursor");
            endOfCursor = true;
        }
        else {
            log_DBG_m(dbg_NORM,"Fatal Drive Allocation error sqlcode:" << SQLCODE);
            throw ivd_Error (
                ie_NO_RESOURCE_FOUND,
                "Fatal DriveAllocation error sqlcode:" +
                cmn_Num2Str((Int32_t)SQLCODE),
                true);
        };

    } while (endOfCursor == false);
    EXEC SQL
        CLOSE SELECT_ALL_DRIVE;
    string sqlErrDesc = errorDesc(SQLCODE,"CLOSE SELECT_ALL_DRIVE");
    SQL_CHECKREAD_M(sqlErrDesc);


    return selDrive;
} //end_of_Select_by_status

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_Drive::SelectByAddr ( int  a_libraryKey,
rm_String a_addr 
) [private]

Definition at line 1103 of file librmdb.exx.

References aveSeekTime, capabilities, cleanNr, rm_String::cvalue_p, dataThroughput, dbg_DETAIL, driveIndex, driveKey, driveName, errorDesc(), firmwareRev, lastClean, libraryKey, loadTime, log_DBG_m, log_FUNC_m, rm_TimeStamp::m_iscTime, mediaFamily, NAME, options, productID, rewindTime, scsiID, serialNo, SQL_CHECKREAD_M, SQL_NOERROR, status, unloadTime, usageCount, and vendorID.

Referenced by rm_Operator::Add(), rm_Operator::InventoryUpdate(), rm_Operator::MediumLoaded(), and rm_Operator::Update().

                                                               {
    log_FUNC_m(SelectByAddr);


    char driveNameVal[rmdb_MAX_DRIVENAME];
    char driveIndexVal[rmdb_MAX_DRIVEIDX];
    char vendorIDVal[rmdb_MAX_VENDORID];
    char productIDVal[rmdb_MAX_PRODUCTID];
    char serialNoVal[rmdb_MAX_SERIALNO];
    char firmwareRevVal[rmdb_MAX_FIRMWAREREV];
    char scsiIDVal[rmdb_MAX_SCSIID];

    EXEC SQL
        SET TRANSACTION NAME readTrans
            READ ONLY
            ISOLATION LEVEL READ COMMITTED;

    EXEC SQL
        SELECT TRANSACTION readTrans
        * INTO
                        :driveKey,
                        :libraryKey,
                        :driveNameVal,
                        :status,
                        :driveIndexVal,
                        :mediaFamily,
                        :capabilities,
                        :dataThroughput,
                        :loadTime,
                        :unloadTime,
                        :aveSeekTime,
                        :rewindTime,
                        :usageCount,
                        :cleanNr,
                        :lastClean.m_iscTime,
                        :options,
                        :vendorIDVal,
                        :productIDVal,
                        :serialNoVal,
                        :firmwareRevVal,
                        :scsiIDVal
                        FROM DRIVE WHERE
                            LIBRARYKEY = :a_libraryKey AND
                            DRIVEINDEX = :a_addr.cvalue_p;

    if ( SQLCODE == SQL_NOERROR ) {
        driveName   = driveNameVal;
        driveIndex  = driveIndexVal;
        lastClean   = lastClean.m_iscTime;
        vendorID    = vendorIDVal;
        productID   = productIDVal;
        serialNo    = serialNoVal;
        firmwareRev = firmwareRevVal;
        scsiID      = scsiIDVal;
        log_DBG_m(dbg_DETAIL, "successfully selected drive: " << driveName);
    }
    string sqlErrDesc = errorDesc(SQLCODE, "Selecting Drive record by Addr");
    SQL_CHECKREAD_M( sqlErrDesc );



}// rm_Drive::SelectByAddr

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_Drive::SelectByName ( rm_String  a_name  )  [private]

Definition at line 1043 of file librmdb.exx.

References aveSeekTime, capabilities, cleanNr, rm_String::cvalue_p, dataThroughput, dbg_DETAIL, driveIndex, driveKey, driveName, errorDesc(), firmwareRev, lastClean, libraryKey, loadTime, log_DBG_m, log_FUNC_m, rm_TimeStamp::m_iscTime, mediaFamily, NAME, options, productID, rewindTime, scsiID, serialNo, SQL_CHECKREAD_M, SQL_NOERROR, status, unloadTime, usageCount, and vendorID.

Referenced by rm_Operator::Add(), rm_Operator::RemoveDrive(), rm_Operator::RemoveDriveHost(), rm_Operator::SelectDrive(), rm_Operator::SelectDriveHost(), rm_Operator::SelectMediumByDrive(), and rm_Operator::Update().

                                            {
    log_FUNC_m(SelectByName);


    char driveNameVal[rmdb_MAX_DRIVENAME];
    char driveIndexVal[rmdb_MAX_DRIVEIDX];
    char vendorIDVal[rmdb_MAX_VENDORID];
    char productIDVal[rmdb_MAX_PRODUCTID];
    char serialNoVal[rmdb_MAX_SERIALNO];
    char firmwareRevVal[rmdb_MAX_PRODUCTID];
    char scsiIDVal[rmdb_MAX_SERIALNO];

    EXEC SQL
        SET TRANSACTION NAME readTrans
            READ ONLY
            ISOLATION LEVEL READ COMMITTED;

    EXEC SQL
        SELECT TRANSACTION readTrans
        * INTO
                        :driveKey,
                        :libraryKey,
                        :driveNameVal,
                        :status,
                        :driveIndexVal,
                          :mediaFamily,
                        :capabilities,
                        :dataThroughput,
                        :loadTime,
                        :unloadTime,
                        :aveSeekTime,
                        :rewindTime,
                        :usageCount,
                        :cleanNr,
                        :lastClean.m_iscTime,
                        :options,
                        :vendorIDVal,
                        :productIDVal,
                        :serialNoVal,
                        :firmwareRevVal,
                        :scsiIDVal
               FROM DRIVE WHERE DRIVENAME = :a_name.cvalue_p;

    if ( SQLCODE == SQL_NOERROR ) {
        driveName       = driveNameVal;
        driveIndex      = driveIndexVal;
        vendorID        = vendorIDVal;
        productID       = productIDVal;
        serialNo        = serialNoVal;
        firmwareRev     = firmwareRevVal;
        scsiID          = scsiIDVal;
        log_DBG_m(dbg_DETAIL, "successfully selected drive: ");
    }
    string sqlErrDesc = errorDesc(SQLCODE, "Selecting Drive record by Name");
    SQL_CHECKREAD_M( sqlErrDesc );

}// rm_Drive::SelectByName

Here is the call graph for this function:

Here is the caller graph for this function:

vector< rm_Drive > rm_Drive::SelectByStatus ( const UInt32_t a_status  )  [private]

Definition at line 1260 of file librmdb.exx.

References aveSeekTime, capabilities, cleanNr, cmn_Num2Str(), dataThroughput, dbg_DETAIL, dbg_NORM, driveIndex, driveKey, driveName, errorDesc(), firmwareRev, ie_NO_RESOURCE_FOUND, ie_RMDB_ERROR, ivd_Error, lastClean, libraryKey, loadTime, log_DBG_m, log_FUNC_m, rm_TimeStamp::m_iscTime, mediaFamily, NAME, options, productID, rewindTime, scsiID, serialNo, SQL_CHECKREAD_M, SQL_NOERROR, SQL_NOTFOUND, status, unloadTime, usageCount, and vendorID.

                                                                 {
    log_FUNC_m(SelectByStatus);
    vector<rm_Drive> selDrive;

    EXEC SQL
        SET TRANSACTION NAME readTrans
            READ ONLY
            ISOLATION LEVEL READ COMMITTED;


    EXEC SQL
        DECLARE SELECT_DRIVE_BY_STATUS CURSOR FOR
        SELECT * FROM DRIVE
            WHERE
            bin_and(DRIVE.STATUS, :a_status) = 0;

    log_DBG_m(dbg_DETAIL, "declare cursor SELECT_DRIVE_BY_STATUS returned sqlcode:" << SQLCODE);


    if ( SQLCODE != SQL_NOERROR ) {
        throw ivd_Error(ie_RMDB_ERROR," Could not declare cursor SELECT_DRIVE_BY_STATUS");
    }


    EXEC SQL
        OPEN TRANSACTION readTrans
        SELECT_DRIVE_BY_STATUS;

    if ( SQLCODE != SQL_NOERROR ) {
        throw ivd_Error(ie_RMDB_ERROR," Could not open cursor SELECT_DRIVE_BY_STATUS");
    }
    log_DBG_m(dbg_DETAIL, "open cursor SELECT_DRIVE_BY_STATUS returned sqlcode:" << SQLCODE);

    bool endOfCursor = false;

    do {
        char driveNameVal[rmdb_MAX_DRIVENAME];
        char driveIndexVal[rmdb_MAX_DRIVEIDX];
        char vendorIDVal[rmdb_MAX_VENDORID];
        char productIDVal[rmdb_MAX_PRODUCTID];
        char serialNoVal[rmdb_MAX_SERIALNO];
        char firmwareRevVal[rmdb_MAX_FIRMWAREREV];
        char scsiIDVal[rmdb_MAX_SCSIID];

        EXEC SQL
            FETCH SELECT_DRIVE_BY_STATUS
                        INTO
                            :driveKey,
                            :libraryKey,
                            :driveNameVal,
                            :status,
                            :driveIndexVal,
                            :mediaFamily,
                            :capabilities,
                            :dataThroughput,
                            :loadTime,
                            :unloadTime,
                            :aveSeekTime,
                            :rewindTime,
                            :usageCount,
                            :cleanNr,
                            :lastClean.m_iscTime,
                            :options,
                            :vendorIDVal,
                            :productIDVal,
                            :serialNoVal,
                            :firmwareRevVal,
                            :scsiIDVal;


        if (SQLCODE == SQL_NOERROR) {
            driveName   = driveNameVal;
            driveIndex  = driveIndexVal;
            lastClean   = lastClean.m_iscTime;
            vendorID    = vendorIDVal;
            productID   = productIDVal;
            serialNo    = serialNoVal;
            firmwareRev = firmwareRevVal;
            scsiID      = scsiIDVal;

            selDrive.push_back(*this);

        }
        else if (SQLCODE == SQL_NOTFOUND) {
            log_DBG_m(dbg_NORM,"reached end of cursor");
            endOfCursor = true;
        }
        else {
            log_DBG_m(dbg_NORM,"Fatal Drive Allocation error sqlcode:" << SQLCODE);
            throw ivd_Error (
                    ie_NO_RESOURCE_FOUND,
                    "Fatal DriveAllocation error sqlcode:" +
                    cmn_Num2Str((Int32_t)SQLCODE), true);
        };

    } while (endOfCursor == false);
    EXEC SQL
        CLOSE SELECT_DRIVE_BY_STATUS;
    string sqlErrDesc = errorDesc(SQLCODE,"CLOSE SELECT_DRIVE_BY_STATUS");
    SQL_CHECKREAD_M(sqlErrDesc);
    return selDrive;
} //end_of_Select_by_status

Here is the call graph for this function:

vector< rm_Drive > rm_Drive::SelectForOperation ( UInt32_t  a_libraryKey,
UInt32_t  a_mediumFamily,
UInt32_t  a_requiredCapability,
bool  a_select_in_use 
) [private]

Definition at line 1365 of file librmdb.exx.

References aveSeekTime, capabilities, cleanNr, cmn_Num2Str(), dataThroughput, dbg_DETAIL, dbg_NORM, driveIndex, driveKey, driveName, errorDesc(), firmwareRev, ie_NO_RESOURCE_FOUND, ie_RMDB_ERROR, ivd_Error, lastClean, libraryKey, loadTime, log_DBG_m, log_FUNC_A_m, rm_TimeStamp::m_iscTime, mediaFamily, NAME, options, productID, rewindTime, rmdb_DRIVE_DISABLED, rmdb_LIBRARY_DISABLED, scsiID, serialNo, SQL_CHECKREAD_M, SQL_NOERROR, SQL_NOTFOUND, status, unloadTime, usageCount, and vendorID.

Referenced by rm_Operator::AllocateAdmin(), rm_Operator::AllocateRecall(), rm_Operator::CheckForAnyResourceForMig(), and rm_Operator::SelectDriveForMig().

                                                     {

    log_FUNC_A_m(SelectForOperation, "a_libraryKey:" << a_libraryKey <<
                                     " a_mediaFamily:" << a_mediaFamily <<
                                     " a_reqCap:" << a_reqCap <<
                                     boolalpha << " a_select_in_use:" << a_select_in_use );

    vector<rm_Drive> selDrive;

    EXEC SQL
        SET TRANSACTION NAME readTrans
            READ ONLY
            ISOLATION LEVEL READ COMMITTED;

    UInt32_t opStatus = rmdb_DRIVE_DISABLED | rmdb_DRIVE_ERROR;
    if (!a_select_in_use) {
        opStatus = opStatus | rmdb_DRIVE_IN_USE;
    }
    UInt32_t opLibStatus = rmdb_LIBRARY_DISABLED | rmdb_LIBRARY_ERROR;


    EXEC SQL
        DECLARE SELECT_DRIVE_FOR_OPERATION CURSOR FOR
        SELECT DRIVE.* FROM DRIVE, LIBRARY
            WHERE
                LIBRARY.LIBRARYKEY = :a_libraryKey          AND
                DRIVE.LIBRARYKEY = LIBRARY.LIBRARYKEY       AND
                bin_and(DRIVE.STATUS, :opStatus ) = 0       AND
                bin_and(LIBRARY.STATUS, :opLibStatus ) = 0  AND
                DRIVE.MEDIAFAMILY = :a_mediaFamily
            ORDER BY USAGECOUNT ASCENDING;

    log_DBG_m(dbg_DETAIL,   "declare cursor SELECT_DRIVE_FOR_OPERATION " <<
                            "returned sqlcode:" << SQLCODE);


    if ( SQLCODE != SQL_NOERROR ) {
        throw ivd_Error(ie_RMDB_ERROR," Could not declare cursor SELECT_DRIVE_FOR_OPERATION");
    }


    EXEC SQL
        OPEN TRANSACTION readTrans
        SELECT_DRIVE_FOR_OPERATION;

    if ( SQLCODE != SQL_NOERROR ) {
        throw ivd_Error(ie_RMDB_ERROR," Could not open cursor SELECT_DRIVE_FOR_OPERATION");
    }
    log_DBG_m(dbg_DETAIL, "open cursor SELECT_DRIVE_FOR_OPERATION returned sqlcode:" << SQLCODE);

    bool endOfCursor = false;

    do {
        char driveNameVal[rmdb_MAX_DRIVENAME];
        char driveIndexVal[rmdb_MAX_DRIVEIDX];
        char vendorIDVal[rmdb_MAX_VENDORID];
        char productIDVal[rmdb_MAX_PRODUCTID];
        char serialNoVal[rmdb_MAX_SERIALNO];
        char firmwareRevVal[rmdb_MAX_FIRMWAREREV];
        char scsiIDVal[rmdb_MAX_SCSIID];

        EXEC SQL
            FETCH SELECT_DRIVE_FOR_OPERATION
                        INTO
                            :driveKey,
                            :libraryKey,
                            :driveNameVal,
                            :status,
                            :driveIndexVal,
                            :mediaFamily,
                            :capabilities,
                            :dataThroughput,
                            :loadTime,
                            :unloadTime,
                            :aveSeekTime,
                            :rewindTime,
                            :usageCount,
                            :cleanNr,
                            :lastClean.m_iscTime,
                            :options,
                            :vendorIDVal,
                            :productIDVal,
                            :serialNoVal,
                            :firmwareRevVal,
                            :scsiIDVal;

        log_DBG_m(dbg_DETAIL,"Fetch returned SQLCODE" << SQLCODE);

        if (SQLCODE == SQL_NOERROR) {
            driveName   = driveNameVal;
            driveIndex  = driveIndexVal;
            lastClean   = lastClean.m_iscTime;
            vendorID    = vendorIDVal;
            productID   = productIDVal;
            serialNo    = serialNoVal;
            firmwareRev = firmwareRevVal;
            scsiID      = scsiIDVal;
            if ( (a_reqCap & this->capabilities) == a_reqCap) {
                log_DBG_m(dbg_DETAIL,"Selected drive: " << this->driveKey << " for operation");
                selDrive.push_back(*this);
            }
            else {
                log_DBG_m(dbg_DETAIL,"Drive " << this->driveKey <<
                                     " does not match capabilities ");
            }


        }
        else if (SQLCODE == SQL_NOTFOUND) {
            log_DBG_m(dbg_NORM,"reached end of cursor");
            endOfCursor = true;
        }
        else {
            log_DBG_m(dbg_NORM,"Fatal Drive Allocation error sqlcode:" << SQLCODE);
            throw ivd_Error (
                        ie_NO_RESOURCE_FOUND,
                        "Fatal DriveAllocation error sqlcode:" +
                        cmn_Num2Str((Int32_t)SQLCODE),
                        true);
        };

    } while (endOfCursor == false);

    EXEC SQL
        CLOSE SELECT_DRIVE_FOR_OPERATION;
    string sqlErrDesc = errorDesc(SQLCODE,"CLOSE SELECT_DRIVE_FOR_OPERATION");
    SQL_CHECKREAD_M(sqlErrDesc);

    return selDrive;
} //end_of_Select_by_status

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_Drive::StartSelectAll (  )  [private]

Definition at line 1167 of file librmdb.exx.

References errorDesc(), cmn_Mutex::Lock(), log_ERR_m, log_FUNC_m, NAME, and cmn_Mutex::Unlock().

                             {

    log_FUNC_m(StartSelectAll);

    g_driveCursor_x.Lock();

    EXEC SQL
        SET TRANSACTION NAME readTrans
            READ ONLY
            ISOLATION LEVEL READ COMMITTED;

    EXEC SQL
        OPEN TRANSACTION readTrans SELECT_ALL_DRIVE;

    if ( SQLCODE != 0 ) {
        string sqlErrDesc = errorDesc(SQLCODE, "Opening SELECT_ALL_DRIVE Cursor failed");
        log_ERR_m(sqlErrDesc);
        g_driveCursor_x.Unlock();
        throw ivd_DBException( SQLCODE ,sqlErrDesc, true);
    }
}// rm_Drive:: StartSelectAll

Here is the call graph for this function:

void rm_Drive::Update (  )  [private]

Definition at line 937 of file librmdb.exx.

References aveSeekTime, capabilities, cleanNr, rm_String::cvalue_p, dataThroughput, driveIndex, driveKey, driveName, errorDesc(), firmwareRev, lastClean, libraryKey, loadTime, log_FUNC_m, rm_TimeStamp::m_iscTime, mediaFamily, NAME, options, productID, rewindTime, scsiID, serialNo, SQL_CHECK_M, status, unloadTime, usageCount, and vendorID.

Referenced by rm_Operator::AllocateAdmin(), rm_Operator::AllocateRecall(), rm_Operator::InventoryUpdate(), rm_Operator::ReleaseResources(), and rm_Operator::Update().

                      {
    log_FUNC_m(Update);


    if (libraryKey < 1) {
        bi1 = -1;
    }
    else {
        bi1 = 0;
    }

    EXEC SQL
        SET TRANSACTION NAME readWriteTrans;

    EXEC SQL
        UPDATE TRANSACTION readWriteTrans
        DRIVE SET
                    LIBRARYKEY =    :libraryKey INDICATOR :bi1,
                    DRIVENAME =     :driveName.cvalue_p,
                    STATUS =        :status,
                    DRIVEINDEX =    :driveIndex.cvalue_p,
                    MEDIAFAMILY =   :mediaFamily,
                    CAPABILITIES =  :capabilities,
                    DATATHROUGHPUT = :dataThroughput,
                    LOADTIME =      :loadTime,
                    UNLOADTIME =    :unloadTime,
                    AVESEEKTIME =   :aveSeekTime,
                    REWINDTIME =    :rewindTime,
                    USAGECOUNT =     :usageCount,
                    CLEANNR =       :cleanNr,
                    LASTCLEAN =     :lastClean.m_iscTime,
                    OPTIONS =       :options,
                    VENDORID =      :vendorID.cvalue_p,
                    PRODUCTID =     :productID.cvalue_p,
                    SERIALNO =      :serialNo.cvalue_p,
                    FIRMWAREREV =   :firmwareRev.cvalue_p,
                    SCSIID =        :scsiID.cvalue_p
                WHERE DRIVEKEY = :driveKey;
    string sqlErrDesc = errorDesc(SQLCODE,"Update Drive record", driveKey);
    SQL_CHECK_M( sqlErrDesc );

}// rm_update_Drive

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class rm_Medium [friend]

Definition at line 209 of file rmdb.h.

friend class rm_Operator [friend]

Definition at line 208 of file rmdb.h.


Member Data Documentation

Definition at line 298 of file rmdb.h.


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