fdbserver/DataDistributionTracker.actor.cpp
// Move keys to destinationTeams by updating shard_teams
Move keys to destinationTeams by updating shard_teams
Move keys to destinationTeams by updating shard_teams
void ShardsAffectedByTeamFailure::moveShard(KeyRangeRef keys, std::vector<Team> destinationTeams) {
	auto ranges = shard_teams.intersectingRanges(keys);
	std::vector<std::pair<std::pair<std::vector<Team>, std::vector<Team>>, KeyRange>> modifiedShards;
	for (auto it = ranges.begin(); it != ranges.end(); ++it) {
		if (keys.contains(it->range())) {
			for (auto t = it->value().first.begin(); t != it->value().first.end(); ++t) {
				erase(*t, it->range());
			}
			std::vector<Team> prevTeams = it->value().second;
			prevTeams.insert(prevTeams.end(), it->value().first.begin(), it->value().first.end());
			uniquify(prevTeams);
			modifiedShards.push_back(std::pair<std::pair<std::vector<Team>, std::vector<Team>>, KeyRange>(
			    std::make_pair(destinationTeams, prevTeams), it->range()));
		} else {
			for (auto& team : destinationTeams) {
				insert(team, it->range());
			}
			auto& teams = it->value();
			teams.second.insert(teams.second.end(), teams.first.begin(), teams.first.end());
			uniquify(teams.second);
			teams.first.insert(teams.first.end(), destinationTeams.begin(), destinationTeams.end());
			uniquify(teams.first);
		}
	}
	for (int i = 0; i < modifiedShards.size(); i++) {
		for (auto& t : modifiedShards[i].first.first) {
			insert(t, modifiedShards[i].second);
		}
		shard_teams.insert(modifiedShards[i].second, modifiedShards[i].first);
	}
	check();
}
void ShardsAffectedByTeamFailure :: moveShard ( KeyRangeRef keys , std :: vector < Team > destinationTeams ) { auto ranges = shard_teams . intersectingRanges ( keys ) ; std :: vector < std :: pair < std :: pair < std :: vector < Team > , std :: vector < Team > > , KeyRange > > modifiedShards ; for ( auto it = ranges . begin ( ) ; it != ranges . end ( ) ; ++ it ) { if ( keys . contains ( it -> range ( ) ) ) { for ( auto t = it -> value ( ) . first . begin ( ) ; t != it -> value ( ) . first . end ( ) ; ++ t ) { erase ( * t , it -> range ( ) ) ; } std :: vector < Team > prevTeams = it -> value ( ) . second ; prevTeams . insert ( prevTeams . end ( ) , it -> value ( ) . first . begin ( ) , it -> value ( ) . first . end ( ) ) ; uniquify ( prevTeams ) ; modifiedShards . push_back ( std :: pair < std :: pair < std :: vector < Team > , std :: vector < Team > > , KeyRange > ( std :: make_pair ( destinationTeams , prevTeams ) , it -> range ( ) ) ) ; } else { for ( auto & team : destinationTeams ) { insert ( team , it -> range ( ) ) ; } auto & teams = it -> value ( ) ; teams . second . insert ( teams . second . end ( ) , teams . first . begin ( ) , teams . first . end ( ) ) ; uniquify ( teams . second ) ; teams . first . insert ( teams . first . end ( ) , destinationTeams . begin ( ) , destinationTeams . end ( ) ) ; uniquify ( teams . first ) ; } } for ( int i = 0 ; i < modifiedShards . size ( ) ; i ++ ) { for ( auto & t : modifiedShards [ i ] . first . first ) { insert ( t , modifiedShards [ i ] . second ) ; } shard_teams . insert ( modifiedShards [ i ] . second , modifiedShards [ i ] . first ) ; } check ( ) ; }
Move keys to destinationTeams by updating shard_teams
Move keys to destinationTeams by updating shard_teams
/*TraceEvent("ShardsAffectedByTeamFailureMove")
	    .detail("KeyBegin", keys.begin)
	    .detail("KeyEnd", keys.end)
	    .detail("NewTeamSize", destinationTeam.size())
	    .detail("NewTeam", describe(destinationTeam));*/ // erase the many teams that were associated with this one shard // save this modification for later insertion // for each range that touches this move, add our team as affecting this range // if we are not in the list of teams associated with this shard, add us in // we cannot modify the KeyRangeMap while iterating through it, so add saved modifications now