XRootD
XrdPfcResourceMonitor.cc File Reference
#include "XrdPfcResourceMonitor.hh"
#include "XrdPfc.hh"
#include "XrdPfcPathParseTools.hh"
#include "XrdPfcFsTraversal.hh"
#include "XrdPfcDirState.hh"
#include "XrdPfcDirStateSnapshot.hh"
#include "XrdPfcDirStatePurgeshot.hh"
#include "XrdPfcTrace.hh"
#include "XrdPfcPurgePin.hh"
#include "XrdOss/XrdOss.hh"
#include <algorithm>
+ Include dependency graph for XrdPfcResourceMonitor.cc:

Go to the source code of this file.

Namespaces

 XrdPfc
 

Macros

#define dprintf(...)   (void(0))
 

Functions

void XrdPfc::OldStylePurgeDriver (DataFsPurgeshot &ps)
 
void Proto_ResourceMonitorHeartBeat ()
 

Macro Definition Documentation

◆ dprintf

#define dprintf (   ...)    (void(0))

Definition at line 19 of file XrdPfcResourceMonitor.cc.

Function Documentation

◆ Proto_ResourceMonitorHeartBeat()

void Proto_ResourceMonitorHeartBeat ( )

Definition at line 936 of file XrdPfcResourceMonitor.cc.

937 {
938  // static const char *trc_pfx = "ResourceMonitorHeartBeat() ";
939 
940  // Pause before initial run
941  sleep(1);
942 
943  // XXXX Setup initial / constant stats (total RAM, total disk, ???)
944 
945  XrdOucCacheStats &S = Cache::GetInstance().Statistics;
947 
948  S.Lock();
949 
950  X.DiskSize = Cache::Conf().m_diskTotalSpace;
951 
952  X.MemSize = Cache::Conf().m_RamAbsAvailable;
953 
954  S.UnLock();
955 
956  // XXXX Schedule initial disk scan, time it!
957  //
958  // TRACE(Info, trc_pfx << "scheduling intial disk scan.");
959  // schedP->Schedule( new ScanAndPurgeJob("XrdPfc::ScanAndPurge") );
960  //
961  // bool scan_and_purge_running = true;
962 
963  // XXXX Could we really hold last-usage for all files in memory?
964 
965  // XXXX Think how to handle disk-full, scan/purge not finishing:
966  // - start dropping things out of write queue, but only when RAM gets near full;
967  // - monitoring this then becomes a high-priority job, inner loop with sleep of,
968  // say, 5 or 10 seconds.
969 
970  while (true)
971  {
972  time_t heartbeat_start = time(0);
973 
974  // TRACE(Info, trc_pfx << "HeartBeat starting ...");
975 
976  // if sumary monitoring configured, pupulate OucCacheStats:
977  S.Lock();
978 
979  // - available / used disk space (files usage calculated elsewhere (maybe))
980 
981  // - RAM usage
982  /* XXXX From Cache
983  { XrdSysMutexHelper lck(&m_RAM_mutex);
984  X.MemUsed = m_RAM_used;
985  X.MemWriteQ = m_RAM_write_queue;
986  }
987  */
988 
989  // - files opened / closed etc
990 
991  // do estimate of available space
992  S.UnLock();
993 
994  // if needed, schedule purge in a different thread.
995  // purge is:
996  // - deep scan + gather FSPurgeState
997  // - actual purge
998  //
999  // this thread can continue running and, if needed, stop writing to disk
1000  // if purge is taking too long.
1001 
1002  // think how data is passed / synchronized between this and purge thread
1003 
1004  // !!!! think how stat collection is done and propgated upwards;
1005  // until now it was done once per purge-interval.
1006  // now stats will be added up more often, but purge will be done
1007  // only occasionally.
1008  // also, do we report cumulative values or deltas? cumulative should
1009  // be easier and consistent with summary data.
1010  // still, some are state - like disk usage, num of files.
1011 
1012  // Do we take care of directories that need to be newly added into DirState hierarchy?
1013  // I.e., when user creates new directories and these are covered by either full
1014  // spec or by root + depth declaration.
1015 
1016  int heartbeat_duration = time(0) - heartbeat_start;
1017 
1018  // TRACE(Info, trc_pfx << "HeartBeat finished, heartbeat_duration " << heartbeat_duration);
1019 
1020  // int sleep_time = m_fs_state..m_purgeInterval - heartbeat_duration;
1021  int sleep_time = 60 - heartbeat_duration;
1022  if (sleep_time > 0)
1023  {
1024  sleep(sleep_time);
1025  }
1026  }
1027 }
struct XrdOucCacheStats::CacheStats X

References XrdPfc::Cache::Conf(), XrdOucCacheStats::CacheStats::DiskSize, XrdPfc::Cache::GetInstance(), XrdOucCacheStats::Lock(), XrdPfc::Configuration::m_diskTotalSpace, XrdPfc::Configuration::m_RamAbsAvailable, XrdOucCacheStats::CacheStats::MemSize, XrdOucCache::Statistics, XrdOucCacheStats::UnLock(), and XrdOucCacheStats::X.

+ Here is the call graph for this function: