MythTV  master
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>

Inheritance diagram for AutoExpire:
Inheritance graph
[legend]
Collaboration diagram for AutoExpire:
Collaboration graph
[legend]

Public Member Functions

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

Static Public Member Functions

static void ClearExpireList (pginfolist_t &expireList, bool deleteProg=true)
 Clears expireList, freeing any ProgramInfo's if necessary. More...
 
static void Update (int encoder, int fsID, bool immediately)
 This is used to update the global AutoExpire instance "expirer". More...
 
static void Update (bool immediately)
 

Public Attributes

QMap< int, EncoderLink * > * m_encoderList {nullptr}
 

Protected Member Functions

void RunExpirer (void)
 This contains the main loop for the auto expire process. More...
 

Private Member Functions

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

Static Private Member Functions

static void SendDeleteMessages (pginfolist_t &deleteList)
 This sends delete message to main event thread. More...
 
static bool IsInExpireList (const pginfolist_t &expireList, uint chanid, const QDateTime &recstartts)
 

Private Attributes

QSet< QString > m_dont_expire_set
 
ExpireThreadm_expire_thread {nullptr}
 
uint m_desired_freq {15}
 
bool m_expire_thread_run {false}
 
QMap< int, int64_t > m_desired_space
 
QMap< int, int > m_used_encoders
 
QMutex m_instance_lock
 
QWaitCondition m_instance_cond
 
MainServerm_main_server {nullptr}
 
QMutex m_update_lock
 
QQueue< UpdateEntrym_update_queue
 

Friends

class ExpireThread
 

Detailed Description

Used to expire recordings to make space for new recordings.

Definition at line 61 of file autoexpire.h.

Constructor & Destructor Documentation

◆ AutoExpire() [1/2]

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

Creates AutoExpire class, starting the thread.

Parameters
tvListEncoderLink list of all recorders

Definition at line 72 of file autoexpire.cpp.

◆ AutoExpire() [2/2]

AutoExpire::AutoExpire ( )
default

◆ ~AutoExpire()

AutoExpire::~AutoExpire ( )

AutoExpire destructor stops auto delete thread if it is running.

Definition at line 84 of file autoexpire.cpp.

Member Function Documentation

◆ CalcParams()

void AutoExpire::CalcParams ( void  )

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

Definition at line 122 of file autoexpire.cpp.

Referenced by RunExpirer(), and Update().

◆ PrintExpireList()

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

Prints a summary of the files that can be deleted.

Definition at line 794 of file autoexpire.cpp.

Referenced by handle_command().

◆ GetDesiredSpace()

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 111 of file autoexpire.cpp.

Referenced by Scheduler::FillRecordingDir().

◆ GetAllExpiring() [1/2]

void AutoExpire::GetAllExpiring ( QStringList &  strList)

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

Definition at line 836 of file autoexpire.cpp.

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

◆ GetAllExpiring() [2/2]

void AutoExpire::GetAllExpiring ( pginfolist_t list)

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

Definition at line 861 of file autoexpire.cpp.

◆ ClearExpireList()

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

◆ Update() [1/2]

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 1041 of file autoexpire.cpp.

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

◆ Update() [2/2]

static void AutoExpire::Update ( bool  immediately)
inlinestatic

Definition at line 81 of file autoexpire.h.

Referenced by Update().

◆ SetMainServer()

void AutoExpire::SetMainServer ( MainServer ms)
inline

Definition at line 83 of file autoexpire.h.

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

◆ RunExpirer()

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 269 of file autoexpire.cpp.

◆ ExpireLiveTV()

void AutoExpire::ExpireLiveTV ( int  type)
private

This expires LiveTV programs.

Definition at line 362 of file autoexpire.cpp.

Referenced by RunExpirer().

◆ ExpireOldDeleted()

void AutoExpire::ExpireOldDeleted ( void  )
private

This expires deleted programs older than DeletedMaxAge.

Definition at line 375 of file autoexpire.cpp.

Referenced by RunExpirer().

◆ ExpireQuickDeleted()

void AutoExpire::ExpireQuickDeleted ( void  )
private

This expires deleted programs within a few minutes.

Definition at line 388 of file autoexpire.cpp.

Referenced by RunExpirer().

◆ ExpireRecordings()

void AutoExpire::ExpireRecordings ( void  )
private

This expires normal recordings.

Definition at line 402 of file autoexpire.cpp.

Referenced by RunExpirer().

◆ ExpireEpisodesOverMax()

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 652 of file autoexpire.cpp.

Referenced by RunExpirer().

◆ FillExpireList()

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 772 of file autoexpire.cpp.

Referenced by ExpireRecordings(), and PrintExpireList().

◆ FillDBOrdered()

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 903 of file autoexpire.cpp.

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

◆ SendDeleteMessages()

void AutoExpire::SendDeleteMessages ( pginfolist_t deleteList)
staticprivate

This sends delete message to main event thread.

Definition at line 615 of file autoexpire.cpp.

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

◆ Sleep()

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 345 of file autoexpire.cpp.

Referenced by RunExpirer().

◆ UpdateDontExpireSet()

void AutoExpire::UpdateDontExpireSet ( void  )
private

Definition at line 1076 of file autoexpire.cpp.

Referenced by GetAllExpiring(), and RunExpirer().

◆ IsInDontExpireSet()

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

Definition at line 1112 of file autoexpire.cpp.

Referenced by ExpireEpisodesOverMax(), and FillDBOrdered().

◆ IsInExpireList()

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

Definition at line 1121 of file autoexpire.cpp.

Referenced by FillDBOrdered().

Friends And Related Function Documentation

◆ ExpireThread

friend class ExpireThread
friend

Definition at line 65 of file autoexpire.h.

Member Data Documentation

◆ m_encoderList

QMap<int, EncoderLink *>* AutoExpire::m_encoderList {nullptr}

Definition at line 89 of file autoexpire.h.

Referenced by CalcParams(), and ExpireRecordings().

◆ m_dont_expire_set

QSet<QString> AutoExpire::m_dont_expire_set
private

Definition at line 112 of file autoexpire.h.

Referenced by IsInDontExpireSet(), and UpdateDontExpireSet().

◆ m_expire_thread

ExpireThread* AutoExpire::m_expire_thread {nullptr}
private

Definition at line 113 of file autoexpire.h.

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

◆ m_desired_freq

uint AutoExpire::m_desired_freq {15}
private

Definition at line 114 of file autoexpire.h.

Referenced by CalcParams(), and RunExpirer().

◆ m_expire_thread_run

bool AutoExpire::m_expire_thread_run {false}
private

Definition at line 115 of file autoexpire.h.

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

◆ m_desired_space

QMap<int, int64_t> AutoExpire::m_desired_space
private

Definition at line 117 of file autoexpire.h.

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

◆ m_used_encoders

QMap<int, int> AutoExpire::m_used_encoders
private

Definition at line 118 of file autoexpire.h.

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

◆ m_instance_lock

QMutex AutoExpire::m_instance_lock
mutableprivate

◆ m_instance_cond

QWaitCondition AutoExpire::m_instance_cond
private

Definition at line 121 of file autoexpire.h.

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

◆ m_main_server

MainServer* AutoExpire::m_main_server {nullptr}
private

Definition at line 123 of file autoexpire.h.

Referenced by CalcParams(), and ExpireRecordings().

◆ m_update_lock

QMutex AutoExpire::m_update_lock
private

Definition at line 126 of file autoexpire.h.

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

◆ m_update_queue

QQueue<UpdateEntry> AutoExpire::m_update_queue
private

Definition at line 127 of file autoexpire.h.

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


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