Skip to content

Commit

Permalink
mgr: use entity_addrvec_t for MgrMap
Browse files Browse the repository at this point in the history
This does several entity_addr_t -> entity_addrvec_t conversions across the
mgr code.

(Note that entity_addr_t and entity_addrvec_t already encode in an
interoperable way.)

Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed May 31, 2018
1 parent 1f19267 commit 7f78770
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 35 deletions.
14 changes: 7 additions & 7 deletions src/messages/MMgrBeacon.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MMgrBeacon : public PaxosServiceMessage {

protected:
uint64_t gid;
entity_addr_t server_addr;
entity_addrvec_t server_addrs;
bool available;
std::string name;
uuid_d fsid;
Expand All @@ -54,17 +54,17 @@ class MMgrBeacon : public PaxosServiceMessage {
}

MMgrBeacon(const uuid_d& fsid_, uint64_t gid_, const std::string &name_,
entity_addr_t server_addr_, bool available_,
entity_addrvec_t server_addrs_, bool available_,
std::vector<MgrMap::ModuleInfo>&& modules_,
map<string,string>&& metadata_)
: PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION),
gid(gid_), server_addr(server_addr_), available(available_), name(name_),
gid(gid_), server_addrs(server_addrs_), available(available_), name(name_),
fsid(fsid_), modules(std::move(modules_)), metadata(std::move(metadata_))
{
}

uint64_t get_gid() const { return gid; }
entity_addr_t get_server_addr() const { return server_addr; }
entity_addrvec_t get_server_addrs() const { return server_addrs; }
bool get_available() const { return available; }
const std::string& get_name() const { return name; }
const uuid_d& get_fsid() const { return fsid; }
Expand Down Expand Up @@ -106,15 +106,15 @@ class MMgrBeacon : public PaxosServiceMessage {

void print(ostream& out) const override {
out << get_type_name() << " mgr." << name << "(" << fsid << ","
<< gid << ", " << server_addr << ", " << available
<< gid << ", " << server_addrs << ", " << available
<< ")";
}

void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();

encode(server_addr, payload, features);
encode(server_addrs, payload, features);
encode(gid, payload);
encode(available, payload);
encode(name, payload);
Expand All @@ -137,7 +137,7 @@ class MMgrBeacon : public PaxosServiceMessage {
void decode_payload() override {
auto p = payload.cbegin();
paxos_decode(p);
decode(server_addr, p);
decode(server_addrs, p);
decode(gid, p);
decode(available, p);
decode(name, p);
Expand Down
4 changes: 2 additions & 2 deletions src/mgr/DaemonServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ int DaemonServer::init(uint64_t gid, entity_addr_t client_addr)
return 0;
}

entity_addr_t DaemonServer::get_myaddr() const
entity_addrvec_t DaemonServer::get_myaddrs() const
{
return msgr->get_myaddr();
return msgr->get_myaddrs();
}


Expand Down
2 changes: 1 addition & 1 deletion src/mgr/DaemonServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class DaemonServer : public Dispatcher, public md_config_obs_t
int init(uint64_t gid, entity_addr_t client_addr);
void shutdown();

entity_addr_t get_myaddr() const;
entity_addrvec_t get_myaddrs() const;

DaemonServer(MonClient *monc_,
Finisher &finisher_,
Expand Down
2 changes: 1 addition & 1 deletion src/mgr/Mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void Mgr::init()
// systemd restart us.
exit(1);
}
dout(4) << "Initialized server at " << server.get_myaddr() << dendl;
dout(4) << "Initialized server at " << server.get_myaddrs() << dendl;

// Preload all daemon metadata (will subsequently keep this
// up to date by watching maps, so do the initial load before
Expand Down
4 changes: 3 additions & 1 deletion src/mgr/Mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ class Mgr {
~Mgr();

bool is_initialized() const {return initialized;}
entity_addr_t get_server_addr() const { return server.get_myaddr(); }
entity_addrvec_t get_server_addrs() const {
return server.get_myaddrs();
}

void handle_mgr_digest(MMgrDigest* m);
void handle_fs_map(MFSMap* m);
Expand Down
12 changes: 5 additions & 7 deletions src/mgr/MgrClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,13 @@ void MgrClient::reconnect()
connect_retry_callback = nullptr;
}

ldout(cct, 4) << "Starting new session with " << map.get_active_addr()
ldout(cct, 4) << "Starting new session with " << map.get_active_addrs()
<< dendl;
entity_inst_t inst;
inst.addr = map.get_active_addr();
inst.name = entity_name_t::MGR(map.get_active_gid());
last_connect_attempt = ceph_clock_now();

session.reset(new MgrSessionState());
session->con = msgr->get_connection(inst);
session->con = msgr->connect_to(CEPH_ENTITY_TYPE_MGR,
map.get_active_addrs());

if (service_daemon) {
daemon_dirty_status = true;
Expand Down Expand Up @@ -208,11 +206,11 @@ bool MgrClient::handle_mgr_map(MMgrMap *m)
ldout(cct, 4) << "Got map version " << map.epoch << dendl;
m->put();

ldout(cct, 4) << "Active mgr is now " << map.get_active_addr() << dendl;
ldout(cct, 4) << "Active mgr is now " << map.get_active_addrs() << dendl;

// Reset session?
if (!session ||
session->con->get_peer_addr() != map.get_active_addr()) {
session->con->get_peer_addrs() != map.get_active_addrs()) {
reconnect();
}

Expand Down
4 changes: 2 additions & 2 deletions src/mgr/MgrStandby.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void MgrStandby::send_beacon()
// as available in the map)
bool available = active_mgr != nullptr && active_mgr->is_initialized();

auto addr = available ? active_mgr->get_server_addr() : entity_addr_t();
auto addrs = available ? active_mgr->get_server_addrs() : entity_addrvec_t();
dout(10) << "sending beacon as gid " << monc.get_global_id() << dendl;

map<string,string> metadata;
Expand All @@ -209,7 +209,7 @@ void MgrStandby::send_beacon()
MMgrBeacon *m = new MMgrBeacon(monc.get_fsid(),
monc.get_global_id(),
g_conf->name.get_id(),
addr,
addrs,
available,
std::move(module_info),
std::move(metadata));
Expand Down
14 changes: 7 additions & 7 deletions src/mon/MgrMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class MgrMap
/// global_id of the ceph-mgr instance selected as a leader
uint64_t active_gid = 0;
/// server address reported by the leader once it is active
entity_addr_t active_addr;
entity_addrvec_t active_addrs;
/// whether the nominated leader is active (i.e. has initialized its server)
bool available = false;
/// the name (foo in mgr.<foo>) of the active daemon
Expand All @@ -151,7 +151,7 @@ class MgrMap
std::map<std::string, std::string> services;

epoch_t get_epoch() const { return epoch; }
entity_addr_t get_active_addr() const { return active_addr; }
entity_addrvec_t get_active_addrs() const { return active_addrs; }
uint64_t get_active_gid() const { return active_gid; }
bool get_available() const { return available; }
const std::string &get_active_name() const { return active_name; }
Expand Down Expand Up @@ -235,9 +235,9 @@ class MgrMap

void encode(bufferlist& bl, uint64_t features) const
{
ENCODE_START(4, 1, bl);
ENCODE_START(5, 1, bl);
encode(epoch, bl);
encode(active_addr, bl, features);
encode(active_addrs, bl, features);
encode(active_gid, bl);
encode(available, bl);
encode(active_name, bl);
Expand All @@ -259,9 +259,9 @@ class MgrMap

void decode(bufferlist::const_iterator& p)
{
DECODE_START(4, p);
DECODE_START(5, p);
decode(epoch, p);
decode(active_addr, p);
decode(active_addrs, p);
decode(active_gid, p);
decode(available, p);
decode(active_name, p);
Expand Down Expand Up @@ -295,7 +295,7 @@ class MgrMap
f->dump_int("epoch", epoch);
f->dump_int("active_gid", get_active_gid());
f->dump_string("active_name", get_active_name());
f->dump_stream("active_addr") << active_addr;
f->dump_object("active_addrs", active_addrs);
f->dump_bool("available", available);
f->open_array_section("standbys");
for (const auto &i : standbys) {
Expand Down
14 changes: 7 additions & 7 deletions src/mon/MgrMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void MgrMonitor::update_from_paxos(bool *need_bootstrap)
auto p = bl.cbegin();
map.decode(p);

dout(4) << "active server: " << map.active_addr
dout(4) << "active server: " << map.active_addrs
<< "(" << map.active_gid << ")" << dendl;

ever_had_active_mgr = get_value("ever_had_active_mgr");
Expand Down Expand Up @@ -320,10 +320,10 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op)
}

// A beacon from the currently active daemon
if (pending_map.active_addr != m->get_server_addr()) {
dout(4) << "learned address " << m->get_server_addr()
<< " (was " << pending_map.active_addr << ")" << dendl;
pending_map.active_addr = m->get_server_addr();
if (pending_map.active_addrs != m->get_server_addrs()) {
dout(4) << "learned address " << m->get_server_addrs()
<< " (was " << pending_map.active_addrs << ")" << dendl;
pending_map.active_addrs = m->get_server_addrs();
updated = true;
}

Expand Down Expand Up @@ -620,7 +620,7 @@ bool MgrMonitor::promote_standby()
pending_map.active_gid = replacement_gid;
pending_map.active_name = pending_map.standbys.at(replacement_gid).name;
pending_map.available = false;
pending_map.active_addr = entity_addr_t();
pending_map.active_addrs = entity_addrvec_t();

drop_standby(replacement_gid, false);

Expand All @@ -641,7 +641,7 @@ void MgrMonitor::drop_active()
pending_map.active_name = "";
pending_map.active_gid = 0;
pending_map.available = false;
pending_map.active_addr = entity_addr_t();
pending_map.active_addrs = entity_addrvec_t();
pending_map.services.clear();

// So that when new active mgr subscribes to mgrdigest, it will
Expand Down

0 comments on commit 7f78770

Please sign in to comment.