In file /home/eternity/Source/Eso/Allocator/H/allocator.h:

class Allocator : public Rollbackable, public Debugable, public SixOffspring

Class for allocating space on a disk

Inheritance:

Allocator < Rollbackable

Allocator < Debugable

Allocator < SixOffspring


Public Methods

Err Allocator::AllocSpace (TID tID, Size fileSize)
Allocates space
Err Allocator::AllocTableFind (const TID tID, const Int shouldClose, Size *fileSize, Char **fileName)
Searches allocTable
Err Allocator::AllocTableInsert (const TID tID, const Size fileSize, const Char *fileName)
Insert into allocTable
Err Allocator::AllocValid (TID tID, Size fileSize)
Is allocation valid?
Allocator::Allocator (Eso *anEso, LogFile *allocLogFile)
Constructor
Err Allocator::CreateAllocFile (const Size fileSize, Char **anAllocFileName)
Creates allocation file
TableFieldQueue* Allocator::CreateDefinition ()
Creates definition of allocTable
Err Allocator::FreeSpace (TID tID)
Frees space
Err Allocator::Rollback (TID tID)
Rolls back a transaction
void Allocator::Test ()
Allocator test
Allocator::~Allocator ()
Destructor

Public

methods
Allocator (Eso *anEso, LogFile *allocLogFile)
Constructor.
~Allocator ()
Destructor.
Err AllocSpace (TID tID, Size fileSize)
Tries to allocate space for a specified time
Err AllocValid (TID tID, Size fileSize)
Tests if there is an allocation (identified by tID) with greater or equal size to fileSize
Err FreeSpace (TID tID)
Frees specified allocation space.
virtual Err Rollback (TID tID)
Rollbacks allocation created in tID transaction.
void Test ()
A test function.

Protected

attributes
Table* allocTable
Used to store information about allocated space.
methods
TableFieldQueue* CreateDefinition ()
Creates definition of allocTable - used only in constructor.
Err CreateAllocFile (const Size fileSize, Char **allocFileName)
Creates a dummy place holder file.
Err AllocTableInsert (const TID tID, const Size fileSize, const Char *fileName)
Inserts information about allocated space to allocTable.
Err AllocTableFind (const TID tID, const Int shouldClose = 1, Size *fileSize = NULL, Char **allocFileName = NULL)
Searches allocTable by transaction ID, enables not closing the table after the search

Inherited from Rollbackable:

Public

methods

virtual Err Rollback(TID)
Raoll back and return to a consistent state

Inherited from Debugable:

Public Methods

string* Debugable::CreateString(char *firstStr, int firstInt, int secondInt)
Debugable::Debugable(LogFile * debugLogFile)
int Debugable::SetDebugOptions(int newLogOptions)
void Debugable::SetLogFile(LogFile *aLogFile)
void Debugable::WriteString(LogLevel debugLevel, char * format, ...)
Debugable::~Debugable()

Public

attributes

int debugOptions
What messages should be logged
LogFile* logFile
Log file for debug messages

Inherited from SixOffspring:

Public Methods

SixOffspring::SixOffspring(Six * aSix)

Documentation

Class for allocating space on a disk. This class is responsible for allocating space on the disk, when request to store a file arrives to Eso. It stores all information about allocations in a table with this structure:
(TID: ID, FileSize: Size, FileName: String).
attributes

Table* allocTable
Used to store information about allocated space.

methods

TableFieldQueue* CreateDefinition()
Creates definition of allocTable - used only in constructor.

Err CreateAllocFile(const Size fileSize, Char **allocFileName)
Creates a dummy place holder file.

Err AllocTableInsert(const TID tID, const Size fileSize, const Char *fileName)
Inserts information about allocated space to allocTable.

Err AllocTableFind(const TID tID, const Int shouldClose = 1, Size *fileSize = NULL, Char **allocFileName = NULL)
Searches allocTable by transaction ID, enables not closing the table after the search

methods

Allocator(Eso *anEso, LogFile *allocLogFile)
Constructor.

~Allocator()
Destructor.

Err AllocSpace(TID tID, Size fileSize)
Tries to allocate space for a specified time

Err AllocValid(TID tID, Size fileSize)
Tests if there is an allocation (identified by tID) with greater or equal size to fileSize

Err FreeSpace(TID tID)
Frees specified allocation space.

virtual Err Rollback(TID tID)
Rollbacks allocation created in tID transaction.

void Test()
A test function.

Err Allocator::AllocSpace(TID tID, Size fileSize)
Allocates space. Tries to allocate space for a specified time
Returns:
error code
Parameters:
tID - transaction ID
fileSize - size of allocated file
Author:
Pavel
See Also:
CreateAllocFile(), AllocTableInsert()

Err Allocator::AllocTableFind(const TID tID, const Int shouldClose, Size *fileSize, Char **fileName)
Searches allocTable. Finds first record with tID and returns fileSize and fileName, if desired. "shouldClose" says wether to close allocTable again.
Returns:
error code
Parameters:
tID - transaction ID
shouldClose - tells if the table should be closed after a successfull search
fileSize - size of found file
fileName - name of found file
Author:
Pavel
See Also:
Table

Err Allocator::AllocTableInsert(const TID tID, const Size fileSize, const Char *fileName)
Insert into allocTable. Inserts a record to table of allocations
Returns:
error code
Parameters:
tID - transaction ID
fileSize - size of allocated file
fileName - name of allocated file
Author:
Pavel
See Also:
Table, Record

Err Allocator::AllocValid(TID tID, Size fileSize)
Is allocation valid?. Tests if there is an allocation (identified by tID) with greater or equal size to fileSize, which was not yet timed out.
Returns:
error code
Parameters:
tID - transaction ID
fileSize - checked size of file
Author:
Pavel
See Also:
AllocTableFind

Allocator::Allocator(Eso *anEso, LogFile *allocLogFile)
Constructor. Creates allocation table and links to its parent Eso
Parameters:
anEso - pointer to Eso owning this class
allocLogFile - pointer to log file where Allocator should log its work
Author:
Pavel
See Also:
Eso, Majordomo, SixOffspring, Debugable

Err Allocator::CreateAllocFile(const Size fileSize, Char **anAllocFileName)
Creates allocation file. Creates a dummy file in ALLOC_FILES_PATH directory of given size
Returns:
error code
Parameters:
fileSize - size of file to allocate on disk
anAllocFileName - out parameter that tells the name of newly created allocation file
Author:
Pavel
See Also:
RandomGenerator, CreateTempFileName()

TableFieldQueue* Allocator::CreateDefinition()
Creates definition of allocTable. Creates the definition of allocation table by inserting all needed fields in it.
Returns:
definition of allocation table
Author:
Pavel
See Also:
Table, TableField

Err Allocator::FreeSpace(TID tID)
Frees space. Frees specified allocation space
Returns:
error code
Parameters:
tID - transaction ID
Author:
Pavel
See Also:
AllocTableFind(), Table

Err Allocator::Rollback(TID tID)
Rolls back a transaction. Rollbacks allocation created in tID transaction
Returns:
error code
Parameters:
tID - transaction ID
Author:
Pavel
See Also:
Rollbackable, FreeSpace()

void Allocator::Test()
Allocator test. Test method used only for debugging
Returns:
void
Author:
Pavel

Allocator::~Allocator()
Destructor. Destroyes allocation table
Author:
Pavel
See Also:
Table


This class has no child classes.
Author:
Pavel
See Also:
Eso

alphabetic index hierarchy of classes


generated by doc++