Skip to content

Commit

Permalink
copyset schedule select copyset random
Browse files Browse the repository at this point in the history
Signed-off-by: chenwei <461432360@qq.com>
  • Loading branch information
cw123 committed Aug 12, 2022
1 parent afc19d5 commit e71aa51
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions curvefs/src/mds/schedule/copysetSchedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ int CopySetScheduler::CheckAndBalanceZoneByMetaserverUsage(ZoneIdType zoneId) {

std::vector<CopySetInfo> copysetVector =
topo_->GetCopySetInfosInMetaServer(sourceId);

thread_local static std::random_device rd;
thread_local static std::mt19937 randomGenerator(rd());
std::shuffle(copysetVector.begin(), copysetVector.end(),
randomGenerator);
for (const auto &copyset : copysetVector) {
if (!IsCopysetCanTransfer(copyset)) {
continue;
Expand Down Expand Up @@ -276,6 +281,11 @@ int CopySetScheduler::CheckAndBalanceZoneByCopysetNum(ZoneIdType zoneId) {

std::vector<CopySetInfo> copysetVector =
topo_->GetCopySetInfosInMetaServer(sourceId);

thread_local static std::random_device rd;
thread_local static std::mt19937 randomGenerator(rd());
std::shuffle(copysetVector.begin(), copysetVector.end(),
randomGenerator);
for (const auto &copyset : copysetVector) {
if (!IsCopysetCanTransfer(copyset)) {
continue;
Expand Down

0 comments on commit e71aa51

Please sign in to comment.