Skip to content

Commit

Permalink
Replace XrdCl::Log with XrdOucTrace
Browse files Browse the repository at this point in the history
  • Loading branch information
alja committed Jun 3, 2016
1 parent 8969ab3 commit dcb407d
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 198 deletions.
28 changes: 11 additions & 17 deletions src/XrdFileCache/XrdFileCache.cc
Expand Up @@ -146,18 +146,19 @@ XrdOucCacheIO2 *Cache::Attach(XrdOucCacheIO2 *io, int Options)
{
if (Cache::GetInstance().Decide(io))
{
clLog()->Info(XrdCl::AppMsg, "Cache::Attach() %s", io->Path());
TRACE(Debug, "Cache::Attach() " << io->Path());
IO* cio;
if (Cache::GetInstance().RefConfiguration().m_hdfsmode)
cio = new IOFileBlock(io, m_stats, *this);
else
cio = new IOEntireFile(io, m_stats, *this);

TRACE(Info, "Cache::Attach() " << io->Path());
return cio;
}
else
{
clLog()->Info(XrdCl::AppMsg, "Cache::Attach() reject %s", io->Path());
TRACE(Info, "Cache::Attach() decision decline " << io->Path());
}
return io;
}
Expand All @@ -172,7 +173,7 @@ int Cache::isAttached()

void Cache::Detach(XrdOucCacheIO* io)
{
clLog()->Info(XrdCl::AppMsg, "Cache::Detach() %s", io->Path());
TRACE(Info, "Cache::Detach() " << io->Path());

// Cache owns File objects
XrdSysMutexHelper lock(&m_active_mutex);
Expand Down Expand Up @@ -200,15 +201,15 @@ Cache::HaveFreeWritingSlots()
return true;
}
else {
XrdCl::DefaultEnv::GetLog()->Info(XrdCl::AppMsg, "Cache::HaveFreeWritingSlots() negative", m_writeQ.size);
TRACE(Dump, "Cache::HaveFreeWritingSlots() negative " << m_writeQ.size);
return false;
}
}
//______________________________________________________________________________
void
Cache::AddWriteTask(Block* b, bool fromRead)
{
XrdCl::DefaultEnv::GetLog()->Dump(XrdCl::AppMsg, "Cache::AddWriteTask() bOff=%ld", b->m_offset);
TRACE(Dump, "Cache::AddWriteTask() bOff=%ld " << b->m_offset);
m_writeQ.condVar.Lock();
if (fromRead)
m_writeQ.queue.push_back(b);
Expand All @@ -228,10 +229,9 @@ void Cache::RemoveWriteQEntriesFor(File *iFile)
{
if ((*i)->m_file == iFile)
{

XrdCl::DefaultEnv::GetLog()->Dump(XrdCl::AppMsg, "Cache::Remove entries for %p path %s", (void*)(*i), iFile->lPath());
TRACE(Dump, "Cache::Remove entries for " << (void*)(*i) << " path " << iFile->lPath());
std::list<Block*>::iterator j = i++;
iFile->BlockRemovedFromWriteQ(*j);
iFile->BlockRemovedFromWriteQ(*j);
m_writeQ.queue.erase(j);
--m_writeQ.size;
}
Expand All @@ -257,7 +257,7 @@ Cache::ProcessWriteTasks()
Block* block = m_writeQ.queue.front(); // AMT should not be back ???
m_writeQ.queue.pop_front();
m_writeQ.size--;
XrdCl::DefaultEnv::GetLog()->Dump(XrdCl::AppMsg, "Cache::ProcessWriteTasks for %p path %s", (void*)(block), block->m_file->lPath());
TRACE(Dump, "Cache::ProcessWriteTasks for %p " << (void*)(block) << " path " << block->m_file->lPath());
m_writeQ.condVar.UnLock();

block->m_file->WriteBlockToDisk(block);
Expand Down Expand Up @@ -332,13 +332,10 @@ Cache::RegisterPrefetchFile(File* file)

if (Cache::GetInstance().RefConfiguration().m_prefetch_max_blocks)
{

XrdCl::DefaultEnv::GetLog()->Dump(XrdCl::AppMsg, "Cache::Register new file BEGIN");
m_prefetch_condVar.Lock();
m_prefetchList.push_back(file);
m_prefetch_condVar.Signal();
m_prefetch_condVar.UnLock();
XrdCl::DefaultEnv::GetLog()->Dump(XrdCl::AppMsg, "Cache::Register new file End");
}
}

Expand Down Expand Up @@ -399,7 +396,7 @@ Cache::Prepare(const char *url, int oflags, mode_t mode)
struct stat buf;
int res = m_output_fs->Stat(spath.c_str(), &buf);
if (res == 0) {
XrdCl::DefaultEnv::GetLog()->Dump(XrdCl::AppMsg, "Cache::Prefetch defer open %s", spath.c_str());
TRACE( Dump, "Cache::Prefetch defer open " << spath);
return 1;
}
else {
Expand Down Expand Up @@ -433,7 +430,7 @@ int Cache::Stat(const char *curl, struct stat &sbuff)
name += ".cinfo";
int res = infoFile->Open(name.c_str(), O_RDONLY, 0600, myEnv);
if (res >= 0) {
Info info(0);
Info info(m_trace, 0);
if (info.Read(infoFile) > 0) {
sbuff.st_size = info.GetFileSize();
success = true;
Expand All @@ -455,9 +452,6 @@ void
Cache::Prefetch()
{
int limitRAM= Cache::GetInstance().RefConfiguration().m_NRamBuffers * 0.7;

XrdCl::DefaultEnv::GetLog()->Dump(XrdCl::AppMsg, "Cache::Prefetch thread start");

while (true) {
m_RAMblock_mutex.Lock();
bool doPrefetch = (m_RAMblocks_used < limitRAM && HaveFreeWritingSlots());
Expand Down
5 changes: 1 addition & 4 deletions src/XrdFileCache/XrdFileCache.hh
Expand Up @@ -192,7 +192,7 @@ namespace XrdFileCache
void AddActive(IO*, File*);


XrdOucTrace* GetTrace() { return m_trace; }
XrdOucTrace* GetTrace() { return m_trace; }
private:
bool ConfigParameters(std::string, XrdOucStream&);
bool ConfigXeq(char *, XrdOucStream &);
Expand All @@ -213,9 +213,6 @@ namespace XrdFileCache

Configuration m_configuration; //!< configurable parameters

//! Short log alias.
XrdCl::Log* clLog() const { return XrdCl::DefaultEnv::GetLog(); }

XrdSysCondVar m_prefetch_condVar; //!< central lock for this class

XrdSysMutex m_RAMblock_mutex; //!< central lock for this class
Expand Down
32 changes: 16 additions & 16 deletions src/XrdFileCache/XrdFileCacheConfiguration.cc
Expand Up @@ -34,7 +34,7 @@ bool Cache::xdlib(XrdOucStream &Config)
std::string libp;
if (!(val = Config.GetWord()) || !val[0])
{
clLog()->Info(XrdCl::AppMsg, " Cache::Config() decisionlib not specified; always caching files");
TRACE(Info," Cache::Config() decisionlib not specified; always caching files");
return true;
}
else
Expand All @@ -55,14 +55,13 @@ bool Cache::xdlib(XrdOucStream &Config)
Decision * d = ep(m_log);
if (!d)
{
clLog()->Error(XrdCl::AppMsg, "Cache::Config() decisionlib was not able to create a decision object");
TRACE(Error, "Cache::Config() decisionlib was not able to create a decision object");
return false;
}
if (params)
d->ConfigDecision(params);

m_decisionpoints.push_back(d);
clLog()->Info(XrdCl::AppMsg, "Cache::Config() successfully created decision lib from %s", libp.c_str());
return true;
}

Expand Down Expand Up @@ -90,11 +89,12 @@ bool Cache::xtrace(XrdOucStream &Config)

for (int i = 0; i < numopts; i++)
{
if (!strcmp(val, tropts[i].opname))
if (!strcmp(val, tropts[i].opname)) {
m_trace->What = tropts[i].opval;
return true;
return true;
}
}
return 0;
return false;
}

//______________________________________________________________________________
Expand All @@ -112,14 +112,14 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char

if (!config_filename || !*config_filename)
{
clLog()->Warning(XrdCl::AppMsg, "Cache::Config() configuration file not specified.");
TRACE(Error, "Cache::Config() configuration file not specified.");
return false;
}

int fd;
if ( (fd = open(config_filename, O_RDONLY, 0)) < 0)
{
clLog()->Error(XrdCl::AppMsg, "Cache::Config() can't open configuration file %s", config_filename);
TRACE( Error, "Cache::Config() can't open configuration file " << config_filename);
return false;
}

Expand All @@ -138,7 +138,7 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char
}
else
{
clLog()->Error(XrdCl::AppMsg, "Cache::Config() Unable to create an OSS object");
TRACE(Error, "Cache::Config() Unable to create an OSS object");
m_output_fs = 0;
return false;
}
Expand Down Expand Up @@ -169,7 +169,7 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char
if (!retval)
{
retval = false;
clLog()->Error(XrdCl::AppMsg, "Cache::Config() error in parsing");
TRACE(Error, "Cache::Config() error in parsing");
break;
}

Expand All @@ -183,15 +183,14 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char
if (m_output_fs->StatVS(&sP, "public", 1) >= 0) {
m_configuration.m_diskUsageLWM = static_cast<long long>(0.90 * sP.Total + 0.5);
m_configuration.m_diskUsageHWM = static_cast<long long>(0.95 * sP.Total + 0.5);
clLog()->Debug(XrdCl::AppMsg, "Default disk usage [%lld, %lld]", m_configuration.m_diskUsageLWM, m_configuration.m_diskUsageHWM);
}
}

// get number of available RAM blocks after process configuration
if (m_configuration.m_RamAbsAvailable == 0 )
{
m_log.Emsg("Error", "RAM usage not specified. Please set pfc.ram value in configuration file.");
return false;
TRACE(Error, "RAM usage not specified. Please set pfc.ram value in configuration file.");
return false;
}
m_configuration.m_NRamBuffers = static_cast<int>(m_configuration.m_RamAbsAvailable/ m_configuration.m_bufferSize);

Expand All @@ -207,12 +206,13 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char
loff = snprintf(buff, sizeof(buff), "Config effective %s pfc configuration:\n"
" pfc.blocksize %lld\n"
" pfc.prefetch %ld\n"
" pfc.ram %.fg",
" pfc.ram %.fg"
" pfc.trace %d",
config_filename,
m_configuration.m_bufferSize,
m_configuration.m_prefetch_max_blocks, // AMT not sure what parsing should be
rg);

rg,
m_trace->What);

if (m_configuration.m_hdfsmode)
{
Expand Down

0 comments on commit dcb407d

Please sign in to comment.