f->dump_int("snapid_first", first);
f->dump_bool("auth", is_auth());
- // >> Only meaningful for auth
- f->open_object_section("replica_map");
- for (std::map<mds_rank_t, unsigned>::const_iterator i = replica_map.begin();
- i != replica_map.end(); ++i) {
- std::ostringstream rank_str;
- rank_str << i->first;
- f->dump_int(rank_str.str().c_str(), i->second);
+ // Fields only meaningful for auth
+ f->open_object_section("auth_state");
+ {
+ f->open_object_section("replica_map");
+ for (std::map<mds_rank_t, unsigned>::const_iterator i = replica_map.begin();
+ i != replica_map.end(); ++i) {
+ std::ostringstream rank_str;
+ rank_str << i->first;
+ f->dump_int(rank_str.str().c_str(), i->second);
+ }
+ f->close_section();
+ f->dump_stream("projected_version") << get_projected_version();
+ f->dump_stream("version") << get_version();
+ f->dump_stream("comitting_version") << get_committing_version();
+ f->dump_stream("comitted_version") << get_committed_version();
+ }
+ f->close_section();
+
+ // Fields only meaningful for replica
+ f->open_object_section("replica_state");
+ {
+ f->dump_stream("authority_first") << authority().first;
+ f->dump_stream("authority_second") << authority().second;
+ f->dump_stream("replica_nonce") << get_replica_nonce();
}
f->close_section();
- f->dump_stream("projected_version") << get_projected_version();
- f->dump_stream("version") << get_version();
- f->dump_stream("comitting_version") << get_committing_version();
- f->dump_stream("comitted_version") << get_committed_version();
- // << Only meaningful for auth
-
- // >> Only meaningful for replica
- f->dump_stream("authority_first") << authority().first;
- f->dump_stream("authority_second") << authority().second;
- f->dump_stream("replica_nonce") << get_replica_nonce();
- // << Only meaningful for replica
f->dump_bool("is_rep", is_rep());
#include "common/Timer.h"
#include "events/ESession.h"
+#include "events/ESubtreeMap.h"
#include "messages/MMDSMap.h"
#include "messages/MMDSBeacon.h"
command_flush_path(f, path);
} else if (command == "flush journal") {
command_flush_journal(f);
+ } else if (command == "get subtrees") {
+ command_get_subtrees(f);
} else if (command == "force_readonly") {
mds_lock.Lock();
mdcache->force_readonly();
return 0;
}
+
+void MDS::command_get_subtrees(Formatter *f)
+{
+ assert(f != NULL);
+
+ std::list<CDir*> subtrees;
+ mdcache->list_subtrees(subtrees);
+
+ f->open_array_section("subtrees");
+ for (std::list<CDir*>::iterator i = subtrees.begin(); i != subtrees.end(); ++i) {
+ const CDir *dir = *i;
+
+ f->open_object_section("subtree");
+ {
+ f->dump_bool("is_auth", dir->is_auth());
+ f->dump_int("auth_first", dir->get_dir_auth().first);
+ f->dump_int("auth_second", dir->get_dir_auth().second);
+ f->open_object_section("dir");
+ dir->dump(f);
+ f->close_section();
+ }
+ f->close_section();
+ }
+ f->close_section();
+}
+
+
void MDS::set_up_admin_socket()
{
int r;
asok_hook,
"Force MDS to read-only mode");
assert(0 == r);
+ r = admin_socket->register_command("get subtrees",
+ "get subtrees",
+ asok_hook,
+ "Return the subtree map");
+ assert(0 == r);
}
void MDS::clean_up_admin_socket()