-void parse_config_options(std::vector<const char*>& args)
+void parse_config_option_string(string& s)
+{
+ char b[s.length()+1];
+ strcpy(b, s.c_str());
+ vector<const char*> nargs;
+ char *p = b;
+ while (*p) {
+ nargs.push_back(p);
+ while (*p && *p != ' ') p++;
+ if (!*p)
+ break;
+ *p++ = 0;
+ while (*p && *p == ' ') p++;
+ }
+ parse_config_options(nargs, false);
+}
+
+void parse_config_options(std::vector<const char*>& args, bool open)
{
std::vector<const char*> nargs;
g_conf.dout_dir = 0;
}
*/
- if (g_conf.dout_dir && g_conf.daemonize) {
+ if (g_conf.dout_dir && g_conf.daemonize && open) {
char fn[80];
char hostname[80];
gethostname(hostname, 79);
void vec_to_argv(std::vector<const char*>& args,
int& argc, const char **&argv);
-void parse_config_options(std::vector<const char*>& args);
+void parse_config_options(std::vector<const char*>& args, bool open=true);
+void parse_config_option_string(string& s);
extern bool parse_ip_port(const char *s, entity_addr_t& addr);
#include "messages/MMDSTableRequest.h"
+#include "messages/MMonCommand.h"
+
#include "config.h"
#define dout(l) if (l<=g_conf.debug || l <= g_conf.debug_mds) *_dout << dbeginl << g_clock.now() << " mds" << whoami << " "
handle_mds_beacon((MMDSBeacon*)m);
break;
+ // misc
+ case MSG_MON_COMMAND:
+ parse_config_option_string(((MMonCommand*)m)->cmd[0]);
+ delete m;
+ break;
+
default:
dout(1) << "MDS unknown messge " << m->get_type() << dendl;
assert(0);
ss << "got mdsmap epoch " << mdsmap.get_epoch();
r = 0;
}
+ else if (m->cmd[1] == "injectargs" && m->cmd.size() == 4) {
+ if (m->cmd[2] == "*") {
+ for (int i=0; i<mdsmap.get_max_mds(); i++)
+ if (mdsmap.is_active(i))
+ mon->inject_args(mdsmap.get_inst(i), m->cmd[3]);
+ r = 0;
+ ss << "ok bcast";
+ } else {
+ errno = 0;
+ int who = strtol(m->cmd[2].c_str(), 0, 10);
+ if (!errno && who >= 0 && mdsmap.is_active(who)) {
+ mon->inject_args(mdsmap.get_inst(who), m->cmd[3]);
+ r = 0;
+ ss << "ok";
+ } else
+ ss << "specify mds number or *";
+ }
+ }
}
if (r != -1) {
dout(0) << "handle_command " << *m << dendl;
string rs;
+ int r = -EINVAL;
if (!m->cmd.empty()) {
if (m->cmd[0] == "mds") {
mdsmon->dispatch(m);
reply_command(m, 0, "initiating cluster shutdown");
return;
}
- rs = "unrecognized subsystem";
+
+ if (m->cmd[0] == "_injectargs") {
+ parse_config_option_string(m->cmd[0]);
+ return;
+ }
+ if (m->cmd[0] == "mon") {
+ if (m->cmd[1] == "injectargs" && m->cmd.size() == 4) {
+ vector<string> args(2);
+ args[0] = "_injectargs";
+ args[1] = m->cmd[3];
+ if (m->cmd[2] == "*") {
+ for (unsigned i=0; i<monmap->size(); i++)
+ inject_args(monmap->get_inst(i), args);
+ r = 0;
+ rs = "ok bcast";
+ } else {
+ errno = 0;
+ int who = strtol(m->cmd[2].c_str(), 0, 10);
+ if (!errno && who >= 0) {
+ inject_args(monmap->get_inst(who), args);
+ r = 0;
+ rs = "ok";
+ } else
+ rs = "specify mon number or *";
+ }
+ } else
+ rs = "unrecognized mon command";
+ } else
+ rs = "unrecognized subsystem";
} else
rs = "no command";
- reply_command(m, -EINVAL, rs);
+ reply_command(m, r, rs);
}
void Monitor::reply_command(MMonCommand *m, int rc, const string &rs)
delete m;
}
+
+void Monitor::inject_args(const entity_inst_t& inst, vector<string>& args)
+{
+ dout(10) << "inject_args " << inst << " " << args << dendl;
+ MMonCommand *c = new MMonCommand(monmap->fsid);
+ c->cmd = args;
+ messenger->send_message(c, inst);
+}
+
+
+
+
void Monitor::stop_cluster()
{
dout(0) << "stop_cluster -- initiating shutdown" << dendl;
}
+
void reply_command(MMonCommand *m, int rc, const string &rs);
void reply_command(MMonCommand *m, int rc, const string &rs, bufferlist& rdata);
+
+ void inject_args(const entity_inst_t& inst, string& args) {
+ vector<string> a(1);
+ a[0] = args;
+ inject_args(inst, a);
+ }
+ void inject_args(const entity_inst_t& inst, vector<string>& args);
+
public:
struct C_Command : public Context {
Monitor *mon;
ss << "max_osd = " << osdmap.get_max_osd() << " in epoch " << osdmap.get_epoch();
r = 0;
}
+ else if (m->cmd[1] == "injectargs" && m->cmd.size() == 4) {
+ if (m->cmd[2] == "*") {
+ for (int i=0; i<osdmap.get_max_osd(); i++)
+ if (osdmap.is_up(i))
+ mon->inject_args(osdmap.get_inst(i), m->cmd[3]);
+ r = 0;
+ ss << "ok bcast";
+ } else {
+ errno = 0;
+ int who = strtol(m->cmd[2].c_str(), 0, 10);
+ if (!errno && who >= 0 && osdmap.is_up(who)) {
+ mon->inject_args(osdmap.get_inst(who), m->cmd[3]);
+ r = 0;
+ ss << "ok";
+ } else
+ ss << "specify osd number or *";
+ }
+ }
}
if (r != -1) {
string rs;
#include "messages/MOSDAlive.h"
+#include "messages/MMonCommand.h"
+
#include "messages/MPGStats.h"
#include "messages/MPGStatsAck.h"
case MSG_PGSTATSACK:
handle_pgstats_ack((MPGStatsAck*)m);
break;
-
+
+ case MSG_MON_COMMAND:
+ parse_config_option_string(((MMonCommand*)m)->cmd[0]);
+ delete m;
+ break;
// -- need OSDMap --