Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes

MigrateTreewalk Class Reference
[Classes for managing events]

#include <hsm_MigrateTreewalk.h>

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

List of all members.

Public Types

enum  hsm_Action_e { action_TrigMigration, action_CheckPreconditions }

Public Member Functions

 MigrateTreewalk (const string &a_pattern, UInt64_t a_majorCollocationId, UInt64_t a_minorCollocationId, bool &a_recursive, bool &a_abort, hsm_Action_e a_action, bool &a_doReplication)
virtual ~MigrateTreewalk ()
UInt64_t GetProcessedFilesCount ()

Public Attributes

 log_CLASSID_m

Private Member Functions

void CheckDir (bool a_mountpoint, const cmn_Path &a_dirPath, ivd_GenInode_t a_fileInode)
 When check dir is called then process current dir is checked directory.

Private Attributes

const string m_pattern
bool m_recursive
UInt64_t m_majorCollocationId
UInt64_t m_minorCollocationId
hsm_Action_e m_action
bool m_doReplication
UInt64_t m_processedFilesCounter
UInt64_t m_skippedFilesCounter

Detailed Description

Definition at line 26 of file hsm_MigrateTreewalk.h.


Member Enumeration Documentation

Enumerator:
action_TrigMigration 
action_CheckPreconditions 

Definition at line 29 of file hsm_MigrateTreewalk.h.

                 {
        action_TrigMigration,
        action_CheckPreconditions
    } hsm_Action_e;


Constructor & Destructor Documentation

MigrateTreewalk::MigrateTreewalk ( const string &  a_pattern,
UInt64_t  a_majorCollocationId,
UInt64_t  a_minorCollocationId,
bool &  a_recursive,
bool &  a_abort,
hsm_Action_e  a_action,
bool &  a_doReplication 
)

Definition at line 39 of file hsm_MigrateTreewalk.cpp.

References log_FUNC_A_m, m_pattern, and m_recursive.

    :
    // TODO: Change abotring in common class
    cmn_TreeWalk(g_cmn.dirs.tmp + "MigrateByAPI_stack", a_abort),
    m_pattern(a_pattern),
    m_recursive(a_recursive),
    m_majorCollocationId(a_majorCollocationId),
    m_minorCollocationId(a_minorCollocationId),
    m_action(a_action),
    m_doReplication(a_doReplication),
    m_processedFilesCounter(0),
    m_skippedFilesCounter(0) {

    log_FUNC_A_m(MigrateTreewalk, "Pattern: " << m_pattern << ", recursive: " << boolalpha << m_recursive);
}

MigrateTreewalk::~MigrateTreewalk (  )  [virtual]

Member Function Documentation

void MigrateTreewalk::CheckDir ( bool  a_mountpoint,
const cmn_Path a_dirPath,
ivd_GenInode_t  a_fileInode 
) [private, virtual]

When check dir is called then process current dir is checked directory.

Implements cmn_TreeWalk.

Definition at line 68 of file hsm_MigrateTreewalk.cpp.

References action_CheckPreconditions, action_TrigMigration, Collocation::CheckPreconditions(), cmn_IsPatternMatch(), dbg_DETAIL, dbg_NORM, cmn_TreeWalk::DoWalk(), ivd_FS_File::e_Cache, g_fs_api_p, cmn_TreeWalk::GetLastVector(), ift_DIR, ift_FILE, ift_SYMLINK, IVD_PRINT_ID_FS, log_DBG_m, log_FUNC_m, log_NOTE_m, m_action, ivd_FS_FileProperty_t::m_dirtyFlag, m_doReplication, ivd_FS_FileProperty_t::m_fileID, fname_inode_t::m_fileType, ivd_FS_FileProperty_t::m_Inode, fname_inode_t::m_iNode, m_majorCollocationId, m_minorCollocationId, fname_inode_t::m_name, m_pattern, m_processedFilesCounter, m_recursive, m_skippedFilesCounter, ivd_FS_FileProperty_t::m_type, and Collocation::TrigMigration().

                                                           {
    log_FUNC_m(CheckDir);

    log_DBG_m(dbg_DETAIL, "Check in directory " << a_dirPath << " a_fileInode " << a_fileInode);

    while (!GetLastVector().empty()) {

        fname_inode_t &f = GetLastVector().back();
        log_DBG_m(dbg_NORM, "File to check: " << f.m_name
                            << ", m_iNode: " << IVD_PRINT_ID_FS(f.m_iNode) 
                            << ", m_fileType: "<< f.m_fileType);
        
        if (f.m_fileType == ift_SYMLINK) { // sym link are not migratted so skip it.
            log_DBG_m(dbg_DETAIL,  "SymLink -> skipping filename: " << f.m_name);
            m_skippedFilesCounter++;
            GetLastVector().pop_back();
            continue;
        }

        ivd_FS_FileProperty_t fileProp;
        auto_ptr<ivd_FS_File> file_ap;
        file_ap.reset(new ivd_FS_File(*g_fs_api_p, f.m_iNode));

        try {
            //The file needs to be opened ( to be in the kernel cache )
            file_ap->Open(ivd_FS_File::e_Cache, (a_dirPath + f.m_name));
            file_ap->GetProperties(fileProp);
            file_ap->Close();
        }
        catch (ivd_SysError &ise) { // can't get fileInfo, skip it
            log_DBG_m(dbg_NORM, "Can't get fileInfo for inode: " << IVD_PRINT_ID_FS(f.m_iNode) << " " << ise);
            ostringstream sstr;
            sstr << "The file '" << (a_dirPath + f.m_name) << "' does not exist any more.";
            log_NOTE_m(sstr.str());
            m_skippedFilesCounter++;
            GetLastVector().pop_back();
            continue;
        }

        log_DBG_m(dbg_DETAIL, "Processing file: inode "
            << IVD_PRINT_ID_FS(fileProp.m_Inode)
            << " fileId "   << fileProp.m_fileID
            << " fileProp.m_type: " << fileProp.m_type
            << " fileType from dirlist " << f.m_fileType);

        if (f.m_fileType == ift_DIR) {
            if (m_recursive) {
                log_DBG_m(dbg_DETAIL, "It is a directory. Call DoWalk():" <<
                    a_dirPath + f.m_name << ", inode: " << IVD_PRINT_ID_FS(fileProp.m_Inode));
                if (!DoWalk(a_dirPath + f.m_name, fileProp.m_Inode, false)) {
                    ostringstream sstr;
                    sstr << "Unable to get directory '" << (a_dirPath + f.m_name) << "' contents.";
                    log_NOTE_m(sstr.str());
                    m_skippedFilesCounter++;
                }
            }
            else {
                log_DBG_m(dbg_NORM, "Skiping directory: " << a_dirPath + f.m_name);
            }

        }
        else if (f.m_fileType == ift_FILE) {

            bool nameMatchesPattern = cmn_IsPatternMatch(m_pattern, f.m_name);

            if (!nameMatchesPattern) {
                log_DBG_m(dbg_DETAIL,  "The filename: '" << f.m_name << "' does not match the pattern '" << m_pattern << "'. Skipping...");
                m_skippedFilesCounter++;
                GetLastVector().pop_back();
                continue;
            }

            if (!fileProp.m_dirtyFlag) {
                log_DBG_m(dbg_DETAIL, "The file not dirty. Skipping. Name: " <<
                    a_dirPath + f.m_name << ", inode: " << IVD_PRINT_ID_FS(fileProp.m_Inode));
                m_skippedFilesCounter++;
            }
            else {
                if (m_action == action_TrigMigration) {
                    Collocation::TrigMigration(*file_ap, fileProp.m_Inode,
                        m_majorCollocationId, m_minorCollocationId);
                }
                else if (m_action == action_CheckPreconditions) {
                    string fileName(a_dirPath + f.m_name);
                    Collocation::CheckPreconditions(fileName, fileProp,
                        m_majorCollocationId, m_minorCollocationId, m_doReplication);
                }
                m_processedFilesCounter++;
            }
        }
        else {
            log_DBG_m(dbg_DETAIL, "Unexpected file type (" << f.m_fileType << "). Skipping. Name: " <<
                a_dirPath + f.m_name << ", inode: " << IVD_PRINT_ID_FS(fileProp.m_Inode));
                ostringstream sstr;
                sstr << "Unexpected file type '" << f.m_fileType << "' File: " << (a_dirPath + f.m_name) << "Skiped!";
                log_NOTE_m(sstr.str());
                m_skippedFilesCounter++;
        }
        GetLastVector().pop_back();
    } //while (!GetLastVector().empty())
}

Here is the call graph for this function:

UInt64_t MigrateTreewalk::GetProcessedFilesCount (  ) 

Definition at line 172 of file hsm_MigrateTreewalk.cpp.

References m_processedFilesCounter.

Referenced by i_HSM_i::MigrateByAPI().

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from cmn_TreeWalk.

Definition at line 44 of file hsm_MigrateTreewalk.h.

Definition at line 50 of file hsm_MigrateTreewalk.h.

Referenced by CheckDir().

Definition at line 51 of file hsm_MigrateTreewalk.h.

Referenced by CheckDir().

Definition at line 48 of file hsm_MigrateTreewalk.h.

Referenced by CheckDir().

Definition at line 49 of file hsm_MigrateTreewalk.h.

Referenced by CheckDir().

const string MigrateTreewalk::m_pattern [private]

Definition at line 46 of file hsm_MigrateTreewalk.h.

Referenced by CheckDir(), and MigrateTreewalk().

Definition at line 53 of file hsm_MigrateTreewalk.h.

Referenced by CheckDir(), GetProcessedFilesCount(), and ~MigrateTreewalk().

Definition at line 47 of file hsm_MigrateTreewalk.h.

Referenced by CheckDir(), and MigrateTreewalk().

Definition at line 54 of file hsm_MigrateTreewalk.h.

Referenced by CheckDir(), and ~MigrateTreewalk().


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