From a470c23e7c022533bd92cef81b58d55442ac7529 Mon Sep 17 00:00:00 2001 From: Alja Mrak-Tadel Date: Wed, 1 Apr 2015 14:57:19 -0700 Subject: [PATCH] Resolve XrdFileCache::Info dependencied. --- src/XrdFileCache/XrdFileCacheFactory.cc | 2 +- src/XrdFileCache/XrdFileCacheInfo.cc | 21 +++++++-------------- src/XrdFileCache/XrdFileCacheInfo.hh | 4 ++-- src/XrdFileCache/XrdFileCachePrefetch.cc | 8 +++++++- src/XrdFileCache/XrdFileCachePrint.cc | 22 +++++++++++++--------- 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/XrdFileCache/XrdFileCacheFactory.cc b/src/XrdFileCache/XrdFileCacheFactory.cc index 4aa70173a65..b89d2c8c90c 100644 --- a/src/XrdFileCache/XrdFileCacheFactory.cc +++ b/src/XrdFileCache/XrdFileCacheFactory.cc @@ -441,7 +441,7 @@ void FillFileMapRecurse( XrdOssDF* iOssDF, const std::string& path, FPurgeState& if (fname_len > InfoExtLen && strncmp(&buff[fname_len - InfoExtLen ], XrdFileCache::Info::m_infoExtension, InfoExtLen) == 0) { fh->Open((np).c_str(),O_RDONLY, 0600, env); - Info cinfo; + Info cinfo(factory.RefConfiguration().m_bufferSize); time_t accessTime; cinfo.Read(fh); if (cinfo.GetLatestDetachTime(accessTime, fh)) diff --git a/src/XrdFileCache/XrdFileCacheInfo.cc b/src/XrdFileCache/XrdFileCacheInfo.cc index 8b6fdc80243..5b3c88455a6 100644 --- a/src/XrdFileCache/XrdFileCacheInfo.cc +++ b/src/XrdFileCache/XrdFileCacheInfo.cc @@ -29,8 +29,8 @@ #include "XrdCl/XrdClConstants.hh" #include "XrdFileCacheInfo.hh" #include "XrdFileCache.hh" -#include "XrdFileCacheFactory.hh" -#include "XrdFileCacheStats.hh" +//#include "XrdFileCacheFactory.hh" +//#include "XrdFileCacheStats.hh" const char* XrdFileCache::Info::m_infoExtension = ".cinfo"; @@ -39,14 +39,13 @@ const char* XrdFileCache::Info::m_infoExtension = ".cinfo"; using namespace XrdFileCache; -Info::Info() : +Info::Info(long long iBufferSize) : m_version(0), - m_bufferSize(0), + m_bufferSize(iBufferSize), m_sizeInBits(0), m_buff_fetched(0), m_buff_write_called(0), m_accessCnt(0), m_complete(false) { - m_bufferSize = Factory::GetInstance().RefConfiguration().m_bufferSize; } Info::~Info() @@ -125,7 +124,7 @@ void Info::WriteHeader(XrdOssDF* fp) } //______________________________________________________________________________ -void Info::AppendIOStat(const Stats* caches, XrdOssDF* fp) +void Info::AppendIOStat(AStat& as, XrdOssDF* fp) { clLog()->Info(XrdCl::AppMsg, "Info:::AppendIOStat()"); @@ -133,20 +132,14 @@ void Info::AppendIOStat(const Stats* caches, XrdOssDF* fp) if (flr) clLog()->Error(XrdCl::AppMsg, "AppendIOStat() lock failed \n"); m_accessCnt++; - long long off = GetHeaderSize(); off += fp->Write(&m_accessCnt, off, sizeof(int)); off += (m_accessCnt-1)*sizeof(AStat); - AStat as; - as.DetachTime = time(0); - as.BytesDisk = caches->m_BytesDisk; - as.BytesRam = caches->m_BytesRam; - as.BytesMissed = caches->m_BytesMissed; - + + long long ws = fp->Write(&as, off, sizeof(AStat)); flr = XrdOucSxeq::Release(fp->getFD()); if (flr) clLog()->Error(XrdCl::AppMsg, "AppenIOStat() un-lock failed \n"); - long long ws = fp->Write(&as, off, sizeof(AStat)); if ( ws != sizeof(AStat)) { assert(0); } } diff --git a/src/XrdFileCache/XrdFileCacheInfo.hh b/src/XrdFileCache/XrdFileCacheInfo.hh index fe35aed949b..a65bd4eab1c 100644 --- a/src/XrdFileCache/XrdFileCacheInfo.hh +++ b/src/XrdFileCache/XrdFileCacheInfo.hh @@ -59,7 +59,7 @@ namespace XrdFileCache //------------------------------------------------------------------------ //! Constructor. //------------------------------------------------------------------------ - Info(); + Info(long long bufferSize); //------------------------------------------------------------------------ //! Destructor. @@ -103,7 +103,7 @@ namespace XrdFileCache //--------------------------------------------------------------------- //! Append access time, and cache statistics //--------------------------------------------------------------------- - void AppendIOStat(const Stats* stat, XrdOssDF* fp); + void AppendIOStat(AStat& stat, XrdOssDF* fp); //--------------------------------------------------------------------- //! Check download status in given block range diff --git a/src/XrdFileCache/XrdFileCachePrefetch.cc b/src/XrdFileCache/XrdFileCachePrefetch.cc index ad8b4eef191..7a4846245f2 100644 --- a/src/XrdFileCache/XrdFileCachePrefetch.cc +++ b/src/XrdFileCache/XrdFileCachePrefetch.cc @@ -82,6 +82,7 @@ Prefetch::RAM::~RAM() Prefetch::Prefetch(XrdOucCacheIO &inputIO, std::string& disk_file_path, long long iOffset, long long iFileSize) : m_output(NULL), m_infoFile(NULL), + m_cfi(Factory::GetInstance().RefConfiguration().m_bufferSize), m_input(inputIO), m_temp_filename(disk_file_path), m_offset(iOffset), @@ -962,7 +963,12 @@ void Prefetch::AppendIOStatToFileInfo() m_downloadStatusMutex.Lock(); if (m_infoFile) { - m_cfi.AppendIOStat(&m_stats, (XrdOssDF*)m_infoFile); + Info::AStat as; + as.DetachTime = time(0); + as.BytesDisk = m_stats.m_BytesDisk; + as.BytesRam = m_stats.m_BytesRam; + as.BytesMissed = m_stats.m_BytesMissed; + m_cfi.AppendIOStat(as, (XrdOssDF*)m_infoFile); } else { diff --git a/src/XrdFileCache/XrdFileCachePrint.cc b/src/XrdFileCache/XrdFileCachePrint.cc index 5610832878d..4a6ca690a9b 100644 --- a/src/XrdFileCache/XrdFileCachePrint.cc +++ b/src/XrdFileCache/XrdFileCachePrint.cc @@ -14,7 +14,7 @@ namespace XrdFileCache { class Print { public: - Print(XrdOss* oss, bool v, const char* path):m_oss(oss), m_verbose(v), m_ossUser("nobody"){ + Print(XrdOss* oss, bool v, const char* path): m_oss(oss), m_verbose(v), m_ossUser("nobody"){ // check if file ends with .cinfo if (isInfoFile(path)) { printFile(std::string(path)); @@ -33,7 +33,7 @@ class Print { XrdOss* m_oss; bool m_verbose; const char* m_ossUser; -XrdOucEnv m_env; + XrdOucEnv m_env; bool isInfoFile(const char* path) { if (strncmp(&path[strlen(path)-6], ".cinfo", 6)) @@ -47,12 +47,11 @@ XrdOucEnv m_env; printf("printing %s ...\n", path.c_str()); XrdOssDF* fh = m_oss->newFile(m_ossUser); fh->Open((path).c_str(),O_RDONLY, 0600, m_env); - Info cfi; + Info cfi(0); long long off = cfi.Read(fh); std::vector statv; - printf("Numaccess %d \n", cfi.GetAccessCnt()); for (int i = 0; i Read(&a, off , sizeof(Info::AStat)); @@ -134,11 +133,16 @@ int main(int argc, char *argv[]) const char* cfgn = 0; XrdOucEnv myEnv; - int efs = open("/dev/null",O_RDWR, 0); XrdSysLogger log(efs); + int efs = open("/dev/null",O_RDWR, 0); + XrdSysLogger ossLog(efs); + XrdSysError ossErr(&ossLog, "print"); - XrdSysError err(&log, "print"); - XrdOucStream Config(&err, getenv("XRDINSTANCE"), &myEnv, "=====> "); - XrdOucArgs Spec(&err, "pfc_print: ", "", + XrdSysLogger log; + XrdSysError err(&log); + + + XrdOucStream Config(&ossErr, getenv("XRDINSTANCE"), &myEnv, "=====> "); + XrdOucArgs Spec(&ossErr, "pfc_print: ", "", "verbose", 1, "v", "config", 1, "c", (const char *)0); @@ -170,7 +174,7 @@ int main(int argc, char *argv[]) } XrdOss *oss; - XrdOfsConfigPI *ofsCfg = XrdOfsConfigPI::New(cfgn,&Config,&err); + XrdOfsConfigPI *ofsCfg = XrdOfsConfigPI::New(cfgn,&Config,&ossErr); bool ossSucc = ofsCfg->Load(XrdOfsConfigPI::theOssLib); if (!ossSucc) { printf("can't load oss\n");