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

877 {
878  // static const char *trc_pfx = "ResourceMonitorHeartBeat() ";
879 
880  // Pause before initial run
881  sleep(1);
882 
883  // XXXX Setup initial / constant stats (total RAM, total disk, ???)
884 
885  XrdOucCacheStats &S = Cache::GetInstance().Statistics;
887 
888  S.Lock();
889 
890  X.DiskSize = Cache::Conf().m_diskTotalSpace;
891 
892  X.MemSize = Cache::Conf().m_RamAbsAvailable;
893 
894  S.UnLock();
895 
896  // XXXX Schedule initial disk scan, time it!
897  //
898  // TRACE(Info, trc_pfx << "scheduling intial disk scan.");
899  // schedP->Schedule( new ScanAndPurgeJob("XrdPfc::ScanAndPurge") );
900  //
901  // bool scan_and_purge_running = true;
902 
903  // XXXX Could we really hold last-usage for all files in memory?
904 
905  // XXXX Think how to handle disk-full, scan/purge not finishing:
906  // - start dropping things out of write queue, but only when RAM gets near full;
907  // - monitoring this then becomes a high-priority job, inner loop with sleep of,
908  // say, 5 or 10 seconds.
909 
910  while (true)
911  {
912  time_t heartbeat_start = time(0);
913 
914  // TRACE(Info, trc_pfx << "HeartBeat starting ...");
915 
916  // if sumary monitoring configured, pupulate OucCacheStats:
917  S.Lock();
918 
919  // - available / used disk space (files usage calculated elsewhere (maybe))
920 
921  // - RAM usage
922  /* XXXX From Cache
923  { XrdSysMutexHelper lck(&m_RAM_mutex);
924  X.MemUsed = m_RAM_used;
925  X.MemWriteQ = m_RAM_write_queue;
926  }
927  */
928 
929  // - files opened / closed etc
930 
931  // do estimate of available space
932  S.UnLock();
933 
934  // if needed, schedule purge in a different thread.
935  // purge is:
936  // - deep scan + gather FSPurgeState
937  // - actual purge
938  //
939  // this thread can continue running and, if needed, stop writing to disk
940  // if purge is taking too long.
941 
942  // think how data is passed / synchronized between this and purge thread
943 
944  // !!!! think how stat collection is done and propgated upwards;
945  // until now it was done once per purge-interval.
946  // now stats will be added up more often, but purge will be done
947  // only occasionally.
948  // also, do we report cumulative values or deltas? cumulative should
949  // be easier and consistent with summary data.
950  // still, some are state - like disk usage, num of files.
951 
952  // Do we take care of directories that need to be newly added into DirState hierarchy?
953  // I.e., when user creates new directories and these are covered by either full
954  // spec or by root + depth declaration.
955 
956  int heartbeat_duration = time(0) - heartbeat_start;
957 
958  // TRACE(Info, trc_pfx << "HeartBeat finished, heartbeat_duration " << heartbeat_duration);
959 
960  // int sleep_time = m_fs_state..m_purgeInterval - heartbeat_duration;
961  int sleep_time = 60 - heartbeat_duration;
962  if (sleep_time > 0)
963  {
964  sleep(sleep_time);
965  }
966  }
967 }
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: