GridComputing
Job Management in Grid Computing
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
IMachine< Container > Class Template Reference

Generic IMachine class. More...

#include <machine.h>

Inheritance diagram for IMachine< Container >:
ISave IUpdate IPrint _Machine

Public Types

typedef std::set< Job
*, IdLess< Job > > 
JobSet
 

Public Member Functions

 IMachine (uint id)
 "Search Constructor"
 
 IMachine (const std::string &machineName, uint maxJobs, double totalRAM, double totalDiskSpace)
 Constructor.
 
 ~IMachine ()
 Destructor.
 
const std::string & GetName () const
 Returns the name of the Machine.
 
void SetName (const std::string &name)
 Updates the name of the Machine.
 
uint GetMaxJobs () const
 Returns the number limit of Jobs.
 
void SetMaxJobs (uint val)
 Updates the number limit of Jobs.
 
double GetAvailableRAM () const
 Calculates the RAM that is not being used (MB)
 
double GetInUseRAM () const
 Calculates the RAM that is being used (MB)
 
double GetTotalRAM () const
 Returns the total amount of RAM (MB)
 
void SetTotalRAM (double val)
 Updates the total amount of RAM (MB)
 
double GetAvailableDiskSpace () const
 Calculated the disk space that is not being used (MB)
 
double GetInUseDiskSpace () const
 Calculated the disk space that is being used (MB)
 
double GetTotalDiskSpace () const
 Returns the total amount of disk space (MB)
 
void SetTotalDiskSpace (double val)
 Updates the total amount of disk space (MB)
 
uint GetId () const
 Returns the identifier of this Machine.
 
void SetId (uint id)
 Updates the identifier of this Machine.
 
void AddAvailableSoftware (const Software &sw)
 Adds a Software to the list of available Software.
 
void RemoveAvailableSoftware (const Software &sw)
 Deletes a Software from the list of available Software.
 
const SoftwareSetGetAvailableSoftware () const
 Returns the SoftwareSet of this Machine.
 
JobVector GetJobs () const
 Returns a Vector of constant Jobs.
 
bool AddJob (Job *job)
 Adds a Job to this Machine. Fails if Job requirements are not supported by this Machine.
 
const JobGetJob (uint id) const
 
bool RemoveJob (uint id)
 
void RemoveAllJobs ()
 Removes all Jobs from this Machine.
 
bool ChangeJobPriority (uint id, uint8 newPriority)
 Changes job with the given id priority.
 
uint GetNumberOfCurrentJobs () const
 Returns the number of Jobs being executed.
 
bool Save (ByteBuffer &bb) const override
 Saves the Machine data to a ByteBuffer.
 
void Update (uint diff) override
 Updates executing Jobs timers and removes expired ones.
 
void Print (std::ostream &os=std::cout) const override
 Prints current machine information.
 

Static Public Member Functions

static void PrintHeader (std::ostream &os=std::cout)
 Prints table header for machines.
 
static MenuGetMenu ()
 Returns the menu associated with Machine.
 
static IMachine< Container > * Load (ByteBuffer &bb)
 Loads a Machine from the given ByteBuffer.
 
- Static Public Member Functions inherited from _Machine
static uint GetLastJobId ()
 
static void SetLastJobId (uint val)
 

Protected Member Functions

bool SoftwareMeetsRequirements (const Software &sw) const
 Returns true if the given Software is available in the Machine.
 
- Protected Member Functions inherited from _Machine
 _Machine ()
 

Protected Attributes

double _totalRAM
 Total RAM (MB)
 
double _inUseRAM
 
double _totalDiskSpace
 Total disk space (MB)
 
double _inUseDiskSpace
 
uint _maxJobs
 Max number of Jobs that can be executed.
 
SoftwareSet _availableSoftware
 The available set of Software.
 
std::string _name
 Machine name.
 
uint _id
 Machine identifier.
 
std::mutex _mutex
 Mutex (multithread safe way to change Jobs)
 
Container _currentJobs
 

Static Protected Attributes

static Menu_menu = Loader<Menu>("machineMenu.txt").Load()
 Menu associated with the Machine class.
 
static uint _maxNameLength = 0
 The length of the biggest Machine name.
 
- Static Protected Attributes inherited from _Machine
static uint _lastJobId = 1
 The Id of the last job used.
 

Private Member Functions

 IMachine (const IMachine &)
 
IMachineoperator= (IMachine const &)
 

Detailed Description

template<class Container>
class IMachine< Container >

Generic IMachine class.

This class is templated on the Container so we can have different containers for the Job* of our Machines. It is derivated of the _Machine class so the ids of the jobs are sequetential and unique in all aplication.

Member Typedef Documentation

template<class Container>
typedef std::set<Job*, IdLess<Job> > IMachine< Container >::JobSet

Constructor & Destructor Documentation

template<class Container>
IMachine< Container >::IMachine ( uint  id)

"Search Constructor"

template<class Container>
IMachine< Container >::IMachine ( const std::string &  machineName,
uint  maxJobs,
double  totalRAM,
double  totalDiskSpace 
)

Constructor.

template<class Container>
IMachine< Container >::~IMachine ( )

Destructor.

template<class Container>
IMachine< Container >::IMachine ( const IMachine< Container > &  )
private

Member Function Documentation

template<class Container>
void IMachine< Container >::AddAvailableSoftware ( const Software sw)

Adds a Software to the list of available Software.

template<class Container >
bool IMachine< Container >::AddJob ( Job job)

Adds a Job to this Machine. Fails if Job requirements are not supported by this Machine.

template<class Container >
bool IMachine< Container >::ChangeJobPriority ( uint  id,
uint8  newPriority 
)

Changes job with the given id priority.

template<class Container>
double IMachine< Container >::GetAvailableDiskSpace ( ) const

Calculated the disk space that is not being used (MB)

template<class Container>
double IMachine< Container >::GetAvailableRAM ( ) const

Calculates the RAM that is not being used (MB)

template<class Container>
const SoftwareSet& IMachine< Container >::GetAvailableSoftware ( ) const

Returns the SoftwareSet of this Machine.

template<class Container>
uint IMachine< Container >::GetId ( ) const

Returns the identifier of this Machine.

template<class Container>
double IMachine< Container >::GetInUseDiskSpace ( ) const

Calculated the disk space that is being used (MB)

template<class Container>
double IMachine< Container >::GetInUseRAM ( ) const

Calculates the RAM that is being used (MB)

template<class Container >
const Job * IMachine< Container >::GetJob ( uint  id) const
template<class Container >
JobVector IMachine< Container >::GetJobs ( ) const

Returns a Vector of constant Jobs.

template<class Container>
uint IMachine< Container >::GetMaxJobs ( ) const

Returns the number limit of Jobs.

template<class Container>
static Menu* IMachine< Container >::GetMenu ( )
static

Returns the menu associated with Machine.

template<class Container>
const std::string& IMachine< Container >::GetName ( ) const

Returns the name of the Machine.

template<class Container>
uint IMachine< Container >::GetNumberOfCurrentJobs ( ) const

Returns the number of Jobs being executed.

template<class Container>
double IMachine< Container >::GetTotalDiskSpace ( ) const

Returns the total amount of disk space (MB)

template<class Container>
double IMachine< Container >::GetTotalRAM ( ) const

Returns the total amount of RAM (MB)

template<class Container >
IMachine< Container > * IMachine< Container >::Load ( ByteBuffer bb)
static

Loads a Machine from the given ByteBuffer.

template<class Container>
IMachine& IMachine< Container >::operator= ( IMachine< Container > const &  )
private
template<class Container >
void IMachine< Container >::Print ( std::ostream &  os = std::cout) const
overridevirtual

Prints current machine information.

Implements IPrint.

template<class Container >
void IMachine< Container >::PrintHeader ( std::ostream &  os = std::cout)
static

Prints table header for machines.

template<class Container >
void IMachine< Container >::RemoveAllJobs ( )

Removes all Jobs from this Machine.

template<class Container>
void IMachine< Container >::RemoveAvailableSoftware ( const Software sw)

Deletes a Software from the list of available Software.

template<class Container >
bool IMachine< Container >::RemoveJob ( uint  id)
template<class Container >
bool IMachine< Container >::Save ( ByteBuffer bb) const
overridevirtual

Saves the Machine data to a ByteBuffer.

Implements ISave.

template<class Container>
void IMachine< Container >::SetId ( uint  id)

Updates the identifier of this Machine.

template<class Container >
void IMachine< Container >::SetMaxJobs ( uint  val)

Updates the number limit of Jobs.

template<class Container >
void IMachine< Container >::SetName ( const std::string &  name)

Updates the name of the Machine.

template<class Container >
void IMachine< Container >::SetTotalDiskSpace ( double  val)

Updates the total amount of disk space (MB)

Parameters
valUpdates the total amount of disk space (MB)
template<class Container >
void IMachine< Container >::SetTotalRAM ( double  val)

Updates the total amount of RAM (MB)

Parameters
valUpdates the total amount of RAM (MB)
template<class Container>
bool IMachine< Container >::SoftwareMeetsRequirements ( const Software sw) const
protected

Returns true if the given Software is available in the Machine.

template<class Container >
void IMachine< Container >::Update ( uint  diff)
overridevirtual

Updates executing Jobs timers and removes expired ones.

Implements IUpdate.

Member Data Documentation

template<class Container>
SoftwareSet IMachine< Container >::_availableSoftware
protected

The available set of Software.

template<class Container>
Container IMachine< Container >::_currentJobs
protected
template<class Container>
uint IMachine< Container >::_id
protected

Machine identifier.

template<class Container>
double IMachine< Container >::_inUseDiskSpace
protected
template<class Container>
double IMachine< Container >::_inUseRAM
protected
template<class Container>
uint IMachine< Container >::_maxJobs
protected

Max number of Jobs that can be executed.

template<class Container>
uint IMachine< Container >::_maxNameLength = 0
staticprotected

The length of the biggest Machine name.

template<class Container>
Menu * IMachine< Container >::_menu = Loader<Menu>("machineMenu.txt").Load()
staticprotected

Menu associated with the Machine class.

template<class Container>
std::mutex IMachine< Container >::_mutex
mutableprotected

Mutex (multithread safe way to change Jobs)

template<class Container>
std::string IMachine< Container >::_name
protected

Machine name.

template<class Container>
double IMachine< Container >::_totalDiskSpace
protected

Total disk space (MB)

template<class Container>
double IMachine< Container >::_totalRAM
protected

Total RAM (MB)


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