Improve DDTeamCollection const-correctness
This commit is contained in:
parent
cfe677c100
commit
904deb9516
|
@ -684,7 +684,6 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
Future<Void> wrongStoreTypeRemover;
|
||||
|
||||
Reference<LocalitySet> storageServerSet;
|
||||
std::vector<LocalityEntry> forcedEntries, resultEntries;
|
||||
|
||||
std::vector<DDTeamCollection*> teamCollections;
|
||||
AsyncVar<Optional<Key>> healthyZone;
|
||||
|
@ -710,13 +709,13 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
}
|
||||
|
||||
bool satisfiesPolicy(const std::vector<Reference<TCServerInfo>>& team, int amount = -1) {
|
||||
forcedEntries.clear();
|
||||
resultEntries.clear();
|
||||
bool satisfiesPolicy(const std::vector<Reference<TCServerInfo>>& team, int amount = -1) const {
|
||||
std::vector<LocalityEntry> forcedEntries, resultEntries;
|
||||
if (amount == -1) {
|
||||
amount = team.size();
|
||||
}
|
||||
|
||||
forcedEntries.reserve(amount);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
forcedEntries.push_back(team[i]->localityEntry);
|
||||
}
|
||||
|
@ -1074,7 +1073,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
}
|
||||
|
||||
int64_t getDebugTotalDataInFlight() {
|
||||
int64_t getDebugTotalDataInFlight() const {
|
||||
int64_t total = 0;
|
||||
for (auto itr = server_info.begin(); itr != server_info.end(); ++itr)
|
||||
total += itr->second->dataInFlightToServer;
|
||||
|
@ -1139,14 +1138,13 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
tempMap->add(it->lastKnownInterface.locality, &it->id);
|
||||
}
|
||||
|
||||
self->resultEntries.clear();
|
||||
self->forcedEntries.clear();
|
||||
std::vector<LocalityEntry> resultEntries, forcedEntries;
|
||||
bool result = tempSet->selectReplicas(
|
||||
self->configuration.storagePolicy, self->forcedEntries, self->resultEntries);
|
||||
ASSERT(result && self->resultEntries.size() == self->configuration.storageTeamSize);
|
||||
self->configuration.storagePolicy, forcedEntries, resultEntries);
|
||||
ASSERT(result && resultEntries.size() == self->configuration.storageTeamSize);
|
||||
|
||||
serverIds.clear();
|
||||
for (auto& it : self->resultEntries) {
|
||||
for (auto& it : resultEntries) {
|
||||
serverIds.push_back(*tempMap->getObject(it));
|
||||
}
|
||||
std::sort(serverIds.begin(), serverIds.end());
|
||||
|
@ -1208,7 +1206,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
|
||||
// Check if server or machine has a valid locality based on configured replication policy
|
||||
bool isValidLocality(Reference<IReplicationPolicy> storagePolicy, const LocalityData& locality) {
|
||||
bool isValidLocality(Reference<IReplicationPolicy> storagePolicy, const LocalityData& locality) const {
|
||||
// Future: Once we add simulation test that misconfigure a cluster, such as not setting some locality entries,
|
||||
// DD_VALIDATE_LOCALITY should always be true. Otherwise, simulation test may fail.
|
||||
if (!SERVER_KNOBS->DD_VALIDATE_LOCALITY) {
|
||||
|
@ -1226,7 +1224,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return true;
|
||||
}
|
||||
|
||||
void evaluateTeamQuality() {
|
||||
void evaluateTeamQuality() const {
|
||||
int teamCount = teams.size(), serverCount = allServers.size();
|
||||
double teamsPerServer = (double)teamCount * configuration.storageTeamSize / serverCount;
|
||||
|
||||
|
@ -1303,14 +1301,14 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return maxMatchingServers;
|
||||
}
|
||||
|
||||
int overlappingMachineMembers(vector<Standalone<StringRef>>& team) {
|
||||
int overlappingMachineMembers(vector<Standalone<StringRef>> const& team) const {
|
||||
if (team.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int maxMatchingServers = 0;
|
||||
Standalone<StringRef>& serverID = team[0];
|
||||
for (auto& usedTeam : machine_info[serverID]->machineTeams) {
|
||||
auto const& serverID = team[0];
|
||||
for (auto const& usedTeam : machine_info.at(serverID)->machineTeams) {
|
||||
auto used = usedTeam->machineIDs;
|
||||
int teamIdx = 0;
|
||||
int usedIdx = 0;
|
||||
|
@ -1336,13 +1334,13 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return maxMatchingServers;
|
||||
}
|
||||
|
||||
Reference<TCMachineTeamInfo> findMachineTeam(vector<Standalone<StringRef>>& machineIDs) {
|
||||
Reference<TCMachineTeamInfo> findMachineTeam(vector<Standalone<StringRef>> const& machineIDs) const {
|
||||
if (machineIDs.empty()) {
|
||||
return Reference<TCMachineTeamInfo>();
|
||||
}
|
||||
|
||||
Standalone<StringRef> machineID = machineIDs[0];
|
||||
for (auto& machineTeam : machine_info[machineID]->machineTeams) {
|
||||
for (auto& machineTeam : machine_info.at(machineID)->machineTeams) {
|
||||
if (machineTeam->machineIDs == machineIDs) {
|
||||
return machineTeam;
|
||||
}
|
||||
|
@ -1476,7 +1474,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return totalServerIndex;
|
||||
}
|
||||
|
||||
void traceConfigInfo() {
|
||||
void traceConfigInfo() const {
|
||||
TraceEvent("DDConfig", distributorId)
|
||||
.detail("StorageTeamSize", configuration.storageTeamSize)
|
||||
.detail("DesiredTeamsPerServer", SERVER_KNOBS->DESIRED_TEAMS_PER_SERVER)
|
||||
|
@ -1484,7 +1482,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
.detail("StoreType", configuration.storageServerStoreType);
|
||||
}
|
||||
|
||||
void traceServerInfo() {
|
||||
void traceServerInfo() const {
|
||||
int i = 0;
|
||||
|
||||
TraceEvent("ServerInfo", distributorId).detail("Size", server_info.size());
|
||||
|
@ -1502,13 +1500,14 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
TraceEvent("ServerStatus", distributorId)
|
||||
.detail("ServerID", uid)
|
||||
.detail("Healthy", !server_status.get(uid).isUnhealthy())
|
||||
.detail("MachineIsValid", server_info[uid]->machine.isValid())
|
||||
.detail("MachineIsValid", server_info.at(uid)->machine.isValid())
|
||||
.detail("MachineTeamSize",
|
||||
server_info[uid]->machine.isValid() ? server_info[uid]->machine->machineTeams.size() : -1);
|
||||
server_info.at(uid)->machine.isValid() ? server_info.at(uid)->machine->machineTeams.size()
|
||||
: -1);
|
||||
}
|
||||
}
|
||||
|
||||
void traceServerTeamInfo() {
|
||||
void traceServerTeamInfo() const {
|
||||
int i = 0;
|
||||
|
||||
TraceEvent("ServerTeamInfo", distributorId).detail("Size", teams.size());
|
||||
|
@ -1522,7 +1521,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
}
|
||||
|
||||
void traceMachineInfo() {
|
||||
void traceMachineInfo() const {
|
||||
int i = 0;
|
||||
|
||||
TraceEvent("MachineInfo").detail("Size", machine_info.size());
|
||||
|
@ -1537,7 +1536,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
}
|
||||
|
||||
void traceMachineTeamInfo() {
|
||||
void traceMachineTeamInfo() const {
|
||||
int i = 0;
|
||||
|
||||
TraceEvent("MachineTeamInfo", distributorId).detail("Size", machineTeams.size());
|
||||
|
@ -1551,7 +1550,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
|
||||
// Locality string is hashed into integer, used as KeyIndex
|
||||
// For better understand which KeyIndex is used for locality, we print this info in trace.
|
||||
void traceLocalityArrayIndexName() {
|
||||
void traceLocalityArrayIndexName() const {
|
||||
TraceEvent("LocalityRecordKeyName").detail("Size", machineLocalityMap._keymap->_lookuparray.size());
|
||||
for (int i = 0; i < machineLocalityMap._keymap->_lookuparray.size(); ++i) {
|
||||
TraceEvent("LocalityRecordKeyIndexName")
|
||||
|
@ -1560,7 +1559,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
}
|
||||
|
||||
void traceMachineLocalityMap() {
|
||||
void traceMachineLocalityMap() const {
|
||||
int i = 0;
|
||||
|
||||
TraceEvent("MachineLocalityMap", distributorId).detail("Size", machineLocalityMap.size());
|
||||
|
@ -1581,7 +1580,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
|
||||
// To enable verbose debug info, set shouldPrint to true
|
||||
void traceAllInfo(bool shouldPrint = false) {
|
||||
void traceAllInfo(bool shouldPrint = false) const {
|
||||
|
||||
if (!shouldPrint)
|
||||
return;
|
||||
|
@ -1786,7 +1785,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return addedMachineTeams;
|
||||
}
|
||||
|
||||
bool isMachineTeamHealthy(vector<Standalone<StringRef>> const& machineIDs) {
|
||||
bool isMachineTeamHealthy(vector<Standalone<StringRef>> const& machineIDs) const {
|
||||
int healthyNum = 0;
|
||||
|
||||
// A healthy machine team should have the desired number of machines
|
||||
|
@ -1794,7 +1793,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return false;
|
||||
|
||||
for (auto& id : machineIDs) {
|
||||
auto& machine = machine_info[id];
|
||||
auto& machine = machine_info.at(id);
|
||||
if (isMachineHealthy(machine)) {
|
||||
healthyNum++;
|
||||
}
|
||||
|
@ -1802,22 +1801,22 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return (healthyNum == machineIDs.size());
|
||||
}
|
||||
|
||||
bool isMachineTeamHealthy(Reference<TCMachineTeamInfo> const& machineTeam) {
|
||||
bool isMachineTeamHealthy(TCMachineTeamInfo const& machineTeam) const {
|
||||
int healthyNum = 0;
|
||||
|
||||
// A healthy machine team should have the desired number of machines
|
||||
if (machineTeam->size() != configuration.storageTeamSize)
|
||||
if (machineTeam.size() != configuration.storageTeamSize)
|
||||
return false;
|
||||
|
||||
for (auto& machine : machineTeam->machines) {
|
||||
for (auto& machine : machineTeam.machines) {
|
||||
if (isMachineHealthy(machine)) {
|
||||
healthyNum++;
|
||||
}
|
||||
}
|
||||
return (healthyNum == machineTeam->machines.size());
|
||||
return (healthyNum == machineTeam.machines.size());
|
||||
}
|
||||
|
||||
bool isMachineHealthy(Reference<TCMachineInfo> const& machine) {
|
||||
bool isMachineHealthy(Reference<TCMachineInfo> const& machine) const {
|
||||
if (!machine.isValid() || machine_info.find(machine->machineID) == machine_info.end() ||
|
||||
machine->serversOnMachine.empty()) {
|
||||
return false;
|
||||
|
@ -1834,7 +1833,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
|
||||
// Return the healthy server with the least number of correct-size server teams
|
||||
Reference<TCServerInfo> findOneLeastUsedServer() {
|
||||
Reference<TCServerInfo> findOneLeastUsedServer() const {
|
||||
vector<Reference<TCServerInfo>> leastUsedServers;
|
||||
int minTeams = std::numeric_limits<int>::max();
|
||||
for (auto& server : server_info) {
|
||||
|
@ -1867,11 +1866,11 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
|
||||
// Randomly choose one machine team that has chosenServer and has the correct size
|
||||
// When configuration is changed, we may have machine teams with old storageTeamSize
|
||||
Reference<TCMachineTeamInfo> findOneRandomMachineTeam(Reference<TCServerInfo> chosenServer) {
|
||||
if (!chosenServer->machine->machineTeams.empty()) {
|
||||
Reference<TCMachineTeamInfo> findOneRandomMachineTeam(TCServerInfo const& chosenServer) const {
|
||||
if (!chosenServer.machine->machineTeams.empty()) {
|
||||
std::vector<Reference<TCMachineTeamInfo>> healthyMachineTeamsForChosenServer;
|
||||
for (auto& mt : chosenServer->machine->machineTeams) {
|
||||
if (isMachineTeamHealthy(mt)) {
|
||||
for (auto& mt : chosenServer.machine->machineTeams) {
|
||||
if (isMachineTeamHealthy(*mt)) {
|
||||
healthyMachineTeamsForChosenServer.push_back(mt);
|
||||
}
|
||||
}
|
||||
|
@ -1882,16 +1881,16 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
|
||||
// If we cannot find a healthy machine team
|
||||
TraceEvent("NoHealthyMachineTeamForServer")
|
||||
.detail("ServerID", chosenServer->id)
|
||||
.detail("MachineTeams", chosenServer->machine->machineTeams.size());
|
||||
.detail("ServerID", chosenServer.id)
|
||||
.detail("MachineTeams", chosenServer.machine->machineTeams.size());
|
||||
return Reference<TCMachineTeamInfo>();
|
||||
}
|
||||
|
||||
// A server team should always come from servers on a machine team
|
||||
// Check if it is true
|
||||
bool isOnSameMachineTeam(Reference<TCTeamInfo>& team) {
|
||||
bool isOnSameMachineTeam(TCTeamInfo const& team) const {
|
||||
std::vector<Standalone<StringRef>> machineIDs;
|
||||
for (const auto& server : team->getServers()) {
|
||||
for (const auto& server : team.getServers()) {
|
||||
if (!server->machine.isValid())
|
||||
return false;
|
||||
machineIDs.push_back(server->machine->machineID);
|
||||
|
@ -1899,7 +1898,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
std::sort(machineIDs.begin(), machineIDs.end());
|
||||
|
||||
int numExistance = 0;
|
||||
for (const auto& server : team->getServers()) {
|
||||
for (const auto& server : team.getServers()) {
|
||||
for (const auto& candidateMachineTeam : server->machine->machineTeams) {
|
||||
std::sort(candidateMachineTeam->machineIDs.begin(), candidateMachineTeam->machineIDs.end());
|
||||
if (machineIDs == candidateMachineTeam->machineIDs) {
|
||||
|
@ -1908,14 +1907,14 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
}
|
||||
}
|
||||
return (numExistance == team->size());
|
||||
return (numExistance == team.size());
|
||||
}
|
||||
|
||||
// Sanity check the property of teams in unit test
|
||||
// Return true if all server teams belong to machine teams
|
||||
bool sanityCheckTeams() {
|
||||
bool sanityCheckTeams() const {
|
||||
for (auto& team : teams) {
|
||||
if (isOnSameMachineTeam(team) == false) {
|
||||
if (isOnSameMachineTeam(*team) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1923,7 +1922,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return true;
|
||||
}
|
||||
|
||||
int calculateHealthyServerCount() {
|
||||
int calculateHealthyServerCount() const {
|
||||
int serverCount = 0;
|
||||
for (auto i = server_info.begin(); i != server_info.end(); ++i) {
|
||||
if (!server_status.get(i->first).isUnhealthy()) {
|
||||
|
@ -1933,7 +1932,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return serverCount;
|
||||
}
|
||||
|
||||
int calculateHealthyMachineCount() {
|
||||
int calculateHealthyMachineCount() const {
|
||||
int totalHealthyMachineCount = 0;
|
||||
for (auto& m : machine_info) {
|
||||
if (isMachineHealthy(m.second)) {
|
||||
|
@ -1944,7 +1943,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return totalHealthyMachineCount;
|
||||
}
|
||||
|
||||
std::pair<int64_t, int64_t> calculateMinMaxServerTeamsOnServer() {
|
||||
std::pair<int64_t, int64_t> calculateMinMaxServerTeamsOnServer() const {
|
||||
int64_t minTeams = std::numeric_limits<int64_t>::max();
|
||||
int64_t maxTeams = 0;
|
||||
for (auto& server : server_info) {
|
||||
|
@ -1957,7 +1956,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return std::make_pair(minTeams, maxTeams);
|
||||
}
|
||||
|
||||
std::pair<int64_t, int64_t> calculateMinMaxMachineTeamsOnMachine() {
|
||||
std::pair<int64_t, int64_t> calculateMinMaxMachineTeamsOnMachine() const {
|
||||
int64_t minTeams = std::numeric_limits<int64_t>::max();
|
||||
int64_t maxTeams = 0;
|
||||
for (auto& machine : machine_info) {
|
||||
|
@ -1971,7 +1970,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
|
||||
// Sanity check
|
||||
bool isServerTeamCountCorrect(Reference<TCMachineTeamInfo>& mt) {
|
||||
bool isServerTeamCountCorrect(Reference<TCMachineTeamInfo> const& mt) const {
|
||||
int num = 0;
|
||||
bool ret = true;
|
||||
for (auto& team : teams) {
|
||||
|
@ -1990,7 +1989,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
|
||||
// Find the machine team with the least number of server teams
|
||||
std::pair<Reference<TCMachineTeamInfo>, int> getMachineTeamWithLeastProcessTeams() {
|
||||
std::pair<Reference<TCMachineTeamInfo>, int> getMachineTeamWithLeastProcessTeams() const {
|
||||
Reference<TCMachineTeamInfo> retMT;
|
||||
int minNumProcessTeams = std::numeric_limits<int>::max();
|
||||
|
||||
|
@ -2009,7 +2008,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
|
||||
// Find the machine team whose members are on the most number of machine teams, same logic as serverTeamRemover
|
||||
std::pair<Reference<TCMachineTeamInfo>, int> getMachineTeamWithMostMachineTeams() {
|
||||
std::pair<Reference<TCMachineTeamInfo>, int> getMachineTeamWithMostMachineTeams() const {
|
||||
Reference<TCMachineTeamInfo> retMT;
|
||||
int maxNumMachineTeams = 0;
|
||||
int targetMachineTeamNumPerMachine =
|
||||
|
@ -2033,7 +2032,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
|
||||
// Find the server team whose members are on the most number of server teams
|
||||
std::pair<Reference<TCTeamInfo>, int> getServerTeamWithMostProcessTeams() {
|
||||
std::pair<Reference<TCTeamInfo>, int> getServerTeamWithMostProcessTeams() const {
|
||||
Reference<TCTeamInfo> retST;
|
||||
int maxNumProcessTeams = 0;
|
||||
int targetTeamNumPerServer = (SERVER_KNOBS->DESIRED_TEAMS_PER_SERVER * (configuration.storageTeamSize + 1)) / 2;
|
||||
|
@ -2055,10 +2054,10 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return std::pair<Reference<TCTeamInfo>, int>(retST, maxNumProcessTeams);
|
||||
}
|
||||
|
||||
int getHealthyMachineTeamCount() {
|
||||
int getHealthyMachineTeamCount() const {
|
||||
int healthyTeamCount = 0;
|
||||
for (auto mt = machineTeams.begin(); mt != machineTeams.end(); ++mt) {
|
||||
ASSERT((*mt)->machines.size() == configuration.storageTeamSize);
|
||||
for (const auto& mt : machineTeams) {
|
||||
ASSERT(mt->machines.size() == configuration.storageTeamSize);
|
||||
|
||||
if (isMachineTeamHealthy(*mt)) {
|
||||
++healthyTeamCount;
|
||||
|
@ -2070,7 +2069,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
|
||||
// Each machine is expected to have targetMachineTeamNumPerMachine
|
||||
// Return true if there exists a machine that does not have enough teams.
|
||||
bool notEnoughMachineTeamsForAMachine() {
|
||||
bool notEnoughMachineTeamsForAMachine() const {
|
||||
// If we want to remove the machine team with most machine teams, we use the same logic as
|
||||
// notEnoughTeamsForAServer
|
||||
int targetMachineTeamNumPerMachine =
|
||||
|
@ -2092,7 +2091,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
|
||||
// Each server is expected to have targetTeamNumPerServer teams.
|
||||
// Return true if there exists a server that does not have enough teams.
|
||||
bool notEnoughTeamsForAServer() {
|
||||
bool notEnoughTeamsForAServer() const {
|
||||
// We build more teams than we finally want so that we can use serverTeamRemover() actor to remove the teams
|
||||
// whose member belong to too many teams. This allows us to get a more balanced number of teams per server.
|
||||
// We want to ensure every server has targetTeamNumPerServer teams.
|
||||
|
@ -2164,7 +2163,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
// instead of choosing the least used machine team.
|
||||
// The correlation happens, for example, when we add two new machines, we may always choose the machine
|
||||
// team with these two new machines because they are typically less used.
|
||||
Reference<TCMachineTeamInfo> chosenMachineTeam = findOneRandomMachineTeam(chosenServer);
|
||||
Reference<TCMachineTeamInfo> chosenMachineTeam = findOneRandomMachineTeam(*chosenServer);
|
||||
|
||||
if (!chosenMachineTeam.isValid()) {
|
||||
// We may face the situation that temporarily we have no healthy machine.
|
||||
|
@ -2266,7 +2265,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
}
|
||||
|
||||
// Check if the number of server (and machine teams) is larger than the maximum allowed number
|
||||
void traceTeamCollectionInfo() {
|
||||
void traceTeamCollectionInfo() const {
|
||||
int totalHealthyServerCount = calculateHealthyServerCount();
|
||||
int desiredServerTeams = SERVER_KNOBS->DESIRED_TEAMS_PER_SERVER * totalHealthyServerCount;
|
||||
int maxServerTeams = SERVER_KNOBS->MAX_TEAMS_PER_SERVER * totalHealthyServerCount;
|
||||
|
@ -2436,7 +2435,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
return Void();
|
||||
}
|
||||
|
||||
void noHealthyTeams() {
|
||||
void noHealthyTeams() const {
|
||||
std::set<UID> desiredServerSet;
|
||||
std::string desc;
|
||||
for (auto i = server_info.begin(); i != server_info.end(); ++i) {
|
||||
|
@ -2453,7 +2452,7 @@ struct DDTeamCollection : ReferenceCounted<DDTeamCollection> {
|
|||
.detail("NonFailedServerCount", desiredServerSet.size());
|
||||
}
|
||||
|
||||
bool shouldHandleServer(const StorageServerInterface& newServer) {
|
||||
bool shouldHandleServer(const StorageServerInterface& newServer) const {
|
||||
return (includedDCs.empty() ||
|
||||
std::find(includedDCs.begin(), includedDCs.end(), newServer.locality.dcId()) != includedDCs.end() ||
|
||||
(otherTrackedDCs.present() &&
|
||||
|
|
|
@ -547,14 +547,14 @@ public:
|
|||
}
|
||||
}
|
||||
void clear(K const& k) { set(k, V()); }
|
||||
V const& get(K const& k) {
|
||||
V const& get(K const& k) const {
|
||||
auto it = items.find(k);
|
||||
if (it != items.end())
|
||||
return it->second.value;
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
int count(K const& k) {
|
||||
int count(K const& k) const {
|
||||
auto it = items.find(k);
|
||||
if (it != items.end())
|
||||
return 1;
|
||||
|
@ -566,7 +566,7 @@ public:
|
|||
return destroyOnCancel(this, k, item.change.getFuture());
|
||||
return item.change.getFuture();
|
||||
}
|
||||
std::vector<K> getKeys() {
|
||||
std::vector<K> getKeys() const {
|
||||
std::vector<K> keys;
|
||||
keys.reserve(items.size());
|
||||
for (auto i = items.begin(); i != items.end(); ++i)
|
||||
|
|
Loading…
Reference in New Issue