mirror of
https://github.com/ceph/ceph
synced 2025-01-21 02:31:19 +00:00
* get_rand_in_mds
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1494 29311d96-e01e-0410-9327-a35deaab8ce9
This commit is contained in:
parent
ee36a38e60
commit
d1436d2b5a
@ -513,7 +513,8 @@ int Client::choose_target_mds(MClientRequest *req)
|
||||
// pick mds
|
||||
if (!diri || g_conf.client_use_random_mds) {
|
||||
// no root info, pick a random MDS
|
||||
mds = rand() % mdsmap->get_num_mds();
|
||||
mds = mdsmap->get_random_in_mds();
|
||||
if (mds < 0) mds = 0;
|
||||
} else {
|
||||
if (req->auth_is_best()) {
|
||||
// pick the actual auth (as best we can)
|
||||
|
@ -186,6 +186,18 @@ class MDSMap {
|
||||
s.insert(p->first);
|
||||
}
|
||||
|
||||
int get_random_in_mds() {
|
||||
vector<int> v;
|
||||
for (map<int,int>::const_iterator p = mds_state.begin();
|
||||
p != mds_state.end();
|
||||
p++)
|
||||
if (p->second > 0) v.push_back(p->first);
|
||||
if (v.empty())
|
||||
return -1;
|
||||
else
|
||||
return v[rand() % v.size()];
|
||||
}
|
||||
|
||||
|
||||
// mds states
|
||||
bool is_down(int m) { return is_dne(m) || is_stopped(m) || is_failed(m); }
|
||||
|
Loading…
Reference in New Issue
Block a user