Public Member Functions | Public Attributes | Private Attributes

FSEvMgrThrd Class Reference
[File System Event Manager]

FS Evenet Manager Thread. More...

#include <ivd-fsevent.h>

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

List of all members.

Public Member Functions

 FSEvMgrThrd (int a_fd)
 Release list thread constructor.
 ~FSEvMgrThrd ()
 Release list thread destructor.
void SendReply (UInt16_t a_status, hsm_req_t *a_req)
virtual void Run (void *arg)
 Release list thread run method.
 FSEvMgrThrd (int a_fd)
 ~FSEvMgrThrd ()
void SendReply (UInt16_t a_status, ivd_req_t *a_req)
virtual void Run (void *arg)

Public Attributes

 log_CLASSID_m

Private Attributes

int m_fd
i_Service_var m_iService

Detailed Description

FS Evenet Manager Thread.

Author:
Andrej Jamsek, HERMES SoftLab

Definition at line 110 of file hpux/ivd-fsevent.h.


Constructor & Destructor Documentation

FSEvMgrThrd::FSEvMgrThrd ( int  a_fd  ) 

Release list thread constructor.

Definition at line 158 of file hpux/ivd-fsevent.cpp.

References log_FUNC_m.

                                : 
        m_fd(a_fd){

    log_FUNC_m(FSEvMgrThrd);
}

FSEvMgrThrd::~FSEvMgrThrd (  ) 

Release list thread destructor.

Definition at line 167 of file hpux/ivd-fsevent.cpp.

References log_FUNC_m.

FSEvMgrThrd::FSEvMgrThrd ( int  a_fd  ) 
FSEvMgrThrd::~FSEvMgrThrd (  ) 

Member Function Documentation

void FSEvMgrThrd::Run ( void *  arg  )  [virtual]

Release list thread run method.

Reimplemented from cmn_Thread.

Definition at line 174 of file hpux/ivd-fsevent.cpp.

References PreMountsMgr::Add(), hsm_req_t::cancel, cmn_Num2Str(), hsm_req_log_error_t::code, hsm_req_pre_mount_t::comm_minor, dbg_LOW, PreMountsMgr::Del(), hsm_req_log_error_t::dev_major, hsm_req_pre_mount_t::dev_major, hsm_req_log_error_t::dev_minor, hsm_req_pre_mount_t::dev_minor, hsm_req_t::error, evt_ERROR, evt_WARNING, g_cmn, g_runHSM, ivd_BaseException::GetDescription(), ivd_BaseException::GetError(), ivd_BaseException::GetFriendly(), hsm_req_t::hdr, HSM_DEVNAME, HSM_ERR_BOTTOM_MOUNT_d, HSM_ERR_HSM_CLOSED_d, HSM_ERR_REPLY_d, HSM_EVT_CANCEL_REQ, HSM_EVT_LOG_ERROR, HSM_EVT_PRE_MOUNT, HSM_WRN_HSM_BUSY_d, i_IVDHSM, ipc_EXEC_m, log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), m_fd, cmn_SysInfo::m_hostName, ivd_Product::m_nameShortLC, MAX_EVT_BUFSIZE, hsm_req_t::pre_mount, cmn_Global::prod, hsm_req_cancel_req_t::reqid, ipc_Corba::ResolveSvc(), SendReply(), cmn_Global::si, size, and hsm_req_hdr_t::type.

                              {

    log_FUNC_m(Run);

    int             size;
    char            buf[MAX_EVT_BUFSIZE];
    hsm_req_t       *req;

    while ((size = read(m_fd, buf, MAX_EVT_BUFSIZE)) > 0) {
        req = (hsm_req_t *) buf;
        if (req->hdr.type == HSM_EVT_PRE_MOUNT) {

            string callDev = 
                string("/dev/" HSM_DEVNAME "/") + 
                cmn_Num2Str(req->pre_mount.comm_minor);

            string fileUUID =
                cmn_Num2Str(req->pre_mount.dev_major) +
                string(":") +
                cmn_Num2Str(req->pre_mount.dev_minor);

            log_WriteEvent("Mount request (comm device: " + callDev + ").", 
                           "", 0, fileUUID);

            try {
                g_premountMgr.Add(fileUUID, req->hdr);

                if (g_runHSM) {
                    i_StringList_t seqArgum;
                    seqArgum.length(2);
                    seqArgum[0] = CORBA::string_dup(callDev.c_str());
                    seqArgum[1] = CORBA::string_dup(fileUUID.c_str());

                    log_DBG_m(dbg_LOW, "Starting ivd-hsm on " << callDev
                        << " for " << fileUUID << "." );

                    ipc_EXEC_m(
                        CORBA::Object_var obj =
                            ipc_Corba::ResolveSvc(g_cmn.si.m_hostName);
                        i_Service_var iService = i_Service::_narrow(obj);

                        iService->Execute(i_IVDHSM, seqArgum);
                    );
                    log_DBG_m(dbg_LOW, "Execute succeeded.");
                }
                else {
                    log_DBG_m(dbg_LOW,
                        "HSM not started - start manually: " << endl << 
                        "ivd-hsm " << callDev << " " << fileUUID);
                }
            }
            catch (ivd_Exception &ie) {
                log_ERR_m("Caught ERROR "
                    << ie.GetError() << " " << ie.GetDescription());
                ostringstream sstr;
                sstr << "Starting HSM failed (" << ie.GetFriendly() << ").";
                log_WriteEvent(evt_ERROR, sstr.str(), "", 0, fileUUID);
                SendReply(ie.GetError(), req);
            }
            catch (std::exception &se) {
                log_ERR_m("Caught std::exception ERROR " << se.what());
                ostringstream sstr;
                sstr << "Starting HSM failed (" << se.what() << ").";
                log_WriteEvent(evt_ERROR, sstr.str(), "", 0, fileUUID);
                SendReply(HSM_ERR_REPLY_d, req);
            }
            catch (...) {
                log_ERR_m("Caught unknown exception");
                ostringstream sstr;
                sstr << "Starting HSM failed (unknown exception).";
                log_WriteEvent(evt_ERROR, sstr.str(), "", 0, fileUUID);
                SendReply(HSM_ERR_REPLY_d, req);
            }

        } else if (req->hdr.type == HSM_EVT_CANCEL_REQ) {
            g_premountMgr.Del(req->cancel.reqid);
        } else if (req->hdr.type == HSM_EVT_LOG_ERROR) {
            string fileUUID =
                cmn_Num2Str(req->error.dev_major) +
                string(":") +
                cmn_Num2Str(req->error.dev_minor);

            switch (req->error.code) {
            case HSM_ERR_HSM_CLOSED_d:
                log_WriteEvent(evt_ERROR,
                               "Premature HSM exit. Unmount and run "
                               + g_cmn.prod.m_nameShortLC + "check!",
                               "", 0, fileUUID);
                break;
            case HSM_ERR_BOTTOM_MOUNT_d:
                log_WriteEvent(evt_ERROR,
                    "Failed to mount bottom file system. See dmesg for details.",
                    "", 0, fileUUID);
                break;
            case HSM_WRN_HSM_BUSY_d:
                log_WriteEvent(evt_WARNING,
                    "Read of event messages were stopped or slowed down by HSM. See dmesg for details.",
                    "", 0, fileUUID);
                break;
            default :
                ostringstream sstr;
                sstr << "Got unknown error code from HSMFS: " 
                     << req->error.code;
                log_WriteEvent(evt_ERROR, sstr.str(), "", 0, fileUUID);
                log_ERR_m("Got unknown error code from HSMFS:"
                    << req->error.code << " for " << fileUUID);
            }
        }
        else {
            log_ERR_m("FSeventMgr caught " << req->hdr.type << " event");
        }
    }
}

Here is the call graph for this function:

virtual void FSEvMgrThrd::Run ( void *  arg  )  [virtual]

Reimplemented from cmn_Thread.

void FSEvMgrThrd::SendReply ( UInt16_t  a_status,
ivd_req_t a_req 
)

Definition at line 288 of file linux/ivd-fsevent.cpp.

References ivd_req_hdr_t::code, dbg_NORM, errno, g_fd, ivd_req_t::hdr, log_DBG_m, log_ERR_m, log_FUNC_m, ivd_req_hdr_t::reqid, and SendReply().

                                                              {

    log_FUNC_m(SendReply);

    int size = sizeof(ivd_req_t);

    log_DBG_m(dbg_NORM, "regid: " << a_req->hdr.reqid
        << " a_status: " << a_status);

    a_req->hdr.code = a_status;

    int ret = write(g_fd, a_req, size);
    if (ret < 0 || ret < size) {
        log_ERR_m("Sending Reply failed. Errno: " << errno);

        //throw ivd_Error(ie_ERRORWRITE, strerror(errno));
        //pgtoni:
        //This throw is not cached in Run, will change it to log_ERR_m
        log_ERR_m(strerror(errno));
    }
}

Here is the call graph for this function:

void FSEvMgrThrd::SendReply ( UInt16_t  a_status,
hsm_req_t a_req 
)

Definition at line 289 of file hpux/ivd-fsevent.cpp.

References dbg_NORM, errno, g_fd, hsm_req_t::hdr, log_DBG_m, log_ERR_m, log_FUNC_m, hsm_req_hdr_t::reqid, size, and hsm_req_hdr_t::status.

Referenced by Run(), and SendReply().

                                                              {

    log_FUNC_m(SendReply);

    int size = sizeof(hsm_req_t);

    log_DBG_m(dbg_NORM, "regid: " << a_req->hdr.reqid
        << " a_status: " << a_req->hdr.reqid, a_status);

    a_req->hdr.status = a_status;

    int ret = write(g_fd, a_req, size);
    if (ret < 0 || ret < size) {
        log_ERR_m("Sending Reply failed. Errno: " << errno);

        //throw ivd_Error(ie_ERRORWRITE, strerror(errno));
        //pgtoni:
        //This throw is not cached in Run, will change it to log_ERR_m
        log_ERR_m(strerror(errno));
    }
}

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from cmn_Thread.

Definition at line 118 of file hpux/ivd-fsevent.h.

int FSEvMgrThrd::m_fd [private]

Definition at line 113 of file hpux/ivd-fsevent.h.

Referenced by Run().

i_Service_var FSEvMgrThrd::m_iService [private]

Definition at line 114 of file hpux/ivd-fsevent.h.


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