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

#include <joblistmgr.h>

Collaboration diagram for JobListMgr< T1 >:

Collaboration graph
[legend]

List of all members.


Detailed Description

template<class T1>
class JobListMgr< T1 >

Definition at line 108 of file joblistmgr.h.


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

Member Typedef Documentation

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

Definition at line 112 of file joblistmgr.h.

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

Definition at line 113 of file joblistmgr.h.


Constructor & Destructor Documentation

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

Default constructor.

Definition at line 117 of file joblistmgr.h.

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

00117                 {
00118         log_FUNC_m(JobListMgr);
00119         m_unusedJTidx.clear();
00120         m_Jobs.clear();
00121     };

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

Definition at line 122 of file joblistmgr.h.

References log_FUNC_m.

00122                              {
00123         log_FUNC_m(~JobListMgr);
00124     };


Member Function Documentation

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

Definition at line 140 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().

00140                                      {
00141         log_FUNC_m(DoReleaseIdx);
00142 
00143         m_Jobs[a_idx].clear();
00144         m_unusedJTidx.push_back(a_idx);
00145         log_DBG_m(dbg_DETAIL, "  JobListMgr list release index " << a_idx << 
00146                               ". Index is put into Unused list");
00147     };

Here is the caller graph for this function:

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

Definition at line 151 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.

00151                                                          {  // Insert structure at the end of a_jobNumber job  
00152         log_FUNC_m(Insert);
00153 
00154         cmn_MutexLock l(m_jobmgr_x);
00155 
00156         OneJob_t &jobList = m_Jobs[a_jobNumber];
00157 //         UInt32_t jobIdx     = static_cast<UInt32_t>(jobList.size());
00158         UInt32_t jobIdx, tJobSize;
00159         a_oneFile->m_jobIdx = jobIdx = jobList.size();
00160         
00161         jobList.push_back(a_oneFile);
00162         
00163         tJobSize = jobList.size();
00164         if (tJobSize != (jobIdx + 1)) {
00165             log_ERR_m("Insert is NOT DONE!");
00166             throw ivd_InternalError (ie_NOINSERT);
00167         }
00168         log_DBG_m(dbg_DETAIL, "  JobListMgr list insert at index [" << a_jobNumber <<
00169                               ":" << jobIdx << "]");
00170         return jobIdx;
00171     };

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

Definition at line 173 of file joblistmgr.h.

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

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

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

Definition at line 181 of file joblistmgr.h.

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

00181                               {  // Get size of jobs vector
00182         cmn_MutexLock l(m_jobmgr_x);
00183         UInt32_t retv;
00184         retv = m_Jobs.size();
00185         return retv;
00186     };

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

Definition at line 188 of file joblistmgr.h.

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

00188                                     {  // Get number of active jobs
00189         cmn_MutexLock l(m_jobmgr_x);
00190         UInt32_t retv;
00191         retv = m_Jobs.size() - m_unusedJTidx.size();
00192         return retv;
00193     };

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

Definition at line 195 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.

00195                                                           {  // Release element in a_jobNumber job at a_jobIdx index 
00196         log_FUNC_m(Release);
00197 
00198         cmn_MutexLock l(m_jobmgr_x);
00199 
00200         OneJob_t &jobList = m_Jobs[a_jobNumber];
00201 
00202         T1 *oneFile = jobList[a_jobIdx];
00203         if (oneFile != NULL) {
00204             delete oneFile;
00205         }
00206         else {
00207             log_DBG_m(dbg_NORM, "JobListMgr list released index [" << a_jobNumber <<
00208                               ":" << a_jobIdx << "]: file is NULL");
00209         }
00210         jobList[a_jobIdx] = NULL;
00211         log_DBG_m(dbg_DETAIL, "  JobListMgr list released index [" << a_jobNumber <<
00212                               ":" << a_jobIdx << "]");
00213     };

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

Definition at line 215 of file joblistmgr.h.

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

00215                                    {  // Release a_idx job 
00216         log_FUNC_m(ReleaseIdx);
00217         cmn_MutexLock l(m_jobmgr_x);
00218         
00219         DoReleaseIdx(a_idx);
00220     };

Here is the call graph for this function:

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

Definition at line 222 of file joblistmgr.h.

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

00222                                                     { // Return element in a_jobNumber job at a_jobIdx position
00223 
00224         log_FUNC_m(At);
00225         cmn_MutexLock l(m_jobmgr_x);
00226         UInt32_t tnumJob, tjobElem;
00227         tnumJob = m_Jobs.size();
00228         if ( tnumJob > a_jobNumber) {
00229             OneJob_t &jobList = m_Jobs[a_jobNumber];
00230             tjobElem = jobList.size();
00231             if (tjobElem > a_jobIdx ) {
00232                 return jobList[a_jobIdx];
00233             }
00234         }
00235         log_DBG_m(dbg_NORM, "  JobListMgr index [" << a_jobNumber <<
00236                               ":" << a_jobIdx << "] IS_WRONG or EMPTY");
00237         return NULL;
00238     };

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 244 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.

00244                                             {  //Reserve new empty job and return it's index
00245         log_FUNC_m(GetJobList);
00246         cmn_MutexLock l(m_jobmgr_x);
00247 
00248         UInt32_t tIdx;
00249         unusedIter_t Iter = m_unusedJTidx.begin();
00250         if (Iter != m_unusedJTidx.end()) {   // has at least one element
00251             tIdx = *Iter;
00252             m_Jobs[tIdx].reserve(a_numFiles);
00253             Iter = m_unusedJTidx.erase(Iter);
00254             if (Iter != m_unusedJTidx.end()) {
00255                 if (   *Iter == tIdx 
00256                     || m_Jobs[tIdx].size() != 0) {
00257                     throw ivd_Error(ie_STLNOTERASED,"Unused JobList at " + cmn_Num2Str(tIdx));
00258                 }
00259             }
00260             log_DBG_m(dbg_DETAIL, "  JobListMgr release index in unused list " << tIdx);
00261         }
00262         else {
00263             OneJob_t tjobFT;
00264             tjobFT.clear();
00265             m_Jobs.push_back(tjobFT);
00266             tIdx = static_cast<UInt32_t>(m_Jobs.size()) - 1;
00267 
00268             m_Jobs[tIdx].reserve(a_numFiles);
00269 
00270             log_DBG_m(dbg_DETAIL, "  Size of JobListMgr's vector is increased to " << tIdx + 1);
00271             if (tIdx > 1000) {
00272                 log_NOTE_m("  Size of JobListMgr's vector is increased to " << tIdx + 1);
00273             }
00274         }
00275         log_DBG_m(dbg_DETAIL, "  JobListMgr list return unused index " << tIdx);
00276         return tIdx;
00277     };

Here is the call graph for this function:

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 284 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.

00284                                         {  // Check whole joblist if is individual job empty
00285         log_FUNC_m(CheckFree);
00286 
00287         cmn_MutexLock l(m_jobmgr_x);
00288 
00289         UInt32_t numEmpty = 0;
00290         OneJob_t &oneJob = m_Jobs[a_jobNumber];
00291         UInt32_t numElem;
00292         numElem = oneJob.size();
00293 
00294         for (UInt32_t vidx = 0; vidx < numElem; vidx ++){
00295             T1 *fileRec = oneJob[vidx];
00296             if (fileRec == NULL){
00297                 numEmpty++;
00298             }
00299         }    
00300         log_DBG_m(dbg_DETAIL, "  JobListMgr at " << a_jobNumber << 
00301                                          " has " << numElem << 
00302                                          " elements and " << numEmpty << " of them are empty.");
00303         if (numElem == numEmpty && numElem != 0) {
00304             DoReleaseIdx(a_jobNumber);
00305         }
00306     };

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 115 of file joblistmgr.h.

template<class T1>
list<UInt32_t> JobListMgr< T1 >::m_unusedJTidx [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 136 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>
cmn_Mutex JobListMgr< T1 >::m_jobmgr_x [private]


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

Generated on Mon Feb 27 19:42:13 2012 for OPENARCHIVE by  doxygen 1.5.6