MonMap monmap;
-enum { OSD, MON, MDS, LAST };
+enum { OSD, MON, MDS, CLIENT, LAST };
int which = 0;
int same = 0;
-const char *prefix[3] = { "mds", "osd", "pg" };
-string status[3];
+const char *prefix[4] = { "mds", "osd", "pg", "client" };
+string status[4];
void get_next_status()
{
#include "messages/MMonMap.h"
#include "messages/MClientMount.h"
#include "messages/MClientUnmount.h"
+#include "messages/MMonCommand.h"
#include "common/Timer.h"
+#include <sstream>
+
#include "config.h"
#define DOUT_SUBSYS mon
}
return false;
+ case MSG_MON_COMMAND:
+ return preprocess_command((MMonCommand*)m);
default:
assert(0);
}
return true;
+
+ case MSG_MON_COMMAND:
+ return prepare_command((MMonCommand*)m);
+
default:
assert(0);
delete m;
}
+// COMMAND
+
+bool ClientMonitor::preprocess_command(MMonCommand *m)
+{
+ int r = -1;
+ bufferlist rdata;
+ stringstream ss;
+
+ if (m->cmd.size() > 1) {
+ if (m->cmd[1] == "stat") {
+ ss << *this;
+ r = 0;
+ }
+ else if (m->cmd[1] == "getmap") {
+ client_map.encode(rdata);
+ ss << "got clientmap version " << client_map.version;
+ r = 0;
+ }
+ else if (m->cmd[1] == "dump") {
+ ss << "version " << client_map.version << std::endl;
+ ss << "next_client " << client_map.next_client << std::endl;
+ for (map<uint32_t, entity_addr_t>::iterator p = client_map.client_addr.begin();
+ p != client_map.client_addr.end();
+ p++) {
+ ss << "client" << p->first << "\t" << p->second << std::endl;
+ }
+ while (!ss.eof()) {
+ string s;
+ getline(ss, s);
+ rdata.append(s.c_str(), s.length());
+ rdata.append("\n", 1);
+ }
+ ss << "ok";
+ r = 0;
+ }
+ }
+
+ if (r != -1) {
+ string rs;
+ getline(ss, rs);
+ mon->reply_command(m, r, rs, rdata);
+ return true;
+ } else
+ return false;
+}
+
+
+bool ClientMonitor::prepare_command(MMonCommand *m)
+{
+ stringstream ss;
+ string rs;
+ int err = -EINVAL;
+
+ // nothing here yet
+ ss << "unrecognized command";
+
+ getline(ss, rs);
+ mon->reply_command(m, err, rs);
+ return false;
+}
+
+
// MOUNT
class Paxos;
class MClientMount;
class MClientUnmount;
+class MMonCommand;
class ClientMonitor : public PaxosService {
public:
bool preprocess_query(Message *m); // true if processed.
bool prepare_update(Message *m);
-
+ bool preprocess_command(MMonCommand *m); // true if processed.
+ bool prepare_command(MMonCommand *m);
+
public:
ClientMonitor(Monitor *mn, Paxos *p) : PaxosService(mn, p) { }