Skip to content

Commit c415e3e

Browse files
committed
[Pfc] Cleanup processing and storage of pfc.dirstats configuration parameters.
1 parent 70991bc commit c415e3e

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

src/XrdPfc/XrdPfc.hh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct Configuration
6767
bool are_file_usage_limits_set() const { return m_fileUsageMax > 0; }
6868
bool is_age_based_purge_in_effect() const { return m_purgeColdFilesAge > 0 ; }
6969
bool is_uvkeep_purge_in_effect() const { return m_cs_UVKeep >= 0; }
70-
bool is_dir_stat_reporting_on() const { return m_dirStatsMaxDepth >= 0 || ! m_dirStatsDirs.empty() || ! m_dirStatsDirGlobs.empty(); }
70+
bool is_dir_stat_reporting_on() const { return m_dirStatsStoreDepth >= 0 || ! m_dirStatsDirs.empty() || ! m_dirStatsDirGlobs.empty(); }
7171
bool is_purge_plugin_set_up() const { return false; }
7272

7373
CkSumCheck_e get_cs_Chk() const { return (CkSumCheck_e) m_cs_Chk; }
@@ -102,8 +102,7 @@ struct Configuration
102102
std::set<std::string> m_dirStatsDirs; //!< directories for which stat reporting was requested
103103
std::set<std::string> m_dirStatsDirGlobs; //!< directory globs for which stat reporting was requested
104104
int m_dirStatsInterval; //!< time between resource monitor statistics dump in seconds
105-
int m_dirStatsMaxDepth; //!< maximum depth for statistics write out
106-
int m_dirStatsStoreDepth; //!< depth to which statistics should be collected
105+
int m_dirStatsStoreDepth; //!< maximum depth for statistics write out
107106

108107
long long m_bufferSize; //!< prefetch buffer size, default 1MB
109108
long long m_RamAbsAvailable; //!< available from configuration

src/XrdPfc/XrdPfcConfiguration.cc

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ Configuration::Configuration() :
4545
m_purgeColdFilesAge(-1),
4646
m_purgeAgeBasedPeriod(10),
4747
m_accHistorySize(20),
48-
m_dirStatsInterval(1500),
49-
m_dirStatsMaxDepth(-1),
50-
m_dirStatsStoreDepth(0),
48+
m_dirStatsInterval(900),
49+
m_dirStatsStoreDepth(1),
5150
m_bufferSize(128*1024),
5251
m_RamAbsAvailable(0),
5352
m_RamKeepStdBlocks(0),
@@ -675,8 +674,8 @@ bool Cache::Config(const char *config_filename, const char *parameters)
675674
if (m_configuration.is_dir_stat_reporting_on())
676675
{
677676
loff += snprintf(buff + loff, sizeof(buff) - loff,
678-
" pfc.dirstats interval %d maxdepth %d ((internal: store_depth %d, size_of_dirlist %d, size_of_globlist %d))\n",
679-
m_configuration.m_dirStatsInterval, m_configuration.m_dirStatsMaxDepth, m_configuration.m_dirStatsStoreDepth,
677+
" pfc.dirstats interval %d maxdepth %d (internal: size_of_dirlist %d, size_of_globlist %d)\n",
678+
m_configuration.m_dirStatsInterval, m_configuration.m_dirStatsStoreDepth,
680679
(int) m_configuration.m_dirStatsDirs.size(), (int) m_configuration.m_dirStatsDirGlobs.size());
681680
loff += snprintf(buff + loff, sizeof(buff) - loff, " dirlist:\n");
682681
for (std::set<std::string>::iterator i = m_configuration.m_dirStatsDirs.begin(); i != m_configuration.m_dirStatsDirs.end(); ++i)
@@ -837,36 +836,42 @@ bool Cache::ConfigParameters(std::string part, XrdOucStream& config, TmpConfigur
837836
{
838837
if (strcmp(p, "interval") == 0)
839838
{
840-
if (XrdOuca2x::a2i(m_log, "Error getting dirstsat interval", cwg.GetWord(), &m_configuration.m_dirStatsInterval, 0, 7 * 24 * 3600))
839+
int validIntervals[] = {60, 120, 300, 600, 900, 1200, 1800, 3600};
840+
int size = sizeof(validIntervals) / sizeof(int);
841+
842+
if (XrdOuca2x::a2tm(m_log, "Error getting dirstsat interval", cwg.GetWord(),
843+
&m_configuration.m_dirStatsInterval, validIntervals[0], validIntervals[size - 1]))
841844
{
842845
return false;
843846
}
844-
int validIntervals[] = {60, 300, 600, 900, 1800, 3600};
845-
int size = sizeof(validIntervals) / sizeof(int);
846-
bool match = false;
847-
std::string vvl;
847+
bool match = false, round_down = false;
848848
for (int i = 0; i < size; i++) {
849849
if (validIntervals[i] == m_configuration.m_dirStatsInterval) {
850850
match = true;
851851
break;
852852
}
853-
vvl += std::to_string(validIntervals[i]);
854-
if ((i+1) != size) vvl += ", ";
853+
if (i > 0 && m_configuration.m_dirStatsInterval < validIntervals[i]) {
854+
m_configuration.m_dirStatsInterval = validIntervals[i - 1];
855+
round_down = true;
856+
break;
857+
}
855858
}
856-
857-
if (!match) {
858-
m_log.Emsg("Config", "Error: Dirstat interval is not valid. Possible interval values are ", vvl.c_str());
859-
return false;
859+
if ( ! match && ! round_down) {
860+
m_log.Emsg("Config", "Error: dirstat interval parsing failed.");
861+
return false;
862+
}
863+
if (round_down) {
864+
m_log.Emsg("Config", "Info: dirstat interval was rounded down to the nearest valid value.");
860865
}
861866

862867
}
863868
else if (strcmp(p, "maxdepth") == 0)
864869
{
865-
if (XrdOuca2x::a2i(m_log, "Error getting maxdepth value", cwg.GetWord(), &m_configuration.m_dirStatsMaxDepth, 0, 16))
870+
if (XrdOuca2x::a2i(m_log, "Error getting maxdepth value", cwg.GetWord(),
871+
&m_configuration.m_dirStatsStoreDepth, 0, 16))
866872
{
867873
return false;
868874
}
869-
m_configuration.m_dirStatsStoreDepth = std::max(m_configuration.m_dirStatsStoreDepth, m_configuration.m_dirStatsMaxDepth);
870875
}
871876
else if (strcmp(p, "dir") == 0)
872877
{

0 commit comments

Comments
 (0)