Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions

VDRIVE::Distributor Class Reference

#include <Distributor.h>

Inheritance diagram for VDRIVE::Distributor:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual ~Distributor ()
virtual std::list< Disk * > * placeExtent (int64_t virtualVolumeId, int64_t position)=0
virtual void setConfiguration (std::list< Disk * > *disks, int64_t extentsize, int32_t copies)=0
virtual void setClusters (std::list< std::list< Disk * > * > *clusters, std::list< uint32_t > *weights)
virtual void setDisks (std::list< Disk * > *disks)=0
virtual uint8_t * getBaseMessage () const
virtual void setBaseMessage (uint8_t *baseMessage)
uint64_t myMTRand (std::string *data) const
uint64_t myRand (std::string *data) const
uint64_t myLC (std::string *data) const
uint64_t mySHA1 (std::string *data) const
uint64_t gcrypt (std::string *data) const
double hashFunction (std::string *data) const
uint64_t hashFunctionInt64 (std::string *data) const
virtual std::list< Disk * > * getDisks () const =0
virtual int64_t getExtentsize () const =0
virtual int32_t getCopies () const =0
virtual xercesc::DOMElement * toXML (xercesc::DOMDocument *doc) const =0
void save (std::string filename) const
uint16_t getNumThreads () const
void setNumThreads (uint16_t numThreads)
void useInternalHashAlgorithm (int algorithm)
bool useGCryptHashAlgorithm (int algorithm)
void usedHashAlgorithm (bool *internal, int *gcryptalgorithm, int *intalgorithm) const

Static Public Member Functions

static DistributorcreateDistributor (int32_t distributor, int argc, char **argv)
static DistributorloadDistributor (std::string filename)

Public Attributes

uint64_t a
uint64_t b

Static Public Attributes

static const int32_t SHARE = 1
static const int32_t NEAREST_NEIGHBOUR = 2
static const int32_t REDUNDANT_SHARE = 3
static const int32_t REDUNDANT_SHARE_K = 4
static const int32_t ROUND_ROBIN = 5
static const int32_t RUSH_P = 6
static const int32_t CRUSH = 7
static const int HASH_SHA1 = 1
static const int HASH_XOR = 2
static const int HASH_RAND = 3
static const int HASH_MT = 4

Protected Member Functions

 Distributor ()

Detailed Description

A Distributor can be used to Distribute Extents of a Virtual Volume over a number of Disks. This abstract class builds the API of all implemented Distribution Algorithms.

Sascha Effert <fermat@uni-paderborn.de>


Constructor & Destructor Documentation

Distributor::~Distributor (  ) [virtual]

Destructor

Distributor::Distributor (  ) [protected]

Creates a new Distributor.


Member Function Documentation

Distributor * Distributor::createDistributor ( int32_t  distributor,
int  argc,
char **  argv 
) [static]

Create a new Distributor of the given kind. Using this factory method a using library has not to know about the implementation classes.

Parameters:
distributorThe kind of distributor
argcnumber of arguments passed to the distributor
argvarguments passed to the distributor
Returns:
A new Distributor object
uint64_t Distributor::gcrypt ( std::string *  data ) const

Creates a Hashvalue using the libgcrypt. The used hash function is specified by gcryptHashAlgorithm.

Parameters:
datamessage to be used as seed
Returns:
a hash values
uint8_t * Distributor::getBaseMessage (  ) const [virtual]

get (a copy of) the BaseMessage used by the Hashfunctions.

Will return a 64-Byte-Array containing a copy of the base-Values used to xor Messages again to create Hashes from. The array belongs to the caller of this method and can be modified and must be deleted by him (using delete[]).

Returns:
a copy of the BaseMessage used by the Hashfunctions.
virtual int32_t VDRIVE::Distributor::getCopies (  ) const [pure virtual]

Get the number of copies of each extents to be placed as passed to setConfiguration.

Returns:
the number of copies of each extents to be placed

Implemented in VDRIVE::DistFastRedundantShare, VDRIVE::DistNearestNeighbour, VDRIVE::DistRedundantShare, VDRIVE::DistRoundRobin, VDRIVE::DistRUSHp, and VDRIVE::DistShare.

virtual std::list<Disk*>* VDRIVE::Distributor::getDisks (  ) const [pure virtual]

Get the Disks used by this object as passed to setDisks or setConfiguration.

The returned list of Disk object as the Disk objects itself belong the caller of this method. A Distributor creates copy of his Disk objects which are send back in this list. Therefore the caller has to delete the list and the Disk objects in the list if it is no more used.

Returns:
The disks used by this object

Implemented in VDRIVE::DistFastRedundantShare, VDRIVE::DistNearestNeighbour, VDRIVE::DistRedundantShare, VDRIVE::DistRoundRobin, VDRIVE::DistRUSHp, and VDRIVE::DistShare.

virtual int64_t VDRIVE::Distributor::getExtentsize (  ) const [pure virtual]

Get the Size of the Extents passed to this object as passed to setConfiguration.

Returns:
the Size of the Extents passed to this object.

Implemented in VDRIVE::DistFastRedundantShare, VDRIVE::DistNearestNeighbour, VDRIVE::DistRedundantShare, VDRIVE::DistRoundRobin, VDRIVE::DistRUSHp, and VDRIVE::DistShare.

uint16_t VDRIVE::Distributor::getNumThreads (  ) const [inline]

get the number of Threads that may be used for Initialization (setDisks)

Returns:
the number of Threads that may be used for Initialization
double Distributor::hashFunction ( std::string *  data ) const

This Hashfunction delivers for a given Text a pseudo randomized value between 0 and 1. We used SHA to calculate this value.

Parameters:
datamessage to be used as seed
Returns:
a hash values
uint64_t Distributor::hashFunctionInt64 ( std::string *  data ) const

This Hashfunction delivers for a given Text a pseudo randomized int64_t value (can be negative).

Parameters:
datamessage to be used as seed
Returns:
a hash value
Distributor * Distributor::loadDistributor ( std::string  filename ) [static]

load a configured Distributor from a file.

Parameters:
filenameThe name of the file containing the distributor
Returns:
the Distributor
uint64_t Distributor::myLC ( std::string *  data ) const

Creates a Hashvalue by using the a linear congruention. Therefore a 64-Bit version of the given message is created which is used as base value. The hash is then computed by

\[h(x) = (a\cdot x + b) mod 2^{64}\]

a and b are initialized in the constructor as a = 10000000000000000051 and b = 13.

Parameters:
datamessage to be used as seed
Returns:
a hash values
uint64_t Distributor::myMTRand ( std::string *  data ) const

Creates a Hashvalue by using the bit shift operation of Mersenne Twister. Therefore a 32-Bit version of the given message is created which is used as seed. The algorithm computes the first two randomized values which mersenne twister would give us and combines them to a 64 bit randomized value.

Parameters:
datamessage to be used as seed
Returns:
a hash values
uint64_t Distributor::myRand ( std::string *  data ) const

Creates a Hashvalue by using the rand-function of stdlib. Therefore a 32-Bit version of the given message is created which is used as seed. The algorithm computes the first two randomized values by using rand() and combines them to a 64 bit randomized value.

Parameters:
datamessage to be used as seed
Returns:
a hash values
uint64_t Distributor::mySHA1 ( std::string *  data ) const

Creates a Hashvalue by using SHA1. Therefore a 64-Byte version of the given message is created which is encrypted by SHA1. The first 8 Byte of the Digest are used as result.

Parameters:
datamessage to be used as seed
Returns:
a hash values
virtual std::list<Disk*>* VDRIVE::Distributor::placeExtent ( int64_t  virtualVolumeId,
int64_t  position 
) [pure virtual]

Compute the Disks to be used to place the Extent at position at the given virtualVolumeID. This method has to be implemented by the subclasses of Distributor.

The returned list of Disk object as the Disk objects itself belong the caller of this method. A Distributor creates copy of his Disk objects which are send back in this list. Therefore the caller has to delete the list and the Disk objects in the list if it is no more used.

Parameters:
virtualVolumeIdA ID referencing the virtual volume the Extent belongs to (therefore several virtual Volumes can use the same disks)
positionThe position of the Extent on the virtual Volume
Returns:
The Disks the Extent has to be placed on. All returned Objects have to be deleted by caller of this method.

Implemented in VDRIVE::DistFastRedundantShare, VDRIVE::DistNearestNeighbour, VDRIVE::DistRedundantShare, VDRIVE::DistRoundRobin, VDRIVE::DistRUSHp, and VDRIVE::DistShare.

void Distributor::save ( std::string  filename ) const

save this (configured) Distributor to a file, so it can be loaded later.

Parameters:
filenameThe name of the file the distributor shall be saved in.
void Distributor::setBaseMessage ( uint8_t *  baseMessage ) [virtual]

Set the new BaseMessage as described at getBaseMessage. This method will create a copy of this message, so the responsibility for deleting stays at the caller of this method.

Parameters:
baseMessageThe new base Message
See also:
getBaseMessage

Reimplemented in VDRIVE::DistFastRedundantShare, and VDRIVE::DistShare.

virtual void VDRIVE::Distributor::setClusters ( std::list< std::list< Disk * > * > *  clusters,
std::list< uint32_t > *  weights 
) [inline, virtual]

Reimplemented in VDRIVE::DistRUSHp.

virtual void VDRIVE::Distributor::setConfiguration ( std::list< Disk * > *  disks,
int64_t  extentsize,
int32_t  copies 
) [pure virtual]

Set the configuration of the Distributor. This method has to be called exacly once on each Object. It initializes the object, so it can be used to place extents. This method has to be implemented by the subclasses of Distributor.

The list of Disks as the Disk objects itself belong the caller of this method. A Distributor creates copy of the Disk objects. Therefore the caller has to delete the list and the Disk objects in the list if it is no more used.

Parameters:
disksA list with the description of the Disks to distribute data over.
extentsizeThe size of each extent placed on the disk in bytes. (This can also be in any other scale, but has to be same for capacity of the Disks)
copiesThe number of Disks used to place eache Extent. If a RAID is used upon the Extents this would be the stripe size.
Returns:
A list with the Disks, that shall be used

Implemented in VDRIVE::DistFastRedundantShare, VDRIVE::DistNearestNeighbour, VDRIVE::DistRedundantShare, VDRIVE::DistRoundRobin, VDRIVE::DistRUSHp, and VDRIVE::DistShare.

virtual void VDRIVE::Distributor::setDisks ( std::list< Disk * > *  disks ) [pure virtual]

Change the Disks used by this Distributor.

The list of Disks as the Disk objects itself belong the caller of this method. A Distributor creates copy of the Disk objects. Therefore the caller has to delete the list and the Disk objects in the list if it is no more used.

Parameters:
disksThe Disks, that now should be used.

Implemented in VDRIVE::DistFastRedundantShare, VDRIVE::DistNearestNeighbour, VDRIVE::DistRedundantShare, VDRIVE::DistRoundRobin, VDRIVE::DistRUSHp, and VDRIVE::DistShare.

void VDRIVE::Distributor::setNumThreads ( uint16_t  numThreads ) [inline]

set the number of Threads that may be used for Initialization (setDisks)

Parameters:
numThreadsthe number of Threads that may be used for Initialization
virtual xercesc::DOMElement* VDRIVE::Distributor::toXML ( xercesc::DOMDocument *  doc ) const [pure virtual]

build an XML-Version of this object

Parameters:
docthe document needed to create new XML Elements
Returns:
a new Element containing the description of this object.

Implemented in VDRIVE::DistFastRedundantShare, VDRIVE::DistNearestNeighbour, VDRIVE::DistRedundantShare, VDRIVE::DistRoundRobin, VDRIVE::DistRUSHp, and VDRIVE::DistShare.

void VDRIVE::Distributor::usedHashAlgorithm ( bool *  internal,
int *  gcryptalgorithm,
int *  intalgorithm 
) const [inline]

get information about used Hashalgorithm.

Parameters:
internaltrue is the internal Hash Algorithm is used, false if a libgcrypt Hash algorithm is used.
algorithmonly set if internal is false. Then it holds the algorithm used by libgrypt to create Hashes.
bool VDRIVE::Distributor::useGCryptHashAlgorithm ( int  algorithm ) [inline]

Use a Hash Algorithm of the lib gcrypt to build hashes.

Parameters:
algorithmthe algorithm to be used. The int represents a hash algorithm which has to exists in the used libgcrypt. For a list of known hash functions have a look at the documentation of your version of libgcrypt.
void VDRIVE::Distributor::useInternalHashAlgorithm ( int  algorithm ) [inline]

use the internal Hash Algorithm to create Hashes (SHA1).


Member Data Documentation

used a factor for creation of own Hash using xor. The Hash is build by result = a * message + b The value had to be set in Constructor to use a real big prime number here...

used a sum for creation of own Hash using xor. The Hash is build by result = a * message + b

const int32_t VDRIVE::Distributor::CRUSH = 7 [static]

This value send to createDistributor creates an implementation of CRUSH

const int VDRIVE::Distributor::HASH_MT = 4 [static]

if we ose an own Hash function (internalHash is true, so no libgcrypt is used) than this value means we use our MT implementation.

const int VDRIVE::Distributor::HASH_RAND = 3 [static]

if we ose an own Hash function (internalHash is true, so no libgcrypt is used) than this value means we use our rand implementation.

const int VDRIVE::Distributor::HASH_SHA1 = 1 [static]

if we ose an own Hash function (internalHash is true, so no libgcrypt is used) than this value means we use our SHA1 implementation.

const int VDRIVE::Distributor::HASH_XOR = 2 [static]

if we ose an own Hash function (internalHash is true, so no libgcrypt is used) than this value means we use our linear congruent implementation.

const int32_t VDRIVE::Distributor::NEAREST_NEIGHBOUR = 2 [static]

This value send to createDistributor creates an implementation of Nearest Neighbour (Consistant Hashing)

const int32_t VDRIVE::Distributor::REDUNDANT_SHARE = 3 [static]

This value send to createDistributor creates an implementation of Redundant Share

const int32_t VDRIVE::Distributor::REDUNDANT_SHARE_K = 4 [static]

This value send to createDistributor creates an implementation of Redundant Share in the O(k) version

const int32_t VDRIVE::Distributor::ROUND_ROBIN = 5 [static]

This value send to createDistributor creates an implementation of Redundant Share

const int32_t VDRIVE::Distributor::RUSH_P = 6 [static]

This value send to createDistributor creates an implementation of RUSHp

const int32_t VDRIVE::Distributor::SHARE = 1 [static]

This value send to createDistributor creates an implementation of Share


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