mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-14 18:02:31 +08:00
Improve DataDistribution const-correctness
This commit is contained in:
parent
26a4884eef
commit
19816ccdbf
@ -108,15 +108,15 @@ struct TCMachineInfo : public ReferenceCounted<TCMachineInfo> {
|
||||
machineID = locality.zoneId().get();
|
||||
}
|
||||
|
||||
std::string getServersIDStr() {
|
||||
std::string getServersIDStr() const {
|
||||
std::stringstream ss;
|
||||
if (serversOnMachine.empty()) return "[unset]";
|
||||
|
||||
for (auto& server : serversOnMachine) {
|
||||
for (const auto& server : serversOnMachine) {
|
||||
ss << server->id.toString() << " ";
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
return std::move(ss).str();
|
||||
}
|
||||
};
|
||||
|
||||
@ -144,16 +144,16 @@ public:
|
||||
return machineIDs.size();
|
||||
}
|
||||
|
||||
std::string getMachineIDsStr() {
|
||||
std::string getMachineIDsStr() const {
|
||||
std::stringstream ss;
|
||||
|
||||
if (machineIDs.empty()) return "[unset]";
|
||||
|
||||
for (auto& id : machineIDs) {
|
||||
for (const auto& id : machineIDs) {
|
||||
ss << id.contents().toString() << " ";
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
return std::move(ss).str();
|
||||
}
|
||||
|
||||
bool operator==(TCMachineTeamInfo& rhs) const { return this->machineIDs == rhs.machineIDs; }
|
||||
@ -199,18 +199,18 @@ public:
|
||||
return servers.size();
|
||||
}
|
||||
vector<UID> const& getServerIDs() const override { return serverIDs; }
|
||||
const vector<Reference<TCServerInfo>>& getServers() { return servers; }
|
||||
const vector<Reference<TCServerInfo>>& getServers() const { return servers; }
|
||||
|
||||
std::string getServerIDsStr() const {
|
||||
std::stringstream ss;
|
||||
|
||||
if (serverIDs.empty()) return "[unset]";
|
||||
|
||||
for (auto& id : serverIDs) {
|
||||
for (const auto& id : serverIDs) {
|
||||
ss << id.toString() << " ";
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
return std::move(ss).str();
|
||||
}
|
||||
|
||||
void addDataInFlightToTeam(int64_t delta) override {
|
||||
|
@ -86,7 +86,7 @@ struct GetTeamRequest {
|
||||
GetTeamRequest( bool wantsNewServers, bool wantsTrueBest, bool preferLowerUtilization, bool teamMustHaveShards, double inflightPenalty = 1.0 )
|
||||
: wantsNewServers( wantsNewServers ), wantsTrueBest( wantsTrueBest ), preferLowerUtilization( preferLowerUtilization ), teamMustHaveShards( teamMustHaveShards ), inflightPenalty( inflightPenalty ) {}
|
||||
|
||||
std::string getDesc() {
|
||||
std::string getDesc() const {
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "WantsNewServers:" << wantsNewServers << " WantsTrueBest:" << wantsTrueBest
|
||||
@ -94,11 +94,11 @@ struct GetTeamRequest {
|
||||
<< " teamMustHaveShards:" << teamMustHaveShards
|
||||
<< " inflightPenalty:" << inflightPenalty << ";";
|
||||
ss << "CompleteSources:";
|
||||
for (auto& cs : completeSources) {
|
||||
for (const auto& cs : completeSources) {
|
||||
ss << cs.toString() << ",";
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
return std::move(ss).str();
|
||||
}
|
||||
};
|
||||
|
||||
@ -162,9 +162,9 @@ public:
|
||||
// no longer in the map), the servers will be set for all contained shards and added to all
|
||||
// intersecting shards.
|
||||
|
||||
int getNumberOfShards( UID ssID );
|
||||
int getNumberOfShards(UID ssID) const;
|
||||
vector<KeyRange> getShardsFor( Team team );
|
||||
bool hasShards(Team team);
|
||||
bool hasShards(Team team) const;
|
||||
|
||||
//The first element of the pair is either the source for non-moving shards or the destination team for in-flight shards
|
||||
//The second element of the pair is all previous sources for in-flight shards
|
||||
|
@ -944,13 +944,14 @@ vector<KeyRange> ShardsAffectedByTeamFailure::getShardsFor( Team team ) {
|
||||
return r;
|
||||
}
|
||||
|
||||
bool ShardsAffectedByTeamFailure::hasShards(Team team) {
|
||||
bool ShardsAffectedByTeamFailure::hasShards(Team team) const {
|
||||
auto it = team_shards.lower_bound(std::pair<Team, KeyRange>(team, KeyRangeRef()));
|
||||
return it != team_shards.end() && it->first == team;
|
||||
}
|
||||
|
||||
int ShardsAffectedByTeamFailure::getNumberOfShards( UID ssID ) {
|
||||
return storageServerShards[ssID];
|
||||
int ShardsAffectedByTeamFailure::getNumberOfShards(UID ssID) const {
|
||||
auto it = storageServerShards.find(ssID);
|
||||
return it == storageServerShards.end() ? 0 : it->second;
|
||||
}
|
||||
|
||||
std::pair<vector<ShardsAffectedByTeamFailure::Team>,vector<ShardsAffectedByTeamFailure::Team>> ShardsAffectedByTeamFailure::getTeamsFor( KeyRangeRef keys ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user