xrootd
XrdPfcIOFileBlock.hh
Go to the documentation of this file.
1 #ifndef __XRDPFC_IO_FILE_BLOCK_HH__
2 #define __XRDPFC_IO_FILE_BLOCK_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 #include <map>
21 #include <string>
22 
23 #include "XrdOuc/XrdOucCache.hh"
24 #include "XrdSys/XrdSysPthread.hh"
25 
26 #include "XrdPfcIO.hh"
27 
28 class XrdSysError;
29 class XrdOssDF;
30 
31 namespace XrdPfc
32 {
33 //----------------------------------------------------------------------------
37 //----------------------------------------------------------------------------
38 class IOFileBlock : public IO
39 {
40 public:
41  IOFileBlock(XrdOucCacheIO *io, Cache &cache);
42 
43  ~IOFileBlock();
44 
47  bool ioActive() /* override */;
48 
51  void DetachFinalize() /* override */;
52 
53  //---------------------------------------------------------------------
55  //---------------------------------------------------------------------
56  using XrdOucCacheIO::Read;
57 
58  virtual int Read(char *Buffer, long long Offset, int Length);
59 
60  virtual int Fstat(struct stat &sbuff);
61 
62  virtual long long FSize();
63 
64  virtual void Update(XrdOucCacheIO &iocp);
65 
66 private:
67  long long m_blocksize;
68  std::map<int, File*> m_blocks;
70  struct stat *m_localStat;
73 
74  void GetBlockSizeFromPath();
75  int initLocalStat();
76  File* newBlockFile(long long off, int blocksize);
77  void CloseInfoFile();
78 };
79 }
80 
81 #endif
long long m_blocksize
size of file-block
Definition: XrdPfcIOFileBlock.hh:67
Base cache-io class that implements XrdOucCacheIO abstract methods.
Definition: XrdPfcIO.hh:16
XrdOssDF * m_info_file
Definition: XrdPfcIOFileBlock.hh:72
Definition: XrdOucCache.hh:104
Attaches/creates and detaches/deletes cache-io objects for disk based cache.
Definition: XrdPfc.hh:263
Status of cached file. Can be read from and written into a binary file.
Definition: XrdPfcInfo.hh:44
XrdSysMutex m_mutex
map mutex
Definition: XrdPfcIOFileBlock.hh:69
struct stat * m_localStat
Definition: XrdPfcIOFileBlock.hh:70
Downloads original file into multiple files, chunked into blocks. Only blocks that are asked for are ...
Definition: XrdPfcIOFileBlock.hh:38
Definition: XrdSysError.hh:89
Definition: XrdPfc.hh:40
Definition: XrdSysPthread.hh:165
IOFileBlock(XrdOucCacheIO *io, Cache &cache)
virtual void Update(XrdOucCacheIO &iocp)
Info m_info
Definition: XrdPfcIOFileBlock.hh:71
#define stat(a, b)
Definition: XrdPosix.hh:96
void DetachFinalize()
Abstract virtual method of XrdPfcIO Called to destruct the IO object after it is no longer used...
std::map< int, File * > m_blocks
map of created blocks
Definition: XrdPfcIOFileBlock.hh:68
Definition: XrdPfcFile.hh:140
Definition: XrdOss.hh:62
virtual int Read(char *buff, long long offs, int rlen)=0
virtual int Fstat(struct stat &sbuff)
virtual long long FSize()
File * newBlockFile(long long off, int blocksize)
virtual int Read(char *Buffer, long long Offset, int Length)
bool ioActive()
Abstract virtual method of XrdPfcIO Called to check if destruction needs to be done in a separate tas...