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 916 of file XrdPfcResourceMonitor.cc.

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