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

Function killDataCenter

fdbrpc/sim2.actor.cpp:1970–2108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1968 }
1969
1970 bool killDataCenter(Optional<Standalone<StringRef>> dcId, KillType kt, bool forceKill, KillType* ktFinal) override {
1971 auto ktOrig = kt;
1972 auto processes = getAllProcesses();
1973 std::map<Optional<Standalone<StringRef>>, int> datacenterMachines;
1974 int dcProcesses = 0;
1975
1976 // Switch to a reboot, if anything protected on machine
1977 for (auto& procRecord : processes) {
1978 auto processDcId = procRecord->locality.dcId();
1979 auto processMachineId = procRecord->locality.machineId();
1980 ASSERT(processMachineId.present());
1981 if (processDcId.present() && (processDcId == dcId)) {
1982 if ((kt != Reboot) && (protectedAddresses.count(procRecord->address))) {
1983 kt = Reboot;
1984 TraceEvent(SevWarn, "DcKillChanged")
1985 .detail("DataCenter", dcId)
1986 .detail("KillType", kt)
1987 .detail("OrigKillType", ktOrig)
1988 .detail("Reason", "Datacenter has protected process")
1989 .detail("ProcessAddress", procRecord->address)
1990 .detail("Failed", procRecord->failed)
1991 .detail("Rebooting", procRecord->rebooting)
1992 .detail("Excluded", procRecord->excluded)
1993 .detail("Cleared", procRecord->cleared)
1994 .detail("Process", procRecord->toString());
1995 }
1996 datacenterMachines[processMachineId.get()]++;
1997 dcProcesses++;
1998 }
1999 }
2000
2001 // Check if machine can be removed, if requested
2002 if (!forceKill && ((kt == KillInstantly) || (kt == InjectFaults) || (kt == FailDisk) ||
2003 (kt == RebootAndDelete) || (kt == RebootProcessAndDelete))) {
2004 std::vector<ProcessInfo*> processesLeft, processesDead;
2005 for (auto processInfo : getAllProcesses()) {
2006 if (processInfo->isAvailableClass()) {
2007 if (processInfo->isExcluded() || processInfo->isCleared() || !processInfo->isAvailable()) {
2008 processesDead.push_back(processInfo);
2009 } else if (protectedAddresses.count(processInfo->address) ||
2010 datacenterMachines.find(processInfo->locality.machineId()) == datacenterMachines.end()) {
2011 processesLeft.push_back(processInfo);
2012 } else {
2013 processesDead.push_back(processInfo);
2014 }
2015 }
2016 }
2017
2018 if (!canKillProcesses(processesLeft, processesDead, kt, &kt)) {
2019 TraceEvent(SevWarn, "DcKillChanged")
2020 .detail("DataCenter", dcId)
2021 .detail("KillType", kt)
2022 .detail("OrigKillType", ktOrig);
2023 } else {
2024 TraceEvent("DeadDataCenter")
2025 .detail("DataCenter", dcId)
2026 .detail("KillType", kt)
2027 .detail("DcZones", datacenterMachines.size())

Callers

nothing calls this directly

Calls 15

getAllProcessesFunction · 0.85
TraceEventClass · 0.85
canKillProcessesFunction · 0.85
deterministicRandomFunction · 0.85
killMachineFunction · 0.85
dcIdMethod · 0.80
machineIdMethod · 0.80
detailMethod · 0.80
isAvailableClassMethod · 0.80
random01Method · 0.80
countMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected