XrdcpXtremeRead.hh

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //                                                                      //
00003 // XrdXtremeRead                                                        //
00004 //                                                                      //
00005 // Author: Fabrizio Furano (CERN, 2009)                                 //
00006 //                                                                      //
00007 // Utility classes handling Extreme readers, i.e. coordinated parallel  //
00008 //  reads from multiple XrdClient instances                             //
00009 //                                                                      //
00010 //////////////////////////////////////////////////////////////////////////
00011 
00012 //         $Id: XrdcpXtremeRead.hh 30949 2009-11-02 16:37:58Z ganis $
00013 
00014 #include "XrdSys/XrdSysPthread.hh"
00015 #include "XrdClient/XrdClient.hh"
00016 #include "XrdClient/XrdClientVector.hh"
00017 
00018 class XrdXtRdBlkInfo {
00019 public:
00020    long long offs;
00021    int len;
00022    time_t lastrequested;
00023 
00024    // Nothing more to do, block acquired
00025    bool done;
00026 
00027    // The seq of the clientidxs which requested this blk
00028    XrdClientVector<int> requests;
00029 
00030    bool AlreadyRequested(int clientIdx) {
00031       for (int i = 0; i < requests.GetSize(); i++)
00032          if (requests[i] == clientIdx) return true;
00033       return false;
00034    }
00035 
00036    XrdXtRdBlkInfo() {offs = 0; len = 0; done = false; requests.Clear(); lastrequested = 0; }
00037 };
00038 
00039 class XrdXtRdFile {
00040 private:
00041    int clientidxcnt;         // counter to assign client idxs
00042    XrdSysRecMutex mtx;       // mutex to protect data structures
00043 
00044    int freeblks;    // Blocks not yet assigned to readers
00045    int nblks;       // Total number of blocks
00046    int doneblks;    // Xferred blocks
00047 
00048    XrdXtRdBlkInfo *blocks;
00049 
00050 public:
00051 
00052    // Models a file as a sequence of blocks, which can be attrbuted to
00053    //  different readers
00054    XrdXtRdFile(int blksize, long long filesize);
00055    ~XrdXtRdFile();
00056 
00057    bool AllDone() { XrdSysMutexHelper m(mtx); return (doneblks >= nblks); }
00058 
00059    // Gives a unique ID which can identify a reader client in the game
00060    int GimmeANewClientIdx();
00061 
00062    int GetNBlks() { return nblks; }
00063 
00064    // Finds a block to prefetch and then read
00065    // Atomically associates it to a client idx
00066    // Returns the blk index
00067    int GetBlkToPrefetch(int fromidx, int clientIdx, XrdXtRdBlkInfo *&blkreadonly);
00068    int GetBlkToRead(int fromidx, int clientidx, XrdXtRdBlkInfo *&blkreadonly);
00069 
00070    void MarkBlkAsRequested(int blkidx);
00071    int MarkBlkAsRead(int blkidx);
00072 
00073    static int GetListOfSources(XrdClient *ref, XrdOucString xtrememgr, XrdClientVector<XrdClient *> &clients);
00074 
00075 
00076 };

Generated on Tue Jul 5 14:46:22 2011 for ROOT_528-00b_version by  doxygen 1.5.1