XrdFileCacheFactory.hh

Go to the documentation of this file.
00001 #ifndef __XRDFILECACHE_FACTORY_HH__
00002 #define __XRDFILECACHE_FACTORY_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 
00021 #include <string>
00022 #include <vector>
00023 #include <map>
00024 
00025 #include "XrdSys/XrdSysPthread.hh"
00026 #include "XrdOuc/XrdOucCache.hh"
00027 
00028 #include "XrdCl/XrdClDefaultEnv.hh"
00029 #include "XrdVersion.hh"
00030 #include "XrdFileCacheDecision.hh"
00031 
00032 class XrdOucStream;
00033 class XrdSysError;
00034 
00035 namespace XrdCl
00036 {
00037    class Log;
00038 }
00039 
00040 namespace XrdFileCache
00041 {
00042    //----------------------------------------------------------------------------
00044    //----------------------------------------------------------------------------
00045    struct Configuration
00046    {
00047       Configuration() :
00048          m_hdfsmode(false),
00049          m_diskUsageLWM(-1),
00050          m_diskUsageHWM(-1),
00051          m_bufferSize(1024*1024),
00052          m_NRamBuffersRead(8),
00053          m_NRamBuffersPrefetch(1),
00054          m_hdfsbsize(128*1024*1024) {}
00055 
00056       bool m_hdfsmode;      
00057       std::string m_cache_dir;        
00058       std::string m_username;         
00059 
00060       long long m_diskUsageLWM;       
00061       long long m_diskUsageHWM;       
00062 
00063       long long m_bufferSize;         
00064       int  m_NRamBuffersRead;         
00065       int  m_NRamBuffersPrefetch;     
00066       long long m_hdfsbsize;          
00067    };
00068 
00069 
00070    //----------------------------------------------------------------------------
00072    //----------------------------------------------------------------------------
00073    class Factory : public XrdOucCache
00074    {
00075       public:
00076          //--------------------------------------------------------------------------
00078          //--------------------------------------------------------------------------
00079          Factory();
00080 
00081          //---------------------------------------------------------------------
00084          //---------------------------------------------------------------------
00085          virtual XrdOucCacheIO *Attach(XrdOucCacheIO *, int Options=0) { return NULL; }
00086 
00087          //---------------------------------------------------------------------
00090          //---------------------------------------------------------------------
00091          virtual int isAttached() { return false; }
00092 
00093          //---------------------------------------------------------------------
00095          //---------------------------------------------------------------------
00096          virtual XrdOucCache* Create(Parms &, XrdOucCacheIO::aprParms *aprP);
00097 
00098          XrdOss* GetOss() const { return m_output_fs; }
00099 
00100          //---------------------------------------------------------------------
00102          //---------------------------------------------------------------------
00103           XrdSysError& GetSysError() { return m_log; }
00104 
00105          //--------------------------------------------------------------------
00111          //--------------------------------------------------------------------
00112          bool Decide(XrdOucCacheIO*);
00113 
00114          //------------------------------------------------------------------------
00116          //------------------------------------------------------------------------
00117          const Configuration& RefConfiguration() const { return m_configuration; }
00118 
00119 
00120          //---------------------------------------------------------------------
00128          //---------------------------------------------------------------------
00129          bool Config(XrdSysLogger *logger, const char *config_filename, const char *parameters);
00130 
00131          //---------------------------------------------------------------------
00133          //---------------------------------------------------------------------
00134          static Factory &GetInstance();
00135 
00136          //---------------------------------------------------------------------
00138          //---------------------------------------------------------------------
00139          static bool VCheck(XrdVersionInfo &urVersion) { return true; }
00140 
00141          //---------------------------------------------------------------------
00143          //---------------------------------------------------------------------
00144          void CacheDirCleanup();
00145 
00146       private:
00147          bool ConfigParameters(std::string, XrdOucStream&);
00148          bool ConfigXeq(char *, XrdOucStream &);
00149          bool xdlib(XrdOucStream &);
00150 
00151          XrdCl::Log* clLog() const { return XrdCl::DefaultEnv::GetLog(); }
00152 
00153          static Factory   *m_factory;   
00154 
00155          XrdSysError       m_log;       
00156          XrdOucCacheStats  m_stats;     
00157          XrdOss           *m_output_fs; 
00158 
00159          std::vector<XrdFileCache::Decision*> m_decisionpoints; 
00160 
00161          std::map<std::string, long long> m_filesInQueue;
00162 
00163          Configuration     m_configuration; 
00164    };
00165 }
00166 
00167 #endif

Generated on 5 Oct 2016 for xrootd by  doxygen 1.4.7