const MonCommand *cmds;
int cmdsize;
if (use_classic_commands) {
- get_classic_monitor_commands(&cmds, &cmdsize);
+ mon->get_classic_monitor_commands(&cmds, &cmdsize);
cmds_bl = &mon->get_classic_commands_bl();
} else {
- get_locally_supported_monitor_commands(&cmds, &cmdsize);
+ mon->get_locally_supported_monitor_commands(&cmds, &cmdsize);
cmds_bl = &mon->get_supported_commands_bl();
}
int cmdsize;
bufferlist::iterator bi = m->commands.begin();
MonCommand::decode_array(&new_cmds, &cmdsize, bi);
- set_leader_supported_commands(new_cmds, cmdsize);
+ mon->set_leader_supported_commands(new_cmds, cmdsize);
} else { // they are a legacy monitor; use known legacy command set
const MonCommand *new_cmds;
int cmdsize;
- get_classic_monitor_commands(&new_cmds, &cmdsize);
- set_leader_supported_commands(new_cmds, cmdsize);
+ mon->get_classic_monitor_commands(&new_cmds, &cmdsize);
+ mon->set_leader_supported_commands(new_cmds, cmdsize);
}
m->put();
const string Monitor::MONITOR_NAME = "monitor";
const string Monitor::MONITOR_STORE_PREFIX = "monitor_store";
+
+#undef COMMAND
+MonCommand mon_commands[] = {
+#define COMMAND(parsesig, helptext, modulename, req_perms, avail) \
+ {parsesig, helptext, modulename, req_perms, avail},
+#include <mon/MonCommands.h>
+};
+MonCommand classic_mon_commands[] = {
+#include <mon/DumplingMonCommands.h>
+};
+
+
long parse_pos_long(const char *s, ostream *pss)
{
if (*s == '-' || *s == '+') {
auth_service_required(cct,
cct->_conf->auth_supported.length() ?
cct->_conf->auth_supported : cct->_conf->auth_service_required),
+ leader_supported_mon_commands(NULL),
+ leader_supported_mon_commands_size(0),
store(s),
state(STATE_PROBING),
delete paxos;
assert(session_map.sessions.empty());
delete mon_caps;
+ if (leader_supported_mon_commands != mon_commands &&
+ leader_supported_mon_commands != classic_mon_commands)
+ delete[] leader_supported_mon_commands;
}
}
}
-#undef COMMAND
-MonCommand mon_commands[] = {
-#define COMMAND(parsesig, helptext, modulename, req_perms, avail) \
- {parsesig, helptext, modulename, req_perms, avail},
-#include <mon/MonCommands.h>
-};
-MonCommand classic_mon_commands[] = {
-#include <mon/DumplingMonCommands.h>
-};
-const MonCommand *leader_supported_mon_commands = NULL;
-int leader_supported_mon_commands_size = 0;
-
void Monitor::_generate_command_map(map<string,cmd_vartype>& cmdmap,
map<string,string> ¶m_str_map)
{
return capable;
}
-void get_command_descriptions(const MonCommand *commands,
- unsigned commands_size,
- Formatter *f,
- bufferlist *rdata) {
+void Monitor::format_command_descriptions(const MonCommand *commands,
+ unsigned commands_size,
+ Formatter *f,
+ bufferlist *rdata)
+{
int cmdnum = 0;
f->open_object_section("command_descriptions");
for (const MonCommand *cp = commands;
f->flush(*rdata);
}
-void get_locally_supported_monitor_commands(const MonCommand **cmds, int *count)
+void Monitor::get_locally_supported_monitor_commands(const MonCommand **cmds,
+ int *count)
{
*cmds = mon_commands;
*count = ARRAY_SIZE(mon_commands);
}
-void get_leader_supported_commands(const MonCommand **cmds, int *count)
+void Monitor::get_leader_supported_commands(const MonCommand **cmds, int *count)
{
*cmds = leader_supported_mon_commands;
*count = leader_supported_mon_commands_size;
}
-void get_classic_monitor_commands(const MonCommand **cmds, int *count)
+void Monitor::get_classic_monitor_commands(const MonCommand **cmds, int *count)
{
*cmds = classic_mon_commands;
*count = ARRAY_SIZE(classic_mon_commands);
}
-void set_leader_supported_commands(const MonCommand *cmds, int size)
+void Monitor::set_leader_supported_commands(const MonCommand *cmds, int size)
{
if (leader_supported_mon_commands != mon_commands &&
leader_supported_mon_commands != classic_mon_commands)
if (prefix == "get_command_descriptions") {
bufferlist rdata;
Formatter *f = new_formatter("json");
- get_command_descriptions(leader_supported_mon_commands,
- leader_supported_mon_commands_size, f, &rdata);
+ format_command_descriptions(leader_supported_mon_commands,
+ leader_supported_mon_commands_size, f, &rdata);
delete f;
reply_command(m, 0, "", rdata, 0);
return;
CompatSet features;
+ const MonCommand *leader_supported_mon_commands;
+ int leader_supported_mon_commands_size;
+
private:
void new_tick();
friend class C_Mon_Tick;
void _convert_machines();
void _convert_paxos();
};
+
+ static void format_command_descriptions(const MonCommand *commands,
+ unsigned commands_size,
+ Formatter *f,
+ bufferlist *rdata);
+ void get_locally_supported_monitor_commands(const MonCommand **cmds, int *count);
+ void get_classic_monitor_commands(const MonCommand **cmds, int *count);
+ void get_leader_supported_commands(const MonCommand **cmds, int *count);
+ /// the Monitor owns this pointer once you pass it in
+ void set_leader_supported_commands(const MonCommand *cmds, int size);
};
#define CEPH_MON_FEATURE_INCOMPAT_BASE CompatSet::Feature (1, "initial feature set (~v.18)")
};
WRITE_CLASS_ENCODER(MonCommand);
-void get_command_descriptions(const MonCommand *commands,
- unsigned commands_size,
- Formatter *f,
- bufferlist *rdata);
-void get_locally_supported_monitor_commands(const MonCommand **cmds, int *count);
-void get_classic_monitor_commands(const MonCommand **cmds, int *count);
-void get_leader_supported_commands(const MonCommand **cmds, int *count);
-/// the Monitor owns this pointer once you pass it in
-void set_leader_supported_commands(const MonCommand *cmds, int size);
-
-
#endif