xrootd
XrdcpXtremeRead.hh
Go to the documentation of this file.
1#ifndef XRDCPXTREMEREAD_HH
2#define XRDCPXTREMEREAD_HH
3/******************************************************************************/
4/* */
5/* X r d c p X t r e m e R e a d . h h */
6/* */
7/* Author: Fabrizio Furano (CERN, 2009) */
8/* */
9/* This file is part of the XRootD software suite. */
10/* */
11/* XRootD is free software: you can redistribute it and/or modify it under */
12/* the terms of the GNU Lesser General Public License as published by the */
13/* Free Software Foundation, either version 3 of the License, or (at your */
14/* option) any later version. */
15/* */
16/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19/* License for more details. */
20/* */
21/* You should have received a copy of the GNU Lesser General Public License */
22/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24/* */
25/* The copyright holder's institutional names and contributor's names may not */
26/* be used to endorse or promote products derived from this software without */
27/* specific prior written permission of the institution or contributor. */
28/******************************************************************************/
29
31// //
32// Utility classes handling Extreme readers, i.e. coordinated parallel //
33// reads from multiple XrdClient instances //
34// //
36
40
42public:
43 long long offs;
44 int len;
46
47 // Nothing more to do, block acquired
48 bool done;
49
50 // The seq of the clientidxs which requested this blk
52
53 bool AlreadyRequested(int clientIdx) {
54 for (int i = 0; i < requests.GetSize(); i++)
55 if (requests[i] == clientIdx) return true;
56 return false;
57 }
58
59 XrdXtRdBlkInfo() {offs = 0; len = 0; done = false; requests.Clear(); lastrequested = 0; }
60};
61
63private:
64 int clientidxcnt; // counter to assign client idxs
65 XrdSysRecMutex mtx; // mutex to protect data structures
66
67 int freeblks; // Blocks not yet assigned to readers
68 int nblks; // Total number of blocks
69 int doneblks; // Xferred blocks
70
72
73public:
74
75 // Models a file as a sequence of blocks, which can be attrbuted to
76 // different readers
77 XrdXtRdFile(int blksize, long long filesize);
79
80 bool AllDone() { XrdSysMutexHelper m(mtx); return (doneblks >= nblks); }
81
82 // Gives a unique ID which can identify a reader client in the game
84
85 int GetNBlks() { return nblks; }
86
87 // Finds a block to prefetch and then read
88 // Atomically associates it to a client idx
89 // Returns the blk index
90 int GetBlkToPrefetch(int fromidx, int clientIdx, XrdXtRdBlkInfo *&blkreadonly);
91 int GetBlkToRead(int fromidx, int clientidx, XrdXtRdBlkInfo *&blkreadonly);
92
93 void MarkBlkAsRequested(int blkidx);
94 int MarkBlkAsRead(int blkidx);
95
96 static int GetListOfSources(XrdClient *ref, XrdOucString xtrememgr,
98 int maxSources=12);
99
100
101};
102#endif
int GetSize() const
Definition: XrdClientVector.hh:142
void Clear()
Definition: XrdClientVector.hh:144
Definition: XrdClient.hh:121
Definition: XrdOucString.hh:254
Definition: XrdSysPthread.hh:261
Definition: XrdSysPthread.hh:240
Definition: XrdcpXtremeRead.hh:41
long long offs
Definition: XrdcpXtremeRead.hh:43
bool AlreadyRequested(int clientIdx)
Definition: XrdcpXtremeRead.hh:53
XrdXtRdBlkInfo()
Definition: XrdcpXtremeRead.hh:59
time_t lastrequested
Definition: XrdcpXtremeRead.hh:45
int len
Definition: XrdcpXtremeRead.hh:44
XrdClientVector< int > requests
Definition: XrdcpXtremeRead.hh:51
bool done
Definition: XrdcpXtremeRead.hh:48
Definition: XrdcpXtremeRead.hh:62
XrdSysRecMutex mtx
Definition: XrdcpXtremeRead.hh:65
bool AllDone()
Definition: XrdcpXtremeRead.hh:80
int GimmeANewClientIdx()
int freeblks
Definition: XrdcpXtremeRead.hh:67
int nblks
Definition: XrdcpXtremeRead.hh:68
int GetNBlks()
Definition: XrdcpXtremeRead.hh:85
int GetBlkToPrefetch(int fromidx, int clientIdx, XrdXtRdBlkInfo *&blkreadonly)
int clientidxcnt
Definition: XrdcpXtremeRead.hh:64
XrdXtRdBlkInfo * blocks
Definition: XrdcpXtremeRead.hh:71
static int GetListOfSources(XrdClient *ref, XrdOucString xtrememgr, XrdClientVector< XrdClient * > &clients, int maxSources=12)
int MarkBlkAsRead(int blkidx)
void MarkBlkAsRequested(int blkidx)
int GetBlkToRead(int fromidx, int clientidx, XrdXtRdBlkInfo *&blkreadonly)
XrdXtRdFile(int blksize, long long filesize)
int doneblks
Definition: XrdcpXtremeRead.hh:69