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

JobListMgr< T1 > Class Template Reference
[Classes for managing events]

#include <joblistmgr.h>

Collaboration diagram for JobListMgr< T1 >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef vector< T1 * > OneJob_t
typedef vector< OneJob_tJobs_t

Public Member Functions

 JobListMgr ()
 Default constructor.
virtual ~JobListMgr ()
UInt32_t Insert (UInt32_t a_jobNumber, T1 *a_oneFile)
UInt32_t GetNumElem (UInt32_t a_jobNumber)
UInt32_t GetNumJobs (void)
UInt32_t GetNumActiveJobs (void)
void Release (UInt32_t a_jobNumber, UInt32_t a_jobIdx)
void ReleaseIdx (UInt32_t a_idx)
T1 * At (UInt32_t a_jobNumber, UInt32_t a_jobIdx)
UInt32_t GetJobList (UInt32_t a_numFiles)
 method to reserve new JobList index for new job.
void CheckFree (UInt32_t a_jobNumber)
 method to check if some vector has all elements in state deleted.

Public Attributes

 log_CLASSID_m
 Macro to add class name member s_className.

Private Member Functions

void DoReleaseIdx (UInt32_t a_idx)

Private Attributes

list< UInt32_tm_unusedJTidx
Jobs_t m_Jobs
 method to delete JobList vector's record and put this unused vector index top list of unused indexes.
cmn_Mutex m_jobmgr_x

Detailed Description

template<class T1>
class JobListMgr< T1 >

Definition at line 122 of file joblistmgr.h.


Member Typedef Documentation

template<class T1 >
typedef vector<OneJob_t> JobListMgr< T1 >::Jobs_t

Definition at line 127 of file joblistmgr.h.

template<class T1 >
typedef vector<T1 *> JobListMgr< T1 >::OneJob_t

Definition at line 126 of file joblistmgr.h.


Constructor & Destructor Documentation

template<class T1 >
JobListMgr< T1 >::JobListMgr (  )  [inline]

Default constructor.

Definition at line 131 of file joblistmgr.h.

References log_FUNC_m, JobListMgr< T1 >::m_Jobs, and JobListMgr< T1 >::m_unusedJTidx.

                {
        log_FUNC_m(JobListMgr);
        m_unusedJTidx.clear();
        m_Jobs.clear();
    };

template<class T1 >
virtual JobListMgr< T1 >::~JobListMgr (  )  [inline, virtual]

Definition at line 136 of file joblistmgr.h.

References log_FUNC_m.


Member Function Documentation

template<class T1 >
T1* JobListMgr< T1 >::At ( UInt32_t  a_jobNumber,
UInt32_t  a_jobIdx 
) [inline]

Definition at line 236 of file joblistmgr.h.

References dbg_NORM, log_DBG_m, log_FUNC_m, JobListMgr< T1 >::m_jobmgr_x, and JobListMgr< T1 >::m_Jobs.

                                                    { // Return element in a_jobNumber job at a_jobIdx position

        log_FUNC_m(At);
        cmn_MutexLock l(m_jobmgr_x);
        UInt32_t tnumJob, tjobElem;
        tnumJob = m_Jobs.size();
        if ( tnumJob > a_jobNumber) {
            OneJob_t &jobList = m_Jobs[a_jobNumber];
            tjobElem = jobList.size();
            if (tjobElem > a_jobIdx ) {
                return jobList[a_jobIdx];
            }
        }
        log_DBG_m(dbg_NORM, "  JobListMgr index [" << a_jobNumber <<
                              ":" << a_jobIdx << "] IS_WRONG or EMPTY");
        return NULL;
    };

template<class T1 >
void JobListMgr< T1 >::CheckFree ( UInt32_t  a_jobNumber  )  [inline]

method to check if some vector has all elements in state deleted.

If found that kind call ReleaseIdx method This method is called after Migration / Recall

Definition at line 298 of file joblistmgr.h.

References dbg_DETAIL, JobListMgr< T1 >::DoReleaseIdx(), log_DBG_m, log_FUNC_m, JobListMgr< T1 >::m_jobmgr_x, JobListMgr< T1 >::m_Jobs, and NULL.

                                        {  // Check whole joblist if is individual job empty
        log_FUNC_m(CheckFree);

        cmn_MutexLock l(m_jobmgr_x);

        UInt32_t numEmpty = 0;
        OneJob_t &oneJob = m_Jobs[a_jobNumber];
        UInt32_t numElem;
        numElem = oneJob.size();

        for (UInt32_t vidx = 0; vidx < numElem; vidx ++){
            T1 *fileRec = oneJob[vidx];
            if (fileRec == NULL){
                numEmpty++;
            }
        }    
        log_DBG_m(dbg_DETAIL, "  JobListMgr at " << a_jobNumber << 
                                         " has " << numElem << 
                                         " elements and " << numEmpty << " of them are empty.");
        if (numElem == numEmpty && numElem != 0) {
            DoReleaseIdx(a_jobNumber);
        }
    };

Here is the call graph for this function:

template<class T1 >
void JobListMgr< T1 >::DoReleaseIdx ( UInt32_t  a_idx  )  [inline, private]

Definition at line 154 of file joblistmgr.h.

References dbg_DETAIL, log_DBG_m, log_FUNC_m, JobListMgr< T1 >::m_Jobs, and JobListMgr< T1 >::m_unusedJTidx.

Referenced by JobListMgr< T1 >::CheckFree(), and JobListMgr< T1 >::ReleaseIdx().

                                     {
        log_FUNC_m(DoReleaseIdx);

        m_Jobs[a_idx].clear();
        m_unusedJTidx.push_back(a_idx);
        log_DBG_m(dbg_DETAIL, "  JobListMgr list release index " << a_idx << 
                              ". Index is put into Unused list");
    };

Here is the caller graph for this function:

template<class T1 >
UInt32_t JobListMgr< T1 >::GetJobList ( UInt32_t  a_numFiles  )  [inline]

method to reserve new JobList index for new job.

Method get index from list of unused JobList indexes. If List is empty reserve new records in JobList vector and put them to list of unused indexes.

Returns:
new index for fileTrans structures of one job

Definition at line 258 of file joblistmgr.h.

References cmn_Num2Str(), dbg_DETAIL, ie_STLNOTERASED, ivd_Error, log_DBG_m, log_FUNC_m, log_NOTE_m, JobListMgr< T1 >::m_jobmgr_x, JobListMgr< T1 >::m_Jobs, JobListMgr< T1 >::m_unusedJTidx, and size.

                                            {  //Reserve new empty job and return it's index
        log_FUNC_m(GetJobList);
        cmn_MutexLock l(m_jobmgr_x);

        UInt32_t tIdx;
        unusedIter_t Iter = m_unusedJTidx.begin();
        if (Iter != m_unusedJTidx.end()) {   // has at least one element
            tIdx = *Iter;
            m_Jobs[tIdx].reserve(a_numFiles);
            Iter = m_unusedJTidx.erase(Iter);
            if (Iter != m_unusedJTidx.end()) {
                if (   *Iter == tIdx 
                    || m_Jobs[tIdx].size() != 0) {
                    throw ivd_Error(ie_STLNOTERASED,"Unused JobList at " + cmn_Num2Str(tIdx));
                }
            }
            log_DBG_m(dbg_DETAIL, "  JobListMgr release index in unused list " << tIdx);
        }
        else {
            OneJob_t tjobFT;
            tjobFT.clear();
            m_Jobs.push_back(tjobFT);
            tIdx = static_cast<UInt32_t>(m_Jobs.size()) - 1;

            m_Jobs[tIdx].reserve(a_numFiles);

            log_DBG_m(dbg_DETAIL, "  Size of JobListMgr's vector is increased to " << tIdx + 1);
            if (tIdx > 1000) {
                log_NOTE_m("  Size of JobListMgr's vector is increased to " << tIdx + 1);
            }
        }
        log_DBG_m(dbg_DETAIL, "  JobListMgr list return unused index " << tIdx);
        return tIdx;
    };

Here is the call graph for this function:

template<class T1 >
UInt32_t JobListMgr< T1 >::GetNumActiveJobs ( void   )  [inline]

Definition at line 202 of file joblistmgr.h.

References JobListMgr< T1 >::m_jobmgr_x, JobListMgr< T1 >::m_Jobs, and JobListMgr< T1 >::m_unusedJTidx.

                                    {  // Get number of active jobs
        cmn_MutexLock l(m_jobmgr_x);
        UInt32_t retv;
        retv = m_Jobs.size() - m_unusedJTidx.size();
        return retv;
    };

template<class T1 >
UInt32_t JobListMgr< T1 >::GetNumElem ( UInt32_t  a_jobNumber  )  [inline]

Definition at line 187 of file joblistmgr.h.

References JobListMgr< T1 >::m_jobmgr_x, and JobListMgr< T1 >::m_Jobs.

                                              { // Return number of elements in one job
        cmn_MutexLock l(m_jobmgr_x);
        OneJob_t &jobList = m_Jobs[a_jobNumber];
        UInt32_t retv;
        retv = jobList.size();
        return retv;
    };

template<class T1 >
UInt32_t JobListMgr< T1 >::GetNumJobs ( void   )  [inline]

Definition at line 195 of file joblistmgr.h.

References JobListMgr< T1 >::m_jobmgr_x, and JobListMgr< T1 >::m_Jobs.

                              {  // Get size of jobs vector
        cmn_MutexLock l(m_jobmgr_x);
        UInt32_t retv;
        retv = m_Jobs.size();
        return retv;
    };

template<class T1 >
UInt32_t JobListMgr< T1 >::Insert ( UInt32_t  a_jobNumber,
T1 *  a_oneFile 
) [inline]

Definition at line 165 of file joblistmgr.h.

References dbg_DETAIL, ie_NOINSERT, log_DBG_m, log_ERR_m, log_FUNC_m, JobListMgr< T1 >::m_jobmgr_x, and JobListMgr< T1 >::m_Jobs.

                                                         {  // Insert structure at the end of a_jobNumber job  
        log_FUNC_m(Insert);

        cmn_MutexLock l(m_jobmgr_x);

        OneJob_t &jobList = m_Jobs[a_jobNumber];
//         UInt32_t jobIdx     = static_cast<UInt32_t>(jobList.size());
        UInt32_t jobIdx, tJobSize;
        a_oneFile->m_jobIdx = jobIdx = jobList.size();
        
        jobList.push_back(a_oneFile);
        
        tJobSize = jobList.size();
        if (tJobSize != (jobIdx + 1)) {
            log_ERR_m("Insert is NOT DONE!");
            throw ivd_InternalError (ie_NOINSERT);
        }
        log_DBG_m(dbg_DETAIL, "  JobListMgr list insert at index [" << a_jobNumber <<
                              ":" << jobIdx << "]");
        return jobIdx;
    };

template<class T1 >
void JobListMgr< T1 >::Release ( UInt32_t  a_jobNumber,
UInt32_t  a_jobIdx 
) [inline]

Definition at line 209 of file joblistmgr.h.

References dbg_DETAIL, dbg_NORM, log_DBG_m, log_FUNC_m, JobListMgr< T1 >::m_jobmgr_x, JobListMgr< T1 >::m_Jobs, and NULL.

                                                          {  // Release element in a_jobNumber job at a_jobIdx index 
        log_FUNC_m(Release);

        cmn_MutexLock l(m_jobmgr_x);

        OneJob_t &jobList = m_Jobs[a_jobNumber];

        T1 *oneFile = jobList[a_jobIdx];
        if (oneFile != NULL) {
            delete oneFile;
        }
        else {
            log_DBG_m(dbg_NORM, "JobListMgr list released index [" << a_jobNumber <<
                              ":" << a_jobIdx << "]: file is NULL");
        }
        jobList[a_jobIdx] = NULL;
        log_DBG_m(dbg_DETAIL, "  JobListMgr list released index [" << a_jobNumber <<
                              ":" << a_jobIdx << "]");
    };

template<class T1 >
void JobListMgr< T1 >::ReleaseIdx ( UInt32_t  a_idx  )  [inline]

Definition at line 229 of file joblistmgr.h.

References JobListMgr< T1 >::DoReleaseIdx(), log_FUNC_m, and JobListMgr< T1 >::m_jobmgr_x.

                                   {  // Release a_idx job 
        log_FUNC_m(ReleaseIdx);
        cmn_MutexLock l(m_jobmgr_x);
        
        DoReleaseIdx(a_idx);
    };

Here is the call graph for this function:


Member Data Documentation

template<class T1 >
JobListMgr< T1 >::log_CLASSID_m

Macro to add class name member s_className.

Definition at line 129 of file joblistmgr.h.

template<class T1 >
cmn_Mutex JobListMgr< T1 >::m_jobmgr_x [private]
template<class T1 >
Jobs_t JobListMgr< T1 >::m_Jobs [private]

method to delete JobList vector's record and put this unused vector index top list of unused indexes.

method do not check if record of vector is empty - methos just delete it!

Parameters:
a_idx unused index of vector

Definition at line 150 of file joblistmgr.h.

Referenced by JobListMgr< T1 >::At(), JobListMgr< T1 >::CheckFree(), JobListMgr< T1 >::DoReleaseIdx(), JobListMgr< T1 >::GetJobList(), JobListMgr< T1 >::GetNumActiveJobs(), JobListMgr< T1 >::GetNumElem(), JobListMgr< T1 >::GetNumJobs(), JobListMgr< T1 >::Insert(), JobListMgr< T1 >::JobListMgr(), and JobListMgr< T1 >::Release().

template<class T1 >
list<UInt32_t> JobListMgr< T1 >::m_unusedJTidx [private]

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