AutoExpire Class Reference

Used to expire recordings to make space for new recordings. More...

#include <autoexpire.h>

List of all members.

Public Member Functions

 AutoExpire (QMap< int, EncoderLink * > *encoderList)
 Creates AutoExpire class, starting the thread.
 AutoExpire (void)
 Creates AutoExpire class.
 ~AutoExpire ()
 AutoExpire destructor stops auto delete thread if it is running.
void CalcParams (void)
 Calculates how much space needs to be cleared, and how often.
void PrintExpireList (QString expHost="ALL")
 Prints a summary of the files that can be deleted.
uint64_t GetDesiredSpace (int fsID) const
 Used by the scheduler to select the next recording dir.
void GetAllExpiring (QStringList &strList)
 Gets the full list of programs that can expire in expiration order.
void GetAllExpiring (pginfolist_t &list)
 Gets the full list of programs that can expire in expiration order.
void ClearExpireList (pginfolist_t &expireList, bool deleteProg=true)
 Clears expireList, freeing any ProgramInfo's if necessary.
void SetMainServer (MainServer *ms)

Static Public Member Functions

static void Update (int encoder, int fsID, bool immediately)
 This is used to update the global AutoExpire instance "expirer".
static void Update (bool immediately)

Public Attributes

QMap< int, EncoderLink * > * encoderList

Protected Member Functions

void RunExpirer (void)
 This contains the main loop for the auto expire process.
void RunUpdate (void)
 This is used by Update(QMap<int, EncoderLink*> *, bool) to run CalcParams(vector<EncoderLink*>).

Private Member Functions

void ExpireLiveTV (int type)
 This expires LiveTV programs.
void ExpireOldDeleted (void)
 This expires deleted programs older than DeletedMaxAge.
void ExpireRecordings (void)
 This expires normal recordings.
void ExpireEpisodesOverMax (void)
 This deletes programs exceeding the maximum number of episodes of that program desired.
void FillExpireList (pginfolist_t &expireList)
 Uses the "AutoExpireMethod" setting in the database to fill the list of files that are deletable.
void FillDBOrdered (pginfolist_t &expireList, int expMethod)
 Creates a list of programs to delete using the database to order list.
void SendDeleteMessages (pginfolist_t &deleteList)
 This sends delete message to main event thread.
void Sleep (int sleepTime)
 Sleeps for sleepTime milliseconds; unless the expire thread is told to quit.
void UpdateDontExpireSet (void)
bool IsInDontExpireSet (uint chanid, const QDateTime &recstartts) const

Static Private Member Functions

static bool IsInExpireList (const pginfolist_t &expireList, uint chanid, const QDateTime &recstartts)

Private Attributes

QSet< QString > dont_expire_set
QSet< QString > deleted_set
ExpireThreadexpire_thread
uint desired_freq
bool expire_thread_run
QMap< int, int64_tdesired_space
QMap< int, int > used_encoders
QMutex instance_lock
QWaitCondition instance_cond
MainServermain_server
bool update_pending
UpdateThreadupdate_thread

Friends

class ExpireThread
class UpdateThread

Detailed Description

Used to expire recordings to make space for new recordings.

Definition at line 61 of file autoexpire.h.


Constructor & Destructor Documentation

AutoExpire::AutoExpire ( QMap< int, EncoderLink * > *  tvList  ) 

Creates AutoExpire class, starting the thread.

Parameters:
tvList EncoderLink list of all recorders

Definition at line 79 of file autoexpire.cpp.

AutoExpire::AutoExpire ( void   ) 

Creates AutoExpire class.

Definition at line 95 of file autoexpire.cpp.

AutoExpire::~AutoExpire (  ) 

AutoExpire destructor stops auto delete thread if it is running.

Definition at line 109 of file autoexpire.cpp.


Member Function Documentation

void AutoExpire::CalcParams ( void   ) 

Calculates how much space needs to be cleared, and how often.

Definition at line 148 of file autoexpire.cpp.

Referenced by RunExpirer(), RunUpdate(), and Update().

void AutoExpire::PrintExpireList ( QString  expHost = "ALL"  ) 

Prints a summary of the files that can be deleted.

Definition at line 779 of file autoexpire.cpp.

Referenced by handle_command().

uint64_t AutoExpire::GetDesiredSpace ( int  fsID  )  const

Used by the scheduler to select the next recording dir.

Returns:
the desired free space for each file system

Definition at line 137 of file autoexpire.cpp.

Referenced by Scheduler::FillRecordingDir().

void AutoExpire::GetAllExpiring ( QStringList &  strList  ) 

Gets the full list of programs that can expire in expiration order.

Definition at line 821 of file autoexpire.cpp.

Referenced by Scheduler::FillRecordingDir(), Dvr::GetExpiringList(), and MainServer::HandleGetExpiringRecordings().

void AutoExpire::GetAllExpiring ( pginfolist_t list  ) 

Gets the full list of programs that can expire in expiration order.

Definition at line 846 of file autoexpire.cpp.

void AutoExpire::ClearExpireList ( pginfolist_t expireList,
bool  deleteProg = true 
)

Clears expireList, freeing any ProgramInfo's if necessary.

Definition at line 869 of file autoexpire.cpp.

Referenced by ExpireLiveTV(), ExpireOldDeleted(), ExpireRecordings(), FillExpireList(), Scheduler::FillRecordingDir(), GetAllExpiring(), and PrintExpireList().

void AutoExpire::Update ( int  encoder,
int  fsID,
bool  immediately 
) [static]

This is used to update the global AutoExpire instance "expirer".

Parameters:
encoder This recorder starts a recording now
fsID file system ID of the writing directory
immediately If true CalcParams() is called directly. If false, a thread is spawned to call CalcParams(), this is for use in the MainServer event thread where calling CalcParams() directly would deadlock the event thread.

Definition at line 1038 of file autoexpire.cpp.

Referenced by MainServer::autoexpireUpdate(), Scheduler::GetNextLiveTVDir(), Scheduler::HandleRecording(), and MainServer::MainServer().

static void AutoExpire::Update ( bool  immediately  )  [inline, static]

Definition at line 82 of file autoexpire.h.

Referenced by Update().

void AutoExpire::SetMainServer ( MainServer ms  )  [inline]

Definition at line 84 of file autoexpire.h.

Referenced by MainServer::MainServer(), and MainServer::Stop().

void AutoExpire::RunExpirer ( void   )  [protected]

This contains the main loop for the auto expire process.

Responsible for cleanup of old LiveTV programs as well as deleting as many recordings that are expirable as necessary to maintain enough free space on all directories in MythTV Storage Groups. The thread deletes short LiveTV programs every 2 minutes and long LiveTV and regular programs as needed every "desired_freq" minutes.

Definition at line 286 of file autoexpire.cpp.

void AutoExpire::RunUpdate ( void   )  [protected]

This is used by Update(QMap<int, EncoderLink*> *, bool) to run CalcParams(vector<EncoderLink*>).

Parameters:
autoExpireInstance AutoExpire instance on which to call CalcParams.

Definition at line 1014 of file autoexpire.cpp.

void AutoExpire::ExpireLiveTV ( int  type  )  [private]

This expires LiveTV programs.

Definition at line 363 of file autoexpire.cpp.

Referenced by RunExpirer().

void AutoExpire::ExpireOldDeleted ( void   )  [private]

This expires deleted programs older than DeletedMaxAge.

Definition at line 376 of file autoexpire.cpp.

Referenced by RunExpirer().

void AutoExpire::ExpireRecordings ( void   )  [private]

This expires normal recordings.

Definition at line 390 of file autoexpire.cpp.

Referenced by RunExpirer().

void AutoExpire::ExpireEpisodesOverMax ( void   )  [private]

This deletes programs exceeding the maximum number of episodes of that program desired.

Excludes recordings in the LiveTV Recording Group.

Definition at line 642 of file autoexpire.cpp.

Referenced by RunExpirer().

void AutoExpire::FillExpireList ( pginfolist_t expireList  )  [private]

Uses the "AutoExpireMethod" setting in the database to fill the list of files that are deletable.

Definition at line 757 of file autoexpire.cpp.

Referenced by ExpireRecordings(), and PrintExpireList().

void AutoExpire::FillDBOrdered ( pginfolist_t expireList,
int  expMethod 
) [private]

Creates a list of programs to delete using the database to order list.

Definition at line 888 of file autoexpire.cpp.

Referenced by ExpireLiveTV(), ExpireOldDeleted(), FillExpireList(), and GetAllExpiring().

void AutoExpire::SendDeleteMessages ( pginfolist_t deleteList  )  [private]

This sends delete message to main event thread.

Definition at line 603 of file autoexpire.cpp.

Referenced by ExpireLiveTV(), ExpireOldDeleted(), and ExpireRecordings().

void AutoExpire::Sleep ( int  sleepTime  )  [private]

Sleeps for sleepTime milliseconds; unless the expire thread is told to quit.

Must be called with instance_lock held.

Note:
Will release instance_lock!

Definition at line 346 of file autoexpire.cpp.

Referenced by RunExpirer(), and RunUpdate().

void AutoExpire::UpdateDontExpireSet ( void   )  [private]

Definition at line 1082 of file autoexpire.cpp.

Referenced by GetAllExpiring(), and RunExpirer().

bool AutoExpire::IsInDontExpireSet ( uint  chanid,
const QDateTime &  recstartts 
) const [private]

Definition at line 1118 of file autoexpire.cpp.

Referenced by ExpireEpisodesOverMax(), and FillDBOrdered().

bool AutoExpire::IsInExpireList ( const pginfolist_t expireList,
uint  chanid,
const QDateTime &  recstartts 
) [static, private]

Definition at line 1127 of file autoexpire.cpp.

Referenced by FillDBOrdered().


Friends And Related Function Documentation

friend class ExpireThread [friend]

Definition at line 65 of file autoexpire.h.

friend class UpdateThread [friend]

Definition at line 66 of file autoexpire.h.

Referenced by Update().


Member Data Documentation

Definition at line 90 of file autoexpire.h.

Referenced by CalcParams(), and ExpireRecordings().

QSet<QString> AutoExpire::dont_expire_set [private]

Definition at line 113 of file autoexpire.h.

Referenced by IsInDontExpireSet(), and UpdateDontExpireSet().

QSet<QString> AutoExpire::deleted_set [private]

Definition at line 114 of file autoexpire.h.

Referenced by SendDeleteMessages(), and UpdateDontExpireSet().

Definition at line 115 of file autoexpire.h.

Referenced by AutoExpire(), and ~AutoExpire().

Definition at line 116 of file autoexpire.h.

Referenced by CalcParams(), and RunExpirer().

Definition at line 117 of file autoexpire.h.

Referenced by RunExpirer(), Sleep(), and ~AutoExpire().

QMap<int, int64_t> AutoExpire::desired_space [private]

Definition at line 119 of file autoexpire.h.

Referenced by CalcParams(), ExpireRecordings(), and GetDesiredSpace().

QMap<int, int> AutoExpire::used_encoders [private]

Definition at line 120 of file autoexpire.h.

Referenced by CalcParams(), and Update().

QMutex AutoExpire::instance_lock [mutable, private]
QWaitCondition AutoExpire::instance_cond [private]

Definition at line 123 of file autoexpire.h.

Referenced by RunUpdate(), Sleep(), Update(), and ~AutoExpire().

Definition at line 125 of file autoexpire.h.

Referenced by CalcParams(), ExpireRecordings(), and SetMainServer().

Definition at line 128 of file autoexpire.h.

Referenced by RunUpdate(), Update(), and ~AutoExpire().

Definition at line 129 of file autoexpire.h.

Referenced by RunUpdate(), and Update().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Generated on Fri Feb 10 06:41:48 2012 for MythTV by  doxygen 1.6.3