From: Sage Weil Date: Fri, 18 May 2012 00:50:01 +0000 (-0700) Subject: mon: 'add_bootstrap_peer_hint ' via admin socket X-Git-Tag: v0.48argonaut~137^2~13^2~26 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b5bec554b292b2a39ddfae014206ec2b619aa57a;p=ceph.git mon: 'add_bootstrap_peer_hint ' via admin socket Let user add peer hints via the admin socket while bootstrapping. Once we have joined a cluster this command is ignored. Signed-off-by: Sage Weil --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index d156c67af6e4..a643533aa02a 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -212,6 +212,8 @@ void Monitor::do_admin_command(string command, ostream& ss) _mon_status(ss); else if (command == "quorum_status") _quorum_status(ss); + else if (command.find("add_bootstrap_peer_hint") == 0) + _add_bootstrap_peer_hint(command, ss); else assert(0 == "bad AdminSocket command binding"); } @@ -378,6 +380,9 @@ int Monitor::init() r = admin_socket->register_command("quorum_status", admin_hook, "show current quorum status"); assert(r == 0); + r = admin_socket->register_command("add_bootstrap_peer_hint", admin_hook, + "add peer address as potential bootstrap peer for cluster bringup"); + assert(r == 0); // i'm ready! messenger->add_dispatcher_tail(this); @@ -523,6 +528,35 @@ void Monitor::bootstrap() } } +void Monitor::_add_bootstrap_peer_hint(string cmd, ostream& ss) +{ + dout(10) << "_add_bootstrap_peer_hint '" << cmd << "'" << dendl; + + if (is_leader() || is_peon()) { + ss << "mon already active; ignoring bootstrap hint"; + return; + } + + size_t off = cmd.find(" "); + if (off == std::string::npos) { + ss << "syntax is 'add_bootstrap_peer_hint ip[:port]'"; + return; + } + + entity_addr_t addr; + const char *end = 0; + if (!addr.parse(cmd.c_str() + off + 1, &end)) { + ss << "failed to parse addr '" << (cmd.c_str() + off + 1) << "'"; + return; + } + + if (addr.get_port() == 0) + addr.set_port(CEPH_MON_PORT); + + extra_probe_peers.insert(addr); + ss << "adding peer " << addr << " to list: " << extra_probe_peers; +} + // called by bootstrap(), or on leader|peon -> electing void Monitor::reset() { diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 1614e06f3a1e..381138a97a18 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -279,6 +279,7 @@ public: bool _allowed_command(MonSession *s, const vector& cmd); void _mon_status(ostream& ss); void _quorum_status(ostream& ss); + void _add_bootstrap_peer_hint(string cmd, ostream& ss); void handle_command(class MMonCommand *m); void handle_route(MRoute *m);