From 1e04ceddeedee8ab726788a3cffb427f357496f2 Mon Sep 17 00:00:00 2001 From: Andreas Joachim Peters Date: Wed, 8 Jan 2025 09:08:44 +0100 Subject: [PATCH] MGM: add two new policies "policy.updateconversion","policy.readconversion" aka "sys.forced.policy.updateconversion" and "sys.forced.policy.updateconversion" allowing to specify an inline conversion when a file is read or updated. --- mgm/Policy.cc | 311 +++++++++++++++++++++++++++----------------------- mgm/Policy.hh | 95 ++++++++------- 2 files changed, 217 insertions(+), 189 deletions(-) diff --git a/mgm/Policy.cc b/mgm/Policy.cc index 8ea945739..c5cfb74e4 100644 --- a/mgm/Policy.cc +++ b/mgm/Policy.cc @@ -22,39 +22,29 @@ ************************************************************************/ /*----------------------------------------------------------------------------*/ -#include "common/Logging.hh" +#include "mgm/Policy.hh" #include "common/LayoutId.hh" +#include "common/Logging.hh" #include "common/Mapping.hh" #include "common/Utils.hh" #include "common/utils/ContainerUtils.hh" #include "common/utils/XrdUtils.hh" #include "mgm/Constants.hh" -#include "mgm/Policy.hh" #include "mgm/XrdMgmOfs.hh" /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ - EOSMGMNAMESPACE_BEGIN const std::vector Policy::gBasePolicyKeys = { - "policy.space", - "policy.layout", - "policy.nstripes", - "policy.checksum", - "policy.blocksize", - "policy.blockchecksum", - "policy.localredirect" -}; + "policy.space", "policy.layout", "policy.nstripes", + "policy.checksum", "policy.blocksize", "policy.blockchecksum", + "policy.localredirect", "policy.updateconversion","policy.readconversion"}; const std::vector Policy::gBasePolicyRWKeys = { - "policy.bandwidth", - "policy.iopriority", - "policy.iotype", - "policy.schedule" -}; - + "policy.bandwidth", "policy.iopriority", "policy.iotype", + "policy.schedule"}; /*----------------------------------------------------------------------------*/ double @@ -69,25 +59,13 @@ Policy::GetDefaultSizeFactor(std::shared_ptr cmd) bool schedule = 0; std::string iopriority; std::string iotype; - bool isrw = false; // does not matter + bool isrw = false; // does not matter uint64_t atimeage = 0; // does not matter eos::IContainerMD::XAttrMap attrmap = cmd->getAttributes(); eos::common::VirtualIdentity rootvid = eos::common::VirtualIdentity::Root(); - GetLayoutAndSpace("/", - attrmap, - rootvid, - layoutid, - ret_space, - env, - forcedfsid, - forcedgroup, - bandwidth, - schedule, - iopriority, - iotype, - isrw, - false, - &atimeage); + GetLayoutAndSpace("/", attrmap, rootvid, layoutid, ret_space, env, forcedfsid, + forcedgroup, bandwidth, schedule, iopriority, iotype, isrw, + false, &atimeage); double f = eos::common::LayoutId::GetSizeFactor(layoutid); return f ? f : 1.0; } @@ -107,25 +85,13 @@ Policy::GetSpacePolicyLayout(const char* space) bool schedule = 0; std::string iopriority; std::string iotype; - bool isrw = false; // does not matter + bool isrw = false; // does not matter uint64_t atimeage = 0; // does not matter eos::IContainerMD::XAttrMap attrmap; eos::common::VirtualIdentity rootvid = eos::common::VirtualIdentity::Root(); - GetLayoutAndSpace("/", - attrmap, - rootvid, - layoutid, - ret_space, - env, - forcedfsid, - forcedgroup, - bandwidth, - schedule, - iopriority, - iotype, - isrw, - true, - &atimeage); + GetLayoutAndSpace("/", attrmap, rootvid, layoutid, ret_space, env, forcedfsid, + forcedgroup, bandwidth, schedule, iopriority, iotype, isrw, + true, &atimeage); return layoutid; } @@ -135,15 +101,10 @@ Policy::GetLayoutAndSpace(const char* path, eos::IContainerMD::XAttrMap& attrmap, const eos::common::VirtualIdentity& vid, unsigned long& layoutId, std::string& space, - XrdOucEnv& env, - unsigned long& forcedfsid, - long& forcedgroup, - std::string& bandwidth, - bool& schedule, - std::string& iopriority, - std::string& iotype, - bool rw, - bool lockview, + XrdOucEnv& env, unsigned long& forcedfsid, + long& forcedgroup, std::string& bandwidth, + bool& schedule, std::string& iopriority, + std::string& iotype, bool rw, bool lockview, uint64_t* atimeage) { eos::common::RWMutexReadLock lock; @@ -161,9 +122,9 @@ Policy::GetLayoutAndSpace(const char* path, std::map spacepolicies; std::map spacerwpolicies; std::string satime; - RWParams rwparams {vid.uid_string, vid.gid_string, - eos::common::XrdUtils::GetEnv(env, "eos.app", "default"), - rw}; + RWParams rwparams{vid.uid_string, vid.gid_string, + eos::common::XrdUtils::GetEnv(env, "eos.app", "default"), + rw}; auto policy_keys = GetConfigKeys(); auto policy_rw_keys = GetRWConfigKeys(rwparams); @@ -176,10 +137,8 @@ Policy::GetLayoutAndSpace(const char* path, auto it = FsView::gFsView.mSpaceView.find("default"); if (it != FsView::gFsView.mSpaceView.end()) { - it->second->GetConfigMembers(policy_keys, - spacepolicies); - it->second->GetConfigMembers(policy_rw_keys, - spacerwpolicies); + it->second->GetConfigMembers(policy_keys, spacepolicies); + it->second->GetConfigMembers(policy_rw_keys, spacerwpolicies); satime = it->second->GetConfigMember("atime"); } // FSView default @@ -204,7 +163,7 @@ Policy::GetLayoutAndSpace(const char* path, std::string space_key = "policy.space"; if (auto kv = spacepolicies.find(space_key); - kv != spacepolicies.end() && (! kv->second.empty())) { + kv != spacepolicies.end() && (!kv->second.empty())) { // if there is no explicit space given, we preset with the policy one space = kv->second.c_str(); } @@ -214,7 +173,7 @@ Policy::GetLayoutAndSpace(const char* path, // Replace the non empty settings from the default space have been already // defined before if (!conversion && space != "default") { - std::map nondefault_policies; + std::map nondefault_policies; spacerwpolicies.clear(); if (lockview) { @@ -224,10 +183,8 @@ Policy::GetLayoutAndSpace(const char* path, auto it = FsView::gFsView.mSpaceView.find(space.c_str()); if (it != FsView::gFsView.mSpaceView.end()) { - it->second->GetConfigMembers(policy_keys, - nondefault_policies); - it->second->GetConfigMembers(policy_rw_keys, - spacerwpolicies); + it->second->GetConfigMembers(policy_keys, nondefault_policies); + it->second->GetConfigMembers(policy_rw_keys, spacerwpolicies); satime = it->second->GetConfigMember("atime"); } // FsView; @@ -237,10 +194,9 @@ Policy::GetLayoutAndSpace(const char* path, // Since this map only contains keys that are already populated, we can be // sure that we'll be only replacing non empty keys - for (auto && kv : nondefault_policies) { + for (auto&& kv : nondefault_policies) { if (!kv.second.empty()) { - spacepolicies.insert_or_assign(kv.first, - std::move(kv.second)); + spacepolicies.insert_or_assign(kv.first, std::move(kv.second)); } } @@ -260,19 +216,18 @@ Policy::GetLayoutAndSpace(const char* path, continue; } - std::string sys_key = "sys.forced."; + std::string sys_key = "sys.forced."; std::string user_key = "user.forced."; - sys_key += key_name; + sys_key += key_name; user_key += key_name; - if ((!attrmap.count(sys_key)) && - (!attrmap.count(user_key)) && + if ((!attrmap.count(sys_key)) && (!attrmap.count(user_key)) && !it.second.empty()) { attrmap[sys_key] = it.second; } } - forcedgroup = eos::common::XrdUtils::GetEnv(env, "eos.group", (long) - 1); + forcedgroup = eos::common::XrdUtils::GetEnv(env, "eos.group", (long)-1); if ((xsum != eos::common::LayoutId::kNone) && (val = env.Get("eos.checksum.noforce"))) { @@ -286,36 +241,37 @@ Policy::GetLayoutAndSpace(const char* path, } else { if (auto space_kv = attrmap.find(SYS_FORCED_SPACE); space_kv != attrmap.end()) { - // we force to use a certain space in this directory even if the user wants something else + // we force to use a certain space in this directory even if the user + // wants something else space = space_kv->second.c_str(); eos_static_debug("sys.forced.space in %s", path); } if (auto forcedgroup_kv = attrmap.find(SYS_FORCED_GROUP); forcedgroup_kv != attrmap.end()) { - // we force to use a certain group in this directory even if the user wants something else + // we force to use a certain group in this directory even if the user + // wants something else eos::common::StringToNumeric(forcedgroup_kv->second, forcedgroup); eos_static_debug("sys.forced.group in %s", path); } - if (auto kv = attrmap.find(SYS_FORCED_LAYOUT); - kv != attrmap.end()) { - // we force to use a specified layout in this directory even if the user wants something else + if (auto kv = attrmap.find(SYS_FORCED_LAYOUT); kv != attrmap.end()) { + // we force to use a specified layout in this directory even if the user + // wants something else layout = eos::common::LayoutId::GetLayoutFromString(kv->second); eos_static_debug("sys.forced.layout in %s", path); } if (!noforcedchecksum) { - if (auto kv = attrmap.find(SYS_FORCED_CHECKSUM); - kv != attrmap.end()) { - // we force to use a specified checksumming in this directory even if the user wants something else + if (auto kv = attrmap.find(SYS_FORCED_CHECKSUM); kv != attrmap.end()) { + // we force to use a specified checksumming in this directory even if + // the user wants something else xsum = eos::common::LayoutId::GetChecksumFromString(kv->second); eos_static_debug("sys.forced.checksum in %s", path); } } - if (auto kv = attrmap.find(SYS_FORCED_BLOCKCHECKSUM); - kv != attrmap.end()) { + if (auto kv = attrmap.find(SYS_FORCED_BLOCKCHECKSUM); kv != attrmap.end()) { bxsum = eos::common::LayoutId::GetBlockChecksumFromString(kv->second); eos_static_debug("sys.forced.blockchecksum in %s %x", path, bxsum); } @@ -324,7 +280,8 @@ Policy::GetLayoutAndSpace(const char* path, XrdOucString layoutstring = "eos.layout.nstripes="; layoutstring += attrmap["sys.forced.nstripes"].c_str(); XrdOucEnv layoutenv(layoutstring.c_str()); - // we force to use a specified stripe number in this directory even if the user wants something else + // we force to use a specified stripe number in this directory even if the + // user wants something else stripes = eos::common::LayoutId::GetStripeNumberFromEnv(layoutenv); eos_static_debug("sys.forced.nstripes in %s", path); } @@ -333,7 +290,8 @@ Policy::GetLayoutAndSpace(const char* path, XrdOucString layoutstring = "eos.layout.blocksize="; layoutstring += attrmap["sys.forced.blocksize"].c_str(); XrdOucEnv layoutenv(layoutstring.c_str()); - // we force to use a specified stripe width in this directory even if the user wants something else + // we force to use a specified stripe width in this directory even if the + // user wants something else blocksize = eos::common::LayoutId::GetBlocksizeFromEnv(layoutenv); eos_static_debug("sys.forced.blocksize in %s : %llu", path, blocksize); } @@ -345,24 +303,26 @@ Policy::GetLayoutAndSpace(const char* path, eos_static_debug("sys.forced.iotype i %s : %s", path, iotype.c_str()); } - std::string iopriorityattr = rw ? "sys.forced.iopriority:w" : - "sys.forced.iopriority:r"; + std::string iopriorityattr = + rw ? "sys.forced.iopriority:w" : "sys.forced.iopriority:r"; if (attrmap.count(iopriorityattr)) { iopriority = attrmap[iopriorityattr]; - eos_static_debug("sys.forced.iopriority i %s : %s", path, iopriority.c_str()); + eos_static_debug("sys.forced.iopriority i %s : %s", path, + iopriority.c_str()); } - std::string bandwidthattr = rw ? "sys.forced.bandwidth:w" : - "sys.forced.bandwidth:r"; + std::string bandwidthattr = + rw ? "sys.forced.bandwidth:w" : "sys.forced.bandwidth:r"; if (attrmap.count(bandwidthattr)) { bandwidth = attrmap[bandwidthattr]; - eos_static_debug("sys.forced.bandwidth i %s : %s", path, bandwidth.c_str()); + eos_static_debug("sys.forced.bandwidth i %s : %s", path, + bandwidth.c_str()); } - std::string scheduleattr = rw ? "sys.forced.schedule:w" : - "sys.forced.schedule:r"; + std::string scheduleattr = + rw ? "sys.forced.schedule:w" : "sys.forced.schedule:r"; if (attrmap.count(scheduleattr)) { schedule = (attrmap[scheduleattr] == "1"); @@ -374,22 +334,23 @@ Policy::GetLayoutAndSpace(const char* path, ((!attrmap.count("user.forced.nouserlayout")) || (attrmap["user.forced.nouserlayout"] != "1"))) { if (attrmap.count("user.forced.space")) { - // we force to use a certain space in this directory even if the user wants something else + // we force to use a certain space in this directory even if the user + // wants something else space = attrmap["user.forced.space"].c_str(); eos_static_debug("user.forced.space in %s", path); } - if (auto kv = attrmap.find(USER_FORCED_LAYOUT); - kv != attrmap.end()) { - // we force to use a specified layout in this directory even if the user wants something else + if (auto kv = attrmap.find(USER_FORCED_LAYOUT); kv != attrmap.end()) { + // we force to use a specified layout in this directory even if the user + // wants something else layout = eos::common::LayoutId::GetLayoutFromString(kv->second); eos_static_debug("user.forced.layout in %s", path); } if (!noforcedchecksum) { - if (auto kv = attrmap.find(USER_FORCED_CHECKSUM); - kv != attrmap.end()) { - // we force to use a specified checksumming in this directory even if the user wants something else + if (auto kv = attrmap.find(USER_FORCED_CHECKSUM); kv != attrmap.end()) { + // we force to use a specified checksumming in this directory even if + // the user wants something else xsum = eos::common::LayoutId::GetChecksumFromString(kv->second); eos_static_debug("user.forced.checksum in %s", path); } @@ -397,7 +358,8 @@ Policy::GetLayoutAndSpace(const char* path, if (auto kv = attrmap.find(USER_FORCED_BLOCKCHECKSUM); kv != attrmap.end()) { - // we force to use a specified checksumming in this directory even if the user wants something else + // we force to use a specified checksumming in this directory even if + // the user wants something else bxsum = eos::common::LayoutId::GetBlockChecksumFromString(kv->second); eos_static_debug("user.forced.blockchecksum in %s", path); } @@ -406,7 +368,8 @@ Policy::GetLayoutAndSpace(const char* path, XrdOucString layoutstring = "eos.layout.nstripes="; layoutstring += attrmap["user.forced.nstripes"].c_str(); XrdOucEnv layoutenv(layoutstring.c_str()); - // we force to use a specified stripe number in this directory even if the user wants something else + // we force to use a specified stripe number in this directory even if + // the user wants something else stripes = eos::common::LayoutId::GetStripeNumberFromEnv(layoutenv); eos_static_debug("user.forced.nstripes in %s", path); } @@ -415,7 +378,8 @@ Policy::GetLayoutAndSpace(const char* path, XrdOucString layoutstring = "eos.layout.blocksize="; layoutstring += attrmap["user.forced.blocksize"].c_str(); XrdOucEnv layoutenv(layoutstring.c_str()); - // we force to use a specified stripe width in this directory even if the user wants something else + // we force to use a specified stripe width in this directory even if + // the user wants something else blocksize = eos::common::LayoutId::GetBlocksizeFromEnv(layoutenv); eos_static_debug("user.forced.blocksize in %s", path); } @@ -436,17 +400,15 @@ Policy::GetLayoutAndSpace(const char* path, *atimeage = std::stoull(satime.c_str(), 0, 10); } - layoutId = eos::common::LayoutId::GetId(layout, xsum, stripes, blocksize, - bxsum); + layoutId = + eos::common::LayoutId::GetId(layout, xsum, stripes, blocksize, bxsum); return; } /*----------------------------------------------------------------------------*/ void -Policy::GetPlctPolicy(const char* path, - eos::IContainerMD::XAttrMap& attrmap, - const eos::common::VirtualIdentity& vid, - XrdOucEnv& env, +Policy::GetPlctPolicy(const char* path, eos::IContainerMD::XAttrMap& attrmap, + const eos::common::VirtualIdentity& vid, XrdOucEnv& env, eos::mgm::Scheduler::tPlctPolicy& plctpol, std::string& targetgeotag) { @@ -463,7 +425,8 @@ Policy::GetPlctPolicy(const char* path, if ((vid.uid == 0) && (val = env.Get("eos.placementpolicy.noforce"))) { // root can request not to apply any forced settings } else if (attrmap.count("sys.forced.placementpolicy")) { - // we force to use a certain placement policy even if the user wants something else + // we force to use a certain placement policy even if the user wants + // something else policyString = attrmap["sys.forced.placementpolicy"].c_str(); eos_static_debug("sys.forced.placementpolicy in %s", path); } else { @@ -489,8 +452,9 @@ Policy::GetPlctPolicy(const char* path, // if no target geotag is provided, it's not a valid placement policy if (seppos == std::string::npos || seppos == policyString.length() - 1) { - eos_static_warning("no geotag given in placement policy for path %s : \"%s\"", - path, policyString.c_str()); + eos_static_warning( + "no geotag given in placement policy for path %s : \"%s\"", path, + policyString.c_str()); return; } @@ -515,20 +479,18 @@ Policy::GetPlctPolicy(const char* path, return; } - /*----------------------------------------------------------------------------*/ Policy::RedirectStatus -Policy::RedirectLocal(const char* path, - eos::IContainerMD::XAttrMap& map, +Policy::RedirectLocal(const char* path, eos::IContainerMD::XAttrMap& map, const eos::common::VirtualIdentity& vid, - unsigned long& layoutId, - const std::string& space, - XrdOucEnv& env - ) + unsigned long& layoutId, const std::string& space, + XrdOucEnv& env) { std::string rkey = "sys.forced.localredirect"; - if (map.count(rkey) && ((map[rkey] == "true") || (map[rkey] == "1") || (map[rkey] == "always")) && + if (map.count(rkey) && + ((map[rkey] == "true") || (map[rkey] == "1") || + (map[rkey] == "always")) && ((eos::common::LayoutId::GetLayoutType(layoutId) == eos::common::LayoutId::kReplica) || (eos::common::LayoutId::GetLayoutType(layoutId) == @@ -541,7 +503,7 @@ Policy::RedirectLocal(const char* path, } } - if (map.count(rkey) && ((map[rkey] == "optional") || (map[rkey] == "2")) && + if (map.count(rkey) && ((map[rkey] == "optional") || (map[rkey] == "2")) && ((eos::common::LayoutId::GetLayoutType(layoutId) == eos::common::LayoutId::kReplica) || (eos::common::LayoutId::GetLayoutType(layoutId) == @@ -562,6 +524,80 @@ Policy::RedirectLocal(const char* path, } } +// enum ConversionPolicy { +// eSync, +// eAsync, +// eNone, +// eFail +// }; + +/*----------------------------------------------------------------------------*/ +Policy::ConversionPolicy +Policy::UpdateConversion(const char* path, eos::IContainerMD::XAttrMap& map, + const eos::common::VirtualIdentity& vid, + unsigned long& layoutId, const std::string& space, + XrdOucEnv& env, unsigned long& targetLayoutId, + std::string& target_space) +{ + std::string rkey = "sys.forced.updateconversion"; + if (map.count(rkey)) { + std::string tspace; + std::string tlayout; + bool split = eos::common::StringConversion::SplitKeyValue(map[rkey], tspace, + tlayout); + if (!split) { + return Policy::eFail; + } + // return space and layout id + target_space = tspace; + targetLayoutId = std::stoi(tlayout, nullptr, 16); + + if ((space == target_space) && (layoutId == targetLayoutId)) { + // this is already with the desired layout and space + return eNone; + } + + return Policy::eAsync; // for the moment we don't want anything synchronous + // happening in the MGM + } else { + // nothing to convert + return Policy::eNone; + } +} + +/*----------------------------------------------------------------------------*/ +Policy::ConversionPolicy +Policy::ReadConversion(const char* path, eos::IContainerMD::XAttrMap& map, + const eos::common::VirtualIdentity& vid, + unsigned long& layoutId, const std::string& space, + XrdOucEnv& env, unsigned long& targetLayoutId, + std::string& target_space) +{ + std::string rkey = "sys.forced.readconversion"; + if (map.count(rkey)) { + std::string tspace; + std::string tlayout; + bool split = eos::common::StringConversion::SplitKeyValue(map[rkey], tspace, + tlayout); + if (!split) { + return Policy::eFail; + } + // return space and layout id + target_space = tspace; + targetLayoutId = std::stoi(tlayout, nullptr, 16); + + if ((space == target_space) && (layoutId == targetLayoutId)) { + // this is already with the desired layout and space + return eNone; + } + + return Policy::eAsync; // for the moment we don't want anything synchronous + // happening in the MGM + } else { + // nothing to convert + return Policy::eNone; + } +} /*----------------------------------------------------------------------------*/ bool @@ -620,7 +656,9 @@ Policy::Set(XrdOucEnv& env, int& retc, XrdOucString& stdOut, /*----------------------------------------------------------------------------*/ void Policy::Ls(XrdOucEnv& env, int& retc, XrdOucString& stdOut, - XrdOucString& stdErr) { } + XrdOucString& stdErr) +{ +} /*----------------------------------------------------------------------------*/ bool @@ -655,10 +693,9 @@ Policy::GetRWValue(const std::map& conf_map, const std::string& key_name, const RWParams& params, std::string& value) { - for (auto && k : params.getKeys(key_name)) { + for (auto&& k : params.getKeys(key_name)) { if (const auto& kv = conf_map.find(k); - kv != conf_map.end() && - !kv->second.empty()) { + kv != conf_map.end() && !kv->second.empty()) { value = kv->second; } } @@ -671,24 +708,18 @@ Policy::GetRWConfigKeys(const RWParams& params) config_keys.reserve(16); for (const auto& _key : gBasePolicyRWKeys) { - eos::common::splice(config_keys, - params.getKeys(_key)); + eos::common::splice(config_keys, params.getKeys(_key)); } return config_keys; } - std::vector Policy::RWParams::getKeys(const std::string& key) const { auto key_name = getKey(key); - return { - key_name + app_key, - key_name + user_key, - key_name + group_key, - key_name - }; + return {key_name + app_key, key_name + user_key, key_name + group_key, + key_name}; } EOSMGMNAMESPACE_END diff --git a/mgm/Policy.hh b/mgm/Policy.hh index 7640e28f9..4fe821c67 100644 --- a/mgm/Policy.hh +++ b/mgm/Policy.hh @@ -25,13 +25,13 @@ #define __EOSMGM_POLICY__HH__ /*----------------------------------------------------------------------------*/ +#include "common/Mapping.hh" #include "mgm/Namespace.hh" #include "mgm/Scheduler.hh" -#include "common/Mapping.hh" #include "namespace/interface/IContainerMD.hh" /*----------------------------------------------------------------------------*/ -#include #include +#include /*----------------------------------------------------------------------------*/ #include @@ -39,53 +39,53 @@ EOSMGMNAMESPACE_BEGIN -class Policy -{ +class Policy { public: + Policy() {}; - Policy() { }; - - ~Policy() { }; + ~Policy() {}; static void GetLayoutAndSpace(const char* path, eos::IContainerMD::XAttrMap& map, const eos::common::VirtualIdentity& vid, - unsigned long& layoutId, - std::string& space, - XrdOucEnv& env, - unsigned long& forcedfsid, - long& forcedgroup, - std::string& bandwidth, - bool& schedul, - std::string& iopriority, - std::string& ioptype, - bool isrw, - bool lock_view = false, - uint64_t* atimeage = 0); - - static void GetPlctPolicy(const char* path, - eos::IContainerMD::XAttrMap& map, + unsigned long& layoutId, std::string& space, + XrdOucEnv& env, unsigned long& forcedfsid, + long& forcedgroup, std::string& bandwidth, + bool& schedul, std::string& iopriority, + std::string& ioptype, bool isrw, + bool lock_view = false, uint64_t* atimeage = 0); + + static void GetPlctPolicy(const char* path, eos::IContainerMD::XAttrMap& map, const eos::common::VirtualIdentity& vid, XrdOucEnv& env, eos::mgm::Scheduler::tPlctPolicy& plctpo, std::string& targetgeotag); - enum RedirectStatus { - eNever, - eAlways, - eOptional - }; + enum RedirectStatus { eNever, eAlways, eOptional }; static RedirectStatus RedirectLocal(const char* path, - eos::IContainerMD::XAttrMap& map, - const eos::common::VirtualIdentity& vid, - unsigned long& layoutId, - const std::string& space, - XrdOucEnv& env - ); + eos::IContainerMD::XAttrMap& map, + const eos::common::VirtualIdentity& vid, + unsigned long& layoutId, + const std::string& space, XrdOucEnv& env); + + enum ConversionPolicy { eSync, eAsync, eNone, eFail }; + + static ConversionPolicy + UpdateConversion(const char* path, eos::IContainerMD::XAttrMap& map, + const eos::common::VirtualIdentity& vid, + unsigned long& layoutId, const std::string& space, + XrdOucEnv& env, unsigned long& targetLayoutId, + std::string& target_space); + + static ConversionPolicy + ReadConversion(const char* path, eos::IContainerMD::XAttrMap& map, + const eos::common::VirtualIdentity& vid, + unsigned long& layoutId, const std::string& space, + XrdOucEnv& env, unsigned long& targetLayoutId, + std::string& target_space); static unsigned long GetSpacePolicyLayout(const char* space); - static bool Set(const char* value); static bool Set(XrdOucEnv& env, int& retc, XrdOucString& stdOut, XrdOucString& stdErr); @@ -94,14 +94,14 @@ public: static bool Rm(XrdOucEnv& env, int& retc, XrdOucString& stdOut, XrdOucString& stdErr); - static bool IsProcConversion(const char* path); static const char* Get(const char* key); struct RWParams; - static inline std::vector GetConfigKeys() + static inline std::vector + GetConfigKeys() { return gBasePolicyKeys; } @@ -109,8 +109,7 @@ public: static std::vector GetRWConfigKeys(const RWParams& params); static void GetRWValue(const std::map& conf_map, - const std::string& key_name, - const RWParams& params, + const std::string& key_name, const RWParams& params, std::string& value); static const std::vector gBasePolicyKeys; @@ -125,17 +124,15 @@ public: std::string app_key; std::string rw_marker; - RWParams(const std::string& user_str, - const std::string& group_str, - const std::string& app_str, - bool is_rw) : - user_key(".user:" + user_str), - group_key(".group:" + group_str), - app_key(".app:" + app_str), - rw_marker(is_rw ? ":w" : ":r") - {} - - std::string getKey(const std::string& key) const + RWParams(const std::string& user_str, const std::string& group_str, + const std::string& app_str, bool is_rw) + : user_key(".user:" + user_str), group_key(".group:" + group_str), + app_key(".app:" + app_str), rw_marker(is_rw ? ":w" : ":r") + { + } + + std::string + getKey(const std::string& key) const { return key + rw_marker; }