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

Function findNewProcessForSingleton

fdbserver/ClusterController.actor.cpp:495–513  ·  view source on GitHub ↗

Finds and returns a new process for role

Source from the content-addressed store, hash-verified

493
494// Finds and returns a new process for role
495WorkerDetails findNewProcessForSingleton(ClusterControllerData* self,
496 const ProcessClass::ClusterRole role,
497 std::map<Optional<Standalone<StringRef>>, int>& id_used) {
498 // find new process in cluster for role
499 WorkerDetails newWorker =
500 self->getWorkerForRoleInDatacenter(
501 self->clusterControllerDcId, role, ProcessClass::NeverAssign, self->db.config, id_used, {}, true)
502 .worker;
503
504 // check if master's process is actually better suited for role
505 if (self->onMasterIsBetter(newWorker, role)) {
506 newWorker = self->id_worker[self->masterProcessId.get()].details;
507 }
508
509 // acknowledge that the pid is now potentially used by this role as well
510 id_used[newWorker.interf.locality.processId()]++;
511
512 return newWorker;
513}
514
515// Return best possible fitness for singleton. Note that lower fitness is better.
516ProcessClass::Fitness findBestFitnessForSingleton(const ClusterControllerData* self,

Callers 1

checkBetterSingletonsFunction · 0.85

Calls 2

processIdMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected