XRootD
XrdPfc::DirState Struct Reference

#include <XrdPfcDirState.hh>

+ Inheritance diagram for XrdPfc::DirState:
+ Collaboration diagram for XrdPfc::DirState:

Public Types

typedef DsMap_t::iterator DsMap_i
 
typedef std::map< std::string, DirStateDsMap_t
 

Public Member Functions

 DirState ()
 Constructor. More...
 
 DirState (DirState *parent)
 
 DirState (DirState *parent, const std::string &dname)
 
void apply_stats_to_usages ()
 
int count_dirs_to_level (int max_depth) const
 
DirStatecreate_child (const std::string &dir)
 
void dump_recursively (const char *name, int max_depth) const
 
DirStatefind_dir (const std::string &dir, bool create_subdirs)
 
DirStatefind_path (const std::string &path, int max_depth, bool parse_as_lfn, bool create_subdirs, DirState **last_existing_dir=nullptr)
 
DirStatefind_path_tok (PathTokenizer &pt, int pos, bool create_subdirs, DirState **last_existing_dir=nullptr)
 
DirStateget_parent ()
 
void init ()
 
void reset_stats ()
 
void upward_propagate_initial_scan_usages ()
 
void upward_propagate_stats_and_times ()
 
- Public Member Functions inherited from XrdPfc::DirStateBase
 DirStateBase ()
 
 DirStateBase (const std::string &dname)
 

Public Attributes

int m_depth
 
DirStats m_here_stats
 
DirUsage m_here_usage
 
DirStatem_parent = nullptr
 
DirStats m_recursive_subdir_stats
 
DirUsage m_recursive_subdir_usage
 
bool m_scanned = false
 
DsMap_t m_subdirs
 
- Public Attributes inherited from XrdPfc::DirStateBase
std::string m_dir_name
 

Detailed Description

Definition at line 121 of file XrdPfcDirState.hh.

Member Typedef Documentation

◆ DsMap_i

typedef DsMap_t::iterator XrdPfc::DirState::DsMap_i

Definition at line 124 of file XrdPfcDirState.hh.

◆ DsMap_t

typedef std::map<std::string, DirState> XrdPfc::DirState::DsMap_t

Definition at line 123 of file XrdPfcDirState.hh.

Constructor & Destructor Documentation

◆ DirState() [1/3]

DirState::DirState ( )

Constructor.

Definition at line 11 of file XrdPfcDirState.cc.

11  : m_parent(0), m_depth(0)
12 {}

Referenced by create_child().

+ Here is the caller graph for this function:

◆ DirState() [2/3]

DirState::DirState ( DirState parent)

Constructor

Parameters
DirStateparent directory

Definition at line 18 of file XrdPfcDirState.cc.

18  :
21 {}
static void parent()

◆ DirState() [3/3]

DirState::DirState ( DirState parent,
const std::string &  dname 
)

Constructor

Parameters
parentparent DirState object
dnamename of this directory only, no slashes, no extras.

Definition at line 28 of file XrdPfcDirState.cc.

28  :
29  DirStateBase(dname),
32 {}

Member Function Documentation

◆ apply_stats_to_usages()

void DirState::apply_stats_to_usages ( )

Definition at line 154 of file XrdPfcDirState.cc.

155 {
156  for (DsMap_i i = m_subdirs.begin(); i != m_subdirs.end(); ++i)
157  {
158  i->second.apply_stats_to_usages();
159  }
162 }
DirUsage m_recursive_subdir_usage
DsMap_t::iterator DsMap_i
DirStats m_recursive_subdir_stats
void update_from_stats(const DirStats &s)

References m_here_stats, m_here_usage, m_recursive_subdir_stats, m_recursive_subdir_usage, m_subdirs, and XrdPfc::DirUsage::update_from_stats().

Referenced by XrdPfc::DataFsState::apply_stats_to_usages().

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

◆ count_dirs_to_level()

int DirState::count_dirs_to_level ( int  max_depth) const

Definition at line 178 of file XrdPfcDirState.cc.

179 {
180  int n_dirs = 1;
181  if (m_depth < max_depth)
182  {
183  for (auto & [name, ds] : m_subdirs)
184  {
185  n_dirs += ds.count_dirs_to_level(max_depth);
186  }
187  }
188  return n_dirs;
189 }

References m_depth, and m_subdirs.

Referenced by XrdPfc::ResourceMonitor::heart_beat(), and XrdPfc::ResourceMonitor::perform_purge_check().

+ Here is the caller graph for this function:

◆ create_child()

DirState * DirState::create_child ( const std::string &  dir)

Internal function called from find_dir or find_path_tok

Parameters
dirsubdir name

Definition at line 38 of file XrdPfcDirState.cc.

39 {
40  std::pair<DsMap_i, bool> ir = m_subdirs.insert(std::make_pair(dir, DirState(this, dir)));
41  return &ir.first->second;
42 }
DirState()
Constructor.

References DirState(), and m_subdirs.

Referenced by find_dir(), and find_path_tok().

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

◆ dump_recursively()

void DirState::dump_recursively ( const char *  name,
int  max_depth 
) const

Recursive print of statistics. Called if defined in pfc configuration.

Definition at line 195 of file XrdPfcDirState.cc.

196 {
197  printf("%*d %s usage_here=%lld usage_sub=%lld usage_total=%lld num_ios=%d duration=%d b_hit=%lld b_miss=%lld b_byps=%lld b_wrtn=%lld\n",
198  2 + 2 * m_depth, m_depth, name,
201  // XXXXX here_stats or sum up? or both?
205 
206  if (m_depth < max_depth)
207  {
208  for (auto & [name, ds] : m_subdirs)
209  {
210  ds.dump_recursively(name.c_str(), max_depth);
211  }
212  }
213 }
long long m_BytesMissed
number of bytes served from remote and cached
Definition: XrdPfcStats.hh:40
long long m_BytesBypassed
number of bytes served directly through XrdCl
Definition: XrdPfcStats.hh:41
int m_Duration
total duration of all IOs attached
Definition: XrdPfcStats.hh:38
int m_NumIos
number of IO objects attached during this access
Definition: XrdPfcStats.hh:37
long long m_BytesHit
number of bytes served from disk
Definition: XrdPfcStats.hh:39
long long m_BytesWritten
number of bytes written to disk
Definition: XrdPfcStats.hh:42
long long m_StBlocks

References XrdPfc::Stats::m_BytesBypassed, XrdPfc::Stats::m_BytesHit, XrdPfc::Stats::m_BytesMissed, XrdPfc::Stats::m_BytesWritten, m_depth, XrdPfc::Stats::m_Duration, m_here_stats, m_here_usage, XrdPfc::Stats::m_NumIos, m_recursive_subdir_usage, XrdPfc::DirUsage::m_StBlocks, and m_subdirs.

Referenced by XrdPfc::DataFsState::dump_recursively().

+ Here is the caller graph for this function:

◆ find_dir()

DirState * DirState::find_dir ( const std::string &  dir,
bool  create_subdirs 
)

Non recursive function to find an entry in this directory only.

Parameters
dirsubdir name
boolcreate the subdir in this DirsStat
create_subdirsif true and the dir is not found, a new DirState child is created

Definition at line 97 of file XrdPfcDirState.cc.

99 {
100  DsMap_i i = m_subdirs.find(dir);
101 
102  if (i != m_subdirs.end())
103  return &i->second;
104 
105  if (create_subdirs)
106  return create_child(dir);
107 
108  return nullptr;
109 }
DirState * create_child(const std::string &dir)

References create_child(), and m_subdirs.

Referenced by XrdPfc::FsTraversal::cd_down().

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

◆ find_path()

DirState * DirState::find_path ( const std::string &  path,
int  max_depth,
bool  parse_as_lfn,
bool  create_subdirs,
DirState **  last_existing_dir = nullptr 
)

Recursive function to find DirState with given absolute dir path

Parameters
pathfull path to parse
max_depthdirectory depth to which to descend (value < 0 means full descent)
parse_as_lfn
create_subdirs

Definition at line 81 of file XrdPfcDirState.cc.

83 {
84  PathTokenizer pt(path, max_depth, parse_as_lfn);
85 
86  if (last_existing_dir)
87  *last_existing_dir = this;
88 
89  return find_path_tok(pt, 0, create_subdirs, last_existing_dir);
90 }
DirState * find_path_tok(PathTokenizer &pt, int pos, bool create_subdirs, DirState **last_existing_dir=nullptr)

References find_path_tok().

Referenced by XrdPfc::DataFsState::find_dirstate_for_lfn(), and XrdPfc::ResourceMonitor::process_queues().

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

◆ find_path_tok()

DirState * DirState::find_path_tok ( PathTokenizer pt,
int  pos,
bool  create_subdirs,
DirState **  last_existing_dir = nullptr 
)

Internal function called from find_path

Parameters
dirsubdir name

Definition at line 48 of file XrdPfcDirState.cc.

50 {
51  if (pos == pt.get_n_dirs())
52  return this;
53 
54  DirState *ds = nullptr;
55 
56  DsMap_i i = m_subdirs.find(pt.m_dirs[pos]);
57 
58  if (i != m_subdirs.end())
59  {
60  ds = &i->second;
61  if (last_existing_dir)
62  *last_existing_dir = ds;
63  }
64  else if (create_subdirs)
65  {
66  ds = create_child(pt.m_dirs[pos]);
67  }
68 
69  if (ds)
70  return ds->find_path_tok(pt, pos + 1, create_subdirs, last_existing_dir);
71 
72  return nullptr;
73 }
std::vector< const char * > m_dirs

References create_child(), find_path_tok(), XrdPfc::PathTokenizer::get_n_dirs(), XrdPfc::PathTokenizer::m_dirs, and m_subdirs.

Referenced by find_path(), and find_path_tok().

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

◆ get_parent()

DirState* XrdPfc::DirState::get_parent ( )
inline

Definition at line 157 of file XrdPfcDirState.hh.

157 { return m_parent; }

References m_parent.

Referenced by XrdPfc::FsTraversal::cd_up(), and XrdPfc::ResourceMonitor::process_queues().

+ Here is the caller graph for this function:

◆ init()

void XrdPfc::DirState::init ( )

◆ reset_stats()

void DirState::reset_stats ( )

Reset current transaction statistics. Called from ... to be seen if needed at all XXXX

Definition at line 168 of file XrdPfcDirState.cc.

169 {
170  for (DsMap_i i = m_subdirs.begin(); i != m_subdirs.end(); ++i)
171  {
172  i->second.reset_stats();
173  }
176 }

References m_here_stats, m_recursive_subdir_stats, m_subdirs, and XrdPfc::DirStats::Reset().

Referenced by XrdPfc::DataFsState::reset_stats().

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

◆ upward_propagate_initial_scan_usages()

void DirState::upward_propagate_initial_scan_usages ( )

Propagate usages to parents after initial directory scan. Called from ResourceMonitor::perform_initial_scan()

Definition at line 115 of file XrdPfcDirState.cc.

116 {
117  DirUsage &here = m_here_usage;
119 
120  for (auto & [name, daughter] : m_subdirs)
121  {
122  daughter.upward_propagate_initial_scan_usages();
123 
124  DirUsage &dhere = daughter.m_here_usage;
125  DirUsage &dsubdirs = daughter.m_recursive_subdir_usage;
126 
127  here.m_NDirectories += 1;
128 
129  subdirs.m_StBlocks += dhere.m_StBlocks + dsubdirs.m_StBlocks;
130  subdirs.m_NFiles += dhere.m_NFiles + dsubdirs.m_NFiles;
131  subdirs.m_NDirectories += dhere.m_NDirectories + dsubdirs.m_NDirectories;
132  }
133 }

References m_here_usage, XrdPfc::DirUsage::m_NDirectories, XrdPfc::DirUsage::m_NFiles, m_recursive_subdir_usage, XrdPfc::DirUsage::m_StBlocks, and m_subdirs.

Referenced by XrdPfc::ResourceMonitor::perform_initial_scan().

+ Here is the caller graph for this function:

◆ upward_propagate_stats_and_times()

void DirState::upward_propagate_stats_and_times ( )

Propagate stat to parents Called from ResourceMonitor::heart_beat()

Definition at line 139 of file XrdPfcDirState.cc.

140 {
141  for (DsMap_i i = m_subdirs.begin(); i != m_subdirs.end(); ++i)
142  {
143  i->second.upward_propagate_stats_and_times();
144 
145  m_recursive_subdir_stats.AddUp(i->second.m_recursive_subdir_stats);
146  m_recursive_subdir_stats.AddUp(i->second.m_here_stats);
147  // nothing to do for m_here_stats.
148 
149  m_recursive_subdir_usage.update_last_times(i->second.m_recursive_subdir_usage);
150  m_recursive_subdir_usage.update_last_times(i->second.m_here_usage);
151  }
152 }
void AddUp(const DirStats &s)
Definition: XrdPfcStats.hh:187
void update_last_times(const DirUsage &u)

References XrdPfc::DirStats::AddUp(), m_recursive_subdir_stats, m_recursive_subdir_usage, m_subdirs, and XrdPfc::DirUsage::update_last_times().

Referenced by XrdPfc::DataFsState::upward_propagate_stats_and_times().

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

Member Data Documentation

◆ m_depth

◆ m_here_stats

DirStats XrdPfc::DirState::m_here_stats

◆ m_here_usage

◆ m_parent

DirState* XrdPfc::DirState::m_parent = nullptr

Definition at line 137 of file XrdPfcDirState.hh.

Referenced by get_parent().

◆ m_recursive_subdir_stats

DirStats XrdPfc::DirState::m_recursive_subdir_stats

◆ m_recursive_subdir_usage

◆ m_scanned

bool XrdPfc::DirState::m_scanned = false

Definition at line 140 of file XrdPfcDirState.hh.

Referenced by XrdPfc::ResourceMonitor::scan_dir_and_recurse().

◆ m_subdirs


The documentation for this struct was generated from the following files: