MCPcopy Create free account
hub / github.com/apple/foundationdb / getPushLocations

Method getPushLocations

fdbserver/LogSystem.cpp:219–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219void LogSet::getPushLocations(VectorRef<Tag> tags, std::vector<int>& locations, int locationOffset, bool allLocations) {
220 if (locality == tagLocalitySatellite) {
221 for (auto& t : tags) {
222 if (t == txsTag || t.locality == tagLocalityTxs || t.locality == tagLocalityLogRouter) {
223 for (int loc : satelliteTagLocations[t == txsTag ? 0 : t.id + 1]) {
224 locations.push_back(locationOffset + loc);
225 }
226 }
227 }
228 uniquify(locations);
229 return;
230 }
231
232 newLocations.clear();
233 alsoServers.clear();
234 resultEntries.clear();
235
236 if (allLocations) {
237 // special handling for allLocations
238 TraceEvent("AllLocationsSet").log();
239 for (int i = 0; i < logServers.size(); i++) {
240 newLocations.push_back(i);
241 }
242 } else {
243 for (auto& t : tags) {
244 if (locality == tagLocalitySpecial || t.locality == locality || t.locality < 0) {
245 newLocations.push_back(bestLocationFor(t));
246 }
247 }
248 }
249
250 uniquify(newLocations);
251
252 if (newLocations.size())
253 alsoServers.reserve(newLocations.size());
254
255 // Convert locations to the also servers
256 for (auto location : newLocations) {
257 locations.push_back(locationOffset + location);
258 alsoServers.push_back(logEntryArray[location]);
259 }
260
261 // Run the policy, assert if unable to satify
262 bool result = logServerSet->selectReplicas(tLogPolicy, alsoServers, resultEntries);
263 ASSERT(result);
264
265 // Add the new servers to the location array
266 LocalityMap<int>* logServerMap = (LocalityMap<int>*)logServerSet.getPtr();
267 for (auto entry : resultEntries) {
268 locations.push_back(locationOffset + *logServerMap->getObject(entry));
269 }
270 //TraceEvent("GetPushLocations").detail("Policy", tLogPolicy->info())
271 // .detail("Results", locations.size()).detail("Selection", logServerSet->size())
272 // .detail("Included", alsoServers.size()).detail("Duration", timer() - t);
273}
274
275LogPushData::LogPushData(Reference<ILogSystem> logSystem, int tlogCount) : logSystem(logSystem), subsequence(1) {
276 ASSERT(tlogCount > 0);

Callers 2

writeMessageMethod · 0.45

Calls 10

uniquifyFunction · 0.85
TraceEventClass · 0.85
getObjectMethod · 0.80
clearMethod · 0.65
push_backMethod · 0.45
logMethod · 0.45
sizeMethod · 0.45
reserveMethod · 0.45
selectReplicasMethod · 0.45
getPtrMethod · 0.45

Tested by

no test coverage detected