MythTV  0.27pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
AutoExpire Class Reference

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

#include <autoexpire.h>

Collaboration diagram for AutoExpire:
Collaboration graph
[legend]

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 ExpireQuickDeleted (void)
 This expires deleted programs within a few minutes.
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
ExpireThreadexpire_thread
uint desired_freq
bool expire_thread_run
QMap< int, int64_t > desired_space
QMap< int, intused_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 62 of file autoexpire.h.

Constructor & Destructor Documentation

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

Creates AutoExpire class, starting the thread.

Parameters
tvListEncoderLink 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 799 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 841 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 866 of file autoexpire.cpp.

void AutoExpire::ClearExpireList ( pginfolist_t expireList,
bool  deleteProg = true 
)
void AutoExpire::Update ( int  encoder,
int  fsID,
bool  immediately 
)
static

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

Parameters
encoderThis recorder starts a recording now
fsIDfile system ID of the writing directory
immediatelyIf 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 1064 of file autoexpire.cpp.

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

static void AutoExpire::Update ( bool  immediately)
inlinestatic

Definition at line 83 of file autoexpire.h.

Referenced by Update().

void AutoExpire::SetMainServer ( MainServer ms)
inline

Definition at line 85 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 287 of file autoexpire.cpp.

void AutoExpire::RunUpdate ( void  )
protected

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

Parameters
autoExpireInstanceAutoExpire instance on which to call CalcParams.

Definition at line 1040 of file autoexpire.cpp.

void AutoExpire::ExpireLiveTV ( int  type)
private

This expires LiveTV programs.

Definition at line 367 of file autoexpire.cpp.

Referenced by RunExpirer().

void AutoExpire::ExpireOldDeleted ( void  )
private

This expires deleted programs older than DeletedMaxAge.

Definition at line 380 of file autoexpire.cpp.

Referenced by RunExpirer().

void AutoExpire::ExpireQuickDeleted ( void  )
private

This expires deleted programs within a few minutes.

Definition at line 393 of file autoexpire.cpp.

Referenced by RunExpirer().

void AutoExpire::ExpireRecordings ( void  )
private

This expires normal recordings.

Definition at line 407 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 657 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 777 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 908 of file autoexpire.cpp.

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

void AutoExpire::SendDeleteMessages ( pginfolist_t deleteList)
private

This sends delete message to main event thread.

Definition at line 620 of file autoexpire.cpp.

Referenced by ExpireLiveTV(), ExpireOldDeleted(), ExpireQuickDeleted(), 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 350 of file autoexpire.cpp.

Referenced by RunExpirer(), and RunUpdate().

void AutoExpire::UpdateDontExpireSet ( void  )
private

Definition at line 1108 of file autoexpire.cpp.

Referenced by GetAllExpiring(), and RunExpirer().

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

Definition at line 1144 of file autoexpire.cpp.

Referenced by ExpireEpisodesOverMax(), and FillDBOrdered().

bool AutoExpire::IsInExpireList ( const pginfolist_t expireList,
uint  chanid,
const QDateTime &  recstartts 
)
staticprivate

Definition at line 1153 of file autoexpire.cpp.

Referenced by FillDBOrdered().

Friends And Related Function Documentation

friend class ExpireThread
friend

Definition at line 66 of file autoexpire.h.

friend class UpdateThread
friend

Definition at line 67 of file autoexpire.h.

Referenced by Update().

Member Data Documentation

QMap<int, EncoderLink *>* AutoExpire::encoderList

Definition at line 91 of file autoexpire.h.

Referenced by CalcParams(), and ExpireRecordings().

QSet<QString> AutoExpire::dont_expire_set
private

Definition at line 115 of file autoexpire.h.

Referenced by IsInDontExpireSet(), and UpdateDontExpireSet().

ExpireThread* AutoExpire::expire_thread
private

Definition at line 116 of file autoexpire.h.

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

uint AutoExpire::desired_freq
private

Definition at line 117 of file autoexpire.h.

Referenced by CalcParams(), and RunExpirer().

bool AutoExpire::expire_thread_run
private

Definition at line 118 of file autoexpire.h.

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

QMap<int, int64_t> AutoExpire::desired_space
private

Definition at line 120 of file autoexpire.h.

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

QMap<int, int> AutoExpire::used_encoders
private

Definition at line 121 of file autoexpire.h.

Referenced by CalcParams(), and Update().

QMutex AutoExpire::instance_lock
mutableprivate
QWaitCondition AutoExpire::instance_cond
private

Definition at line 124 of file autoexpire.h.

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

MainServer* AutoExpire::main_server
private

Definition at line 126 of file autoexpire.h.

Referenced by CalcParams(), and ExpireRecordings().

bool AutoExpire::update_pending
private

Definition at line 129 of file autoexpire.h.

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

UpdateThread* AutoExpire::update_thread
private

Definition at line 130 of file autoexpire.h.

Referenced by RunUpdate(), and Update().


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