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

Function newProcess

fdbrpc/sim2.actor.cpp:1240–1322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1238 // Implement ISimulator interface
1239 void run() override { runLoop(this); }
1240 ProcessInfo* newProcess(const char* name,
1241 IPAddress ip,
1242 uint16_t port,
1243 bool sslEnabled,
1244 uint16_t listenPerProcess,
1245 LocalityData locality,
1246 ProcessClass startingClass,
1247 const char* dataFolder,
1248 const char* coordinationFolder,
1249 ProtocolVersion protocol) override {
1250 ASSERT(locality.machineId().present());
1251 MachineInfo& machine = machines[locality.machineId().get()];
1252 if (!machine.machineId.present())
1253 machine.machineId = locality.machineId();
1254 if (port == 0 && std::string(name) == "remote flow process") {
1255 port = machine.getRandomPort();
1256 }
1257 for (int i = 0; i < machine.processes.size(); i++) {
1258 if (machine.processes[i]->locality.machineId() !=
1259 locality.machineId()) { // SOMEDAY: compute ip from locality to avoid this check
1260 TraceEvent("Sim2Mismatch")
1261 .detail("IP", format("%s", ip.toString().c_str()))
1262 .detail("MachineId", locality.machineId())
1263 .detail("NewName", name)
1264 .detail("ExistingMachineId", machine.processes[i]->locality.machineId())
1265 .detail("ExistingName", machine.processes[i]->name);
1266 ASSERT(false);
1267 }
1268 ASSERT(machine.processes[i]->address.port != port);
1269 }
1270
1271 // This is for async operations on non-durable files.
1272 // These files must live on after process kills for sim purposes.
1273 if (machine.machineProcess == 0) {
1274 NetworkAddress machineAddress(ip, 0, false, false);
1275 machine.machineProcess =
1276 new ProcessInfo("Machine", locality, startingClass, { machineAddress }, this, "", "");
1277 machine.machineProcess->machine = &machine;
1278 }
1279
1280 NetworkAddressList addresses;
1281 addresses.address = NetworkAddress(ip, port, true, sslEnabled);
1282 if (listenPerProcess == 2) { // listenPerProcess is only 1 or 2
1283 addresses.secondaryAddress = NetworkAddress(ip, port + 1, true, false);
1284 }
1285
1286 ProcessInfo* m =
1287 new ProcessInfo(name, locality, startingClass, addresses, this, dataFolder, coordinationFolder);
1288 for (int processPort = port; processPort < port + listenPerProcess; ++processPort) {
1289 NetworkAddress address(ip, processPort, true, sslEnabled && processPort == port);
1290 m->listenerMap[address] = Reference<IListener>(new Sim2Listener(m, address));
1291 addressMap[address] = m;
1292 }
1293 m->machine = &machine;
1294 machine.processes.push_back(m);
1295 currentlyRebootingProcesses.erase(addresses.address);
1296 m->excluded = g_simulator.isExcluded(NetworkAddress(ip, port, true, false));
1297 m->cleared = g_simulator.isCleared(addresses.address);

Callers

nothing calls this directly

Calls 15

TraceEventClass · 0.85
machineIdMethod · 0.80
getRandomPortMethod · 0.80
detailMethod · 0.80
getMethod · 0.65
formatFunction · 0.50
NetworkAddressClass · 0.50
presentMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
toStringMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected