XRootD
XrdPfcResourceMonitor.cc File Reference
#include "XrdPfcResourceMonitor.hh"
#include "XrdPfc.hh"
#include "XrdPfcPathParseTools.hh"
#include "XrdPfcFsTraversal.hh"
#include "XrdPfcDirState.hh"
#include "XrdPfcDirStateSnapshot.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 18 of file XrdPfcResourceMonitor.cc.

Function Documentation

◆ Proto_ResourceMonitorHeartBeat()

void Proto_ResourceMonitorHeartBeat ( )

Definition at line 849 of file XrdPfcResourceMonitor.cc.

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