xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdFileCache
XrdFileCachePrefetch.hh
Go to the documentation of this file.
1
#ifndef __XRDFILECACHE_PREFETCH_HH__
2
#define __XRDFILECACHE_PREFETCH_HH__
3
//----------------------------------------------------------------------------------
4
// Copyright (c) 2014 by Board of Trustees of the Leland Stanford, Jr., University
5
// Author: Alja Mrak-Tadel, Matevz Tadel, Brian Bockelman
6
//----------------------------------------------------------------------------------
7
// XRootD is free software: you can redistribute it and/or modify
8
// it under the terms of the GNU Lesser General Public License as published by
9
// the Free Software Foundation, either version 3 of the License, or
10
// (at your option) any later version.
11
//
12
// XRootD is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
16
//
17
// You should have received a copy of the GNU Lesser General Public License
18
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19
//----------------------------------------------------------------------------------
20
21
#include <string>
22
#include <queue>
23
24
#include "
XrdCl/XrdClDefaultEnv.hh
"
25
26
#include "
XrdFileCacheInfo.hh
"
27
#include "
XrdFileCacheStats.hh
"
28
29
class
XrdOucIOVec
;
30
namespace
XrdCl
31
{
32
class
Log;
33
}
34
35
namespace
XrdFileCache
36
{
37
//----------------------------------------------------------------------------
39
//----------------------------------------------------------------------------
40
class
Prefetch
41
{
42
friend
class
IOEntireFile
;
43
friend
class
IOFileBlock
;
44
enum
ReadRamState_t
{
kReadWait
,
kReadSuccess
,
kReadFailed
};
45
46
struct
Task;
47
public
:
48
//------------------------------------------------------------------------
50
//------------------------------------------------------------------------
51
Prefetch
(
XrdOucCacheIO
& inputFile, std::string& path,
52
long
long
offset,
long
long
fileSize);
53
54
//------------------------------------------------------------------------
56
//------------------------------------------------------------------------
57
~Prefetch
();
58
59
//---------------------------------------------------------------------
61
//---------------------------------------------------------------------
62
void
Run
();
63
64
//----------------------------------------------------------------------
66
//----------------------------------------------------------------------
67
Stats
&
GetStats
() {
return
m_stats
; }
68
69
//----------------------------------------------------------------------
71
//----------------------------------------------------------------------
72
void
WriteBlockToDisk
(
int
ramIdx,
size_t
size);
73
74
//----------------------------------------------------------------------
76
//----------------------------------------------------------------------
77
void
DecRamBlockRefCount
(
int
ramIdx);
78
79
//----------------------------------------------------------------------
82
//----------------------------------------------------------------------
83
bool
InitiateClose
();
84
85
protected
:
87
ssize_t
Read
(
char
* buff, off_t offset,
size_t
size);
88
90
int
ReadV
(
const
XrdOucIOVec
*readV,
int
n);
91
93
void
AppendIOStatToFileInfo
();
94
95
private
:
96
//----------------------------------------------------------------------
98
//----------------------------------------------------------------------
99
struct
Task
100
{
101
int
ramBlockIdx
;
102
XrdSysCondVar
*
condVar
;
103
104
Task
():
ramBlockIdx
(-1),
condVar
(0) {}
105
Task
(
int
r,
XrdSysCondVar
*cv):
106
ramBlockIdx
(r),
condVar
(cv) {}
107
~Task
() {}
108
};
109
110
struct
RAMBlock
{
111
int
fileBlockIdx
;
112
int
refCount
;
113
bool
fromRead
;
114
ReadRamState_t
status
;
115
int
readErrno
;
116
117
RAMBlock
():
fileBlockIdx
(-1),
refCount
(0),
fromRead
(false),
status
(
kReadWait
) {}
118
};
119
120
struct
RAM
121
{
122
int
m_numBlocks
;
123
char
*
m_buffer
;
124
RAMBlock
*
m_blockStates
;
125
XrdSysCondVar
m_writeMutex
;
126
127
RAM
();
128
~RAM
();
129
};
130
132
void
CloseCleanly
();
133
135
Task
*
GetNextTask
();
136
138
bool
Open
();
139
141
void
RecordDownloadInfo
();
142
144
XrdCl::Log*
clLog
()
const
{
return
XrdCl::DefaultEnv::GetLog
(); }
145
147
ssize_t
ReadInBlocks
(
char
* buff, off_t offset,
size_t
size);
148
150
Task*
CreateTaskForFirstUndownloadedBlock
();
151
153
bool
ReadFromTask
(
int
bIdx,
char
* buff,
long
long
off,
size_t
size);
154
156
void
DoTask
(Task* task);
157
159
const
char
*
lPath
()
const
;
160
161
RAM
m_ram
;
162
163
XrdOssDF
*
m_output
;
164
XrdOssDF
*
m_infoFile
;
165
Info
m_cfi
;
166
XrdOucCacheIO
&
m_input
;
167
168
std::string
m_temp_filename
;
169
170
long
long
m_offset
;
171
long
long
m_fileSize
;
172
173
bool
m_started
;
174
bool
m_failed
;
175
bool
m_stopping
;
176
bool
m_stopped
;
177
XrdSysCondVar
m_stateCond
;
178
179
XrdSysMutex
m_downloadStatusMutex
;
180
181
std::deque<Task*>
m_tasks_queue
;
182
XrdSysCondVar
m_queueCond
;
183
184
Stats
m_stats
;
185
};
186
}
187
#endif
Generated by
1.8.3.1