Public Member Functions | Public Attributes | Private Attributes

hsm_FHpVecMgr Class Reference
[Classes for managing object list]

File header pointer vector manager. More...

#include <hsm_FHcache.h>

Collaboration diagram for hsm_FHpVecMgr:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~hsm_FHpVecMgr ()
void Insert (hsm_FileHeader *a_FileHObj)
 Insert must be used ONLY if GetFH return NULL Doesn't check if FH olready exist and put &FH at the end of the vector Insert method increase reference by 2.
void InsertDirWithTest (hsm_FileHeader **a_FileHObj)
void Remove (register hsm_FileHeader *a_FileHObj)
 Find proper FH by serching its addres in container if FH has only one reference then is removed from cache othervice not iterator possition is replaced with last FH in vector or just remove Fh if it's last.
bool RemoveLastButOne (register hsm_FileHeader *a_FileHObj)
hsm_FileHeaderGetFH (ivd_GenInode_t a_generalInode)
 search for file header NOTE if fount then referece will be increased to prevent from delete

Public Attributes

 log_CLASSID_m

Private Attributes

cmn_Mutex m_FHpVec_x

Detailed Description

File header pointer vector manager.

Definition at line 49 of file hsm_FHcache.h.


Constructor & Destructor Documentation

hsm_FHpVecMgr::~hsm_FHpVecMgr (  ) 

Definition at line 58 of file hsm_FHcache.cpp.

References NULL.

                              {
//    log_FUNC_m(hsm_FHcache);
    hsm_FileHeader* *ip = &(*begin());
    hsm_FileHeader* *ep = &(*end()); // addres of past the end
    for (; ip < ep; ip++) {
        if (*ip != NULL) {
            (*ip)->DecrRef();
        }
    }
    //for (hsm_FH_p_vi iter = begin(); iter != end(); iter++) {
    //     if (*iter != NULL) {
    //         (*iter)->DecrRef();
    //     }
    //}
}


Member Function Documentation

hsm_FileHeader * hsm_FHpVecMgr::GetFH ( ivd_GenInode_t  a_generalInode  ) 

search for file header NOTE if fount then referece will be increased to prevent from delete

Definition at line 169 of file hsm_FHcache.cpp.

References dbg_DETAIL, IVD_PRINT_ID_FS, log_DBG_m, log_FUNC_m, and m_FHpVec_x.

                                                                   {
    log_FUNC_m(GetFH(ivd_GenInode_t));
    cmn_MutexLock l(m_FHpVec_x);
//    register hsm_FH_p_vi endel = end();
    log_DBG_m(dbg_DETAIL, " Search FH. inode " << IVD_PRINT_ID_FS(a_generalInode));
    for (hsm_FH_p_vi iter = begin(); iter != end(); iter++) {
        if ((*iter)->GetInode() == a_generalInode) {  
            // when found inc ref to prevent removal from memory specialy for owners
//BUG269            (*iter)->IncMemberRef(); 
            (*iter)->IncrRef(); 
            return *iter;
         }
    }    
    return NULL;
}

void hsm_FHpVecMgr::Insert ( hsm_FileHeader a_FileHObj  ) 

Insert must be used ONLY if GetFH return NULL Doesn't check if FH olready exist and put &FH at the end of the vector Insert method increase reference by 2.

Definition at line 76 of file hsm_FHcache.cpp.

References hsm_FileHeader::IncrRef(), log_FUNC_m, and m_FHpVec_x.

                                                     {
    log_FUNC_m(Insert);
    cmn_MutexLock l(m_FHpVec_x);
    insert(end(), a_FileHObj); // here is oposite    
    a_FileHObj->IncrRef();
}

Here is the call graph for this function:

void hsm_FHpVecMgr::InsertDirWithTest ( hsm_FileHeader **  a_FileHObj  ) 
See also:
hsm_FHcache

Definition at line 85 of file hsm_FHcache.cpp.

References dbg_NORM, IVD_PRINT_ID_FS, log_DBG_m, log_FUNC_m, and m_FHpVec_x.

                                                                 {
    log_FUNC_m(InsertDirWithTest);
    cmn_MutexLock l(m_FHpVec_x);

    ivd_GenInode_t inode = (*a_FileHObj)->GetInode();
    for (hsm_FH_p_vi iter = begin(); iter != end(); iter++) {
        if ((*iter)->GetInode() == inode) {  // already inserted 
            // delete 
            log_DBG_m(dbg_NORM, " Dir. " << (*iter)->MakePath() 
                             << " inode " << IVD_PRINT_ID_FS(inode)
                             << " already exist in cache. It's going to delete and replace with FH from cache.");
//          (*a_FileHObj)->DecrRef();   not need. It is going to delete anyhow 
            delete *a_FileHObj;   // forget constructed FH 
            *a_FileHObj = (*iter); // use it that from cache
            // when found inc ref to prevent removal from memory specialy for owners
//BUG269            (*iter)->IncMemberRef(); 
//             (*iter)->IncrRef();  not need inserted FH already has increased reference
            return;
         }
    }    
    // not in cache yet
    insert(end(), *a_FileHObj);
    (*a_FileHObj)->IncrRef();
}

void hsm_FHpVecMgr::Remove ( register hsm_FileHeader a_FileHObj  ) 

Find proper FH by serching its addres in container if FH has only one reference then is removed from cache othervice not iterator possition is replaced with last FH in vector or just remove Fh if it's last.

if element is directory then has one

Definition at line 115 of file hsm_FHcache.cpp.

References dbg_NORM, hsm_FileHeader::GetInode(), ie_INVALID_ARG, IVD_PRINT_ID_FS, log_DBG_m, log_FUNC_m, and m_FHpVec_x.

                                                              {
    log_FUNC_m(Remove);
    cmn_MutexLock l(m_FHpVec_x);

    hsm_FH_p_vi endel = end();
    for (hsm_FH_p_vi iter = begin(); iter != end(); iter++) {
        if (*iter == a_FileHObj) {  // find iter that point to FH
            log_DBG_m(dbg_NORM, "Removed from cache. INO " << IVD_PRINT_ID_FS(a_FileHObj->GetInode()));
            (*iter)->DecrRef();
            if (iter != --endel) { // endel become last
                *iter = *endel;  // if iter is not last move last to current
            }
            erase(endel);        // othervice remove last
            return; // DONE
        }
    }
    throw ivd_InternalError(ie_INVALID_ARG, 
            "File Header is not found in FHcache by its pointer.", true);
}

Here is the call graph for this function:

bool hsm_FHpVecMgr::RemoveLastButOne ( register hsm_FileHeader a_FileHObj  ) 

Definition at line 137 of file hsm_FHcache.cpp.

References dbg_DETAIL, dbg_NORM, hsm_FileHeader::GetInode(), hsm_FileHeader::GetRef(), ie_INVALID_ARG, IVD_PRINT_ID_FS, log_DBG_m, log_FUNC_m, and m_FHpVec_x.

                                                                        {
    log_FUNC_m(RemoveLastButOne);
    cmn_MutexLock l(m_FHpVec_x);

    hsm_FH_p_vi endel = end();
    for (hsm_FH_p_vi iter = begin(); iter != end(); iter++) {
        if (*iter == a_FileHObj) {  // find iter that point to FH
            UInt32_t ref = a_FileHObj->GetRef();
            if (ref == 2) { // cache and caller referencies
                log_DBG_m(dbg_NORM, "Removed from cache. INO " << IVD_PRINT_ID_FS(a_FileHObj->GetInode()));
                (*iter)->DecrRef();
                if (iter != --endel) { // endel become last
                    *iter = *endel;  // if iter is not last move last to current
                }
                erase(endel);        // othervice remove last
                return true;
            }
            else {
                log_DBG_m(dbg_DETAIL, "Don't remove from cache. Ref=" << ref
                        << ". INO " << IVD_PRINT_ID_FS(a_FileHObj->GetInode()));
                return false;
            }
         }
    }
    // 
    ostringstream sstr;
    sstr << "File Header is not found in FHcache by its pointer." << endl
         << *a_FileHObj;
    throw ivd_InternalError(ie_INVALID_ARG, sstr.str(), true);
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 57 of file hsm_FHcache.h.

Definition at line 54 of file hsm_FHcache.h.

Referenced by GetFH(), Insert(), InsertDirWithTest(), Remove(), and RemoveLastButOne().


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