Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _DISTSHARE_H
00009 #define _DISTSHARE_H
00010
00011 #include"Distributor.h"
00012 #include "DistNearestNeighbour.h"
00013 #include<set>
00014 #include<gmpxx.h>
00015 #include"DistNearestNeighbour.h"
00016 #include "ImprovedMap.h"
00017
00018 namespace VDRIVE {
00019
00026 class DistShare : public Distributor {
00027 public:
00028
00034 DistShare(xercesc::DOMElement* data);
00035
00039 DistShare(int argc, char** argv);
00040
00046 DistShare(const DistShare& orig);
00047
00051 virtual ~DistShare();
00052
00056 virtual std::list<Disk*>* placeExtent(int64_t virtualVolumeId, int64_t position) ;
00057
00063 virtual void setConfiguration(std::list<Disk*>* disks, int64_t extentsize, int32_t copies);
00064
00068 virtual void setDisks(std::list<Disk*>* disks);
00069
00073 virtual xercesc::DOMElement* toXML(xercesc::DOMDocument* doc) const;
00074
00078 virtual std::list<Disk*>* getDisks() const;
00079
00083 virtual int64_t getExtentsize() const {
00084 return extentsize;
00085 }
00086
00093 virtual void setBaseMessage(uint8_t* baseMessage);
00094
00100 virtual int32_t getCopies() const {
00101 return copies;
00102 }
00103
00109 static std::string getXMLRootType() {
00110 return std::string("Share");
00111 }
00112
00119 void __runInitThread(uint32_t threadID);
00120
00121 private:
00122
00123 struct NNInitWorkPackage {
00124 std::list<Disk*> *disks;
00125 VDRIVE_DNN_MULT *multi;
00126 uint64_t pos;
00127 };
00128
00129 std::list<NNInitWorkPackage*>* workPackages;
00130
00131 pthread_rwlock_t* workPackageLock;
00132
00133 pthread_rwlock_t* workPackageResultLock;
00134
00138 int32_t copies;
00139
00143 int32_t extentsize;
00144
00148 std::list<Disk*>* disks;
00149
00153 std::tr1::unordered_map<uint64_t, DistNearestNeighbour*>* distributors;
00154
00158 uint64_t systemCapacity;
00159
00163 ImprovedMap *keyFinder;
00164
00169 uint32_t stretchFactorConst;
00170
00175 uint32_t staticStretchFactor;
00176
00180 bool staticNNCopies;
00181
00185 int32_t nnCopies;
00186
00190 int32_t nnCopiesFactor;
00191
00196 int32_t shareCopies;
00197
00202 bool copiesByNN;
00203
00209 virtual int32_t getShareCopies(const std::list<Disk*>* disks);
00210
00221 virtual double getStretchFactor(const std::list<Disk*>* disks);
00222
00232 uint64_t hashFunction(Disk* disk, int64_t iteration) const;
00233
00246 uint64_t hashFunction(int64_t virtualVolumeId, int64_t blockposition, int64_t index) const;
00247
00261 uint64_t hashFunctionNN(int64_t virtualVolumeId, int64_t blockposition, int64_t index) const;
00262 };
00263
00264 }
00265 #endif
00266