CJobStatusTracker Class Reference

Search Toolkit Book for CJobStatusTracker

#include <job_status.hpp>

Collaboration diagram for CJobStatusTracker:

Collaboration graph
[legend]
List of all members.

Detailed Description

In-Memory storage to track status of all jobs Syncronized thread safe class.

Definition at line 57 of file job_status.hpp.

Public Types

typedef vector< TNSBitVector * > TStatusStorage
typedef map< TJobStatus, unsigned > TStatusSummaryMap
 Status to number of jobs map.

Public Member Functions

 CJobStatusTracker ()
 ~CJobStatusTracker ()
TJobStatus GetStatus (unsigned job_id) const
TJobStatus ChangeStatus (unsigned job_id, TJobStatus status, bool *updated=NULL)
 Set job status.
void AddPendingBatch (unsigned job_id_from, unsigned job_id_to)
 Add closed interval of ids to pending status.
bool GetPendingJobFromSet (TNSBitVector *candidate_set, unsigned *job_id)
 Get pending job out of a certain candidate set Method cleans candidates if they are no longer available for scheduling (it means job was already dispatched).
bool GetPendingJob (const TNSBitVector &unwanted_jobs, unsigned *job_id)
 Get any pending job, but it should NOT be in the unwanted list Presumed, that unwanted jobs are speculatively assigned to other worker nodes or postponed.
void PendingIntersect (TNSBitVector *candidate_set)
 Logical AND of candidates and pending jobs (candidate_set &= pending_set).
void SwitchJobs (unsigned count, TJobStatus old_status, TJobStatus new_status, TNSBitVector &jobs, const TNSBitVector *unwanted_jobs=NULL)
 Group switch up to 'count' jobs, not including ones from 'unwanted_jobs', from old_status to new_status.
void GetAliveJobs (TNSBitVector &ids)
 Logical AND with statuses ORed cleans up a list from non-existing jobs.
bool AnyPending () const
 TRUE if we have pending jobs.
unsigned GetFirstDone () const
 Get first job id from DONE status.
unsigned GetFirst (TJobStatus status) const
 Get first job in the specified status.
unsigned GetNext (TJobStatus status, unsigned job_id) const
 Get next job in the specified status, or first if job_id is 0.
void SetStatus (unsigned job_id, TJobStatus status)
void Erase (unsigned job_id)
void SetExactStatusNoLock (unsigned job_id, TJobStatus status, bool set_clear)
 Set job status without any protection.
unsigned CountStatus (TJobStatus status) const
 Return number of jobs in specified status.
void CountStatus (TStatusSummaryMap *status_map, const TNSBitVector *candidate_set)
 Count all status vectors using candidate_set(optional) as a mask (AND_COUNT).
unsigned Count (void)
 Count all jobs in any status.
void StatusStatistics (TJobStatus status, TNSBitVector::statistics *st) const
void StatusSnapshot (TJobStatus status, TNSBitVector *bv) const
 Specified status is OR-ed with the target vector.
void ClearAll (TNSBitVector *bv=0)
 Clear status storage.
void OptimizeMem ()
 Optimize bitvectors memory.
void PrintStatusMatrix (CNcbiOstream &out) const

Static Public Member Functions

static bool IsCancelCode (TJobStatus status)

Protected Member Functions

TJobStatus x_GetStatusNoLock (unsigned job_id) const
TJobStatus IsStatusNoLock (unsigned job_id, TJobStatus st1, TJobStatus st2=CNetScheduleAPI::eJobNotFound, TJobStatus st3=CNetScheduleAPI::eJobNotFound) const
 Check if job is in specified status.
void ReportInvalidStatus (unsigned job_id, TJobStatus status, TJobStatus old_status)
void x_SetClearStatusNoLock (unsigned job_id, TJobStatus status, TJobStatus old_status)
void IncDoneJobs ()

Private Member Functions

 CJobStatusTracker (const CJobStatusTracker &)
CJobStatusTrackeroperator= (const CJobStatusTracker &)

Private Attributes

TStatusStorage m_StatusStor
CRWLock m_Lock
TNSBitVector m_UsedIds
bm::id_t m_LastPending
 Last pending id.
unsigned m_DoneCnt
 Done jobs counter.

Friends

class CNetSchedule_JSGroupGuard


Member Typedef Documentation

typedef vector<TNSBitVector*> CJobStatusTracker::TStatusStorage
 

Definition at line 60 of file job_status.hpp.

typedef map<TJobStatus, unsigned> CJobStatusTracker::TStatusSummaryMap
 

Status to number of jobs map.

Definition at line 63 of file job_status.hpp.


Constructor & Destructor Documentation

CJobStatusTracker::CJobStatusTracker  ) 
 

Definition at line 42 of file job_status.cpp.

References bm::BM_GAP, CNetScheduleAPI::eLastStatus, and m_StatusStor.

CJobStatusTracker::~CJobStatusTracker  ) 
 

Definition at line 54 of file job_status.cpp.

References m_StatusStor.

CJobStatusTracker::CJobStatusTracker const CJobStatusTracker  )  [private]
 


Member Function Documentation

void CJobStatusTracker::AddPendingBatch unsigned  job_id_from,
unsigned  job_id_to
 

Add closed interval of ids to pending status.

Definition at line 327 of file job_status.cpp.

References CNetScheduleAPI::ePending, m_Lock, m_StatusStor, and bm::bvector< Alloc, MS >::set_range().

bool CJobStatusTracker::AnyPending  )  const
 

TRUE if we have pending jobs.

Definition at line 459 of file job_status.cpp.

References bm::bvector< Alloc, MS >::any(), CNetScheduleAPI::ePending, m_Lock, and m_StatusStor.

Referenced by CQueue::NotifyListeners(), CQueue::Submit(), and CQueue::SubmitBatch().

TJobStatus CJobStatusTracker::ChangeStatus unsigned  job_id,
TJobStatus  status,
bool updated = NULL
 

Set job status.

(Controls status change logic)

Status switching rules, [] - means request ignored ePending <- eRunning, "no status" eRunning <- ePending, [eCanceled] eCanceled <- ePending, eRunning, [eDone, eFailed (ignored if job is ready)] eFailed <- eRunning, [eCanceled] eDone <- ePending, eRunning, [eCanceled, eFailed], eReading (timeout) eReading <- eDone eConfirmed <- eReading, eDone eReadFailed <- eReading

Parameters:
updated (out) TRUE if database needs to be updated for job_id.
Returns:
old status. Job may be already canceled (or failed) in this case status change is ignored

Definition at line 223 of file job_status.cpp.

References _ASSERT, CNetScheduleAPI::eCanceled, CNetScheduleAPI::eDone, CNetScheduleAPI::eFailed, CNetScheduleAPI::eJobNotFound, CNetScheduleAPI::ePending, CNetScheduleAPI::eReturned, CNetScheduleAPI::eRunning, IncDoneJobs(), IsCancelCode(), IsStatusNoLock(), m_Lock, ReportInvalidStatus(), SetExactStatusNoLock(), x_GetStatusNoLock(), and x_SetClearStatusNoLock().

Referenced by CNetSchedule_JS_Guard::CNetSchedule_JS_Guard(), and CQueue::x_UpdateDB_GetJobNoLock().

void CJobStatusTracker::ClearAll TNSBitVector bv = 0  ) 
 

Clear status storage.

Parameters:
bv If not NULL all ids from the matrix are OR-ed with this vector (bv is not cleared)

Definition at line 181 of file job_status.cpp.

References m_Lock, and m_StatusStor.

Referenced by CQueue::Clear().

unsigned CJobStatusTracker::Count void   ) 
 

Count all jobs in any status.

Definition at line 112 of file job_status.cpp.

References m_Lock, and m_StatusStor.

Referenced by CQueue::IsExpired().

void CJobStatusTracker::CountStatus TStatusSummaryMap status_map,
const TNSBitVector candidate_set
 

Count all status vectors using candidate_set(optional) as a mask (AND_COUNT).

Definition at line 91 of file job_status.cpp.

References _ASSERT, map_checker< Container >::clear(), bm::count_and(), m_Lock, and m_StatusStor.

unsigned CJobStatusTracker::CountStatus TJobStatus  status  )  const
 

Return number of jobs in specified status.

Definition at line 84 of file job_status.cpp.

References m_Lock, and m_StatusStor.

Referenced by CQueue::CountStatus().

void CJobStatusTracker::Erase unsigned  job_id  ) 
 

Definition at line 175 of file job_status.cpp.

References CNetScheduleAPI::eJobNotFound, and SetStatus().

Referenced by CQueue::CheckJobsExpiry(), and CQueue::EraseJob().

void CJobStatusTracker::GetAliveJobs TNSBitVector ids  ) 
 

Logical AND with statuses ORed cleans up a list from non-existing jobs.

Definition at line 449 of file job_status.cpp.

References m_Lock, and m_StatusStor.

Referenced by CQueue::FilterJobs().

unsigned CJobStatusTracker::GetFirst TJobStatus  status  )  const
 

Get first job in the specified status.

Definition at line 476 of file job_status.cpp.

References bm::bvector< Alloc, MS >::get_first(), m_Lock, and m_StatusStor.

Referenced by GetFirstDone().

unsigned CJobStatusTracker::GetFirstDone  )  const
 

Get first job id from DONE status.

Definition at line 469 of file job_status.cpp.

References CNetScheduleAPI::eDone, and GetFirst().

unsigned CJobStatusTracker::GetNext TJobStatus  status,
unsigned  job_id
const
 

Get next job in the specified status, or first if job_id is 0.

Definition at line 486 of file job_status.cpp.

References bm::bvector< Alloc, MS >::get_next(), m_Lock, and m_StatusStor.

Referenced by CQueue::CheckJobsExpiry().

bool CJobStatusTracker::GetPendingJob const TNSBitVector unwanted_jobs,
unsigned *  job_id
 

Get any pending job, but it should NOT be in the unwanted list Presumed, that unwanted jobs are speculatively assigned to other worker nodes or postponed.

Definition at line 395 of file job_status.cpp.

References bm::bvector< Alloc, MS >::any(), bm::bvector< Alloc, MS >::enumerator, CNetScheduleAPI::ePending, bm::bvector< Alloc, MS >::first(), m_Lock, and m_StatusStor.

Referenced by CQueue::FindPendingJob().

bool CJobStatusTracker::GetPendingJobFromSet TNSBitVector candidate_set,
unsigned *  job_id
 

Get pending job out of a certain candidate set Method cleans candidates if they are no longer available for scheduling (it means job was already dispatched).

Parameters:
job_id OUT job id (moved from pending to running) job_id is taken out of candidates When 0 - means no pending candidates
Returns:
true - if there are any available pending jobs false - queue has no pending jobs whatsoever (not just candidates)

Definition at line 337 of file job_status.cpp.

References bm::bvector< Alloc, MS >::any(), bm::bvector< Alloc, MS >::enumerator, CNetScheduleAPI::ePending, bm::bvector< Alloc, MS >::first(), m_Lock, and m_StatusStor.

TJobStatus CJobStatusTracker::GetStatus unsigned  job_id  )  const
 

Definition at line 64 of file job_status.cpp.

References m_Lock, and x_GetStatusNoLock().

Referenced by CQueue::GetJobStatus().

void CJobStatusTracker::IncDoneJobs  )  [protected]
 

Definition at line 580 of file job_status.cpp.

References CNetScheduleAPI::eDone, CNetScheduleAPI::ePending, m_DoneCnt, m_StatusStor, bm::bvector< Alloc, MS >::opt_free_0, bm::bvector< Alloc, MS >::opt_free_01, and bm::bvector< Alloc, MS >::optimize().

Referenced by ChangeStatus().

static bool CJobStatusTracker::IsCancelCode TJobStatus  status  )  [inline, static]
 

Definition at line 179 of file job_status.hpp.

References CNetScheduleAPI::eCanceled, and CNetScheduleAPI::eFailed.

Referenced by ChangeStatus(), and CQueue::x_UpdateDB_GetJobNoLock().

TJobStatus CJobStatusTracker::IsStatusNoLock unsigned  job_id,
TJobStatus  st1,
TJobStatus  st2 = CNetScheduleAPI::eJobNotFound,
TJobStatus  st3 = CNetScheduleAPI::eJobNotFound
const [protected]
 

Check if job is in specified status.

Returns:
-1 if no, status value otherwise

Definition at line 520 of file job_status.cpp.

References CNetScheduleAPI::eJobNotFound, and m_StatusStor.

Referenced by ChangeStatus().

CJobStatusTracker& CJobStatusTracker::operator= const CJobStatusTracker  )  [private]
 

void CJobStatusTracker::OptimizeMem  ) 
 

Optimize bitvectors memory.

Definition at line 195 of file job_status.cpp.

References m_Lock, m_StatusStor, and bm::bvector< Alloc, MS >::opt_free_0.

Referenced by CQueue::OptimizeMem().

void CJobStatusTracker::PendingIntersect TNSBitVector candidate_set  ) 
 

Logical AND of candidates and pending jobs (candidate_set &= pending_set).

Definition at line 420 of file job_status.cpp.

References CNetScheduleAPI::ePending, m_Lock, and m_StatusStor.

Referenced by CQueue::GetAffinityList(), and CWorkerNodeAffinityGuard::GetJobWithAffinities().

void CJobStatusTracker::PrintStatusMatrix CNcbiOstream out  )  const
 

Definition at line 557 of file job_status.cpp.

References bm::bvector< Alloc, MS >::enumerator, CNetScheduleAPI::ePending, bm::bvector< Alloc, MS >::first(), m_Lock, m_StatusStor, and CNetScheduleAPI::StatusToString().

Referenced by CQueue::PrintJobStatusMatrix().

void CJobStatusTracker::ReportInvalidStatus unsigned  job_id,
TJobStatus  status,
TJobStatus  old_status
[protected]
 

Definition at line 506 of file job_status.cpp.

References NCBI_THROW, and CNetScheduleAPI::StatusToString().

Referenced by ChangeStatus().

void CJobStatusTracker::SetExactStatusNoLock unsigned  job_id,
TJobStatus  status,
bool  set_clear
 

Set job status without any protection.

Definition at line 208 of file job_status.cpp.

References CNetScheduleAPI::ePending, m_LastPending, m_StatusStor, and bm::bvector< Alloc, MS >::set().

Referenced by ChangeStatus(), and x_SetClearStatusNoLock().

void CJobStatusTracker::SetStatus unsigned  job_id,
TJobStatus  status
 

Parameters:
status Status to set (all other statuses are cleared) Non existing status code clears all statuses

Definition at line 150 of file job_status.cpp.

References ERR_POST, m_Lock, and m_StatusStor.

Referenced by Erase(), CQueue::ForceReschedule(), CNetSchedule_JS_Guard::SetStatus(), CQueue::Submit(), and CNetSchedule_JS_Guard::~CNetSchedule_JS_Guard().

void CJobStatusTracker::StatusSnapshot TJobStatus  status,
TNSBitVector bv
const
 

Specified status is OR-ed with the target vector.

Definition at line 138 of file job_status.cpp.

References _ASSERT, m_Lock, and m_StatusStor.

Referenced by CQueue::JobsWithStatus().

void CJobStatusTracker::StatusStatistics TJobStatus  status,
TNSBitVector::statistics *  st
const
 

Definition at line 126 of file job_status.cpp.

References _ASSERT, bm::bvector< Alloc, MS >::calc_stat(), m_Lock, and m_StatusStor.

Referenced by CQueue::StatusStatistics().

void CJobStatusTracker::SwitchJobs unsigned  count,
TJobStatus  old_status,
TJobStatus  new_status,
TNSBitVector jobs,
const TNSBitVector unwanted_jobs = NULL
 

Group switch up to 'count' jobs, not including ones from 'unwanted_jobs', from old_status to new_status.

Definition at line 429 of file job_status.cpp.

References bm::bvector< Alloc, MS >::enumerator, bm::bvector< Alloc, MS >::first(), m_Lock, m_StatusStor, and bm::bvector< Alloc, MS >::set().

Referenced by CQueue::ReadJobs().

TJobStatus CJobStatusTracker::x_GetStatusNoLock unsigned  job_id  )  const [protected]
 

Definition at line 72 of file job_status.cpp.

References m_StatusStor.

Referenced by ChangeStatus(), and GetStatus().

void CJobStatusTracker::x_SetClearStatusNoLock unsigned  job_id,
TJobStatus  status,
TJobStatus  old_status
[protected]
 

Definition at line 496 of file job_status.cpp.

References SetExactStatusNoLock().

Referenced by ChangeStatus().


Friends And Related Function Documentation

friend class CNetSchedule_JSGroupGuard [friend]
 

Definition at line 225 of file job_status.hpp.


Member Data Documentation

unsigned CJobStatusTracker::m_DoneCnt [private]
 

Done jobs counter.

Definition at line 233 of file job_status.hpp.

Referenced by IncDoneJobs().

bm::id_t CJobStatusTracker::m_LastPending [private]
 

Last pending id.

Definition at line 231 of file job_status.hpp.

Referenced by SetExactStatusNoLock().

CRWLock CJobStatusTracker::m_Lock [mutable, private]
 

Definition at line 227 of file job_status.hpp.

Referenced by AddPendingBatch(), AnyPending(), ChangeStatus(), ClearAll(), CNetSchedule_JSGroupGuard::CNetSchedule_JSGroupGuard(), Count(), CountStatus(), GetAliveJobs(), GetFirst(), GetNext(), GetPendingJob(), GetPendingJobFromSet(), GetStatus(), OptimizeMem(), PendingIntersect(), PrintStatusMatrix(), SetStatus(), StatusSnapshot(), StatusStatistics(), SwitchJobs(), and CNetSchedule_JSGroupGuard::~CNetSchedule_JSGroupGuard().

TStatusStorage CJobStatusTracker::m_StatusStor [private]
 

Definition at line 226 of file job_status.hpp.

Referenced by AddPendingBatch(), AnyPending(), CJobStatusTracker(), ClearAll(), CNetSchedule_JSGroupGuard::CNetSchedule_JSGroupGuard(), Count(), CountStatus(), GetAliveJobs(), GetFirst(), GetNext(), GetPendingJob(), GetPendingJobFromSet(), IncDoneJobs(), IsStatusNoLock(), OptimizeMem(), PendingIntersect(), PrintStatusMatrix(), SetExactStatusNoLock(), SetStatus(), StatusSnapshot(), StatusStatistics(), SwitchJobs(), x_GetStatusNoLock(), ~CJobStatusTracker(), and CNetSchedule_JSGroupGuard::~CNetSchedule_JSGroupGuard().

TNSBitVector CJobStatusTracker::m_UsedIds [private]
 

Definition at line 228 of file job_status.hpp.


The documentation for this class was generated from the following files:
Generated on Mon Dec 7 12:35:54 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:23:21 2009 by modify_doxy.py rev. 173732