Public Member Functions | Public Attributes | Friends

hdb_Tables Class Reference
[HSM Database]

#include <hdb_Tables.h>

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

List of all members.

Public Member Functions

 hdb_Tables (cmn_Path a_path, bool a_readOnly, bool a_winStructFiles=false)
virtual ~hdb_Tables ()
void DumpActiveEntries (ostream &a_os)
void DumpReleaseCand (ostream &a_os, fio_CirFileTrans *a_cf_p)
void DumpMigratedFiles (ostream &a_os)

Public Attributes

 log_CLASSID_m

Friends

class ut_hdb_Tables

Detailed Description

Definition at line 47 of file hdb_Tables.h.


Constructor & Destructor Documentation

hdb_Tables::hdb_Tables ( cmn_Path  a_path,
bool  a_readOnly,
bool  a_winStructFiles = false 
)

Definition at line 79 of file hdb_Tables.cpp.

References c_hsm_ActiveVer, c_hsm_DirTreeVer, c_hsm_File2hdbIDVer, c_hsm_NameOwnerVer, c_hsm_RelCandVer, cmn_CreatePath(), dbg_DETAIL, g_winStructures, fio_RelFileTransLstMgr::Insert(), ivd_NULLCHK_m, log_DBG_m, log_FUNC_m, and s_className.

    :
    fio_RelFileTransLstMgr()
{
    log_FUNC_m(hdb_Tables);

    g_winStructures = a_winStructFiles;

    UInt32_t sizeOfActive = sizeof(hdb_Active_t);
    UInt32_t sizeOfRelCand = sizeof(hdb_ReleaseCand_t);

    #if   TGT_OS_linux
        if (a_winStructFiles) {
            sizeOfActive  += 4;
            sizeOfRelCand += 8;
        }        
    //#elif TGT_OS_windows
    //#else
    //#   error "Unsupported platform!"
    #endif

    cmn_CreatePath(a_path);
    // Be careful of relative file          |    sequence number.
    // Do not change the seq num            v      after release.
    log_DBG_m(dbg_DETAIL, "Instantiate hsmDirEntName.lrf  record size=8");
    g_DirEntName_p   = new fio_VarLenRFT   (a_readOnly, 1, a_path, "hsmDirEntName.lrf");
    ivd_NULLCHK_m(g_DirEntName_p, fio_VarLenRFT::s_className);

    log_DBG_m(dbg_DETAIL, "Instantiate hsmDirTree.lrf  record size=" << sizeof(hdb_DirNode_t));
    g_DirTree_p      = new fio_RelFileTrans(a_readOnly, 2, a_path, "hsmDirTree.lrf",      
                                               sizeof(hdb_DirNode_t),       
                                               c_hsm_DirTreeVer,
                                               1); // number of different vectors
    ivd_NULLCHK_m(g_DirTree_p, fio_RelFileTrans::s_className);

    log_DBG_m(dbg_DETAIL, "Instantiate hsmNameOwner.lrf  record size=" << sizeof(hdb_NameOwner_t));
    g_NameOwner_p    = new fio_RelFileTrans(a_readOnly, 3, a_path, "hsmNameOwner.lrf", 
                                               sizeof(hdb_NameOwner_t),   
                                               c_hsm_NameOwnerVer,
                                               1); // number of different vectors
    ivd_NULLCHK_m(g_NameOwner_p, fio_RelFileTrans::s_className);

    log_DBG_m(dbg_DETAIL, "Instantiate hsmFile2hdbID.lrf  record size=" << sizeof(hdb_file2hdbID_t));
    g_File2hdbID_p   = new fio_RelFileTrans(a_readOnly, 4, a_path, "hsmFile2hdbID.lrf", 
                                               sizeof(hdb_file2hdbID_t),   
                                               c_hsm_File2hdbIDVer,
                                               1); // number of different vectors
    ivd_NULLCHK_m(g_File2hdbID_p, fio_RelFileTrans::s_className);

    g_Active_p       = new fio_CirFileTrans(a_readOnly, 5, a_path, "hsmActive.lrf", 
                                               sizeOfActive,   
                                               c_hsm_ActiveVer);
    ivd_NULLCHK_m(g_Active_p, fio_CirFileTrans::s_className);

    g_RelCandMigrt_p = new fio_CirFileTrans(a_readOnly, 6, a_path, "hsmRelCndMigrt.lrf",  
                                              sizeOfRelCand,
                                              c_hsm_RelCandVer);
    ivd_NULLCHK_m(g_RelCandMigrt_p, fio_CirFileTrans::s_className);

    g_RelCandRecal_p = new fio_CirFileTrans(a_readOnly, 7, a_path, "hsmRelCndRecal.lrf",  
                                              sizeOfRelCand,   
                                              c_hsm_RelCandVer);
    ivd_NULLCHK_m(g_RelCandRecal_p, fio_CirFileTrans::s_className);

    g_RelCandSmall_p = new fio_CirFileTrans(a_readOnly, 8, a_path, "hsmRelCndSmall.lrf",  
                                              sizeOfRelCand,
                                              c_hsm_RelCandVer);
    ivd_NULLCHK_m(g_RelCandSmall_p, fio_CirFileTrans::s_className);


    Insert(g_DirEntName_p);     // 1
    Insert(g_DirTree_p);        // 2
    Insert(g_NameOwner_p);      // 3
    Insert(g_File2hdbID_p);     // 4
    Insert(g_Active_p);         // 5
    Insert(g_RelCandMigrt_p);   // 6
    Insert(g_RelCandRecal_p);   // 7
    Insert(g_RelCandSmall_p);   // 8
}

Here is the call graph for this function:

virtual hdb_Tables::~hdb_Tables (  )  [inline, virtual]

Definition at line 52 of file hdb_Tables.h.

{};


Member Function Documentation

void hdb_Tables::DumpActiveEntries ( ostream &  a_os  ) 

Definition at line 161 of file hdb_Tables.cpp.

References hdb_Active_t::chgFlags, fio_CirFileTrans::DumpHdr(), hdb_Active_t::fileID, hdb_Active_t::generalInode, hdbReadNameOwnRec(), hsmdbGetPath(), IVD_PRINT_ID_FS, log_FUNC_m, hdb_Active_t::nameOwnIdx, hdb_Active_t::oldNameOwnIdx, path, fio_CirFileTrans::ReadNext(), and fio_CirFileTrans::ReadNextReset().

Referenced by main().

                                                {
    log_FUNC_m(DumpActiveEntries);

    hdb_Active_t  actRec;
    ivd_RecordIDX_t idx;
    
    g_Active_p->DumpHdr(a_os);
    
    a_os << " Counter  DB Idx   Flags  FileID Inode              Path/oldPath\n"
         << "==================================================================\n";
    
    int counter = 0;
    // reset circular list for read
    g_Active_p->ReadNextReset();
    while ((idx = g_Active_p->ReadNext(&actRec)) > 0) {
        if (actRec.generalInode > 0) {
            counter++;
            // directory can be already in cache
//            a_os << "Find active FH rec in HSMDB Idx = " << idx << '\n' << actRec;

            hdb_DirNode_t dir; // default const. it filled with zeroes
            ivd_RecordIDX_t dirTreeIdx = 0;
            hdb_String name;
            hdbReadNameOwnRec(actRec.nameOwnIdx, dirTreeIdx, name, dir);
            cmn_Path path = hsmdbGetPath(dir);

            a_os << setw(8)  << counter 
                 << setw(8)  << idx 
                 << hex << setw(8) << actRec.chgFlags << dec
                 << setw(8) << actRec.fileID
                 << " " << IVD_PRINT_ID_FS(actRec.generalInode) << " " << path + name;
            
            hdb_DirNode_t oldDir;
            ivd_RecordIDX_t oldDirTreeIdx = 0;
            hdb_String oldName;

            if (actRec.oldNameOwnIdx > 0) {
                hdbReadNameOwnRec(actRec.oldNameOwnIdx, oldDirTreeIdx, oldName, oldDir);
                cmn_Path oldPath = hsmdbGetPath(oldDir);
                a_os << "  old: " << oldPath + oldName << '\n';
            }
            else {
                a_os << '\n';
            }
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hdb_Tables::DumpMigratedFiles ( ostream &  a_os  ) 

Definition at line 259 of file hdb_Tables.cpp.

References hdb_file2hdbID_t::circList, fio_RelFile::FirstNewIDX(), hdbReadNameOwnRec(), hsmdbGetPath(), hdb_file2hdbID_t::nameOwnIdx, path, and fio_RelFile::ReadRec().

Referenced by main().

                                                {
    a_os << "Dump migrated files. \n";
    a_os << "legend:  M- migrate, R- recall, S-small release candidate list";
    a_os << "\n    FileID NameOwnIdx List Path         (NameOwnIdx DirTreeIdx)/... of parrent directory\n"
         << "=================================================================\n";
    char list[5] = " MRS";
    ivd_RecordIDX_t fileID = 1;
    UInt32_t fileIDs = g_File2hdbID_p->FirstNewIDX();
    int showProgEvery = 1000;
    int count = showProgEvery;
    cerr << (fileIDs - 1) << " has to be scanned. Progres every " << showProgEvery << endl;
    while (fileID < g_File2hdbID_p->FirstNewIDX()) {
        hdb_file2hdbID_t file2hdbID;
        g_File2hdbID_p->ReadRec(fileID, &file2hdbID);
        if (file2hdbID.nameOwnIdx > 0) {
            hdb_DirNode_t dir; // default const. it filled with zeroes
            ivd_RecordIDX_t dirTreeIdx = 0;
            hdb_String name;
            hdbReadNameOwnRec(file2hdbID.nameOwnIdx, dirTreeIdx, name, dir);
            hdb_DirTreeVec_t dirNode_v;
            dirNode_v.push_back(hdb_DirTree_t(dirTreeIdx, dir));
            cmn_Path path = hsmdbGetPath(dir, dirNode_v) + name;

            a_os << setw(10) << fileID 
                 << setw(11) << file2hdbID.nameOwnIdx 
//                 << setw(11) << dirTreeIdx 
                 << " " << list[file2hdbID.circList] 
                            << "    " << path << " ";
            if (path.size() < 40) {
                a_os << string(40 - path.size(), ' ');
            }
            for (int i = dirNode_v.size() - 1; i >= 0; --i) {
                a_os << "(" << setw(7) << dirNode_v[i].dirNode.nameOwnIdx
                     << " " << setw(7) << dirNode_v[i].dirTreeIdx << ")/";
            }
            a_os << endl;
        }
        if (--count == 0) {
            cerr << fileID << "\015";
            cerr.flush();
            count = showProgEvery;
        }
        fileID++;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hdb_Tables::DumpReleaseCand ( ostream &  a_os,
fio_CirFileTrans a_cf_p 
)

Definition at line 211 of file hdb_Tables.cpp.

References hdb_ReleaseCand_t::appendTime, hdb_ReleaseCand_t::fileID, g_winStructures, hdb_ReleaseCand_t::generalInode, cmn_File::GetFullPathRef(), hdbReadNameOwnRec(), hsmdbGetPath(), log_FUNC_m, hdb_ReleaseCand_t::nameOwnIdx, path, fio_CirFileTrans::ReadNext(), fio_CirFileTrans::ReadNextReset(), cmn_Time::Time2YMDhms(), and hdb_ReleaseCand_t::ToHostStructure().

Referenced by main().

                                                                        {
    log_FUNC_m(DumpMigReleaseCand);


    hdbWIN_ReleaseCand_t relCandRecWinStr;
    hdb_ReleaseCand_t   &relCandRec = *reinterpret_cast<hdb_ReleaseCand_t*>(&relCandRecWinStr);
    ivd_RecordIDX_t idx;

    a_os << "Dump release candidate from file " << a_cf_p->GetFullPathRef();
    a_os << "\n Counter    FileID  DB Idx Append time         Path\n"
         << "======================================================\n";
    
//    int recSize = g_RelCandMigrt_p->GetRecordSize();
    
    int counter = 0;
    // reset circular list for read
    a_cf_p->ReadNextReset();
    while ((idx = a_cf_p->ReadNext(&relCandRecWinStr)) > 0) {
#if TGT_OS_hpux
#pragma warning "Cross platform DatabBase dump not implemented."
#else
        relCandRec.ToHostStructure(g_winStructures);
#endif
        if (relCandRec.generalInode > 0) {
            counter++;
            // directory can be already in cache
//            a_os << "Find active FH rec in HSMDB Idx = " << idx << '\n' << actRec;

            hdb_DirNode_t dir; // default const. it filled with zeroes
            ivd_RecordIDX_t dirTreeIdx = 0;
            hdb_String name;
            hdbReadNameOwnRec(relCandRec.nameOwnIdx, dirTreeIdx, name, dir);
            cmn_Path path = hsmdbGetPath(dir);

            cmn_Time appendTime(relCandRec.appendTime);
            
            a_os << setw( 8) << counter 
                 << setw(10) << relCandRec.fileID 
                 << setw( 8) << idx 
                 << " " << appendTime.Time2YMDhms() << " " << path + name << '\n';
//                 << relCandRec << endl
//                 << cmn_HexDump(&relCandRec, recSize, recSize, false);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class ut_hdb_Tables [friend]

Definition at line 48 of file hdb_Tables.h.


Member Data Documentation

Reimplemented from fio_RelFileTransLstMgr.

Definition at line 60 of file hdb_Tables.h.


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