} else if (active_con && active_con->is_my_peer(conn->get_peer_addr())) {
logger().warn("active conn reset {}", conn->get_peer_addr());
active_con.reset();
- return reopen_session(-1).then([this] {
- if (active_con) {
+ return reopen_session(-1).then([this](bool opened) {
+ if (opened) {
return on_session_opened();
} else {
return seastar::now();
}
} else {
logger().warn("mon.{} went away", cur_mon);
- return reopen_session(-1).then([this] {
- if (active_con) {
+ return reopen_session(-1).then([this](bool opened) {
+ if (opened) {
return on_session_opened();
} else {
return seastar::now();
seastar::future<> Client::authenticate()
{
- return reopen_session(-1).then([this] {
- if (active_con) {
+ return reopen_session(-1).then([this](bool opened) {
+ if (opened) {
return on_session_opened();
} else {
return seastar::now();
return entity_addr_t{};
}
-seastar::future<> Client::reopen_session(int rank)
+seastar::future<bool> Client::reopen_session(int rank)
{
logger().info("{} to mon.{}", __func__, rank);
vector<unsigned> mons;
return seastar::make_exception_future(ep);
});
}).then([this] {
- if (!active_con) {
+ if (active_con) {
+ return true;
+ } else {
logger().warn("cannot establish the active_con with any mon");
+ return false;
}
});
}
seastar::future<> authenticate();
bool is_hunting() const;
- seastar::future<> reopen_session(int rank);
+ // @param rank, rank of the monitor to be connected, if it is less than 0,
+ // try to connect to all monitors in monmap, until one of them
+ // is connected.
+ // @return true if a connection is established to a monitor
+ seastar::future<bool> reopen_session(int rank);
std::vector<unsigned> get_random_mons(unsigned n) const;
seastar::future<> _add_conn(unsigned rank, uint64_t global_id);
void _finish_auth(const entity_addr_t& peer);