Commit 36a8aee1 authored by Georgios Bitzes's avatar Georgios Bitzes

PROTO: Make container specifier on (path, cid, cxid) independent

Will allow to make utility functions for resolving based on
oneof {path, cid, cxid} and prevent duplicated code.
parent 9adbc17e
Pipeline #467198 canceled with stages
in 3 minutes and 17 seconds
......@@ -237,12 +237,12 @@ NsHelper::ParseCommand(const char* arg)
}
} else if ((soption.find("cid:") == 0)) {
pos = soption.find(':') + 1;
tree->set_cid(soption.substr(pos));
tree->mutable_container()->set_cid(soption.substr(pos));
} else if (soption.find("cxid:") == 0) {
pos = soption.find(':') + 1;
tree->set_cxid(soption.substr(pos));
tree->mutable_container()->set_cxid(soption.substr(pos));
} else { // this should be a plain path
tree->set_path(soption);
tree->mutable_container()->set_path(soption);
}
if (!(option = tokenizer.GetToken())) {
......
......@@ -551,15 +551,17 @@ NsCmd::TreeSizeSubcmd(const eos::console::NsProto_TreeSizeProto& tree,
eos::console::ReplyProto& reply)
{
using eos::console::NsProto_TreeSizeProto;
using eos::console::NsProto_ContainerSpecificationProto;
std::ostringstream oss;
NsProto_TreeSizeProto::ContainerCase cont_type = tree.container_case();
eos::console::NsProto_ContainerSpecificationProto::ContainerCase cont_type =
tree.container().container_case();
eos::common::RWMutexWriteLock ns_wr_lock(gOFS->eosViewRWMutex);
std::shared_ptr<IContainerMD> cont {nullptr};
if (cont_type == NsProto_TreeSizeProto::kPath) {
if (cont_type == NsProto_ContainerSpecificationProto::kPath) {
try {
// @todo (esindril): how to deal with symlinks
cont = gOFS->eosView->getContainer(tree.path());
cont = gOFS->eosView->getContainer(tree.container().path());
} catch (const eos::MDException& e) {
oss << "error: " << e.what();
reply.set_std_err(oss.str());
......@@ -570,10 +572,10 @@ NsCmd::TreeSizeSubcmd(const eos::console::NsProto_TreeSizeProto& tree,
eos::IContainerMD::id_t cid = 0;
try {
if (cont_type == NsProto_TreeSizeProto::kCid) {
cid = std::stoull(tree.cid(), nullptr, 10);
if (cont_type == NsProto_ContainerSpecificationProto::kCid) {
cid = std::stoull(tree.container().cid(), nullptr, 10);
} else {
cid = std::stoull(tree.cxid(), nullptr, 16);
cid = std::stoull(tree.container().cxid(), nullptr, 16);
}
} catch (const std::exception& e) {
oss << "error: " << e.what();
......
......@@ -103,6 +103,15 @@ private:
void TreeSizeSubcmd(const eos::console::NsProto_TreeSizeProto& tree,
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
//!
......
......@@ -49,16 +49,19 @@ message NsProto {
string Host = 2;
}
message TreeSizeProto {
uint32 depth = 1;
message ContainerSpecificationProto {
oneof container {
string path = 2;
string cid = 3;
string cxid = 4;
string path = 1;
string cid = 2;
string cxid = 3;
}
}
message TreeSizeProto {
uint32 depth = 1;
ContainerSpecificationProto container = 2;
}
message CacheProto {
enum OpType {
SET_FILE = 0;
......
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