treqs::Queue Class Reference

The queue class represents a queue of files to be read sequentially. More...

#include <Queue.h>

List of all members.

Public Member Functions

 Queue ()
 Default constructor.
 Queue (std::string tape, unsigned short int pvrid)
 Constructor that associates a tape and a pvr with the Queue.
 ~Queue ()
 Destructor.
time_t getCreationTime ()
 Getter for creationTime member.
unsigned int getCurrentPosition () const
 Getter for currentPosition member.
time_t getEndTime ()
 Getter for endTime member.
time_t getSuspensionTime ()
 Getter for suspensionTime member.
ReadinggetNextReading ()
 Getter for the first Reading with FS_SUBMITTED state.
std::string getOwnerName () const
 Getter for Owner.
unsigned short int getPVR () const
 Getter for pvr member.
QueueStatus getStatus ()
 Getter for Status member.
time_t getSubmissionTime ()
 Getter for SubmissionTime member.
unsigned short int getSuspendDuration ()
 Getter for suspend duration in seconds.
void setCreationTime (time_t t)
 Setter for CreationTime member.
void setCurrentPosition (unsigned int currentPosition)
 Setter for CurrentPosition member.
void setEndTime (time_t t)
 Setter for EndTime member.
void setPVR (unsigned short int p)
 Setter for pvr member.
void setStatus (QueueStatus qs)
 Setter for queue status member.
void setSubmissionTime (time_t t)
 Setter for SubmissionTime member.
void setSuspendDuration (unsigned short int d)
 Setter for suspend duration in seconds.
void activate ()
 Activating the queue means that the staging process can be started.
void dump ()
 Dumps the content of the queue in the logs.
void initCreationTime ()
 Assigns the current time to the queue as Creation Time.
void prepareCleanup ()
 Tells the related Reading objects to unregister themselves.
bool registerFile (FilePositionOnTape *fpot, unsigned short int r) throw (Error)
 Add a file in the queue.
void suspendQueue ()
 Tells the queue to suspend for time seconds.
void unsuspend ()
 Remove the suspended status from the queue.

Private Member Functions

void countJobs ()
 Count the readObjects making difference between done and failed jobs.
void finalize ()
 Sets the queue in a final state if appropriate.
void setOwnerName ()
 Compute the owner of the queue.

Private Attributes

unsigned long long int byteSize
 The size of the queue as the sum of the file's sizes.
time_t creationTime
 The creation time of this queue.
unsigned int currentPosition
 The position of the file being read.
time_t endTime
 The time when the queue finish.
std::map< unsigned short int,
Reading
filesList
 The list of files to read <position, Reading of file>.
unsigned long id
 Unique Id of this queue given by the database.
unsigned short int nbDone
 The number of files successfully staged.
unsigned short int nbFailed
 The number of file requests failed.
std::string ownerName
 The owner of the queue. When there is no owner, it is an empty string.
unsigned short int pvr
 The PVR of this queue.
unsigned short int maxReadRetries
 Maximal retries when reading.
QueueStatus status
 The status of this queue.
time_t submissionTime
 The time when the queue is activated.
time_t suspensionTime
 The time when the queue is can be reactivated after a suspension.
unsigned short int suspendDuration
 The duration in seconds of a suspension.

Static Private Attributes

static LoggerPtr logger
 Logger log4cxx.

Detailed Description

The queue class represents a queue of files to be read sequentially.

A queue can be considered as a sequential read of files in a tape, without rewinding the tape.

A queue represents a tape mounted in a drive with the head in a given position.

A file can be added to an existing queue under the following conditions, depending on the current queue status:

The valid states and their transitions for a queue are:

After a temporarily suspended queue is activated, there could be two queues in created state (The one that has been activated, and another one containing files before the current position.) Both queues have to be merged by QueuesController. The created one, will receive all the files from the suspended one. And the suspended one will pass to QS_ENDED state.

When a queue is created it does not have any file, so the FileList is empty and at this time there is not owner for the queue.

The owner of the queue is the user owning the most reading objects. If there are several users with the same quantity of reading objects, the last one will be selected.

The creation time is when the queue has been created (the first demand of a file contained in the associated tape.) Then, when the queue is chosen by the Activator, the queue writes the submission time. Eventually, the queue could be temporarily suspended, and then the suspension time is written. After that, the queue can pass to created state if there are not another queue in that state, but the creation time is still the same as before. If there is another queue in created state, the files of both queues will be merged; the one which is in created state will hold all the files, and the other, which will be empty, will be change to QS_ENDED state. When a queue has processed all its files, it will write the end time.


Constructor & Destructor Documentation

treqs::Queue::Queue (  ) 

Default constructor.

Here is the call graph for this function:

treqs::Queue::Queue ( std::string  tape,
unsigned short int  pvrid 
)

Constructor that associates a tape and a pvr with the Queue.

This constructor also registers the instance in the database and sets the Id of the queue.

Parameters:
tape the name of the tape for this queue
pvrid the PVR Id.

Here is the call graph for this function:

treqs::Queue::~Queue (  ) 

Destructor.


Member Function Documentation

void treqs::Queue::activate (  ) 

Activating the queue means that the staging process can be started.

The list has to be sorted according to the files' position.

It resets the counters of the queue.

Here is the call graph for this function:

Here is the caller graph for this function:

void treqs::Queue::countJobs (  )  [private]

Count the readObjects making difference between done and failed jobs.

Updates NbDone and NbFailed.

Here is the caller graph for this function:

void treqs::Queue::dump (  ) 

Dumps the content of the queue in the logs.

This is used for Debug purposes.

Here is the caller graph for this function:

void treqs::Queue::finalize (  )  [private]

Sets the queue in a final state if appropriate.

Here is the call graph for this function:

Here is the caller graph for this function:

time_t treqs::Queue::getCreationTime (  ) 

Getter for creationTime member.

Here is the caller graph for this function:

unsigned int treqs::Queue::getCurrentPosition (  )  const

Getter for currentPosition member.

time_t treqs::Queue::getEndTime (  ) 

Getter for endTime member.

treqs::Reading * treqs::Queue::getNextReading (  ) 

Getter for the first Reading with FS_SUBMITTED state.

If there are files that have not been queued, it will return the next one to process. If all files have been queued, it will return NULL; that means the queue is still in activated state, but at least one file is being read.

This function also updates the CurrentPosition.

Returns:
a pointer to the Reading instance, NULL if none is found.

Here is the call graph for this function:

Here is the caller graph for this function:

std::string treqs::Queue::getOwnerName (  )  const

Getter for Owner.

If the queue has been created and it still does not have any file, there is not an associated owned. When there is not owner, it returns an empty String.

Here is the caller graph for this function:

unsigned short int treqs::Queue::getPVR (  )  const

Getter for pvr member.

treqs::QueueStatus treqs::Queue::getStatus (  ) 

Getter for Status member.

Here is the caller graph for this function:

time_t treqs::Queue::getSubmissionTime (  ) 

Getter for SubmissionTime member.

unsigned short int treqs::Queue::getSuspendDuration (  ) 

Getter for suspend duration in seconds.

time_t treqs::Queue::getSuspensionTime (  ) 

Getter for suspensionTime member.

void treqs::Queue::initCreationTime (  ) 

Assigns the current time to the queue as Creation Time.

Here is the call graph for this function:

void treqs::Queue::prepareCleanup (  ) 

Tells the related Reading objects to unregister themselves.

Before destroying a queue, the QueuesController will call this method.

bool treqs::Queue::registerFile ( treqs::FilePositionOnTape fpot,
unsigned short int  r 
) throw (Error)

Add a file in the queue.

The new reading object is created by this function. The reading status is FS_QUEUED.

Each time this method is called, the Queue owner is recalculated. This is done by counting the files for each owner and then selecting the biggest one.

Parameters:
fpot the metadata of the file.
r the number of tries.
Returns:
true if insertion was successful. False if the object existed already.

Here is the call graph for this function:

void treqs::Queue::setCreationTime ( time_t  t  ) 

Setter for CreationTime member.

Here is the caller graph for this function:

void treqs::Queue::setCurrentPosition ( unsigned int  currentPosition  ) 

Setter for CurrentPosition member.

The new position cannot be before the old position (old < new.)

void treqs::Queue::setEndTime ( time_t  t  ) 

Setter for EndTime member.

void treqs::Queue::setOwnerName (  )  [private]

Compute the owner of the queue.

The owner with more files in this queue. This selects the first users with more files in the queue, or the user that owns more than 50% of the files.

void treqs::Queue::setPVR ( unsigned short int  p  ) 

Setter for pvr member.

void treqs::Queue::setStatus ( QueueStatus  qs  ) 

Setter for queue status member.

void treqs::Queue::setSubmissionTime ( time_t  t  ) 

Setter for SubmissionTime member.

void treqs::Queue::setSuspendDuration ( unsigned short int  d  ) 

Setter for suspend duration in seconds.

Default is 600. This is controlled by the [MAIN]:QUEUE_SUSPEND_TIME parameter.

Parameters:
d Duration of the suspension.

Here is the caller graph for this function:

void treqs::Queue::suspendQueue (  ) 

Tells the queue to suspend for time seconds.

This will do as if the queue is ended. Sets the status to QS_TEMPORARILY_SUSPENDED, and writes this new status through DAO. The Activator will ignore such queues and reschedule them when the suspension time is over.

Here is the call graph for this function:

Here is the caller graph for this function:

void treqs::Queue::unsuspend (  ) 

Remove the suspended status from the queue.

Puts the queue in QS_CREATED state if there are not other queue for the same tape in created state. If there is another, it is responsibility of the QueuesController to merge both queues and change the suspended one to ended state.

Here is the call graph for this function:


Member Data Documentation

unsigned long long int treqs::Queue::byteSize [private]

The size of the queue as the sum of the file's sizes.

time_t treqs::Queue::creationTime [private]

The creation time of this queue.

unsigned int treqs::Queue::currentPosition [private]

The position of the file being read.

time_t treqs::Queue::endTime [private]

The time when the queue finish.

If the queue is in QS_TEMPORARILY_SUSPENDED state, suspensionTime is used as the end of the suspension. The Activator will un-suspend the queue when the time's up.

std::map<unsigned short int, Reading> treqs::Queue::filesList [private]

The list of files to read <position, Reading of file>.

unsigned long treqs::Queue::id [private]

Unique Id of this queue given by the database.

LoggerPtr treqs::Queue::logger [static, private]

Logger log4cxx.

unsigned short int treqs::Queue::maxReadRetries [private]

Maximal retries when reading.

unsigned short int treqs::Queue::nbDone [private]

The number of files successfully staged.

unsigned short int treqs::Queue::nbFailed [private]

The number of file requests failed.

std::string treqs::Queue::ownerName [private]

The owner of the queue. When there is no owner, it is an empty string.

unsigned short int treqs::Queue::pvr [private]

The PVR of this queue.

The status of this queue.

time_t treqs::Queue::submissionTime [private]

The time when the queue is activated.

unsigned short int treqs::Queue::suspendDuration [private]

The duration in seconds of a suspension.

time_t treqs::Queue::suspensionTime [private]

The time when the queue is can be reactivated after a suspension.


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

Generated on 4 Mar 2010 for TReqS by  doxygen 1.6.1