xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdClient
XrdcpXtremeRead.hh
Go to the documentation of this file.
1
2
// //
3
// XrdXtremeRead //
4
// //
5
// Author: Fabrizio Furano (CERN, 2009) //
6
// //
7
// Utility classes handling Extreme readers, i.e. coordinated parallel //
8
// reads from multiple XrdClient instances //
9
// //
11
12
#include "
XrdSys/XrdSysPthread.hh
"
13
#include "
XrdClient/XrdClient.hh
"
14
#include "
XrdClient/XrdClientVector.hh
"
15
16
class
XrdXtRdBlkInfo
{
17
public
:
18
long
long
offs
;
19
int
len
;
20
time_t
lastrequested
;
21
22
// Nothing more to do, block acquired
23
bool
done
;
24
25
// The seq of the clientidxs which requested this blk
26
XrdClientVector<int>
requests
;
27
28
bool
AlreadyRequested
(
int
clientIdx) {
29
for
(
int
i = 0; i <
requests
.
GetSize
(); i++)
30
if
(
requests
[i] == clientIdx)
return
true
;
31
return
false
;
32
}
33
34
XrdXtRdBlkInfo
() {
offs
= 0;
len
= 0;
done
=
false
;
requests
.
Clear
();
lastrequested
= 0; }
35
};
36
37
class
XrdXtRdFile
{
38
private
:
39
int
clientidxcnt
;
// counter to assign client idxs
40
XrdSysRecMutex
mtx
;
// mutex to protect data structures
41
42
int
freeblks
;
// Blocks not yet assigned to readers
43
int
nblks
;
// Total number of blocks
44
int
doneblks
;
// Xferred blocks
45
46
XrdXtRdBlkInfo
*
blocks
;
47
48
public
:
49
50
// Models a file as a sequence of blocks, which can be attrbuted to
51
// different readers
52
XrdXtRdFile
(
int
blksize,
long
long
filesize);
53
~XrdXtRdFile
();
54
55
bool
AllDone
() {
XrdSysMutexHelper
m(
mtx
);
return
(
doneblks
>=
nblks
); }
56
57
// Gives a unique ID which can identify a reader client in the game
58
int
GimmeANewClientIdx
();
59
60
int
GetNBlks
() {
return
nblks
; }
61
62
// Finds a block to prefetch and then read
63
// Atomically associates it to a client idx
64
// Returns the blk index
65
int
GetBlkToPrefetch
(
int
fromidx,
int
clientIdx,
XrdXtRdBlkInfo
*&blkreadonly);
66
int
GetBlkToRead
(
int
fromidx,
int
clientidx,
XrdXtRdBlkInfo
*&blkreadonly);
67
68
void
MarkBlkAsRequested
(
int
blkidx);
69
int
MarkBlkAsRead
(
int
blkidx);
70
71
static
int
GetListOfSources
(
XrdClient
*ref,
XrdOucString
xtrememgr,
72
XrdClientVector<XrdClient *>
&clients,
73
int
maxSources
=12);
74
75
76
};
Generated by
1.8.1.2