xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdOuc
XrdOucCacheData.hh
Go to the documentation of this file.
1
#ifndef __XRDOUCCACHEDATA_HH__
2
#define __XRDOUCCACHEDATA_HH__
3
/******************************************************************************/
4
/* */
5
/* X r d O u c C a c h e D a t a . h h */
6
/* */
7
/* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University */
8
/* All Rights Reserved */
9
/* Produced by Andrew Hanushevsky for Stanford University under contract */
10
/* DE-AC02-76-SFO0515 with the Department of Energy */
11
/******************************************************************************/
12
13
/* The XrdOucCacheData object defines a remanufactured XrdOucCacheIO object and
14
is used to front a XrdOucCacheIO object with an XrdOucCacheReal object.
15
*/
16
17
#include "
XrdOuc/XrdOucCache.hh
"
18
#include "
XrdOuc/XrdOucCacheReal.hh
"
19
#include "
XrdSys/XrdSysPthread.hh
"
20
#include "
XrdSys/XrdSysXSLock.hh
"
21
22
/******************************************************************************/
23
/* C l a s s X r d O u c C a c h e D a t a */
24
/******************************************************************************/
25
26
class
XrdOucCacheData
:
public
XrdOucCacheIO
27
{
28
public
:
29
30
XrdOucCacheIO
*
Base
() {
return
ioObj
;}
31
32
XrdOucCacheIO
*
Detach
();
33
34
long
long
FSize
() {
return
(
ioObj
?
ioObj
->
FSize
() : 0);}
35
36
const
char
*
Path
() {
return
ioObj
->
Path
();}
37
38
void
Preread
();
39
40
void
Preread
(aprParms &Parms);
41
42
void
Preread
(
long
long
Offs,
int
rLen,
int
Opts
=0);
43
44
int
Read
(
char
*Buffer,
long
long
Offset,
int
Length);
45
46
static
int
setAPR
(aprParms &Dest, aprParms &Src,
int
pSize);
47
48
int
Sync
() {
return
0;}
// We only support write-through for now
49
50
int
Trunc
(
long
long
Offset);
51
52
int
Write
(
char
*Buffer,
long
long
Offset,
int
Length);
53
54
XrdOucCacheData
(
XrdOucCacheReal
*cP,
XrdOucCacheIO
*ioP,
55
long
long
vn,
int
opts
);
56
57
private
:
58
~XrdOucCacheData
() {}
59
void
QueuePR
(
long
long
SegOffs,
int
rLen,
int
prHow,
int
isAuto=0);
60
int
Read
(
XrdOucCacheStats
&Now,
61
char
*Buffer,
long
long
Offs,
int
Length);
62
63
// The following is for read/write support
64
//
65
class
MrSw
66
{
67
public
:
68
inline
void
UnLock
() {
if
(
myLock
) {
myLock
->
UnLock
(
myUsage
);
myLock
= 0;}}
69
70
MrSw
(
XrdSysXSLock
*lP,
XrdSysXS_Type
usage) :
myUsage
(usage)
71
{
if
((
myLock
= lP)) lP->
Lock
(usage);}
72
~MrSw
() {
if
(
myLock
)
myLock
->
UnLock
(
myUsage
);}
73
74
private
:
75
XrdSysXSLock
*
myLock
;
76
XrdSysXS_Type
myUsage
;
77
};
78
79
// The following supports MRSW serialization
80
//
81
XrdSysXSLock
rwLock
;
82
XrdSysXSLock
*
pPLock
;
// 0 if no preread lock required
83
XrdSysXSLock
*
rPLock
;
// 0 if no read lock required
84
XrdSysXSLock
*
wPLock
;
// 0 if no write lock required
85
XrdSysXS_Type
pPLopt
;
86
XrdSysXS_Type
rPLopt
;
87
88
XrdSysMutex
DMutex
;
89
XrdOucCacheReal
*
Cache
;
90
XrdOucCacheIO
*
ioObj
;
91
long
long
VNum
;
92
long
long
SegSize
;
93
long
long
OffMask
;
94
long
long
SegShft
;
95
int
maxCache
;
96
char
isFIS
;
97
char
isRW
;
98
char
isADB
;
99
char
Debug
;
100
101
static
const
int
okRW
= 1;
102
static
const
int
xqRW
= 2;
103
104
// Preread Control Area
105
//
106
XrdOucCacheReal::prTask
prReq
;
107
XrdSysSemaphore
*
prStop
;
108
109
long
long
prNSS
;
// Next Sequential Segment for maxi prereads
110
111
static
const
int
prRRMax
= 5;
112
long
long
prRR
[
prRRMax
];
// Recent reads
113
int
prRRNow
;
// Pointer to next entry to use
114
115
static
const
int
prMax
= 8;
116
static
const
int
prRun
= 1;
// Status in prActive (running)
117
static
const
int
prWait
= 2;
// Status in prActive (waiting)
118
119
static
const
int
prLRU
= 1;
// Status in prOpt (set LRU)
120
static
const
int
prSUSE
= 2;
// Status in prOpt (set Single Use)
121
static
const
int
prSKIP
= 3;
// Status in prOpt (skip entry)
122
123
aprParms
Apr
;
124
long
long
prCalc
;
125
long
long
prBeg
[
prMax
];
126
long
long
prEnd
[
prMax
];
127
int
prNext
;
128
int
prFree
;
129
int
prPerf
;
130
char
prOpt
[
prMax
];
131
char
prOK
;
132
char
prActive
;
133
char
prAuto
;
134
};
135
#endif
Generated by
1.8.1.2