00001 #ifndef __XRDFILECACHE_FACTORY_HH__
00002 #define __XRDFILECACHE_FACTORY_HH__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <string>
00022 #include <vector>
00023 #include <map>
00024
00025 #include "XrdSys/XrdSysPthread.hh"
00026 #include "XrdOuc/XrdOucCache.hh"
00027 #include "XrdCl/XrdClDefaultEnv.hh"
00028 #include "XrdVersion.hh"
00029
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_prefetchFileBlocks(false),
00049 m_cache_dir("/var/tmp/xrootd-file-cache"),
00050 m_username("nobody"),
00051 m_lwm(0.95),
00052 m_hwm(0.9),
00053 m_bufferSize(1024*1024),
00054 m_NRamBuffersRead(8),
00055 m_NRamBuffersPrefetch(1),
00056 m_blockSize(128*1024*1024) {}
00057
00058 bool m_prefetchFileBlocks;
00059 std::string m_cache_dir;
00060 std::string m_username;
00061 std::string m_osslib_name;
00062
00063 float m_lwm;
00064 float m_hwm;
00065
00066 long long m_bufferSize;
00067 int m_NRamBuffersRead;
00068 int m_NRamBuffersPrefetch;
00069 long long m_blockSize;
00070 };
00071
00072
00073
00075
00076 class Factory : public XrdOucCache
00077 {
00078 public:
00079
00081
00082 Factory();
00083
00084
00087
00088 virtual XrdOucCacheIO *Attach(XrdOucCacheIO *, int Options=0) { return NULL; }
00089
00090
00093
00094 virtual int isAttached() { return false; }
00095
00096
00098
00099 virtual XrdOucCache* Create(Parms &, XrdOucCacheIO::aprParms *aprP);
00100
00101 XrdOss* GetOss() const { return m_output_fs; }
00102
00103
00105
00106 XrdSysError& GetSysError() { return m_log; }
00107
00108
00114
00115 bool Decide(XrdOucCacheIO*);
00116
00117
00119
00120 const Configuration& RefConfiguration() const { return m_configuration; }
00121
00122
00123
00131
00132 bool Config(XrdSysLogger *logger, const char *config_filename, const char *parameters);
00133
00134
00136
00137 static Factory &GetInstance();
00138
00139
00141
00142 static bool VCheck(XrdVersionInfo &urVersion) { return true; }
00143
00144
00146
00147 void CacheDirCleanup();
00148
00149 private:
00150 bool CheckFileForDiskSpace(const char* path, long long fsize);
00151 void UnCheckFileForDiskSpace(const char* path);
00152
00153 bool ConfigParameters(const char *);
00154 bool ConfigXeq(char *, XrdOucStream &);
00155 bool xolib(XrdOucStream &);
00156 bool xdlib(XrdOucStream &);
00157
00158 XrdCl::Log* clLog() const { return XrdCl::DefaultEnv::GetLog(); }
00159
00160 static Factory *m_factory;
00161
00162 XrdSysError m_log;
00163 XrdOucCacheStats m_stats;
00164 XrdOss *m_output_fs;
00165
00166 std::vector<XrdFileCache::Decision*> m_decisionpoints;
00167
00168 std::map<std::string, long long> m_filesInQueue;
00169
00170 Configuration m_configuration;
00171 };
00172 }
00173
00174 #endif