Public Member Functions | Private Member Functions | Private Attributes

mif_PartMgr Class Reference
[G_new_group]

#include <mif_partmgr.h>

Collaboration diagram for mif_PartMgr:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 mif_PartMgr ()
virtual ~mif_PartMgr ()
void SetMif (i_ManagementInterface_i *a_iMIF)
void AddPart (const string &a_partName, const string &a_partUUID, const string &a_host, const string &a_fsID)
void UpdatePart (const string &a_partName, const string &a_host, const string &a_fsID)
void RemovePart (const string &a_partName)
void EnablePart (const string &a_partName)
void DisablePart (const string &a_partName)
mif_PartEntry GetPart (const string &a_partName)
vector< mif_PartEntryGetAllPart ()
void GetAllPartFromRM ()
void StartAllPart ()
void StopAllPart ()
void GetClientFSIDs (const string &a_clientHost, i_StringList_t &a_list)
bool IsInRecallOnlyMode (const string &a_partName)
bool IsMigrateWithCollocationSet (const string &a_partName)

Private Member Functions

vector< mif_PartEntry >::iterator Find (const string &a_partName)
void StartPM (vector< mif_PartEntry >::iterator a_iter)
void StopPM (vector< mif_PartEntry >::iterator a_iter)
void GetFSIDs (const string &a_clientHost, i_StringList_t &a_list)
void SendClientFSIDs (const string &a_clientHost)

Private Attributes

vector< mif_PartEntrym_partList
cmn_Mutex m_partList_x
i_ManagementInterface_im_iMIF
 log_CLASSID_m

Detailed Description

Definition at line 64 of file mif_partmgr.h.


Constructor & Destructor Documentation

mif_PartMgr::mif_PartMgr (  ) 

Definition at line 51 of file mif_partmgr.cpp.

                        :
    m_iMIF(NULL) {
    // empty    
}

mif_PartMgr::~mif_PartMgr (  )  [virtual]

Definition at line 56 of file mif_partmgr.cpp.

                          {
}


Member Function Documentation

void mif_PartMgr::AddPart ( const string &  a_partName,
const string &  a_partUUID,
const string &  a_host,
const string &  a_fsID 
)

Definition at line 149 of file mif_partmgr.cpp.

References dbg_NORM, Find(), ie_MIF_PARTITION_MGR, ivd_Error, log_DBG_m, log_FUNC_m, mif_PartEntry::m_partFSID, mif_PartEntry::m_partHost, m_partList, m_partList_x, mif_PartEntry::m_partName, mif_PartEntry::m_partStatus, mif_PartEntry::m_partUUID, SendClientFSIDs(), and StartPM().

Referenced by i_ManagementInterface_i::AddPartition().

                                                                      {
    log_FUNC_m(AddPart);

    cmn_MutexLock l(m_partList_x);

    try {
        // verify that entry does not exist already
        Find(a_partName);
    }
    catch (...) {
        // not found -> add to list
        mif_PartEntry pe;

        pe.m_partName = a_partName;
        pe.m_partUUID = a_partUUID;
        pe.m_partHost = a_host;
        pe.m_partFSID = a_fsID;
        pe.m_partStatus = mps_Stopped; // StartPM() will update this

        log_DBG_m(dbg_NORM, "partName: " << pe.m_partName << endl
                  << "  partHost: " << pe.m_partHost << endl 
                  << "  partFSID: " << pe.m_partFSID << endl);
        m_partList.push_back(pe);

        // start Partition Manager
        StartPM(--m_partList.end()); 

        // notify client about new FS ID
        SendClientFSIDs(a_host);

        return;
    }

    // Find() succeded - partition exist
    throw ivd_Error(ie_MIF_PARTITION_MGR, "Cannot add partition - duplicate"); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mif_PartMgr::DisablePart ( const string &  a_partName  ) 

Definition at line 294 of file mif_partmgr.cpp.

References dbg_LOW, Find(), log_DBG_m, log_FUNC_m, m_partList_x, SendClientFSIDs(), and StopPM().

Referenced by i_ManagementInterface_i::DisablePartition().

                                                      {
    log_FUNC_m(DisablePart);

    cmn_MutexLock l(m_partList_x);

    vector<mif_PartEntry>::iterator iter = Find(a_partName);

    // stop Partition Manager
    try {
        StopPM(iter);
    }
    catch (ivd_Exception &e) {
        log_DBG_m(dbg_LOW, "Cannot stop PM: " << iter->m_partName 
            << " - ignored: " << e);
    }

    // mark status as disabled
    iter->m_partStatus = mps_Disabled;

    // notify client about disabled FS ID
    SendClientFSIDs(iter->m_partHost);

    // TODO: should we update RMDB also here?
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mif_PartMgr::EnablePart ( const string &  a_partName  ) 

Definition at line 269 of file mif_partmgr.cpp.

References Find(), ie_PRECONDITION, ivd_Error, log_FUNC_m, m_partList_x, mps_Online, SendClientFSIDs(), and StartPM().

Referenced by i_ManagementInterface_i::EnablePartition().

                                                     {
    log_FUNC_m(EnablePart);

    cmn_MutexLock l(m_partList_x);

    vector<mif_PartEntry>::iterator iter = Find(a_partName);

    if (iter->m_partStatus == mps_Online){
        throw ivd_Error(ie_PRECONDITION, 
                        "Partition can not be enabled, it is already running.");
    } else {
        // mark status as stopped (will start later)
        iter->m_partStatus = mps_Stopped;
    }

    // start Partition Manager
    StartPM(iter);

    // notify client about enabled FS ID
    SendClientFSIDs(iter->m_partHost);

    // TODO: should we update RMDB also here?
}

Here is the call graph for this function:

Here is the caller graph for this function:

vector< mif_PartEntry >::iterator mif_PartMgr::Find ( const string &  a_partName  )  [private]

Definition at line 60 of file mif_partmgr.cpp.

References ie_FATAL_ERROR, ie_NOTFOUND, ivd_Error, log_FUNC_m, m_iMIF, m_partList, and NULL.

Referenced by AddPart(), DisablePart(), EnablePart(), GetPart(), IsInRecallOnlyMode(), IsMigrateWithCollocationSet(), RemovePart(), and UpdatePart().

                                                                        {

    log_FUNC_m(Find);
    if (m_iMIF == NULL){
        throw ivd_InternalError(ie_FATAL_ERROR, "MIF pointer not set.");
    }
    
    for (vector<mif_PartEntry>::iterator iter = m_partList.begin();
         iter != m_partList.end();
         ++iter) {

        if (iter->m_partName == a_partName) {
            return iter;
        }
    }

    throw ivd_Error(ie_NOTFOUND, "Cannot find partition.");
}

Here is the caller graph for this function:

vector<mif_PartEntry> mif_PartMgr::GetAllPart (  )  [inline]
void mif_PartMgr::GetAllPartFromRM (  ) 

Definition at line 330 of file mif_partmgr.cpp.

References dbg_LOW, dbg_NORM, ipc_EXEC_m, log_DBG_m, log_FUNC_m, m_iMIF, mif_PartEntry::m_iPM, mif_PartEntry::m_partFSID, mif_PartEntry::m_partFSMountPoint, mif_PartEntry::m_partHost, m_partList, m_partList_x, mif_PartEntry::m_partName, mif_PartEntry::m_partStatus, mif_PartEntry::m_partUUID, i_ManagementInterface_i::m_rm, partitionName, and rmdb_PARTITION_DISABLED.

Referenced by i_ManagementInterface_i::i_ManagementInterface_i().

                                   {
    log_FUNC_m(GetAllPartFromRM);

    cmn_MutexLock l(m_partList_x);

    // we will re-read all info about partitions from RMDB & CfgDB -> clear all
    m_partList.clear();

    i_PartSeq_t_var partSeq;
    try {
        ipc_EXEC_m(
            partSeq = m_iMIF->m_rm->SelectAllPartition();
        );
    }
    catch (ivd_Exception) {
        log_DBG_m(dbg_LOW, "No partitions found?");
        return;
    }

    for (UInt32_t i = 0; i < partSeq->length(); i++) {
        
        mif_PartEntry pe;

        log_DBG_m(dbg_LOW, "Found PM: " << partSeq[i].partitionName <<
            " fsID: " << partSeq[i].fsID);

        // set default value to pe element
        // TODO: move this to CTOR of mif_PartEntry
        pe.m_partName = partSeq[i].partitionName;
        pe.m_iPM = i_PartitionManager::_nil();
        pe.m_partStatus = mps_Stopped;

        if ((partSeq[i].status & rmdb_PARTITION_DISABLED)  
            == rmdb_PARTITION_DISABLED) {
                log_DBG_m(dbg_LOW, "Partition disabled");
                pe.m_partStatus = mps_Disabled;
        }

        // get client hostname and FS ID from configuration file
        // mif_Partition partition(m_iMIF, pe.m_partName);
        // partition.GetClientInfo(pe.m_partHost, pe.m_partFSID);

        // if fsID is empty update it with proper values 1.2->2.0 upgrade
        if (string(partSeq[i].fsID).empty()){
            ipc_EXEC_m(
                m_iMIF->m_rm->UpdatePartition(partSeq[i].partitionName);
                i_Partition_t_var pNew = m_iMIF->m_rm->SelectPartition(partSeq[i].partitionName);
                pe.m_partFSMountPoint = pNew->fsMountpoint;
                pe.m_partHost = pNew->fsHost;
                pe.m_partFSID = pNew->fsID;
                pe.m_partUUID = pNew->partitionUUIDString;
            );
        } else {
            pe.m_partFSMountPoint = partSeq[i].fsMountpoint;
            pe.m_partHost = partSeq[i].fsHost;
            pe.m_partFSID = partSeq[i].fsID;
            pe.m_partUUID = partSeq[i].partitionUUIDString;
        }


        // add partition to list of partitions
        log_DBG_m(dbg_NORM, "partName: " << pe.m_partName << endl
            << "  partHost: " << pe.m_partHost << endl 
            << "  partFSID: " << pe.m_partFSID << endl);
        m_partList.push_back(pe);
    }
} // mif_PartMgr::GetAllPartFromRM()

Here is the caller graph for this function:

void mif_PartMgr::GetClientFSIDs ( const string &  a_clientHost,
i_StringList_t a_list 
)

Definition at line 489 of file mif_partmgr.cpp.

References GetFSIDs(), log_FUNC_m, and m_partList_x.

Referenced by i_ManagementInterface_i::GetFSList().

                                                         {
    log_FUNC_m(GetClientFSIDs);

    cmn_MutexLock l(m_partList_x);

    GetFSIDs(a_clientHost, a_list);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mif_PartMgr::GetFSIDs ( const string &  a_clientHost,
i_StringList_t a_list 
) [private]

Definition at line 434 of file mif_partmgr.cpp.

References dbg_NORM, log_DBG_m, log_FUNC_m, m_partList, and mps_Disabled.

Referenced by GetClientFSIDs(), and SendClientFSIDs().

                                                                             {
    log_FUNC_m(GetFSIDs);

    for (UInt32_t i=0; i < m_partList.size(); ++i) {

        // only if partition online/enabled and host matches
        if (m_partList[i].m_partStatus != mps_Disabled
            && m_partList[i].m_partHost == a_clientHost) {

            log_DBG_m(dbg_NORM, "Client: " << a_clientHost << 
                                " FS: " << m_partList[i].m_partFSID);

            a_list.length(a_list.length()+1);
            a_list[a_list.length()-1] = 
                CORBA::string_dup(m_partList[i].m_partFSID.c_str());
        }
    }
}

Here is the caller graph for this function:

mif_PartEntry mif_PartMgr::GetPart ( const string &  a_partName  ) 
bool mif_PartMgr::IsInRecallOnlyMode ( const string &  a_partName  ) 

Definition at line 498 of file mif_partmgr.cpp.

References Find(), ipc_EXEC_m, log_FUNC_m, and m_partList_x.

Referenced by i_ManagementInterface_i::UpdatePartition().

                                                             {
    log_FUNC_m(IsInRecallOnlyMode);

    cmn_MutexLock l(m_partList_x);
    vector<mif_PartEntry>::iterator iter = Find(a_partName);
  
    ipc_EXEC_m(
        return iter->m_iPM->RecallOnlyMode();
    );
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool mif_PartMgr::IsMigrateWithCollocationSet ( const string &  a_partName  ) 

Definition at line 509 of file mif_partmgr.cpp.

References Find(), ipc_EXEC_m, log_FUNC_m, and m_partList_x.

Referenced by i_ManagementInterface_i::UpdatePartition().

                                                                      {
    log_FUNC_m(IsMigrateWithCollocationSet);

    cmn_MutexLock l(m_partList_x);
    vector<mif_PartEntry>::iterator iter = Find(a_partName);
  
    ipc_EXEC_m(
        return iter->m_iPM->MigrateWithCollocation()
    );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mif_PartMgr::RemovePart ( const string &  a_partName  ) 

Definition at line 243 of file mif_partmgr.cpp.

References dbg_LOW, Find(), log_DBG_m, log_FUNC_m, m_partList, m_partList_x, mps_Online, SendClientFSIDs(), and StopPM().

Referenced by i_ManagementInterface_i::RemovePartition().

                                                     {
    log_FUNC_m(RemovePart);

    cmn_MutexLock l(m_partList_x);

    vector<mif_PartEntry>::iterator iter = Find(a_partName);

    if (iter->m_partStatus == mps_Online) {
        try {
            StopPM(iter);
        }
        catch (ivd_Exception &e) {
            log_DBG_m(dbg_LOW, "Cannot stop PM: " << iter->m_partName 
                << " - ignored: " << e);
        }
    }

    // remove from partition list
    string host(iter->m_partHost);
    m_partList.erase(iter);

    // notify client about removed FS ID
    SendClientFSIDs(host);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mif_PartMgr::SendClientFSIDs ( const string &  a_clientHost  )  [private]

Definition at line 454 of file mif_partmgr.cpp.

References dbg_NORM, GetFSIDs(), log_DBG_m, log_ERR_m, log_FUNC_m, and ipc_Corba::ResolveFSEvtMgr().

Referenced by AddPart(), DisablePart(), EnablePart(), RemovePart(), and UpdatePart().

                                                            {
    log_FUNC_m(SendClientFSIDs);

    i_StringList_t list;
    GetFSIDs(a_clientHost, list);

    // now try to send list of FS IDs to client
    i_FsEvMgr_var iFSE;
    try {
        CORBA::Object_var obj = ipc_Corba::ResolveFSEvtMgr(a_clientHost.c_str(),
                                                        false);
        iFSE = i_FsEvMgr::_narrow(obj);
    }
    catch (...) {
        // ignore error and check next one...
        log_DBG_m(dbg_NORM, "Warning: cannot resolve FSE: " << 
                  a_clientHost);
        iFSE = i_FsEvMgr::_nil();
    }

    if (!CORBA::is_nil(iFSE)) {
        try {
            iFSE->SetFSList(list);
        }
        catch(...) {
            // ignore - try to do us much as possible
            log_ERR_m("Could not send FS IDs to FSE: " << a_clientHost);
        }
    }
    else {
        log_ERR_m("Could not send FS IDs to FSE (down): " << a_clientHost);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mif_PartMgr::SetMif ( i_ManagementInterface_i a_iMIF  )  [inline]

Definition at line 88 of file mif_partmgr.h.

References m_iMIF.

Referenced by i_ManagementInterface_i::i_ManagementInterface_i().

                                                   {
                m_iMIF = a_iMIF;
            }

Here is the caller graph for this function:

void mif_PartMgr::StartAllPart (  ) 

Definition at line 398 of file mif_partmgr.cpp.

References dbg_LOW, log_DBG_m, log_FUNC_m, m_partList, m_partList_x, mps_Disabled, and StartPM().

Referenced by i_ManagementInterface_i::i_ManagementInterface_i().

                               {
    log_FUNC_m(StartAllPart);

    cmn_MutexLock l(m_partList_x);

    vector<mif_PartEntry>::iterator iter;
    for (iter = m_partList.begin(); iter != m_partList.end(); ++iter){
        log_DBG_m(dbg_LOW, "Will start PM: " << iter->m_partName <<
                            " fsID" << iter->m_partFSID);
        // start Partition Manager (if not disabled)
        if (iter->m_partStatus != mps_Disabled) {
            StartPM(iter);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mif_PartMgr::StartPM ( vector< mif_PartEntry >::iterator  a_iter  )  [private]

Definition at line 80 of file mif_partmgr.cpp.

References dbg_NORM, g_cmn, i_IVDPM, ie_MIF_PARTITION_MGR, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_m, m_iMIF, cmn_SysInfo::m_serverHost, i_ManagementInterface_i::m_svc, ipc_Corba::ResolvePMByPartID(), and cmn_Global::si.

Referenced by AddPart(), EnablePart(), and StartAllPart().

                                                              {
    log_FUNC_m(StartPM);

    ipc_EXEC_m(
        try {
            bool isActive(false);

            // check if PM already running
            try { 
                ipc_EXEC_m(
                    CORBA::Object_var obj = ipc_Corba::ResolvePMByPartID(
                        g_cmn.si.m_serverHost, a_iter->m_partName, false);
                    i_PartitionManager_var p = i_PartitionManager::_narrow(obj);
                    isActive = true;
                )
            }
            catch (ivd_Exception) {
                isActive = false;
            }

            if (isActive) {
                throw ivd_Error(ie_MIF_PARTITION_MGR, 
                                "Can not start partition, already running");    
            }

            i_StringList_t argSequence;
            argSequence.length(2);
            argSequence[0] = CORBA::string_dup("--name");
            argSequence[1] = CORBA::string_dup(a_iter->m_partName.c_str());
            ipc_EXEC_m(
                m_iMIF->m_svc->Execute(i_IVDPM, argSequence);
            );
            log_DBG_m(dbg_NORM, "MIF: HSM-PM for partition " 
                      << a_iter->m_partName << " started.");


            CORBA::Object_var obj = ipc_Corba::ResolvePMByPartID(
                        g_cmn.si.m_serverHost, a_iter->m_partName, true);
            a_iter->m_iPM = i_PartitionManager::_narrow(obj);
            a_iter->m_partStatus = mps_Online;
        }
        catch (...) {
            a_iter->m_partStatus = mps_Stopped;
            a_iter->m_iPM = i_PartitionManager::_nil();
        }
    );
} // mif_PartMgr::StartPM()

Here is the call graph for this function:

Here is the caller graph for this function:

void mif_PartMgr::StopAllPart (  ) 

Definition at line 415 of file mif_partmgr.cpp.

References dbg_LOW, log_DBG_m, log_FUNC_m, m_partList, m_partList_x, mps_Online, and StopPM().

Referenced by i_ManagementInterface_i::Remove().

                              {
    log_FUNC_m(StopAllPart);

    cmn_MutexLock l(m_partList_x);

    vector<mif_PartEntry>::iterator iter;
    for (iter = m_partList.begin(); iter != m_partList.end(); ++iter){
        log_DBG_m(dbg_LOW, "Will stop PM: " << iter->m_partName);
        try {
            if (iter->m_partStatus == mps_Online) StopPM(iter);
        }
        catch (ivd_Exception &e) {
            log_DBG_m(dbg_LOW, "Cannot stop PM: " << iter->m_partName 
                                << " - ignored: " << e);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mif_PartMgr::StopPM ( vector< mif_PartEntry >::iterator  a_iter  )  [private]

Definition at line 129 of file mif_partmgr.cpp.

References ipc_EXEC_m, and log_FUNC_m.

Referenced by DisablePart(), RemovePart(), and StopAllPart().

                                                             {
    log_FUNC_m(StopPM);

    try {
        ipc_EXEC_m(
            if (a_iter->m_iPM != i_PartitionManager::_nil()){
                a_iter->m_iPM->Remove();
                CORBA::release(a_iter->m_iPM);
            }
        );
    } catch (ivd_Error& e){
        // just log this error and continue
        log_ERR_m(e);
    }

    a_iter->m_partStatus = mps_Stopped;
    a_iter->m_iPM = i_PartitionManager::_nil();
}

Here is the caller graph for this function:

void mif_PartMgr::UpdatePart ( const string &  a_partName,
const string &  a_host,
const string &  a_fsID 
)

Definition at line 188 of file mif_partmgr.cpp.

References dbg_NORM, Find(), ivd_BaseException::GetFriendly(), ie_MIF_PARTITION_MGR, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_m, m_partList_x, mps_Online, and SendClientFSIDs().

Referenced by i_ManagementInterface_i::UpdatePartition().

                                                                         {
    log_FUNC_m(UpdatePart);

    cmn_MutexLock l(m_partList_x);

    vector<mif_PartEntry>::iterator iter = Find(a_partName);
  
    // check if FS ID changed: has to notify client
    bool changedFSID(false);
    if (iter->m_partFSID != a_fsID) {
        iter->m_partFSID = a_fsID;
        changedFSID = true;
    }

    // check if client name changed: has to notify old client also
    string oldHost;
    if (iter->m_partHost != a_host) {
        iter->m_partHost = a_host;
        oldHost = iter->m_partHost; // save old hostname for update
    }

    log_DBG_m(dbg_NORM, "partName: " << iter->m_partName << endl
              << "  partHost: " << iter->m_partHost << endl 
              << "  partFSID: " << iter->m_partFSID << endl);

    if (iter->m_partStatus == mps_Online) {
        // update partition manager configuration (re-read)
        try {
            ipc_EXEC_m(
                iter->m_iPM->RefreshCfg();
            );
        }
        catch (ivd_Exception &ex) {
            throw ivd_Error(ie_MIF_PARTITION_MGR, 
                            "Cannot reconfigure Partition Manager: " + 
                            ex.GetFriendly());
        }
        log_DBG_m(dbg_NORM, "Partition manager " << a_partName << 
                            " refreshed configuration.");
    }

    // if host changed: notify old client about removed FS ID
    if (!oldHost.empty()) {
        SendClientFSIDs(oldHost);
    }

    // if host or FSID changed: notify old client about removed FS ID
    if (changedFSID || !oldHost.empty()) {
        // notify client about new FS ID
        SendClientFSIDs(iter->m_partHost);
    }
} // mif_PartMgr::UpdatePart()

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 85 of file mif_partmgr.h.

Definition at line 83 of file mif_partmgr.h.

Referenced by Find(), GetAllPartFromRM(), SetMif(), and StartPM().


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