4 #include "XrdOuc/XrdOucJson.hh"
12 #define PFC_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
13 inline void to_json(nlohmann::json &nlohmann_json_j, const Type &nlohmann_json_t) { \
14 NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \
16 inline void from_json(const nlohmann::json &nlohmann_json_j, Type &nlohmann_json_t) { \
17 NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \
19 inline void to_json(nlohmann::ordered_json &nlohmann_json_j, const Type &nlohmann_json_t) { \
20 NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) \
22 inline void from_json(const nlohmann::ordered_json &nlohmann_json_j, Type &nlohmann_json_t) { \
23 NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) \
29 m_NumIos, m_Duration, m_BytesHit, m_BytesMissed, m_BytesBypassed, m_BytesWritten, m_StBlocksAdded, m_NCksumErrors,
30 m_StBlocksRemoved, m_NFilesOpened, m_NFilesClosed, m_NFilesCreated, m_NFilesRemoved, m_NDirectoriesCreated, m_NDirectoriesRemoved)
34 m_dir_name, m_stats, m_usage,
35 m_parent, m_daughters_begin, m_daughters_end)
44 void open_ofstream(std::ofstream &ofs,
const std::string &fname,
const char *pfx =
nullptr)
46 ofs.open(fname, std::ofstream::trunc);
50 snprintf(m, 2048,
"%s%sError opening %s for write: %m", pfx ? pfx :
"", pfx ?
" " :
"", fname.c_str());
51 throw std::runtime_error(m);
63 open_ofstream(ofs, fname, __func__);
67 ofs <<
"{ \"dirstate_snapshot\": ";
70 nlohmann::ordered_json j;
87 nlohmann::ordered_json j;
89 std::cout << j.dump(3) <<
"\n";
106 if (last_existing_entry)
107 *last_existing_entry = entry;
120 return entry >= 0 ? &
m_dir_vec[entry].m_usage :
nullptr;
m_NDirectories m_usage_update_time
m_NDirectories m_meta_total
m_NDirectories m_meta_used
m_NDirectories m_stats_reset_time
m_NDirectories m_disk_used
m_NDirectories m_disk_total
PFC_DEFINE_TYPE_NON_INTRUSIVE(DirStats, m_NumIos, m_Duration, m_BytesHit, m_BytesMissed, m_BytesBypassed, m_BytesWritten, m_StBlocksAdded, m_NCksumErrors, m_StBlocksRemoved, m_NFilesOpened, m_NFilesClosed, m_NFilesCreated, m_NFilesRemoved, m_NDirectoriesCreated, m_NDirectoriesRemoved) PFC_DEFINE_TYPE_NON_INTRUSIVE(DirUsage
m_NDirectories m_file_usage
int find_dir_entry_from_tok(int entry, PathTokenizer &pt, int pos, int *last_existing_entry) const
std::vector< DirPurgeElement > m_dir_vec
int find_dir_entry_for_dir_path(const std::string &dir_path) const
const DirUsage * find_dir_usage_for_dir_path(const std::string &dir_path) const
void write_json_file(const std::string &fname, bool include_preamble)
const char * get_dir(int pos)