Skip to content

Commit

Permalink
Merge pull request #11511 from stiopaa1/mds_mdsmap_addConstToMemFunct…
Browse files Browse the repository at this point in the history
…ions

mds/MDSMap.h: add const to member functions

Reviewed-by: John Spray <john.spray@redhat.com>
Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
John Spray committed Oct 19, 2016
2 parents 0928f53 + 51d6359 commit ed9d35d
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/mds/MDSMap.h
Expand Up @@ -233,13 +233,13 @@ class MDSMap {
cached_up_features(0)
{ }

bool get_inline_data_enabled() { return inline_data_enabled; }
bool get_inline_data_enabled() const { return inline_data_enabled; }
void set_inline_data_enabled(bool enabled) { inline_data_enabled = enabled; }

utime_t get_session_timeout() {
utime_t get_session_timeout() const {
return utime_t(session_timeout,0);
}
uint64_t get_max_filesize() { return max_file_size; }
uint64_t get_max_filesize() const { return max_file_size; }
void set_max_filesize(uint64_t m) { max_file_size = m; }

int get_flags() const { return flags; }
Expand Down Expand Up @@ -394,29 +394,31 @@ class MDSMap {
/**
* Get MDS ranks which are in but not up.
*/
void get_down_mds_set(std::set<mds_rank_t> *s)
void get_down_mds_set(std::set<mds_rank_t> *s) const
{
assert(s != NULL);
s->insert(failed.begin(), failed.end());
s->insert(damaged.begin(), damaged.end());
}

int get_failed() {
int get_failed() const {
if (!failed.empty()) return *failed.begin();
return -1;
}
void get_stopped_mds_set(std::set<mds_rank_t>& s) {
void get_stopped_mds_set(std::set<mds_rank_t>& s) const {
s = stopped;
}
void get_recovery_mds_set(std::set<mds_rank_t>& s) {
void get_recovery_mds_set(std::set<mds_rank_t>& s) const {
s = failed;
for (std::map<mds_gid_t, mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p)
if (p->second.state >= STATE_REPLAY && p->second.state <= STATE_STOPPING)
s.insert(p->second.rank);
}
void get_clientreplay_or_active_or_stopping_mds_set(std::set<mds_rank_t>& s) {

void
get_clientreplay_or_active_or_stopping_mds_set(std::set<mds_rank_t>& s) const {
for (std::map<mds_gid_t, mds_info_t>::const_iterator p = mds_info.begin();
p != mds_info.end();
++p)
Expand Down Expand Up @@ -543,16 +545,16 @@ class MDSMap {
return true;
return false;
}
bool is_any_failed() {
bool is_any_failed() const {
return failed.size();
}
bool is_resolving() {
bool is_resolving() const {
return
get_num_mds(STATE_RESOLVE) > 0 &&
get_num_mds(STATE_REPLAY) == 0 &&
failed.empty();
}
bool is_rejoining() {
bool is_rejoining() const {
// nodes are rejoining cache state
return
get_num_mds(STATE_REJOIN) > 0 &&
Expand All @@ -561,7 +563,7 @@ class MDSMap {
get_num_mds(STATE_RESOLVE) == 0 &&
failed.empty();
}
bool is_stopped() {
bool is_stopped() const {
return up.empty();
}

Expand All @@ -570,7 +572,7 @@ class MDSMap {
* an MDS daemon's entity_inst_t associated
* with it.
*/
bool have_inst(mds_rank_t m) {
bool have_inst(mds_rank_t m) const {
return up.count(m);
}

Expand Down Expand Up @@ -610,9 +612,10 @@ class MDSMap {
}
}

int get_inc_gid(mds_gid_t gid) {
if (mds_info.count(gid))
return mds_info[gid].inc;
int get_inc_gid(mds_gid_t gid) const {
auto mds_info_entry = mds_info.find(gid);
if (mds_info_entry != mds_info.end())
return mds_info_entry->second.inc;
return -1;
}
void encode(bufferlist& bl, uint64_t features) const;
Expand Down

0 comments on commit ed9d35d

Please sign in to comment.