XRootD
XrdPfcPurgeQuota Class Reference
+ Inheritance diagram for XrdPfcPurgeQuota:
+ Collaboration diagram for XrdPfcPurgeQuota:

Public Member Functions

 XrdPfcPurgeQuota (XrdSysError &log)
 
bool ConfigPurgePin (const char *parms) override
 Provide bytes to erase from dir quota listed in a text file. More...
 
long long GetBytesToRecover (const XrdPfc::DataFsPurgeshot &purge_shot) override
 Provide bytes to erase from dir quota listed in a text file. More...
 
void InitDirStatesForLocalPaths (const XrdPfc::DataFsPurgeshot &purge_shot)
 Set directory statistics. More...
 
- Public Member Functions inherited from XrdPfc::PurgePin
virtual ~PurgePin ()
 
virtual bool CallPeriodically ()
 
list_trefDirInfos ()
 

Additional Inherited Members

- Public Types inherited from XrdPfc::PurgePin
typedef list_t::iterator list_i
 
typedef std::vector< DirInfolist_t
 
- Protected Attributes inherited from XrdPfc::PurgePin
list_t m_list
 

Detailed Description

Definition at line 11 of file XrdPfcPurgeQuota.cc.

Constructor & Destructor Documentation

◆ XrdPfcPurgeQuota()

XrdPfcPurgeQuota::XrdPfcPurgeQuota ( XrdSysError log)
inline

Definition at line 16 of file XrdPfcPurgeQuota.cc.

16 : m_log(log) {}

Member Function Documentation

◆ ConfigPurgePin()

bool XrdPfcPurgeQuota::ConfigPurgePin ( const char *  parms)
inlineoverridevirtual

Provide bytes to erase from dir quota listed in a text file.

Reimplemented from XrdPfc::PurgePin.

Definition at line 61 of file XrdPfcPurgeQuota.cc.

62  {
63  // retrive configuration file name
64  if (!parms || !parms[0] || (strlen(parms) == 0))
65  {
66  m_log.Emsg("ConfigPurgePin", "Quota file not specified.");
67  return false;
68  }
69  m_log.Emsg("ConfigPurgePin", "Using directory list", parms);
70 
71  // parse the file to get directory quotas
72  const char *config_filename = parms;
73  const char *theINS = getenv("XRDINSTANCE");
74  XrdOucEnv myEnv;
75  XrdOucStream Config(&m_log, theINS, &myEnv, "=====> PurgeQuota ");
76 
77  int fd;
78  if ((fd = open(config_filename, O_RDONLY, 0)) < 0)
79  {
80  m_log.Emsg("ConfigPurgePin() can't open configuration file ", config_filename);
81  }
82 
83  Config.Attach(fd);
84  static const char *cvec[] = {"*** pfc purge plugin :", 0};
85  Config.Capture(cvec);
86 
87  char *var;
88  while ((var = Config.GetMyFirstWord()))
89  {
90  std::string dirpath = var;
91  const char *val;
92 
93  if (!(val = Config.GetWord()))
94  {
95  m_log.Emsg("PurgeQuota plugin", "quota not specified");
96  continue;
97  }
98 
99  std::string tmpc = val;
100  long long quota = 0;
101  if (::isalpha(*(tmpc.rbegin())))
102  {
103  if (XrdOuca2x::a2sz(m_log, "Error getting quota", tmpc.c_str(), &quota))
104  {
105  continue;
106  }
107  }
108  else
109  {
110  if (XrdOuca2x::a2ll(m_log, "Error getting quota", tmpc.c_str(), &quota))
111  {
112  continue;
113  }
114  }
115 
116  DirInfo d;
117  d.path = dirpath;
118  d.nBytesQuota = quota;
119  m_list.push_back(d);
120  }
121 
122  return true;
123  }
int open(const char *path, int oflag,...)
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
Definition: XrdOuca2x.cc:257
static int a2ll(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
Definition: XrdOuca2x.cc:70
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
XrdCmsConfig Config

References XrdOuca2x::a2ll(), XrdOuca2x::a2sz(), XrdCms::Config, XrdSysError::Emsg(), XrdPfc::PurgePin::m_list, XrdPfc::PurgePin::DirInfo::nBytesQuota, open(), and XrdPfc::PurgePin::DirInfo::path.

+ Here is the call graph for this function:

◆ GetBytesToRecover()

long long XrdPfcPurgeQuota::GetBytesToRecover ( const XrdPfc::DataFsPurgeshot purge_shot)
inlineoverridevirtual

Provide bytes to erase from dir quota listed in a text file.

Implements XrdPfc::PurgePin.

Definition at line 32 of file XrdPfcPurgeQuota.cc.

33  {
34  // setup diskusage for each dir path
35  InitDirStatesForLocalPaths(purge_shot);
36 
37  long long totalToRemove = 0;
38  // get bytes to remove
39  for (list_i it = m_list.begin(); it != m_list.end(); ++it)
40  {
41  if (it->dirUsage == nullptr)
42  {
43  m_log.Emsg("PurgeQuotaPin--GetBytesToRecover", "directory not found:", it->path.c_str());
44  continue;
45  }
46  long long cv = 512ll * it->dirUsage->m_StBlocks - it->nBytesQuota;
47  if (cv > 0)
48  it->nBytesToRecover = cv;
49  else
50  it->nBytesToRecover = 0;
51 
52  totalToRemove += it->nBytesToRecover;
53  }
54 
55  return totalToRemove;
56  }
void InitDirStatesForLocalPaths(const XrdPfc::DataFsPurgeshot &purge_shot)
Set directory statistics.
list_t::iterator list_i

References XrdSysError::Emsg(), InitDirStatesForLocalPaths(), and XrdPfc::PurgePin::m_list.

+ Here is the call graph for this function:

◆ InitDirStatesForLocalPaths()

void XrdPfcPurgeQuota::InitDirStatesForLocalPaths ( const XrdPfc::DataFsPurgeshot purge_shot)
inline

Set directory statistics.

Definition at line 21 of file XrdPfcPurgeQuota.cc.

22  {
23  for (list_i it = m_list.begin(); it != m_list.end(); ++it)
24  {
25  it->dirUsage = purge_shot.find_dir_usage_for_dir_path(it->path);
26  }
27  }
const DirUsage * find_dir_usage_for_dir_path(const std::string &dir_path) const

References XrdPfc::DataFsPurgeshot::find_dir_usage_for_dir_path(), and XrdPfc::PurgePin::m_list.

Referenced by GetBytesToRecover().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: