Skip to content

Commit

Permalink
Resolve XrdFileCache::Info dependencied.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja committed Apr 1, 2015
1 parent d69a15e commit a470c23
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/XrdFileCache/XrdFileCacheFactory.cc
Expand Up @@ -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))
Expand Down
21 changes: 7 additions & 14 deletions src/XrdFileCache/XrdFileCacheInfo.cc
Expand Up @@ -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";
Expand All @@ -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()
Expand Down Expand Up @@ -125,28 +124,22 @@ 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()");

int flr = XrdOucSxeq::Serialize(fp->getFD(), 0);
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); }
}

Expand Down
4 changes: 2 additions & 2 deletions src/XrdFileCache/XrdFileCacheInfo.hh
Expand Up @@ -59,7 +59,7 @@ namespace XrdFileCache
//------------------------------------------------------------------------
//! Constructor.
//------------------------------------------------------------------------
Info();
Info(long long bufferSize);

//------------------------------------------------------------------------
//! Destructor.
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/XrdFileCache/XrdFileCachePrefetch.cc
Expand Up @@ -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),
Expand Down Expand Up @@ -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
{
Expand Down
22 changes: 13 additions & 9 deletions src/XrdFileCache/XrdFileCachePrint.cc
Expand Up @@ -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));
Expand All @@ -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))
Expand All @@ -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<Info::AStat> statv;

printf("Numaccess %d \n", cfi.GetAccessCnt());
for (int i = 0; i <cfi.GetAccessCnt(); ++i ) {
Info::AStat a;
fh->Read(&a, off , sizeof(Info::AStat));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit a470c23

Please sign in to comment.