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

Function canLaunchSrc

fdbserver/DataDistributionQueue.actor.cpp:421–455  ·  view source on GitHub ↗

Data movement's resource control: Do not overload servers used for the RelocateData return true if servers are not too busy to launch the relocation This ensure source servers will not be overloaded.

Source from the content-addressed store, hash-verified

419// return true if servers are not too busy to launch the relocation
420// This ensure source servers will not be overloaded.
421bool canLaunchSrc(RelocateData& relocation,
422 int teamSize,
423 int singleRegionTeamSize,
424 std::map<UID, Busyness>& busymap,
425 std::vector<RelocateData> cancellableRelocations) {
426 // assert this has not already been launched
427 ASSERT(relocation.workFactor == 0);
428 ASSERT(relocation.src.size() != 0);
429 ASSERT(teamSize >= singleRegionTeamSize);
430
431 // find the "workFactor" for this, were it launched now
432 int workFactor = getSrcWorkFactor(relocation, singleRegionTeamSize);
433 int neededServers = std::min<int>(relocation.src.size(), teamSize - singleRegionTeamSize + 1);
434 if (SERVER_KNOBS->USE_OLD_NEEDED_SERVERS) {
435 neededServers = std::max(1, (int)relocation.src.size() - teamSize + 1);
436 }
437 // see if each of the SS can launch this task
438 for (int i = 0; i < relocation.src.size(); i++) {
439 // For each source server for this relocation, copy and modify its busyness to reflect work that WOULD be
440 // cancelled
441 auto busyCopy = busymap[relocation.src[i]];
442 for (int j = 0; j < cancellableRelocations.size(); j++) {
443 auto& servers = cancellableRelocations[j].src;
444 if (std::count(servers.begin(), servers.end(), relocation.src[i]))
445 busyCopy.removeWork(cancellableRelocations[j].priority, cancellableRelocations[j].workFactor);
446 }
447 // Use this modified busyness to check if this relocation could be launched
448 if (busyCopy.canLaunch(relocation.priority, workFactor)) {
449 --neededServers;
450 if (neededServers == 0)
451 return true;
452 }
453 }
454 return false;
455}
456
457// candidateTeams is a vector containing one team per datacenter, the team(s) DD is planning on moving the shard to.
458bool canLaunchDest(const std::vector<std::pair<Reference<IDataDistributionTeam>, bool>>& candidateTeams,

Callers 1

launchQueuedWorkMethod · 0.85

Calls 7

getSrcWorkFactorFunction · 0.85
countFunction · 0.85
removeWorkMethod · 0.80
canLaunchMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected