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

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