Commit 51aad268 authored by Georgios Bitzes's avatar Georgios Bitzes

MGM: Add skeleton for quotanode recomputation command

parent ead1f659
Pipeline #467648 canceled with stages
in 4 minutes 4 seconds
......@@ -250,6 +250,32 @@ NsHelper::ParseCommand(const char* arg)
}
}
}
} else if (cmd == "recompute_quotanode") {
using eos::console::NsProto_QuotaSizeProto;
NsProto_QuotaSizeProto* quota = ns->mutable_quota();
if (!(option = tokenizer.GetToken())) {
return false;
} else {
while (true) {
int pos = 0;
soption = option;
if ((soption.find("cid:") == 0)) {
pos = soption.find(':') + 1;
quota->mutable_container()->set_cid(soption.substr(pos));
} else if (soption.find("cxid:") == 0) {
pos = soption.find(':') + 1;
quota->mutable_container()->set_cxid(soption.substr(pos));
} else { // this should be a plain path
quota->mutable_container()->set_path(soption);
}
if (!(option = tokenizer.GetToken())) {
break;
}
}
}
} else if (cmd == "cache") {
eos::console::NsProto_CacheProto* cache = ns->mutable_cache();
......@@ -403,6 +429,12 @@ void com_ns_help()
<< " --depth : maximum depth for recomputation, default 0 i.e no limit"
<< std::endl
<< std::endl
<< " ns recompute_quotanode <path>|cid:<decimal_id>|cxid:<hex_id>"
<< std::endl
<< " recompute the specified quotanode"
<< std::endl
<< std::endl
<< std::endl
<< " ns cache set|drop [-d|-f] [<max_num>] [<max_size>K|M|G...]" << std::endl
<< " set the max number of entries or the max size of the cache. Use the" <<
std::endl
......
......@@ -32,6 +32,7 @@
#include "namespace/interface/ContainerIterators.hh"
#include "namespace/ns_quarkdb/Constants.hh"
#include "namespace/Resolver.hh"
#include "namespace/Constants.hh"
#include "mgm/XrdMgmOfs.hh"
#include "mgm/Quota.hh"
#include "mgm/Stat.hh"
......@@ -64,6 +65,8 @@ NsCmd::ProcessRequest()
TreeSizeSubcmd(ns.tree(), reply);
} else if (subcmd == eos::console::NsProto::kCache) {
CacheSubcmd(ns.cache(), reply);
} else if (subcmd == eos::console::NsProto::kQuota) {
QuotaSizeSubcmd(ns.quota(), reply);
} else {
reply.set_retc(EINVAL);
reply.set_std_err("error: not supported");
......@@ -551,9 +554,7 @@ void
NsCmd::TreeSizeSubcmd(const eos::console::NsProto_TreeSizeProto& tree,
eos::console::ReplyProto& reply)
{
using eos::console::NsProto_TreeSizeProto;
eos::common::RWMutexWriteLock ns_wr_lock(gOFS->eosViewRWMutex);
std::shared_ptr<IContainerMD> cont;
try {
......@@ -590,6 +591,35 @@ NsCmd::TreeSizeSubcmd(const eos::console::NsProto_TreeSizeProto& tree,
}
//------------------------------------------------------------------------------
// Execute quota size recompute comand
//------------------------------------------------------------------------------
void
NsCmd::QuotaSizeSubcmd(const eos::console::NsProto_QuotaSizeProto& tree,
eos::console::ReplyProto& reply)
{
std::shared_ptr<IContainerMD> cont;
try {
cont = eos::Resolver::resolveContainer(gOFS->eosView, tree.container());
}
catch(const eos::MDException& e) {
reply.set_std_err(SSTR(e.what()));
reply.set_retc(e.getErrno());
return;
}
if( (cont->getFlags() & eos::QUOTA_NODE_FLAG) == 0) {
reply.set_std_err("Specified directory is not a quota node.");
reply.set_retc(EINVAL);
return;
}
reply.set_std_err("TODO LOL");
reply.set_retc(EINVAL);
return;
}
//------------------------------------------------------------------------------
// Recompute and update tree size of the given container assumming its
// subcontainers tree size values are correct and adding the size of files
// attached directly to the current container
......
......@@ -104,6 +104,15 @@ private:
eos::console::ReplyProto& reply);
//----------------------------------------------------------------------------
//! Execute quota size recompute
//!
//! @param quota size subcommand proto object
//! @param reply reply proto object
//----------------------------------------------------------------------------
void QuotaSizeSubcmd(const eos::console::NsProto_QuotaSizeProto& tree,
eos::console::ReplyProto& reply);
//----------------------------------------------------------------------------
//! Execute cache update command
//!
//! @param cache cache subcommand proto object
......
......@@ -62,6 +62,10 @@ message NsProto {
ContainerSpecificationProto container = 2;
}
message QuotaSizeProto {
ContainerSpecificationProto container = 1;
}
message CacheProto {
enum OpType {
SET_FILE = 0;
......@@ -83,5 +87,6 @@ message NsProto {
MasterProto master = 4;
TreeSizeProto tree = 5;
CacheProto cache = 6;
QuotaSizeProto quota = 7;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment