• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

DistRedundantShare.h

Go to the documentation of this file.
00001 /* 
00002  * File:   DistRedundantShare.h
00003  * Author: fermat
00004  *
00005  * Created on 20. Januar 2010, 17:39
00006  */
00007 
00008 #ifndef _DISTREDUNDANTSHARE_H
00009 #define _DISTREDUNDANTSHARE_H
00010 
00011 #include"RSDisk.h"
00012 #include"Distributor.h"
00013 #include "RSCache.h"
00014 #include<iostream>
00015 #include<fstream>
00016 #include<map>
00017 #include<set>
00018 #include<tr1/unordered_map>
00019 #include<sys/time.h>
00020 
00021 #ifndef USE_P_CACHE
00022 //#define USE_P_CACHE
00023 #endif
00024 
00025 #ifndef USE_R_CACHE
00026 //#define USE_R_CACHE
00027 #endif
00028 
00029 #ifndef USE_R2_CACHE
00030 //#define USE_R2_CACHE
00031 #endif
00032 
00033 namespace VDRIVE {
00034 
00040     class DistRedundantShare : public Distributor {
00041     public:
00042 
00048         DistRedundantShare(xercesc::DOMElement* data);
00049 
00053         DistRedundantShare(int argc, char** argv);
00054 
00058         DistRedundantShare(const DistRedundantShare& orig);
00059 
00063         virtual ~DistRedundantShare();
00064 
00068         virtual std::list<Disk*>* placeExtent(int64_t virtualVolumeId, int64_t position) ;
00069 
00073         virtual void setConfiguration(std::list<Disk*>* disks, int64_t extentsize, int32_t copies);
00074 
00078         virtual void setDisks(std::list<Disk*>* disks);
00079 
00083         virtual xercesc::DOMElement* toXML(xercesc::DOMDocument* doc) const;
00084 
00090         static std::string getXMLRootType() {
00091             return std::string("RedundantShare");
00092         }
00093 
00097         virtual std::list<Disk*>* getDisks() const;
00098 
00102         virtual int64_t getExtentsize() const {
00103             return extentsize;
00104         }
00105 
00109         virtual int32_t getCopies() const {
00110             return copies;
00111         }
00112 
00113         RSDisk** getRSDisks() {
00114             return disks;
00115         }
00116 
00117         int32_t getNumDisks() {
00118             return numDisks;
00119         }
00120 
00121     private:
00122 
00126         int32_t copies;
00127 
00131         int64_t extentsize;
00132 
00136         int64_t capacity;
00137 
00141         bool revertIDOrder;
00142 
00147         RSDisk** disks;
00148 
00152         int32_t numDisks;
00153 
00157         std::ofstream debugfile;
00158 
00162         uint64_t** hashValues;
00163 
00167         uint64_t* errorValues;
00168 
00172         int64_t* errorDisks;
00173 
00177         void initValueCaches();
00178 
00179 #ifdef USE_P_CACHE
00180 
00184         //std::tr1::unordered_map<int32_t,std::tr1::unordered_map<int32_t,std::tr1::unordered_map<int32_t,mpq_class*>*>*>* p_cache;
00185         std::map<int32_t, std::map<int32_t, std::map<int32_t, mpq_class*>*>*>* p_cache;
00186 
00190         mpq_class* getP(int32_t a, int32_t b, int32_t l);
00191 
00196         std::pair<const int32_t, mpq_class*>* getBestP(int32_t a, int32_t b, int32_t l);
00197 
00201         void setP(int32_t a, int32_t b, int32_t l, mpq_class* val);
00202 
00206         void clearP();
00207 #endif
00208 
00209 #ifdef USE_R_CACHE
00210 
00213         RSCache *r_cache;
00214 
00215         void initR() {
00216             r_cache = RSCache::createInstance((int32_t) 4);
00217         }
00218 
00219         mpq_class* getR(int32_t o, int32_t m, int32_t j, int32_t i) {
00220             int32_t* query = new int32_t[4];
00221             query[0] = o;
00222             query[1] = m;
00223             query[2] = j;
00224             query[3] = i;
00225             mpq_class* result = r_cache->getValue(query);
00226             delete[] query;
00227             return result;
00228         }
00229 
00230         void setR(int32_t o, int32_t m, int32_t j, int32_t i, mpq_class& val) {
00231             int32_t* query = new int32_t[4];
00232             query[0] = o;
00233             query[1] = m;
00234             query[2] = j;
00235             query[3] = i;
00236             r_cache->setValue(query, val);
00237             delete[] query;
00238         }
00239 
00240         void clearR() {
00241             delete r_cache;
00242         }
00243 #endif
00244 
00245 #ifdef USE_R2_CACHE
00246 
00249         RSCache *r2_cache;
00250 
00251         void initR2() {
00252             r2_cache = RSCache::createInstance((int32_t) 4);
00253         }
00254 
00255         mpq_class* getR2(int32_t o, int32_t m, int32_t j, int32_t i) {
00256             int32_t* query = new int32_t[4];
00257             query[0] = o;
00258             query[1] = m;
00259             query[2] = j;
00260             query[3] = i;
00261             mpq_class* result = r2_cache->getValue(query);
00262             delete[] query;
00263             return result;
00264         }
00265 
00266         void setR2(int32_t o, int32_t m, int32_t j, int32_t i, mpq_class& val) {
00267             int32_t* query = new int32_t[4];
00268             query[0] = o;
00269             query[1] = m;
00270             query[2] = j;
00271             query[3] = i;
00272             r2_cache->setValue(query, val);
00273             delete[] query;
00274         }
00275 
00276         void clearR2() {
00277             delete r2_cache;
00278         }
00279 #endif
00280 
00284         int32_t placeCopy(int64_t position, int32_t copy, int32_t firstDisk) const;
00285 
00291         uint64_t alignDisks(std::set<RSDisk*, bool (*) (RSDisk*, RSDisk*)>* disks, int32_t copies);
00292 
00302         mpq_class P(int32_t a, int32_t b, int32_t l);
00303 
00307         mpq_class r_inner(int32_t o, int32_t m, int32_t j, int32_t i);
00308 
00318         mpq_class r(int32_t o, int32_t m, int32_t j, int32_t i);
00319 
00323         mpq_class r2_inner(int32_t o, int32_t m, int32_t j, int32_t i);
00324 
00334         mpq_class r2(int32_t o, int32_t m, int32_t j, int32_t i);
00335 
00345         mpq_class ki(int32_t i, int32_t l);
00346 
00352         mpq_class cStar(int32_t i, int32_t l);
00353 
00357         void printConfiguration();
00358 
00362         void clear();
00363 
00364         uint64_t getTimeMS() {
00365             struct timeval before;
00366             gettimeofday(&before, 0);
00367             return (before.tv_sec * 1000 + before.tv_usec / 1000);
00368         }
00369     };
00370 
00380     bool rsDiskCompare(RSDisk* ld, RSDisk* rd);
00381 
00391     bool rsDiskCompareRevertID(RSDisk* ld, RSDisk* rd);
00392 }
00393 #endif  /* _DISTREDUNDANTSHARE_H */
00394 

Generated on Mon Oct 11 2010 13:09:26 for CppDistributors by  doxygen 1.7.2