xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdClient
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
37
#include "
XrdSys/XrdSysPthread.hh
"
38
#include "
XrdClient/XrdClient.hh
"
39
#include "
XrdClient/XrdClientVector.hh
"
40
41
class
XrdXtRdBlkInfo
{
42
public
:
43
long
long
offs
;
44
int
len
;
45
time_t
lastrequested
;
46
47
// Nothing more to do, block acquired
48
bool
done
;
49
50
// The seq of the clientidxs which requested this blk
51
XrdClientVector<int>
requests
;
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
62
class
XrdXtRdFile
{
63
private
:
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
71
XrdXtRdBlkInfo
*
blocks
;
72
73
public
:
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);
78
~XrdXtRdFile
();
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
83
int
GimmeANewClientIdx
();
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,
97
XrdClientVector<XrdClient *>
&clients,
98
int
maxSources
=12);
99
100
101
};
102
#endif
Generated by
1.8.3.1