00001 #ifndef __XRDFILECACHE_IO_FILE_BLOCK_HH__ 00002 #define __XRDFILECACHE_IO_FILE_BLOCK_HH__ 00003 //---------------------------------------------------------------------------------- 00004 // Copyright (c) 2014 by Board of Trustees of the Leland Stanford, Jr., University 00005 // Author: Alja Mrak-Tadel, Matevz Tadel, Brian Bockelman 00006 //---------------------------------------------------------------------------------- 00007 // XRootD is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU Lesser General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // XRootD is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public License 00018 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00019 //---------------------------------------------------------------------------------- 00020 #include <map> 00021 #include <string> 00022 00023 #include "XrdOuc/XrdOucCache2.hh" 00024 #include "XrdSys/XrdSysPthread.hh" 00025 00026 #include "XrdFileCacheIO.hh" 00027 00028 class XrdSysError; 00029 class XrdOssDF; 00030 00031 namespace XrdFileCache 00032 { 00033 //---------------------------------------------------------------------------- 00037 //---------------------------------------------------------------------------- 00038 class IOFileBlock : public IO 00039 { 00040 public: 00041 //------------------------------------------------------------------------ 00043 //------------------------------------------------------------------------ 00044 IOFileBlock(XrdOucCacheIO2 *io, XrdOucCacheStats &stats, Cache &cache); 00045 00046 //------------------------------------------------------------------------ 00048 //------------------------------------------------------------------------ 00049 ~IOFileBlock(); 00050 00051 //--------------------------------------------------------------------- 00055 //--------------------------------------------------------------------- 00056 virtual XrdOucCacheIO *Detach(); 00057 00058 //--------------------------------------------------------------------- 00060 //--------------------------------------------------------------------- 00061 using XrdOucCacheIO2::Read; 00062 00063 virtual int Read(char *Buffer, long long Offset, int Length); 00064 00067 virtual bool ioActive(); 00068 00069 virtual int Fstat(struct stat &sbuff); 00070 00071 virtual long long FSize(); 00072 00073 private: 00074 long long m_blocksize; 00075 std::map<int, File*> m_blocks; 00076 XrdSysMutex m_mutex; 00077 struct stat *m_localStat; 00078 Info m_info; 00079 XrdOssDF* m_infoFile; 00080 00081 void GetBlockSizeFromPath(); 00082 int initLocalStat(); 00083 File* newBlockFile(long long off, int blocksize); 00084 void CloseInfoFile(); 00085 }; 00086 } 00087 00088 #endif