mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
src/MDSMonitor: make use of imported namespace symbols
Symbols imported into current namespace should be used directly; there is no need to mention their parent namespace while using them. IOW, to use "std::string" after it has been imported, just write "string" instead of "std::string". Signed-off-by: Rishabh Dave <ridave@redhat.com>
This commit is contained in:
parent
7c864711e5
commit
84f1280991
@ -62,7 +62,8 @@ using ceph::mono_time;
|
||||
#define dout_subsys ceph_subsys_mon
|
||||
#undef dout_prefix
|
||||
#define dout_prefix _prefix(_dout, mon, get_fsmap())
|
||||
static ostream& _prefix(std::ostream *_dout, Monitor &mon, const FSMap& fsmap) {
|
||||
|
||||
static ostream& _prefix(ostream *_dout, Monitor &mon, const FSMap& fsmap) {
|
||||
return *_dout << "mon." << mon.name << "@" << mon.rank
|
||||
<< "(" << mon.get_state_name()
|
||||
<< ").mds e" << fsmap.get_epoch() << " ";
|
||||
@ -78,19 +79,19 @@ static const string MDS_HEALTH_PREFIX("mds_health");
|
||||
*/
|
||||
namespace TOPNSPC::common {
|
||||
template<> bool cmd_getval(const cmdmap_t& cmdmap,
|
||||
std::string_view k, mds_gid_t &val)
|
||||
string_view k, mds_gid_t &val)
|
||||
{
|
||||
return cmd_getval(cmdmap, k, (int64_t&)val);
|
||||
}
|
||||
|
||||
template<> bool cmd_getval(const cmdmap_t& cmdmap,
|
||||
std::string_view k, mds_rank_t &val)
|
||||
string_view k, mds_rank_t &val)
|
||||
{
|
||||
return cmd_getval(cmdmap, k, (int64_t&)val);
|
||||
}
|
||||
|
||||
template<> bool cmd_getval(const cmdmap_t& cmdmap,
|
||||
std::string_view k, MDSMap::DaemonState &val)
|
||||
string_view k, MDSMap::DaemonState &val)
|
||||
{
|
||||
return cmd_getval(cmdmap, k, (int64_t&)val);
|
||||
}
|
||||
@ -195,14 +196,14 @@ void MDSMonitor::encode_pending(MonitorDBStore::TransactionRef t)
|
||||
put_last_committed(t, pending.get_epoch());
|
||||
|
||||
// Encode MDSHealth data
|
||||
for (std::map<uint64_t, MDSHealth>::iterator i = pending_daemon_health.begin();
|
||||
for (map<uint64_t, MDSHealth>::iterator i = pending_daemon_health.begin();
|
||||
i != pending_daemon_health.end(); ++i) {
|
||||
bufferlist bl;
|
||||
i->second.encode(bl);
|
||||
t->put(MDS_HEALTH_PREFIX, stringify(i->first), bl);
|
||||
}
|
||||
|
||||
for (std::set<uint64_t>::iterator i = pending_daemon_health_rm.begin();
|
||||
for (set<uint64_t>::iterator i = pending_daemon_health_rm.begin();
|
||||
i != pending_daemon_health_rm.end(); ++i) {
|
||||
t->erase(MDS_HEALTH_PREFIX, stringify(*i));
|
||||
}
|
||||
@ -588,12 +589,12 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
|
||||
const auto &old_health = pending_daemon_health[gid].metrics;
|
||||
const auto &new_health = m->get_health().metrics;
|
||||
|
||||
std::set<mds_metric_t> old_types;
|
||||
set<mds_metric_t> old_types;
|
||||
for (const auto &i : old_health) {
|
||||
old_types.insert(i.type);
|
||||
}
|
||||
|
||||
std::set<mds_metric_t> new_types;
|
||||
set<mds_metric_t> new_types;
|
||||
for (const auto &i : new_health) {
|
||||
if (i.type == MDS_HEALTH_DUMMY) {
|
||||
continue;
|
||||
@ -1073,7 +1074,7 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op)
|
||||
|
||||
f->open_object_section("mds");
|
||||
f->dump_string("name", info.name);
|
||||
std::ostringstream get_err;
|
||||
ostringstream get_err;
|
||||
r = dump_metadata(fsmap, info.name, f.get(), get_err);
|
||||
if (r == -EINVAL || r == -ENOENT) {
|
||||
// Drop error, list what metadata we do have
|
||||
@ -1282,11 +1283,11 @@ bool MDSMonitor::fail_mds_gid(FSMap &fsmap, mds_gid_t gid)
|
||||
return blocklist_epoch != 0;
|
||||
}
|
||||
|
||||
mds_gid_t MDSMonitor::gid_from_arg(const FSMap &fsmap, const std::string &arg, std::ostream &ss)
|
||||
mds_gid_t MDSMonitor::gid_from_arg(const FSMap &fsmap, const string &arg, ostream &ss)
|
||||
{
|
||||
// Try parsing as a role
|
||||
mds_role_t role;
|
||||
std::ostringstream ignore_err; // Don't spam 'ss' with parse_role errors
|
||||
ostringstream ignore_err; // Don't spam 'ss' with parse_role errors
|
||||
int r = fsmap.parse_role(arg, &role, ignore_err);
|
||||
if (r == 0) {
|
||||
// See if a GID is assigned to this role
|
||||
@ -1300,7 +1301,7 @@ mds_gid_t MDSMonitor::gid_from_arg(const FSMap &fsmap, const std::string &arg, s
|
||||
}
|
||||
|
||||
// Try parsing as a gid
|
||||
std::string err;
|
||||
string err;
|
||||
unsigned long long maybe_gid = strict_strtoll(arg.c_str(), 10, &err);
|
||||
if (!err.empty()) {
|
||||
// Not a role or a GID, try as a daemon name
|
||||
@ -1328,8 +1329,8 @@ mds_gid_t MDSMonitor::gid_from_arg(const FSMap &fsmap, const std::string &arg, s
|
||||
return MDS_GID_NONE;
|
||||
}
|
||||
|
||||
int MDSMonitor::fail_mds(FSMap &fsmap, std::ostream &ss,
|
||||
const std::string &arg, MDSMap::mds_info_t *failed_info)
|
||||
int MDSMonitor::fail_mds(FSMap &fsmap, ostream &ss,
|
||||
const string &arg, MDSMap::mds_info_t *failed_info)
|
||||
{
|
||||
ceph_assert(failed_info != nullptr);
|
||||
|
||||
@ -1440,9 +1441,9 @@ out:
|
||||
int MDSMonitor::filesystem_command(
|
||||
FSMap &fsmap,
|
||||
MonOpRequestRef op,
|
||||
std::string const &prefix,
|
||||
string const &prefix,
|
||||
const cmdmap_t& cmdmap,
|
||||
std::stringstream &ss)
|
||||
stringstream &ss)
|
||||
{
|
||||
dout(4) << __func__ << " prefix='" << prefix << "'" << dendl;
|
||||
op->mark_mdsmon_event(__func__);
|
||||
@ -1540,7 +1541,7 @@ int MDSMonitor::filesystem_command(
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
std::string role_str;
|
||||
string role_str;
|
||||
cmd_getval(cmdmap, "role", role_str);
|
||||
mds_role_t role;
|
||||
const auto fs_names = op->get_session()->get_allowed_fs_names();
|
||||
@ -1596,7 +1597,7 @@ int MDSMonitor::filesystem_command(
|
||||
}
|
||||
r = 0;
|
||||
} else if (prefix == "mds repaired") {
|
||||
std::string role_str;
|
||||
string role_str;
|
||||
cmd_getval(cmdmap, "role", role_str);
|
||||
mds_role_t role;
|
||||
const auto fs_names = op->get_session()->get_allowed_fs_names();
|
||||
@ -1619,7 +1620,7 @@ int MDSMonitor::filesystem_command(
|
||||
|
||||
r = 0;
|
||||
} else if (prefix == "mds freeze") {
|
||||
std::string who;
|
||||
string who;
|
||||
cmd_getval(cmdmap, "role_or_gid", who);
|
||||
mds_gid_t gid = gid_from_arg(fsmap, who, ss);
|
||||
if (gid == MDS_GID_NONE) {
|
||||
@ -1634,7 +1635,7 @@ int MDSMonitor::filesystem_command(
|
||||
|
||||
bool freeze = false;
|
||||
{
|
||||
std::string str;
|
||||
string str;
|
||||
cmd_getval(cmdmap, "val", str);
|
||||
if ((r = parse_bool(str, &freeze, ss)) != 0) {
|
||||
return r;
|
||||
@ -1666,7 +1667,7 @@ void MDSMonitor::check_subs()
|
||||
// filesystems. Build a list of all the types we service
|
||||
// subscriptions for.
|
||||
|
||||
std::vector<std::string> types = {
|
||||
vector<string> types = {
|
||||
"fsmap",
|
||||
"fsmap.user",
|
||||
"mdsmap",
|
||||
@ -1675,7 +1676,7 @@ void MDSMonitor::check_subs()
|
||||
for (const auto& [fscid, fs] : get_fsmap()) {
|
||||
CachedStackStringStream cos;
|
||||
*cos << "mdsmap." << fscid;
|
||||
types.push_back(std::string(cos->strv()));
|
||||
types.push_back(string(cos->strv()));
|
||||
}
|
||||
|
||||
for (const auto &type : types) {
|
||||
@ -1744,9 +1745,9 @@ void MDSMonitor::check_sub(Subscription *sub)
|
||||
// You're a client. Did you request a particular
|
||||
// namespace?
|
||||
if (sub->type.compare(0, 7, "mdsmap.") == 0) {
|
||||
auto namespace_id_str = sub->type.substr(std::string("mdsmap.").size());
|
||||
auto namespace_id_str = sub->type.substr(string("mdsmap.").size());
|
||||
dout(10) << __func__ << ": namespace_id " << namespace_id_str << dendl;
|
||||
std::string err;
|
||||
string err;
|
||||
fscid = strict_strtoll(namespace_id_str.c_str(), 10, &err);
|
||||
if (!err.empty()) {
|
||||
// Client asked for a non-existent namespace, send them nothing
|
||||
@ -1868,7 +1869,7 @@ int MDSMonitor::load_metadata(map<mds_gid_t, Metadata>& m)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MDSMonitor::count_metadata(const std::string &field, map<string,int> *out)
|
||||
void MDSMonitor::count_metadata(const string &field, map<string,int> *out)
|
||||
{
|
||||
map<mds_gid_t,Metadata> meta;
|
||||
load_metadata(meta);
|
||||
@ -1882,7 +1883,7 @@ void MDSMonitor::count_metadata(const std::string &field, map<string,int> *out)
|
||||
}
|
||||
}
|
||||
|
||||
void MDSMonitor::count_metadata(const std::string &field, Formatter *f)
|
||||
void MDSMonitor::count_metadata(const string &field, Formatter *f)
|
||||
{
|
||||
map<string,int> by_val;
|
||||
count_metadata(field, &by_val);
|
||||
@ -1893,12 +1894,12 @@ void MDSMonitor::count_metadata(const std::string &field, Formatter *f)
|
||||
f->close_section();
|
||||
}
|
||||
|
||||
void MDSMonitor::get_versions(std::map<string, list<string> > &versions)
|
||||
void MDSMonitor::get_versions(map<string, list<string> > &versions)
|
||||
{
|
||||
map<mds_gid_t,Metadata> meta;
|
||||
load_metadata(meta);
|
||||
const auto &fsmap = get_fsmap();
|
||||
std::map<mds_gid_t, mds_info_t> map = fsmap.get_mds_info();
|
||||
map<mds_gid_t, mds_info_t> map = fsmap.get_mds_info();
|
||||
dout(10) << __func__ << " mds meta=" << meta << dendl;
|
||||
for (auto& p : meta) {
|
||||
auto q = p.second.find("ceph_version_short");
|
||||
@ -1907,7 +1908,7 @@ void MDSMonitor::get_versions(std::map<string, list<string> > &versions)
|
||||
}
|
||||
}
|
||||
|
||||
int MDSMonitor::dump_metadata(const FSMap& fsmap, const std::string &who,
|
||||
int MDSMonitor::dump_metadata(const FSMap& fsmap, const string &who,
|
||||
Formatter *f, ostream& err)
|
||||
{
|
||||
ceph_assert(f);
|
||||
@ -2126,7 +2127,7 @@ bool MDSMonitor::check_health(FSMap& fsmap, bool* propose_osdmap)
|
||||
std::max(g_conf()->mds_beacon_interval, g_conf()->mds_beacon_grace * 0.5);
|
||||
|
||||
// check beacon timestamps
|
||||
std::vector<mds_gid_t> to_remove;
|
||||
vector<mds_gid_t> to_remove;
|
||||
const bool mon_down = mon.is_mon_down();
|
||||
const auto mds_beacon_mon_down_grace =
|
||||
g_conf().get_val<std::chrono::seconds>("mds_beacon_mon_down_grace");
|
||||
|
Loading…
Reference in New Issue
Block a user