@@ -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